From 9b2ccabae80e8ed8106a0deba2cd6bcce462909f Mon Sep 17 00:00:00 2001 From: Jamie Pratt Date: Sat, 20 Aug 2011 20:52:38 +0700 Subject: [PATCH] MDL-47494 ddimageortext: NOBUG added feedback for student when they have not dragged an image to each drop zone. --- .../type/ddimageortext/lang/en/qtype_ddimagetoimage.php | 1 + question/type/ddimageortext/question.php | 6 ++++++ question/type/ddimageortext/renderer.php | 5 +++++ 3 files changed, 12 insertions(+) diff --git a/question/type/ddimageortext/lang/en/qtype_ddimagetoimage.php b/question/type/ddimageortext/lang/en/qtype_ddimagetoimage.php index 1f744a6e232..e065751d67b 100644 --- a/question/type/ddimageortext/lang/en/qtype_ddimagetoimage.php +++ b/question/type/ddimageortext/lang/en/qtype_ddimagetoimage.php @@ -48,6 +48,7 @@ $string['formerror_nobgimage'] = 'You need to select an image to use as the back $string['infinite'] = 'Infinite'; $string['label'] = 'Label'; $string['nolabel'] = 'No label text'; +$string['pleasedraganimagetoeachdropregion'] = 'Your answer is not complete, please drag an image to each drop region.'; $string['previewarea'] = 'Preview area -'; $string['previewareaheader'] = 'Preview'; $string['previewareamessage'] = ''; diff --git a/question/type/ddimageortext/question.php b/question/type/ddimageortext/question.php index 9e76dcf5068..42439880685 100755 --- a/question/type/ddimageortext/question.php +++ b/question/type/ddimageortext/question.php @@ -99,6 +99,12 @@ class qtype_ddimagetoimage_question extends qtype_gapselect_question_base { $filearea, $args, $forcedownload); } } + public function get_validation_error(array $response) { + if ($this->is_complete_response($response)) { + return ''; + } + return get_string('pleasedraganimagetoeachdropregion', 'qtype_ddimagetoimage'); + } } diff --git a/question/type/ddimageortext/renderer.php b/question/type/ddimageortext/renderer.php index 4b28e5e8731..8805b2d9ea5 100755 --- a/question/type/ddimageortext/renderer.php +++ b/question/type/ddimageortext/renderer.php @@ -119,6 +119,11 @@ class qtype_ddimagetoimage_renderer extends qtype_with_combined_feedback_rendere $sendtojs, true, $jsmodule); + if ($qa->get_state() == question_state::$invalid) { + $output .= html_writer::nonempty_tag('div', + $question->get_validation_error($qa->get_last_qt_data()), + array('class' => 'validationerror')); + } return $output; }