break; case "content": default: $_SESSION[APPLICATION_IDENTIFIER]["tmp"]["post_action"] = "content"; break; } } else { $_SESSION[APPLICATION_IDENTIFIER]["tmp"]["post_action"] = "new1"; } if (!$ERROR) { if (isset($type) && isset($qquestion_group_id) && $type == 1) { $PROCESSED["qquestion_group_id"] = $qquestion_group_id; } if ($ENTRADA_ACL->amIAllowed(new QuizQuestionResource(null, $quiz_record->getQuizID()), 'create')) { $quiz_question = new Models_Quiz_Question($PROCESSED); if ($quiz_question->insert()) { $qquestion_id = $quiz_question->getQquestionID(); if ($qquestion_id) { /** * Add the quiz question responses to the quiz_question_responses table. * Ummm... we really need to switch to InnoDB tables to get transaction support. */ if (is_array($PROCESSED["quiz_question_responses"]) && count($PROCESSED["quiz_question_responses"])) { foreach ($PROCESSED["quiz_question_responses"] as $quiz_question_response) { $PROCESSED = array("qquestion_id" => $qquestion_id, "response_text" => $quiz_question_response["response_text"], "response_order" => $quiz_question_response["response_order"], "response_correct" => $quiz_question_response["response_correct"], "response_is_html" => $quiz_question_response["response_is_html"], "response_feedback" => $quiz_question_response["response_feedback"]); $quiz_question_response = new Models_Quiz_Question_Response($PROCESSED); if (!$quiz_question_response->insert()) { add_error("There was an error while trying to attach a <strong>Question Response</strong> to this quiz question.<br /><br />The system administrator was informed of this error; please try again later."); application_log("error", "Unable to insert a new quiz_question_responses record while adding a new quiz question [" . $qquestion_id . "] to quiz_id [" . $RECORD_ID . "]. Database said: " . $db->ErrorMsg()); } }
if (!$q_c->insert()) { $ERROR++; } } } if (!$ERROR) { $questions = Models_Quiz_Question::fetchAllRecords($RECORD_ID); if ($questions) { $new_qquestion_ids = array(); foreach ($questions as $q) { $question = $q->toArray(); $old_qquestion_id = $question["qquestion_id"]; unset($question["qquestion_id"]); $question["quiz_id"] = $new_quiz_id; $new_question = new Models_Quiz_Question($question); if ($new_question->insert()) { $new_qquestion_id = $new_question->getQquestionID(); if ($new_question->getQuestiontypeID() == "1" || $new_question->getQuestiontypeID() == "4") { $responses = Models_Quiz_Question_Response::fetchAllRecords($old_qquestion_id); foreach ($responses as $r) { $response_data = $r->toArray(); unset($response_data["qqresponse_id"]); $response_data["qquestion_id"] = $new_qquestion_id; $response = new Models_Quiz_Question_Response($response_data); if (!$response->insert()) { $ERROR++; } } } } else { application_log("error", "Unable to insert new quiz_questions record when attempting to copy quiz_id [" . $RECORD_ID . "]. Database said: " . $db->ErrorMsg());