1

I have one quiz with multiple questions.I got a solution for taking quiz with multiple questions.

$account = user_load($quiz_taker_uid);
// Load quiz and question nodes
$quiz = node_load($quiz_nid);
$question = node_load($question_nid);
// Create a new result id
db_query("INSERT INTO {quiz_node_results} (nid, vid, uid, time_start) VALUES (%d, %d, %d, %d)", $quiz->nid, $quiz->vid, $account->uid, time());
$rid = db_last_insert_id('quiz_node_results', 'result_id');
// Submit the answer
$result = quiz_question_evaluate_question($question, $rid, $long_answer_text);
quiz_store_question_result($quiz, $result, array('set_msg' => FALSE));
// Finish the scoring and properly invoke hooks
$score = quiz_end_scoring($quiz, $rid);
quiz_end_actions($quiz, $rid, $score);

change one line in above code // passing the number of question .

quiz_store_question_result($quiz, $result, array('question_data'=>array('number' =>1))); 

But I got another problem. score could not be updated.

1
  • any luck if your tried to update the score programatically?
    – chandru225
    Commented Oct 20, 2016 at 11:05

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.