MDL-20636 Finish making ddwtos work, mostly. Also various other JS fixes.
authorTim Hunt <T.J.Hunt@open.ac.uk>
Wed, 2 Feb 2011 19:03:38 +0000 (19:03 +0000)
committerTim Hunt <T.J.Hunt@open.ac.uk>
Wed, 2 Feb 2011 19:03:38 +0000 (19:03 +0000)
This JavaScript really needs to be rewritten to use YUI3.

question/preview.js
question/qengine.js
question/type/ddwtos/renderer.php
question/type/ddwtos/styles.css
question/type/gapselect/questionbase.php

index 511ea1c..73d7cef 100644 (file)
@@ -35,7 +35,7 @@ M.core_question_preview.init = function(Y) {
 
     // Add a close button to the window.
     var closebutton = Y.Node.create('<input type="button" />');
-    button.value = M.str.question.closepreview;
+    closebutton.set('value', M.str.question.closepreview);
     Y.one('#previewcontrols').append(closebutton);
     Y.on('click', function() { window.close() }, closebutton);
 
index f8f0663..dcd708a 100644 (file)
@@ -11,14 +11,15 @@ M.core_question_engine.questionformalreadysubmitted = false;
  * @param id the id of the button in the HTML.
  * @param slot the number of the question_attempt within the usage.
  */
-M.core_question_engine.init_submit_button(Y, button, slot) {
+M.core_question_engine.init_submit_button = function(Y, button, slot) {
+    var buttonel = document.getElementById(button);
     Y.on('click', function(e) {
         var scrollpos = document.getElementById('scrollpos');
         if (scrollpos) {
             scrollpos.value = YAHOO.util.Dom.getDocumentScrollTop();
         }
-        button.form.action = button.form.action + '#q' + slot;
-    }, button);
+        buttonel.form.action = buttonel.form.action + '#q' + slot;
+    }, buttonel);
 }
 
 /**
@@ -68,14 +69,14 @@ M.core_question_engine.init_form = function(Y, form) {
  * @param e the form submit event.
  * @param form the form element.
  */
-M.core_question_engine.prevent_repeat_submission(e, Y) {
+M.core_question_engine.prevent_repeat_submission = function(e, Y) {
     if (M.core_question_engine.questionformalreadysubmitted) {
         e.halt();
         return;
     }
 
     setTimeout(function() {
-        Y.all('input[type=submit]').disabled = true;
+        Y.all('input[type=submit]').set('disabled', true);
     }, 0);
     M.core_question_engine.questionformalreadysubmitted = true;
 }
@@ -84,7 +85,7 @@ M.core_question_engine.prevent_repeat_submission(e, Y) {
  * Beat IE into submission.
  * @param targetpos the target scroll position.
  */
-M.core_question_engine.force_ie_to_scroll(targetpos) {
+M.core_question_engine.force_ie_to_scroll = function(targetpos) {
     var hackcount = 25;
     function do_scroll() {
         window.scrollTo(0, targetpos);
index 8f4362f..8be3eea 100644 (file)
@@ -127,7 +127,9 @@ class qtype_ddwtos_renderer extends qtype_elements_embedded_in_question_text_ren
 
 
     public function head_code(question_attempt $qa) {
-        require_js(array('yui_dom-event', 'yui_dragdrop'));
+        $this->page->requires->yui2_lib('dom');
+        $this->page->requires->yui2_lib('event');
+        $this->page->requires->yui2_lib('dragdrop');
         return parent::head_code($qa);
     }
 
index 991b59e..8a84a09 100644 (file)
@@ -1,13 +1,16 @@
 .que.ddwtos .qtext {
-    line-height:2em;
-    margin-top: 1px;
+    line-height: 2em;
     margin-bottom: 0.5em;
     display: block;
 }
 
+.que.ddwtos .qtext * {
+    line-height: 2em;
+}
+
 .que.ddwtos .answercontainer {
     line-height: 2em;
-    margin-bottom:1em;
+    margin-bottom: 1em;
     display: block;
 }
 
index 52857ee..eb4da07 100644 (file)
@@ -283,4 +283,17 @@ abstract class qtype_gapselect_question_base extends question_graded_automatical
         }
         return $parts;
     }
+
+    public function check_file_access($qa, $options, $component, $filearea, $args, $forcedownload) {
+        if ($component == 'question' && in_array($filearea,
+                array('correctfeedback', 'partiallycorrectfeedback', 'incorrectfeedback'))) {
+            return $this->check_combined_feedback_file_access($qa, $options, $filearea);
+
+        } else if ($component == 'question' && $filearea == 'hint') {
+            return $this->check_hint_file_access($qa, $options, $args);
+
+        } else {
+            return parent::check_file_access($qa, $options, $component, $filearea, $args, $forcedownload);
+        }
+    }
 }