Skip to content
Permalink
Browse files

Moved function quiz_question_used from mod/quiz/locallib.php to quest…

…ion_used in lib/questionlib. Fixed some more links.
  • Loading branch information...
gustav_delius
gustav_delius committed Feb 24, 2006
1 parent 219e92f commit 4b32fd66aba28ecb8f2054d40f6862aac320962e
Showing with 24 additions and 23 deletions.
  1. +19 −0 lib/questionlib.php
  2. +1 −19 mod/quiz/locallib.php
  3. +4 −4 question/question.php
@@ -1275,4 +1275,23 @@ function get_questions_category( $category, $noparent=false ) {
return $qresults;
}
/**
* Array of names of course modules a question appears in
*
* TODO: Currently this works with quiz only
*
* @return array Array of quiz names
* @param integer $id Question id
*/
function question_used($id) {
$quizlist = array();
if ($instances = get_records('quiz_question_instances', 'question', $id)) {
foreach($instances as $instance) {
$quizlist[$instance->quiz] = get_field('quiz', 'name', 'id', $instance->quiz);
}
}
return $quizlist;
}
?>
@@ -418,24 +418,6 @@ function quiz_view_dates($quiz) {
print_simple_box_end();
}
/**
* Array of names of quizzes a question appears in
*
* @return array Array of quiz names
* @param integer $id Question id
*/
function quizzes_question_used($id) {
$quizlist = array();
if ($instances = get_records('quiz_question_instances', 'question', $id)) {
foreach($instances as $instance) {
$quizlist[$instance->quiz] = get_field('quiz', 'name', 'id', $instance->quiz);
}
}
return $quizlist;
}
/**
* Parse field names used for the replace options on question edit forms
@@ -559,7 +541,7 @@ function quizzes_category_used($id, $recursive = false) {
//Look for each question in the category
if ($questions = get_records('quiz_questions', 'category', $id)) {
foreach ($questions as $question) {
$qlist = quizzes_question_used($question->id);
$qlist = question_used($question->id);
$quizlist = $quizlist + $qlist;
}
}
@@ -98,7 +98,7 @@
// TODO: remove restriction to quiz
$streditingquestion = get_string('editingquestion', 'quiz');
if (isset($SESSION->modform->instance)) {
$strediting = '<a href="edit.php">'.get_string('editingquiz', 'quiz').'</a> -> '.
$strediting = '<a href=".$editurl.">'.get_string('editingquiz', 'quiz').'</a> -> '.
$streditingquestion;
} else {
$strediting = '<a href="edit.php?courseid='.$course->id.'">'.
@@ -123,21 +123,21 @@
error("An error occurred trying to delete question (id $question->id)");
}
}
redirect("edit.php");
redirect($editurl);
} else {
error("Confirmation string was incorrect");
}
} else {
// TODO: check for other modules using this question
if ($quiznames = quizzes_question_used($id)) {
if ($quiznames = question_used($id)) {
$a->questionname = $question->name;
$a->quiznames = implode(', ', $quiznames);
notify(get_string('questioninuse', 'quiz', $a));
}
notice_yesno(get_string("deletequestioncheck", "quiz", $question->name),
"question.php?sesskey=$USER->sesskey&amp;id=$question->id&amp;delete=$delete&amp;confirm=".md5($delete), "edit.php");
"question.php?sesskey=$USER->sesskey&amp;id=$question->id&amp;delete=$delete&amp;confirm=".md5($delete), $editurl);
}
print_footer($course);
exit;

0 comments on commit 4b32fd6

Please sign in to comment.
You can’t perform that action at this time.