Skip to content

Commit

Permalink
MDL-31080 quiz editing, must be able to see and delete missing questions
Browse files Browse the repository at this point in the history
  • Loading branch information
timhunt committed Jan 12, 2012
1 parent c1dc3a5 commit ce7595e
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 19 deletions.
23 changes: 10 additions & 13 deletions mod/quiz/editlib.php
Expand Up @@ -462,19 +462,16 @@ function quiz_print_question_list($quiz, $pageurl, $allowdelete, $reordertool,
$reordercheckboxlabel = '';
$reordercheckboxlabelclose = '';

if ($qnum && empty($questions[$qnum])) {
continue;
}

// If the questiontype is missing change the question type
if ($qnum && !array_key_exists($qnum, $questions)) {
$fakequestion = new stdClass();
$fakequestion->id = 0;
$fakequestion->id = $qnum;
$fakequestion->category = 0;
$fakequestion->qtype = 'missingtype';
$fakequestion->name = get_string('deletedquestion', 'qtype_missingtype');
$fakequestion->questiontext = '<p>' .
get_string('deletedquestion', 'qtype_missing') . '</p>';
$fakequestion->length = 0;
$fakequestion->name = get_string('missingquestion', 'quiz');
$fakequestion->questiontext = ' ';
$fakequestion->questiontextformat = FORMAT_HTML;
$fakequestion->length = 1;
$questions[$qnum] = $fakequestion;
$quiz->grades[$qnum] = 0;

Expand Down Expand Up @@ -581,7 +578,7 @@ function quiz_print_question_list($quiz, $pageurl, $allowdelete, $reordertool,
array('title' => $strmovedown));
}
}
if ($allowdelete && (empty($question->id) ||
if ($allowdelete && ($question->qtype == 'missingtype' ||
question_has_capability_on($question, 'use', $question->category))) {
// remove from quiz, not question delete.
if (!$hasattempts) {
Expand All @@ -595,7 +592,7 @@ function quiz_print_question_list($quiz, $pageurl, $allowdelete, $reordertool,
}
?>
</div><?php
if ($question->qtype != 'description' && !$reordertool) {
if (!in_array($question->qtype, array('description', 'missingtype')) && !$reordertool) {
?>
<div class="points">
<form method="post" action="edit.php" class="quizsavegradesform"><div>
Expand Down Expand Up @@ -777,7 +774,7 @@ function quiz_print_pagecontrols($quiz, $pageurl, $page, $hasattempts, $defaultc
* @param object $quiz The quiz in the context of which the question is being displayed
*/
function quiz_print_singlequestion($question, $returnurl, $quiz) {
echo '<div class="singlequestion">';
echo '<div class="singlequestion ' . $question->qtype . '">';
echo quiz_question_edit_button($quiz->cmid, $question, $returnurl,
quiz_question_tostring($question) . ' ');
echo '<span class="questiontype">';
Expand Down Expand Up @@ -884,7 +881,7 @@ function quiz_print_randomquestion(&$question, &$pageurl, &$quiz, $quiz_qbanktoo
* @param object $quiz The quiz in the context of which the question is being displayed
*/
function quiz_print_singlequestion_reordertool($question, $returnurl, $quiz) {
echo '<div class="singlequestion">';
echo '<div class="singlequestion ' . $question->qtype . '">';
echo '<label for="s' . $question->id . '">';
echo print_question_icon($question);
echo ' ' . quiz_question_tostring($question);
Expand Down
1 change: 1 addition & 0 deletions mod/quiz/lang/en/quiz.php
Expand Up @@ -402,6 +402,7 @@
$string['minutes'] = 'Minutes';
$string['missingcorrectanswer'] = 'Correct answer must be specified';
$string['missingitemtypename'] = 'Missing name';
$string['missingquestion'] = 'This question no longer seems to exist';
$string['modulename'] = 'Quiz';
$string['modulename_help'] = 'The quiz module enables the teacher to design and set quizzes consisting of multiple choice, true-false, matching and other question types. Each attempt is automatically marked, and the teacher can choose whether to give feedback and/or show correct answers.';
$string['modulenameplural'] = 'Quizzes';
Expand Down
6 changes: 4 additions & 2 deletions mod/quiz/locallib.php
Expand Up @@ -855,11 +855,13 @@ function quiz_question_edit_button($cmid, $question, $returnurl, $contentafteric
}
$questionparams = array('returnurl' => $returnurl, 'cmid' => $cmid, 'id' => $question->id);
$questionurl = new moodle_url("$CFG->wwwroot/question/question.php", $questionparams);
return '<a title="' . $action . '" href="' . $questionurl->out() . '"><img src="' .
return '<a title="' . $action . '" href="' . $questionurl->out() . '" class="questioneditbutton"><img src="' .
$OUTPUT->pix_url($icon) . '" alt="' . $action . '" />' . $contentaftericon .
'</a>';
} else if ($contentaftericon) {
return '<span class="questioneditbutton">' . $contentaftericon . '</span>';
} else {
return $contentaftericon;
return '';
}
}

Expand Down
10 changes: 6 additions & 4 deletions mod/quiz/styles.css
Expand Up @@ -264,8 +264,10 @@ table#categoryquestions {width: 100%;overflow: hidden;table-layout: fixed;}
#page-mod-quiz-edit .editq div.question div.content .questionpreview {float:left;}
#page-mod-quiz-edit .editq div.question div.content .questionpreview a{font-weight:normal;margin-left:0em;display:inline;float:none;}
#page-mod-quiz-edit .editq div.question div.content .randomquestioncategory .questionpreview img{padding-right:0.3em;}
#page-mod-quiz-edit .editq div.question div.content .singlequestion a .questionname,
#page-mod-quiz-edit .editq div.question div.content .singlequestion a .questiontext{float:left;}
#page-mod-quiz-edit .editq div.question div.content .singlequestion .questioneditbutton .questionname,
#page-mod-quiz-edit .editq div.question div.content .singlequestion .questioneditbutton .questiontext{float:left;}
#page-mod-quiz-edit .reorder div.question div.content .singlequestion.missingtype .questionname,
#page-mod-quiz-edit .editq div.question div.content .singlequestion.missingtype .questionname {font-style: italic; max-width: 75%;}
#page-mod-quiz-edit .editq div.question div.description div.content .questiontext {max-width: 75%;}
#page-mod-quiz-edit .editq div.question div.qnum{font-size:1.5em;}

Expand Down Expand Up @@ -397,8 +399,8 @@ bank window's title is prominent enough*/
#page-mod-quiz-edit.dir-rtl div.editq div.question div.content {float: right;height: 40px;}
#page-mod-quiz-edit.dir-rtl div.question div.content div.points {left: 50px;right:auto;}
#page-mod-quiz-edit.dir-rtl div.question div.content div.questioncontrols {float: left;left: 0.3em; right:auto;}
#page-mod-quiz-edit.dir-rtl .editq div.question div.content .singlequestion a .questionname,
#page-mod-quiz-edit.dir-rtl .editq div.question div.content .singlequestion a .questiontext {float: right; padding-right: 0.3em;}
#page-mod-quiz-edit.dir-rtl .editq div.question div.content .singlequestion .questioneditbutton .questionname,
#page-mod-quiz-edit.dir-rtl .editq div.question div.content .singlequestion .questioneditbutton .questiontext {float: right; padding-right: 0.3em;}
#page-mod-quiz-edit.dir-rtl div.question div.content .questiontext,
#page-mod-quiz-edit.dir-rtl #categoryquestions .questiontext {padding-right: 0.3em;}
#page-mod-quiz-edit.dir-rtl .editq div.questioncontentcontainer div.singlequestion img {float: right;}
Expand Down

0 comments on commit ce7595e

Please sign in to comment.