function quiz_clone_quiz_result in Quiz 7.6
Same name and namespace in other branches
- 7.5 quiz.module \quiz_clone_quiz_result()
Clone a result, and its correct answers. Do not finish.
1 call to quiz_clone_quiz_result()
- QuizResultController::save in includes/
QuizResultController.class.inc - Save the Quiz result and do any post-processing to the result.
File
- ./
quiz.module, line 3932 - quiz.module Main file for the Quiz module.
Code
function quiz_clone_quiz_result($result_old, $result_new) {
// Re-take all the questions.
foreach ($result_old->layout as $qinfo) {
$question = node_load($qinfo['nid'], $qinfo['vid']);
$quiz_question_response = _quiz_question_response_get_instance($result_old->result_id, $question);
if ($result_new->build_on_last == 'all' || $quiz_question_response
->isCorrect()) {
// Override the existing response.
$quiz_question_response
->setResultId($result_new->result_id);
$quiz_question_response
->save();
}
}
return $result_new;
}