libdir.'/blocklib.php'); require_once('lib.php'); require_once('tuis_tools.php'); $courseid = required_param('course', PARAM_INT); $attsid = required_param('attsid'); $action = optional_param('action', '', PARAM_ALPHA); $submit = optional_param('submit', ''); if (!empty($submit) && $submit==get_string('return', 'block_autoattend')) { redirect('index.php?course='.$courseid); } if (! $course = get_record('course', 'id', $courseid)) { error(get_string('courseidwrong','block_autoattend')); } require_login($course->id); if (!isteacher($course->id)) { error(get_string('notaccessstudent','block_autoattend')); } if (! $user = get_record("user", "id", $USER->id) ) { error(get_string('nosuchuser','block_autoattend')); } if (!$att = get_record('autoattend_sessions', 'id', $attsid) ) { error(get_string('nosuchsession','block_autoattend')); } if ($course->category) { print_header(get_string('updatesessioninfo','block_autoattend'). ' ' .get_string('autoattend','block_autoattend') .' ' . get_string('date','block_autoattend'), $course->fullname, "wwwroot}/course/view.php?id=$course->id\">$course->shortname -> ". "id\">".get_string('autoattend','block_autoattend')." -> ". get_string('updatesessioninfo','block_autoattend'),"", "", true, " ", navmenu($course)); } else { print_header("$course->shortname: ".get_string('autoattend','block_autoattend'), $course->fullname, get_string('autoattend','block_autoattend'), "", "", true, " ", navmenu($course)); } print_heading(get_string('update','block_autoattend').'   ' . get_string('attendforsession','block_autoattend').' :: ' .$course->fullname); if ($action=="update") { $newday = required_param('newday', PARAM_INT); $newmonth = required_param('newmonth', PARAM_INT); $newyear = required_param('newyear', PARAM_INT); $method = required_param('newmethod', PARAM_ALPHA); $shour = required_param('newshour', PARAM_INT); $smin = required_param('newsmin', PARAM_INT); $ehour = required_param('newehour', PARAM_INT); $emin = required_param('newemin', PARAM_INT); $lmin = required_param('newlmin', PARAM_INT); $attendkey = required_param('attendkey'); $allowip = required_param('allowip'); $desc = required_param('desc'); $randomkey = optional_param('randomkey',''); $denysameip = optional_param('denysameip',''); if (empty($denysameip)) $denysameip = '0'; $stime = $shour*ONE_HOUR + $smin*ONE_MIN; $etime = $ehour*ONE_HOUR + $emin*ONE_MIN; $starttime = $stime + $TIME_OFFSET; // GMT $endtime = $etime + $TIME_OFFSET; // GMT $latetime = ($lmin - 1)*MIN_INTVL*ONE_MIN; $newdate = mktime(0, 0, 0, $newmonth, $newday, $newyear); $times = $endtime - $starttime; if($times <= 0) { error(get_string('wrongtimesselected','block_autoattend'), "$CFG->wwwroot/blocks/autoattend/updateSession.php?course=$courseid&attsid=$attsid"); } $count = count_records('autoattend_sessions','courseid', $course->id, 'sessdate', $newdate, 'starttime', $starttime); if ($count!=0 and ($newdate!=$att->sessdate or $starttime!=$att->starttime)) { //duplicate session exists error(get_string('sessionalreadyexists','block_autoattend'), "$CFG->wwwroot/blocks/autoattend/updateSession.php?course=".$courseid."&attsid=".$attsid); } else { $ntime = time(); if ($ntime < $newdate+$stime) $state = 'N'; else if ($ntime>=$newdate+$stime and $ntime<=$newdate+$etime) $state = 'O'; else $state = 'C'; $prvstate = $att->state; $prvmethod = $att->method; $att->sessdate = $newdate; $att->timemodified = $ntime; $att->method = $method; $att->state = $state; $att->starttime = $starttime; $att->endtime = $endtime; $att->latetime = $latetime; $att->allowip = $allowip; $att->denysameip = $denysameip; $att->description = $desc; if (!$attendkey and $randomkey) { $att->attendkey = tuis_randstr(5, true); } else { $att->attendkey = $attendkey; } $result = update_record('autoattend_sessions', $att); if ($result) { $loginfo = "=$attsid,$prvmethod,$method,$prvstate,$state"; add_to_log($course->id, 'autoattend', 'update session', 'index.php?course='.$course->id, $loginfo); } else { error(get_string('sessionupdateerror','block_autoattend'), "$CFG->wwwroot/blocks/autoattend/updateSession.php?course=".$courseid."&attsid=".$attsid); } } //redirect('index.php?course='.$course->id, get_string('sessionupdated','block_autoattend'), 1); redirect('updateSession.php?course='.$course->id.'&attsid='.$attsid, get_string('sessionupdated','block_autoattend'), 1); } $acheck = ''; $scheck = ''; $mcheck = ''; if ($att->method=='A') $acheck = 'checked="checked"'; else if ($att->method=='S') $scheck = 'checked="checked"'; else if ($att->method=='M') $mcheck = 'checked="checked"'; $late_time = (int)($att->latetime/ONE_MIN); $late_order = (int)($late_time/5) + 1; ?>
state!='N') { ?> method=='S') { ?> method=='A' or $att->method=='S') { ?> method=='S') { ?>

:      ">
: >    >    >

: sessdate);?>
: sessdate);?>
: starttime);?>
: starttime);?>
: endtime);?>
: endtime);?>
:
: 0, 5,10,15,20,25,30,35,40,45,50,55,60, 65,70,75,80,85,90,95,100,105,110,115,120), 'newlmin', $late_order, false); echo ' '.get_string('minute','block_autoattend');?>
: attendkey ? '': 'checked') ?> >
:
: denysameip=='0' ? '': 'checked') ?> >
:
  ">   ">   ">