Permalink
Browse files

Merge branch 'MDL-31729_22' of git://github.com/timhunt/moodle into M…

…OODLE_22_STABLE
  • Loading branch information...
2 parents edb03ff + ea9f1a8 commit bd4b665ed6e03d9523d2ae295dcbff4c9ed2bf60 @stronk7 stronk7 committed Feb 27, 2012
@@ -1839,13 +1839,15 @@ public function move_files($questionid, $oldcontextid, $newcontextid) {
parent::move_files($questionid, $oldcontextid, $newcontextid);
$this->move_files_in_answers($questionid, $oldcontextid, $newcontextid);
+ $this->move_files_in_hints($questionid, $oldcontextid, $newcontextid);
}
protected function delete_files($questionid, $contextid) {
$fs = get_file_storage();
parent::delete_files($questionid, $contextid);
$this->delete_files_in_answers($questionid, $contextid);
+ $this->delete_files_in_hints($questionid, $contextid);
}
}
@@ -276,6 +276,7 @@ public function move_files($questionid, $oldcontextid, $newcontextid) {
parent::move_files($questionid, $oldcontextid, $newcontextid);
$this->move_files_in_answers($questionid, $oldcontextid, $newcontextid, true);
+ $this->move_files_in_hints($questionid, $oldcontextid, $newcontextid);
$fs->move_area_files_to_new_context($oldcontextid,
$newcontextid, 'qtype_calculatedmulti', 'correctfeedback', $questionid);
@@ -290,6 +291,7 @@ protected function delete_files($questionid, $contextid) {
parent::delete_files($questionid, $contextid);
$this->delete_files_in_answers($questionid, $contextid, true);
+ $this->delete_files_in_hints($questionid, $contextid);
$fs->delete_area_files($contextid, 'qtype_calculatedmulti',
'correctfeedback', $questionid);
@@ -208,6 +208,7 @@ public function move_files($questionid, $oldcontextid, $newcontextid) {
}
$this->move_files_in_combined_feedback($questionid, $oldcontextid, $newcontextid);
+ $this->move_files_in_hints($questionid, $oldcontextid, $newcontextid);
}
protected function delete_files($questionid, $contextid) {
@@ -223,5 +224,6 @@ protected function delete_files($questionid, $contextid) {
}
$this->delete_files_in_combined_feedback($questionid, $contextid);
+ $this->delete_files_in_hints($questionid, $contextid);
}
}
@@ -223,6 +223,16 @@ public function get_random_guess_score($questiondata) {
}
return $fractionsum / $fractionmax;
}
+
+ public function move_files($questionid, $oldcontextid, $newcontextid) {
+ parent::move_files($questionid, $oldcontextid, $newcontextid);
+ $this->move_files_in_hints($questionid, $oldcontextid, $newcontextid);
+ }
+
+ protected function delete_files($questionid, $contextid) {
+ parent::delete_files($questionid, $contextid);
+ $this->delete_files_in_hints($questionid, $contextid);
+ }
}
@@ -240,11 +240,13 @@ public function move_files($questionid, $oldcontextid, $newcontextid) {
parent::move_files($questionid, $oldcontextid, $newcontextid);
$this->move_files_in_answers($questionid, $oldcontextid, $newcontextid, true);
$this->move_files_in_combined_feedback($questionid, $oldcontextid, $newcontextid);
+ $this->move_files_in_hints($questionid, $oldcontextid, $newcontextid);
}
protected function delete_files($questionid, $contextid) {
parent::delete_files($questionid, $contextid);
$this->delete_files_in_answers($questionid, $contextid, true);
$this->delete_files_in_combined_feedback($questionid, $contextid);
+ $this->delete_files_in_hints($questionid, $contextid);
}
}
@@ -470,13 +470,15 @@ public function move_files($questionid, $oldcontextid, $newcontextid) {
parent::move_files($questionid, $oldcontextid, $newcontextid);
$this->move_files_in_answers($questionid, $oldcontextid, $newcontextid);
+ $this->move_files_in_hints($questionid, $oldcontextid, $newcontextid);
}
protected function delete_files($questionid, $contextid) {
$fs = get_file_storage();
parent::delete_files($questionid, $contextid);
$this->delete_files_in_answers($questionid, $contextid);
+ $this->delete_files_in_hints($questionid, $contextid);
}
}
@@ -1118,6 +1118,27 @@ protected function move_files_in_answers($questionid, $oldcontextid,
}
/**
+ * Move all the files belonging to this question's hints 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_hints($questionid, $oldcontextid, $newcontextid) {
+ global $DB;
+ $fs = get_file_storage();
+
+ $hintids = $DB->get_records_menu('question_hints',
+ array('questionid' => $questionid), 'id', 'id,1');
+ foreach ($hintids as $hintid => $notused) {
+ $fs->move_area_files_to_new_context($oldcontextid,
+ $newcontextid, 'question', 'hint', $hintid);
+ }
+ }
+
+ /**
* 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.
@@ -1172,6 +1193,22 @@ protected function delete_files_in_answers($questionid, $contextid, $answerstoo
}
/**
+ * Delete all the files belonging to this question's hints.
+ * @param int $questionid the question being deleted.
+ * @param int $contextid the context the question is in.
+ */
+ protected function delete_files_in_hints($questionid, $contextid) {
+ global $DB;
+ $fs = get_file_storage();
+
+ $hintids = $DB->get_records_menu('question_hints',
+ array('questionid' => $questionid), 'id', 'id,1');
+ foreach ($hintids as $hintid => $notused) {
+ $fs->delete_area_files($contextid, 'question', 'hint', $hintid);
+ }
+ }
+
+ /**
* 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.
@@ -49,11 +49,13 @@ public function questionid_column_name() {
public function move_files($questionid, $oldcontextid, $newcontextid) {
parent::move_files($questionid, $oldcontextid, $newcontextid);
$this->move_files_in_answers($questionid, $oldcontextid, $newcontextid);
+ $this->move_files_in_hints($questionid, $oldcontextid, $newcontextid);
}
protected function delete_files($questionid, $contextid) {
parent::delete_files($questionid, $contextid);
$this->delete_files_in_answers($questionid, $contextid);
+ $this->delete_files_in_hints($questionid, $contextid);
}
public function save_question_options($question) {

0 comments on commit bd4b665

Please sign in to comment.