if ($tmp_input) { $PROCESSED["qquestion_ids"][] = $tmp_input; } else { add_error("Invalid quiz question ID"); application_log("API passed [" . $question_id . "] which is an invalid question ID."); } } } else { add_error("No question IDs were passed to delete."); } } else { add_error("Invalid quiz question ID."); } if (!$ERROR && !empty($PROCESSED["qquestion_ids"])) { foreach ($PROCESSED["qquestion_ids"] as $question_id) { $qquestion = Models_Quiz_Question::fetchRowByID($question_id); if (!$qquestion->fromArray(array("question_active" => "0"))->update()) { add_error("Failed to deactivate question."); applicaiton_log("Failed to deactivate quiz question, DB said: " . $db->ErrorMsg()); } } if (!$ERROR) { echo json_encode(array("status" => "success", "data" => array("qquestion_ids" => $PROCESSED["qquestion_ids"]))); } else { echo json_encode(array("status" => "error", "data" => array("Failed to delete quiz question."))); } } break; } break; case "GET":
} </style> <div class="quiz-questions" id="quiz-content-questions-holder"> <ol class="questions" id="quiz-questions-list"> <?php foreach ($questions as $q) { if ($q->getQuestionTypeID() != 3) { $question = $q->toArray(); $question_correct = false; $question_feedback = ""; echo "<li id=\"question_" . $question["qquestion_id"] . "\" class=\"" . ($question["questiontype_id"] == 4 ? "group" : "") . "\">"; echo "\t<div class=\"question noneditable\">\n"; echo "\t\t<span id=\"question_text_" . $question["qquestion_id"] . "\" class=\"question\">" . clean_input($question["question_text"], "trim") . "</span>"; echo "\t</div>\n"; if ($q->getQuestionTypeID() == "4") { $grouped_qquestions = Models_Quiz_Question::fetchGroupedQuestions($q->getQquestionID()); if ($grouped_qquestions) { echo "<ul>"; foreach ($grouped_qquestions as $q) { $question = $q->toArray(); echo "<li id=\"question_" . $question["qquestion_id"] . "\">"; echo "\t<div class=\"question noneditable\">\n"; echo "\t\t<span id=\"question_text_" . $question["qquestion_id"] . "\" class=\"question\">" . clean_input($question["question_text"], "trim") . "</span>"; echo "\t</div>\n"; $responses = Models_Quiz_Question_Response::fetchAllRecords($q->getQquestionID()); if ($responses) { echo "\t<ul class=\"responses\">\n"; foreach ($responses as $r) { $response = $r->toArray(); $response_selected = false; $response_correct = false;
$_SESSION[APPLICATION_IDENTIFIER]["tmp"]["post_action"] = "index"; 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()); }
</div> <div class="row-fluid"> <button href="#delete-quiz-confirmation-box" id="quiz-control-delete" class="btn btn-danger">Delete Quiz</button> <button href="#copy-quiz-confirmation-box" id="quiz-control-copy" class="btn">Copy Quiz</button> <div class="pull-right"> <input type="submit" class="btn btn-primary" value="Save Changes" /> </div> </div> </form> </div> <a name="quiz_questions_section"></a> <h2 id="quiz_questions_section" title="Quiz Content Questions">Quiz Questions</h2> <div id="quiz-content-questions"> <?php $questions = Models_Quiz_Question::fetchAllRecords($RECORD_ID); if ($ALLOW_QUESTION_MODIFICATIONS) { $question_types = Models_Quiz_QuestionType::fetchAllRecords(); if ($question_types) { ?> <div class="row-fluid space-below"> <?php if (isset($questions) && $questions) { ?> <a href="#delete-question-confirmation-box" class="btn btn-danger" id="delete-questions" data-toggle="modal">Delete Selected</a> <a href="#" class="btn" id="group-questions">Group Selected</a> <?php } ?> <div class="pull-right"> <div class="btn-group">
$q_c = new Models_Quiz_Contact($contact); 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 {
} ol.questions { padding-left:20px; } </style> <?php $problem_pages = array(); $page_counter = 1; $counter = 1; $quiz_markup = ""; $used_qquestion_group_ids = array(); foreach ($questions as $question) { if ($question->getQquestionGroupID()) { if (!in_array($question->getQquestionGroupID(), $used_qquestion_group_ids)) { $used_qquestion_group_ids[] = $question->getQquestionGroupID(); $grouped_qquestions = Models_Quiz_Question::fetchGroupedQuestions($question->getQuizID(), $question->getQquestionGroupID()); if ($grouped_qquestions) { $quiz_markup .= "</ol><ol class=\"questions group\" start=\"" . $counter . "\">"; foreach ($grouped_qquestions as $question) { $quiz_markup .= "<li>" . clean_input($question->getQuestionText(), "trim"); $responses = Models_Quiz_Question_Response::fetchAllRecords($question->getQquestionID()); if ($responses) { $quiz_markup .= "<ul class=\"responses\">"; foreach ($responses as $r) { $response = $r->toArray(); $quiz_markup .= "<li class=\"row-fluid\">"; $quiz_markup .= "\t<span class=\"span1\"><input type=\"radio\" id=\"response_" . $question->getQquestionID() . "_" . $response["qqresponse_id"] . "\" name=\"responses[" . $question->getQquestionID() . "]\" value=\"" . $response["qqresponse_id"] . "\"" . ($ajax_load_progress[$question->getQquestionID()] == $response["qqresponse_id"] ? " checked=\"checked\"" : "") . " onclick=\"((this.checked == true) ? storeResponse('" . $question->getQquestionID() . "', '" . $response["qqresponse_id"] . "') : false)\" /></span>"; $quiz_markup .= "\t<label class=\"span11\" for=\"response_" . $question->getQquestionID() . "_" . $response["qqresponse_id"] . "\">" . clean_input($response["response_text"], $response["response_is_html"] == 1 ? "trim" : "encode") . "</label>"; $quiz_markup .= "</li>\n"; } $quiz_markup .= "</ul>";
* */ if (!defined("PARENT_INCLUDED") || !defined("IN_QUIZZES")) { exit; } elseif (!isset($_SESSION["isAuthorized"]) || !$_SESSION["isAuthorized"]) { header("Location: " . ENTRADA_URL); exit; } elseif (!$ENTRADA_ACL->amIAllowed('quizquestion', 'update', false)) { $ONLOAD[] = "setTimeout('window.location=\\'" . ENTRADA_URL . "/admin/" . $MODULE . "\\'', 15000)"; $ERROR++; $ERRORSTR[] = "Your account does not have the permissions required to use this feature of this module.<br /><br />If you believe you are receiving this message in error please contact <a href=\"mailto:" . html_encode($AGENT_CONTACTS["administrator"]["email"]) . "\">" . html_encode($AGENT_CONTACTS["administrator"]["name"]) . "</a> for assistance."; echo display_error(); application_log("error", "Group [" . $_SESSION["permissions"][$ENTRADA_USER->getAccessId()]["group"] . "] and role [" . $_SESSION["permissions"][$ENTRADA_USER->getAccessId()]["role"] . "] does not have access to this module [" . $MODULE . "]"); } else { if ($RECORD_ID) { $question = Models_Quiz_Question::fetchRowByID($RECORD_ID); $quiz_record = Models_Quiz::fetchRowByID($question->getQuizID()); if ($quiz_record && $ENTRADA_ACL->amIAllowed(new QuizResource($quiz_record->getQuizID()), "update")) { if ($ALLOW_QUESTION_MODIFICATIONS) { $BREADCRUMB[] = array("url" => ENTRADA_URL . "/admin/" . $MODULE . "?section=edit&id=" . $quiz_record->getQuizID(), "title" => limit_chars($quiz_record->getQuizTitle(), 32)); $BREADCRUMB[] = array("url" => ENTRADA_URL . "/admin/" . $MODULE . "?section=edit-question&id=" . $RECORD_ID, "title" => "Edit Quiz Question"); /** * Load the rich text editor. */ load_rte("advanced"); // Error Checking switch ($STEP) { case 2: /** * Required field "questiontype_id" / Question Type * Currently only multile choice questions are supported, although
<tr> <th width="5%"> </th> <th width="30%">Quiz Title</th> <th width="25%">Author</th> <th width="15%">Questions</th> <th width="25%">Last Updated</th> </tr> </thead> <tbody> <?php foreach ($delete_quizzes as $quiz) { echo "<tr>\n"; echo "\t<td class=\"modified\"><input class=\"delete-control\" type=\"checkbox\" name=\"delete[]\" value=\"" . (int) $quiz->getQuizID() . "\" checked=\"checked\" /></td>\n"; echo "\t<td class=\"title\"><a href=\"" . ENTRADA_RELATIVE . "/admin/" . $MODULE . "?section=edit&id=" . (int) $quiz->getQuizID() . "\">" . html_encode($quiz->getQuizTitle()) . "</a></td>\n"; echo "\t<td class=\"author\"><a href=\"" . ENTRADA_RELATIVE . "/admin/" . $MODULE . "?section=edit&id=" . (int) $quiz->getQuizID() . "\">" . html_encode($quiz->getQuizAuthor()->getFullname()) . "</a></td>\n"; echo "\t<td class=\"questions\"><a href=\"" . ENTRADA_RELATIVE . "/admin/" . $MODULE . "?section=edit&id=" . (int) $quiz->getQuizID() . "\">" . count(Models_Quiz_Question::fetchAllRecords($quiz->getQuizID())) . "</a></td>\n"; echo "\t<td class=\"updated\"><a href=\"" . ENTRADA_RELATIVE . "/admin/" . $MODULE . "?section=edit&id=" . (int) $quiz->getQuizID() . "\">" . date("Y-m-d g:ia", $quiz->getUpdatedDate()) . "</a></td>\n"; echo "</tr>\n"; } ?> </tbody> </table> <div class="row-fluid"> <a href="<?php echo ENTRADA_RELATIVE . "/admin/" . $MODULE; ?> " class="btn">Cancel</a> <input id="delete-quizzes" type="submit" class="btn btn-danger pull-right" value="Confirm Delete" /> </div> </form> <?php
public function getQuizQuestions() { return Models_Quiz_Question::fetchAllRecords($this->quiz_id); }