MDL-10888: - groupings - mod/scorm - updated to support groupings
This commit is contained in:
+1
-1
@@ -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,
|
||||
|
||||
+4
-3
@@ -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 = ' ';
|
||||
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');
|
||||
}
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
@@ -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();
|
||||
|
||||
+18
-1
@@ -100,7 +100,24 @@
|
||||
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');
|
||||
|
||||
+4
-3
@@ -75,9 +75,10 @@
|
||||
}
|
||||
|
||||
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>';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user