mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 16:36:37 +02:00
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:
parent
706d06e29b
commit
0fafed0f09
5 changed files with 30 additions and 11 deletions
|
@ -35,7 +35,7 @@ M.core_question_preview.init = function(Y) {
|
||||||
|
|
||||||
// Add a close button to the window.
|
// Add a close button to the window.
|
||||||
var closebutton = Y.Node.create('<input type="button" />');
|
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.one('#previewcontrols').append(closebutton);
|
||||||
Y.on('click', function() { window.close() }, closebutton);
|
Y.on('click', function() { window.close() }, closebutton);
|
||||||
|
|
||||||
|
|
|
@ -11,14 +11,15 @@ M.core_question_engine.questionformalreadysubmitted = false;
|
||||||
* @param id the id of the button in the HTML.
|
* @param id the id of the button in the HTML.
|
||||||
* @param slot the number of the question_attempt within the usage.
|
* @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) {
|
Y.on('click', function(e) {
|
||||||
var scrollpos = document.getElementById('scrollpos');
|
var scrollpos = document.getElementById('scrollpos');
|
||||||
if (scrollpos) {
|
if (scrollpos) {
|
||||||
scrollpos.value = YAHOO.util.Dom.getDocumentScrollTop();
|
scrollpos.value = YAHOO.util.Dom.getDocumentScrollTop();
|
||||||
}
|
}
|
||||||
button.form.action = button.form.action + '#q' + slot;
|
buttonel.form.action = buttonel.form.action + '#q' + slot;
|
||||||
}, button);
|
}, buttonel);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -68,14 +69,14 @@ M.core_question_engine.init_form = function(Y, form) {
|
||||||
* @param e the form submit event.
|
* @param e the form submit event.
|
||||||
* @param form the form element.
|
* @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) {
|
if (M.core_question_engine.questionformalreadysubmitted) {
|
||||||
e.halt();
|
e.halt();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
Y.all('input[type=submit]').disabled = true;
|
Y.all('input[type=submit]').set('disabled', true);
|
||||||
}, 0);
|
}, 0);
|
||||||
M.core_question_engine.questionformalreadysubmitted = true;
|
M.core_question_engine.questionformalreadysubmitted = true;
|
||||||
}
|
}
|
||||||
|
@ -84,7 +85,7 @@ M.core_question_engine.prevent_repeat_submission(e, Y) {
|
||||||
* Beat IE into submission.
|
* Beat IE into submission.
|
||||||
* @param targetpos the target scroll position.
|
* @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;
|
var hackcount = 25;
|
||||||
function do_scroll() {
|
function do_scroll() {
|
||||||
window.scrollTo(0, targetpos);
|
window.scrollTo(0, targetpos);
|
||||||
|
|
|
@ -127,7 +127,9 @@ class qtype_ddwtos_renderer extends qtype_elements_embedded_in_question_text_ren
|
||||||
|
|
||||||
|
|
||||||
public function head_code(question_attempt $qa) {
|
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);
|
return parent::head_code($qa);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,13 +1,16 @@
|
||||||
.que.ddwtos .qtext {
|
.que.ddwtos .qtext {
|
||||||
line-height:2em;
|
line-height: 2em;
|
||||||
margin-top: 1px;
|
|
||||||
margin-bottom: 0.5em;
|
margin-bottom: 0.5em;
|
||||||
display: block;
|
display: block;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.que.ddwtos .qtext * {
|
||||||
|
line-height: 2em;
|
||||||
|
}
|
||||||
|
|
||||||
.que.ddwtos .answercontainer {
|
.que.ddwtos .answercontainer {
|
||||||
line-height: 2em;
|
line-height: 2em;
|
||||||
margin-bottom:1em;
|
margin-bottom: 1em;
|
||||||
display: block;
|
display: block;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -283,4 +283,17 @@ abstract class qtype_gapselect_question_base extends question_graded_automatical
|
||||||
}
|
}
|
||||||
return $parts;
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue