Example #1
0
 * @copyright Copyright 2010 Queen's University. All Rights Reserved.
 *
*/
if (!defined("PARENT_INCLUDED") || !defined("IN_QUIZZES")) {
    exit;
} elseif (!isset($_SESSION["isAuthorized"]) || !$_SESSION["isAuthorized"]) {
    header("Location: " . ENTRADA_URL);
    exit;
} elseif (!$ENTRADA_ACL->amIAllowed('quiz', 'update', false)) {
    $ONLOAD[] = "setTimeout('window.location=\\'" . ENTRADA_URL . "/admin/" . $MODULE . "\\'', 15000)";
    $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) {
        $quiz = Models_Quiz::fetchRowByID($RECORD_ID);
        $PROCESSED = $quiz->toArray();
        if ($PROCESSED && $ENTRADA_ACL->amIAllowed(new QuizResource($PROCESSED["quiz_id"]), "update")) {
            $BREADCRUMB[] = array("url" => ENTRADA_URL . "/admin/" . $MODULE . "?section=edit&id=" . $RECORD_ID, "title" => limit_chars($PROCESSED["quiz_title"], 32));
            $PROCESSED["associated_proxy_ids"] = array();
            /**
             * Load the rich text editor.
             */
            load_rte();
            // Error Checking
            switch ($STEP) {
                case 2:
                    /**
                     * Required field "quiz_title" / Quiz Title.
                     */
                    if (isset($_POST["quiz_title"]) && ($tmp_input = clean_input($_POST["quiz_title"], array("notags", "trim")))) {
     foreach ($question_types as $question_type) {
         $question_type_ids[] = $question_type->getQuestionTypeID();
     }
 }
 if ($question_types && isset($_GET["type"]) && in_array($_GET["type"], $question_type_ids)) {
     $set_type = true;
     $type = clean_input($_GET["type"], "numeric");
 } else {
     $set_type = false;
     $type = 1;
 }
 if (isset($_GET["qquestion_id"]) && ($tmp_input = clean_input($_GET["qquestion_id"], "int"))) {
     $qquestion_group_id = $tmp_input;
 }
 if ($RECORD_ID) {
     $quiz_record = Models_Quiz::fetchRowByID($RECORD_ID);
     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=" . $RECORD_ID, "title" => limit_chars($quiz_record->getQuizTitle(), 32));
             $BREADCRUMB[] = array("url" => ENTRADA_URL . "/admin/" . $MODULE . "?section=add-question&id=" . $RECORD_ID, "title" => "Add Quiz Question");
             /**
              * Load the rich text editor.
              */
             load_rte("advanced");
             if ($type == "3") {
                 $STEP = 2;
                 $_POST["question_text"] = "Page Break";
                 $_POST["questiontype_id"] = $type;
                 $_POST["post_action"] = "content";
             }
             // Error Checking
Example #3
0
                         }
                         $quiz_contacts = Models_Quiz_Contact::fetchAllRecords($new_quiz_id);
                         if ($quiz_contacts) {
                             foreach ($quiz_contacts as $quiz_contact) {
                                 $quiz_contact->delete();
                             }
                         }
                         $quiz = Models_Quiz::fetchRowByID($new_quiz_id);
                         if ($quiz) {
                             $quiz->delete();
                         }
                         add_error("There was a problem creating the new quiz at this time. The system administrator was informed of this error; please try again later.");
                     }
                 }
             } else {
                 $quiz = Models_Quiz::fetchRowByID($new_quiz_id);
                 if ($quiz) {
                     $quiz->delete();
                 }
                 add_error("Unable to copy the existing quiz authors from the original quiz. The system administrator was informed of this error; please try again later.");
                 application_log("error", "Unable to copy any quiz authors when attempting to copy quiz_id [" . $RECORD_ID . "] authors to quiz_id [" . $new_quiz_id . "]. Database said: " . $db->ErrorMsg());
             }
         } else {
             add_error("There was a problem creating the new quiz at this time. The system administrator was informed of this error; please try again later.");
             application_log("error", "There was an error inserting a copied quiz, as there was no new_quiz_id available from Insert_Id(). Database said: " . $db->ErrorMsg());
         }
     } else {
         add_error("There was a problem creating the new quiz at this time. The system administrator was informed of this error; please try again later.");
         application_log("error", "There was an error inserting a new copied quiz. Database said: " . $db->ErrorMsg());
     }
 } else {
Example #4
0
*/
if (!defined("PARENT_INCLUDED") || !defined("IN_QUIZZES")) {
    exit;
} elseif (!isset($_SESSION["isAuthorized"]) || !(bool) $_SESSION["isAuthorized"]) {
    header("Location: " . ENTRADA_RELATIVE);
    exit;
} elseif (!$ENTRADA_ACL->amIAllowed("quiz", "update", false)) {
    add_error("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 {
    $HEAD[] = "<script type=\"text/javascript\" src=\"" . ENTRADA_URL . "/javascript/jquery/jquery.dataTables.min.js" . "\"></script>";
    if ($ENTRADA_USER->getActiveRole() != "admin") {
        $quizzes = Models_Quiz::fetchAllRecordsByProxyID($ENTRADA_USER->getID());
    } else {
        $quizzes = Models_Quiz::fetchAllRecords();
    }
    $i = 0;
    foreach ($quizzes as $quiz) {
        $quiz_data[$i]["quiz_id"] = $quiz->getQuizID();
        $quiz_data[$i]["quiz_title"] = $quiz->getQuizTitle();
        $quiz_data[$i]["question_total"] = count($quiz->getQuizQuestions());
        $quiz_data[$i]["quiz_status"] = $quiz->getQuizActive() ? "Active" : "Disabled";
        $quiz_data[$i]["quiz_author"] = $quiz->getQuizAuthor() ? $quiz->getQuizAuthor()->getFullName(false) : "";
        $quiz_data[$i]["updated_date"] = $quiz->getUpdatedDate();
        $i++;
    }
    if (isset($_GET["ajax"]) && $_GET["ajax"] && isset($_GET["method"]) && $_GET["method"] == "list") {
        ob_clear_open_buffers();
        $output = array("aaData" => array());
        $count = 0;
Example #5
0
         case "index":
             $_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"] = "new";
 }
 if (!$ERROR) {
     $PROCESSED["updated_date"] = time();
     $PROCESSED["updated_by"] = $ENTRADA_USER->getID();
     $PROCESSED["created_by"] = $ENTRADA_USER->getID();
     $quiz = new Models_Quiz($PROCESSED);
     if ($quiz->insert()) {
         $quiz_id = $quiz->getQuizID();
         if ($quiz_id) {
             /**
              * Add the quiz authors to the quiz_contacts table.
              */
             if (is_array($PROCESSED["associated_proxy_ids"]) && count($PROCESSED["associated_proxy_ids"])) {
                 foreach ($PROCESSED["associated_proxy_ids"] as $proxy_id) {
                     $contact = new Models_Quiz_Contact(array("quiz_id" => $quiz_id, "proxy_id" => $proxy_id, "updated_date" => time(), "updated_by" => $ENTRADA_USER->getID()));
                     if (!$contact->insert()) {
                         add_error("There was an error while trying to attach a <strong>Quiz Author</strong> to this quiz.<br /><br />The system administrator was informed of this error; please try again later.");
                         application_log("error", "Unable to insert a new quiz_contact record while adding a new quiz. Database said: " . $db->ErrorMsg());
                     }
                 }
             }
*/
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
                         * this is something we will be expanding on shortly.