Skip to content

Commit

Permalink
MDL-11081 and MDL-11211 - Implement quiz_question_list_instances. The…
Browse files Browse the repository at this point in the history
… lach of this function was causing a horrible dataloss bug: MDL-11211. Fix thanks to Janne Mikkonen, refined by me.
  • Loading branch information
tjhunt committed Sep 13, 2007
1 parent 3e3a800 commit 8a3df96
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion mod/quiz/lib.php
Expand Up @@ -682,11 +682,25 @@ function quiz_get_post_actions() {
/** /**
* Returns an array of names of quizzes that use this question * Returns an array of names of quizzes that use this question
* *
* TODO: write this
* @param object $questionid * @param object $questionid
* @return array of strings * @return array of strings
*/ */
function quiz_question_list_instances($questionid) { function quiz_question_list_instances($questionid) {
global $CFG;

// TODO: we should also consider other questions that are used by
// random questions in this quiz, but that is very hard.

$sql = "SELECT q.id, q.name
FROM {$CFG->prefix}quiz q
INNER JOIN
{$CFG->prefix}quiz_question_instances qqi
ON q.id = qqi.quiz
WHERE qqi.question = '$questionid'";

if ($instances = get_records_sql_menu($sql)) {
return $instances;
}
return array(); return array();
} }


Expand Down

0 comments on commit 8a3df96

Please sign in to comment.