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,
<?php // $Id$
require_once("../../config.php");
+ require_once("locallib.php");
$id = required_param('id', PARAM_INT); // course id
}
$report = ' ';
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');
}
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));
+}
+
?>
//-------------------------------------------------------------------------------
- $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();
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(' ', get_string('name'));
$table->align = array('center', 'left');
}
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>';
}