mirror of
https://github.com/moodle/moodle.git
synced 2025-08-06 17:36:38 +02:00
display template for shortanswer questions
This commit is contained in:
parent
b9709b76d9
commit
3fc63cbe96
2 changed files with 40 additions and 10 deletions
30
mod/quiz/questiontypes/shortanswer/display.html
Normal file
30
mod/quiz/questiontypes/shortanswer/display.html
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
<div class="qtext">
|
||||||
|
<?php echo $questiontext; ?>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<?php if ($image) { ?>
|
||||||
|
<img class="qimage" src="<?php echo $q->imageurl; ?>" alt="" />
|
||||||
|
<?php } ?>
|
||||||
|
|
||||||
|
<div class="answer">
|
||||||
|
<div class="prompt">
|
||||||
|
<?php echo get_string("answer", "quiz").': '; ?>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="shortanswer">
|
||||||
|
<input type="text" <?php echo "$readonly $inputname $value"; ?> size="80"/>
|
||||||
|
</div>
|
||||||
|
<?php $this->print_question_submit_buttons($question, $state, $cmoptions, $options); ?>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<?php if ($feedback) { ?>
|
||||||
|
<div class="feedback">
|
||||||
|
<?php echo $feedback ?>
|
||||||
|
</div>
|
||||||
|
<?php } ?>
|
||||||
|
|
||||||
|
<?php if ($correctanswer) { ?>
|
||||||
|
<div class="correct">
|
||||||
|
<?php echo get_string('correctis', 'quiz', $correctanswer) ?>
|
||||||
|
</div>
|
||||||
|
<?php } ?>
|
|
@ -119,6 +119,7 @@ class quiz_shortanswer_qtype extends quiz_default_questiontype {
|
||||||
}
|
}
|
||||||
|
|
||||||
function print_question_formulation_and_controls(&$question, &$state, $cmoptions, $options) {
|
function print_question_formulation_and_controls(&$question, &$state, $cmoptions, $options) {
|
||||||
|
global $CFG;
|
||||||
/// This implementation is also used by question type NUMERICAL
|
/// This implementation is also used by question type NUMERICAL
|
||||||
$answers = &$question->options->answers;
|
$answers = &$question->options->answers;
|
||||||
$correctanswers = $this->get_correct_responses($question, $state);
|
$correctanswers = $this->get_correct_responses($question, $state);
|
||||||
|
@ -127,45 +128,44 @@ class quiz_shortanswer_qtype extends quiz_default_questiontype {
|
||||||
|
|
||||||
/// Print question text and media
|
/// Print question text and media
|
||||||
|
|
||||||
echo format_text($question->questiontext,
|
$questiontext = format_text($question->questiontext,
|
||||||
$question->questiontextformat,
|
$question->questiontextformat,
|
||||||
NULL, $cmoptions->course);
|
NULL, $cmoptions->course);
|
||||||
quiz_print_possible_question_image($question, $cmoptions->course);
|
$image = quiz_get_image($question, $cmoptions->course);
|
||||||
|
|
||||||
/// Print input controls
|
/// Print input controls
|
||||||
|
|
||||||
$stranswer = get_string("answer", "quiz");
|
|
||||||
if (isset($state->responses[''])) {
|
if (isset($state->responses[''])) {
|
||||||
$value = ' value="'.s($state->responses['']).'" ';
|
$value = ' value="'.s($state->responses['']).'" ';
|
||||||
} else {
|
} else {
|
||||||
$value = ' value="" ';
|
$value = ' value="" ';
|
||||||
}
|
}
|
||||||
$inputname = ' name="'.$nameprefix.'" ';
|
$inputname = ' name="'.$nameprefix.'" ';
|
||||||
echo "<p align=\"right\">$stranswer: <input type=\"text\" $readonly $inputname size=\"80\" $value /></p>";
|
|
||||||
|
|
||||||
|
$feedback = '';
|
||||||
if ($options->feedback) {
|
if ($options->feedback) {
|
||||||
$testedstate = clone($state);
|
$testedstate = clone($state);
|
||||||
$teststate = clone($state);
|
$teststate = clone($state);
|
||||||
foreach($answers as $answer) {
|
foreach($answers as $answer) {
|
||||||
$teststate->responses[''] = trim($answer->answer);
|
$teststate->responses[''] = trim($answer->answer);
|
||||||
if($this->compare_responses($question, $testedstate, $teststate)) {
|
if($answer->feedback and $this->compare_responses($question, $testedstate, $teststate)) {
|
||||||
quiz_print_comment($answer->feedback);
|
$feedback = format_text($answer->feedback, true, false);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$correctanswer = '';
|
||||||
if ($options->readonly && $options->correct_responses) {
|
if ($options->readonly && $options->correct_responses) {
|
||||||
$delimiter = '';
|
$delimiter = '';
|
||||||
$correct = '';
|
|
||||||
if ($correctanswers) {
|
if ($correctanswers) {
|
||||||
foreach ($correctanswers as $correctanswer) {
|
foreach ($correctanswers as $ca) {
|
||||||
$correct .= $delimiter.$correctanswer;
|
$correctanswer .= $delimiter.$ca;
|
||||||
$delimiter = ', ';
|
$delimiter = ', ';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
quiz_print_correctanswer($correct);
|
|
||||||
}
|
}
|
||||||
|
include("$CFG->dirroot/mod/quiz/questiontypes/shortanswer/display.html");
|
||||||
}
|
}
|
||||||
|
|
||||||
// ULPGC ecastro
|
// ULPGC ecastro
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue