From: tjhunt Date: Thu, 14 Aug 2008 03:50:14 +0000 (+0000) Subject: MDL-14979 - Remove the obsolete quizfile.php and associated code. This has not been... X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=dfe23b6e6689d033a9dcaec91a3dfbd1176c8dae;p=moodle.git MDL-14979 - Remove the obsolete quizfile.php and associated code. This has not been used since Moodle 1.5. --- diff --git a/mod/quiz/quizfile.php b/mod/quiz/quizfile.php deleted file mode 100644 index 03c0188802..0000000000 --- a/mod/quiz/quizfile.php +++ /dev/null @@ -1,111 +0,0 @@ -libdir.'/filelib.php'); - require_once('locallib.php'); - - if (empty($CFG->filelifetime)) { - $lifetime = 86400; // Seconds for files to remain in caches - } else { - $lifetime = $CFG->filelifetime; - } - - // disable moodle specific debug messages - disable_debugging(); - - $relativepath = get_file_argument('quizfile.php'); - - if (!$relativepath) { - print_error('invalidargorconf'); - } - - // extract relative path components - $args = explode('/', trim($relativepath, '/')); - if (count($args) < 3) { // always at least category, question and path - print_error('invalidarguments'); - } - - $quizid = (int)array_shift($args); - $questionid = (int)array_shift($args); - $relativepath = implode ('/', $args); - - if (!($question = $DB->get_record('question', array('id' => $questionid)))) { - print_error('invalidarguments'); - } - - if (!($questioncategory = $DB->get_record('question_categories', array('id' => $question->category)))) { - print_error('invalidarguments'); - } - - ///////////////////////////////////// - // Check access - ///////////////////////////////////// - if ($quizid == 0) { // teacher doing preview during quiz creation - if ($questioncategory->publish) { - require_login(); - if (!isteacherinanycourse()) { - print_error('invalidarguments'); - } - } else { - require_login($questioncategory->course); - $cm = get_coursemodule_from_instance('quiz', $quizid); - require_capability('mod/quiz:preview', get_context_instance(CONTEXT_MODULE, $cm->id)); - } - } else { - if (!($quiz = $DB->get_record('quiz', array('id' => $quizid)))) { - print_error('invalidarguments'); - } - if (!($course = $DB->get_record('course', array('id' => $quiz->course)))) { - print_error('invalidarguments'); - } - require_login($course->id); - - // For now, let's not worry about this. The following check causes - // problems sometimes when reviewing a quiz - //if (!isteacher($course->id) - // and !quiz_get_user_attempt_unfinished($quiz->id, $USER->id) - // and ! ($quiz->review && time() > $quiz->timeclose) - // || !quiz_get_user_attempts($quiz->id, $USER->id) ) - //{ - // print_error('noview', 'quiz'); - //} - - /////////////////////////////////////////////////// - // The logged-in user has the right to view material on this quiz! - // Now verify the consistency between $quiz, $question, its category and $relativepathname - /////////////////////////////////////////////////// - - // For now, let's not worry about this. The following check doesn't - // work for randomly selected questions and it gets complicated - //if (!in_array($question->id, explode(',', $quiz->questions), FALSE)) { - // print_error('specificquestionnotonquiz', 'quiz'); - //} - } - - // Have the question check whether it uses this file or not - if (!$QTYPES[$question->qtype]->uses_quizfile($question, - $relativepath)) { - print_error('specificapathnotonquestion', 'quiz'); - } - - - /////////////////////////////////////////// - // All security stuff is now taken care of. - // Specified file can now be returned... - ////////////////////////////////////////// - - $pathname = "$CFG->dataroot/$questioncategory->course/$relativepath"; - $filename = $args[count($args)-1]; - - - if (file_exists($pathname)) { - send_file($pathname, $filename, $lifetime); - } else { - header('HTTP/1.0 404 not found'); - print_error('filenotfound', 'error'); //this is not displayed on IIS?? - } -?> diff --git a/question/type/datasetdependent/abstractqtype.php b/question/type/datasetdependent/abstractqtype.php index 799237345e..cb2767107f 100644 --- a/question/type/datasetdependent/abstractqtype.php +++ b/question/type/datasetdependent/abstractqtype.php @@ -87,26 +87,6 @@ class question_dataset_dependent_questiontype extends default_questiontype { return $str; } - function uses_quizfile($question, $relativefilepath) { - // Check whether the specified file is available by any - // dataset item on this question... - global $CFG, $DB; - if ($DB->get_record_sql(" SELECT * - FROM {question_dataset_items} i, - {question_dataset_definitions} d, - {question_datasets} q - WHERE i.value = ? - AND d.id = i.definition AND d.type = 2 - AND d.id = q.datasetdefinition - AND q.question = ? ", array($relativefilepath, $question->id))) { - - return true; - } else { - // Make the check of the parent: - return parent::uses_quizfile($question, $relativefilepath); - } - } - function finished_edit_wizard(&$form) { return isset($form->backtoquiz); }