From a3be6d9da12cd8a45fb975c5835eb9398da488b4 Mon Sep 17 00:00:00 2001 From: Jamie Pratt Date: Thu, 8 Sep 2011 19:22:46 +0700 Subject: [PATCH] MDL-47494 ddimageortext: NOBUG started making this a mixed question type with draggable text as welll as draggable images. --- .../edit_ddimagetoimage_form.php | 8 ++----- question/type/ddimageortext/renderer.php | 22 +++++++++++++++---- question/type/ddimageortext/yui/dd/dd.js | 2 +- question/type/ddimageortext/yui/form/form.js | 4 ++-- 4 files changed, 23 insertions(+), 13 deletions(-) diff --git a/question/type/ddimageortext/edit_ddimagetoimage_form.php b/question/type/ddimageortext/edit_ddimagetoimage_form.php index 1f9e41e5874..7b255359d54 100644 --- a/question/type/ddimageortext/edit_ddimagetoimage_form.php +++ b/question/type/ddimageortext/edit_ddimagetoimage_form.php @@ -276,6 +276,7 @@ class qtype_ddimagetoimage_edit_form extends question_edit_form { $PAGE->requires->yui_module('moodle-qtype_ddimagetoimage-form', 'M.qtype_ddimagetoimage.init_form', array($params)); + //$PAGE->requires->css('/lib/yui/3.4.0/build/csscssfonts/fonts-context-min.css'); return $question; } @@ -316,12 +317,7 @@ class qtype_ddimagetoimage_edit_form extends question_edit_form { $errors["drops[$i]"] = get_string('formerror_noxleft', 'qtype_ddimagetoimage'); } - if (!self::file_uploaded($data['dragitem'][$choice - 1])) { - $errors["drops[$i]"] = - get_string('formerror_nofile', 'qtype_ddimagetoimage', $choice); - $errors['dragitem['.($choice - 1).']'] = - get_string('formerror_nofile2', 'qtype_ddimagetoimage', $i); - } + if (isset($allchoices[$choice]) && !$data['drags'][$choice-1]['infinite']) { $errors["drops[$i]"] = get_string('formerror_multipledraginstance', 'qtype_ddimagetoimage', $choice); diff --git a/question/type/ddimageortext/renderer.php b/question/type/ddimageortext/renderer.php index 6f8d585c3c6..7b23f86a11b 100755 --- a/question/type/ddimageortext/renderer.php +++ b/question/type/ddimageortext/renderer.php @@ -37,7 +37,12 @@ require_once($CFG->dirroot . '/question/type/gapselect/rendererbase.php'); */ class qtype_ddimagetoimage_renderer extends qtype_with_combined_feedback_renderer { - + public function head_code(question_attempt $qa) { + $this->page->requires->css('/lib/yui/3.4.0/build/csscssfonts/fonts-context-min.css'); + $this->page->requires->yui2_lib('event'); + $this->page->requires->yui2_lib('dragdrop'); + return parent::head_code($qa); + } public function clear_wrong(question_attempt $qa) { $question = $qa->get_question(); $response = $qa->get_last_qt_data(); @@ -84,9 +89,18 @@ class qtype_ddimagetoimage_renderer extends qtype_with_combined_feedback_rendere if ($dragimage->isinfinite) { $classes[] = 'infinite'; } - $dragimagehomesgroup .= html_writer::empty_tag('img', - array('src'=>$dragimageurl, - 'class'=>join(' ', $classes))); + if ($dragimageurl === null) { + $classes[] = 'yui3-cssfonts'; + $dragimagehomesgroup .= html_writer::tag('div', + $dragimage->text, + array('src'=>$dragimageurl, + 'class'=>join(' ', $classes))); + } else { + $dragimagehomesgroup .= html_writer::empty_tag('img', + array('src'=>$dragimageurl, + 'alt' => $dragimage->text, + 'class'=>join(' ', $classes))); + } } $dragimagehomes .= html_writer::tag('div', $dragimagehomesgroup, array('class'=>'dragitemgroup'.$groupno)); diff --git a/question/type/ddimageortext/yui/dd/dd.js b/question/type/ddimageortext/yui/dd/dd.js index 622db858bc7..1f45d634df5 100644 --- a/question/type/ddimageortext/yui/dd/dd.js +++ b/question/type/ddimageortext/yui/dd/dd.js @@ -87,7 +87,7 @@ YUI.add('moodle-qtype_ddimagetoimage-dd', function(Y) { var oldhome = this.drag_image_home(dragimageno); var classes = 'draghome dragimagehomes'+dragimageno+' group'+group; var imghtml = ''+alt+''; - var divhtml = '
'+alt+'
'; + var divhtml = '
'+alt+'
'; if (oldhome === null) { if (url) { dragimagesarea.append(imghtml); diff --git a/question/type/ddimageortext/yui/form/form.js b/question/type/ddimageortext/yui/form/form.js index ce84daf032b..f68362ec790 100644 --- a/question/type/ddimageortext/yui/form/form.js +++ b/question/type/ddimageortext/yui/form/form.js @@ -14,8 +14,8 @@ YUI.add('moodle-qtype_ddimagetoimage-form', function(Y) { Y.one(this.get('topnode')).append('
'+ '
'+ '
'); - this.doc = this.doc_structure(this); - this.draw_dd_area(); + //this.doc = this.doc_structure(this); + //this.draw_dd_area(); }, draw_dd_area : function() {