Moodle  2.2.1
http://www.collinsharper.com
C:/xampp/htdocs/moodle/question/engine/upgrade/logger.php
Go to the documentation of this file.
00001 <?php
00002 // This file is part of Moodle - http://moodle.org/
00003 //
00004 // Moodle is free software: you can redistribute it and/or modify
00005 // it under the terms of the GNU General Public License as published by
00006 // the Free Software Foundation, either version 3 of the License, or
00007 // (at your option) any later version.
00008 //
00009 // Moodle is distributed in the hope that it will be useful,
00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012 // GNU General Public License for more details.
00013 //
00014 // You should have received a copy of the GNU General Public License
00015 // along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
00016 
00027 defined('MOODLE_INTERNAL') || die();
00028 
00029 
00038 class question_engine_assumption_logger {
00039     protected $handle;
00040     protected $attemptid;
00041 
00042     public function __construct() {
00043         global $CFG;
00044         make_upload_directory('upgradelogs');
00045         $date = date('Ymd-His');
00046         $this->handle = fopen($CFG->dataroot . '/upgradelogs/qe_' .
00047                 $date . '.html', 'a');
00048         fwrite($this->handle, '<html><head><title>Question engine upgrade assumptions ' .
00049                 $date . '</title></head><body><h2>Question engine upgrade assumptions ' .
00050                 $date . "</h2>\n\n");
00051     }
00052 
00053     public function set_current_attempt_id($id) {
00054         $this->attemptid = $id;
00055     }
00056 
00057     public function log_assumption($description, $quizattemptid = null) {
00058         global $CFG;
00059         $message = '<p>' . $description;
00060         if (!$quizattemptid) {
00061             $quizattemptid = $this->attemptid;
00062         }
00063         if ($quizattemptid) {
00064             $message .= ' (<a href="' . $CFG->wwwroot . '/mod/quiz/review.php?attempt=' .
00065                     $quizattemptid . '">Review this attempt</a>)';
00066         }
00067         $message .= "</p>\n";
00068         fwrite($this->handle, $message);
00069     }
00070 
00071     public function __destruct() {
00072         fwrite($this->handle, '</body></html>');
00073         fclose($this->handle);
00074     }
00075 }
00076 
00077 
00084 class dummy_question_engine_assumption_logger extends question_engine_assumption_logger {
00085     protected $attemptid;
00086 
00087     public function __construct() {
00088     }
00089 
00090     public function log_assumption($description, $quizattemptid = null) {
00091     }
00092 
00093     public function __destruct() {
00094     }
00095 }
 All Data Structures Namespaces Files Functions Variables Enumerations