$filearea, $idsstr, $options);
}
-/**
- * Rewrite the PLUGINFILE urls in the questiontext, when viewing the question
- * text outside an attempt (for example, in the question bank listing or in the
- * quiz statistics report).
- *
- * @param string $questiontext the question text.
- * @param int $contextid the context the text is being displayed in.
- * @param string $component component
- * @param array $questionid the question id
- * @param array $options e.g. forcedownload. Passed to file_rewrite_pluginfile_urls.
- * @return string $questiontext with URLs rewritten.
- * @deprecated since Moodle 2.6
- */
-function question_rewrite_questiontext_preview_urls($questiontext, $contextid,
- $component, $questionid, $options=null) {
- global $DB;
-
- debugging('question_rewrite_questiontext_preview_urls has been deprecated. ' .
- 'Please use question_rewrite_question_preview_urls instead', DEBUG_DEVELOPER);
- $questioncontextid = $DB->get_field_sql('
- SELECT qc.contextid
- FROM {question} q
- JOIN {question_categories} qc ON qc.id = q.category
- WHERE q.id = :id', array('id' => $questionid), MUST_EXIST);
-
- return question_rewrite_question_preview_urls($questiontext, $questionid,
- $questioncontextid, 'question', 'questiontext', $questionid,
- $contextid, $component, $options);
-}
-
/**
* Rewrite the PLUGINFILE urls in part of the content of a question, for use when
* viewing the question outside an attempt (for example, in the question bank
$filecomponent, $filearea, $path, $options);
}
-/**
- * Send a file from the question text of a question.
- * @param int $questionid the question id
- * @param array $args the remaining file arguments (file path).
- * @param bool $forcedownload whether the user must be forced to download the file.
- * @param array $options additional options affecting the file serving
- * @deprecated since Moodle 2.6.
- */
-function question_send_questiontext_file($questionid, $args, $forcedownload, $options) {
- global $DB;
-
- debugging('question_send_questiontext_file has been deprecated. It is no longer necessary. ' .
- 'You can now just use send_stored_file.', DEBUG_DEVELOPER);
- $question = $DB->get_record_sql('
- SELECT q.id, qc.contextid
- FROM {question} q
- JOIN {question_categories} qc ON qc.id = q.category
- WHERE q.id = :id', array('id' => $questionid), MUST_EXIST);
-
- $fs = get_file_storage();
- $fullpath = "/$question->contextid/question/questiontext/$question->id/" . implode('/', $args);
-
- // Get rid of the redundant questionid.
- $fullpath = str_replace("/{$questionid}/{$questionid}/", "/{$questionid}/", $fullpath);
-
- if (!$file = $fs->get_file_by_hash(sha1($fullpath)) or $file->is_directory()) {
- send_file_not_found();
- }
-
- send_stored_file($file, 0, 0, $forcedownload, $options);
-}
-
/**
* Called by pluginfile.php to serve files related to the 'question' core
* component and for files belonging to qtypes.
$result = component_callback($previewcomponent, 'question_preview_pluginfile', array(
$previewcontext, $questionid,
$context, $component, $filearea, $args,
- $forcedownload, $options), 'newcallbackmissing');
-
- if ($result === 'newcallbackmissing' && $filearea = 'questiontext') {
- // Fall back to the legacy callback for backwards compatibility.
- debugging("Component {$previewcomponent} does not define the expected " .
- "{$previewcomponent}_question_preview_pluginfile callback. Falling back to the deprecated " .
- "{$previewcomponent}_questiontext_preview_pluginfile callback.", DEBUG_DEVELOPER);
- component_callback($previewcomponent, 'questiontext_preview_pluginfile', array(
- $previewcontext, $questionid, $args, $forcedownload, $options));
+ $forcedownload, $options), 'callbackmissing');
+
+ if ($result === 'callbackmissing') {
+ throw new coding_exception("Component {$previewcomponent} does not define the callback " .
+ "{$previewcomponent}_question_preview_pluginfile callback. " .
+ "Which is required if you are using question_rewrite_question_preview_urls.", DEBUG_DEVELOPER);
}
send_file_not_found();