示例#1
0
 /**
  * Saves a ilObjTest object to a database
  * 
  * @param bool $properties_only
  */
 public function saveToDb($properties_only = FALSE)
 {
     global $tree, $ilDB, $ilPluginAdmin;
     // moved online_status to ilObjectActivation (see below)
     // cleanup RTE images
     $this->cleanupMediaobjectUsage();
     require_once 'Modules/Test/classes/class.ilTestQuestionSetConfigFactory.php';
     $testQuestionSetConfigFactory = new ilTestQuestionSetConfigFactory($tree, $ilDB, $ilPluginAdmin, $this);
     $testQuestionSetConfig = $testQuestionSetConfigFactory->getQuestionSetConfig();
     include_once "./Modules/Test/classes/class.ilObjAssessmentFolder.php";
     if ($this->test_id == -1) {
         // Create new dataset
         $next_id = $ilDB->nextId('tst_tests');
         $ilDB->insert('tst_tests', array('test_id' => array('integer', $next_id), 'obj_fi' => array('integer', $this->getId()), 'author' => array('text', $this->getAuthor()), 'intro_enabled' => array('integer', (int) $this->isIntroductionEnabled()), 'introduction' => array('text', ilRTE::_replaceMediaObjectImageSrc($this->getIntroduction(), 0)), 'finalstatement' => array('text', ilRTE::_replaceMediaObjectImageSrc($this->getFinalStatement(), 0)), 'showinfo' => array('integer', $this->getShowInfo()), 'forcejs' => array('integer', $this->getForceJS()), 'customstyle' => array('text', $this->getCustomStyle()), 'showfinalstatement' => array('integer', $this->getShowFinalStatement()), 'sequence_settings' => array('integer', $this->getSequenceSettings()), 'score_reporting' => array('integer', $this->getScoreReporting()), 'instant_verification' => array('text', $this->getInstantFeedbackSolution()), 'answer_feedback_points' => array('text', $this->getAnswerFeedbackPoints()), 'answer_feedback' => array('text', $this->getAnswerFeedback()), 'anonymity' => array('text', $this->getAnonymity()), 'show_cancel' => array('text', $this->getShowCancel()), 'show_marker' => array('integer', $this->getShowMarker()), 'fixed_participants' => array('text', $this->getFixedParticipants()), 'nr_of_tries' => array('integer', $this->getNrOfTries()), 'kiosk' => array('integer', $this->getKiosk()), 'use_previous_answers' => array('text', $this->getUsePreviousAnswers()), 'title_output' => array('text', $this->getTitleOutput()), 'processing_time' => array('text', $this->getProcessingTime()), 'enable_processing_time' => array('text', $this->getEnableProcessingTime()), 'reset_processing_time' => array('integer', $this->getResetProcessingTime()), 'reporting_date' => array('text', $this->getReportingDate()), 'starting_time_enabled' => array('integer', $this->isStartingTimeEnabled()), 'starting_time' => array('text', $this->getStartingTime()), 'ending_time_enabled' => array('integer', $this->isEndingTimeEnabled()), 'ending_time' => array('text', $this->getEndingTime()), 'complete' => array('text', $this->isComplete($testQuestionSetConfig)), 'ects_output' => array('text', $this->getECTSOutput()), 'ects_a' => array('float', strlen($this->ects_grades["A"]) ? $this->ects_grades["A"] : NULL), 'ects_b' => array('float', strlen($this->ects_grades["B"]) ? $this->ects_grades["B"] : NULL), 'ects_c' => array('float', strlen($this->ects_grades["C"]) ? $this->ects_grades["C"] : NULL), 'ects_d' => array('float', strlen($this->ects_grades["D"]) ? $this->ects_grades["D"] : NULL), 'ects_e' => array('float', strlen($this->ects_grades["E"]) ? $this->ects_grades["E"] : NULL), 'ects_fx' => array('float', $this->getECTSFX()), 'count_system' => array('text', $this->getCountSystem()), 'mc_scoring' => array('text', $this->getMCScoring()), 'score_cutting' => array('text', $this->getScoreCutting()), 'pass_scoring' => array('text', $this->getPassScoring()), 'shuffle_questions' => array('text', $this->getShuffleQuestions()), 'results_presentation' => array('integer', $this->getResultsPresentation()), 'show_summary' => array('integer', $this->getListOfQuestionsSettings()), 'password_enabled' => array('integer', (int) $this->isPasswordEnabled()), 'password' => array('text', $this->getPassword()), 'limit_users_enabled' => array('integer', (int) $this->isLimitUsersEnabled()), 'allowedusers' => array('integer', $this->getAllowedUsers()), 'alloweduserstimegap' => array('integer', $this->getAllowedUsersTimeGap()), 'mailnottype' => array('integer', $this->getMailNotificationType()), 'exportsettings' => array('integer', $this->getExportSettings()), 'certificate_visibility' => array('text', $this->getCertificateVisibility()), 'mailnotification' => array('integer', $this->getMailNotification()), 'created' => array('integer', time()), 'tstamp' => array('integer', time()), 'enabled_view_mode' => array('text', $this->getEnabledViewMode()), 'template_id' => array('integer', $this->getTemplate()), 'pool_usage' => array('integer', $this->getPoolUsage()), 'print_bs_with_res' => array('integer', (int) $this->isBestSolutionPrintedWithResult()), 'obligations_enabled' => array('integer', (int) $this->areObligationsEnabled()), 'offer_question_hints' => array('integer', (int) $this->isOfferingQuestionHintsEnabled()), 'highscore_enabled' => array('integer', (int) $this->getHighscoreEnabled()), 'highscore_anon' => array('integer', (int) $this->getHighscoreAnon()), 'highscore_achieved_ts' => array('integer', (int) $this->getHighscoreAchievedTS()), 'highscore_score' => array('integer', (int) $this->getHighscoreScore()), 'highscore_percentage' => array('integer', (int) $this->getHighscorePercentage()), 'highscore_hints' => array('integer', (int) $this->getHighscoreHints()), 'highscore_wtime' => array('integer', (int) $this->getHighscoreWTime()), 'highscore_own_table' => array('integer', (int) $this->getHighscoreOwnTable()), 'highscore_top_table' => array('integer', (int) $this->getHighscoreTopTable()), 'highscore_top_num' => array('integer', (int) $this->getHighscoreTopNum()), 'online_status' => array('integer', (int) $this->isOnline()), 'specific_feedback' => array('integer', (int) $this->getSpecificAnswerFeedback()), 'autosave' => array('integer', (int) $this->getAutosave()), 'autosave_ival' => array('integer', (int) $this->getAutosaveIval()), 'pass_deletion_allowed' => array('integer', (int) $this->isPassDeletionAllowed()), 'enable_examview' => array('integer', (int) $this->getEnableExamview()), 'show_examview_html' => array('integer', (int) $this->getShowExamviewHtml()), 'show_examview_pdf' => array('integer', (int) $this->getShowExamviewPdf()), 'redirection_mode' => array('integer', (int) $this->getRedirectionMode()), 'redirection_url' => array('text', (string) $this->getRedirectionUrl()), 'enable_archiving' => array('integer', (int) $this->getEnableArchiving()), 'examid_in_test_pass' => array('integer', (int) $this->isShowExamIdInTestPassEnabled()), 'examid_in_test_res' => array('integer', (int) $this->isShowExamIdInTestResultsEnabled()), 'sign_submission' => array('integer', (int) $this->getSignSubmission()), 'question_set_type' => array('text', $this->getQuestionSetType()), 'char_selector_availability' => array('integer', (int) $this->getCharSelectorAvailability()), 'char_selector_definition' => array('text', (string) $this->getCharSelectorDefinition()), 'skill_service' => array('integer', (int) $this->isSkillServiceEnabled()), 'result_tax_filters' => array('text', serialize((array) $this->getResultFilterTaxIds())), 'show_grading_status' => array('integer', (int) $this->isShowGradingStatusEnabled()), 'show_grading_mark' => array('integer', (int) $this->isShowGradingMarkEnabled()), 'inst_fb_answer_fixation' => array('integer', (int) $this->isInstantFeedbackAnswerFixationEnabled())));
         $this->test_id = $next_id;
         if (ilObjAssessmentFolder::_enabledAssessmentLogging()) {
             $this->logAction($this->lng->txtlng("assessment", "log_create_new_test", ilObjAssessmentFolder::_getLogLanguage()));
         }
     } else {
         // Modify existing dataset
         $oldrow = array();
         if (ilObjAssessmentFolder::_enabledAssessmentLogging()) {
             $result = $ilDB->queryF("SELECT * FROM tst_tests WHERE test_id = %s", array('integer'), array($this->test_id));
             if ($result->numRows() == 1) {
                 $oldrow = $ilDB->fetchAssoc($result);
             }
         }
         $ilDB->update('tst_tests', array('author' => array('text', $this->getAuthor()), 'intro_enabled' => array('integer', (int) $this->isIntroductionEnabled()), 'introduction' => array('text', ilRTE::_replaceMediaObjectImageSrc($this->getIntroduction(), 0)), 'finalstatement' => array('text', ilRTE::_replaceMediaObjectImageSrc($this->getFinalStatement(), 0)), 'showinfo' => array('integer', $this->getShowInfo()), 'forcejs' => array('integer', $this->getForceJS()), 'customstyle' => array('text', $this->getCustomStyle()), 'showfinalstatement' => array('integer', $this->getShowFinalStatement()), 'sequence_settings' => array('integer', $this->getSequenceSettings()), 'score_reporting' => array('integer', $this->getScoreReporting()), 'instant_verification' => array('text', $this->getInstantFeedbackSolution()), 'answer_feedback_points' => array('text', $this->getAnswerFeedbackPoints()), 'answer_feedback' => array('text', $this->getGenericAnswerFeedback()), 'anonymity' => array('text', $this->getAnonymity()), 'show_cancel' => array('text', $this->getShowCancel()), 'show_marker' => array('integer', $this->getShowMarker()), 'fixed_participants' => array('text', $this->getFixedParticipants()), 'nr_of_tries' => array('integer', $this->getNrOfTries()), 'kiosk' => array('integer', $this->getKiosk()), 'use_previous_answers' => array('text', $this->getUsePreviousAnswers()), 'title_output' => array('text', $this->getTitleOutput()), 'processing_time' => array('text', $this->getProcessingTime()), 'enable_processing_time' => array('text', $this->getEnableProcessingTime()), 'reset_processing_time' => array('integer', $this->getResetProcessingTime()), 'reporting_date' => array('text', $this->getReportingDate()), 'starting_time_enabled' => array('integer', $this->isStartingTimeEnabled()), 'starting_time' => array('text', $this->getStartingTime()), 'ending_time_enabled' => array('integer', $this->isEndingTimeEnabled()), 'ending_time' => array('text', $this->getEndingTime()), 'complete' => array('text', $this->isComplete($testQuestionSetConfig)), 'ects_output' => array('text', $this->getECTSOutput()), 'ects_a' => array('float', strlen($this->ects_grades["A"]) ? $this->ects_grades["A"] : NULL), 'ects_b' => array('float', strlen($this->ects_grades["B"]) ? $this->ects_grades["B"] : NULL), 'ects_c' => array('float', strlen($this->ects_grades["C"]) ? $this->ects_grades["C"] : NULL), 'ects_d' => array('float', strlen($this->ects_grades["D"]) ? $this->ects_grades["D"] : NULL), 'ects_e' => array('float', strlen($this->ects_grades["E"]) ? $this->ects_grades["E"] : NULL), 'ects_fx' => array('float', $this->getECTSFX()), 'count_system' => array('text', $this->getCountSystem()), 'mc_scoring' => array('text', $this->getMCScoring()), 'score_cutting' => array('text', $this->getScoreCutting()), 'pass_scoring' => array('text', $this->getPassScoring()), 'shuffle_questions' => array('text', $this->getShuffleQuestions()), 'results_presentation' => array('integer', $this->getResultsPresentation()), 'show_summary' => array('integer', $this->getListOfQuestionsSettings()), 'password_enabled' => array('integer', (int) $this->isPasswordEnabled()), 'password' => array('text', $this->getPassword()), 'limit_users_enabled' => array('integer', (int) $this->isLimitUsersEnabled()), 'allowedusers' => array('integer', $this->getAllowedUsers()), 'alloweduserstimegap' => array('integer', $this->getAllowedUsersTimeGap()), 'mailnottype' => array('integer', $this->getMailNotificationType()), 'exportsettings' => array('integer', $this->getExportSettings()), 'print_bs_with_res' => array('integer', (int) $this->isBestSolutionPrintedWithResult()), 'certificate_visibility' => array('text', $this->getCertificateVisibility()), 'mailnotification' => array('integer', $this->getMailNotification()), 'tstamp' => array('integer', time()), 'enabled_view_mode' => array('text', $this->getEnabledViewMode()), 'template_id' => array('text', $this->getTemplate()), 'pool_usage' => array('integer', $this->getPoolUsage()), 'offer_question_hints' => array('integer', (int) $this->isOfferingQuestionHintsEnabled()), 'highscore_enabled' => array('integer', (int) $this->getHighscoreEnabled()), 'highscore_anon' => array('integer', (int) $this->getHighscoreAnon()), 'highscore_achieved_ts' => array('integer', (int) $this->getHighscoreAchievedTS()), 'highscore_score' => array('integer', (int) $this->getHighscoreScore()), 'highscore_percentage' => array('integer', (int) $this->getHighscorePercentage()), 'highscore_hints' => array('integer', (int) $this->getHighscoreHints()), 'highscore_wtime' => array('integer', (int) $this->getHighscoreWTime()), 'highscore_own_table' => array('integer', (int) $this->getHighscoreOwnTable()), 'highscore_top_table' => array('integer', (int) $this->getHighscoreTopTable()), 'highscore_top_num' => array('integer', (int) $this->getHighscoreTopNum()), 'online_status' => array('integer', (int) $this->isOnline()), 'specific_feedback' => array('integer', (int) $this->getSpecificAnswerFeedback()), 'obligations_enabled' => array('integer', (int) $this->areObligationsEnabled()), 'autosave' => array('integer', $this->getAutosave()), 'autosave_ival' => array('integer', $this->getAutosaveIval()), 'pass_deletion_allowed' => array('integer', (int) $this->isPassDeletionAllowed()), 'enable_examview' => array('integer', (int) $this->getEnableExamview()), 'show_examview_html' => array('integer', (int) $this->getShowExamviewHtml()), 'show_examview_pdf' => array('integer', (int) $this->getShowExamviewPdf()), 'redirection_mode' => array('integer', (int) $this->getRedirectionMode()), 'redirection_url' => array('text', (string) $this->getRedirectionUrl()), 'enable_archiving' => array('integer', (int) $this->getEnableArchiving()), 'examid_in_test_pass' => array('integer', (int) $this->isShowExamIdInTestPassEnabled()), 'examid_in_test_res' => array('integer', (int) $this->isShowExamIdInTestResultsEnabled()), 'sign_submission' => array('integer', (int) $this->getSignSubmission()), 'question_set_type' => array('text', $this->getQuestionSetType()), 'char_selector_availability' => array('integer', (int) $this->getCharSelectorAvailability()), 'char_selector_definition' => array('text', (string) $this->getCharSelectorDefinition()), 'skill_service' => array('integer', (int) $this->isSkillServiceEnabled()), 'result_tax_filters' => array('text', serialize((array) $this->getResultFilterTaxIds())), 'show_grading_status' => array('integer', (int) $this->isShowGradingStatusEnabled()), 'show_grading_mark' => array('integer', (int) $this->isShowGradingMarkEnabled()), 'inst_fb_answer_fixation' => array('integer', (int) $this->isInstantFeedbackAnswerFixationEnabled())), array('test_id' => array('integer', (int) $this->getTestId())));
         include_once "./Modules/Test/classes/class.ilObjAssessmentFolder.php";
         if (ilObjAssessmentFolder::_enabledAssessmentLogging()) {
             $logresult = $ilDB->queryF("SELECT * FROM tst_tests WHERE test_id = %s", array('integer'), array($this->getTestId()));
             $newrow = array();
             if ($logresult->numRows() == 1) {
                 $newrow = $ilDB->fetchAssoc($logresult);
             }
             $changed_fields = array();
             foreach ($oldrow as $key => $value) {
                 if (strcmp($oldrow[$key], $newrow[$key]) != 0) {
                     array_push($changed_fields, "{$key}: " . $oldrow[$key] . " => " . $newrow[$key]);
                 }
             }
             $changes = join($changed_fields, ", ");
             if (count($changed_fields) > 0) {
                 $this->logAction($this->lng->txtlng("assessment", "log_modified_test", ilObjAssessmentFolder::_getLogLanguage()) . " [" . $changes . "]");
             }
         }
         if ($this->evalTotalPersons() > 0) {
             // reset the finished status of participants if the nr of test passes did change
             if ($this->getNrOfTries() > 0) {
                 // set all unfinished tests with nr of passes >= allowed passes finished
                 $aresult = $ilDB->queryF("SELECT active_id FROM tst_active WHERE test_fi = %s AND tries >= %s AND submitted = %s", array('integer', 'integer', 'integer'), array($this->getTestId(), $this->getNrOfTries(), 0));
                 while ($row = $ilDB->fetchAssoc($aresult)) {
                     $ilDB->manipulateF("UPDATE tst_active SET submitted = %s, submittimestamp = %s WHERE active_id = %s", array('integer', 'timestamp', 'integer'), array(1, date('Y-m-d H:i:s'), $row["active_id"]));
                 }
                 // set all finished tests with nr of passes < allowed passes not finished
                 $aresult = $ilDB->queryF("SELECT active_id FROM tst_active WHERE test_fi = %s AND tries < %s AND submitted = %s", array('integer', 'integer', 'integer'), array($this->getTestId(), $this->getNrOfTries() - 1, 1));
                 while ($row = $ilDB->fetchAssoc($aresult)) {
                     $ilDB->manipulateF("UPDATE tst_active SET submitted = %s, submittimestamp = %s WHERE active_id = %s", array('integer', 'timestamp', 'integer'), array(0, NULL, $row["active_id"]));
                 }
             } else {
                 // set all finished tests with nr of passes >= allowed passes not finished
                 $aresult = $ilDB->queryF("SELECT active_id FROM tst_active WHERE test_fi = %s AND submitted = %s", array('integer', 'integer'), array($this->getTestId(), 1));
                 while ($row = $ilDB->fetchAssoc($aresult)) {
                     $ilDB->manipulateF("UPDATE tst_active SET submitted = %s, submittimestamp = %s WHERE active_id = %s", array('integer', 'timestamp', 'integer'), array(0, NULL, $row["active_id"]));
                 }
             }
         }
     }
     // moved activation to ilObjectActivation
     if ($this->ref_id) {
         include_once "./Services/Object/classes/class.ilObjectActivation.php";
         ilObjectActivation::getItem($this->ref_id);
         $item = new ilObjectActivation();
         if (!$this->isActivationLimited()) {
             $item->setTimingType(ilObjectActivation::TIMINGS_DEACTIVATED);
         } else {
             $item->setTimingType(ilObjectActivation::TIMINGS_ACTIVATION);
             $item->setTimingStart($this->getActivationStartingTime());
             $item->setTimingEnd($this->getActivationEndingTime());
             $item->toggleVisible($this->getActivationVisibility());
         }
         $item->update($this->ref_id);
     }
     if (!$properties_only) {
         if (PEAR::isError($result)) {
             global $ilias;
             $ilias->raiseError($result->getMessage());
         } else {
             if ($this->getQuestionSetType() == self::QUESTION_SET_TYPE_FIXED) {
                 $this->saveQuestionsToDb();
             }
             $this->mark_schema->saveToDb($this->test_id);
         }
     }
 }
 /**
  * Saves a ilObjTest object to a database
  *
  * @global ilDB $ilDB
  * @param object $db A pear DB object
  * @access public
  */
 function saveToDb($properties_only = FALSE)
 {
     global $ilDB, $ilLog;
     // moved online_status to ilObjectActivation (see below)
     // cleanup RTE images
     $this->cleanupMediaobjectUsage();
     include_once "./Modules/Test/classes/class.ilObjAssessmentFolder.php";
     if ($this->test_id == -1) {
         // Create new dataset
         $next_id = $ilDB->nextId('tst_tests');
         $ilDB->insert('tst_tests', array('test_id' => array('integer', $next_id), 'obj_fi' => array('integer', $this->getId()), 'author' => array('text', $this->getAuthor()), 'introduction' => array('text', ilRTE::_replaceMediaObjectImageSrc($this->getIntroduction(), 0)), 'finalstatement' => array('text', ilRTE::_replaceMediaObjectImageSrc($this->getFinalStatement(), 0)), 'showinfo' => array('integer', $this->getShowInfo()), 'forcejs' => array('integer', $this->getForceJS()), 'customstyle' => array('text', $this->getCustomStyle()), 'showfinalstatement' => array('integer', $this->getShowFinalStatement()), 'sequence_settings' => array('integer', $this->getSequenceSettings()), 'score_reporting' => array('integer', $this->getScoreReporting()), 'instant_verification' => array('text', $this->getInstantFeedbackSolution()), 'answer_feedback_points' => array('text', $this->getAnswerFeedbackPoints()), 'answer_feedback' => array('text', $this->getAnswerFeedback()), 'anonymity' => array('text', $this->getAnonymity()), 'show_cancel' => array('text', $this->getShowCancel()), 'show_marker' => array('integer', $this->getShowMarker()), 'fixed_participants' => array('text', $this->getFixedParticipants()), 'nr_of_tries' => array('integer', $this->getNrOfTries()), 'kiosk' => array('integer', $this->getKiosk()), 'use_previous_answers' => array('text', $this->getUsePreviousAnswers()), 'title_output' => array('text', $this->getTitleOutput()), 'processing_time' => array('text', $this->getProcessingTime()), 'enable_processing_time' => array('text', $this->getEnableProcessingTime()), 'reset_processing_time' => array('integer', $this->getResetProcessingTime()), 'reporting_date' => array('text', $this->getReportingDate()), 'starting_time' => array('text', $this->getStartingTime()), 'ending_time' => array('text', $this->getEndingTime()), 'complete' => array('text', $this->isComplete()), 'ects_output' => array('text', $this->getECTSOutput()), 'ects_a' => array('float', strlen($this->ects_grades["A"]) ? $this->ects_grades["A"] : NULL), 'ects_b' => array('float', strlen($this->ects_grades["B"]) ? $this->ects_grades["B"] : NULL), 'ects_c' => array('float', strlen($this->ects_grades["C"]) ? $this->ects_grades["C"] : NULL), 'ects_d' => array('float', strlen($this->ects_grades["D"]) ? $this->ects_grades["D"] : NULL), 'ects_e' => array('float', strlen($this->ects_grades["E"]) ? $this->ects_grades["E"] : NULL), 'ects_fx' => array('float', $this->getECTSFX()), 'random_test' => array('text', $this->isRandomTest()), 'random_question_count' => array('integer', $this->getRandomQuestionCount()), 'count_system' => array('text', $this->getCountSystem()), 'mc_scoring' => array('text', $this->getMCScoring()), 'score_cutting' => array('text', $this->getScoreCutting()), 'pass_scoring' => array('text', $this->getPassScoring()), 'shuffle_questions' => array('text', $this->getShuffleQuestions()), 'results_presentation' => array('integer', $this->getResultsPresentation()), 'show_summary' => array('integer', $this->getListOfQuestionsSettings()), 'password' => array('text', $this->getPassword()), 'allowedusers' => array('integer', $this->getAllowedUsers()), 'mailnottype' => array('integer', $this->getMailNotificationType()), 'exportsettings' => array('integer', $this->getExportSettings()), 'alloweduserstimegap' => array('integer', $this->getAllowedUsersTimeGap()), 'certificate_visibility' => array('text', $this->getCertificateVisibility()), 'mailnotification' => array('integer', $this->getMailNotification()), 'created' => array('integer', time()), 'tstamp' => array('integer', time()), 'enabled_view_mode' => array('text', $this->getEnabledViewMode()), 'template_id' => array('integer', $this->getTemplate()), 'pool_usage' => array('integer', $this->getPoolUsage()), 'print_bs_with_res' => array('integer', (int) $this->isBestSolutionPrintedWithResult()), 'obligations_enabled' => array('integer', (int) $this->areObligationsEnabled()), 'offer_question_hints' => array('integer', (int) $this->isOfferingQuestionHintsEnabled()), 'highscore_enabled' => array('integer', (int) $this->getHighscoreEnabled()), 'highscore_anon' => array('integer', (int) $this->getHighscoreAnon()), 'highscore_achieved_ts' => array('integer', (int) $this->getHighscoreAchievedTS()), 'highscore_score' => array('integer', (int) $this->getHighscoreScore()), 'highscore_percentage' => array('integer', (int) $this->getHighscorePercentage()), 'highscore_hints' => array('integer', (int) $this->getHighscoreHints()), 'highscore_wtime' => array('integer', (int) $this->getHighscoreWTime()), 'highscore_own_table' => array('integer', (int) $this->getHighscoreOwnTable()), 'highscore_top_table' => array('integer', (int) $this->getHighscoreTopTable()), 'highscore_top_num' => array('integer', (int) $this->getHighscoreTopNum()), 'online_status' => array('integer', (int) $this->isOnline()), 'specific_feedback' => array('integer', (int) $this->getSpecificAnswerFeedback()), 'autosave' => array('integer', (int) $this->getAutosave()), 'autosave_ival' => array('integer', (int) $this->getAutosaveIval()), 'pass_deletion_allowed' => array('integer', (int) $this->isPassDeletionAllowed())));
         $this->test_id = $next_id;
         if (ilObjAssessmentFolder::_enabledAssessmentLogging()) {
             $this->logAction($this->lng->txtlng("assessment", "log_create_new_test", ilObjAssessmentFolder::_getLogLanguage()));
         }
     } else {
         // Modify existing dataset
         $oldrow = array();
         if (ilObjAssessmentFolder::_enabledAssessmentLogging()) {
             $result = $ilDB->queryF("SELECT * FROM tst_tests WHERE test_id = %s", array('integer'), array($this->test_id));
             if ($result->numRows() == 1) {
                 $oldrow = $ilDB->fetchAssoc($result);
             }
         }
         $affectedRows = $ilDB->manipulateF("UPDATE tst_tests SET author = %s, introduction = %s, " . "finalstatement = %s, showinfo = %s, forcejs = %s, customstyle = %s, showfinalstatement = %s, sequence_settings = %s, " . "score_reporting = %s, instant_verification = %s, answer_feedback_points = %s, answer_feedback = %s, anonymity = %s, show_cancel = %s, show_marker = %s, " . "fixed_participants = %s, nr_of_tries = %s, kiosk = %s, use_previous_answers = %s, title_output = %s, processing_time = %s, enable_processing_time = %s, " . "reset_processing_time = %s, reporting_date = %s, starting_time = %s, ending_time = %s, complete = %s, ects_output = %s, ects_a = %s, ects_b = %s, ects_c = %s, ects_d = %s, " . "ects_e = %s, ects_fx = %s, random_test = %s, random_question_count = %s, count_system = %s, mc_scoring = %s, score_cutting = %s, pass_scoring = %s, " . "shuffle_questions = %s, results_presentation = %s, show_summary = %s, password = %s, allowedusers = %s, mailnottype = %s, exportsettings = %s, " . "print_bs_with_res = %s," . "alloweduserstimegap = %s, certificate_visibility = %s, mailnotification = %s, tstamp = %s, enabled_view_mode = %s, template_id = %s, pool_usage = %s, " . "offer_question_hints = %s, highscore_enabled = %s, highscore_anon = %s, highscore_achieved_ts = %s, " . "highscore_score = %s, highscore_percentage = %s, " . "highscore_hints = %s, highscore_wtime = %s, highscore_own_table = %s, highscore_top_table = %s, highscore_top_num = %s, " . "online_status = %s, specific_feedback = %s, obligations_enabled = %s, autosave = %s, autosave_ival = %s, pass_deletion_allowed = %s " . "WHERE test_id = %s", array('text', 'text', 'text', 'integer', 'integer', 'text', 'integer', 'integer', 'integer', 'text', 'text', 'text', 'text', 'text', 'integer', 'text', 'integer', 'integer', 'text', 'text', 'text', 'text', 'integer', 'text', 'text', 'text', 'text', 'text', 'float', 'float', 'float', 'float', 'float', 'float', 'text', 'integer', 'text', 'text', 'text', 'text', 'text', 'integer', 'integer', 'text', 'integer', 'integer', 'integer', 'integer', 'integer', 'text', 'integer', 'integer', 'text', 'text', 'integer', 'integer', 'integer', 'integer', 'integer', 'integer', 'integer', 'integer', 'integer', 'integer', 'integer', 'integer', 'integer', 'integer', 'integer', 'integer', 'integer', 'integer', 'integer'), array($this->getAuthor(), ilRTE::_replaceMediaObjectImageSrc($this->getIntroduction(), 0), ilRTE::_replaceMediaObjectImageSrc($this->getFinalStatement(), 0), $this->getShowInfo(), $this->getForceJS(), $this->getCustomStyle(), $this->getShowFinalStatement(), $this->getSequenceSettings(), $this->getScoreReporting(), $this->getInstantFeedbackSolution(), $this->getAnswerFeedbackPoints(), $this->getGenericAnswerFeedback(), $this->getAnonymity(), $this->getShowCancel(), $this->getShowMarker(), $this->getFixedParticipants(), $this->getNrOfTries(), $this->getKiosk(), $this->getUsePreviousAnswers(), $this->getTitleOutput(), $this->getProcessingTime(), $this->getEnableProcessingTime(), $this->getResetProcessingTime(), $this->getReportingDate(), $this->getStartingTime(), $this->getEndingTime(), $this->isComplete(), $this->getECTSOutput(), strlen($this->ects_grades["A"]) ? $this->ects_grades["A"] : NULL, strlen($this->ects_grades["B"]) ? $this->ects_grades["B"] : NULL, strlen($this->ects_grades["C"]) ? $this->ects_grades["C"] : NULL, strlen($this->ects_grades["D"]) ? $this->ects_grades["D"] : NULL, strlen($this->ects_grades["E"]) ? $this->ects_grades["E"] : NULL, $this->getECTSFX(), $this->isRandomTest(), $this->getRandomQuestionCount(), $this->getCountSystem(), $this->getMCScoring(), $this->getScoreCutting(), $this->getPassScoring(), $this->getShuffleQuestions(), $this->getResultsPresentation(), $this->getListOfQuestionsSettings(), $this->getPassword(), $this->getAllowedUsers(), $this->getMailNotificationType(), $this->getExportSettings(), (int) $this->isBestSolutionPrintedWithResult(), $this->getAllowedUsersTimeGap(), $this->getCertificateVisibility(), $this->getMailNotification(), time(), $this->getEnabledViewMode(), $this->getTemplate(), $this->getPoolUsage(), (int) $this->isOfferingQuestionHintsEnabled(), (int) $this->getHighscoreEnabled(), (int) $this->getHighscoreAnon(), (int) $this->getHighscoreAchievedTS(), (int) $this->getHighscoreScore(), (int) $this->getHighscorePercentage(), (int) $this->getHighscoreHints(), (int) $this->getHighscoreWTime(), (int) $this->getHighscoreOwnTable(), (int) $this->getHighscoreTopTable(), (int) $this->getHighscoreTopNum(), (int) $this->isOnline(), (int) $this->getSpecificAnswerFeedback(), (int) $this->areObligationsEnabled(), $this->getAutosave(), $this->getAutosaveIval(), (int) $this->isPassDeletionAllowed(), $this->getTestId()));
         include_once "./Modules/Test/classes/class.ilObjAssessmentFolder.php";
         if (ilObjAssessmentFolder::_enabledAssessmentLogging()) {
             $logresult = $ilDB->queryF("SELECT * FROM tst_tests WHERE test_id = %s", array('integer'), array($this->getTestId()));
             $newrow = array();
             if ($logresult->numRows() == 1) {
                 $newrow = $ilDB->fetchAssoc($logresult);
             }
             $changed_fields = array();
             foreach ($oldrow as $key => $value) {
                 if (strcmp($oldrow[$key], $newrow[$key]) != 0) {
                     array_push($changed_fields, "{$key}: " . $oldrow[$key] . " => " . $newrow[$key]);
                 }
             }
             $changes = join($changed_fields, ", ");
             if (count($changed_fields) > 0) {
                 $this->logAction($this->lng->txtlng("assessment", "log_modified_test", ilObjAssessmentFolder::_getLogLanguage()) . " [" . $changes . "]");
             }
         }
         if ($this->evalTotalPersons() > 0) {
             // reset the finished status of participants if the nr of test passes did change
             if ($this->getNrOfTries() > 0) {
                 // set all unfinished tests with nr of passes >= allowed passes finished
                 $aresult = $ilDB->queryF("SELECT active_id FROM tst_active WHERE test_fi = %s AND tries >= %s AND submitted = %s", array('integer', 'integer', 'integer'), array($this->getTestId(), $this->getNrOfTries(), 0));
                 while ($row = $ilDB->fetchAssoc($aresult)) {
                     $affectedRows = $ilDB->manipulateF("UPDATE tst_active SET submitted = %s, submittimestamp = %s WHERE active_id = %s", array('integer', 'timestamp', 'integer'), array(1, date('Y-m-d H:i:s'), $row["active_id"]));
                 }
                 // set all finished tests with nr of passes < allowed passes not finished
                 $aresult = $ilDB->queryF("SELECT active_id FROM tst_active WHERE test_fi = %s AND tries < %s AND submitted = %s", array('integer', 'integer', 'integer'), array($this->getTestId(), $this->getNrOfTries() - 1, 1));
                 while ($row = $ilDB->fetchAssoc($aresult)) {
                     $affectedRows = $ilDB->manipulateF("UPDATE tst_active SET submitted = %s, submittimestamp = %s WHERE active_id = %s", array('integer', 'timestamp', 'integer'), array(0, NULL, $row["active_id"]));
                 }
             } else {
                 // set all finished tests with nr of passes >= allowed passes not finished
                 $aresult = $ilDB->queryF("SELECT active_id FROM tst_active WHERE test_fi = %s AND submitted = %s", array('integer', 'integer'), array($this->getTestId(), 1));
                 while ($row = $ilDB->fetchAssoc($aresult)) {
                     $affectedRows = $ilDB->manipulateF("UPDATE tst_active SET submitted = %s, submittimestamp = %s WHERE active_id = %s", array('integer', 'timestamp', 'integer'), array(0, NULL, $row["active_id"]));
                 }
             }
         }
     }
     // moved activation to ilObjectActivation
     if ($this->ref_id) {
         include_once "./Services/Object/classes/class.ilObjectActivation.php";
         ilObjectActivation::getItem($this->ref_id);
         $item = new ilObjectActivation();
         if (!$this->isActivationLimited()) {
             $item->setTimingType(ilObjectActivation::TIMINGS_DEACTIVATED);
         } else {
             $item->setTimingType(ilObjectActivation::TIMINGS_ACTIVATION);
             $item->setTimingStart($this->getActivationStartingTime());
             $item->setTimingEnd($this->getActivationEndingTime());
             $item->toggleVisible($this->getActivationVisibility());
         }
         $item->update($this->ref_id);
     }
     if (!$this->isRandomTest()) {
         $this->removeDuplicatedQuestionpools();
     }
     if (!$properties_only) {
         if (PEAR::isError($result)) {
             global $ilias;
             $ilias->raiseError($result->getMessage());
         } else {
             if (!$this->isRandomTest()) {
                 $this->saveQuestionsToDb();
             }
             $this->mark_schema->saveToDb($this->test_id);
         }
     }
 }