Skip to content

Commit

Permalink
MDL-20636 Add lots of missing public/protected/private.
Browse files Browse the repository at this point in the history
  • Loading branch information
timhunt committed Mar 23, 2011
1 parent c73c983 commit c7df500
Show file tree
Hide file tree
Showing 86 changed files with 663 additions and 695 deletions.
4 changes: 2 additions & 2 deletions mod/quiz/addrandomform.php
Expand Up @@ -38,7 +38,7 @@
*/
class quiz_add_random_form extends moodleform {

function definition() {
protected function definition() {
global $CFG, $DB;
$mform =& $this->_form;

Expand Down Expand Up @@ -78,7 +78,7 @@ function definition() {
$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']) == '') {
Expand Down
18 changes: 9 additions & 9 deletions mod/quiz/attemptlib.php
Expand Up @@ -40,7 +40,7 @@
* @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();
}
Expand Down Expand Up @@ -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;
Expand All @@ -101,7 +101,7 @@ function __construct($quiz, $cm, $course, $getcontext = true) {
* @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);
Expand Down Expand Up @@ -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);
Expand All @@ -370,7 +370,7 @@ function __construct($attempt, $quiz, $cm, $course) {
* 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.
Expand All @@ -396,7 +396,7 @@ static protected function create_helper($conditions) {
* @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));
}

Expand All @@ -406,7 +406,7 @@ static public function create($attemptid) {
* @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));
}

Expand Down Expand Up @@ -1200,9 +1200,9 @@ protected function get_before_button_bits() {
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;
Expand Down
Expand Up @@ -71,7 +71,7 @@ protected function define_my_steps() {
* 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,"/");
Expand Down
8 changes: 4 additions & 4 deletions mod/quiz/backup/moodle2/restore_quiz_activity_task.class.php
Expand Up @@ -56,7 +56,7 @@ protected function define_my_steps() {
* 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');
Expand All @@ -69,7 +69,7 @@ static public function define_decode_contents() {
* 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');
Expand All @@ -86,7 +86,7 @@ static public function define_decode_rules() {
* 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}');
Expand Down Expand Up @@ -148,7 +148,7 @@ static public function define_restore_log_rules() {
* 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);
Expand Down
6 changes: 3 additions & 3 deletions mod/quiz/mod_form.php
Expand Up @@ -54,7 +54,7 @@ public function __construct($current, $section, $cm, $course) {
parent::__construct($current, $section, $cm, $course);
}

function definition() {
protected function definition() {
global $COURSE, $CFG, $DB, $PAGE;
$quizconfig = get_config('quiz');
$mform = $this->_form;
Expand Down Expand Up @@ -353,7 +353,7 @@ protected function preprocessing_review_settings(&$toform, $whenname, $when) {
}
}

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.
}
Expand Down Expand Up @@ -409,7 +409,7 @@ function data_preprocessing(&$toform) {
}
}

function validation($data, $files) {
public function validation($data, $files) {
$errors = parent::validation($data, $files);

// Check open and close times are consistent.
Expand Down
2 changes: 1 addition & 1 deletion mod/quiz/override_form.php
Expand Up @@ -58,7 +58,7 @@ public function quiz_override_form($submiturl, $cm, $quiz, $context, $groupmode,

}

public function definition() {
protected function definition() {
global $CFG, $USER, $DB;

$cm = $this->cm;
Expand Down
6 changes: 3 additions & 3 deletions mod/quiz/report/attemptsreport.php
Expand Up @@ -475,7 +475,7 @@ public function col_feedbacktext($attempt) {
}
}

function get_row_class($attempt) {
protected function get_row_class($attempt) {
if ($this->qmsubselect && $attempt->gradedattempt) {
return 'gradedattempt';
} else {
Expand Down Expand Up @@ -525,7 +525,7 @@ public function make_review_link($data, $attempt, $slot) {
* @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);
Expand All @@ -551,7 +551,7 @@ function icon_for_fraction($fraction) {
* @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));
Expand Down
11 changes: 4 additions & 7 deletions mod/quiz/report/default.php
Expand Up @@ -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);
}
}
2 changes: 1 addition & 1 deletion mod/quiz/report/grading/gradingsettings_form.php
Expand Up @@ -53,7 +53,7 @@ public function __construct($hidden, $counts, $shownames, $showidnumbers) {
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'));
Expand Down
4 changes: 2 additions & 2 deletions mod/quiz/report/grading/report.php
Expand Up @@ -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;
Expand Down Expand Up @@ -519,7 +519,7 @@ protected function get_question_state_summary($slots) {
* 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();
Expand Down
2 changes: 1 addition & 1 deletion mod/quiz/report/overview/overviewsettings_form.php
Expand Up @@ -38,7 +38,7 @@
*/
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'));
Expand Down
2 changes: 1 addition & 1 deletion mod/quiz/report/overview/report.php
Expand Up @@ -40,7 +40,7 @@
*/
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);
Expand Down
2 changes: 1 addition & 1 deletion mod/quiz/report/responses/report.php
Expand Up @@ -48,7 +48,7 @@
*/
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);
Expand Down
2 changes: 1 addition & 1 deletion mod/quiz/report/responses/responses_table.php
Expand Up @@ -50,7 +50,7 @@ public function build_table() {
}
}

function wrap_html_start() {
public function wrap_html_start() {
global $PAGE;
if ($this->is_downloading() || !$this->candelete) {
return;
Expand Down
2 changes: 1 addition & 1 deletion mod/quiz/report/responses/responsessettings_form.php
Expand Up @@ -38,7 +38,7 @@
*/
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'));
Expand Down
4 changes: 2 additions & 2 deletions mod/quiz/report/simpletest/testreportlib.php
Expand Up @@ -43,7 +43,7 @@
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;
Expand All @@ -67,7 +67,7 @@ function test_quiz_report_index_by_keys() {
$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;
Expand Down
9 changes: 5 additions & 4 deletions mod/quiz/report/statistics/simpletest/test_qstats.php
Expand Up @@ -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;
}
Expand All @@ -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');
Expand All @@ -84,7 +85,7 @@ function test_qstats() {
$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) {
Expand All @@ -95,7 +96,7 @@ function qstats_q_fields($fieldname, $values, $multiplier=1) {
}
}

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)) {
Expand All @@ -116,7 +117,7 @@ function get_fields_from_csv($line) {
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
Expand Down
2 changes: 1 addition & 1 deletion mod/quiz/report/statistics/statistics_form.php
Expand Up @@ -37,7 +37,7 @@
* @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'));
Expand Down
4 changes: 2 additions & 2 deletions mod/quiz/report/statistics/statistics_table.php
Expand Up @@ -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');
}

Expand All @@ -60,7 +60,7 @@ function __construct() {
* @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;

Expand Down

0 comments on commit c7df500

Please sign in to comment.