Missingtype now also works without notices when the missing question has no answers.

This commit is contained in:
gustav_delius
2006-04-30 17:30:22 +00:00
parent ed28abca24
commit 2be604b665
2 changed files with 23 additions and 20 deletions
+15 -15
View File
@@ -1,4 +1,3 @@
<?php notify('This question is of a type that has not been installed on your Moodle yet.<br />Please alert your Moodle administrator.'); ?>
<div class="qtext">
<?php echo $questiontext; ?>
</div>
@@ -7,18 +6,19 @@
<img class="qimage" src="<?php echo $image; ?>" alt="" />
<?php } ?>
<div class="ablock clearfix">
<div class="prompt">
<?php print_string('answers', 'quiz'); ?>
<?php if ($anss) { ?>
<div class="ablock clearfix">
<div class="prompt">
<?php print_string('answers', 'quiz'); ?>
</div>
<table class="answer">
<?php $row = 1; foreach ($anss as $answer) { ?>
<tr class="<?php echo 'r'.$row = $row ? 0 : 1; ?>">
<td class="c1 text">
<?php echo $answer->text; ?>
</td>
</tr>
<?php } ?>
</table>
</div>
<table class="answer">
<?php $row = 1; foreach ($anss as $answer) { ?>
<tr class="<?php echo 'r'.$row = $row ? 0 : 1; ?>">
<td class="c1 text">
<?php echo $answer->text; ?>
</td>
</tr>
<?php } ?>
</table>
</div>
<?php } ?>
+8 -5
View File
@@ -34,11 +34,14 @@ class question_missingtype_qtype extends default_questiontype {
$formatoptions, $cmoptions->course);
$image = get_question_image($question, $cmoptions->course);
// Print each answer in a separate row
foreach ($answers as $answer) {
$a->text = format_text("$answer->answer", FORMAT_MOODLE, $formatoptions, $cmoptions->course);
$anss[] = clone($a);
// Print each answer in a separate row if there are any
$anss = array();
if ($answers) {
foreach ($answers as $answer) {
$a->text = format_text("$answer->answer", FORMAT_MOODLE, $formatoptions, $cmoptions->course);
$anss[] = clone($a);
}
}
include("$CFG->dirroot/question/type/missingtype/display.html");
}