MDL-20636 Finish making ddwtos work, mostly. Also various other JS fixes.

This JavaScript really needs to be rewritten to use YUI3.
This commit is contained in:
Tim Hunt 2011-02-02 19:03:38 +00:00
parent 706d06e29b
commit 0fafed0f09
5 changed files with 30 additions and 11 deletions

View 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);

View 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);

View 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);
}

View file

@ -1,10 +1,13 @@
.que.ddwtos .qtext {
line-height: 2em;
margin-top: 1px;
margin-bottom: 0.5em;
display: block;
}
.que.ddwtos .qtext * {
line-height: 2em;
}
.que.ddwtos .answercontainer {
line-height: 2em;
margin-bottom: 1em;

View 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);
}
}
}