MDL-48259 questionlib.php: remove functions deprecated in Moodle 2.6

This commit is contained in:
Tim Hunt 2014-11-17 15:06:53 +00:00
parent 4c3c1b5169
commit 1b49f31df2
2 changed files with 14 additions and 72 deletions

View File

@ -1688,36 +1688,6 @@ function question_rewrite_question_urls($text, $file, $contextid, $component,
$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
@ -1747,38 +1717,6 @@ function question_rewrite_question_preview_urls($text, $questionid,
$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.
@ -1878,15 +1816,12 @@ function question_pluginfile($course, $context, $component, $filearea, $args, $f
$result = component_callback($previewcomponent, 'question_preview_pluginfile', array(
$previewcontext, $questionid,
$context, $component, $filearea, $args,
$forcedownload, $options), 'newcallbackmissing');
$forcedownload, $options), 'callbackmissing');
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));
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();

View File

@ -2,8 +2,8 @@ This files describes API changes for code that uses the question API.
=== 2.9 ===
1) Some functions in questionlib.php where were deprecated in the past have now
beed deleted:
1) Some functions in questionlib.php which were deprecated in the past have now
been deleted:
Deprecated since 2.1
* question_list_instances
@ -12,6 +12,13 @@ This files describes API changes for code that uses the question API.
* save_question_options
* question_get_real_state
Deprecated since 2.6
* question_rewrite_questiontext_preview_urls
* question_send_questiontext_file
* question_pluginfile no longer falls back to using the old
{$previewcomponent}_questiontext_preview_pluginfile callback if the new
{$previewcomponent}_question_preview_pluginfile callback is missing.
=== 2.8 ===