Example #1
0
     }
     if (!$ERROR) {
         $PROCESSED["updated_date"] = time();
         $PROCESSED["updated_by"] = $ENTRADA_USER->getID();
         if ($quiz->fromArray($PROCESSED)->update()) {
             /**
              * Delete existing quiz contacts, so we can re-add them.
              */
             Models_Quiz_Contact::deleteContacts($RECORD_ID);
             /**
              * Add the updated quiz authors to the quiz_contacts table.
              */
             if (is_array($PROCESSED["associated_proxy_ids"]) && !empty($PROCESSED["associated_proxy_ids"])) {
                 foreach ($PROCESSED["associated_proxy_ids"] as $proxy_id) {
                     $contact = new Models_Quiz_Contact(array("quiz_id" => $RECORD_ID, "proxy_id" => $proxy_id, "updated_date" => time(), "updated_by" => $ENTRADA_USER->getActiveID()));
                     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());
                     }
                 }
             }
             add_success("The <strong>Quiz Information</strong> section has been successfully updated.");
             application_log("success", "Quiz information for quiz_id [" . $quiz_id . "] was updated.");
         } else {
             add_error("There was a problem updating this quiz. The system administrator was informed of this error; please try again later.");
             application_log("error", "There was an error updating quiz information for quiz_id [" . $quiz_id . "]. Database said: " . $db->ErrorMsg());
         }
     }
     break;
 case 1:
 default:
Example #2
0
 $PROCESSED["created_by"] = $ENTRADA_USER->getID();
 if ($ENTRADA_ACL->amIAllowed('quiz', 'create')) {
     $quiz = new Models_Quiz($PROCESSED);
     if ($quiz->insert()) {
         $new_quiz_id = $quiz->getQuizID();
         if ($new_quiz_id) {
             $quiz_contacts = Models_Quiz_Contact::fetchAllRecords($RECORD_ID);
             if ($quiz_contacts) {
                 foreach ($quiz_contacts as $q) {
                     $contact = $q->toArray();
                     unset($contact["qcontact_id"]);
                     $contact["quiz_id"] = $new_quiz_id;
                     $contact["updated_date"] = time();
                     $contact["updated_by"] = $ENTRADA_USER->getActiveID();
                     $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()) {