dirroot.'/blocks/autoattend/lib.php');
class block_autoattend extends block_base
{
function init()
{
$this->title = get_string('autoattendblock', 'block_autoattend');
$this->version = 2010032820;
$this->release = '1.1.0';
}
function get_content()
{
global $CFG, $USER;
if ($this->content != NULL) {
return $this->content;
}
$id = optional_param('id', 0, PARAM_INT);
if ($id != 0) {
if (!$course = get_record('course', 'id', $id)) {
error(get_string('courseidwrong', 'block_autoattend'));
}
}
else {
return '';
}
$this->content = new stdClass;
$this->content->items = array();
$this->content->icons = array();
$this->content->footer = '';
if(isteacher($course->id)) { // Teacher
$this->content->text = ''.get_string('takemanualattend','block_autoattend').'
';
$this->content->text .= ''.get_string('report','block_autoattend').'
';
$this->content->text .= ''.get_string('settings','block_autoattend').'
';
}
elseif (isguest()) {
$this->content->text = ''; // Guest
}
else { // Student
$comqry = "select count(*) as cnt
from {$CFG->prefix}autoattend_students std, {$CFG->prefix}autoattend_sessions ses
where attsid=ses.id and ses.courseid={$course->id} and std.studentid={$USER->id}
and std.status<>'Y' ";
$comdata = get_record_sql($comqry);
$complete = $comdata->cnt;
if($complete == 0) { //autoattend not generated yet
$this->content->text .= get_string('attendnotstarted','block_autoattend');
}
else { //autoattend taken
$settings = autoattend_get_settings($course->id);
foreach($settings as $set) {
$desc = get_string($set->status.'acronymfull', 'block_autoattend');
$this->content->text .= $desc.': '.
autoattend_get_status_num($USER->id,$course->id,$set->status).'
';
}
$percent = sprintf("%0.1f", autoattend_get_percent($USER->id,$course->id));
$grade = autoattend_get_grade($USER->id,$course->id);
$this->content->text .= get_string('attendpercent','block_autoattend').': '.$percent.' %
';
$this->content->text .= get_string('attendgrade','block_autoattend').": $grade
";
$this->content->text .= ''.get_string('indetail','block_autoattend').'';
}
}
return $this->content;
}
}
?>