]> git.mjollnir.org Git - moodle.git/commitdiff
course/view MDL-10142 AJAX move functionality on section content
authorRossiani Wijaya <rossianiwijaya@gmail.com>
Fri, 30 Oct 2009 08:02:16 +0000 (08:02 +0000)
committerRossiani Wijaya <rossianiwijaya@gmail.com>
Fri, 30 Oct 2009 08:02:16 +0000 (08:02 +0000)
lib/ajax/ajaxcourse.js
lib/ajax/ajaxlib.php

index 23ee24d5232e0eb02d04bb42589307a5e0aae3e6..d8fec5fb8b8f29951ee82a81d73d27422c91e97e 100644 (file)
@@ -63,6 +63,7 @@ function main_class() {
     this.icons = [];
     this.courseformat = null;
     this.marker = null;
+    this.numsections = null;
 
     //things to process onload
     onloadobj.add('main.process_document();');
@@ -117,17 +118,22 @@ main_class.prototype.process_document = function() {
     this.rightcolumn = new column_class('right-column', "blocks", null, 'r');
 
     //process sections
-    var ct = 0;
-    while (document.getElementById('section-'+ct) != null) {
-        this.sections[ct] = new section_class('section-'+ct, "sections", null, ct!=0?true:false);
-        this.sections[ct].addToGroup('resources');
-        if (ct > 0) {
-            var sectiontitle = YAHOO.util.Selector.query('#section-'+ct+' h3.weekdates')[0];
-            if (undefined !== sectiontitle) { // Only save date for weekly format
-                this.sectiondates[ct] = sectiontitle.innerHTML;
+    //var ct = 0;
+    //while (document.getElementById('section-'+ct) != null) {
+    var maxct = this.portal.numsections;
+    this.courseformat = this.portal.courseformat;
+    for(var ct=0; ct <= maxct; ct++){
+        if(document.getElementById('section-'+ct) != null) {
+            this.sections[ct] = new section_class('section-'+ct, "sections", null, ct!=0?true:false);
+            this.sections[ct].addToGroup('resources');
+            if (ct > 0) {
+                var sectiontitle = YAHOO.util.Selector.query('#section-'+ct+' h3.weekdates')[0];
+                if (undefined !== sectiontitle) { // Only save date for weekly format
+                    this.sectiondates[ct] = sectiontitle.innerHTML;
+                }
             }
         }
-        ct++;
+        //ct++;
     }
     if (this.debug) {
         YAHOO.log("Processed "+ct+" sections");
index 99cb45587888e3582c7d165ecd61eae6e54a8653..f53f0cc65a92f54f776e5ef62fc969720123fda5 100644 (file)
@@ -1398,6 +1398,7 @@ class jsportal {
         $output .= "    main.portal.strings['wwwroot']='".$CFG->wwwroot."';\n";
         $output .= "    main.portal.strings['marker']='".get_string('markthistopic', '', '_var_')."';\n";
         $output .= "    main.portal.strings['marked']='".get_string('markedthistopic', '', '_var_')."';\n";
+        $output .= "    main.portal.numsections = ".$COURSE->numsections.";\n";
         $output .= "    main.portal.strings['hide']='".get_string('hide')."';\n";
         $output .= "    main.portal.strings['hidesection']='".get_string('hidesection', '', '_var_')."';\n";
         $output .= "    main.portal.strings['show']='".get_string('show')."';\n";