コード例 #1
0
ファイル: startattempt.php プロジェクト: e-rasvet/reader
// Course module id
$book = required_param('book', PARAM_INT);
// Course module id
$page = optional_param('page', 0, PARAM_INT);
// Page to jump to in the attempt.
if (!($cm = get_coursemodule_from_id('reader', $id))) {
    print_error('invalidcoursemodule');
}
if (!($course = $DB->get_record('course', array('id' => $cm->course)))) {
    print_error("coursemisconf");
}
if (!($reader = $DB->get_record('reader', array('id' => $cm->instance)))) {
    print_error('invalidcoursemodule');
}
require_login($course, true, $cm);
$readerobj = reader::create($reader->id, $USER->id, $book);
// This script should only ever be posted to, so set page URL to the view page.
$PAGE->set_url($readerobj->view_url());
// Check login and sesskey.
$PAGE->set_pagelayout('base');
// if no questions have been set up yet redirect to edit.php
if (!$readerobj->has_questions()) {
    redirect($readerobj->edit_url());
}
// Look for an existing attempt.
$attempts = reader_get_user_attempts($reader->id, $USER->id, 'all');
$lastattempt = end($attempts);
// If an in-progress attempt exists, check password then redirect to it.
if ($lastattempt && !$lastattempt->timefinish) {
    redirect($readerobj->attempt_url($lastattempt->id, $page));
}
コード例 #2
0
ファイル: session.php プロジェクト: rgantt/sake
 public function __construct($session = array())
 {
     parent::__construct($session);
     $this->heap = isset($_SESSION) ? $_SESSION : $session;
 }
コード例 #3
0
ファイル: attemptlib.php プロジェクト: e-rasvet/reader
 /**
  * Constructor assuming we already have the necessary data loaded.
  *
  * @param object $attempt the row of the reader_attempts table.
  * @param object $reader the reader object for this attempt and user.
  * @param object $cm the course_module object for this reader.
  * @param object $course the row from the course table for the course we belong to.
  */
 public function __construct($attempt, $reader, $cm, $course)
 {
     $this->attempt = $attempt;
     $this->readerobj = reader::create($reader->id, $attempt->userid, $attempt->quizid);
     $this->quba = question_engine::load_questions_usage_by_activity($this->attempt->uniqueid);
     $this->determine_layout();
     $this->number_questions();
 }