예제 #1
0
 /**
  * Initialise the JavaScript for the general editing. (JavaScript for popups
  * is handled with the specific code for those.)
  *
  * @param structure $structure object containing the structure of the quiz.
  * @param \question_edit_contexts $contexts the relevant question bank contexts.
  * @param array $pagevars the variables from {@link \question_edit_setup()}.
  * @param \moodle_url $pageurl the canonical URL of this page.
  * @return bool Always returns true
  */
 protected function initialise_editing_javascript(structure $structure, \question_edit_contexts $contexts, array $pagevars, \moodle_url $pageurl)
 {
     $config = new \stdClass();
     $config->resourceurl = '/mod/quiz/edit_rest.php';
     $config->sectionurl = '/mod/quiz/edit_rest.php';
     $config->pageparams = array();
     $config->questiondecimalpoints = $structure->get_decimal_places_for_question_marks();
     $config->pagehtml = $this->new_page_template($structure, $contexts, $pagevars, $pageurl);
     $config->addpageiconhtml = $this->add_page_icon_template($structure);
     $this->page->requires->yui_module('moodle-mod_quiz-toolboxes', 'M.mod_quiz.init_resource_toolbox', array(array('courseid' => $structure->get_courseid(), 'quizid' => $structure->get_quizid(), 'ajaxurl' => $config->resourceurl, 'config' => $config)));
     unset($config->pagehtml);
     unset($config->addpageiconhtml);
     $this->page->requires->yui_module('moodle-mod_quiz-toolboxes', 'M.mod_quiz.init_section_toolbox', array(array('courseid' => $structure, 'quizid' => $structure->get_quizid(), 'ajaxurl' => $config->sectionurl, 'config' => $config)));
     $this->page->requires->yui_module('moodle-mod_quiz-dragdrop', 'M.mod_quiz.init_section_dragdrop', array(array('courseid' => $structure, 'quizid' => $structure->get_quizid(), 'ajaxurl' => $config->sectionurl, 'config' => $config)), null, true);
     $this->page->requires->yui_module('moodle-mod_quiz-dragdrop', 'M.mod_quiz.init_resource_dragdrop', array(array('courseid' => $structure, 'quizid' => $structure->get_quizid(), 'ajaxurl' => $config->resourceurl, 'config' => $config)), null, true);
     // Require various strings for the command toolbox.
     $this->page->requires->strings_for_js(array('clicktohideshow', 'deletechecktype', 'deletechecktypename', 'edittitle', 'edittitleinstructions', 'emptydragdropregion', 'hide', 'markedthistopic', 'markthistopic', 'move', 'movecontent', 'moveleft', 'movesection', 'page', 'question', 'selectall', 'show', 'tocontent'), 'moodle');
     $this->page->requires->strings_for_js(array('addpagebreak', 'confirmremovesectionheading', 'confirmremovequestion', 'dragtoafter', 'dragtostart', 'numquestionsx', 'sectionheadingedit', 'sectionheadingremove', 'removepagebreak', 'questiondependencyadd', 'questiondependencyfree', 'questiondependencyremove', 'questiondependsonprevious'), 'quiz');
     foreach (\question_bank::get_all_qtypes() as $qtype => $notused) {
         $this->page->requires->string_for_js('pluginname', 'qtype_' . $qtype);
     }
     return true;
 }