MDL-28618 question combined feedback: inconsistency in file areas.

The (partially|in)?correct feedback fields acutally store their files in a file area with component 'question'. Some code, however, was written as if they were stored in the qtype_whatever area.
This commit is contained in:
Tim Hunt
2011-08-05 17:38:22 +01:00
parent 80eb52c415
commit c5fe3d7490
5 changed files with 52 additions and 37 deletions
+41
View File
@@ -1107,6 +1107,28 @@ class question_type {
}
}
/**
* Move all the files belonging to this question's answers when the question
* is moved from one context to another.
* @param int $questionid the question being moved.
* @param int $oldcontextid the context it is moving from.
* @param int $newcontextid the context it is moving to.
* @param bool $answerstoo whether there is an 'answer' question area,
* as well as an 'answerfeedback' one. Default false.
*/
protected function move_files_in_combined_feedback($questionid, $oldcontextid,
$newcontextid) {
global $DB;
$fs = get_file_storage();
$fs->move_area_files_to_new_context($oldcontextid,
$newcontextid, 'question', 'correctfeedback', $questionid);
$fs->move_area_files_to_new_context($oldcontextid,
$newcontextid, 'question', 'partiallycorrectfeedback', $questionid);
$fs->move_area_files_to_new_context($oldcontextid,
$newcontextid, 'question', 'incorrectfeedback', $questionid);
}
/**
* Delete all the files belonging to this question.
* @param int $questionid the question being deleted.
@@ -1139,6 +1161,25 @@ class question_type {
}
}
/**
* Delete all the files belonging to this question's answers.
* @param int $questionid the question being deleted.
* @param int $contextid the context the question is in.
* @param bool $answerstoo whether there is an 'answer' question area,
* as well as an 'answerfeedback' one. Default false.
*/
protected function delete_files_in_combined_feedback($questionid, $contextid) {
global $DB;
$fs = get_file_storage();
$fs->delete_area_files($contextid,
'question', 'correctfeedback', $questionid);
$fs->delete_area_files($contextid,
'question', 'partiallycorrectfeedback', $questionid);
$fs->delete_area_files($contextid,
'question', 'incorrectfeedback', $questionid);
}
public function import_file($context, $component, $filearea, $itemid, $file) {
$fs = get_file_storage();
$record = new stdClass();