]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-10888: - groupings - mod/scorm - updated to support groupings
authormattc-catalyst <mattc-catalyst>
Tue, 28 Aug 2007 02:54:37 +0000 (02:54 +0000)
committermattc-catalyst <mattc-catalyst>
Tue, 28 Aug 2007 02:54:37 +0000 (02:54 +0000)
lib/datalib.php
mod/scorm/index.php
mod/scorm/locallib.php
mod/scorm/mod_form.php
mod/scorm/report.php
mod/scorm/view.php

index 4b26e82e1ca7c5e399180bd854f9047664579695..73bc9aa8e24f78d927d635899fecf0bc43e129f4 100644 (file)
@@ -1303,7 +1303,7 @@ function get_all_instances_in_course($modulename, $course, $userid=NULL, $includ
         return array();
     }
 
-    if (!$rawmods = get_records_sql("SELECT cm.id as coursemodule, m.*,cw.section,cm.visible as visible,cm.groupmode
+    if (!$rawmods = get_records_sql("SELECT cm.id as coursemodule, m.*,cw.section,cm.visible as visible,cm.groupmode,cm.groupingid
                             FROM {$CFG->prefix}course_modules cm,
                                  {$CFG->prefix}course_sections cw,
                                  {$CFG->prefix}modules md,
index 4b0d4c41c85b9e0e9dcf97f982908e747d40c622..92c9ee8a0cf73b9e3584b34e67a154ef553fd79f 100755 (executable)
@@ -1,6 +1,7 @@
 <?php // $Id$
 
     require_once("../../config.php");
+    require_once("locallib.php");
 
     $id = required_param('id', PARAM_INT);   // course id
 
@@ -67,9 +68,9 @@
         }
         $report = '&nbsp;';
         if (has_capability('mod/scorm:viewreport', $context)) {
-            $trackedusers = get_record('scorm_scoes_track', 'scormid', $scorm->id, '', '', '', '', 'count(distinct(userid)) as c');
-            if ($trackedusers->c > 0) {
-                $reportshow = '<a href="report.php?id='.$scorm->coursemodule.'">'.get_string('viewallreports','scorm',$trackedusers->c).'</a></div>';
+            $trackedusers = scorm_get_count_users($scorm->id, $scorm->groupingid);
+            if ($trackedusers > 0) {
+                $reportshow = '<a href="report.php?id='.$scorm->coursemodule.'">'.get_string('viewallreports','scorm',$trackedusers).'</a></div>';
             } else {
                 $reportshow = get_string('noreports','scorm');
             }
index e50faa663f9ec3adf20361cff9ef19e4070b11c3..95c29fa158f049c2b6b68e8d02fa0fcfc837f261 100755 (executable)
@@ -960,4 +960,26 @@ function scorm_check_package($data) {
     return $validation;
 }
 
+
+function scorm_get_count_users($scormid, $groupingid=null) {
+    
+    global $CFG;
+    
+    if (!empty($CFG->enablegroupings) && !empty($groupingid)) {
+        $sql = "SELECT COUNT(DISTINCT st.userid)
+                FROM {$CFG->prefix}scorm_scoes_track st
+                    INNER JOIN {$CFG->prefix}groups_members gm ON st.userid = gm.userid
+                    INNER JOIN {$CFG->prefix}groupings_groups gg ON gm.groupid = gg.groupid 
+                WHERE st.scormid = $scormid AND gg.groupingid = $groupingid
+                ";
+    } else {
+        $sql = "SELECT COUNT(DISTINCT st.userid)
+                FROM {$CFG->prefix}scorm_scoes_track st 
+                WHERE st.scormid = $scormid
+                ";
+    }
+    
+    return(count_records_sql($sql));
+}
+
 ?>
index 95bc3a4a856873c8760c130882b0c44f3988014d..a3758f7d739e0324dd2070e876f6a09a5621d0c9 100644 (file)
@@ -186,7 +186,11 @@ class mod_scorm_mod_form extends moodleform_mod {
 
 
 //-------------------------------------------------------------------------------
-        $this->standard_coursemodule_elements();
+        $features = new stdClass;
+        $features->groups = false;
+        $features->groupings = true;
+        $features->groupmembersonly = true;
+        $this->standard_coursemodule_elements($features);
 //-------------------------------------------------------------------------------
         // buttons
         $this->add_action_buttons();
index 19c8f773223518afb678a0b0f3940bf9e51cf121..6be8b3c544b0b05abb239a3b8876c2dff5946054 100755 (executable)
     if (empty($b)) {
         if (empty($a)) {
             // No options, show the global scorm report
-            if ($scousers=get_records_select('scorm_scoes_track', "scormid='$scorm->id' GROUP BY userid,scormid", "", "userid,scormid")) {
+            
+            if (!empty($CFG->enablegroupings) && !empty($cm->groupingid)) {
+                $sql = "SELECT st.userid, st.scormid
+                        FROM {$CFG->prefix}scorm_scoes_track st
+                            INNER JOIN {$CFG->prefix}groups_members gm ON st.userid = gm.userid
+                            INNER JOIN {$CFG->prefix}groupings_groups gg ON gm.groupid = gg.groupid 
+                        WHERE st.scormid = {$scorm->id} AND gg.groupingid = {$cm->groupingid}
+                        GROUP BY st.userid,st.scormid
+                        ";
+            } else {
+                $sql = "SELECT st.userid, st.scormid
+                        FROM {$CFG->prefix}scorm_scoes_track st 
+                        WHERE st.scormid = {$scorm->id}
+                        GROUP BY st.userid,st.scormid
+                        ";
+            }
+            
+            if ($scousers=get_records_sql($sql)) {
                 $table = new stdClass();
                 $table->head = array('&nbsp;', get_string('name'));
                 $table->align = array('center', 'left');
index f753e3056b76db66453b4f95e26df58cddce640a..db9ec88afb9fc5e059b1e8498a6c3d30cd2310a7 100755 (executable)
     }
 
     if (has_capability('moodle/course:manageactivities', $context)) {
-        $trackedusers = get_record('scorm_scoes_track', 'scormid', $scorm->id, '', '', '', '', 'count(distinct(userid)) as c');
-        if ($trackedusers->c > 0) {
-            echo "<div class=\"reportlink\"><a $CFG->frametarget href=\"report.php?id=$cm->id\"> ".get_string('viewallreports','scorm',$trackedusers->c).'</a></div>';
+        
+        $trackedusers = scorm_get_count_users($scorm->id, $cm->groupingid);
+        if ($trackedusers > 0) {
+            echo "<div class=\"reportlink\"><a $CFG->frametarget href=\"report.php?id=$cm->id\"> ".get_string('viewallreports','scorm',$trackedusers).'</a></div>';
         } else {
             echo '<div class="reportlink">'.get_string('noreports','scorm').'</div>';
         }