Commit c7df5006 authored by Tim Hunt's avatar Tim Hunt
Browse files

MDL-20636 Add lots of missing public/protected/private.

parent c73c9836
......@@ -38,7 +38,7 @@ require_once($CFG->libdir.'/formslib.php');
*/
class quiz_add_random_form extends moodleform {
function definition() {
protected function definition() {
global $CFG, $DB;
$mform =& $this->_form;
......@@ -78,7 +78,7 @@ class quiz_add_random_form extends moodleform {
$mform->setType('returnurl', PARAM_LOCALURL);
}
function validation($fromform, $files) {
public function validation($fromform, $files) {
$errors = parent::validation($fromform, $files);
if (!empty($fromform['newcategory']) && trim($fromform['name']) == '') {
......
......@@ -40,7 +40,7 @@ defined('MOODLE_INTERNAL') || die();
* @since Moodle 2.0
*/
class moodle_quiz_exception extends moodle_exception {
function __construct($quizobj, $errorcode, $a = NULL, $link = '', $debuginfo = null) {
public function __construct($quizobj, $errorcode, $a = NULL, $link = '', $debuginfo = null) {
if (!$link) {
$link = $quizobj->view_url();
}
......@@ -83,7 +83,7 @@ class quiz {
* @param object $course the row from the course table for the course we belong to.
* @param bool $getcontext intended for testing - stops the constructor getting the context.
*/
function __construct($quiz, $cm, $course, $getcontext = true) {
public function __construct($quiz, $cm, $course, $getcontext = true) {
$this->quiz = $quiz;
$this->cm = $cm;
$this->quiz->cmid = $this->cm->id;
......@@ -101,7 +101,7 @@ class quiz {
* @param int $userid the the userid.
* @return quiz the new quiz object
*/
static public function create($quizid, $userid) {
public static function create($quizid, $userid) {
global $DB;
$quiz = $DB->get_record('quiz', array('id' => $quizid), '*', MUST_EXIST);
......@@ -358,7 +358,7 @@ class quiz_attempt {
* @param object $cm the course_module object for this quiz.
* @param object $course the row from the course table for the course we belong to.
*/
function __construct($attempt, $quiz, $cm, $course) {
public function __construct($attempt, $quiz, $cm, $course) {
$this->attempt = $attempt;
$this->quizobj = new quiz($quiz, $cm, $course);
$this->quba = question_engine::load_questions_usage_by_activity($this->attempt->uniqueid);
......@@ -370,7 +370,7 @@ class quiz_attempt {
* Used by {create()} and {create_from_usage_id()}.
* @param array $conditions passed to $DB->get_record('quiz_attempts', $conditions).
*/
static protected function create_helper($conditions) {
protected static function create_helper($conditions) {
global $DB;
// TODO deal with the issue that makes this necessary.
......@@ -396,7 +396,7 @@ class quiz_attempt {
* @param int $attemptid the attempt id.
* @return quiz_attempt the new quiz_attempt object
*/
static public function create($attemptid) {
public static function create($attemptid) {
return self::create_helper(array('id' => $attemptid));
}
......@@ -406,7 +406,7 @@ class quiz_attempt {
* @param int $usageid the attempt usage id.
* @return quiz_attempt the new quiz_attempt object
*/
static public function create_from_usage_id($usageid) {
public static function create_from_usage_id($usageid) {
return self::create_helper(array('uniqueid' => $usageid));
}
......@@ -1200,9 +1200,9 @@ abstract class quiz_nav_panel_base {
return '';
}
abstract protected function get_end_bits();
protected abstract function get_end_bits();
abstract protected function get_question_url($slot);
protected abstract function get_question_url($slot);
protected function get_user_picture() {
global $DB, $OUTPUT;
......
......@@ -71,7 +71,7 @@ class backup_quiz_activity_task extends backup_activity_task {
* Code the transformations to perform in the activity in
* order to get transportable (encoded) links
*/
static public function encode_content_links($content) {
public static function encode_content_links($content) {
global $CFG;
$base = preg_quote($CFG->wwwroot,"/");
......
......@@ -56,7 +56,7 @@ class restore_quiz_activity_task extends restore_activity_task {
* Define the contents in the activity that must be
* processed by the link decoder
*/
static public function define_decode_contents() {
public static function define_decode_contents() {
$contents = array();
$contents[] = new restore_decode_content('quiz', array('intro'), 'quiz');
......@@ -69,7 +69,7 @@ class restore_quiz_activity_task extends restore_activity_task {
* Define the decoding rules for links belonging
* to the activity to be executed by the link decoder
*/
static public function define_decode_rules() {
public static function define_decode_rules() {
$rules = array();
$rules[] = new restore_decode_rule('QUIZVIEWBYID', '/mod/quiz/view.php?id=$1', 'course_module');
......@@ -86,7 +86,7 @@ class restore_quiz_activity_task extends restore_activity_task {
* quiz logs. It must return one array
* of {@link restore_log_rule} objects
*/
static public function define_restore_log_rules() {
public static function define_restore_log_rules() {
$rules = array();
$rules[] = new restore_log_rule('quiz', 'add', 'view.php?id={course_module}', '{quiz}');
......@@ -148,7 +148,7 @@ class restore_quiz_activity_task extends restore_activity_task {
* by the restore final task, but are defined here at
* activity level. All them are rules not linked to any module instance (cmid = 0)
*/
static public function define_restore_log_rules_for_course() {
public static function define_restore_log_rules_for_course() {
$rules = array();
$rules[] = new restore_log_rule('quiz', 'view all', 'index.php?id={course}', null);
......
......@@ -54,7 +54,7 @@ class mod_quiz_mod_form extends moodleform_mod {
parent::__construct($current, $section, $cm, $course);
}
function definition() {
protected function definition() {
global $COURSE, $CFG, $DB, $PAGE;
$quizconfig = get_config('quiz');
$mform = $this->_form;
......@@ -353,7 +353,7 @@ class mod_quiz_mod_form extends moodleform_mod {
}
}
function data_preprocessing(&$toform) {
protected function data_preprocessing(&$toform) {
if (isset($toform['grade'])) {
$toform['grade'] = $toform['grade'] + 0; // Convert to a real number, so we don't get 0.0000.
}
......@@ -409,7 +409,7 @@ class mod_quiz_mod_form extends moodleform_mod {
}
}
function validation($data, $files) {
public function validation($data, $files) {
$errors = parent::validation($data, $files);
// Check open and close times are consistent.
......
......@@ -58,7 +58,7 @@ class quiz_override_form extends moodleform {
}
public function definition() {
protected function definition() {
global $CFG, $USER, $DB;
$cm = $this->cm;
......
......@@ -475,7 +475,7 @@ abstract class quiz_attempt_report_table extends table_sql {
}
}
function get_row_class($attempt) {
protected function get_row_class($attempt) {
if ($this->qmsubselect && $attempt->gradedattempt) {
return 'gradedattempt';
} else {
......@@ -525,7 +525,7 @@ abstract class quiz_attempt_report_table extends table_sql {
* @param float $fraction grade on a scale 0..1.
* @return string html fragment.
*/
function icon_for_fraction($fraction) {
protected function icon_for_fraction($fraction) {
global $OUTPUT;
$state = question_state::graded_state_for_fraction($fraction);
......@@ -551,7 +551,7 @@ abstract class quiz_attempt_report_table extends table_sql {
* @param array $slots A list of slots for the questions you want to konw about.
* @return array of records. See the SQL in this function to see the fields available.
*/
function load_question_latest_steps(qubaid_condition $qubaids) {
protected function load_question_latest_steps(qubaid_condition $qubaids) {
$dm = new question_engine_data_mapper();
$latesstepdata = $dm->load_questions_usages_latest_steps(
$qubaids, array_keys($this->questions));
......
......@@ -50,17 +50,14 @@ abstract class quiz_default_report {
* @param $course the coures we are in.
* @param $quiz this quiz.
*/
abstract function display($cm, $course, $quiz);
public abstract function display($cm, $course, $quiz);
function print_header_and_tabs($cm, $course, $quiz, $reportmode = "overview") {
public function print_header_and_tabs($cm, $course, $quiz, $reportmode = 'overview') {
global $PAGE, $OUTPUT;
/// Define some strings
$strquizzes = get_string("modulenameplural", "quiz");
$strquiz = get_string("modulename", "quiz");
/// Print the page header
// Print the page header
$PAGE->set_title(format_string($quiz->name));
$PAGE->set_heading($course->fullname);
echo $OUTPUT->header();
$course_context = get_context_instance(CONTEXT_COURSE, $course->id);
}
}
......@@ -53,7 +53,7 @@ class quiz_grading_settings extends moodleform {
parent::__construct($CFG->wwwroot . '/mod/quiz/report.php', null, 'get');
}
public function definition() {
protected function definition() {
$mform =& $this->_form;
$mform->addElement('header', 'options', get_string('options', 'quiz_grading'));
......
......@@ -52,7 +52,7 @@ class quiz_grading_report extends quiz_default_report {
protected $quiz;
protected $context;
function display($quiz, $cm, $course) {
public function display($quiz, $cm, $course) {
global $CFG, $DB, $PAGE;
$this->quiz = $quiz;
......@@ -519,7 +519,7 @@ class quiz_grading_report extends quiz_default_report {
* Ignored if $orderby = random or $pagesize is null.
* @param int $pagesize implements paging of the results. null = all.
*/
function get_usage_ids_where_question_in_state($summarystate, $slot,
protected function get_usage_ids_where_question_in_state($summarystate, $slot,
$questionid = null, $orderby = 'random', $page = 0, $pagesize = null) {
global $CFG;
$dm = new question_engine_data_mapper();
......
......@@ -38,7 +38,7 @@ require_once($CFG->libdir . '/formslib.php');
*/
class mod_quiz_report_overview_settings extends moodleform {
public function definition() {
protected function definition() {
$mform = $this->_form;
$mform->addElement('header', 'preferencespage', get_string('preferencespage', 'quiz_overview'));
......
......@@ -40,7 +40,7 @@ require_once($CFG->dirroot.'/mod/quiz/report/overview/overview_table.php');
*/
class quiz_overview_report extends quiz_attempt_report {
function display($quiz, $cm, $course) {
public function display($quiz, $cm, $course) {
global $CFG, $COURSE, $DB, $OUTPUT;
$this->context = get_context_instance(CONTEXT_MODULE, $cm->id);
......
......@@ -48,7 +48,7 @@ require_once($CFG->dirroot.'/mod/quiz/report/responses/responses_table.php');
*/
class quiz_responses_report extends quiz_attempt_report {
function display($quiz, $cm, $course) {
public function display($quiz, $cm, $course) {
global $CFG, $COURSE, $DB, $PAGE, $OUTPUT;
$this->context = get_context_instance(CONTEXT_MODULE, $cm->id);
......
......@@ -50,7 +50,7 @@ class quiz_report_responses_table extends quiz_attempt_report_table {
}
}
function wrap_html_start() {
public function wrap_html_start() {
global $PAGE;
if ($this->is_downloading() || !$this->candelete) {
return;
......
......@@ -38,7 +38,7 @@ require_once($CFG->libdir . '/formslib.php');
*/
class mod_quiz_report_responses_settings extends moodleform {
public function definition() {
protected function definition() {
$mform = $this->_form;
$mform->addElement('header', 'preferencespage', get_string('preferencespage', 'quiz_overview'));
......
......@@ -43,7 +43,7 @@ require_once($CFG->dirroot . '/mod/quiz/report/reportlib.php'); // Include the c
class question_reportlib_test extends UnitTestCase {
public static $includecoverage = array('mod/quiz/report/reportlib.php');
function test_quiz_report_index_by_keys() {
public function test_quiz_report_index_by_keys() {
$datum = array();
$object = new stdClass();
$object->qid = 3;
......@@ -67,7 +67,7 @@ class question_reportlib_test extends UnitTestCase {
$this->assertEqual($indexed[101][3][0]->grade, 3);
}
function test_quiz_report_scale_summarks_as_percentage() {
public function test_quiz_report_scale_summarks_as_percentage() {
$quiz = new stdClass();
$quiz->sumgrades = 10;
$quiz->decimalpoints = 2;
......
......@@ -43,6 +43,7 @@ class testable_quiz_statistics_question_stats extends quiz_statistics_question_s
public function set_step_data($states) {
$this->lateststeps = $states;
}
protected function get_random_guess_score($questiondata) {
return 0;
}
......@@ -61,7 +62,7 @@ class quiz_statistics_question_stats_test extends UnitTestCase {
/** @var qstats object created to test class. */
protected $qstats;
function test_qstats() {
public function test_qstats() {
global $CFG;
//data is taken from randomly generated attempts data generated by contrib/tools/generators/qagenerator/
$steps = $this->get_records_from_csv($CFG->dirroot.'/mod/quiz/report/statistics/simpletest/mdl_question_states.csv');
......@@ -84,7 +85,7 @@ class quiz_statistics_question_stats_test extends UnitTestCase {
$this->qstats_q_fields('discriminativeefficiency', $discriminativeefficiency);
}
function qstats_q_fields($fieldname, $values, $multiplier=1) {
public function qstats_q_fields($fieldname, $values, $multiplier=1) {
foreach ($this->qstats->questions as $question) {
$value = array_shift($values);
if ($value !== null) {
......@@ -95,7 +96,7 @@ class quiz_statistics_question_stats_test extends UnitTestCase {
}
}
function get_fields_from_csv($line) {
public function get_fields_from_csv($line) {
$line = trim($line);
$items = preg_split('!,!', $line);
while (list($key) = each($items)) {
......@@ -116,7 +117,7 @@ class quiz_statistics_question_stats_test extends UnitTestCase {
return $items;
}
function get_records_from_csv($filename) {
public function get_records_from_csv($filename) {
$filecontents = file($filename, FILE_IGNORE_NEW_LINES);
$records = array();
$keys = $this->get_fields_from_csv(array_shift($filecontents));//first line is field names
......
......@@ -37,7 +37,7 @@ require_once($CFG->libdir . '/formslib.php');
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class quiz_statistics_statistics_settings_form extends moodleform {
function definition() {
protected function definition() {
$mform = $this->_form;
$mform->addElement('header', 'preferencespage', get_string('preferencespage', 'quiz_overview'));
......
......@@ -47,7 +47,7 @@ class quiz_report_statistics_table extends flexible_table {
/**
* Constructor.
*/
function __construct() {
public function __construct() {
parent::__construct('mod-quiz-report-statistics-report');
}
......@@ -60,7 +60,7 @@ class quiz_report_statistics_table extends flexible_table {
* @param moodle_url $reporturl the URL to redisplay this report.
* @param int $s number of attempts included in the statistics.
*/
function setup($quiz, $cmid, $reporturl, $s) {
public function setup($quiz, $cmid, $reporturl, $s) {
$this->quiz = $quiz;
$this->cmid = $cmid;
......
......@@ -38,7 +38,7 @@ require_once($CFG->dirroot . '/mod/quiz/locallib.php');
*/
class simple_rules_test extends UnitTestCase {
public static $includecoverage = array('mod/quiz/locallib.php');
function test_num_attempts_access_rule() {
public function test_num_attempts_access_rule() {
$quiz = new stdClass();
$quiz->attempts = 3;
$quiz->questions = '';
......@@ -64,7 +64,7 @@ class simple_rules_test extends UnitTestCase {
$this->assertFalse($rule->time_left($attempt, 1));
}
function test_ipaddress_access_rule() {
public function test_ipaddress_access_rule() {
$quiz = new stdClass();
$attempt = new stdClass();
$cm = new stdClass();
......@@ -95,7 +95,7 @@ class simple_rules_test extends UnitTestCase {
$this->assertFalse($rule->time_left($attempt, 1));
}
function test_time_limit_access_rule() {
public function test_time_limit_access_rule() {
$quiz = new stdClass();
$quiz->timelimit = 3600;
$quiz->questions = '';
......@@ -124,7 +124,7 @@ class simple_rules_test extends UnitTestCase {
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class open_close_date_access_rule_test extends UnitTestCase {
function test_no_dates() {
public function test_no_dates() {
$quiz = new stdClass();
$quiz->timeopen = 0;
$quiz->timeclose = 0;
......@@ -151,7 +151,7 @@ class open_close_date_access_rule_test extends UnitTestCase {
$this->assertFalse($rule->time_left($attempt, 0));
}
function test_start_date() {
public function test_start_date() {
$quiz = new stdClass();
$quiz->timeopen = 10000;
$quiz->timeclose = 0;
......@@ -177,7 +177,7 @@ class open_close_date_access_rule_test extends UnitTestCase {
$this->assertFalse($rule->time_left($attempt, 0));
}
function test_close_date() {
public function test_close_date() {
$quiz = new stdClass();
$quiz->timeopen = 0;
$quiz->timeclose = 20000;
......@@ -209,7 +209,7 @@ class open_close_date_access_rule_test extends UnitTestCase {
$this->assertEqual($rule->time_left($attempt, 20100), -100);
}
function test_both_dates() {
public function test_both_dates() {
$quiz = new stdClass();
$quiz->timeopen = 10000;
$quiz->timeclose = 20000;
......@@ -259,7 +259,7 @@ class open_close_date_access_rule_test extends UnitTestCase {
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class inter_attempt_delay_access_rule_test extends UnitTestCase {
function test_just_first_delay() {
public function test_just_first_delay() {
$quiz = new stdClass();
$quiz->attempts = 3;
$quiz->timelimit = 0;
......@@ -291,7 +291,7 @@ class inter_attempt_delay_access_rule_test extends UnitTestCase {
$this->assertFalse($rule->prevent_new_attempt(2, $attempt));
}
function test_just_second_delay() {
public function test_just_second_delay() {
$quiz = new stdClass();
$quiz->attempts = 5;
$quiz->timelimit = 0;
......@@ -326,7 +326,7 @@ class inter_attempt_delay_access_rule_test extends UnitTestCase {
$this->assertEqual($rule->prevent_new_attempt(4, $attempt), get_string('youmustwait', 'quiz', userdate(10001)));
}
function test_just_both_delays() {
public function test_just_both_delays() {
$quiz = new stdClass();
$quiz->attempts = 5;
$quiz->timelimit = 0;
......@@ -369,7 +369,7 @@ class inter_attempt_delay_access_rule_test extends UnitTestCase {
$this->assertEqual($rule->prevent_new_attempt(4, $attempt), get_string('youmustwait', 'quiz', userdate(10001)));
}
function test_with_close_date() {
public function test_with_close_date() {
$quiz = new stdClass();
$quiz->attempts = 5;
$quiz->timelimit = 0;
......@@ -419,7 +419,7 @@ class inter_attempt_delay_access_rule_test extends UnitTestCase {
$this->assertFalse($rule->prevent_new_attempt(2, $attempt));
}
function test_time_limit_and_overdue() {
public function test_time_limit_and_overdue() {
$quiz = new stdClass();
$quiz->attempts = 5;
$quiz->timelimit = 100;
......@@ -484,7 +484,7 @@ class inter_attempt_delay_access_rule_test extends UnitTestCase {
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class password_access_rule_test extends UnitTestCase {
function test_password_access_rule() {
public function test_password_access_rule() {
$quiz = new stdClass();
$quiz->password = 'frog';
$quiz->questions = '';
......@@ -510,7 +510,7 @@ class password_access_rule_test extends UnitTestCase {
class securewindow_access_rule_test extends UnitTestCase {
// Nothing very testable in this class, just test that it obeys the general access rule contact.
function test_securewindow_access_rule() {
public function test_securewindow_access_rule() {
$quiz = new stdClass();
$quiz->popup = 1;
$quiz->questions = '';
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment