Documentos de Académico
Documentos de Profesional
Documentos de Cultura
php
//
//
//
//
//
//
//
//
//
//
//
//
//
//
/**
* Prints a particular instance of jclic
*
* You can have a rather longer description of the file as well,
* if you like, and it can span multiple lines.
*
* @package
mod
* @subpackage jclic
* @copyright 2011 Departament d'Ensenyament de la Generalitat de Catalunya
* @author
Sara Arjona Tllez <sarjona@xtec.cat>
* @license
http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require_once(dirname(dirname(dirname(__FILE__))).'/config.php');
require_once(dirname(__FILE__).'/locallib.php');
$id = optional_param('id', 0, PARAM_INT); // course_module ID, or
$mode = optional_param('mode', 'normal', PARAM_TEXT);
if ($id) {
$cm
$course
T_EXIST);
$jclic
ST_EXIST);
} else {
error('You
}
$extrafieldnames,
array(
$strstarttime,
get_string('attempts', 'jclic'),
get_string('solveddone', 'jclic'),
get_string('totaltime', 'jclic'),
get_string('grade'),
));
require_once($CFG->libdir.'/tablelib.php');
$table = new flexible_table('mod-jclic-results');
$table->define_columns($tablecolumns);
$table->define_headers($tableheaders);
$table->define_baseurl($CFG->wwwroot.'/mod/jclic/report.php?id='.$cm->id.'&curre
ntgroup='.$currentgroup.'&mode='.$mode);
$table->sortable(true, 'lastname'); // Sorted by lastname by default
$table->collapsible(true);
$table->initialbars(true);
$table->column_suppress('picture');
$table->column_suppress('fullname');
$table->column_class('picture', 'picture');
$table->column_class('fullname', 'fullname');
foreach ($extrafields as $field) {
$table->column_class($field, $field);
}
$table->set_attribute('cellspacing', '0');
$table->set_attribute('id', 'attempts');
$table->set_attribute('class', 'results generaltable generalbox');
$table->set_attribute('width', '100%');
$table->no_sorting('starttime');
$table->no_sorting('solveddone');
$table->no_sorting('totaltime');
$table->no_sorting('attempts');
$table->no_sorting('grade');
// Start working -- this is necessary as soon as the niceties are over
$table->setup();
/// Construct the SQL
list($where, $params) = $table->get_sql_where();
if ($where) {
$where .= ' AND ';
}
if ($sort = $table->get_sql_sort()) {
$sort = ' ORDER BY '.$sort;
}
$ufields = user_picture::fields('u', $extrafields);
if (!empty($users)) {
$select = "SELECT $ufields ";
$sql = 'FROM {user} u '.
'WHERE '.$where.'u.id IN ('.implode(',',$users).') ';
$first_session = false;
$picture = null;
$userlink = null;
// Remove extradata fields to show them only once
foreach ($extradata as $key=>$value) {
$extradata[$key] = '';
}
}
}
}
}
// Sessions summary
$starttime = ($numsessions>0)?get_string('totals', 'jclic'):(isset($
sessions_summary->starttime)?date('d/m/Y H:i',strtotime($sessions_summary->start
time)):'-');
$solveddone = $sessions_summary->solved. ' / '. $sessions_summary->d
one;
$grade = $sessions_summary->score;
$totaltime = $sessions_summary->totaltime;
$attempts = $sessions_summary->attempts;
$row = array_merge(array($picture, $userlink), $extradata,
array($starttime, $attempts, $solveddone, $totaltime, $grade
));
$rowclass = ($numsessions > 0) ? 'summary-row' : "";
$table->add_data($row, $rowclass);
}
if ($countusers) {
$table->pagesize($perpage, $countusers);
$table->print_html(); // Print the whole table
} else {
echo $OUTPUT->notification(get_string('msg_nosessions', 'jclic'), 'n
otifymessage');
}
}
} else {
echo $OUTPUT->notification(get_string('msg_nosessions', 'jclic'), 'notifymes
sage');
}
echo $OUTPUT->footer();