Skip to content

Commit

Permalink
quiz editing: MDL-17298 We should not add JavaScript to the YAHOO nam…
Browse files Browse the repository at this point in the history
…espace Also, use the newer methods for including required JavaScript.
  • Loading branch information
tjhunt committed Nov 25, 2008
1 parent 9429952 commit 1372b5d
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 44 deletions.
27 changes: 12 additions & 15 deletions mod/quiz/edit.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
/** JavaScript for /mod/quiz/edit.php
*/

YAHOO.namespace("cats.container");
YAHOO.namespace("quiz.container");
function init() {
var quiz_edit = {};
function quiz_edit_init() {
YAHOO.util.Dom.setStyle('randomquestiondialog', 'display', 'block');
/* zIndex must be way above 99 to be above the active quiz tab*/
YAHOO.quiz.container.randomquestiondialog = new YAHOO.widget.Dialog("randomquestiondialog",
quiz_edit.randomquestiondialog = new YAHOO.widget.Dialog("randomquestiondialog",
{
constraintoviewport : true,
visible : false,
Expand All @@ -19,12 +17,11 @@ function init() {
draggable: true,
dragOnly: true,
postmethod: "form"

} );
//show the dialog and depending on from which form (corresponding
// a specific quiz page) it was triggered, set the value of the form's
// rqpage input element to the form number
YAHOO.util.Event.addListener(this.dialog_listeners, "click",
YAHOO.util.Event.addListener(this.dialoglisteners, "click",
function(e){
this.show();
var rbutton = YAHOO.util.Event.getTarget(e);
Expand All @@ -43,12 +40,12 @@ function init() {
}
}
YAHOO.util.Event.stopEvent(e);
}, YAHOO.quiz.container.randomquestiondialog,
YAHOO.quiz.container.randomquestiondialog, true);
YAHOO.quiz.container.randomquestiondialog.render();
}, quiz_edit.randomquestiondialog,
quiz_edit.randomquestiondialog, true);
quiz_edit.randomquestiondialog.render();


YAHOO.quiz.container.repaginatedialog = new YAHOO.widget.Dialog("repaginatedialog",
quiz_edit.repaginatedialog = new YAHOO.widget.Dialog("repaginatedialog",
{
modal:true,
width : "100%",
Expand All @@ -66,11 +63,11 @@ function init() {
function(e){
YAHOO.util.Dom.setStyle('repaginatedialog', 'display', 'block');
this.show();
}, YAHOO.quiz.container.repaginatedialog,
YAHOO.quiz.container.repaginatedialog, true);
YAHOO.quiz.container.repaginatedialog.render();
}, quiz_edit.repaginatedialog,
quiz_edit.repaginatedialog, true);
quiz_edit.repaginatedialog.render();

}

YAHOO.util.Event.onDOMReady(init,phpGenerated,true);
YAHOO.util.Event.onDOMReady(quiz_edit_init, quiz_edit_config, true);
YAHOO.util.Dom.setStyle('repaginatedialog', 'display', 'block');
46 changes: 17 additions & 29 deletions mod/quiz/edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -542,51 +542,39 @@ function module_specific_controls($totalnumber, $recurse, $category, $cmid, $cmo
question_showbank_actions($thispageurl, $cm);

/// all commands have been dealt with, now print the page
$questionbankmanagement='<a href="'.$CFG->wwwroot.
'/question/edit.php?courseid='.$course->id.'">'.
get_string("questionbankmanagement","quiz").'</a> ';

if (isset($quiz->instance) and $DB->record_exists_select('quiz_attempts',
"quiz = ? AND preview = '0'", array($quiz->instance))){
$quiz_has_attempts=true;
}

// Print the header.
$questionbankmanagement='<a href="'.$CFG->wwwroot.
'/question/edit.php?courseid='.$course->id.'">'.
get_string("questionbankmanagement","quiz").'</a> ';
$strupdatemodule = has_capability('moodle/course:manageactivities',
$contexts->lowest()) ?
update_module_button($cm->id, $course->id,
get_string('modulename', 'quiz')) :
"";
$navigation = build_navigation($pagetitle, $cm);

$quiz_randomquestion_dialog_listeners='this.dialog_listeners=[';
if(($numberoflisteners=quiz_number_of_pages($quiz->questions))==0){
$numberoflisteners=1;
}
for($page_iter=1;$page_iter<=$numberoflisteners;$page_iter++){
if($page_iter!=1){
$quiz_randomquestion_dialog_listeners.= ',';
}
$quiz_randomquestion_dialog_listeners.= '"addrandomdialoglaunch_'.
$page_iter.'"';
}
$quiz_randomquestion_dialog_listeners.='];';
$surl=$thispageurl->out(false,array('qbanktool'=>'0'));
$surl_js="this.sUrl=\"$surl\";";
$localjs= '<script type="text/javascript" charset="utf-8">
function phpdata(){
'.$quiz_randomquestion_dialog_listeners.'
'.$surl_js.'
}
var phpGenerated=new phpdata();
</script>
<script type="text/javascript" src="'.$CFG->wwwroot.
'/mod/quiz/edit.js" charset="utf-8"></script>
';
$localcss= '<link rel="stylesheet" type="text/css" href="'.$CFG->wwwroot.
'/lib/yui/container/assets/container.css" />';
print_header_simple($pagetitle, '', $navigation, "", $localcss,true,
$questionbankmanagement.$strupdatemodule);
echo $localjs;

// Initialise the JavaScript.
$quizeditconfig = new stdClass;
$quizeditconfig->url = $thispageurl->out(false, array('qbanktool' => '0'));
$quizeditconfig->dialoglisteners =array();
$numberoflisteners = max(quiz_number_of_pages($quiz->questions), 1);
for ($pageiter = 1; $pageiter <= $numberoflisteners; $pageiter++) {
$quizeditconfig->dialoglisteners[] = 'addrandomdialoglaunch_' . $pageiter;
}
print_js_config($quizeditconfig, 'quiz_edit_config');
require_js('mod/quiz/edit.js');

// Print the tabs.
$mode = 'editq';
$currenttab="edit";
if($quiz_reordertool){
Expand Down

0 comments on commit 1372b5d

Please sign in to comment.