MDL27522 First version Push

modified:   mod/scorm/report.php
	new file:   mod/scorm/reportuser.php

MDL-27522 SCORM Reports-remove users report to seperate files for better re-use

	modified:   mod/scorm/reportuser.php

MDL-27522 SCORM Reports validated reportuser.php

	modified:   mod/scorm/report.php
	modified:   mod/scorm/reportuser.php

MDL-27522 SCORM REPORT - updating reportuser.php to use MUST_EXIST parameter

	modified:   mod/scorm/lang/en/scorm.php
	modified:   mod/scorm/reportuser.php

MDL-27522 SCORM Reports- Cleaning of codes
	modified:   mod/scorm/report.php
	modified:   mod/scorm/reportuser.php

MDL-27522 SCORM Reports- update formating

	modified:   mod/scorm/report.php
	modified:   mod/scorm/reportuser.php

MDL-27522 SCORM Reports removed unwanted codes from reportuser.php

	modified:   mod/scorm/reportuser.php

MDL-27522 Scorm Reports - optimising codes

	modified:   mod/scorm/report.php
	modified:   mod/scorm/reportuser.php

MDL-27522 Scorm Reports-Formating report.php
	modified:   mod/scorm/report.php

MDL-27522 Scorm Reporting - removing unsed variables

	modified:   mod/scorm/lang/en/scorm.php
	modified:   mod/scorm/report.php
	modified:   mod/scorm/reportuser.php

MDL-27522 SCORM Reporting - Renaming reportuser.php to userreport.php
	new file:   mod/scorm/userreport.php

MDL-27522 SCORM Reporting - deleting old reportuser.php

	deleted:    mod/scorm/reportuser.php

MDL-27522 Scorm Reporting - updated version number

MDL-27522 Scorm Reporting - Discarding version changes

MDL-27523 Scorm Reporting - Basic reporting plugin
	new file:   mod/scorm/report/basic/lang/en/scorm_basic.php
	new file:   mod/scorm/report/basic/report.php
	new file:   mod/scorm/report/default.php
	new file:   mod/scorm/report/reportlib.php

MDL-27523 Scorm Reporting - Database Table structure pushed
	new file:   mod/scorm/db/subplugins.php

MDL-27523 Scorm Reporting - Plugin container codes
	modified:   mod/scorm/report.php
	modified:   mod/scorm/tabs.php

MDL-27523 Scorm Reporting - Capability update
	modified:   mod/scorm/report/reportlib.php

MDL-27523 Scorm Reporting - commenting files
	modified:   mod/scorm/report/basic/db/install.php
	modified:   mod/scorm/report/basic/lang/en/scorm_basic.php
	modified:   mod/scorm/report/basic/version.php

MDL-27523 Scorm Reporting - Formating codes
	modified:   mod/scorm/report/basic/db/install.php
	modified:   mod/scorm/report/basic/report.php
	modified:   mod/scorm/report/basic/version.php
	modified:   mod/scorm/report/default.php
	modified:   mod/scorm/report/reportlib.php

MDL-27523 Scorm Reporting - fixing small bugs
	modified:   mod/scorm/report/basic/report.php

MDL-27523 Scorm Reporting - added databse upgrade code to scorm/db/upgrade.php

MDL-27523 Scorm Reporting - small optimisations

MDL-27523 SCorm Reporting - Removing Mod.php

MDL-27523 Scorm Reporting - Minor Fixes

	new file:   mod/scorm/db/subplugins.php
	modified:   mod/scorm/lang/en/scorm.php
	modified:   mod/scorm/report.php
	new file:   mod/scorm/report/basic/db/install.php
	new file:   mod/scorm/report/basic/lang/en/scorm_basic.php
	new file:   mod/scorm/report/basic/report.php
	new file:   mod/scorm/report/basic/version.php
	new file:   mod/scorm/report/default.php
	new file:   mod/scorm/report/reportlib.php
	modified:   mod/scorm/tabs.php
	modified:   mod/scorm/userreport.php

	modified:   mod/scorm/db/install.xml
	new file:   mod/scorm/db/subplugins.php
	modified:   mod/scorm/db/upgrade.php
	modified:   mod/scorm/lang/en/scorm.php
	modified:   mod/scorm/report.php
	new file:   mod/scorm/report/basic/db/install.php
	new file:   mod/scorm/report/basic/lang/en/scorm_basic.php
	new file:   mod/scorm/report/basic/report.php
	new file:   mod/scorm/report/basic/version.php
	new file:   mod/scorm/report/default.php
	new file:   mod/scorm/report/reportlib.php
	modified:   mod/scorm/tabs.php
	modified:   mod/scorm/userreport.php
	modified:   mod/scorm/version.php

MDL-27523 Scorm Reporting - Removing Database Refereneces

MDL-27523 Scorm Reporting - Updating structure to remove DB usage
	modified:   mod/scorm/db/upgrade.php
	modified:   mod/scorm/report.php
	modified:   mod/scorm/report/basic/report.php
	modified:   mod/scorm/report/default.php
	modified:   mod/scorm/report/reportlib.php

MDL-27523 Scorm Reporting - Minor fixes

MDL-27523 Scorm Reporting - Formating codes

MDL-27523 Scorm Reporting - Foramting Codes
	modified:   mod/scorm/report/basic/lang/en/scorm_basic.php
	modified:   mod/scorm/report/basic/report.php
	modified:   mod/scorm/report/default.php
	modified:   mod/scorm/report/reportlib.php

	new file:   mod/scorm/db/subplugins.php
	modified:   mod/scorm/lang/en/scorm.php
	modified:   mod/scorm/report.php
	new file:   mod/scorm/report/basic/lang/en/scorm_basic.php
	new file:   mod/scorm/report/basic/report.php
	new file:   mod/scorm/report/basic/version.php
	new file:   mod/scorm/report/default.php
	new file:   mod/scorm/report/reportlib.php
	modified:   mod/scorm/tabs.php
	modified:   mod/scorm/userreport.php
	modified:   mod/scorm/version.php
This commit is contained in:
Ankit Kumar Agarwal
2011-07-14 10:57:29 +12:00
committed by Dan Marsden
parent ecb8829273
commit 62b82cbcff
11 changed files with 741 additions and 496 deletions
+3
View File
@@ -0,0 +1,3 @@
<?php
$subplugins = array('scorm'=>'mod/scorm/report');
+1
View File
@@ -217,6 +217,7 @@ $string['prev'] = 'Previous';
$string['raw'] = 'Raw score';
$string['regular'] = 'Regular manifest';
$string['report'] = 'Report';
$string['reports'] = 'Reports';
$string['reportcountallattempts'] = '{$a->nbattempts} attempts for {$a->nbusers} users, out of {$a->nbresults} results';
$string['reportcountattempts'] = '{$a->nbresults} results ({$a->nbusers} users)';
$string['resizable'] = 'Allow the window to be resized';
+46 -477
View File
@@ -14,13 +14,15 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
// This script uses installed report plugins to print quiz reports
// This script uses installed report plugins to print scorm reports
require_once("../../config.php");
require_once($CFG->libdir.'/tablelib.php');
require_once($CFG->dirroot.'/mod/scorm/locallib.php');
require_once($CFG->dirroot.'/mod/scorm/reportsettings_form.php');
require_once($CFG->dirroot.'/mod/scorm/report/reportlib.php');
require_once($CFG->libdir.'/formslib.php');
include_once("report/default.php"); // Parent class
define('SCORM_REPORT_DEFAULT_PAGE_SIZE', 20);
define('SCORM_REPORT_ATTEMPTS_ALL_STUDENTS', 0);
define('SCORM_REPORT_ATTEMPTS_STUDENTS_WITH', 1);
@@ -31,18 +33,22 @@ $id = required_param('id', PARAM_INT);// Course Module ID, or
$action = optional_param('action', '', PARAM_ALPHA);
$attemptids = optional_param('attemptid', array(), PARAM_RAW);
$download = optional_param('download', '', PARAM_RAW);
$mode = optional_param('mode', '', PARAM_ALPHA); // Report mode
$url = new moodle_url('/mod/scorm/report.php');
if ($action !== '') {
$url->param('action', $action);
}
if ($mode !== '') {
$url->param('mode', $mode);
}
$url->param('id', $id);
$cm = get_coursemodule_from_id('scorm', $id, 0, false, MUST_EXIST);
$course = $DB->get_record('course', array('id'=>$cm->course), '*', MUST_EXIST);
$scorm = $DB->get_record('scorm', array('id'=>$cm->instance), '*', MUST_EXIST);
$PAGE->set_url($url);
require_login($course->id, false, $cm);
@@ -59,8 +65,8 @@ if (!empty($download)) {
/// Print the page header
if (empty($noheader)) {
$strreport = get_string('report', 'scorm');
$strattempt = get_string('attempt', 'scorm');
$strreport = get_string('report', 'scorm');
$strattempt = get_string('attempt', 'scorm');
$PAGE->set_title("$course->shortname: ".format_string($scorm->name));
$PAGE->set_heading($course->fullname);
@@ -78,484 +84,47 @@ if ($action == 'delete' && has_capability('mod/scorm:deleteresponses', $contextm
echo $OUTPUT->notification(get_string('scormresponsedeleted', 'scorm'), 'notifysuccess');
}
}
// No options, show the global scorm report
$pageoptions = array();
$pageoptions['id'] = $cm->id;
$reporturl = new moodle_url($CFG->wwwroot.'/mod/scorm/report.php', $pageoptions);
// find out current groups mode
$currentgroup = groups_get_activity_group($cm, true);
// detailed report
$mform = new mod_scorm_report_settings( $reporturl, compact('currentgroup') );
if ($fromform = $mform->get_data()) {
$detailedrep = $fromform->detailedrep;
$pagesize = $fromform->pagesize;
$attemptsmode = $fromform->attemptsmode;
set_user_preference('scorm_report_detailed', $detailedrep);
set_user_preference('scorm_report_pagesize', $pagesize);
} else {
$detailedrep = get_user_preferences('scorm_report_detailed', false);
$pagesize = get_user_preferences('scorm_report_pagesize', 0);
$attemptsmode = optional_param('attemptsmode', SCORM_REPORT_ATTEMPTS_STUDENTS_WITH, PARAM_INT);
}
if ($pagesize < 1) {
$pagesize = SCORM_REPORT_DEFAULT_PAGE_SIZE;
$reportlist = scorm_report_list($contextmodule);
if (count($reportlist)==0){
print_error('erroraccessingreport', 'scorm');
}
// select group menu
$displayoptions = array();
$displayoptions['id'] = $cm->id;
$displayoptions['attemptsmode'] = $attemptsmode;
$reporturlwithdisplayoptions = new moodle_url($CFG->wwwroot.'/mod/scorm/report.php', $displayoptions);
if ($groupmode = groups_get_activity_groupmode($cm)) { // Groups are being used
if (!$download) {
groups_print_activity_menu($cm, $reporturlwithdisplayoptions->out());
}
}
// We only want to show the checkbox to delete attempts
// if the user has permissions and if the report mode is showing attempts.
$candelete = has_capability('mod/scorm:deleteresponses', $contextmodule)
&& ($attemptsmode!= SCORM_REPORT_ATTEMPTS_STUDENTS_WITH_NO);
// select the students
$nostudents = false;
if (empty($currentgroup)) {
// all users who can attempt scoes
if (!$students = get_users_by_capability($contextmodule, 'mod/scorm:savetrack', '', '', '', '', '', '', false)) {
echo $OUTPUT->notification(get_string('nostudentsyet'));
$nostudents = true;
$allowedlist = '';
} else {
$allowedlist = join(',', array_keys($students));
}
} else {
// all users who can attempt scoes and who are in the currently selected group
if (!$groupstudents = get_users_by_capability($contextmodule, 'mod/scorm:savetrack', '', '', '', '', $currentgroup, '', false)) {
echo $OUTPUT->notification(get_string('nostudentsingroup'));
$nostudents = true;
$groupstudents = array();
}
$allowedlist = join(',', array_keys($groupstudents));
}
if ( !$nostudents ) {
// Now check if asked download of data
if ($download) {
$filename = clean_filename("$course->shortname ".format_string($scorm->name, true));
}
// Define table columns
$columns = array();
$headers = array();
if (!$download && $candelete) {
$columns[]= 'checkbox';
$headers[]= null;
}
if (!$download && $CFG->grade_report_showuserimage) {
$columns[]= 'picture';
$headers[]= '';
}
$columns[]= 'fullname';
$headers[]= get_string('name');
if ($CFG->grade_report_showuseridnumber) {
$columns[]= 'idnumber';
$headers[]= get_string('idnumber');
}
$columns[]= 'attempt';
$headers[]= get_string('attempt', 'scorm');
$columns[]= 'start';
$headers[]= get_string('started', 'scorm');
$columns[]= 'finish';
$headers[]= get_string('last', 'scorm');
$columns[]= 'score';
$headers[]= get_string('score', 'scorm');
if ($detailedrep && $scoes = $DB->get_records('scorm_scoes', array("scorm"=>$scorm->id), 'id')) {
foreach ($scoes as $sco) {
if ($sco->launch!='') {
$columns[]= 'scograde'.$sco->id;
$headers[]= format_string($sco->title);
$table->head[]= format_string($sco->title);
}
}
} else {
$scoes = null;
}
if (!$download) {
$table = new flexible_table('mod-scorm-report');
$table->define_columns($columns);
$table->define_headers($headers);
$table->define_baseurl($reporturlwithdisplayoptions->out());
$table->sortable(true);
$table->collapsible(true);
$table->column_suppress('picture');
$table->column_suppress('fullname');
$table->column_suppress('idnumber');
$table->no_sorting('start');
$table->no_sorting('finish');
$table->no_sorting('score');
if ( $scoes ) {
foreach ($scoes as $sco) {
if ($sco->launch!='') {
$table->no_sorting('scograde'.$sco->id);
}
}
}
$table->column_class('picture', 'picture');
$table->column_class('fullname', 'bold');
$table->column_class('score', 'bold');
$table->set_attribute('cellspacing', '0');
$table->set_attribute('id', 'attempts');
$table->set_attribute('class', 'generaltable generalbox');
// Start working -- this is necessary as soon as the niceties are over
$table->setup();
} else if ($download =='ODS') {
require_once("$CFG->libdir/odslib.class.php");
$filename .= ".ods";
// Creating a workbook
$workbook = new MoodleODSWorkbook("-");
// Sending HTTP headers
$workbook->send($filename);
// Creating the first worksheet
$sheettitle = get_string('report', 'scorm');
$myxls =& $workbook->add_worksheet($sheettitle);
// format types
$format =& $workbook->add_format();
$format->set_bold(0);
$formatbc =& $workbook->add_format();
$formatbc->set_bold(1);
$formatbc->set_align('center');
$formatb =& $workbook->add_format();
$formatb->set_bold(1);
$formaty =& $workbook->add_format();
$formaty->set_bg_color('yellow');
$formatc =& $workbook->add_format();
$formatc->set_align('center');
$formatr =& $workbook->add_format();
$formatr->set_bold(1);
$formatr->set_color('red');
$formatr->set_align('center');
$formatg =& $workbook->add_format();
$formatg->set_bold(1);
$formatg->set_color('green');
$formatg->set_align('center');
// Here starts workshhet headers
$colnum = 0;
foreach ($headers as $item) {
$myxls->write(0, $colnum, $item, $formatbc);
$colnum++;
}
$rownum=1;
} else if ($download =='Excel') {
require_once("$CFG->libdir/excellib.class.php");
$filename .= ".xls";
// Creating a workbook
$workbook = new MoodleExcelWorkbook("-");
// Sending HTTP headers
$workbook->send($filename);
// Creating the first worksheet
$sheettitle = get_string('report', 'scorm');
$myxls =& $workbook->add_worksheet($sheettitle);
// format types
$format =& $workbook->add_format();
$format->set_bold(0);
$formatbc =& $workbook->add_format();
$formatbc->set_bold(1);
$formatbc->set_align('center');
$formatb =& $workbook->add_format();
$formatb->set_bold(1);
$formaty =& $workbook->add_format();
$formaty->set_bg_color('yellow');
$formatc =& $workbook->add_format();
$formatc->set_align('center');
$formatr =& $workbook->add_format();
$formatr->set_bold(1);
$formatr->set_color('red');
$formatr->set_align('center');
$formatg =& $workbook->add_format();
$formatg->set_bold(1);
$formatg->set_color('green');
$formatg->set_align('center');
$colnum = 0;
foreach ($headers as $item) {
$myxls->write(0, $colnum, $item, $formatbc);
$colnum++;
}
$rownum=1;
} else if ($download=='CSV') {
$filename .= ".txt";
header("Content-Type: application/download\n");
header("Content-Disposition: attachment; filename=\"$filename\"");
header("Expires: 0");
header("Cache-Control: must-revalidate,post-check=0,pre-check=0");
header("Pragma: public");
echo implode("\t", $headers)." \n";
}
// Construct the SQL
$select = 'SELECT DISTINCT '.$DB->sql_concat('u.id', '\'#\'', 'COALESCE(st.attempt, 0)').' AS uniqueid, ';
$select .= 'st.scormid AS scormid, st.attempt AS attempt, ' .
'u.id AS userid, u.idnumber, u.firstname, u.lastname, u.picture, u.imagealt, u.email ';
// This part is the same for all cases - join users and scorm_scoes_track tables
$from = 'FROM {user} u ';
$from .= 'LEFT JOIN {scorm_scoes_track} st ON st.userid = u.id AND st.scormid = '.$scorm->id;
switch ($attemptsmode) {
case SCORM_REPORT_ATTEMPTS_STUDENTS_WITH:
// Show only students with attempts
$where = ' WHERE u.id IN (' .$allowedlist. ') AND st.userid IS NOT NULL';
break;
case SCORM_REPORT_ATTEMPTS_STUDENTS_WITH_NO:
// Show only students without attempts
$where = ' WHERE u.id IN (' .$allowedlist. ') AND st.userid IS NULL';
break;
case SCORM_REPORT_ATTEMPTS_ALL_STUDENTS:
// Show all students with or without attempts
$where = ' WHERE u.id IN (' .$allowedlist. ') AND (st.userid IS NOT NULL OR st.userid IS NULL)';
break;
}
$countsql = 'SELECT COUNT(DISTINCT('.$DB->sql_concat('u.id', '\'#\'', 'COALESCE(st.attempt, 0)').')) AS nbresults, ';
$countsql .= 'COUNT(DISTINCT('.$DB->sql_concat('u.id', '\'#\'', 'st.attempt').')) AS nbattempts, ';
$countsql .= 'COUNT(DISTINCT(u.id)) AS nbusers ';
$countsql .= $from.$where;
$params = array();
if (!$download) {
$sort = $table->get_sql_sort();
} else {
$sort = '';
}
// Fix some wired sorting
if (empty($sort)) {
$sort = ' ORDER BY uniqueid';
} else {
$sort = ' ORDER BY '.$sort;
}
if (!$download) {
// Add extra limits due to initials bar
list($twhere, $tparams) = $table->get_sql_where();
if ($twhere) {
$where .= ' AND '.$twhere; //initial bar
$params = array_merge($params, $tparams);
}
if (!empty($countsql)) {
$count = $DB->get_record_sql($countsql);
$totalinitials = $count->nbresults;
if ($twhere) {
$countsql .= ' AND '.$twhere;
}
$count = $DB->get_record_sql($countsql, $params);
$total = $count->nbresults;
}
$table->pagesize($pagesize, $total);
echo '<div class="quizattemptcounts">';
if ( $count->nbresults == $count->nbattempts ) {
echo get_string('reportcountattempts', 'scorm', $count);
} else if ( $count->nbattempts>0 ) {
echo get_string('reportcountallattempts', 'scorm', $count);
} else {
echo $count->nbusers.' '.get_string('users');
}
echo '</div>';
}
// Fetch the attempts
if (!$download) {
$attempts = $DB->get_records_sql($select.$from.$where.$sort, $params,
$table->get_page_start(), $table->get_page_size());
echo '<div id="scormtablecontainer">';
if ($candelete) {
// Start form
$strreallydel = addslashes_js(get_string('deleteattemptcheck', 'scorm'));
echo '<form id="attemptsform" method="post" action="' . $reporturlwithdisplayoptions->out(true) .
'" onsubmit="return confirm(\''.$strreallydel.'\');">';
echo '<input type="hidden" name="action" value="delete"/>';
echo '<input type="hidden" name="sesskey" value="'.sesskey().'" />';
echo '<div style="display: none;">';
echo html_writer::input_hidden_params($reporturlwithdisplayoptions);
if (empty($mode)) {
// Default to listing of plugins.
foreach ($reportlist as $reportname) {
$reportclassname = "scorm_{$reportname}_report";
$report = new $reportclassname();
$html = $report->canview($id,$contextmodule);
if (!empty($html)) {
echo '<div class="plugin">';
echo $html;
echo '</div>';
echo '<div>';
}
$table->initialbars($totalinitials>20); // Build table rows
} else {
$attempts = $DB->get_records_sql($select.$from.$where.$sort, $params);
}
}
if ($attempts) {
foreach ($attempts as $scouser) {
$row = array();
if (!empty($scouser->attempt)) {
$timetracks = scorm_get_sco_runtime($scorm->id, false, $scouser->userid, $scouser->attempt);
}
if (in_array('checkbox', $columns)) {
if ($candelete && !empty($timetracks->start)) {
$row[] = '<input type="checkbox" name="attemptid[]" value="'. $scouser->userid . ':' . $scouser->attempt . '" />';
} else if ($candelete) {
$row[] = '';
}
}
if (in_array('picture', $columns)) {
$user = (object)array(
'id'=>$scouser->userid,
'picture'=>$scouser->picture,
'imagealt'=>$scouser->imagealt,
'email'=>$scouser->email,
'firstname'=>$scouser->firstname,
'lastname'=>$scouser->lastname);
$row[] = $OUTPUT->user_picture($user, array('courseid'=>$course->id));
}
if (!$download) {
$row[] = '<a href="'.$CFG->wwwroot.'/user/view.php?id='.$scouser->userid.'&amp;course='.$course->id.'">'.fullname($scouser).'</a>';
} else {
$row[] = fullname($scouser);
}
if (in_array('idnumber', $columns)) {
$row[] = $scouser->idnumber;
}
if (empty($timetracks->start)) {
$row[] = '-';
$row[] = '-';
$row[] = '-';
$row[] = '-';
} else {
if (!$download) $row[] = '<a href="userreport.php?a='.$scorm->id.'&amp;user='.$scouser->userid.'&amp;attempt='.$scouser->attempt.'">'.$scouser->attempt.'</a>';
else $row[] = $scouser->attempt;
if ($download =='ODS' || $download =='Excel' ) $row[] = userdate($timetracks->start, get_string("strftimedatetime", "langconfig"));
else $row[] = userdate($timetracks->start);
if ($download =='ODS' || $download =='Excel' ) $row[] = userdate($timetracks->finish, get_string('strftimedatetime', 'langconfig'));
else $row[] = userdate($timetracks->finish);
$row[] = scorm_grade_user_attempt($scorm, $scouser->userid, $scouser->attempt);
}
// print out all scores of attempt
if ($scoes) {
foreach ($scoes as $sco) {
if ($sco->launch!='') {
if ($trackdata = scorm_get_tracks($sco->id, $scouser->userid, $scouser->attempt)) {
if ($trackdata->status == '') {
$trackdata->status = 'notattempted';
}
$strstatus = get_string($trackdata->status, 'scorm');
// if raw score exists, print it
if ($trackdata->score_raw != '') {
$score = $trackdata->score_raw;
// add max score if it exists
if ($scorm->version == 'SCORM_1.3') {
$maxkey = 'cmi.score.max';
} else {
$maxkey = 'cmi.core.score.max';
}
if (isset($trackdata->$maxkey)) {
$score .= '/'.$trackdata->$maxkey;
}
} else { // else print out status
$score = $strstatus;
}
if (!$download) {
$row[] = '<img src="'.$OUTPUT->pix_url($trackdata->status, 'scorm').'" alt="'.$strstatus.'" title="'.$strstatus.'" /><br/>
<a href="userreport.php?b='.$sco->id.'&amp;user='.$scouser->userid.'&amp;attempt='.$scouser->attempt.
'" title="'.get_string('details', 'scorm').'">'.$score.'</a>';
} else {
$row[] = $score;
}
} else {
// if we don't have track data, we haven't attempted yet
$strstatus = get_string('notattempted', 'scorm');
if (!$download) {
$row[] = '<img src="'.$OUTPUT->pix_url('notattempted', 'scorm').'" alt="'.$strstatus.'" title="'.$strstatus.'" /><br/>'.$strstatus;
} else {
$row[] = $strstatus;
}
}
}
}
}
if (!$download) {
$table->add_data($row);
} else if ($download == 'Excel' or $download == 'ODS') {
$colnum = 0;
foreach ($row as $item) {
$myxls->write($rownum, $colnum, $item, $format);
$colnum++;
}
$rownum++;
} else if ($download=='CSV') {
$text = implode("\t", $row);
echo $text." \n";
}
}
if (!$download) {
$table->finish_output();
if ($candelete) {
echo '<table id="commands">';
echo '<tr><td>';
echo '<a href="javascript:select_all_in(\'DIV\', null, \'scormtablecontainer\');">'.
get_string('selectall', 'scorm').'</a> / ';
echo '<a href="javascript:deselect_all_in(\'DIV\', null, \'scormtablecontainer\');">'.
get_string('selectnone', 'scorm').'</a> ';
echo '&nbsp;&nbsp;';
echo '<input type="submit" value="'.get_string('deleteselected', 'quiz_overview').'"/>';
echo '</td></tr></table>';
// Close form
echo '</div>';
echo '</form>';
}
echo '</div>';
if (!empty($attempts)) {
echo '<table class="boxaligncenter"><tr>';
echo '<td>';
echo $OUTPUT->single_button(new moodle_url('/mod/scorm/report.php', $pageoptions + $displayoptions + array('download' => 'ODS')), get_string('downloadods'));
echo "</td>\n";
echo '<td>';
echo $OUTPUT->single_button(new moodle_url('/mod/scorm/report.php', $pageoptions + $displayoptions + array('download' => 'Excel')), get_string('downloadexcel'));
echo "</td>\n";
echo '<td>';
echo $OUTPUT->single_button(new moodle_url('/mod/scorm/report.php', $pageoptions + $displayoptions + array('download' => 'CSV')), get_string('downloadtext'));
echo "</td>\n";
echo "<td>";
echo "</td>\n";
echo '</tr></table>';
}
}
if (!$download) {
$mform->set_data($displayoptions + compact('detailedrep', 'pagesize'));
$mform->display();
}
} else {
echo $OUTPUT->notification(get_string('noactivity', 'scorm'));
}
if ($download == 'Excel' or $download == 'ODS') {
$workbook->close();
exit;
} else if ($download == 'CSV') {
exit;
}
} else {
echo $OUTPUT->notification(get_string('noactivity', 'scorm'));
//end of default mode condition.
} else if (!in_array($mode, $reportlist)){
print_error('erroraccessingreport', 'scorm');
}
// Open the selected Scorm report and display it
// DISPLAY PLUGIN REPORT
if(!empty($mode))
{
$reportclassname = "scorm_{$mode}_report";
if (!class_exists($reportclassname)) {
print_error('reportnotfound', 'scorm', '', $mode);
}
$report = new $reportclassname();
if (!$report->display($scorm, $cm, $course, $attemptids, $action, $download)) { // Run the report!
print_error("preprocesserror", 'scorm');
}
if (!$report->settings($scorm, $cm, $course)) { // Run the report!
print_error("preprocesserror", 'scorm');
}
}
// Print footer
if (empty($noheader)) {
echo $OUTPUT->footer();
@@ -0,0 +1,26 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Strings for component 'scorm_basic', language 'en', branch 'MOODLE_20_STABLE'
*
* @package scorm_basic
* @author Ankit Kumar Agarwal
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
$string['pluginname'] = 'Basic Reporting';
+529
View File
@@ -0,0 +1,529 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Core Report class of basic reporting plugin
* @package scorm_basic
* @author Ankit Kumar Agarwal
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
if (!defined('MOODLE_INTERNAL')) {
die('Direct access to this script is forbidden.');// It must be included from a Moodle page
}
class scorm_basic_report extends scorm_default_report {
/**
* Displays the report.
*/
function display($scorm, $cm, $course, $attemptids, $action, $download) {
global $CFG, $DB, $OUTPUT;
$contextmodule= get_context_instance(CONTEXT_MODULE, $cm->id);
// No options, show the global scorm report
$pageoptions = array();
$pageoptions['id'] = $cm->id;
$pageoptions['mode'] = "basic";
$reporturl = new moodle_url($CFG->wwwroot.'/mod/scorm/report.php', $pageoptions);
// detailed report
$mform = new mod_scorm_report_settings( $reporturl, compact('currentgroup') );
if ($fromform = $mform->get_data()) {
$detailedrep = $fromform->detailedrep;
$pagesize = $fromform->pagesize;
$attemptsmode = $fromform->attemptsmode;
set_user_preference('scorm_report_detailed', $detailedrep);
set_user_preference('scorm_report_pagesize', $pagesize);
} else {
$detailedrep = get_user_preferences('scorm_report_detailed', false);
$pagesize = get_user_preferences('scorm_report_pagesize', 0);
$attemptsmode = optional_param('attemptsmode', SCORM_REPORT_ATTEMPTS_STUDENTS_WITH, PARAM_INT);
}
if ($pagesize < 1) {
$pagesize = SCORM_REPORT_DEFAULT_PAGE_SIZE;
}
// select group menu
$displayoptions = array();
$displayoptions['id'] = $cm->id;
$displayoptions['mode'] = "basic";
$displayoptions['attemptsmode'] = $attemptsmode;
$reporturlwithdisplayoptions = new moodle_url($CFG->wwwroot.'/mod/scorm/report.php', $displayoptions);
if ($groupmode = groups_get_activity_groupmode($cm)) { // Groups are being used
if (!$download) {
groups_print_activity_menu($cm, $reporturlwithdisplayoptions->out());
}
}
// We only want to show the checkbox to delete attempts
// if the user has permissions and if the report mode is showing attempts.
$candelete = has_capability('mod/scorm:deleteresponses', $contextmodule)
&& ($attemptsmode!= SCORM_REPORT_ATTEMPTS_STUDENTS_WITH_NO);
// select the students
$nostudents = false;
if (empty($currentgroup)) {
// all users who can attempt scoes
if (!$students = get_users_by_capability($contextmodule, 'mod/scorm:savetrack', '', '', '', '', '', '', false)) {
echo $OUTPUT->notification(get_string('nostudentsyet'));
$nostudents = true;
$allowedlist = '';
} else {
$allowedlist = join(',', array_keys($students));
}
} else {
// all users who can attempt scoes and who are in the currently selected group
if (!$groupstudents = get_users_by_capability($contextmodule, 'mod/scorm:savetrack', '', '', '', '', $currentgroup, '', false)) {
echo $OUTPUT->notification(get_string('nostudentsingroup'));
$nostudents = true;
$groupstudents = array();
}
$allowedlist = join(',', array_keys($groupstudents));
}
if ( !$nostudents ) {
// Now check if asked download of data
if ($download) {
$filename = clean_filename("$course->shortname ".format_string($scorm->name, true));
}
// Define table columns
$columns = array();
$headers = array();
if (!$download && $candelete) {
$columns[]= 'checkbox';
$headers[]= null;
}
if (!$download && $CFG->grade_report_showuserimage) {
$columns[]= 'picture';
$headers[]= '';
}
$columns[]= 'fullname';
$headers[]= get_string('name');
if ($CFG->grade_report_showuseridnumber) {
$columns[]= 'idnumber';
$headers[]= get_string('idnumber');
}
$columns[]= 'attempt';
$headers[]= get_string('attempt', 'scorm');
$columns[]= 'start';
$headers[]= get_string('started', 'scorm');
$columns[]= 'finish';
$headers[]= get_string('last', 'scorm');
$columns[]= 'score';
$headers[]= get_string('score', 'scorm');
if ($detailedrep && $scoes = $DB->get_records('scorm_scoes', array("scorm"=>$scorm->id), 'id')) {
foreach ($scoes as $sco) {
if ($sco->launch!='') {
$columns[]= 'scograde'.$sco->id;
$headers[]= format_string($sco->title);
$table->head[]= format_string($sco->title);
}
}
} else {
$scoes = null;
}
if (!$download) {
$table = new flexible_table('mod-scorm-report');
$table->define_columns($columns);
$table->define_headers($headers);
$table->define_baseurl($reporturlwithdisplayoptions->out());
$table->sortable(true);
$table->collapsible(true);
$table->column_suppress('picture');
$table->column_suppress('fullname');
$table->column_suppress('idnumber');
$table->no_sorting('start');
$table->no_sorting('finish');
$table->no_sorting('score');
if ( $scoes ) {
foreach ($scoes as $sco) {
if ($sco->launch!='') {
$table->no_sorting('scograde'.$sco->id);
}
}
}
$table->column_class('picture', 'picture');
$table->column_class('fullname', 'bold');
$table->column_class('score', 'bold');
$table->set_attribute('cellspacing', '0');
$table->set_attribute('id', 'attempts');
$table->set_attribute('class', 'generaltable generalbox');
// Start working -- this is necessary as soon as the niceties are over
$table->setup();
} else if ($download =='ODS') {
require_once("$CFG->libdir/odslib.class.php");
$filename .= ".ods";
// Creating a workbook
$workbook = new MoodleODSWorkbook("-");
// Sending HTTP headers
$workbook->send($filename);
// Creating the first worksheet
$sheettitle = get_string('report', 'scorm');
$myxls =& $workbook->add_worksheet($sheettitle);
// format types
$format =& $workbook->add_format();
$format->set_bold(0);
$formatbc =& $workbook->add_format();
$formatbc->set_bold(1);
$formatbc->set_align('center');
$formatb =& $workbook->add_format();
$formatb->set_bold(1);
$formaty =& $workbook->add_format();
$formaty->set_bg_color('yellow');
$formatc =& $workbook->add_format();
$formatc->set_align('center');
$formatr =& $workbook->add_format();
$formatr->set_bold(1);
$formatr->set_color('red');
$formatr->set_align('center');
$formatg =& $workbook->add_format();
$formatg->set_bold(1);
$formatg->set_color('green');
$formatg->set_align('center');
// Here starts workshhet headers
$colnum = 0;
foreach ($headers as $item) {
$myxls->write(0, $colnum, $item, $formatbc);
$colnum++;
}
$rownum=1;
} else if ($download =='Excel') {
require_once("$CFG->libdir/excellib.class.php");
$filename .= ".xls";
// Creating a workbook
$workbook = new MoodleExcelWorkbook("-");
// Sending HTTP headers
$workbook->send($filename);
// Creating the first worksheet
$sheettitle = get_string('report', 'scorm');
$myxls =& $workbook->add_worksheet($sheettitle);
// format types
$format =& $workbook->add_format();
$format->set_bold(0);
$formatbc =& $workbook->add_format();
$formatbc->set_bold(1);
$formatbc->set_align('center');
$formatb =& $workbook->add_format();
$formatb->set_bold(1);
$formaty =& $workbook->add_format();
$formaty->set_bg_color('yellow');
$formatc =& $workbook->add_format();
$formatc->set_align('center');
$formatr =& $workbook->add_format();
$formatr->set_bold(1);
$formatr->set_color('red');
$formatr->set_align('center');
$formatg =& $workbook->add_format();
$formatg->set_bold(1);
$formatg->set_color('green');
$formatg->set_align('center');
$colnum = 0;
foreach ($headers as $item) {
$myxls->write(0, $colnum, $item, $formatbc);
$colnum++;
}
$rownum=1;
} else if ($download=='CSV') {
$filename .= ".txt";
header("Content-Type: application/download\n");
header("Content-Disposition: attachment; filename=\"$filename\"");
header("Expires: 0");
header("Cache-Control: must-revalidate,post-check=0,pre-check=0");
header("Pragma: public");
echo implode("\t", $headers)." \n";
}
// Construct the SQL
$select = 'SELECT DISTINCT '.$DB->sql_concat('u.id', '\'#\'', 'COALESCE(st.attempt, 0)').' AS uniqueid, ';
$select .= 'st.scormid AS scormid, st.attempt AS attempt, ' .
'u.id AS userid, u.idnumber, u.firstname, u.lastname, u.picture, u.imagealt, u.email ';
// This part is the same for all cases - join users and scorm_scoes_track tables
$from = 'FROM {user} u ';
$from .= 'LEFT JOIN {scorm_scoes_track} st ON st.userid = u.id AND st.scormid = '.$scorm->id;
switch ($attemptsmode) {
case SCORM_REPORT_ATTEMPTS_STUDENTS_WITH:
// Show only students with attempts
$where = ' WHERE u.id IN (' .$allowedlist. ') AND st.userid IS NOT NULL';
break;
case SCORM_REPORT_ATTEMPTS_STUDENTS_WITH_NO:
// Show only students without attempts
$where = ' WHERE u.id IN (' .$allowedlist. ') AND st.userid IS NULL';
break;
case SCORM_REPORT_ATTEMPTS_ALL_STUDENTS:
// Show all students with or without attempts
$where = ' WHERE u.id IN (' .$allowedlist. ') AND (st.userid IS NOT NULL OR st.userid IS NULL)';
break;
}
$countsql = 'SELECT COUNT(DISTINCT('.$DB->sql_concat('u.id', '\'#\'', 'COALESCE(st.attempt, 0)').')) AS nbresults, ';
$countsql .= 'COUNT(DISTINCT('.$DB->sql_concat('u.id', '\'#\'', 'st.attempt').')) AS nbattempts, ';
$countsql .= 'COUNT(DISTINCT(u.id)) AS nbusers ';
$countsql .= $from.$where;
$params = array();
if (!$download) {
$sort = $table->get_sql_sort();
} else {
$sort = '';
}
// Fix some wired sorting
if (empty($sort)) {
$sort = ' ORDER BY uniqueid';
} else {
$sort = ' ORDER BY '.$sort;
}
if (!$download) {
// Add extra limits due to initials bar
list($twhere, $tparams) = $table->get_sql_where();
if ($twhere) {
$where .= ' AND '.$twhere; //initial bar
$params = array_merge($params, $tparams);
}
if (!empty($countsql)) {
$count = $DB->get_record_sql($countsql);
$totalinitials = $count->nbresults;
if ($twhere) {
$countsql .= ' AND '.$twhere;
}
$count = $DB->get_record_sql($countsql, $params);
$total = $count->nbresults;
}
$table->pagesize($pagesize, $total);
echo '<div class="quizattemptcounts">';
if ( $count->nbresults == $count->nbattempts ) {
echo get_string('reportcountattempts', 'scorm', $count);
} else if ( $count->nbattempts>0 ) {
echo get_string('reportcountallattempts', 'scorm', $count);
} else {
echo $count->nbusers.' '.get_string('users');
}
echo '</div>';
}
// Fetch the attempts
if (!$download) {
$attempts = $DB->get_records_sql($select.$from.$where.$sort, $params,
$table->get_page_start(), $table->get_page_size());
echo '<div id="scormtablecontainer">';
if ($candelete) {
// Start form
$strreallydel = addslashes_js(get_string('deleteattemptcheck', 'scorm'));
echo '<form id="attemptsform" method="post" action="' . $reporturlwithdisplayoptions->out(true) .
'" onsubmit="return confirm(\''.$strreallydel.'\');">';
echo '<input type="hidden" name="action" value="delete"/>';
echo '<input type="hidden" name="sesskey" value="'.sesskey().'" />';
echo '<div style="display: none;">';
echo html_writer::input_hidden_params($reporturlwithdisplayoptions);
echo '</div>';
echo '<div>';
}
$table->initialbars($totalinitials>20); // Build table rows
} else {
$attempts = $DB->get_records_sql($select.$from.$where.$sort, $params);
}
if ($attempts) {
foreach ($attempts as $scouser) {
$row = array();
if (!empty($scouser->attempt)) {
$timetracks = scorm_get_sco_runtime($scorm->id, false, $scouser->userid, $scouser->attempt);
}
if (in_array('checkbox', $columns)) {
if ($candelete && !empty($timetracks->start)) {
$row[] = '<input type="checkbox" name="attemptid[]" value="'. $scouser->userid . ':' . $scouser->attempt . '" />';
} else if ($candelete) {
$row[] = '';
}
}
if (in_array('picture', $columns)) {
$user = (object)array(
'id'=>$scouser->userid,
'picture'=>$scouser->picture,
'imagealt'=>$scouser->imagealt,
'email'=>$scouser->email,
'firstname'=>$scouser->firstname,
'lastname'=>$scouser->lastname);
$row[] = $OUTPUT->user_picture($user, array('courseid'=>$course->id));
}
if (!$download) {
$row[] = '<a href="'.$CFG->wwwroot.'/user/view.php?id='.$scouser->userid.'&amp;course='.$course->id.'">'.fullname($scouser).'</a>';
} else {
$row[] = fullname($scouser);
}
if (in_array('idnumber', $columns)) {
$row[] = $scouser->idnumber;
}
if (empty($timetracks->start)) {
$row[] = '-';
$row[] = '-';
$row[] = '-';
$row[] = '-';
} else {
if (!$download) {
$row[] = '<a href="userreport.php?a='.$scorm->id.'&amp;user='.$scouser->userid.'&amp;attempt='.$scouser->attempt.'">'.$scouser->attempt.'</a>';
} else {
$row[] = $scouser->attempt;
}
if ($download =='ODS' || $download =='Excel' ) {
$row[] = userdate($timetracks->start, get_string("strftimedatetime", "langconfig"));
} else {
$row[] = userdate($timetracks->start);
}
if ($download =='ODS' || $download =='Excel' ) {
$row[] = userdate($timetracks->finish, get_string('strftimedatetime', 'langconfig'));
} else {
$row[] = userdate($timetracks->finish);
}
$row[] = scorm_grade_user_attempt($scorm, $scouser->userid, $scouser->attempt);
}
// print out all scores of attempt
if ($scoes) {
foreach ($scoes as $sco) {
if ($sco->launch!='') {
if ($trackdata = scorm_get_tracks($sco->id, $scouser->userid, $scouser->attempt)) {
if ($trackdata->status == '') {
$trackdata->status = 'notattempted';
}
$strstatus = get_string($trackdata->status, 'scorm');
// if raw score exists, print it
if ($trackdata->score_raw != '') {
$score = $trackdata->score_raw;
// add max score if it exists
if ($scorm->version == 'SCORM_1.3') {
$maxkey = 'cmi.score.max';
} else {
$maxkey = 'cmi.core.score.max';
}
if (isset($trackdata->$maxkey)) {
$score .= '/'.$trackdata->$maxkey;
}
// else print out status
} else {
$score = $strstatus;
}
if (!$download) {
$row[] = '<img src="'.$OUTPUT->pix_url($trackdata->status, 'scorm').'" alt="'.$strstatus.'" title="'.$strstatus.'" /><br/>
<a href="userreport.php?b='.$sco->id.'&amp;user='.$scouser->userid.'&amp;attempt='.$scouser->attempt.
'" title="'.get_string('details', 'scorm').'">'.$score.'</a>';
} else {
$row[] = $score;
}
} else {
// if we don't have track data, we haven't attempted yet
$strstatus = get_string('notattempted', 'scorm');
if (!$download) {
$row[] = '<img src="'.$OUTPUT->pix_url('notattempted', 'scorm').'" alt="'.$strstatus.'" title="'.$strstatus.'" /><br/>'.$strstatus;
} else {
$row[] = $strstatus;
}
}
}
}
}
if (!$download) {
$table->add_data($row);
} else if ($download == 'Excel' or $download == 'ODS') {
$colnum = 0;
foreach ($row as $item) {
$myxls->write($rownum, $colnum, $item, $format);
$colnum++;
}
$rownum++;
} else if ($download=='CSV') {
$text = implode("\t", $row);
echo $text." \n";
}
}
if (!$download) {
$table->finish_output();
if ($candelete) {
echo '<table id="commands">';
echo '<tr><td>';
echo '<a href="javascript:select_all_in(\'DIV\', null, \'scormtablecontainer\');">'.
get_string('selectall', 'scorm').'</a> / ';
echo '<a href="javascript:deselect_all_in(\'DIV\', null, \'scormtablecontainer\');">'.
get_string('selectnone', 'scorm').'</a> ';
echo '&nbsp;&nbsp;';
echo '<input type="submit" value="'.get_string('deleteselected', 'quiz_overview').'"/>';
echo '</td></tr></table>';
// Close form
echo '</div>';
echo '</form>';
}
echo '</div>';
if (!empty($attempts)) {
echo '<table class="boxaligncenter"><tr>';
echo '<td>';
echo $OUTPUT->single_button(new moodle_url('/mod/scorm/report.php', $pageoptions + $displayoptions + array('download' => 'ODS')), get_string('downloadods'));
echo "</td>\n";
echo '<td>';
echo $OUTPUT->single_button(new moodle_url('/mod/scorm/report.php', $pageoptions + $displayoptions + array('download' => 'Excel')), get_string('downloadexcel'));
echo "</td>\n";
echo '<td>';
echo $OUTPUT->single_button(new moodle_url('/mod/scorm/report.php', $pageoptions + $displayoptions + array('download' => 'CSV')), get_string('downloadtext'));
echo "</td>\n";
echo "<td>";
echo "</td>\n";
echo '</tr></table>';
}
}
if (!$download) {
$mform->set_data($displayoptions + compact('detailedrep', 'pagesize'));
$mform->display();
}
} else {
echo $OUTPUT->notification(get_string('noactivity', 'scorm'));
}
if ($download == 'Excel' or $download == 'ODS') {
$workbook->close();
exit;
} else if ($download == 'CSV') {
exit;
}
} else {
echo $OUTPUT->notification(get_string('noactivity', 'scorm'));
}
return 1;
}// function ends
function canview($id, $contextmodule) {
global $CFG;
if (has_capability('mod/scorm:viewreport', $contextmodule)) {
$return = '<p>';
$return.= '<a href="'.$CFG->wwwroot.'/mod/scorm/report.php?mode=basic&id='.$id.'">'.get_string('pluginname', 'scorm_basic').'</a>';
$return.= '</p>';
return $return;
}
return false;
}
}
+28
View File
@@ -0,0 +1,28 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Defines the version of scorm_basic
*
* @package scorm_basic
* @author Ankit Kumar Agarwal
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
$plugin->version = 0.3;
+47
View File
@@ -0,0 +1,47 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* @package scorm_basic
* @author Ankit Kumar Agarwal
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
////////////////////////////////////////////////////////////////////
/// Default class for Scorm plugins
///
/// Doesn't do anything on it's own -- it needs to be extended.
/// This class displays scorm reports. Because it is called from
/// within /mod/scorm/report.php you can assume that the page header
/// and footer are taken care of.
///
/// This file can refer to itself as report.php to pass variables
/// to itself - all these will also be globally available.
////////////////////////////////////////////////////////////////////
class scorm_default_report {
function display($scorm, $cm, $course, $attemptids, $action, $download) {
/// This function just displays the report
return true;
}
function settings($cm, $course, $quiz) {
/// This function just displays the settings
return true;
}
function canview($id, $contextmodule) {
/// This function just displays the settings
return false;
}
}
+43
View File
@@ -0,0 +1,43 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Returns an array of reports to which are currently readable.
* @package scorm_basic
* @author Ankit Kumar Agarwal
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
function scorm_report_list($context) {
global $DB;
static $reportlist = null;
if (!is_null($reportlist)) {
return $reportlist;
}
$reportdirs = get_plugin_list('scorm');
$reportcaps = array();
foreach ($reportdirs as $reportname => $notused) {
$pluginfile = 'report/'.$reportname.'/report.php';
if (is_readable($pluginfile)) {
include_once($pluginfile);
$reportclassname = "scorm_{$reportname}_report";
if (class_exists($reportclassname)) {
$reportcaps[] = $reportname;
}
}
}
return $reportcaps;
}
+8 -8
View File
@@ -15,12 +15,12 @@
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Sets up the tabs used by the scorm pages based on the users capabilities.
*
* @author Dan Marsden and others.
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
* @package scorm
*/
* Sets up the tabs used by the scorm pages based on the users capabilities.
*
* @author Dan Marsden and others.
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
* @package scorm
*/
if (empty($scorm)) {
error('You cannot call this script in that way');
@@ -36,7 +36,7 @@ if (!isset($cm)) {
$contextmodule = get_context_instance(CONTEXT_MODULE, $cm->id);
$tabs = array();
$row = array();
$row = array();
$inactive = array();
$activated = array();
@@ -44,7 +44,7 @@ if (has_capability('mod/scorm:savetrack', $contextmodule)) {
$row[] = new tabobject('info', "$CFG->wwwroot/mod/scorm/view.php?id=$cm->id", get_string('info', 'scorm'));
}
if (has_capability('mod/scorm:viewreport', $contextmodule)) {
$row[] = new tabobject('reports', "$CFG->wwwroot/mod/scorm/report.php?id=$cm->id", get_string('results', 'scorm'));
$row[] = new tabobject('reports', "$CFG->wwwroot/mod/scorm/report.php?id=$cm->id", get_string('reports', 'scorm'));
}
if ($currenttab == 'info' && count($row) == 1) {
+9 -9
View File
@@ -8,20 +8,20 @@
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* This page displays the user data from a single attempt
*
* @package mod
* @subpackage scorm
* @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
* This page displays the user data from a single attempt
*
* @package mod
* @subpackage scorm
* @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require_once("../../config.php");
require_once($CFG->dirroot.'/mod/scorm/locallib.php');
+1 -2
View File
@@ -23,7 +23,6 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
$module->version = 2011021402; // The (date) version of this module
$module->version = 2011060500; // The (date) version of this module
$module->requires = 2010080300; // The version of Moodle that is required
$module->cron = 300; // How often should cron check this module (seconds)?