protected function updateActivation()
 {
     // 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->getActivationStartDate());
             $item->setTimingEnd($this->getActivationEndDate());
             $item->toggleVisible($this->getActivationVisibility());
         }
         $item->update($this->ref_id);
     }
 }
示例#2
0
 function updateSettings()
 {
     global $ilDB;
     // Due to a bug 3.5.alpha maybe no settings exist. => create default settings
     $query = "SELECT * FROM crs_settings WHERE obj_id = " . $ilDB->quote($this->getId(), 'integer') . " ";
     $res = $ilDB->query($query);
     if (!$res->numRows()) {
         $this->__createDefaultSettings();
     }
     $query = "UPDATE crs_settings SET " . "syllabus = " . $ilDB->quote($this->getSyllabus(), 'text') . ", " . "contact_name = " . $ilDB->quote($this->getContactName(), 'text') . ", " . "contact_responsibility = " . $ilDB->quote($this->getContactResponsibility(), 'text') . ", " . "contact_phone = " . $ilDB->quote($this->getContactPhone(), 'text') . ", " . "contact_email = " . $ilDB->quote($this->getContactEmail(), 'text') . ", " . "contact_consultation = " . $ilDB->quote($this->getContactConsultation(), 'text') . ", " . "activation_type = " . $ilDB->quote(!$this->getOfflineStatus(), 'integer') . ", " . "sub_limitation_type = " . $ilDB->quote($this->getSubscriptionLimitationType(), 'integer') . ", " . "sub_start = " . $ilDB->quote($this->getSubscriptionStart(), 'integer') . ", " . "sub_end = " . $ilDB->quote($this->getSubscriptionEnd(), 'integer') . ", " . "sub_type = " . $ilDB->quote($this->getSubscriptionType(), 'integer') . ", " . "sub_password = "******", " . "sub_mem_limit = " . $ilDB->quote((int) $this->isSubscriptionMembershipLimited(), 'integer') . ", " . "sub_max_members = " . $ilDB->quote($this->getSubscriptionMaxMembers(), 'integer') . ", " . "sub_notify = " . $ilDB->quote($this->getSubscriptionNotify(), 'integer') . ", " . "view_mode = " . $ilDB->quote($this->getViewMode(), 'integer') . ", " . "archive_start = " . $ilDB->quote($this->getArchiveStart(), 'integer') . ", " . "archive_end = " . $ilDB->quote($this->getArchiveEnd(), 'integer') . ", " . "archive_type = " . $ilDB->quote($this->getArchiveType(), 'integer') . ", " . "abo = " . $ilDB->quote($this->getAboStatus(), 'integer') . ", " . "waiting_list = " . $ilDB->quote($this->enabledWaitingList(), 'integer') . ", " . "important = " . $ilDB->quote($this->getImportantInformation(), 'text') . ", " . "show_members = " . $ilDB->quote($this->getShowMembers(), 'integer') . ", " . "latitude = " . $ilDB->quote($this->getLatitude(), 'text') . ", " . "longitude = " . $ilDB->quote($this->getLongitude(), 'text') . ", " . "location_zoom = " . $ilDB->quote($this->getLocationZoom(), 'integer') . ", " . "enable_course_map = " . $ilDB->quote((int) $this->getEnableCourseMap(), 'integer') . ", " . 'session_limit = ' . $ilDB->quote($this->isSessionLimitEnabled(), 'integer') . ', ' . 'session_prev = ' . $ilDB->quote($this->getNumberOfPreviousSessions(), 'integer') . ', ' . 'session_next = ' . $ilDB->quote($this->getNumberOfNextSessions(), 'integer') . ', ' . 'reg_ac_enabled = ' . $ilDB->quote($this->isRegistrationAccessCodeEnabled(), 'integer') . ', ' . 'reg_ac = ' . $ilDB->quote($this->getRegistrationAccessCode(), 'text') . ', ' . 'auto_notification = ' . $ilDB->quote((int) $this->getAutoNotification(), 'integer') . ', ' . 'status_dt = ' . $ilDB->quote((int) $this->getStatusDetermination()) . ', ' . 'mail_members_type = ' . $ilDB->quote((int) $this->getMailToMembersType(), 'integer') . ' ' . "WHERE obj_id = " . $ilDB->quote($this->getId(), 'integer') . "";
     $res = $ilDB->manipulate($query);
     // 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->getActivationUnlimitedStatus()) {
             $item->setTimingType(ilObjectActivation::TIMINGS_DEACTIVATED);
         } else {
             $item->setTimingType(ilObjectActivation::TIMINGS_ACTIVATION);
             $item->setTimingStart($this->getActivationStart());
             $item->setTimingEnd($this->getActivationEnd());
             $item->toggleVisible($this->getActivationVisibility());
         }
         $item->update($this->ref_id);
     }
 }
 function updateTimings()
 {
     include_once 'Services/Object/classes/class.ilObjectActivation.php';
     global $ilAccess, $ilErr;
     if (!$ilAccess->checkAccess('write', '', $this->container_obj->getRefId())) {
         $ilErr->raiseError($this->lng->txt('msg_no_perm_write'), $ilErr->WARNING);
     }
     $this->failed = array();
     // Validate
     $_POST['item'] = is_array($_POST['item']) ? $_POST['item'] : array();
     $all_items = array();
     foreach ($_POST['item'] as $ref_id => $data) {
         $item_obj = new ilObjectActivation();
         $old_data = ilObjectActivation::getItem($ref_id);
         $item_obj->setTimingType($_POST['item_active'][$ref_id]['active'] ? ilObjectActivation::TIMINGS_PRESETTING : ilObjectActivation::TIMINGS_DEACTIVATED);
         $item_obj->setTimingStart($old_data['timing_start']);
         $item_obj->setTimingEnd($old_data['timing_end']);
         $item_obj->setSuggestionStart($this->__toUnix($data["sug_start"]));
         // add duration
         $data['sug_start']['d'] += abs($data['duration_a']);
         $item_obj->setSuggestionEnd($this->__toUnix($data['sug_start'], array('h' => 23, 'm' => 55)));
         $item_obj->setEarliestStart(time());
         $item_obj->setLatestEnd($this->__toUnix($data['lim_end'], array('h' => 23, 'm' => 55)));
         $item_obj->toggleVisible($old_data['visible']);
         $item_obj->toggleChangeable($_POST['item_change'][$ref_id]['change']);
         if (!$item_obj->validateActivation()) {
             $this->failed[$ref_id] = $old_data['title'];
         }
         $all_items[$ref_id] =& $item_obj;
         unset($item_obj);
     }
     if (count($this->failed)) {
         $message = $this->lng->txt('crs_timings_update_error');
         $message .= "<br />" . $this->lng->txt('crs_materials') . ': ';
         $message .= implode(',', $this->failed);
         ilUtil::sendFailure($message);
         $this->editTimings();
         return false;
     }
     // No do update
     foreach ($all_items as $ref_id => $item_obj_new) {
         $item_obj_new->update($ref_id);
     }
     ilUtil::sendSuccess($this->lng->txt('settings_saved'));
     $this->editTimings();
     return false;
 }
示例#4
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);
         }
     }
 }
 /**
  * update
  *
  * @access public
  * @return
  */
 public function update()
 {
     global $ilErr, $ilAccess, $tpl, $ilUser;
     // #19997 - see ilObjectListGUI::insertTimingsCommand()
     if (!$ilAccess->checkAccess('write', '', $this->parent_ref_id) && !$ilAccess->checkAccess('write', '', $this->getItemId())) {
         $ilErr->raiseError($this->lng->txt('permission_denied'), $ilErr->MESSAGE);
     }
     $this->initFormEdit();
     if ($this->form->checkInput()) {
         include_once "Services/Object/classes/class.ilObjectActivation.php";
         $activation = new ilObjectActivation();
         $activation->setTimingType($this->form->getInput('timing_type'));
         $date = $this->form->getInput('timing_start');
         $date = new ilDateTime($date['date'] . ' ' . $date['time'], IL_CAL_DATETIME, $ilUser->getTimeZone());
         $activation->setTimingStart($date->get(IL_CAL_UNIX));
         $date = $this->form->getInput('timing_end');
         $date = new ilDateTime($date['date'] . ' ' . $date['time'], IL_CAL_DATETIME, $ilUser->getTimeZone());
         $activation->setTimingEnd($date->get(IL_CAL_UNIX));
         $date = $this->form->getInput('sug_start');
         $date = new ilDate($date['date'], IL_CAL_DATE);
         $activation->setSuggestionStart($date->get(IL_CAL_UNIX));
         $date = $this->form->getInput('sug_end');
         $date = new ilDate($date['date'], IL_CAL_DATE);
         $activation->setSuggestionEnd($date->get(IL_CAL_UNIX));
         $date = $this->form->getInput('early_start');
         $date = new ilDate($date['date'], IL_CAL_DATE);
         $activation->setEarliestStart($date->get(IL_CAL_UNIX));
         $date = $this->form->getInput('late_end');
         $date = new ilDate($date['date'], IL_CAL_DATE);
         $activation->setLatestEnd($date->get(IL_CAL_UNIX));
         $activation->toggleVisible((bool) $this->form->getInput('visible'));
         $activation->toggleChangeable((bool) $this->form->getInput('changeable'));
         if (!$activation->validateActivation()) {
             ilUtil::sendFailure($ilErr->getMessage());
             $this->form->setValuesByPost();
             $tpl->setContent($this->form->getHTML());
             return false;
         } else {
             $activation->update($this->getItemId());
             ilUtil::sendSuccess($this->lng->txt('settings_saved'), true);
             $this->ctrl->redirect($this, "edit");
         }
     } else {
         $this->form->setValuesByPost();
         $tpl->setContent($this->form->getHTML());
     }
 }
 /**
 * Saves a survey object to a database
 *
 * @access public
 */
 function saveToDb()
 {
     global $ilDB;
     include_once "./Services/RTE/classes/class.ilRTE.php";
     if ($this->getSurveyId() < 1) {
         $next_id = $ilDB->nextId('svy_svy');
         $affectedRows = $ilDB->insert("svy_svy", array("survey_id" => array("integer", $next_id), "obj_fi" => array("integer", $this->getId()), "author" => array("text", $this->getAuthor()), "introduction" => array("clob", ilRTE::_replaceMediaObjectImageSrc($this->getIntroduction(), 0)), "outro" => array("clob", ilRTE::_replaceMediaObjectImageSrc($this->getOutro(), 0)), "status" => array("text", $this->getStatus()), "startdate" => array("text", $this->getStartDate()), "enddate" => array("text", $this->getEndDate()), "evaluation_access" => array("text", $this->getEvaluationAccess()), "invitation" => array("text", $this->getInvitation()), "invitation_mode" => array("text", $this->getInvitationMode()), "complete" => array("text", $this->isComplete()), "created" => array("integer", time()), "anonymize" => array("text", $this->getAnonymize()), "show_question_titles" => array("text", $this->getShowQuestionTitles()), "mailnotification" => array('integer', $this->getMailNotification() ? 1 : 0), "mailaddresses" => array('text', strlen($this->getMailAddresses()) ? $this->getMailAddresses() : NULL), "mailparticipantdata" => array('text', strlen($this->getMailParticipantData()) ? $this->getMailParticipantData() : NULL), "tstamp" => array("integer", time()), "template_id" => array("integer", $this->getTemplate()), "pool_usage" => array("integer", $this->getPoolUsage()), "mode_360" => array("integer", $this->get360Mode()), "mode_360_self_eval" => array("integer", $this->get360SelfEvaluation()), "mode_360_self_rate" => array("integer", $this->get360SelfRaters()), "mode_360_self_appr" => array("integer", $this->get360SelfAppraisee()), "mode_360_results" => array("integer", $this->get360Results()), "mode_360_skill_service" => array("integer", (int) $this->get360SkillService()), "reminder_status" => array("integer", (int) $this->getReminderStatus()), "reminder_start" => array("datetime", $rmd_start), "reminder_end" => array("datetime", $rmd_end), "reminder_frequency" => array("integer", (int) $this->getReminderFrequency()), "reminder_target" => array("integer", (int) $this->getReminderTarget()), "reminder_last_sent" => array("datetime", $this->getReminderLastSent()), "tutor_ntf_status" => array("integer", (int) $this->getTutorNotificationStatus()), "tutor_ntf_reci" => array("text", implode(";", (array) $this->getTutorNotificationRecipients())), "tutor_ntf_target" => array("integer", (int) $this->getTutorNotificationTarget())));
         $this->setSurveyId($next_id);
     } else {
         $affectedRows = $ilDB->update("svy_svy", array("author" => array("text", $this->getAuthor()), "introduction" => array("clob", ilRTE::_replaceMediaObjectImageSrc($this->getIntroduction(), 0)), "outro" => array("clob", ilRTE::_replaceMediaObjectImageSrc($this->getOutro(), 0)), "status" => array("text", $this->getStatus()), "startdate" => array("text", $this->getStartDate()), "enddate" => array("text", $this->getEndDate()), "evaluation_access" => array("text", $this->getEvaluationAccess()), "invitation" => array("text", $this->getInvitation()), "invitation_mode" => array("text", $this->getInvitationMode()), "complete" => array("text", $this->isComplete()), "anonymize" => array("text", $this->getAnonymize()), "show_question_titles" => array("text", $this->getShowQuestionTitles()), "mailnotification" => array('integer', $this->getMailNotification() ? 1 : 0), "mailaddresses" => array('text', strlen($this->getMailAddresses()) ? $this->getMailAddresses() : NULL), "mailparticipantdata" => array('text', strlen($this->getMailParticipantData()) ? $this->getMailParticipantData() : NULL), "tstamp" => array("integer", time()), "template_id" => array("integer", $this->getTemplate()), "pool_usage" => array("integer", $this->getPoolUsage()), "mode_360" => array("integer", $this->get360Mode()), "mode_360_self_eval" => array("integer", $this->get360SelfEvaluation()), "mode_360_self_rate" => array("integer", $this->get360SelfRaters()), "mode_360_self_appr" => array("integer", $this->get360SelfAppraisee()), "mode_360_results" => array("integer", $this->get360Results()), "mode_360_skill_service" => array("integer", (int) $this->get360SkillService()), "reminder_status" => array("integer", $this->getReminderStatus()), "reminder_start" => array("datetime", $rmd_start), "reminder_end" => array("datetime", $rmd_end), "reminder_frequency" => array("integer", $this->getReminderFrequency()), "reminder_target" => array("integer", $this->getReminderTarget()), "reminder_last_sent" => array("datetime", $this->getReminderLastSent()), "tutor_ntf_status" => array("integer", $this->getTutorNotificationStatus()), "tutor_ntf_reci" => array("text", implode(";", (array) $this->getTutorNotificationRecipients())), "tutor_ntf_target" => array("integer", $this->getTutorNotificationTarget())), array("survey_id" => array("integer", $this->getSurveyId())));
     }
     if ($affectedRows) {
         // save questions to db
         $this->saveQuestionsToDb();
     }
     // 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->getActivationStartDate());
             $item->setTimingEnd($this->getActivationEndDate());
             $item->toggleVisible($this->getActivationVisibility());
         }
         $item->update($this->ref_id);
     }
 }
示例#7
0
 protected function doUpdate()
 {
     global $ilDB;
     if ($this->getId()) {
         $fields = $this->propertiesToDB();
         $ilDB->update("il_poll", $fields, array("id" => array("integer", $this->getId())));
         // #14661
         include_once "./Services/Notes/classes/class.ilNote.php";
         ilNote::activateComments($this->getId(), 0, $this->getType(), $this->getShowComments());
         if ($this->ref_id) {
             $activation = new ilObjectActivation();
             $activation->setTimingType($this->getAccessType());
             $activation->setTimingStart($this->getAccessBegin());
             $activation->setTimingEnd($this->getAccessEnd());
             $activation->toggleVisible($this->getAccessVisibility());
             $activation->update($this->ref_id);
         }
     }
 }
 private function addReferences($source, $a_object_data)
 {
     global $tree, $ilLog;
     if (!isset($a_object_data['references']) or !count($a_object_data['references'])) {
         return true;
     }
     $original_id = $source->getRefId();
     foreach ($a_object_data['references'] as $ref_data) {
         $new_ref_id = $ref_id = $original_id;
         if ($tree->getParentId($original_id) != $ref_data['parent_id']) {
             // New reference requested => create it
             $new_ref_id = $source->createReference();
             $source->putInTree($ref_data['parent_id']);
             $source->setPermissions($ref_data['parent_id']);
         }
         if (isset($ref_data['time_target'])) {
             include_once './webservice/soap/classes/class.ilObjectXMLWriter.php';
             include_once './Services/Object/classes/class.ilObjectActivation.php';
             if (!isset($ref_data['time_target']['starting_time'])) {
                 $ref_data['time_target']['starting_time'] = time();
             }
             if (!isset($ref_data['time_target']['ending_time'])) {
                 $ref_data['time_target']['ending_time'] = time();
             }
             $items = new ilObjectActivation();
             $items->toggleChangeable($ref_data['time_target']['changeable']);
             $items->setTimingStart($ref_data['time_target']['starting_time']);
             $items->setTimingEnd($ref_data['time_target']['ending_time']);
             $items->toggleVisible($ref_data['time_target']['timing_visibility']);
             $items->setSuggestionStart($ref_data['time_target']['suggestion_start']);
             $items->setSuggestionEnd($ref_data['time_target']['suggestion_end']);
             $items->setEarliestStart($ref_data['time_target']['earliest_start']);
             $items->setLatestEnd($ref_data['time_target']['latest_end']);
             switch ($ref_data['time_target']['timing_type']) {
                 case ilObjectXMLWriter::TIMING_DEACTIVATED:
                     $ilLog->write(__METHOD__ . ilObjectActivation::TIMINGS_DEACTIVATED . ' ' . $ref_data['time_target']['timing_type']);
                     $items->setTimingType(ilObjectActivation::TIMINGS_DEACTIVATED);
                     break;
                 case ilObjectXMLWriter::TIMING_TEMPORARILY_AVAILABLE:
                     $ilLog->write(__METHOD__ . ilObjectActivation::TIMINGS_ACTIVATION . ' ' . $ref_data['time_target']['timing_type']);
                     $items->setTimingType(ilObjectActivation::TIMINGS_ACTIVATION);
                     break;
                 case ilObjectXMLWriter::TIMING_PRESETTING:
                     $ilLog->write(__METHOD__ . ilObjectActivation::TIMINGS_PRESETTING . ' ' . $ref_data['time_target']['timing_type']);
                     $items->setTimingType(ilObjectActivation::TIMINGS_PRESETTING);
                     break;
             }
             $items->update($new_ref_id);
         }
     }
 }
 /**
  * Parse timing info
  * @param object $a_ref_id
  * @param object $a_parent_id
  * @param object $timing
  * @return 
  */
 protected function parseTiming($a_ref_id, $a_parent_id, $timing)
 {
     $type = (string) $timing['Type'];
     $visible = (string) $timing['Visible'];
     $changeable = (string) $timing['Changeable'];
     include_once './Services/Object/classes/class.ilObjectActivation.php';
     $crs_item = new ilObjectActivation();
     $crs_item->setTimingType($type);
     $crs_item->toggleVisible((bool) $visible);
     $crs_item->toggleChangeable((bool) $changeable);
     foreach ($timing->children() as $sub) {
         switch ((string) $sub->getName()) {
             case 'Start':
                 $dt = new ilDateTime((string) $sub, IL_CAL_DATETIME, ilTimeZone::UTC);
                 $crs_item->setTimingStart($dt->get(IL_CAL_UNIX));
                 break;
             case 'End':
                 $dt = new ilDateTime((string) $sub, IL_CAL_DATETIME, ilTimeZone::UTC);
                 $crs_item->setTimingEnd($dt->get(IL_CAL_UNIX));
                 break;
             case 'SuggestionStart':
                 $dt = new ilDateTime((string) $sub, IL_CAL_DATETIME, ilTimeZone::UTC);
                 $crs_item->setSuggestionStart($dt->get(IL_CAL_UNIX));
                 break;
             case 'SuggestionEnd':
                 $dt = new ilDateTime((string) $sub, IL_CAL_DATETIME, ilTimeZone::UTC);
                 $crs_item->setSuggestionEnd($dt->get(IL_CAL_UNIX));
                 break;
             case 'EarliestStart':
                 $dt = new ilDateTime((string) $sub, IL_CAL_DATETIME, ilTimeZone::UTC);
                 $crs_item->setEarliestStart($dt->get(IL_CAL_UNIX));
                 break;
             case 'LatestEnd':
                 $dt = new ilDateTime((string) $sub, IL_CAL_DATETIME, ilTimeZone::UTC);
                 $crs_item->setLatestEnd($dt->get(IL_CAL_UNIX));
                 break;
         }
     }
     if ($crs_item->getTimingStart()) {
         $crs_item->update($a_ref_id, $a_parent_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);
         }
     }
 }
 /**
 * Saves a survey object to a database
 *
 * @access public
 */
 function saveToDb()
 {
     global $ilDB;
     include_once "./Services/RTE/classes/class.ilRTE.php";
     if ($this->getSurveyId() < 1) {
         $next_id = $ilDB->nextId('svy_svy');
         $affectedRows = $ilDB->insert("svy_svy", array("survey_id" => array("integer", $next_id), "obj_fi" => array("integer", $this->getId()), "author" => array("text", $this->getAuthor()), "introduction" => array("clob", ilRTE::_replaceMediaObjectImageSrc($this->getIntroduction(), 0)), "outro" => array("clob", ilRTE::_replaceMediaObjectImageSrc($this->getOutro(), 0)), "status" => array("text", $this->getStatus()), "startdate" => array("text", $this->getStartDate()), "enddate" => array("text", $this->getEndDate()), "evaluation_access" => array("text", $this->getEvaluationAccess()), "invitation" => array("text", $this->getInvitation()), "invitation_mode" => array("text", $this->getInvitationMode()), "complete" => array("text", $this->isComplete()), "created" => array("integer", time()), "anonymize" => array("text", $this->getAnonymize()), "show_question_titles" => array("text", $this->getShowQuestionTitles()), "mailnotification" => array('integer', $this->getMailNotification() ? 1 : 0), "mailaddresses" => array('text', strlen($this->getMailAddresses()) ? $this->getMailAddresses() : NULL), "mailparticipantdata" => array('text', strlen($this->getMailParticipantData()) ? $this->getMailParticipantData() : NULL), "tstamp" => array("integer", time()), "template_id" => array("integer", $this->getTemplate()), "pool_usage" => array("integer", $this->getPoolUsage())));
         $this->setSurveyId($next_id);
     } else {
         $affectedRows = $ilDB->update("svy_svy", array("author" => array("text", $this->getAuthor()), "introduction" => array("clob", ilRTE::_replaceMediaObjectImageSrc($this->getIntroduction(), 0)), "outro" => array("clob", ilRTE::_replaceMediaObjectImageSrc($this->getOutro(), 0)), "status" => array("text", $this->getStatus()), "startdate" => array("text", $this->getStartDate()), "enddate" => array("text", $this->getEndDate()), "evaluation_access" => array("text", $this->getEvaluationAccess()), "invitation" => array("text", $this->getInvitation()), "invitation_mode" => array("text", $this->getInvitationMode()), "complete" => array("text", $this->isComplete()), "anonymize" => array("text", $this->getAnonymize()), "show_question_titles" => array("text", $this->getShowQuestionTitles()), "mailnotification" => array('integer', $this->getMailNotification() ? 1 : 0), "mailaddresses" => array('text', strlen($this->getMailAddresses()) ? $this->getMailAddresses() : NULL), "mailparticipantdata" => array('text', strlen($this->getMailParticipantData()) ? $this->getMailParticipantData() : NULL), "tstamp" => array("integer", time()), "template_id" => array("integer", $this->getTemplate()), "pool_usage" => array("integer", $this->getPoolUsage())), array("survey_id" => array("integer", $this->getSurveyId())));
     }
     if ($affectedRows) {
         // save questions to db
         $this->saveQuestionsToDb();
     }
     // 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->getActivationStartDate());
             $item->setTimingEnd($this->getActivationEndDate());
             $item->toggleVisible($this->getActivationVisibility());
         }
         $item->update($this->ref_id);
     }
 }
示例#12
0
 protected function doUpdate()
 {
     global $ilDB;
     if ($this->getId()) {
         $fields = $this->propertiesToDB();
         $ilDB->update("il_poll", $fields, array("id" => array("integer", $this->getId())));
         if ($this->ref_id) {
             $activation = new ilObjectActivation();
             $activation->setTimingType($this->getAccessType());
             $activation->setTimingStart($this->getAccessBegin());
             $activation->setTimingEnd($this->getAccessEnd());
             $activation->toggleVisible($this->getAccessVisibility());
             $activation->update($this->ref_id);
         }
     }
 }