. /** * Page module version information * * @package mod_palestra * @copyright 2021 Interlegis (https://www.interlegis.leg.br) * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ require('../../config.php'); require_once($CFG->dirroot.'/mod/palestra/lib.php'); require_once($CFG->libdir.'/completionlib.php'); $id = optional_param('id', 0, PARAM_INT); // Course Module ID $p = optional_param('p', 0, PARAM_INT); // Palestra instance ID if ($p) { if (!$palestra = $DB->get_record('palestra', array('id'=>$p))) { print_error('invalidaccessparameter'); } $cm = get_coursemodule_from_instance('palestra', $palestra->id, $palestra->course, false, MUST_EXIST); } else { if (!$cm = get_coursemodule_from_id('palestra', $id)) { print_error('invalidcoursemodule'); } $palestra = $DB->get_record('palestra', array('id'=>$cm->instance), '*', MUST_EXIST); } $course = $DB->get_record('course', array('id'=>$cm->course), '*', MUST_EXIST); require_course_login($course, true, $cm); $context = context_module::instance($cm->id); require_capability('mod/palestra:view', $context); // Completion and trigger events. palestra_view($palestra, $course, $cm, $context); $PAGE->set_url('/mod/palestra/view.php', array('id' => $cm->id)); $PAGE->set_title($course->shortname.': '.$palestra->name); $PAGE->set_heading($course->fullname); $PAGE->set_activity_record($palestra); $PAGE->requires->jquery(); echo $OUTPUT->header(); echo $OUTPUT->heading(format_string($palestra->name), 2); if (trim(strip_tags($palestra->intro))) { echo $OUTPUT->box_start('mod_introbox', 'pageintro'); echo format_module_intro('palestra', $palestra, $cm->id); echo $OUTPUT->box_end(); } echo $OUTPUT->box("", "generalbox center clearfix text-center"); $stream = ""; if ($palestra->includechat) { $parse = parse_url($CFG->wwwroot); $domain = $parse['host']; $chat = ""; if ($palestra->chatdisposition =='S') { echo '
'; echo $OUTPUT->box($stream, "col-8"); echo $OUTPUT->box($chat, "col-4"); echo "
"; } else { echo $OUTPUT->box($stream, "generalbox center clearfix"); echo $OUTPUT->box($chat, "generalbox center clearfix"); } } $now = time(); // Presence will only be registered if user accessed before the end // of palestra (startdate+duration), plus a lag margin (duration*1.5) // or if gradeafter is checked as True if (($now < ($palestra->startdate + ($palestra->duration*1.5*60))) or ($palestra->gradeafter == 1)) { $presence = array('palestraid'=>$palestra->id, 'userid'=>$USER->id, 'starttime'=>$now, 'lastcheck'=>$now); if ($palestra->checkinterval == 0) { // Just accessing the palestra grants 100% of grade $presence['lastcheck'] += $palestra->duration * 60; } $presence['id'] = $DB->insert_record('palestra_presence', $presence); $DB->set_field('palestra', 'needsupdate', '1', ['id'=>$palestra->id]); $interval = $palestra->checkinterval * 60 * 1000; $alert = get_string('presence_unregistered', 'palestra'); if ($interval > 0) { echo " "; } } else { $out_of_date_alert = get_string('out_of_date_alert', 'palestra'); echo " "; } echo $OUTPUT->footer();