]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-19815 Migrated choose_from_menu to the new $OUTPUT->select_menu() function
authornicolasconnault <nicolasconnault>
Tue, 28 Jul 2009 09:32:23 +0000 (09:32 +0000)
committernicolasconnault <nicolasconnault>
Tue, 28 Jul 2009 09:32:23 +0000 (09:32 +0000)
mod/scorm/locallib.php
mod/scorm/report.php
mod/scorm/scorm.js [new file with mode: 0644]

index ad3b9f99ab3fe38e2758ce49d47f05ee628652f1..5253f2da90f016befb4004ea833840da0da6454f 100755 (executable)
@@ -716,7 +716,7 @@ function scorm_course_format_display($user,$course) {
 }
 
 function scorm_view_display ($user, $scorm, $action, $cm, $boxwidth='') {
-    global $CFG, $DB;
+    global $CFG, $DB, $PAGE, $OUTPUT;
 
     if ($scorm->updatefreq == UPDATE_EVERYTIME) {
         scorm_parse($scorm, false);
@@ -739,7 +739,14 @@ function scorm_view_display ($user, $scorm, $action, $cm, $boxwidth='') {
             <div class='scorm-center'>
                 <?php print_string('organizations','scorm') ?>
                 <form id='changeorg' method='post' action='<?php echo $action ?>'>
-                    <?php choose_from_menu($orgs, 'organization', "$organization", '','submit()') ?>
+                    <?php 
+                    $selectmenu = new moodle_select_menu();
+                    $selectmenu->options = $orgs;
+                    $selectmenu->name = 'organization';
+                    $selectmenu->selectedvalue = $organization;
+                    $selectmenu->add_action('change', 'submit_form_by_id', array('id' => 'changeorg'));
+                    echo $OUTPUT->select_menu($selectmenu); 
+                    ?>
                 </form>
             </div>
 <?php
@@ -1182,4 +1189,4 @@ function scorm_delete_attempt($userid, $scormid, $attemptid) {
     $DB->delete_records('scorm_scoes_track', array('userid' => $userid, 'scormid' => $scormid, 'attempt' => $attemptid));
     return true;
 }
-?>
\ No newline at end of file
+?>
index c66f2d5ac3461b024dcffbb129014369f9eb2dd2..cb474a2053776e027ede3f3247c6157e5c2a30b1 100755 (executable)
                     echo '<a href="javascript:select_all_in(\'DIV\',null,\'scormtablecontainer\');">'.get_string('selectall', 'quiz').'</a> / ';
                     echo '<a href="javascript:deselect_all_in(\'DIV\',null,\'scormtablecontainer\');">'.get_string('selectnone', 'quiz').'</a> ';
                     echo '&nbsp;&nbsp;';
-                    $options = array('delete' => get_string('delete'));
-                    echo choose_from_menu($options, 'action', '', get_string('withselected', 'quiz'), 'if(this.selectedIndex > 0) submitFormById(\'attemptsform\');', '', true);
+                    $PAGE->requires->js('mod/scorm/scorm.js');
+                    $selectmenu = new moodle_select_menu();
+                    $selectmenu->options = array('delete' => get_string('delete'));
+                    $selectmenu->name = 'action';
+                    $selectmenu->button->label = get_string('withselected', 'quiz');
+                    $selectmenu->id = 'menuaction';
+                    $selectmenu->add_action('change', 'submit_attempts_form');
+                    echo $OUTPUT->select_menu($selectmenu);
                     echo '<noscript id="noscriptmenuaction" style="display: inline;">';
                     echo '<div>';
                     echo '<input type="submit" value="'.get_string('go').'" /></div></noscript>';
diff --git a/mod/scorm/scorm.js b/mod/scorm/scorm.js
new file mode 100644 (file)
index 0000000..19897bd
--- /dev/null
@@ -0,0 +1,5 @@
+function submit_attempts_form(e, args) {
+    if (e.target.selectedIndex > 0) {
+        submit_form_by_id(null, {id: 'attemptsform'});
+    }
+}