Ejemplo n.º 1
0
require_once $CFG->dirroot . '/mod/reader/accessrules.php';
require_once $CFG->dirroot . '/mod/reader/attemptlib.php';
// Remember the current time as the time any responses were submitted
// (so as to make sure students don't get penalized for slow processing on this page)
$timenow = time();
// Get submitted parameters.
$attemptid = required_param('attempt', PARAM_INT);
$next = optional_param('next', false, PARAM_BOOL);
$thispage = optional_param('thispage', 0, PARAM_INT);
$nextpage = optional_param('nextpage', 0, PARAM_INT);
$finishattempt = optional_param('finishattempt', 0, PARAM_BOOL);
$timeup = optional_param('timeup', 0, PARAM_BOOL);
$scrollpos = optional_param('scrollpos', '', PARAM_RAW);
$likebook = optional_param('likebook', NULL, PARAM_CLEAN);
$transaction = $DB->start_delegated_transaction();
$attemptobj = reader_attempt::create($attemptid);
// Set $nexturl now.
if ($next) {
    $page = $nextpage;
} else {
    $page = $thispage;
}
if ($page == -1) {
    $nexturl = $attemptobj->summary_url();
} else {
    $nexturl = $attemptobj->attempt_url(0, $page);
    if ($scrollpos !== '') {
        $nexturl->param('scrollpos', $scrollpos);
    }
}
// We treat automatically closed attempts just like normally closed attempts
Ejemplo n.º 2
0
 public function user_picture()
 {
     global $DB;
     if (!$this->attemptobj->get_reader()->showuserpicture) {
         return null;
     }
     $user = $DB->get_record('user', array('id' => $this->attemptobj->get_userid()));
     $userpicture = new user_picture($user);
     $userpicture->courseid = $this->attemptobj->get_courseid();
     return $userpicture;
 }