/** * Given an object containing all the necessary data, * (defined by the form in mod_form.php) this function * will update an existing instance with new data. * * @param object $quiz the data that came from the form. * @return mixed true on success, false or a string error message on failure. */ function quiz_update_instance($quiz, $mform) { global $CFG, $DB; // Process the options from the form. $result = quiz_process_options($quiz); if ($result && is_string($result)) { return $result; } $oldquiz = $DB->get_record('quiz', array('id' => $quiz->instance)); // Repaginate, if asked to. if (!$quiz->shufflequestions && !empty($quiz->repaginatenow)) { require_once $CFG->dirroot . '/mod/quiz/locallib.php'; $quiz->questions = quiz_repaginate(quiz_clean_layout($oldquiz->questions, true), $quiz->questionsperpage); } unset($quiz->repaginatenow); // Update the database. $quiz->id = $quiz->instance; $DB->update_record('quiz', $quiz); // Do the processing required after an add or an update. quiz_after_add_or_update($quiz); if ($oldquiz->grademethod != $quiz->grademethod) { require_once $CFG->dirroot . '/mod/quiz/locallib.php'; $quiz->sumgrades = $oldquiz->sumgrades; $quiz->grade = $oldquiz->grade; quiz_update_all_final_grades($quiz); quiz_update_grades($quiz); } // Delete any previous preview attempts quiz_delete_previews($quiz); return true; }
/** * Given an object containing all the necessary data, * (defined by the form in mod.html) this function * will update an existing instance with new data. * * @param object $quiz the data that came from the form. * @return mixed true on success, false or a string error message on failure. */ function quiz_update_instance($quiz) { // Process the options from the form. $result = quiz_process_options($quiz); if ($result && is_string($result)) { return $result; } // Update the database. $quiz->id = $quiz->instance; if (!update_record("quiz", $quiz)) { return false; // some error occurred } // Do the processing required after an add or an update. quiz_after_add_or_update($quiz); // Delete any previous preview attempts delete_records('quiz_attempts', 'preview', '1', 'quiz', $quiz->id); return true; }
/** * Given an object containing all the necessary data, * (defined by the form in mod_form.php) this function * will update an existing instance with new data. * * @param object $quiz the data that came from the form. * @return mixed true on success, false or a string error message on failure. */ function quiz_update_instance($quiz, $mform) { global $CFG, $DB; require_once $CFG->dirroot . '/mod/quiz/locallib.php'; // Process the options from the form. $result = quiz_process_options($quiz); if ($result && is_string($result)) { return $result; } // Get the current value, so we can see what changed. $oldquiz = $DB->get_record('quiz', array('id' => $quiz->instance)); // We need two values from the existing DB record that are not in the form, // in some of the function calls below. $quiz->sumgrades = $oldquiz->sumgrades; $quiz->grade = $oldquiz->grade; // Repaginate, if asked to. if (!$quiz->shufflequestions && !empty($quiz->repaginatenow)) { $quiz->questions = quiz_repaginate(quiz_clean_layout($oldquiz->questions, true), $quiz->questionsperpage); } unset($quiz->repaginatenow); // Update the database. $quiz->id = $quiz->instance; $DB->update_record('quiz', $quiz); // Do the processing required after an add or an update. quiz_after_add_or_update($quiz); if ($oldquiz->grademethod != $quiz->grademethod) { quiz_update_all_final_grades($quiz); quiz_update_grades($quiz); } $quizdateschanged = $oldquiz->timelimit != $quiz->timelimit || $oldquiz->timeclose != $quiz->timeclose || $oldquiz->graceperiod != $quiz->graceperiod; if ($quizdateschanged) { quiz_update_open_attempts(array('quizid' => $quiz->id)); } // Delete any previous preview attempts. quiz_delete_previews($quiz); return true; }
function RWSISRec(&$r_qiz, $r_rcd, $r_pop = false) { global $RWSLB; global $CFG; $r_p = 0; $r_sz = strlen($r_rcd); if (!empty($r_qiz->coursemodule)) { if (respondusws_floatcompare($CFG->version, 2013111800, 2) >= 0) { $r_ctx = context_module::instance($r_qiz->coursemodule); } else { $r_ctx = get_context_instance(CONTEXT_MODULE, $r_qiz->coursemodule); } $r_ctxi = $r_ctx->id; } else { if (!empty($r_qiz->course)) { if (respondusws_floatcompare($CFG->version, 2013111800, 2) >= 0) { $r_ctx = context_course::instance($r_qiz->course); } else { $r_ctx = get_context_instance(CONTEXT_COURSE, $r_qiz->course); } $r_ctxi = $r_ctx->id; } else { $r_ctxi = null; } } if ($r_sz < 1) { return false; } $r_ct = strpos(substr($r_rcd, $r_p), ""); if ($r_ct === false) { return false; } if ($r_ct > 0) { $r_fld = substr($r_rcd, $r_p, $r_ct); } else { $r_fld = ""; } $r_ct++; $r_p += $r_ct; $r_sz -= $r_ct; $r_qiz->intro = trim($r_fld); $r_qiz->introformat = FORMAT_HTML; $r_ct = 2; if ($r_sz < $r_ct) { return false; } $r_fld = substr($r_rcd, $r_p, $r_ct); $r_p += $r_ct; $r_sz -= $r_ct; $r_dat = unpack("n", $r_fld); $r_y = $r_dat[1]; if ($r_y != 0 && ($r_y < 1970 || $r_y > 2020)) { return false; } $r_ct = 1; if ($r_sz < $r_ct) { return false; } $r_fld = substr($r_rcd, $r_p, $r_ct); $r_p += $r_ct; $r_sz -= $r_ct; $r_dat = unpack("C", $r_fld); $r_mo = intval($r_dat[1]); if ($r_y != 0 && ($r_mo < 1 || $r_mo > 12)) { return false; } $r_ct = 1; if ($r_sz < $r_ct) { return false; } $r_fld = substr($r_rcd, $r_p, $r_ct); $r_p += $r_ct; $r_sz -= $r_ct; $r_dat = unpack("C", $r_fld); $r_da = intval($r_dat[1]); if ($r_y != 0 && ($r_da < 1 || $r_da > RWSGDIMon($r_mo, $r_y))) { return false; } $r_ct = 1; if ($r_sz < $r_ct) { return false; } $r_fld = substr($r_rcd, $r_p, $r_ct); $r_p += $r_ct; $r_sz -= $r_ct; $r_dat = unpack("C", $r_fld); $r_hr = intval($r_dat[1]); if ($r_y != 0 && ($r_hr < 0 || $r_hr > 23)) { return false; } $r_ct = 1; if ($r_sz < $r_ct) { return false; } $r_fld = substr($r_rcd, $r_p, $r_ct); $r_p += $r_ct; $r_sz -= $r_ct; $r_dat = unpack("C", $r_fld); $r_mt = intval($r_dat[1]); if ($r_y != 0 && ($r_mt < 0 || $r_mt > 55 || $r_mt % 5 != 0)) { return false; } if ($r_y == 0) { $r_qiz->timeopen = 0; } else { $r_qiz->timeopen = make_timestamp($r_y, $r_mo, $r_da, $r_hr, $r_mt); } $r_ct = 2; if ($r_sz < $r_ct) { return false; } $r_fld = substr($r_rcd, $r_p, $r_ct); $r_p += $r_ct; $r_sz -= $r_ct; $r_dat = unpack("n", $r_fld); $r_y = $r_dat[1]; if ($r_y != 0 && ($r_y < 1970 || $r_y > 2020)) { return false; } $r_ct = 1; if ($r_sz < $r_ct) { return false; } $r_fld = substr($r_rcd, $r_p, $r_ct); $r_p += $r_ct; $r_sz -= $r_ct; $r_dat = unpack("C", $r_fld); $r_mo = intval($r_dat[1]); if ($r_y != 0 && ($r_mo < 1 || $r_mo > 12)) { return false; } $r_ct = 1; if ($r_sz < $r_ct) { return false; } $r_fld = substr($r_rcd, $r_p, $r_ct); $r_p += $r_ct; $r_sz -= $r_ct; $r_dat = unpack("C", $r_fld); $r_da = intval($r_dat[1]); if ($r_y != 0 && ($r_da < 1 || $r_da > RWSGDIMon($r_mo, $r_y))) { return false; } $r_ct = 1; if ($r_sz < $r_ct) { return false; } $r_fld = substr($r_rcd, $r_p, $r_ct); $r_p += $r_ct; $r_sz -= $r_ct; $r_dat = unpack("C", $r_fld); $r_hr = intval($r_dat[1]); if ($r_y != 0 && ($r_hr < 0 || $r_hr > 23)) { return false; } $r_ct = 1; if ($r_sz < $r_ct) { return false; } $r_fld = substr($r_rcd, $r_p, $r_ct); $r_p += $r_ct; $r_sz -= $r_ct; $r_dat = unpack("C", $r_fld); $r_mt = intval($r_dat[1]); if ($r_y != 0 && ($r_mt < 0 || $r_mt > 55 || $r_mt % 5 != 0)) { return false; } if ($r_y == 0) { $r_qiz->timeclose = 0; } else { $r_qiz->timeclose = make_timestamp($r_y, $r_mo, $r_da, $r_hr, $r_mt); } if ($r_qiz->timeopen != 0 && $r_qiz->timeclose != 0 && $r_qiz->timeopen > $r_qiz->timeclose) { return false; } $r_ct = 1; if ($r_sz < $r_ct) { return false; } $r_fld = substr($r_rcd, $r_p, $r_ct); $r_p += $r_ct; $r_sz -= $r_ct; $r_dat = unpack("C", $r_fld); $r_qiz->timelimitenable = intval($r_dat[1]); if ($r_qiz->timelimitenable != 0 && $r_qiz->timelimitenable != 1) { return false; } $r_ct = 4; if ($r_sz < $r_ct) { return false; } $r_fld = substr($r_rcd, $r_p, $r_ct); $r_p += $r_ct; $r_sz -= $r_ct; $r_dat = unpack("N", $r_fld); $r_qiz->timelimit = $r_dat[1] * 60; if ($r_qiz->timelimitenable == 0) { $r_qiz->timelimit = 0; } $r_ct = 4; if ($r_sz < $r_ct) { return false; } $r_fld = substr($r_rcd, $r_p, $r_ct); $r_p += $r_ct; $r_sz -= $r_ct; $r_dat = unpack("N", $r_fld); $r_qiz->delay1 = $r_dat[1]; $r_ct = 4; if ($r_sz < $r_ct) { return false; } $r_fld = substr($r_rcd, $r_p, $r_ct); $r_p += $r_ct; $r_sz -= $r_ct; $r_dat = unpack("N", $r_fld); $r_qiz->delay2 = $r_dat[1]; $r_ct = 1; if ($r_sz < $r_ct) { return false; } $r_fld = substr($r_rcd, $r_p, $r_ct); $r_p += $r_ct; $r_sz -= $r_ct; $r_dat = unpack("C", $r_fld); $r_qiz->questionsperpage = intval($r_dat[1]); if ($r_qiz->questionsperpage < 0 || $r_qiz->questionsperpage > 50) { return false; } $r_ct = 1; if ($r_sz < $r_ct) { return false; } $r_fld = substr($r_rcd, $r_p, $r_ct); $r_p += $r_ct; $r_sz -= $r_ct; $r_dat = unpack("C", $r_fld); $r_qiz->shufflequestions = intval($r_dat[1]); if ($r_qiz->shufflequestions != 0 && $r_qiz->shufflequestions != 1) { return false; } $r_ct = 1; if ($r_sz < $r_ct) { return false; } $r_fld = substr($r_rcd, $r_p, $r_ct); $r_p += $r_ct; $r_sz -= $r_ct; $r_dat = unpack("C", $r_fld); $r_qiz->shuffleanswers = intval($r_dat[1]); if ($r_qiz->shuffleanswers != 0 && $r_qiz->shuffleanswers != 1) { return false; } $r_ct = 1; if ($r_sz < $r_ct) { return false; } $r_fld = substr($r_rcd, $r_p, $r_ct); $r_p += $r_ct; $r_sz -= $r_ct; $r_dat = unpack("C", $r_fld); $r_qiz->attempts = intval($r_dat[1]); if ($r_qiz->attempts < 0 || $r_qiz->attempts > 10) { return false; } $r_ct = 1; if ($r_sz < $r_ct) { return false; } $r_fld = substr($r_rcd, $r_p, $r_ct); $r_p += $r_ct; $r_sz -= $r_ct; $r_dat = unpack("C", $r_fld); $r_qiz->attemptonlast = intval($r_dat[1]); if ($r_qiz->attemptonlast != 0 && $r_qiz->attemptonlast != 1) { return false; } $r_ct = 1; if ($r_sz < $r_ct) { return false; } $r_fld = substr($r_rcd, $r_p, $r_ct); $r_p += $r_ct; $r_sz -= $r_ct; $r_dat = unpack("C", $r_fld); $r_adap = intval($r_dat[1]); if ($r_adap != 0 && $r_adap != 1) { return false; } $r_ct = 4; if ($r_sz < $r_ct) { return false; } $r_fld = substr($r_rcd, $r_p, $r_ct); $r_p += $r_ct; $r_sz -= $r_ct; $r_dat = unpack("N", $r_fld); $r_qiz->grade = $r_dat[1]; $r_ct = 1; if ($r_sz < $r_ct) { return false; } $r_fld = substr($r_rcd, $r_p, $r_ct); $r_p += $r_ct; $r_sz -= $r_ct; $r_dat = unpack("C", $r_fld); $r_qiz->grademethod = intval($r_dat[1]); switch ($r_qiz->grademethod) { case 1: case 2: case 3: case 4: break; default: return false; } $r_ct = 1; if ($r_sz < $r_ct) { return false; } $r_fld = substr($r_rcd, $r_p, $r_ct); $r_p += $r_ct; $r_sz -= $r_ct; $r_dat = unpack("C", $r_fld); $r_pen = intval($r_dat[1]); if ($r_pen != 0 && $r_pen != 1) { return false; } if (respondusws_floatcompare($CFG->version, 2011070100, 2) >= 0) { if ($r_adap == 0 && $r_pen == 0) { $r_qiz->preferredbehaviour = "deferredfeedback"; } else { if ($r_adap == 0 && $r_pen == 1) { $r_qiz->preferredbehaviour = "deferredfeedback"; } else { if ($r_adap == 1 && $r_pen == 0) { $r_qiz->preferredbehaviour = "adaptivenopenalty"; } else { if ($r_adap == 1 && $r_pen == 1) { $r_qiz->preferredbehaviour = "adaptive"; } else { return false; } } } } } else { $r_qiz->adaptive = $r_adap; $r_qiz->penaltyscheme = $r_pen; } $r_ct = 1; if ($r_sz < $r_ct) { return false; } $r_fld = substr($r_rcd, $r_p, $r_ct); $r_p += $r_ct; $r_sz -= $r_ct; $r_dat = unpack("C", $r_fld); $r_qiz->decimalpoints = intval($r_dat[1]); switch ($r_qiz->decimalpoints) { case 0: case 1: case 2: case 3: case 4: case 5: break; default: return false; } $r_ct = 1; if ($r_sz < $r_ct) { return false; } $r_fld = substr($r_rcd, $r_p, $r_ct); $r_p += $r_ct; $r_sz -= $r_ct; $r_dat = unpack("C", $r_fld); $r_stg = intval($r_dat[1]); if ($r_stg == 0 || $r_stg == 1) { $r_rim = $r_stg; } else { return false; } $r_ct = 1; if ($r_sz < $r_ct) { return false; } $r_fld = substr($r_rcd, $r_p, $r_ct); $r_p += $r_ct; $r_sz -= $r_ct; $r_dat = unpack("C", $r_fld); $r_stg = intval($r_dat[1]); if ($r_stg == 0 || $r_stg == 1) { $r_aim = $r_stg; } else { return false; } $r_ct = 1; if ($r_sz < $r_ct) { return false; } $r_fld = substr($r_rcd, $r_p, $r_ct); $r_p += $r_ct; $r_sz -= $r_ct; $r_dat = unpack("C", $r_fld); $r_stg = intval($r_dat[1]); if ($r_stg == 0 || $r_stg == 1) { $r_fim = $r_stg; } else { return false; } $r_ct = 1; if ($r_sz < $r_ct) { return false; } $r_fld = substr($r_rcd, $r_p, $r_ct); $r_p += $r_ct; $r_sz -= $r_ct; $r_dat = unpack("C", $r_fld); $r_stg = intval($r_dat[1]); if ($r_stg == 0 || $r_stg == 1) { $r_gim = $r_stg; } else { return false; } $r_ct = 1; if ($r_sz < $r_ct) { return false; } $r_fld = substr($r_rcd, $r_p, $r_ct); $r_p += $r_ct; $r_sz -= $r_ct; $r_dat = unpack("C", $r_fld); $r_stg = intval($r_dat[1]); if ($r_stg == 0 || $r_stg == 1) { $r_sim = $r_stg; } else { return false; } $r_ct = 1; if ($r_sz < $r_ct) { return false; } $r_fld = substr($r_rcd, $r_p, $r_ct); $r_p += $r_ct; $r_sz -= $r_ct; $r_dat = unpack("C", $r_fld); $r_stg = intval($r_dat[1]); if ($r_stg == 0 || $r_stg == 1) { $r_oim = $r_stg; } else { return false; } $r_ct = 1; if ($r_sz < $r_ct) { return false; } $r_fld = substr($r_rcd, $r_p, $r_ct); $r_p += $r_ct; $r_sz -= $r_ct; $r_dat = unpack("C", $r_fld); $r_stg = intval($r_dat[1]); if ($r_stg == 0 || $r_stg == 1) { $r_rop = $r_stg; } else { return false; } $r_ct = 1; if ($r_sz < $r_ct) { return false; } $r_fld = substr($r_rcd, $r_p, $r_ct); $r_p += $r_ct; $r_sz -= $r_ct; $r_dat = unpack("C", $r_fld); $r_stg = intval($r_dat[1]); if ($r_stg == 0 || $r_stg == 1) { $r_aop = $r_stg; } else { return false; } $r_ct = 1; if ($r_sz < $r_ct) { return false; } $r_fld = substr($r_rcd, $r_p, $r_ct); $r_p += $r_ct; $r_sz -= $r_ct; $r_dat = unpack("C", $r_fld); $r_stg = intval($r_dat[1]); if ($r_stg == 0 || $r_stg == 1) { $r_fop = $r_stg; } else { return false; } $r_ct = 1; if ($r_sz < $r_ct) { return false; } $r_fld = substr($r_rcd, $r_p, $r_ct); $r_p += $r_ct; $r_sz -= $r_ct; $r_dat = unpack("C", $r_fld); $r_stg = intval($r_dat[1]); if ($r_stg == 0 || $r_stg == 1) { $r_gop = $r_stg; } else { return false; } $r_ct = 1; if ($r_sz < $r_ct) { return false; } $r_fld = substr($r_rcd, $r_p, $r_ct); $r_p += $r_ct; $r_sz -= $r_ct; $r_dat = unpack("C", $r_fld); $r_stg = intval($r_dat[1]); if ($r_stg == 0 || $r_stg == 1) { $r_sop = $r_stg; } else { return false; } $r_ct = 1; if ($r_sz < $r_ct) { return false; } $r_fld = substr($r_rcd, $r_p, $r_ct); $r_p += $r_ct; $r_sz -= $r_ct; $r_dat = unpack("C", $r_fld); $r_stg = intval($r_dat[1]); if ($r_stg == 0 || $r_stg == 1) { $r_oop = $r_stg; } else { return false; } $r_ct = 1; if ($r_sz < $r_ct) { return false; } $r_fld = substr($r_rcd, $r_p, $r_ct); $r_p += $r_ct; $r_sz -= $r_ct; $r_dat = unpack("C", $r_fld); $r_stg = intval($r_dat[1]); if ($r_stg == 0 || $r_stg == 1) { $r_rcl = $r_stg; } else { return false; } $r_ct = 1; if ($r_sz < $r_ct) { return false; } $r_fld = substr($r_rcd, $r_p, $r_ct); $r_p += $r_ct; $r_sz -= $r_ct; $r_dat = unpack("C", $r_fld); $r_stg = intval($r_dat[1]); if ($r_stg == 0 || $r_stg == 1) { $r_acl = $r_stg; } else { return false; } $r_ct = 1; if ($r_sz < $r_ct) { return false; } $r_fld = substr($r_rcd, $r_p, $r_ct); $r_p += $r_ct; $r_sz -= $r_ct; $r_dat = unpack("C", $r_fld); $r_stg = intval($r_dat[1]); if ($r_stg == 0 || $r_stg == 1) { $r_fcl = $r_stg; } else { return false; } $r_ct = 1; if ($r_sz < $r_ct) { return false; } $r_fld = substr($r_rcd, $r_p, $r_ct); $r_p += $r_ct; $r_sz -= $r_ct; $r_dat = unpack("C", $r_fld); $r_stg = intval($r_dat[1]); if ($r_stg == 0 || $r_stg == 1) { $r_gcl = $r_stg; } else { return false; } $r_ct = 1; if ($r_sz < $r_ct) { return false; } $r_fld = substr($r_rcd, $r_p, $r_ct); $r_p += $r_ct; $r_sz -= $r_ct; $r_dat = unpack("C", $r_fld); $r_stg = intval($r_dat[1]); if ($r_stg == 0 || $r_stg == 1) { $r_scl = $r_stg; } else { return false; } $r_ct = 1; if ($r_sz < $r_ct) { return false; } $r_fld = substr($r_rcd, $r_p, $r_ct); $r_p += $r_ct; $r_sz -= $r_ct; $r_dat = unpack("C", $r_fld); $r_stg = intval($r_dat[1]); if ($r_stg == 0 || $r_stg == 1) { $r_ocl = $r_stg; } else { return false; } if (respondusws_floatcompare($CFG->version, 2011070100, 2) >= 0) { $r_qiz->attemptduring = 1; if (!$r_qiz->attemptduring) { unset($r_qiz->attemptduring); } $r_qiz->correctnessduring = 1; if (!$r_qiz->correctnessduring) { unset($r_qiz->correctnessduring); } $r_qiz->marksduring = 1; if (!$r_qiz->marksduring) { unset($r_qiz->marksduring); } $r_qiz->specificfeedbackduring = $r_fim; if (!$r_qiz->specificfeedbackduring) { unset($r_qiz->specificfeedbackduring); } $r_qiz->generalfeedbackduring = $r_gim; if (!$r_qiz->generalfeedbackduring) { unset($r_qiz->generalfeedbackduring); } $r_qiz->rightanswerduring = $r_aim; if (!$r_qiz->rightanswerduring) { unset($r_qiz->rightanswerduring); } $r_qiz->overallfeedbackduring = 0; if (!$r_qiz->overallfeedbackduring) { unset($r_qiz->overallfeedbackduring); } $r_qiz->attemptimmediately = $r_rim; if (!$r_qiz->attemptimmediately) { unset($r_qiz->attemptimmediately); } $r_qiz->correctnessimmediately = $r_sim; if (!$r_qiz->correctnessimmediately) { unset($r_qiz->correctnessimmediately); } $r_qiz->marksimmediately = $r_sim; if (!$r_qiz->marksimmediately) { unset($r_qiz->marksimmediately); } $r_qiz->specificfeedbackimmediately = $r_fim; if (!$r_qiz->specificfeedbackimmediately) { unset($r_qiz->specificfeedbackimmediately); } $r_qiz->generalfeedbackimmediately = $r_gim; if (!$r_qiz->generalfeedbackimmediately) { unset($r_qiz->generalfeedbackimmediately); } $r_qiz->rightanswerimmediately = $r_aim; if (!$r_qiz->rightanswerimmediately) { unset($r_qiz->rightanswerimmediately); } $r_qiz->overallfeedbackimmediately = $r_oim; if (!$r_qiz->overallfeedbackimmediately) { unset($r_qiz->overallfeedbackimmediately); } $r_qiz->attemptopen = $r_rop; if (!$r_qiz->attemptopen) { unset($r_qiz->attemptopen); } $r_qiz->correctnessopen = $r_sop; if (!$r_qiz->correctnessopen) { unset($r_qiz->correctnessopen); } $r_qiz->marksopen = $r_sop; if (!$r_qiz->marksopen) { unset($r_qiz->marksopen); } $r_qiz->specificfeedbackopen = $r_fop; if (!$r_qiz->specificfeedbackopen) { unset($r_qiz->specificfeedbackopen); } $r_qiz->generalfeedbackopen = $r_gop; if (!$r_qiz->generalfeedbackopen) { unset($r_qiz->generalfeedbackopen); } $r_qiz->rightansweropen = $r_aop; if (!$r_qiz->rightansweropen) { unset($r_qiz->rightansweropen); } $r_qiz->overallfeedbackopen = $r_oop; if (!$r_qiz->overallfeedbackopen) { unset($r_qiz->overallfeedbackopen); } $r_qiz->attemptclosed = $r_rcl; if (!$r_qiz->attemptclosed) { unset($r_qiz->attemptclosed); } $r_qiz->correctnessclosed = $r_scl; if (!$r_qiz->correctnessclosed) { unset($r_qiz->correctnessclosed); } $r_qiz->marksclosed = $r_scl; if (!$r_qiz->marksclosed) { unset($r_qiz->marksclosed); } $r_qiz->specificfeedbackclosed = $r_fcl; if (!$r_qiz->specificfeedbackclosed) { unset($r_qiz->specificfeedbackclosed); } $r_qiz->generalfeedbackclosed = $r_gcl; if (!$r_qiz->generalfeedbackclosed) { unset($r_qiz->generalfeedbackclosed); } $r_qiz->rightanswerclosed = $r_acl; if (!$r_qiz->rightanswerclosed) { unset($r_qiz->rightanswerclosed); } $r_qiz->overallfeedbackclosed = $r_ocl; if (!$r_qiz->overallfeedbackclosed) { unset($r_qiz->overallfeedbackclosed); } } else { $r_qiz->responsesimmediately = $r_rim; if (!$r_qiz->responsesimmediately) { unset($r_qiz->responsesimmediately); } $r_qiz->answersimmediately = $r_aim; if (!$r_qiz->answersimmediately) { unset($r_qiz->answersimmediately); } $r_qiz->feedbackimmediately = $r_fim; if (!$r_qiz->feedbackimmediately) { unset($r_qiz->feedbackimmediately); } $r_qiz->generalfeedbackimmediately = $r_gim; if (!$r_qiz->generalfeedbackimmediately) { unset($r_qiz->generalfeedbackimmediately); } $r_qiz->scoreimmediately = $r_sim; if (!$r_qiz->scoreimmediately) { unset($r_qiz->scoreimmediately); } $r_qiz->overallfeedbackimmediately = $r_oim; if (!$r_qiz->overallfeedbackimmediately) { unset($r_qiz->overallfeedbackimmediately); } $r_qiz->responsesopen = $r_rop; if (!$r_qiz->responsesopen) { unset($r_qiz->responsesopen); } $r_qiz->answersopen = $r_aop; if (!$r_qiz->answersopen) { unset($r_qiz->answersopen); } $r_qiz->feedbackopen = $r_fop; if (!$r_qiz->feedbackopen) { unset($r_qiz->feedbackopen); } $r_qiz->generalfeedbackopen = $r_gop; if (!$r_qiz->generalfeedbackopen) { unset($r_qiz->generalfeedbackopen); } $r_qiz->scoreopen = $r_sop; if (!$r_qiz->scoreopen) { unset($r_qiz->scoreopen); } $r_qiz->overallfeedbackopen = $r_oop; if (!$r_qiz->overallfeedbackopen) { unset($r_qiz->overallfeedbackopen); } $r_qiz->responsesclosed = $r_rcl; if (!$r_qiz->responsesclosed) { unset($r_qiz->responsesclosed); } $r_qiz->answersclosed = $r_acl; if (!$r_qiz->answersclosed) { unset($r_qiz->answersclosed); } $r_qiz->feedbackclosed = $r_fcl; if (!$r_qiz->feedbackclosed) { unset($r_qiz->feedbackclosed); } $r_qiz->generalfeedbackclosed = $r_gcl; if (!$r_qiz->generalfeedbackclosed) { unset($r_qiz->generalfeedbackclosed); } $r_qiz->scoreclosed = $r_scl; if (!$r_qiz->scoreclosed) { unset($r_qiz->scoreclosed); } $r_qiz->overallfeedbackclosed = $r_ocl; if (!$r_qiz->overallfeedbackclosed) { unset($r_qiz->overallfeedbackclosed); } } $r_ct = 1; if ($r_sz < $r_ct) { return false; } $r_fld = substr($r_rcd, $r_p, $r_ct); $r_p += $r_ct; $r_sz -= $r_ct; $r_dat = unpack("C", $r_fld); $popup = intval($r_dat[1]); if ($popup != 0 && $popup != 1) { return false; } $r_qiz->popup = $popup; if ($popup == 0) { $r_qiz->browsersecurity = "-"; } else { $r_qiz->browsersecurity = "securewindow"; } if ($r_sz < 1) { return false; } $r_ct = strpos(substr($r_rcd, $r_p), ""); if ($r_ct === false) { return false; } if ($r_ct > 0) { $r_fld = substr($r_rcd, $r_p, $r_ct); } else { $r_fld = ""; } $r_ct++; $r_p += $r_ct; $r_sz -= $r_ct; $r_qiz->quizpassword = trim($r_fld); if ($r_sz < 1) { return false; } $r_ct = strpos(substr($r_rcd, $r_p), ""); if ($r_ct === false) { return false; } if ($r_ct > 0) { $r_fld = substr($r_rcd, $r_p, $r_ct); } else { $r_fld = ""; } $r_ct++; $r_p += $r_ct; $r_sz -= $r_ct; $r_qiz->subnet = trim($r_fld); $r_ct = 1; if ($r_sz < $r_ct) { return false; } $r_fld = substr($r_rcd, $r_p, $r_ct); $r_p += $r_ct; $r_sz -= $r_ct; $r_dat = unpack("C", $r_fld); $r_qiz->groupmode = intval($r_dat[1]); switch ($r_qiz->groupmode) { case 0: case 1: case 2: break; default: return false; } $r_ct = 1; if ($r_sz < $r_ct) { return false; } $r_fld = substr($r_rcd, $r_p, $r_ct); $r_p += $r_ct; $r_sz -= $r_ct; $r_dat = unpack("C", $r_fld); $r_qiz->visible = intval($r_dat[1]); if ($r_qiz->visible != 0 && $r_qiz->visible != 1) { return false; } if ($r_sz < 1) { return false; } $r_ct = strpos(substr($r_rcd, $r_p), ""); if ($r_ct === false) { return false; } if ($r_ct > 0) { $r_fld = substr($r_rcd, $r_p, $r_ct); } else { $r_fld = ""; } $r_ct++; $r_p += $r_ct; $r_sz -= $r_ct; $r_qiz->cmidnumber = trim($r_fld); if ($r_sz < 1) { return false; } $r_ct = strpos(substr($r_rcd, $r_p), ""); if ($r_ct === false) { return false; } $r_ct++; $r_p += $r_ct; $r_sz -= $r_ct; $r_ct = 1; if ($r_sz < $r_ct) { return false; } $r_fld = substr($r_rcd, $r_p, $r_ct); $r_p += $r_ct; $r_sz -= $r_ct; $r_dat = unpack("C", $r_fld); $r_nf = intval($r_dat[1]); $r_fds = array(); for ($r_i = 0; $r_i < $r_nf; $r_i++) { if ($r_sz < 1) { return false; } $r_ct = strpos(substr($r_rcd, $r_p), ""); if ($r_ct === false) { return false; } if ($r_ct > 0) { $r_fld = substr($r_rcd, $r_p, $r_ct); } else { $r_fld = ""; } $r_ct++; $r_p += $r_ct; $r_sz -= $r_ct; $r_fds[] = trim($r_fld); } $r_ct = 1; if ($r_sz < $r_ct) { return false; } $r_fld = substr($r_rcd, $r_p, $r_ct); $r_p += $r_ct; $r_sz -= $r_ct; $r_dat = unpack("C", $r_fld); $r_nb = intval($r_dat[1]); $r_bds = array(); for ($r_i = 0; $r_i < $r_nb; $r_i++) { if ($r_sz < 1) { return false; } $r_ct = strpos(substr($r_rcd, $r_p), ""); if ($r_ct === false) { return false; } if ($r_ct > 0) { $r_fld = substr($r_rcd, $r_p, $r_ct); } else { $r_fld = ""; } $r_ct++; $r_p += $r_ct; $r_sz -= $r_ct; $r_bd = trim($r_fld); $r_l = strlen($r_bd); if ($r_l == 0) { return false; } if (is_numeric($r_bd)) { if ($r_bd <= 0 || $r_bd >= $r_qiz->grade) { return false; } if ($r_i > 0 && $r_bd >= $r_lb) { return false; } $r_lb = $r_bd; } else { if ($r_bd[$r_l - 1] != '%') { return false; } $r_pct = trim(substr($r_bd, 0, -1)); if (!is_numeric($r_pct)) { return false; } if ($r_pct <= 0 || $r_pct >= 100) { return false; } if ($r_i > 0 && $r_bd >= $r_lb) { return false; } $r_lb = $r_bd * $r_qiz->grade / 100.0; } $r_bds[] = $r_bd; } $r_nf = count($r_fds); $r_nb = count($r_bds); if ($r_nf > 0) { if ($r_nf != $r_nb + 1) { return false; } for ($r_i = 0; $r_i < $r_nf; $r_i++) { if (isset($r_qiz->feedbacktext[$r_i]["itemid"])) { $r_drf = $r_qiz->feedbacktext[$r_i]["itemid"]; } else { $r_drf = 0; } $r_cmp = "mod_quiz"; $r_far = "feedback"; $r_iti = null; $r_op = null; $r_txt = $r_fds[$r_i]; $r_qiz->feedbacktext[$r_i]["text"] = file_prepare_draft_area($r_drf, $r_ctxi, $r_cmp, $r_far, $r_iti, $r_op, $r_txt); $r_qiz->feedbacktext[$r_i]["format"] = FORMAT_HTML; $r_qiz->feedbacktext[$r_i]["itemid"] = $r_drf; if ($r_i < $r_nf - 1) { $r_qiz->feedbackboundaries[$r_i] = $r_bds[$r_i]; } } } $r_ct = 1; if ($r_sz < $r_ct) { return false; } $r_fld = substr($r_rcd, $r_p, $r_ct); $r_p += $r_ct; $r_sz -= $r_ct; $r_dat = unpack("C", $r_fld); $r_lbq = intval($r_dat[1]); if ($r_lbq != 0 && $r_lbq != 1) { return false; } $RWSLB->atts = $r_lbq; $r_ct = 1; if ($r_sz < $r_ct) { return false; } $r_fld = substr($r_rcd, $r_p, $r_ct); $r_p += $r_ct; $r_sz -= $r_ct; $r_dat = unpack("C", $r_fld); $r_lbr = intval($r_dat[1]); if ($r_lbr != 0 && $r_lbr != 1) { return false; } $RWSLB->revs = $r_lbr; if ($r_sz < 1) { return false; } $r_ct = strpos(substr($r_rcd, $r_p), ""); if ($r_ct === false) { return false; } if ($r_ct > 0) { $r_fld = substr($r_rcd, $r_p, $r_ct); } else { $r_fld = ""; } $r_ct++; $r_p += $r_ct; $r_sz -= $r_ct; $RWSLB->pw = trim($r_fld); $r_ct = 4; if ($r_sz < $r_ct) { return false; } $r_fld = substr($r_rcd, $r_p, $r_ct); $r_p += $r_ct; $r_sz -= $r_ct; $r_dat = unpack("N", $r_fld); $r_ct = $r_dat[1]; if ($r_sz < $r_ct) { return false; } $r_p += $r_ct; $r_sz -= $r_ct; if ($r_pop) { if (is_null($r_qiz->quizpassword) && !is_null($r_qiz->password)) { $r_qiz->quizpassword = $r_qiz->password; } quiz_process_options($r_qiz); } return true; }