From c7df5006b9e3c7d0ae3a316572b57967e6a96f36 Mon Sep 17 00:00:00 2001 From: Tim Hunt Date: Wed, 23 Mar 2011 16:22:25 +0000 Subject: [PATCH] MDL-20636 Add lots of missing public/protected/private. --- mod/quiz/addrandomform.php | 4 +- mod/quiz/attemptlib.php | 18 +- .../backup_quiz_activity_task.class.php | 2 +- .../restore_quiz_activity_task.class.php | 8 +- mod/quiz/mod_form.php | 6 +- mod/quiz/override_form.php | 2 +- mod/quiz/report/attemptsreport.php | 6 +- mod/quiz/report/default.php | 11 +- .../report/grading/gradingsettings_form.php | 2 +- mod/quiz/report/grading/report.php | 4 +- .../report/overview/overviewsettings_form.php | 2 +- mod/quiz/report/overview/report.php | 2 +- mod/quiz/report/responses/report.php | 2 +- mod/quiz/report/responses/responses_table.php | 2 +- .../responses/responsessettings_form.php | 2 +- mod/quiz/report/simpletest/testreportlib.php | 4 +- .../statistics/simpletest/test_qstats.php | 9 +- .../report/statistics/statistics_form.php | 2 +- .../report/statistics/statistics_table.php | 4 +- mod/quiz/simpletest/testaccessrules.php | 28 +- mod/quiz/simpletest/testeditlib.php | 11 +- mod/quiz/simpletest/testlib.php | 6 +- mod/quiz/simpletest/testlocallib.php | 10 +- .../simpletest/testquizdisplayoptions.php | 2 +- question/behaviour/behaviourbase.php | 2 +- question/category_form.php | 2 +- question/editlib.php | 6 +- question/engine/lib.php | 4 +- .../engine/simpletest/testquestionbank.php | 2 +- question/export_form.php | 2 +- question/format.php | 74 +-- question/format/aiken/format.php | 10 +- question/format/blackboard/format.php | 534 +++++++++--------- question/format/gift/format.php | 28 +- question/format/multianswer/format.php | 4 +- question/format/qti_two/format.php | 26 +- question/format/xhtml/format.php | 250 ++++---- question/format/xml/format.php | 54 +- question/import_form.php | 2 +- question/move_form.php | 2 +- .../calculated/datasetdefinitions_form.php | 3 +- .../type/calculated/datasetitems_form.php | 2 +- .../type/calculated/edit_calculated_form.php | 2 +- .../edit_calculatedmulti_form.php | 2 +- .../edit_calculatedsimple_form.php | 2 +- .../restore_qtype_ddwtos_plugin.class.php | 2 +- question/type/ddwtos/edit_ddwtos_form.php | 2 +- question/type/ddwtos/questiontype.php | 2 +- question/type/edit_question_form.php | 4 +- question/type/essay/questiontype.php | 2 +- .../restore_qtype_gapselect_plugin.class.php | 2 +- question/type/gapselect/edit_form_base.php | 4 +- .../type/gapselect/edit_gapselect_form.php | 2 +- question/type/gapselect/questiontype.php | 4 +- question/type/gapselect/questiontypebase.php | 2 +- .../restore_qtype_match_plugin.class.php | 2 +- question/type/match/edit_match_form.php | 6 +- question/type/match/questiontype.php | 10 +- question/type/missingtype/questiontype.php | 2 +- .../multianswer/edit_multianswer_form.php | 2 +- ...restore_qtype_multichoice_plugin.class.php | 2 +- .../multichoice/edit_multichoice_form.php | 2 +- question/type/multichoice/question.php | 4 +- question/type/multichoice/questiontype.php | 4 +- question/type/multichoice/renderer.php | 12 +- .../type/numerical/edit_numerical_form.php | 18 +- question/type/numerical/questiontype.php | 4 +- .../numerical/simpletest/testquestiontype.php | 20 +- question/type/opaque/edit_engine_form.php | 2 +- question/type/opaque/edit_opaque_form.php | 10 +- question/type/opaque/questiontype.php | 8 +- .../type/opaque/simpletest/testlocallib.php | 2 +- ...ore_qtype_oumultiresponse_plugin.class.php | 2 +- .../edit_oumultiresponse_form.php | 4 +- question/type/oumultiresponse/question.php | 2 +- .../type/oumultiresponse/questiontype.php | 2 +- .../simpletest/testquestion.php | 4 +- question/type/questionbase.php | 2 +- question/type/questiontype.php | 12 +- question/type/random/edit_random_form.php | 2 +- question/type/random/questiontype.php | 4 +- .../randomsamatch/edit_randomsamatch_form.php | 6 +- question/type/rendererbase.php | 2 +- .../shortanswer/edit_shortanswer_form.php | 8 +- question/type/shortanswer/questiontype.php | 2 +- question/type/truefalse/questiontype.php | 8 +- 86 files changed, 663 insertions(+), 695 deletions(-) diff --git a/mod/quiz/addrandomform.php b/mod/quiz/addrandomform.php index 6315af3bcc72e..40c0c86548b1c 100644 --- a/mod/quiz/addrandomform.php +++ b/mod/quiz/addrandomform.php @@ -38,7 +38,7 @@ */ class quiz_add_random_form extends moodleform { - function definition() { + protected function definition() { global $CFG, $DB; $mform =& $this->_form; @@ -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']) == '') { diff --git a/mod/quiz/attemptlib.php b/mod/quiz/attemptlib.php index 7adc972805b80..0c830d1a907ff 100644 --- a/mod/quiz/attemptlib.php +++ b/mod/quiz/attemptlib.php @@ -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(); } @@ -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 @@ 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); @@ -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 @@ 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. @@ -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)); } @@ -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)); } @@ -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; diff --git a/mod/quiz/backup/moodle2/backup_quiz_activity_task.class.php b/mod/quiz/backup/moodle2/backup_quiz_activity_task.class.php index d065a472e9e6d..a461055c14e9f 100644 --- a/mod/quiz/backup/moodle2/backup_quiz_activity_task.class.php +++ b/mod/quiz/backup/moodle2/backup_quiz_activity_task.class.php @@ -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,"/"); diff --git a/mod/quiz/backup/moodle2/restore_quiz_activity_task.class.php b/mod/quiz/backup/moodle2/restore_quiz_activity_task.class.php index 4c36b7b778448..a264f10169fd2 100644 --- a/mod/quiz/backup/moodle2/restore_quiz_activity_task.class.php +++ b/mod/quiz/backup/moodle2/restore_quiz_activity_task.class.php @@ -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'); @@ -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'); @@ -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}'); @@ -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); diff --git a/mod/quiz/mod_form.php b/mod/quiz/mod_form.php index 1189445454854..111645ad705ab 100644 --- a/mod/quiz/mod_form.php +++ b/mod/quiz/mod_form.php @@ -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; @@ -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. } @@ -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. diff --git a/mod/quiz/override_form.php b/mod/quiz/override_form.php index fe846745e02c3..60303e270c624 100644 --- a/mod/quiz/override_form.php +++ b/mod/quiz/override_form.php @@ -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; diff --git a/mod/quiz/report/attemptsreport.php b/mod/quiz/report/attemptsreport.php index 802584060d81b..0f91cb49f6a8c 100644 --- a/mod/quiz/report/attemptsreport.php +++ b/mod/quiz/report/attemptsreport.php @@ -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 { @@ -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); @@ -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)); diff --git a/mod/quiz/report/default.php b/mod/quiz/report/default.php index c918c81a95e79..c845e4c0210fd 100644 --- a/mod/quiz/report/default.php +++ b/mod/quiz/report/default.php @@ -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); } } diff --git a/mod/quiz/report/grading/gradingsettings_form.php b/mod/quiz/report/grading/gradingsettings_form.php index 14b3f66cdc606..06930fe69083f 100644 --- a/mod/quiz/report/grading/gradingsettings_form.php +++ b/mod/quiz/report/grading/gradingsettings_form.php @@ -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')); diff --git a/mod/quiz/report/grading/report.php b/mod/quiz/report/grading/report.php index f0feb6642c1b0..6fe4a1e02174e 100644 --- a/mod/quiz/report/grading/report.php +++ b/mod/quiz/report/grading/report.php @@ -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 @@ 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(); diff --git a/mod/quiz/report/overview/overviewsettings_form.php b/mod/quiz/report/overview/overviewsettings_form.php index 9dff2e56e7f6d..b64b349151c18 100644 --- a/mod/quiz/report/overview/overviewsettings_form.php +++ b/mod/quiz/report/overview/overviewsettings_form.php @@ -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')); diff --git a/mod/quiz/report/overview/report.php b/mod/quiz/report/overview/report.php index 008f018a1b5ff..da4ceeaec032b 100644 --- a/mod/quiz/report/overview/report.php +++ b/mod/quiz/report/overview/report.php @@ -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); diff --git a/mod/quiz/report/responses/report.php b/mod/quiz/report/responses/report.php index 214b7b0f13870..d48276ee08410 100644 --- a/mod/quiz/report/responses/report.php +++ b/mod/quiz/report/responses/report.php @@ -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); diff --git a/mod/quiz/report/responses/responses_table.php b/mod/quiz/report/responses/responses_table.php index 6397fcce4bc7f..a2901e818f740 100644 --- a/mod/quiz/report/responses/responses_table.php +++ b/mod/quiz/report/responses/responses_table.php @@ -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; diff --git a/mod/quiz/report/responses/responsessettings_form.php b/mod/quiz/report/responses/responsessettings_form.php index b36c3a8e5125f..fe4447e38ef0b 100644 --- a/mod/quiz/report/responses/responsessettings_form.php +++ b/mod/quiz/report/responses/responsessettings_form.php @@ -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')); diff --git a/mod/quiz/report/simpletest/testreportlib.php b/mod/quiz/report/simpletest/testreportlib.php index cc9025fe8b071..cf07620d24742 100644 --- a/mod/quiz/report/simpletest/testreportlib.php +++ b/mod/quiz/report/simpletest/testreportlib.php @@ -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; @@ -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; diff --git a/mod/quiz/report/statistics/simpletest/test_qstats.php b/mod/quiz/report/statistics/simpletest/test_qstats.php index ccd454972c15e..32abbedf966ee 100644 --- a/mod/quiz/report/statistics/simpletest/test_qstats.php +++ b/mod/quiz/report/statistics/simpletest/test_qstats.php @@ -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 @@ 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) { @@ -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)) { @@ -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 diff --git a/mod/quiz/report/statistics/statistics_form.php b/mod/quiz/report/statistics/statistics_form.php index 8919b1b8f0680..21b70ee067c77 100644 --- a/mod/quiz/report/statistics/statistics_form.php +++ b/mod/quiz/report/statistics/statistics_form.php @@ -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')); diff --git a/mod/quiz/report/statistics/statistics_table.php b/mod/quiz/report/statistics/statistics_table.php index ade4d76be99bf..5dc1159d7f14f 100644 --- a/mod/quiz/report/statistics/statistics_table.php +++ b/mod/quiz/report/statistics/statistics_table.php @@ -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 @@ 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; diff --git a/mod/quiz/simpletest/testaccessrules.php b/mod/quiz/simpletest/testaccessrules.php index 05be3eeaf4d42..9ce53752f316d 100644 --- a/mod/quiz/simpletest/testaccessrules.php +++ b/mod/quiz/simpletest/testaccessrules.php @@ -38,7 +38,7 @@ */ 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 @@ function test_num_attempts_access_rule() { $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 @@ function test_ipaddress_access_rule() { $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 @@ function test_time_limit_access_rule() { * @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 @@ function test_no_dates() { $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 @@ function test_start_date() { $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 @@ function test_close_date() { $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 @@ function test_both_dates() { * @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 @@ function test_just_first_delay() { $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 @@ function test_just_second_delay() { $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 @@ function test_just_both_delays() { $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 @@ function test_with_close_date() { $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 @@ function test_time_limit_and_overdue() { * @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 @@ function test_password_access_rule() { 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 = ''; diff --git a/mod/quiz/simpletest/testeditlib.php b/mod/quiz/simpletest/testeditlib.php index 08e9ca451bd60..dc9d447c14341 100644 --- a/mod/quiz/simpletest/testeditlib.php +++ b/mod/quiz/simpletest/testeditlib.php @@ -38,7 +38,7 @@ */ class quiz_editlib_test extends UnitTestCase { public static $includecoverage = array('mod/quiz/editlib.php'); - function test_quiz_move_question_up() { + public function test_quiz_move_question_up() { $this->assertEqual(quiz_move_question_up('0', 123), '0'); $this->assertEqual(quiz_move_question_up('1,2,0', 1), '1,2,0'); $this->assertEqual(quiz_move_question_up('1,2,0', 0), '1,2,0'); @@ -47,7 +47,7 @@ function test_quiz_move_question_up() { $this->assertEqual(quiz_move_question_up('1,2,3,0,4,0', 4), '1,2,3,4,0,0'); } - function test_quiz_move_question_down() { + public function test_quiz_move_question_down() { $this->assertEqual(quiz_move_question_down('0', 123), '0'); $this->assertEqual(quiz_move_question_down('1,2,0', 2), '1,2,0'); $this->assertEqual(quiz_move_question_down('1,2,0', 0), '1,2,0'); @@ -56,7 +56,7 @@ function test_quiz_move_question_down() { $this->assertEqual(quiz_move_question_down('1,0,2,3,0,4,0', 1), '0,1,2,3,0,4,0'); } - function test_quiz_delete_empty_page() { + public function test_quiz_delete_empty_page() { $this->assertEqual(quiz_delete_empty_page('0', 0), '0'); $this->assertEqual(quiz_delete_empty_page('1,2,0', 2), '1,2,0'); $this->assertEqual(quiz_delete_empty_page('0,1,2,0', -1), '1,2,0'); @@ -69,14 +69,14 @@ function test_quiz_delete_empty_page() { $this->assertEqual(quiz_delete_empty_page('0,0,1,2,0', 0), '0,1,2,0'); } - function test_quiz_add_page_break_after() { + public function test_quiz_add_page_break_after() { $this->assertEqual(quiz_add_page_break_after('0', 1), '0'); $this->assertEqual(quiz_add_page_break_after('1,2,0', 1), '1,0,2,0'); $this->assertEqual(quiz_add_page_break_after('1,2,0', 2), '1,2,0,0'); $this->assertEqual(quiz_add_page_break_after('1,2,0', 0), '1,2,0'); } - function test_quiz_add_page_break_at() { + public function test_quiz_add_page_break_at() { $this->assertEqual(quiz_add_page_break_at('0', 0), '0,0'); $this->assertEqual(quiz_add_page_break_at('1,2,0', 0), '0,1,2,0'); $this->assertEqual(quiz_add_page_break_at('1,2,0', 1), '1,0,2,0'); @@ -84,4 +84,3 @@ function test_quiz_add_page_break_at() { $this->assertEqual(quiz_add_page_break_at('1,2,0', 3), '1,2,0'); } } - diff --git a/mod/quiz/simpletest/testlib.php b/mod/quiz/simpletest/testlib.php index 422fa5b280e11..ff5ef88bea3cb 100644 --- a/mod/quiz/simpletest/testlib.php +++ b/mod/quiz/simpletest/testlib.php @@ -36,7 +36,7 @@ */ class quiz_lib_test extends UnitTestCase { public static $includecoverage = array('mod/quiz/lib.php'); - function test_quiz_has_grades() { + public function test_quiz_has_grades() { $quiz = new stdClass(); $quiz->grade = '100.0000'; $quiz->sumgrades = '100.0000'; @@ -49,7 +49,7 @@ function test_quiz_has_grades() { $this->assertFalse(quiz_has_grades($quiz)); } - function test_quiz_format_grade() { + public function test_quiz_format_grade() { $quiz = new stdClass(); $quiz->decimalpoints = 2; $this->assertEqual(quiz_format_grade($quiz, 0.12345678), format_float(0.12, 2)); @@ -59,7 +59,7 @@ function test_quiz_format_grade() { $this->assertEqual(quiz_format_grade($quiz, 0.12345678), '0'); } - function test_quiz_format_question_grade() { + public function test_quiz_format_question_grade() { $quiz = new stdClass(); $quiz->decimalpoints = 2; $quiz->questiondecimalpoints = 2; diff --git a/mod/quiz/simpletest/testlocallib.php b/mod/quiz/simpletest/testlocallib.php index f04b8e17a487c..a81954954bc84 100644 --- a/mod/quiz/simpletest/testlocallib.php +++ b/mod/quiz/simpletest/testlocallib.php @@ -38,7 +38,7 @@ */ class quiz_locallib_test extends UnitTestCase { public static $includecoverage = array('mod/quiz/locallib.php'); - function test_quiz_questions_in_quiz() { + public function test_quiz_questions_in_quiz() { $this->assertEqual(quiz_questions_in_quiz(''), ''); $this->assertEqual(quiz_questions_in_quiz('0'), ''); $this->assertEqual(quiz_questions_in_quiz('0,0'), ''); @@ -49,7 +49,7 @@ function test_quiz_questions_in_quiz() { $this->assertEqual(quiz_questions_in_quiz('0,1,0,0,2,0'), '1,2'); } - function test_quiz_number_of_pages() { + public function test_quiz_number_of_pages() { $this->assertEqual(quiz_number_of_pages('0'), 1); $this->assertEqual(quiz_number_of_pages('0,0'), 2); $this->assertEqual(quiz_number_of_pages('0,0,0'), 3); @@ -61,7 +61,7 @@ function test_quiz_number_of_pages() { $this->assertEqual(quiz_number_of_pages('0,1,0,0,2,0'), 4); } - function test_quiz_number_of_questions_in_quiz() { + public function test_quiz_number_of_questions_in_quiz() { $this->assertEqual(quiz_number_of_questions_in_quiz('0'), 0); $this->assertEqual(quiz_number_of_questions_in_quiz('0,0'), 0); $this->assertEqual(quiz_number_of_questions_in_quiz('0,0,0'), 0); @@ -74,7 +74,7 @@ function test_quiz_number_of_questions_in_quiz() { $this->assertEqual(quiz_number_of_questions_in_quiz('10,,0,0'), 1); } - function test_quiz_clean_layout() { + public function test_quiz_clean_layout() { // Without stripping empty pages. $this->assertEqual(quiz_clean_layout(',,1,,,2,,'), '1,2,0'); $this->assertEqual(quiz_clean_layout(''), '0'); @@ -97,7 +97,7 @@ function test_quiz_clean_layout() { $this->assertEqual(quiz_clean_layout('0,1,0,0,2,0', true), '1,0,2,0'); } - function test_quiz_rescale_grade() { + public function test_quiz_rescale_grade() { $quiz = new stdClass(); $quiz->decimalpoints = 2; $quiz->questiondecimalpoints = 3; diff --git a/mod/quiz/simpletest/testquizdisplayoptions.php b/mod/quiz/simpletest/testquizdisplayoptions.php index 982746013bb34..f17808d63b7e7 100644 --- a/mod/quiz/simpletest/testquizdisplayoptions.php +++ b/mod/quiz/simpletest/testquizdisplayoptions.php @@ -37,7 +37,7 @@ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class mod_quiz_display_options_test extends UnitTestCase { - function test_num_attempts_access_rule() { + public function test_num_attempts_access_rule() { $quiz = new stdClass(); $quiz->decimalpoints = 2; $quiz->questiondecimalpoints = -1; diff --git a/question/behaviour/behaviourbase.php b/question/behaviour/behaviourbase.php index 47b6292b4a971..153038d9db459 100644 --- a/question/behaviour/behaviourbase.php +++ b/question/behaviour/behaviourbase.php @@ -322,7 +322,7 @@ public function get_state_string($showcorrectness) { return $this->qa->get_state()->default_string($showcorrectness); } - abstract public function summarise_action(question_attempt_step $step); + public abstract function summarise_action(question_attempt_step $step); /** * Initialise the first step in a question attempt when a new diff --git a/question/category_form.php b/question/category_form.php index ceb7c79948644..47248eea3252d 100644 --- a/question/category_form.php +++ b/question/category_form.php @@ -38,7 +38,7 @@ */ class question_category_edit_form extends moodleform { - function definition() { + protected function definition() { global $CFG, $DB; $mform = $this->_form; diff --git a/question/editlib.php b/question/editlib.php index cae3f0e5a0348..5a3aae97f5c99 100644 --- a/question/editlib.php +++ b/question/editlib.php @@ -193,7 +193,7 @@ public function display_header() { * @param object $question the row from the $question table, augmented with extra information. * @param string $rowclasses CSS class names that should be applied to this row of output. */ - abstract protected function get_title(); + protected abstract function get_title(); /** * @return string a fuller version of the name. Use this when get_title() returns @@ -277,7 +277,7 @@ protected function get_classes() { * @return string internal name for this column. Used as a CSS class name, * and to store information about the current sort. Must match PARAM_ALPHA. */ - abstract public function get_name(); + public abstract function get_name(); /** * @return array any extra class names you would like applied to every cell in this column. @@ -291,7 +291,7 @@ public function get_extra_classes() { * @param object $question the row from the $question table, augmented with extra information. * @param string $rowclasses CSS class names that should be applied to this row of output. */ - abstract protected function display_content($question, $rowclasses); + protected abstract function display_content($question, $rowclasses); protected function display_end($question, $rowclasses) { echo "\n"; diff --git a/question/engine/lib.php b/question/engine/lib.php index da19cfc369899..bd6fa348ad781 100644 --- a/question/engine/lib.php +++ b/question/engine/lib.php @@ -601,7 +601,7 @@ public static function initialise_js() { * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class question_out_of_sequence_exception extends moodle_exception { - function __construct($qubaid, $slot, $postdata) { + public function __construct($qubaid, $slot, $postdata) { if ($postdata == null) { $postdata = data_submitted(); } @@ -1624,7 +1624,7 @@ public function get_full_step_iterator() { * @return question_attempt_reverse_step_iterator for iterating over the steps in * this attempt, in reverse order. */ - public function get_reverse_step_iterator() { + public function get_reverse_step_iterator() { return new question_attempt_reverse_step_iterator($this); } diff --git a/question/engine/simpletest/testquestionbank.php b/question/engine/simpletest/testquestionbank.php index 5043c3f92de94..e51648810c6bd 100644 --- a/question/engine/simpletest/testquestionbank.php +++ b/question/engine/simpletest/testquestionbank.php @@ -44,7 +44,7 @@ public function setUp() { public function tearDown() { } - function test_sort_qtype_array() { + public function test_sort_qtype_array() { $config = new stdClass(); $config->multichoice_sortorder = '1'; $config->calculated_sortorder = '2'; diff --git a/question/export_form.php b/question/export_form.php index 87aa703e18ef5..e1a6aa18ef550 100644 --- a/question/export_form.php +++ b/question/export_form.php @@ -38,7 +38,7 @@ */ class question_export_form extends moodleform { - function definition() { + protected function definition() { $mform = $this->_form; $defaultcategory = $this->_customdata['defaultcategory']; diff --git a/question/format.php b/question/format.php index 45622cf5b3092..62c0596612cae 100644 --- a/question/format.php +++ b/question/format.php @@ -59,17 +59,17 @@ class qformat_default { // override to return true if implemented /** @return bool whether this plugin provides import functionality. */ - function provide_import() { + public function provide_import() { return false; } /** @return bool whether this plugin provides export functionality. */ - function provide_export() { + public function provide_export() { return false; } /** The string mime-type of the files that this plugin reads or writes. */ - function mime_type() { + public function mime_type() { return mimeinfo('type', $this->export_file_extension()); } @@ -77,7 +77,7 @@ function mime_type() { * @return string the file extension (including .) that is normally used for * files handled by this plugin. */ - function export_file_extension() { + public function export_file_extension() { return '.txt'; } @@ -87,7 +87,7 @@ function export_file_extension() { * set the category * @param object category the category object */ - function setCategory($category) { + public function setCategory($category) { if (count($this->questions)) { debugging('You shouldn\'t call setCategory after setQuestions'); } @@ -100,7 +100,7 @@ function setCategory($category) { * Only used for question export. * @param array of question objects */ - function setQuestions($questions) { + public function setQuestions($questions) { if ($this->category !== null) { debugging('You shouldn\'t call setQuestions after setCategory'); } @@ -111,7 +111,7 @@ function setQuestions($questions) { * set the course class variable * @param course object Moodle course variable */ - function setCourse($course) { + public function setCourse($course) { $this->course = $course; } @@ -119,7 +119,7 @@ function setCourse($course) { * set an array of contexts. * @param array $contexts Moodle course variable */ - function setContexts($contexts) { + public function setContexts($contexts) { $this->contexts = $contexts; $this->translator = new context_to_string_translator($this->contexts); } @@ -128,7 +128,7 @@ function setContexts($contexts) { * set the filename * @param string filename name of file to import/export */ - function setFilename($filename) { + public function setFilename($filename) { $this->filename = $filename; } @@ -137,7 +137,7 @@ function setFilename($filename) { * (this is what the user typed, regardless of wha happened next) * @param string realfilename name of file as typed by user */ - function setRealfilename($realfilename) { + public function setRealfilename($realfilename) { $this->realfilename = $realfilename; } @@ -145,7 +145,7 @@ function setRealfilename($realfilename) { * set matchgrades * @param string matchgrades error or nearest for grades */ - function setMatchgrades($matchgrades) { + public function setMatchgrades($matchgrades) { $this->matchgrades = $matchgrades; } @@ -153,7 +153,7 @@ function setMatchgrades($matchgrades) { * set catfromfile * @param bool catfromfile allow categories embedded in import file */ - function setCatfromfile($catfromfile) { + public function setCatfromfile($catfromfile) { $this->catfromfile = $catfromfile; } @@ -161,7 +161,7 @@ function setCatfromfile($catfromfile) { * set contextfromfile * @param bool $contextfromfile allow contexts embedded in import file */ - function setContextfromfile($contextfromfile) { + public function setContextfromfile($contextfromfile) { $this->contextfromfile = $contextfromfile; } @@ -169,7 +169,7 @@ function setContextfromfile($contextfromfile) { * set cattofile * @param bool cattofile exports categories within export file */ - function setCattofile($cattofile) { + public function setCattofile($cattofile) { $this->cattofile = $cattofile; } @@ -177,7 +177,7 @@ function setCattofile($cattofile) { * set contexttofile * @param bool cattofile exports categories within export file */ - function setContexttofile($contexttofile) { + public function setContexttofile($contexttofile) { $this->contexttofile = $contexttofile; } @@ -185,7 +185,7 @@ function setContexttofile($contexttofile) { * set stoponerror * @param bool stoponerror stops database write if any errors reported */ - function setStoponerror($stoponerror) { + public function setStoponerror($stoponerror) { $this->stoponerror = $stoponerror; } @@ -193,7 +193,7 @@ function setStoponerror($stoponerror) { * @param bool $canaccess Whether the current use can access the backup data folder. Determines * where export files are saved. */ - function set_can_access_backupdata($canaccess) { + public function set_can_access_backupdata($canaccess) { $this->canaccessbackupdata = $canaccess; } @@ -204,7 +204,7 @@ function set_can_access_backupdata($canaccess) { /** * Handle parsing error */ - function error($message, $text='', $questionname='') { + protected function error($message, $text='', $questionname='') { $importerrorquestion = get_string('importerrorquestion', 'question'); echo "
\n"; @@ -228,7 +228,7 @@ function error($message, $text='', $questionname='') { * @param qtypehint hint about a question type from format * @return object question object suitable for save_options() or false if cannot handle */ - function try_importing_using_qtypes($data, $question = null, $extra = null, + public function try_importing_using_qtypes($data, $question = null, $extra = null, $qtypehint = '') { // work out what format we are using @@ -262,7 +262,7 @@ function try_importing_using_qtypes($data, $question = null, $extra = null, * Perform any required pre-processing * @return bool success */ - function importpreprocess() { + protected function importpreprocess() { return true; } @@ -272,7 +272,7 @@ function importpreprocess() { * @param object $category * @return bool success */ - function importprocess($category) { + protected function importprocess($category) { global $USER, $CFG, $DB, $OUTPUT; $context = $category->context; @@ -423,7 +423,7 @@ function importprocess($category) { * @return int The count. * */ - function count_questions($questions) { + protected function count_questions($questions) { $count = 0; if (!is_array($questions)) { return $count; @@ -448,7 +448,7 @@ function count_questions($questions) { * @param int courseid course to search for categories * @return mixed category object or null if fails */ - function create_category_path($catpath) { + protected function create_category_path($catpath) { global $DB; $catnames = $this->split_category_path($catpath); $parent = 0; @@ -497,7 +497,7 @@ function create_category_path($catpath) { * @param string filename name of file * @return mixed contents array or false on failure */ - function readdata($filename) { + protected function readdata($filename) { if (is_readable($filename)) { $filearray = file($filename); @@ -524,7 +524,7 @@ function readdata($filename) { * @param object $context * @return array array of question objects */ - function readquestions($lines, $context) { + protected function readquestions($lines, $context) { $questions = array(); $currentquestion = array(); @@ -559,7 +559,7 @@ function readquestions($lines, $context) { * This should not be overridden. * @return object default question */ - function defaultquestion() { + protected function defaultquestion() { global $CFG; static $defaultshuffleanswers = null; if (is_null($defaultshuffleanswers)) { @@ -598,7 +598,7 @@ function defaultquestion() { * @param $lines mixed data that represents question * @return object question object */ - function readquestion($lines) { + protected function readquestion($lines) { $formatnotimplemented = get_string('formatnotimplemented', 'question'); echo "

$formatnotimplemented

"; @@ -610,7 +610,7 @@ function readquestion($lines) { * Override if any post-processing is required * @return bool success */ - function importpostprocess() { + protected function importpostprocess() { return true; } @@ -627,7 +627,7 @@ function importpostprocess() { * @param extra mixed any addition format specific data needed * @return string the data to append to export or false if error (or unhandled) */ - function try_exporting_using_qtypes($name, $question, $extra=null) { + protected function try_exporting_using_qtypes($name, $question, $extra=null) { // work out the name of format in use $formatname = substr(get_class($this), strlen('qformat_')); $methodname = "export_to_$formatname"; @@ -643,7 +643,7 @@ function try_exporting_using_qtypes($name, $question, $extra=null) { * Do any pre-processing that may be required * @param bool success */ - function exportpreprocess() { + public function exportpreprocess() { return true; } @@ -654,7 +654,7 @@ function exportpreprocess() { * @param string output text * @param string processed output text */ - function presave_process($content) { + protected function presave_process($content) { return $content; } @@ -663,7 +663,7 @@ function presave_process($content) { * For most types this should not need to be overrided * @return stored_file */ - function exportprocess() { + public function exportprocess() { global $CFG, $OUTPUT, $DB, $USER; // get the questions (from database) in this category @@ -746,7 +746,7 @@ function exportprocess() { * @param int id the id of the most nested catgory * @return string the path */ - function get_category_path($id, $includecontext = true) { + protected function get_category_path($id, $includecontext = true) { global $DB; if (!$category = $DB->get_record('question_categories',array('id' =>$id))) { @@ -820,7 +820,7 @@ protected function split_category_path($path) { * Do an post-processing that may be required * @return bool success */ - function exportpostprocess() { + protected function exportpostprocess() { return true; } @@ -831,7 +831,7 @@ function exportpostprocess() { * @param object question question object * @return mixed question export text or null if not implemented */ - function writequestion($question) { + protected function writequestion($question) { // if not overidden, then this is an error. $formatnotimplemented = get_string('formatnotimplemented', 'question'); echo "

$formatnotimplemented

"; @@ -842,7 +842,7 @@ function writequestion($question) { * Convert the question text to plain text, so it can safely be displayed * during import to let the user see roughly what is going on. */ - function format_question_text($question) { + protected function format_question_text($question) { global $DB; $formatoptions = new stdClass(); $formatoptions->noclean = true; @@ -856,7 +856,7 @@ function format_question_text($question) { * @param string encoding method * @return string $string */ - function writefiles($files, $encoding='base64') { + protected function writefiles($files, $encoding='base64') { if (empty($files)) { return ''; } diff --git a/question/format/aiken/format.php b/question/format/aiken/format.php index afbf29223d3fc..ea603941e68b8 100644 --- a/question/format/aiken/format.php +++ b/question/format/aiken/format.php @@ -55,11 +55,11 @@ */ class qformat_aiken extends qformat_default { - function provide_import() { - return true; - } + public function provide_import() { + return true; + } - function readquestions($lines) { + public function readquestions($lines) { $questions = array(); $question = $this->defaultquestion(); $endchar = chr(13); @@ -107,7 +107,7 @@ function readquestions($lines) { return $questions; } - function readquestion($lines) { + public function readquestion($lines) { //this is no longer needed but might still be called by default.php return; } diff --git a/question/format/blackboard/format.php b/question/format/blackboard/format.php index 1b707818b896c..98e7644acb091 100644 --- a/question/format/blackboard/format.php +++ b/question/format/blackboard/format.php @@ -38,379 +38,371 @@ */ class qformat_blackboard extends qformat_default { - function provide_import() { + public function provide_import() { return true; } - function readquestions ($lines) { - /// Parses an array of lines into an array of questions, - /// where each item is a question object as defined by - /// readquestion(). + function readquestions ($lines) { + /// Parses an array of lines into an array of questions, + /// where each item is a question object as defined by + /// readquestion(). - $text = implode($lines, " "); - $xml = xmlize($text, 0); + $text = implode($lines, " "); + $xml = xmlize($text, 0); - $questions = array(); + $questions = array(); - $this->process_tf($xml, $questions); - $this->process_mc($xml, $questions); - $this->process_ma($xml, $questions); - $this->process_fib($xml, $questions); - $this->process_matching($xml, $questions); - $this->process_essay($xml, $questions); + $this->process_tf($xml, $questions); + $this->process_mc($xml, $questions); + $this->process_ma($xml, $questions); + $this->process_fib($xml, $questions); + $this->process_matching($xml, $questions); + $this->process_essay($xml, $questions); - return $questions; -} + return $questions; + } //---------------------------------------- // Process Essay Questions //---------------------------------------- -function process_essay($xml, &$questions ) { + function process_essay($xml, &$questions ) { - if (isset($xml["POOL"]["#"]["QUESTION_ESSAY"])) { - $essayquestions = $xml["POOL"]["#"]["QUESTION_ESSAY"]; - } - else { - return; - } - - foreach ($essayquestions as $essayquestion) { + if (isset($xml["POOL"]["#"]["QUESTION_ESSAY"])) { + $essayquestions = $xml["POOL"]["#"]["QUESTION_ESSAY"]; + } + else { + return; + } - $question = $this->defaultquestion(); + foreach ($essayquestions as $essayquestion) { - $question->qtype = ESSAY; + $question = $this->defaultquestion(); - // determine if the question is already escaped html - $ishtml = $essayquestion["#"]["BODY"][0]["#"]["FLAGS"][0]["#"]["ISHTML"][0]["@"]["value"]; + $question->qtype = ESSAY; - // put questiontext in question object - if ($ishtml) { - $question->questiontext = html_entity_decode(trim($essayquestion["#"]["BODY"][0]["#"]["TEXT"][0]["#"])); - } + // determine if the question is already escaped html + $ishtml = $essayquestion["#"]["BODY"][0]["#"]["FLAGS"][0]["#"]["ISHTML"][0]["@"]["value"]; - // put name in question object - $question->name = substr($question->questiontext, 0, 254); - $question->answer = ''; - $question->feedback = ''; - $question->fraction = 0; + // put questiontext in question object + if ($ishtml) { + $question->questiontext = html_entity_decode(trim($essayquestion["#"]["BODY"][0]["#"]["TEXT"][0]["#"])); + } - $questions[] = $question; - } -} + // put name in question object + $question->name = substr($question->questiontext, 0, 254); + $question->answer = ''; + $question->feedback = ''; + $question->fraction = 0; -//---------------------------------------- -// Process True / False Questions -//---------------------------------------- -function process_tf($xml, &$questions) { - - if (isset($xml["POOL"]["#"]["QUESTION_TRUEFALSE"])) { - $tfquestions = $xml["POOL"]["#"]["QUESTION_TRUEFALSE"]; - } - else { - return; + $questions[] = $question; + } } - for ($i = 0; $i < sizeof ($tfquestions); $i++) { + //---------------------------------------- + // Process True / False Questions + //---------------------------------------- + function process_tf($xml, &$questions) { - $question = $this->defaultquestion(); + if (isset($xml["POOL"]["#"]["QUESTION_TRUEFALSE"])) { + $tfquestions = $xml["POOL"]["#"]["QUESTION_TRUEFALSE"]; + } + else { + return; + } - $question->qtype = TRUEFALSE; - $question->single = 1; // Only one answer is allowed + for ($i = 0; $i < sizeof ($tfquestions); $i++) { - $thisquestion = $tfquestions[$i]; + $question = $this->defaultquestion(); - // determine if the question is already escaped html - $ishtml = $thisquestion["#"]["BODY"][0]["#"]["FLAGS"][0]["#"]["ISHTML"][0]["@"]["value"]; + $question->qtype = TRUEFALSE; + $question->single = 1; // Only one answer is allowed - // put questiontext in question object - if ($ishtml) { - $question->questiontext = html_entity_decode(trim($thisquestion["#"]["BODY"][0]["#"]["TEXT"][0]["#"]),ENT_QUOTES,'UTF-8'); - } - $question->questiontext = $question->questiontext; - // put name in question object - $question->name = shorten_text($question->questiontext, 254); + $thisquestion = $tfquestions[$i]; - $choices = $thisquestion["#"]["ANSWER"]; + // determine if the question is already escaped html + $ishtml = $thisquestion["#"]["BODY"][0]["#"]["FLAGS"][0]["#"]["ISHTML"][0]["@"]["value"]; - $correct_answer = $thisquestion["#"]["GRADABLE"][0]["#"]["CORRECTANSWER"][0]["@"]["answer_id"]; + // put questiontext in question object + if ($ishtml) { + $question->questiontext = html_entity_decode(trim($thisquestion["#"]["BODY"][0]["#"]["TEXT"][0]["#"]),ENT_QUOTES,'UTF-8'); + } + $question->questiontext = $question->questiontext; + // put name in question object + $question->name = shorten_text($question->questiontext, 254); - // first choice is true, second is false. - $id = $choices[0]["@"]["id"]; + $choices = $thisquestion["#"]["ANSWER"]; - if (strcmp($id, $correct_answer) == 0) { // true is correct - $question->answer = 1; - $question->feedbacktrue = trim(@$thisquestion["#"]["GRADABLE"][0]["#"]["FEEDBACK_WHEN_CORRECT"][0]["#"]); - $question->feedbackfalse = trim(@$thisquestion["#"]["GRADABLE"][0]["#"]["FEEDBACK_WHEN_INCORRECT"][0]["#"]); - } else { // false is correct - $question->answer = 0; - $question->feedbacktrue = trim(@$thisquestion["#"]["GRADABLE"][0]["#"]["FEEDBACK_WHEN_INCORRECT"][0]["#"]); - $question->feedbackfalse = trim(@$thisquestion["#"]["GRADABLE"][0]["#"]["FEEDBACK_WHEN_CORRECT"][0]["#"]); - } - $question->correctanswer = $question->answer; - $questions[] = $question; - } -} + $correct_answer = $thisquestion["#"]["GRADABLE"][0]["#"]["CORRECTANSWER"][0]["@"]["answer_id"]; -//---------------------------------------- -// Process Multiple Choice Questions -//---------------------------------------- -function process_mc($xml, &$questions) { + // first choice is true, second is false. + $id = $choices[0]["@"]["id"]; - if (isset($xml["POOL"]["#"]["QUESTION_MULTIPLECHOICE"])) { - $mcquestions = $xml["POOL"]["#"]["QUESTION_MULTIPLECHOICE"]; - } - else { - return; + if (strcmp($id, $correct_answer) == 0) { // true is correct + $question->answer = 1; + $question->feedbacktrue = trim(@$thisquestion["#"]["GRADABLE"][0]["#"]["FEEDBACK_WHEN_CORRECT"][0]["#"]); + $question->feedbackfalse = trim(@$thisquestion["#"]["GRADABLE"][0]["#"]["FEEDBACK_WHEN_INCORRECT"][0]["#"]); + } else { // false is correct + $question->answer = 0; + $question->feedbacktrue = trim(@$thisquestion["#"]["GRADABLE"][0]["#"]["FEEDBACK_WHEN_INCORRECT"][0]["#"]); + $question->feedbackfalse = trim(@$thisquestion["#"]["GRADABLE"][0]["#"]["FEEDBACK_WHEN_CORRECT"][0]["#"]); + } + $question->correctanswer = $question->answer; + $questions[] = $question; + } } - for ($i = 0; $i < sizeof ($mcquestions); $i++) { - - $question = $this->defaultquestion(); + //---------------------------------------- + // Process Multiple Choice Questions + //---------------------------------------- + function process_mc($xml, &$questions) { - $question->qtype = MULTICHOICE; - $question->single = 1; // Only one answer is allowed + if (isset($xml["POOL"]["#"]["QUESTION_MULTIPLECHOICE"])) { + $mcquestions = $xml["POOL"]["#"]["QUESTION_MULTIPLECHOICE"]; + } + else { + return; + } - $thisquestion = $mcquestions[$i]; + for ($i = 0; $i < sizeof ($mcquestions); $i++) { - // determine if the question is already escaped html - $ishtml = $thisquestion["#"]["BODY"][0]["#"]["FLAGS"][0]["#"]["ISHTML"][0]["@"]["value"]; + $question = $this->defaultquestion(); - // put questiontext in question object - if ($ishtml) { - $question->questiontext = html_entity_decode(trim($thisquestion["#"]["BODY"][0]["#"]["TEXT"][0]["#"]),ENT_QUOTES,'UTF-8'); - } - $question->questiontext = $question->questiontext; + $question->qtype = MULTICHOICE; + $question->single = 1; // Only one answer is allowed - // put name of question in question object, careful of length - $question->name = shorten_text($question->questiontext, 254); + $thisquestion = $mcquestions[$i]; - $choices = $thisquestion["#"]["ANSWER"]; - for ($j = 0; $j < sizeof ($choices); $j++) { + // determine if the question is already escaped html + $ishtml = $thisquestion["#"]["BODY"][0]["#"]["FLAGS"][0]["#"]["ISHTML"][0]["@"]["value"]; - $choice = trim($choices[$j]["#"]["TEXT"][0]["#"]); - // put this choice in the question object. + // put questiontext in question object if ($ishtml) { - $question->answer[$j] = html_entity_decode($choice,ENT_QUOTES,'UTF-8'); + $question->questiontext = html_entity_decode(trim($thisquestion["#"]["BODY"][0]["#"]["TEXT"][0]["#"]),ENT_QUOTES,'UTF-8'); } - $question->answer[$j] = $question->answer[$j]; + $question->questiontext = $question->questiontext; + + // put name of question in question object, careful of length + $question->name = shorten_text($question->questiontext, 254); - $id = $choices[$j]["@"]["id"]; - $correct_answer_id = $thisquestion["#"]["GRADABLE"][0]["#"]["CORRECTANSWER"][0]["@"]["answer_id"]; - // if choice is the answer, give 100%, otherwise give 0% - if (strcmp ($id, $correct_answer_id) == 0) { - $question->fraction[$j] = 1; + $choices = $thisquestion["#"]["ANSWER"]; + for ($j = 0; $j < sizeof ($choices); $j++) { + + $choice = trim($choices[$j]["#"]["TEXT"][0]["#"]); + // put this choice in the question object. if ($ishtml) { - $question->feedback[$j] = html_entity_decode(trim(@$thisquestion["#"]["GRADABLE"][0]["#"]["FEEDBACK_WHEN_CORRECT"][0]["#"]),ENT_QUOTES,'UTF-8'); + $question->answer[$j] = html_entity_decode($choice,ENT_QUOTES,'UTF-8'); } - $question->feedback[$j] = $question->feedback[$j]; - } else { - $question->fraction[$j] = 0; - if ($ishtml) { - $question->feedback[$j] = html_entity_decode(trim(@$thisquestion["#"]["GRADABLE"][0]["#"]["FEEDBACK_WHEN_INCORRECT"][0]["#"]),ENT_QUOTES,'UTF-8'); + $question->answer[$j] = $question->answer[$j]; + + $id = $choices[$j]["@"]["id"]; + $correct_answer_id = $thisquestion["#"]["GRADABLE"][0]["#"]["CORRECTANSWER"][0]["@"]["answer_id"]; + // if choice is the answer, give 100%, otherwise give 0% + if (strcmp ($id, $correct_answer_id) == 0) { + $question->fraction[$j] = 1; + if ($ishtml) { + $question->feedback[$j] = html_entity_decode(trim(@$thisquestion["#"]["GRADABLE"][0]["#"]["FEEDBACK_WHEN_CORRECT"][0]["#"]),ENT_QUOTES,'UTF-8'); + } + $question->feedback[$j] = $question->feedback[$j]; + } else { + $question->fraction[$j] = 0; + if ($ishtml) { + $question->feedback[$j] = html_entity_decode(trim(@$thisquestion["#"]["GRADABLE"][0]["#"]["FEEDBACK_WHEN_INCORRECT"][0]["#"]),ENT_QUOTES,'UTF-8'); + } + $question->feedback[$j] = $question->feedback[$j]; } - $question->feedback[$j] = $question->feedback[$j]; } + $questions[] = $question; } - $questions[] = $question; } -} -//---------------------------------------- -// Process Multiple Choice Questions With Multiple Answers -//---------------------------------------- -function process_ma($xml, &$questions) { + //---------------------------------------- + // Process Multiple Choice Questions With Multiple Answers + //---------------------------------------- + function process_ma($xml, &$questions) { - if (isset($xml["POOL"]["#"]["QUESTION_MULTIPLEANSWER"])) { - $maquestions = $xml["POOL"]["#"]["QUESTION_MULTIPLEANSWER"]; - } - else { - return; - } + if (isset($xml["POOL"]["#"]["QUESTION_MULTIPLEANSWER"])) { + $maquestions = $xml["POOL"]["#"]["QUESTION_MULTIPLEANSWER"]; + } + else { + return; + } - for ($i = 0; $i < sizeof ($maquestions); $i++) { + for ($i = 0; $i < sizeof ($maquestions); $i++) { - $question = $this->defaultquestion(); + $question = $this->defaultquestion(); - $question->qtype = MULTICHOICE; - $question->defaultmark = 1; - $question->single = 0; // More than one answers allowed - $question->image = ""; // No images with this format + $question->qtype = MULTICHOICE; + $question->defaultmark = 1; + $question->single = 0; // More than one answers allowed + $question->image = ""; // No images with this format - $thisquestion = $maquestions[$i]; + $thisquestion = $maquestions[$i]; - // determine if the question is already escaped html - $ishtml = $thisquestion["#"]["BODY"][0]["#"]["FLAGS"][0]["#"]["ISHTML"][0]["@"]["value"]; + // determine if the question is already escaped html + $ishtml = $thisquestion["#"]["BODY"][0]["#"]["FLAGS"][0]["#"]["ISHTML"][0]["@"]["value"]; - // put questiontext in question object - if ($ishtml) { - $question->questiontext = html_entity_decode(trim($thisquestion["#"]["BODY"][0]["#"]["TEXT"][0]["#"]),ENT_QUOTES,'UTF-8'); - } - $question->questiontext = $question->questiontext; - // put name of question in question object - $question->name = shorten_text($question->questiontext, 254); + // put questiontext in question object + if ($ishtml) { + $question->questiontext = html_entity_decode(trim($thisquestion["#"]["BODY"][0]["#"]["TEXT"][0]["#"]),ENT_QUOTES,'UTF-8'); + } + $question->questiontext = $question->questiontext; + // put name of question in question object + $question->name = shorten_text($question->questiontext, 254); - $choices = $thisquestion["#"]["ANSWER"]; - $correctanswers = $thisquestion["#"]["GRADABLE"][0]["#"]["CORRECTANSWER"]; + $choices = $thisquestion["#"]["ANSWER"]; + $correctanswers = $thisquestion["#"]["GRADABLE"][0]["#"]["CORRECTANSWER"]; - for ($j = 0; $j < sizeof ($choices); $j++) { + for ($j = 0; $j < sizeof ($choices); $j++) { - $choice = trim($choices[$j]["#"]["TEXT"][0]["#"]); - // put this choice in the question object. - $question->answer[$j] = $choice; + $choice = trim($choices[$j]["#"]["TEXT"][0]["#"]); + // put this choice in the question object. + $question->answer[$j] = $choice; - $correctanswercount = sizeof($correctanswers); - $id = $choices[$j]["@"]["id"]; - $iscorrect = 0; - for ($k = 0; $k < $correctanswercount; $k++) { + $correctanswercount = sizeof($correctanswers); + $id = $choices[$j]["@"]["id"]; + $iscorrect = 0; + for ($k = 0; $k < $correctanswercount; $k++) { - $correct_answer_id = trim($correctanswers[$k]["@"]["answer_id"]); - if (strcmp ($id, $correct_answer_id) == 0) { - $iscorrect = 1; - } + $correct_answer_id = trim($correctanswers[$k]["@"]["answer_id"]); + if (strcmp ($id, $correct_answer_id) == 0) { + $iscorrect = 1; + } + } + if ($iscorrect) { + $question->fraction[$j] = floor(100000/$correctanswercount)/100000; // strange behavior if we have more than 5 decimal places + $question->feedback[$j] = trim($thisquestion["#"]["GRADABLE"][$j]["#"]["FEEDBACK_WHEN_CORRECT"][0]["#"]); + } else { + $question->fraction[$j] = 0; + $question->feedback[$j] = trim($thisquestion["#"]["GRADABLE"][$j]["#"]["FEEDBACK_WHEN_INCORRECT"][0]["#"]); + } } - if ($iscorrect) { - $question->fraction[$j] = floor(100000/$correctanswercount)/100000; // strange behavior if we have more than 5 decimal places - $question->feedback[$j] = trim($thisquestion["#"]["GRADABLE"][$j]["#"]["FEEDBACK_WHEN_CORRECT"][0]["#"]); - } else { - $question->fraction[$j] = 0; - $question->feedback[$j] = trim($thisquestion["#"]["GRADABLE"][$j]["#"]["FEEDBACK_WHEN_INCORRECT"][0]["#"]); - } - } - $questions[] = $question; + $questions[] = $question; + } } -} -//---------------------------------------- -// Process Fill in the Blank Questions -//---------------------------------------- -function process_fib($xml, &$questions) { + //---------------------------------------- + // Process Fill in the Blank Questions + //---------------------------------------- + function process_fib($xml, &$questions) { - if (isset($xml["POOL"]["#"]["QUESTION_FILLINBLANK"])) { - $fibquestions = $xml["POOL"]["#"]["QUESTION_FILLINBLANK"]; - } - else { - return; - } + if (isset($xml["POOL"]["#"]["QUESTION_FILLINBLANK"])) { + $fibquestions = $xml["POOL"]["#"]["QUESTION_FILLINBLANK"]; + } + else { + return; + } - for ($i = 0; $i < sizeof ($fibquestions); $i++) { - $question = $this->defaultquestion(); + for ($i = 0; $i < sizeof ($fibquestions); $i++) { + $question = $this->defaultquestion(); - $question->qtype = SHORTANSWER; - $question->usecase = 0; // Ignore case + $question->qtype = SHORTANSWER; + $question->usecase = 0; // Ignore case - $thisquestion = $fibquestions[$i]; + $thisquestion = $fibquestions[$i]; - // determine if the question is already escaped html - $ishtml = $thisquestion["#"]["BODY"][0]["#"]["FLAGS"][0]["#"]["ISHTML"][0]["@"]["value"]; + // determine if the question is already escaped html + $ishtml = $thisquestion["#"]["BODY"][0]["#"]["FLAGS"][0]["#"]["ISHTML"][0]["@"]["value"]; - // put questiontext in question object - if ($ishtml) { - $question->questiontext = html_entity_decode(trim($thisquestion["#"]["BODY"][0]["#"]["TEXT"][0]["#"]),ENT_QUOTES,'UTF-8'); - } - $question->questiontext = $question->questiontext; - // put name of question in question object - $question->name = shorten_text($question->questiontext, 254); + // put questiontext in question object + if ($ishtml) { + $question->questiontext = html_entity_decode(trim($thisquestion["#"]["BODY"][0]["#"]["TEXT"][0]["#"]),ENT_QUOTES,'UTF-8'); + } + $question->questiontext = $question->questiontext; + // put name of question in question object + $question->name = shorten_text($question->questiontext, 254); - $answer = trim($thisquestion["#"]["ANSWER"][0]["#"]["TEXT"][0]["#"]); + $answer = trim($thisquestion["#"]["ANSWER"][0]["#"]["TEXT"][0]["#"]); - $question->answer[] = $answer; - $question->fraction[] = 1; - $question->feedback = array(); + $question->answer[] = $answer; + $question->fraction[] = 1; + $question->feedback = array(); - if (is_array( $thisquestion['#']['GRADABLE'][0]['#'] )) { - $question->feedback[0] = trim($thisquestion["#"]["GRADABLE"][0]["#"]["FEEDBACK_WHEN_CORRECT"][0]["#"]); - } - else { - $question->feedback[0] = ''; - } - if (is_array( $thisquestion["#"]["GRADABLE"][0]["#"] )) { - $question->feedback[1] = trim($thisquestion["#"]["GRADABLE"][0]["#"]["FEEDBACK_WHEN_INCORRECT"][0]["#"]); - } - else { - $question->feedback[1] = ''; - } + if (is_array( $thisquestion['#']['GRADABLE'][0]['#'] )) { + $question->feedback[0] = trim($thisquestion["#"]["GRADABLE"][0]["#"]["FEEDBACK_WHEN_CORRECT"][0]["#"]); + } + else { + $question->feedback[0] = ''; + } + if (is_array( $thisquestion["#"]["GRADABLE"][0]["#"] )) { + $question->feedback[1] = trim($thisquestion["#"]["GRADABLE"][0]["#"]["FEEDBACK_WHEN_INCORRECT"][0]["#"]); + } + else { + $question->feedback[1] = ''; + } - $questions[] = $question; + $questions[] = $question; + } } -} -//---------------------------------------- -// Process Matching Questions -//---------------------------------------- -function process_matching($xml, &$questions) { + //---------------------------------------- + // Process Matching Questions + //---------------------------------------- + function process_matching($xml, &$questions) { - if (isset($xml["POOL"]["#"]["QUESTION_MATCH"])) { - $matchquestions = $xml["POOL"]["#"]["QUESTION_MATCH"]; - } - else { - return; - } - - for ($i = 0; $i < sizeof ($matchquestions); $i++) { + if (isset($xml["POOL"]["#"]["QUESTION_MATCH"])) { + $matchquestions = $xml["POOL"]["#"]["QUESTION_MATCH"]; + } + else { + return; + } - $question = $this->defaultquestion(); + for ($i = 0; $i < sizeof ($matchquestions); $i++) { - $question->qtype = MATCH; + $question = $this->defaultquestion(); - $thisquestion = $matchquestions[$i]; + $question->qtype = MATCH; - // determine if the question is already escaped html - $ishtml = $thisquestion["#"]["BODY"][0]["#"]["FLAGS"][0]["#"]["ISHTML"][0]["@"]["value"]; + $thisquestion = $matchquestions[$i]; - // put questiontext in question object - if ($ishtml) { - $question->questiontext = html_entity_decode(trim($thisquestion["#"]["BODY"][0]["#"]["TEXT"][0]["#"]),ENT_QUOTES,'UTF-8'); - } - $question->questiontext = $question->questiontext; - // put name of question in question object - $question->name = shorten_text($question->questiontext, 254); + // determine if the question is already escaped html + $ishtml = $thisquestion["#"]["BODY"][0]["#"]["FLAGS"][0]["#"]["ISHTML"][0]["@"]["value"]; - $choices = $thisquestion["#"]["CHOICE"]; - for ($j = 0; $j < sizeof ($choices); $j++) { + // put questiontext in question object + if ($ishtml) { + $question->questiontext = html_entity_decode(trim($thisquestion["#"]["BODY"][0]["#"]["TEXT"][0]["#"]),ENT_QUOTES,'UTF-8'); + } + $question->questiontext = $question->questiontext; + // put name of question in question object + $question->name = shorten_text($question->questiontext, 254); - $subquestion = NULL; + $choices = $thisquestion["#"]["CHOICE"]; + for ($j = 0; $j < sizeof ($choices); $j++) { - $choice = $choices[$j]["#"]["TEXT"][0]["#"]; - $choice_id = $choices[$j]["@"]["id"]; + $subquestion = NULL; - $question->subanswers[] = trim($choice); + $choice = $choices[$j]["#"]["TEXT"][0]["#"]; + $choice_id = $choices[$j]["@"]["id"]; - $correctanswers = $thisquestion["#"]["GRADABLE"][0]["#"]["CORRECTANSWER"]; - for ($k = 0; $k < sizeof ($correctanswers); $k++) { + $question->subanswers[] = trim($choice); - if (strcmp($choice_id, $correctanswers[$k]["@"]["choice_id"]) == 0) { + $correctanswers = $thisquestion["#"]["GRADABLE"][0]["#"]["CORRECTANSWER"]; + for ($k = 0; $k < sizeof ($correctanswers); $k++) { - $answer_id = $correctanswers[$k]["@"]["answer_id"]; + if (strcmp($choice_id, $correctanswers[$k]["@"]["choice_id"]) == 0) { - $answers = $thisquestion["#"]["ANSWER"]; - for ($m = 0; $m < sizeof ($answers); $m++) { + $answer_id = $correctanswers[$k]["@"]["answer_id"]; - $answer = $answers[$m]; - $current_ans_id = $answer["@"]["id"]; - if (strcmp ($current_ans_id, $answer_id) == 0) { + $answers = $thisquestion["#"]["ANSWER"]; + for ($m = 0; $m < sizeof ($answers); $m++) { - $answer = $answer["#"]["TEXT"][0]["#"]; - $question->subquestions[] = trim($answer); - break; + $answer = $answers[$m]; + $current_ans_id = $answer["@"]["id"]; + if (strcmp ($current_ans_id, $answer_id) == 0) { + $answer = $answer["#"]["TEXT"][0]["#"]; + $question->subquestions[] = trim($answer); + break; + } } - + break; } - - break; - } - } - } - - $questions[] = $question; + $questions[] = $question; + } } } - -} - diff --git a/question/format/gift/format.php b/question/format/gift/format.php index 08436d404e161..7fca460bcf01f 100644 --- a/question/format/gift/format.php +++ b/question/format/gift/format.php @@ -63,19 +63,19 @@ */ class qformat_gift extends qformat_default { - function provide_import() { + public function provide_import() { return true; } - function provide_export() { + public function provide_export() { return true; } - function export_file_extension() { + public function export_file_extension() { return '.txt'; } - function answerweightparser(&$answer) { + protected function answerweightparser(&$answer) { $answer = substr($answer, 1); // removes initial % $end_position = strpos($answer, "%"); $answer_weight = substr($answer, 0, $end_position); // gets weight as integer @@ -84,7 +84,7 @@ function answerweightparser(&$answer) { return $answer_weight; } - function commentparser($answer, $defaultformat) { + protected function commentparser($answer, $defaultformat) { $bits = explode('#', $answer, 2); $ans = $this->parse_text_with_format(trim($bits[0]), $defaultformat); if (count($bits) > 1) { @@ -95,7 +95,7 @@ function commentparser($answer, $defaultformat) { return array($ans, $feedback); } - function split_truefalse_comment($answer, $defaultformat) { + protected function split_truefalse_comment($answer, $defaultformat) { $bits = explode('#', $answer, 3); $ans = $this->parse_text_with_format(trim($bits[0]), $defaultformat); if (count($bits) > 1) { @@ -111,7 +111,7 @@ function split_truefalse_comment($answer, $defaultformat) { return array($ans, $wrongfeedback, $rightfeedback); } - function escapedchar_pre($string) { + protected function escapedchar_pre($string) { //Replaces escaped control characters with a placeholder BEFORE processing $escapedcharacters = array("\\:", "\\#", "\\=", "\\{", "\\}", "\\~", "\\n" ); //dlnsk @@ -123,7 +123,7 @@ function escapedchar_pre($string) { return $string; } - function escapedchar_post($string) { + protected function escapedchar_post($string) { //Replaces placeholders with corresponding character AFTER processing is done $placeholders = array("&&058;", "&&035;", "&&061;", "&&123;", "&&125;", "&&126;", "&&010"); //dlnsk $characters = array(":", "#", "=", "{", "}", "~", "\n" ); //dlnsk @@ -131,7 +131,7 @@ function escapedchar_post($string) { return $string; } - function check_answer_count($min, $answers, $text) { + protected function check_answer_count($min, $answers, $text) { $countanswers = count($answers); if ($countanswers < $min) { $this->error(get_string('importminerror', 'qformat_gift'), $text); @@ -160,7 +160,7 @@ protected function parse_text_with_format($text, $defaultformat = FORMAT_MOODLE) return $result; } - function readquestion($lines) { + public function readquestion($lines) { // Given an array of lines known to define a question in this format, this function // converts it into a question object suitable for processing and insertion into Moodle. @@ -559,7 +559,7 @@ function readquestion($lines) { } - function repchar($text, $notused = 0) { + protected function repchar($text, $notused = 0) { // Escapes 'reserved' characters # = ~ {) : // Removes new lines $reserved = array( '#', '=', '~', '{', '}', ':', "\n", "\r"); @@ -573,7 +573,7 @@ function repchar($text, $notused = 0) { * @param int $format one of the FORMAT_ constants. * @return string the corresponding name. */ - function format_const_to_name($format) { + protected function format_const_to_name($format) { if ($format == FORMAT_MOODLE) { return 'moodle'; } else if ($format == FORMAT_HTML) { @@ -591,7 +591,7 @@ function format_const_to_name($format) { * @param int $format one of the FORMAT_ constants. * @return string the corresponding name. */ - function format_name_to_const($format) { + protected function format_name_to_const($format) { if ($format == 'moodle') { return FORMAT_MOODLE; } else if ($format == 'html') { @@ -618,7 +618,7 @@ public function write_questiontext($text, $format, $defaultformat = FORMAT_MOODL return $output; } - function writequestion($question) { + public function writequestion($question) { global $OUTPUT; // Start with a comment diff --git a/question/format/multianswer/format.php b/question/format/multianswer/format.php index 5469e007652b1..661485266fd31 100644 --- a/question/format/multianswer/format.php +++ b/question/format/multianswer/format.php @@ -37,11 +37,11 @@ */ class qformat_multianswer extends qformat_default { - function provide_import() { + public function provide_import() { return true; } - function readquestions($lines) { + protected function readquestions($lines) { // For this class the method has been simplified as // there can never be more than one question for a // multianswer import diff --git a/question/format/qti_two/format.php b/question/format/qti_two/format.php index cf578876a7535..ca92d2a34e130 100644 --- a/question/format/qti_two/format.php +++ b/question/format/qti_two/format.php @@ -139,7 +139,7 @@ function importpreprocess() { print_error('cannotimportformat', 'question'); } - function exportpreprocess() { + public function exportpreprocess() { global $CFG; require_once("{$CFG->libdir}/smarty/Smarty.class.php"); @@ -251,15 +251,15 @@ function handle_questions_media(&$questions, $path, $courseid) { return empty($errors) ? true : $errors; } -/** - * exports the questions in a question category to the given location - * - * The parent class method was overridden because the IMS export consists of multiple files - * - * @param string $filename the directory name which will hold the exported files - * @return bool - or errors out - */ - function exportprocess() { + /** + * exports the questions in a question category to the given location + * + * The parent class method was overridden because the IMS export consists of multiple files + * + * @param string $filename the directory name which will hold the exported files + * @return bool - or errors out + */ + public function exportprocess() { global $CFG, $OUTPUT, $USER; $courseid = $this->course->id; @@ -355,13 +355,13 @@ function export_quiz($course, $quiz, $questions, $result, $redirect, $submiturl $this->xml_entitize($questions); $this->xml_entitize($result); $this->xml_entitize($submiturl); - if (! $this->exportpreprocess(0, $course)) { // Do anything before that we need to + if (!$this->exportpreprocess(0, $course)) { // Do anything before that we need to print_error('errorpreprocess', 'question', $redirect); } - if (! $this->exportprocess_quiz($quiz, $questions, $result, $submiturl, $course)) { // Process the export data + if (!$this->exportprocess_quiz($quiz, $questions, $result, $submiturl, $course)) { // Process the export data print_error('errorprocess','question', $redirect); } - if (! $this->exportpostprocess()) { // In case anything needs to be done after + if (!$this->exportpostprocess()) { // In case anything needs to be done after print_error('errorpostprocess', 'question', $redirect); } diff --git a/question/format/xhtml/format.php b/question/format/xhtml/format.php index 74f4a57b5fed1..a9c50accbd2a5 100644 --- a/question/format/xhtml/format.php +++ b/question/format/xhtml/format.php @@ -38,144 +38,142 @@ */ class qformat_xhtml extends qformat_default { - function provide_export() { - return true; + public function provide_export() { + return true; } -function repchar($text) { - return $text; -} + protected function repchar($text) { + return $text; + } -function writequestion($question) { - global $OUTPUT; - // turns question into string - // question reflects database fields for general question and specific to type + protected function writequestion($question) { + global $OUTPUT; + // turns question into string + // question reflects database fields for general question and specific to type - // if a category switch, just ignore - if ($question->qtype=='category') { - return ''; - } + // if a category switch, just ignore + if ($question->qtype=='category') { + return ''; + } - // initial string; - $expout = ""; - $id = $question->id; - - // add comment and div tags - $expout .= "\n"; - $expout .= "
\n"; - - // add header - $expout .= "

$question->name

\n"; - - // Format and add the question text - $expout .= '

' . format_text($question->questiontext, - $question->questiontextformat) . "

\n"; - - // selection depends on question type - switch($question->qtype) { - case TRUEFALSE: - $st_true = get_string('true', 'qtype_truefalse'); - $st_false = get_string('false', 'qtype_truefalse'); - $expout .= "
    \n"; - $expout .= "
  • $st_true
  • \n"; - $expout .= "
  • $st_false
  • \n"; - $expout .= "
\n"; - break; - case MULTICHOICE: - $expout .= "
    \n"; - foreach($question->options->answers as $answer) { - $ans_text = $this->repchar( $answer->answer ); - if ($question->options->single) { - $expout .= "
  • $ans_text
  • \n"; + // initial string; + $expout = ""; + $id = $question->id; + + // add comment and div tags + $expout .= "\n"; + $expout .= "
    \n"; + + // add header + $expout .= "

    $question->name

    \n"; + + // Format and add the question text + $expout .= '

    ' . format_text($question->questiontext, + $question->questiontextformat) . "

    \n"; + + // selection depends on question type + switch($question->qtype) { + case TRUEFALSE: + $st_true = get_string('true', 'qtype_truefalse'); + $st_false = get_string('false', 'qtype_truefalse'); + $expout .= "
      \n"; + $expout .= "
    • $st_true
    • \n"; + $expout .= "
    • $st_false
    • \n"; + $expout .= "
    \n"; + break; + case MULTICHOICE: + $expout .= "
      \n"; + foreach($question->options->answers as $answer) { + $ans_text = $this->repchar( $answer->answer ); + if ($question->options->single) { + $expout .= "
    • $ans_text
    • \n"; + } + else { + $expout .= "
    • $ans_text
    • \n"; + } } - else { - $expout .= "
    • $ans_text
    • \n"; + $expout .= "
    \n"; + break; + case SHORTANSWER: + $expout .= "
      \n"; + $expout .= "
    • \n"; + $expout .= "
    \n"; + break; + case NUMERICAL: + $expout .= "
      \n"; + $expout .= "
    • \n"; + $expout .= "
    \n"; + break; + case MATCH: + $expout .= "
      \n"; + + // build answer list + $ans_list = array(); + foreach($question->options->subquestions as $subquestion) { + $ans_list[] = $this->repchar( $subquestion->answertext ); } - } - $expout .= "
    \n"; - break; - case SHORTANSWER: - $expout .= "
      \n"; - $expout .= "
    • \n"; - $expout .= "
    \n"; - break; - case NUMERICAL: - $expout .= "
      \n"; - $expout .= "
    • \n"; - $expout .= "
    \n"; - break; - case MATCH: - $expout .= "
      \n"; - - // build answer list - $ans_list = array(); - foreach($question->options->subquestions as $subquestion) { - $ans_list[] = $this->repchar( $subquestion->answertext ); - } - shuffle( $ans_list ); // random display order + shuffle( $ans_list ); // random display order - // build drop down for answers - $dropdown = "\n"; + // build drop down for answers + $dropdown = "\n"; - // finally display - foreach($question->options->subquestions as $subquestion) { - $quest_text = $this->repchar( $subquestion->questiontext ); - $expout .= "
    • $quest_text
    • \n"; - $expout .= $dropdown; + // finally display + foreach($question->options->subquestions as $subquestion) { + $quest_text = $this->repchar( $subquestion->questiontext ); + $expout .= "
    • $quest_text
    • \n"; + $expout .= $dropdown; + } + $expout .= "
    \n"; + break; + case DESCRIPTION: + break; + case MULTIANSWER: + $expout .= "\n"; + break; + default: + echo $OUTPUT->notification("No handler for qtype $question->qtype for GIFT export" ); } - $expout .= "
\n"; - break; - case DESCRIPTION: - break; - case MULTIANSWER: - $expout .= "\n"; - break; - default: - echo $OUTPUT->notification("No handler for qtype $question->qtype for GIFT export" ); + // close off div + $expout .= "
\n\n\n"; + return $expout; } - // close off div - $expout .= "
\n\n\n"; - return $expout; -} -function presave_process( $content ) { - // override method to allow us to add xhtml headers and footers - - global $CFG; - - // get css bit - $css_lines = file( "$CFG->dirroot/question/format/xhtml/xhtml.css" ); - $css = implode( ' ',$css_lines ); - - $xp = "\n"; - $xp .= "\n"; - $xp .= "\n"; - $xp .= "\n"; - $xp .= "Moodle Quiz XHTML Export\n"; - $xp .= $css; - $xp .= "\n"; - $xp .= "\n"; - $xp .= "
\n\n"; - $xp .= $content; - $xp .= "

\n"; - $xp .= " \n"; - $xp .= "

\n"; - $xp .= "
\n"; - $xp .= "\n"; - $xp .= "\n"; - - return $xp; -} - -function export_file_extension() { - return ".html"; -} + protected function presave_process($content) { + // override method to allow us to add xhtml headers and footers + + global $CFG; + + // get css bit + $css_lines = file( "$CFG->dirroot/question/format/xhtml/xhtml.css" ); + $css = implode( ' ',$css_lines ); + + $xp = "\n"; + $xp .= "\n"; + $xp .= "\n"; + $xp .= "\n"; + $xp .= "Moodle Quiz XHTML Export\n"; + $xp .= $css; + $xp .= "\n"; + $xp .= "\n"; + $xp .= "
\n\n"; + $xp .= $content; + $xp .= "

\n"; + $xp .= " \n"; + $xp .= "

\n"; + $xp .= "
\n"; + $xp .= "\n"; + $xp .= "\n"; + + return $xp; + } + public function export_file_extension() { + return '.html'; + } } - diff --git a/question/format/xml/format.php b/question/format/xml/format.php index e79fba3fd01dc..9421a9e0c0006 100644 --- a/question/format/xml/format.php +++ b/question/format/xml/format.php @@ -41,15 +41,15 @@ */ class qformat_xml extends qformat_default { - function provide_import() { + public function provide_import() { return true; } - function provide_export() { + public function provide_export() { return true; } - function mime_type() { + public function mime_type() { return 'application/xml'; } @@ -61,7 +61,7 @@ function mime_type() { * @param string name format name from xml file * @return int Moodle format code */ - function trans_format($name) { + protected function trans_format($name) { $name = trim($name); if ($name == 'moodle_auto_format') { @@ -85,7 +85,7 @@ function trans_format($name) { * @param string name true/false * @return int internal code number */ - function trans_single($name) { + public function trans_single($name) { $name = trim($name); if ($name == "false" || !$name) { return 0; @@ -99,7 +99,7 @@ function trans_single($name) { * @param array $text bit of xml tree after ['text'] * @return string processed text. */ - function import_text($text) { + public function import_text($text) { // quick sanity check if (empty($text)) { return ''; @@ -118,7 +118,7 @@ function import_text($text) { * @param string error if set value must exist, return false and issue message if not * @return mixed value */ - function getpath($xml, $path, $default, $istext=false, $error='') { + public function getpath($xml, $path, $default, $istext=false, $error='') { foreach ($path as $index) { if (!isset($xml[$index])) { if (!empty($error)) { @@ -148,7 +148,7 @@ function getpath($xml, $path, $default, $istext=false, $error='') { * @param $question array question question array from xml tree * @return object question object */ - function import_headers($question) { + public function import_headers($question) { global $CFG; // get some error strings @@ -217,7 +217,7 @@ function import_headers($question) { * @param array answer xml tree for single answer * @return object answer object */ - function import_answer($answer) { + public function import_answer($answer) { $fraction = $this->getpath($answer, array('@', 'fraction'), 0); $answertext = $this->getpath($answer, array('#', 'text', 0, '#'), '', true); $answerformat = $this->trans_format($this->getpath($answer, @@ -368,7 +368,7 @@ public function import_files($xml) { * @param array question question array from xml tree * @return object question object */ - function import_multichoice($question) { + public function import_multichoice($question) { // get common parts $qo = $this->import_headers($question); @@ -407,7 +407,7 @@ function import_multichoice($question) { * @param array question question array from xml tree * @return object question object */ - function import_multianswer( $questions ) { + public function import_multianswer( $questions ) { $questiontext = array(); $questiontext['text'] = $this->import_text($questions['#']['questiontext'][0]['#']['text']); $questiontext['format'] = '1'; @@ -441,7 +441,7 @@ function import_multianswer( $questions ) { * @param array question question array from xml tree * @return object question object */ - function import_truefalse($question) { + public function import_truefalse($question) { // get common parts global $OUTPUT; $qo = $this->import_headers($question); @@ -513,7 +513,7 @@ function import_truefalse($question) { * @param array question question array from xml tree * @return object question object */ - function import_shortanswer($question) { + public function import_shortanswer($question) { // get common parts $qo = $this->import_headers($question); @@ -544,7 +544,7 @@ function import_shortanswer($question) { * @param array question question array from xml tree * @return object question object */ - function import_description($question) { + public function import_description($question) { // get common parts $qo = $this->import_headers($question); // header parts particular to shortanswer @@ -559,7 +559,7 @@ function import_description($question) { * @param array question question array from xml tree * @return object question object */ - function import_numerical($question) { + public function import_numerical($question) { // get common parts $qo = $this->import_headers($question); @@ -624,7 +624,7 @@ function import_numerical($question) { * @param array question question array from xml tree * @return object question object */ - function import_matching($question) { + public function import_matching($question) { // get common parts $qo = $this->import_headers($question); @@ -660,7 +660,7 @@ function import_matching($question) { * @param array question question array from xml tree * @return object question object */ - function import_essay($question) { + public function import_essay($question) { // get common parts $qo = $this->import_headers($question); @@ -684,7 +684,7 @@ function import_essay($question) { return $qo; } - function import_calculated($question, $qtype) { + public function import_calculated($question, $qtype) { // import calculated question // get common parts @@ -823,7 +823,7 @@ function import_calculated($question, $qtype) { * tom/dick/harry * */ - function import_category($question) { + protected function import_category($question) { $qo = new stdClass(); $qo->qtype = 'category'; $qo->category = $this->import_text($question['#']['category'][0]['#']['text']); @@ -837,7 +837,7 @@ function import_category($question) { * @param array of lines from the input file. * @return array (of objects) question objects. */ - function readquestions($lines) { + protected function readquestions($lines) { // We just need it as one big string $text = implode($lines, ' '); unset($lines); @@ -898,7 +898,7 @@ function readquestions($lines) { // EXPORT FUNCTIONS START HERE - function export_file_extension() { + public function export_file_extension() { return '.xml'; } @@ -909,7 +909,7 @@ function export_file_extension() { * @param mixed $typeid Internal code * @return string question type string */ - function get_qtype($typeid) { + protected function get_qtype($typeid) { switch($typeid) { case TRUEFALSE: return 'truefalse'; @@ -940,7 +940,7 @@ function get_qtype($typeid) { * @param int id internal code * @return string format text */ - function get_format($id) { + protected function get_format($id) { switch($id) { case FORMAT_MOODLE: return 'moodle_auto_format'; @@ -963,7 +963,7 @@ function get_format($id) { * @param int id single question code * @return string single question string */ - function get_single($id) { + public function get_single($id) { switch($id) { case 0: return 'false'; @@ -981,7 +981,7 @@ function get_single($id) { * @param bool $short stick it on one line. * @return string formatted text. */ - function writetext($raw, $indent = 0, $short = true) { + public function writetext($raw, $indent = 0, $short = true) { $indent = str_repeat(' ', $indent); // if required add CDATA tags @@ -998,7 +998,7 @@ function writetext($raw, $indent = 0, $short = true) { return $xml; } - function presave_process($content) { + protected function presave_process($content) { // Override to allow us to add xml headers and footers return ' @@ -1010,7 +1010,7 @@ function presave_process($content) { * @param object $question the question data. * @return string xml segment */ - function writequestion($question) { + public function writequestion($question) { global $CFG, $OUTPUT; $fs = get_file_storage(); diff --git a/question/import_form.php b/question/import_form.php index ae1615a5b43f4..27aadd6daecfb 100644 --- a/question/import_form.php +++ b/question/import_form.php @@ -38,7 +38,7 @@ */ class question_import_form extends moodleform { - function definition() { + protected function definition() { global $COURSE; $mform = $this->_form; diff --git a/question/move_form.php b/question/move_form.php index 07df4fecb9f32..c7ca2c481af54 100644 --- a/question/move_form.php +++ b/question/move_form.php @@ -37,7 +37,7 @@ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class question_move_form extends moodleform { - function definition() { + protected function definition() { $mform = $this->_form; $currentcat = $this->_customdata['currentcat']; diff --git a/question/type/calculated/datasetdefinitions_form.php b/question/type/calculated/datasetdefinitions_form.php index 69e1a39437a51..98e56e33012ad 100644 --- a/question/type/calculated/datasetdefinitions_form.php +++ b/question/type/calculated/datasetdefinitions_form.php @@ -66,7 +66,8 @@ function question_dataset_dependent_definitions_form($submiturl, $question){ $this->categorycontext = get_context_instance_by_id($category->contextid); parent::moodleform($submiturl); } - function definition() { + + protected function definition() { global $SESSION; $mform =& $this->_form; $possibledatasets = $this->qtypeobj->find_dataset_names($this->question->questiontext); diff --git a/question/type/calculated/datasetitems_form.php b/question/type/calculated/datasetitems_form.php index 4acbd45e69f30..d11a15515781c 100644 --- a/question/type/calculated/datasetitems_form.php +++ b/question/type/calculated/datasetitems_form.php @@ -100,7 +100,7 @@ function question_dataset_dependent_items_form($submiturl, $question, $regenerat } parent::moodleform($submiturl); } - function definition() { + protected function definition() { $labelsharedwildcard = get_string("sharedwildcard", "qtype_calculated"); $mform =& $this->_form; diff --git a/question/type/calculated/edit_calculated_form.php b/question/type/calculated/edit_calculated_form.php index 848275f473cdb..4d0fad01007b3 100644 --- a/question/type/calculated/edit_calculated_form.php +++ b/question/type/calculated/edit_calculated_form.php @@ -106,7 +106,7 @@ function get_per_answer_fields(&$mform, $label, $gradeoptions, &$repeatedoptions * * @param MoodleQuickForm $mform the form being built. */ - function definition_inner(&$mform) { + protected function definition_inner(&$mform) { global $QTYPES; $this->qtypeobj =& $QTYPES[$this->qtype()]; $label = get_string('sharedwildcards', 'qtype_calculated'); diff --git a/question/type/calculatedmulti/edit_calculatedmulti_form.php b/question/type/calculatedmulti/edit_calculatedmulti_form.php index e8aa0c5cf5cc3..19f645c72cf7e 100644 --- a/question/type/calculatedmulti/edit_calculatedmulti_form.php +++ b/question/type/calculatedmulti/edit_calculatedmulti_form.php @@ -103,7 +103,7 @@ function get_per_answer_fields(&$mform, $label, $gradeoptions, &$repeatedoptions * * @param MoodleQuickForm $mform the form being built. */ - function definition_inner(&$mform) { + protected function definition_inner($mform) { global $QTYPES; $this->qtypeobj =& $QTYPES[$this->qtype()]; // echo code left for testing period diff --git a/question/type/calculatedsimple/edit_calculatedsimple_form.php b/question/type/calculatedsimple/edit_calculatedsimple_form.php index cbaa1c1ca67ef..edeac540ce39d 100644 --- a/question/type/calculatedsimple/edit_calculatedsimple_form.php +++ b/question/type/calculatedsimple/edit_calculatedsimple_form.php @@ -305,7 +305,7 @@ function get_per_answer_fields(&$mform, $label, $gradeoptions, &$repeatedoptions * * @param MoodleQuickForm $mform the form being built. */ - function definition_inner(&$mform) { + protected function definition_inner($mform) { global $QTYPES; $this->qtypeobj =& $QTYPES[$this->qtype()]; $strquestionlabel = $this->qtypeobj->comment_header($this->nonemptyanswer); diff --git a/question/type/ddwtos/backup/moodle2/restore_qtype_ddwtos_plugin.class.php b/question/type/ddwtos/backup/moodle2/restore_qtype_ddwtos_plugin.class.php index 786ec45e5cd32..1676ddbb227a0 100644 --- a/question/type/ddwtos/backup/moodle2/restore_qtype_ddwtos_plugin.class.php +++ b/question/type/ddwtos/backup/moodle2/restore_qtype_ddwtos_plugin.class.php @@ -124,7 +124,7 @@ public function recode_state_answer($state) { /** * Return the contents of this qtype to be processed by the links decoder */ - static public function define_decode_contents() { + public static function define_decode_contents() { $contents = array(); diff --git a/question/type/ddwtos/edit_ddwtos_form.php b/question/type/ddwtos/edit_ddwtos_form.php index f840a6ef919c2..fd2273b71b1a5 100644 --- a/question/type/ddwtos/edit_ddwtos_form.php +++ b/question/type/ddwtos/edit_ddwtos_form.php @@ -37,7 +37,7 @@ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class qtype_ddwtos_edit_form extends qtype_gapselect_edit_form_base { - function qtype() { + public function qtype() { return 'ddwtos'; } diff --git a/question/type/ddwtos/questiontype.php b/question/type/ddwtos/questiontype.php index 3bda33afea6b0..c990afab80276 100644 --- a/question/type/ddwtos/questiontype.php +++ b/question/type/ddwtos/questiontype.php @@ -110,7 +110,7 @@ public function import_from_xml($data, $question, $format, $extra=null) { return $question; } - function export_to_xml($question, $format, $extra = null) { + public function export_to_xml($question, $format, $extra = null) { $output = ''; $output .= ' ' . $question->options->shuffleanswers . "\n"; diff --git a/question/type/edit_question_form.php b/question/type/edit_question_form.php index 649a0eb95f123..7a2e5da966cca 100644 --- a/question/type/edit_question_form.php +++ b/question/type/edit_question_form.php @@ -86,7 +86,7 @@ public function __construct($submiturl, $question, $category, $contexts, $formed * If your question type does not support all these fields, then you can * override this method and remove the ones you don't want with $mform->removeElement(). */ - public function definition() { + protected function definition() { global $COURSE, $CFG, $DB; $qtype = $this->qtype(); @@ -442,7 +442,7 @@ public function set_data($question) { * * @param array $question - array to fill in with the default values */ - function data_preprocessing($question) { + protected function data_preprocessing($question) { return $question; } diff --git a/question/type/essay/questiontype.php b/question/type/essay/questiontype.php index 2c735fbcf9246..d91e6edef91a5 100644 --- a/question/type/essay/questiontype.php +++ b/question/type/essay/questiontype.php @@ -39,7 +39,7 @@ public function is_manual_graded() { return true; } - function move_files($questionid, $oldcontextid, $newcontextid) { + public function move_files($questionid, $oldcontextid, $newcontextid) { parent::move_files($questionid, $oldcontextid, $newcontextid); $this->move_files_in_answers($questionid, $oldcontextid, $newcontextid); } diff --git a/question/type/gapselect/backup/moodle2/restore_qtype_gapselect_plugin.class.php b/question/type/gapselect/backup/moodle2/restore_qtype_gapselect_plugin.class.php index 34dbf812b2aaa..4adaa9cbc012f 100644 --- a/question/type/gapselect/backup/moodle2/restore_qtype_gapselect_plugin.class.php +++ b/question/type/gapselect/backup/moodle2/restore_qtype_gapselect_plugin.class.php @@ -124,7 +124,7 @@ public function recode_state_answer($state) { /** * Return the contents of this qtype to be processed by the links decoder */ - static public function define_decode_contents() { + public static function define_decode_contents() { $contents = array(); diff --git a/question/type/gapselect/edit_form_base.php b/question/type/gapselect/edit_form_base.php index 21d5afe985ec5..be882418fc514 100644 --- a/question/type/gapselect/edit_form_base.php +++ b/question/type/gapselect/edit_form_base.php @@ -92,7 +92,7 @@ private function get_list_of_printable_allowed_tags($allowedhtmltags) { * definition_inner adds all specific fields to the form. * @param object $mform (the form being built). */ - function definition_inner($mform) { + protected function definition_inner($mform) { global $CFG; //add the answer (choice) fields to the form @@ -242,7 +242,7 @@ private function validate_slots($questiontext, $choices) { return false; } - function qtype() { + public function qtype() { return ''; } } \ No newline at end of file diff --git a/question/type/gapselect/edit_gapselect_form.php b/question/type/gapselect/edit_gapselect_form.php index 4c57e27ce02e8..e8274a6fe8b2a 100644 --- a/question/type/gapselect/edit_gapselect_form.php +++ b/question/type/gapselect/edit_gapselect_form.php @@ -40,7 +40,7 @@ class qtype_gapselect_edit_form extends qtype_gapselect_edit_form_base { // HTML tags allowed in answers (choices). protected $allowedhtmltags = array(); - function qtype() { + public function qtype() { return 'gapselect'; } } diff --git a/question/type/gapselect/questiontype.php b/question/type/gapselect/questiontype.php index 8bc86c6cf6e4e..1bb69fa36a63e 100644 --- a/question/type/gapselect/questiontype.php +++ b/question/type/gapselect/questiontype.php @@ -57,7 +57,7 @@ protected function choice_group_key() { return 'selectgroup'; } - function import_from_xml($data, $question, $format, $extra=null) { + public function import_from_xml($data, $question, $format, $extra=null) { if (!isset($data['@']['type']) || $data['@']['type'] != 'gapselect') { return false; } @@ -98,7 +98,7 @@ function import_from_xml($data, $question, $format, $extra=null) { return $question; } - function export_to_xml($question, $format, $extra = null) { + public function export_to_xml($question, $format, $extra = null) { $output = ''; $output .= ' ' . $question->options->shuffleanswers . "\n"; diff --git a/question/type/gapselect/questiontypebase.php b/question/type/gapselect/questiontypebase.php index 65662dca1581d..c670923698048 100644 --- a/question/type/gapselect/questiontypebase.php +++ b/question/type/gapselect/questiontypebase.php @@ -308,7 +308,7 @@ public function get_possible_responses($questiondata) { return $parts; } - function move_files($questionid, $oldcontextid, $newcontextid) { + public function move_files($questionid, $oldcontextid, $newcontextid) { parent::move_files($questionid, $oldcontextid, $newcontextid); $fs = get_file_storage(); diff --git a/question/type/match/backup/moodle2/restore_qtype_match_plugin.class.php b/question/type/match/backup/moodle2/restore_qtype_match_plugin.class.php index daac47a5793e2..d7ad26923aa78 100644 --- a/question/type/match/backup/moodle2/restore_qtype_match_plugin.class.php +++ b/question/type/match/backup/moodle2/restore_qtype_match_plugin.class.php @@ -177,7 +177,7 @@ public function recode_state_answer($state) { /** * Return the contents of this qtype to be processed by the links decoder */ - static public function define_decode_contents() { + public static function define_decode_contents() { $contents = array(); diff --git a/question/type/match/edit_match_form.php b/question/type/match/edit_match_form.php index d8bf17f189a97..36249e54361a4 100644 --- a/question/type/match/edit_match_form.php +++ b/question/type/match/edit_match_form.php @@ -36,7 +36,7 @@ */ class qtype_match_edit_form extends question_edit_form { - function get_per_answer_fields($mform, $label, $gradeoptions, &$repeatedoptions, &$answersoption) { + protected function get_per_answer_fields($mform, $label, $gradeoptions, &$repeatedoptions, &$answersoption) { $repeated = array(); $repeated[] = $mform->createElement('header', 'answerhdr', $label); $repeated[] = $mform->createElement('editor', 'subquestions', get_string('question'), array('rows'=>40), $this->editoroptions); @@ -66,7 +66,7 @@ protected function definition_inner($mform) { $this->add_interactive_settings(true, true); } - function data_preprocessing($question) { + protected function data_preprocessing($question) { $question = parent::data_preprocessing($question); $question = $this->data_preprocessing_combined_feedback($question, true); $question = $this->data_preprocessing_hints($question, true, true); @@ -134,7 +134,7 @@ public function validation($data, $files) { return $errors; } - function qtype() { + public function qtype() { return 'match'; } } diff --git a/question/type/match/questiontype.php b/question/type/match/questiontype.php index 4678b8d3f00aa..54585d5731398 100644 --- a/question/type/match/questiontype.php +++ b/question/type/match/questiontype.php @@ -39,7 +39,7 @@ */ class qtype_match extends question_type { - function get_question_options($question) { + public function get_question_options($question) { global $DB; parent::get_question_options($question); $question->options = $DB->get_record('question_match', array('question' => $question->id)); @@ -47,7 +47,7 @@ function get_question_options($question) { return true; } - function save_question_options($question) { + public function save_question_options($question) { global $DB; $context = $question->context; $result = new stdClass(); @@ -159,7 +159,7 @@ protected function make_hint($hint) { return question_hint_with_parts::load_from_record($hint); } - function delete_question($questionid, $contextid) { + public function delete_question($questionid, $contextid) { global $DB; $DB->delete_records('question_match', array('question' => $questionid)); $DB->delete_records('question_match_sub', array('question' => $questionid)); @@ -172,7 +172,7 @@ public function get_random_guess_score($questiondata) { return 1 / count($q->choices); } - function get_possible_responses($questiondata) { + public function get_possible_responses($questiondata) { $subqs = array(); $q = $this->make_question($questiondata); @@ -193,7 +193,7 @@ function get_possible_responses($questiondata) { return $subqs; } - function move_files($questionid, $oldcontextid, $newcontextid) { + public function move_files($questionid, $oldcontextid, $newcontextid) { global $DB; $fs = get_file_storage(); diff --git a/question/type/missingtype/questiontype.php b/question/type/missingtype/questiontype.php index 95a179070bb5e..3eb12e33b8e36 100644 --- a/question/type/missingtype/questiontype.php +++ b/question/type/missingtype/questiontype.php @@ -88,7 +88,7 @@ public function get_random_guess_score($questiondata) { return null; } - function display_question_editing_page(&$mform, $question, $wizardnow){ + public function display_question_editing_page(&$mform, $question, $wizardnow){ global $OUTPUT; echo $OUTPUT->heading(get_string('warningmissingtype', 'qtype_missingtype')); diff --git a/question/type/multianswer/edit_multianswer_form.php b/question/type/multianswer/edit_multianswer_form.php index 13229fb8d753e..725ebc16a606e 100644 --- a/question/type/multianswer/edit_multianswer_form.php +++ b/question/type/multianswer/edit_multianswer_form.php @@ -76,7 +76,7 @@ function question_edit_multianswer_form(&$submiturl, &$question, &$category, &$c parent::question_edit_form($submiturl, $question, $category, $contexts, $formeditable); } - function definition_inner(&$mform) { + protected function definition_inner($mform) { $mform->addElement('hidden', 'reload', 1); // $mform->addElement('hidden', 'generalfeedback',''); $mform->setType('reload', PARAM_INT); diff --git a/question/type/multichoice/backup/moodle2/restore_qtype_multichoice_plugin.class.php b/question/type/multichoice/backup/moodle2/restore_qtype_multichoice_plugin.class.php index ded1e11ae69e3..fbcd9b4ba1201 100644 --- a/question/type/multichoice/backup/moodle2/restore_qtype_multichoice_plugin.class.php +++ b/question/type/multichoice/backup/moodle2/restore_qtype_multichoice_plugin.class.php @@ -130,7 +130,7 @@ public function recode_state_answer($state) { /** * Return the contents of this qtype to be processed by the links decoder */ - static public function define_decode_contents() { + public static function define_decode_contents() { $contents = array(); diff --git a/question/type/multichoice/edit_multichoice_form.php b/question/type/multichoice/edit_multichoice_form.php index 6b9c484b78f0c..02738eb6c4ed7 100644 --- a/question/type/multichoice/edit_multichoice_form.php +++ b/question/type/multichoice/edit_multichoice_form.php @@ -63,7 +63,7 @@ protected function definition_inner($mform) { $this->add_interactive_settings(true, true); } - function data_preprocessing($question) { + protected function data_preprocessing($question) { $question = parent::data_preprocessing($question); $question = $this->data_preprocessing_answers($question, true); $question = $this->data_preprocessing_combined_feedback($question, true); diff --git a/question/type/multichoice/question.php b/question/type/multichoice/question.php index e3c4f882ba26f..2b1fe93572c30 100644 --- a/question/type/multichoice/question.php +++ b/question/type/multichoice/question.php @@ -88,9 +88,9 @@ protected function init_order(question_attempt $qa) { } } - abstract public function get_response(question_attempt $qa); + public abstract function get_response(question_attempt $qa); - abstract public function is_choice_selected($response, $value); + public abstract function is_choice_selected($response, $value); public function check_file_access($qa, $options, $component, $filearea, $args, $forcedownload) { if ($component == 'question' && in_array($filearea, diff --git a/question/type/multichoice/questiontype.php b/question/type/multichoice/questiontype.php index a3be59da1491a..87d3e7b9d159f 100644 --- a/question/type/multichoice/questiontype.php +++ b/question/type/multichoice/questiontype.php @@ -193,7 +193,7 @@ public function get_random_guess_score($questiondata) { return $totalfraction / count($questiondata->options->answers); } - function get_possible_responses($questiondata) { + public function get_possible_responses($questiondata) { if ($questiondata->options->single) { $responses = array(); @@ -230,7 +230,7 @@ public static function get_numbering_styles() { return $styles; } - function move_files($questionid, $oldcontextid, $newcontextid) { + public function move_files($questionid, $oldcontextid, $newcontextid) { $fs = get_file_storage(); parent::move_files($questionid, $oldcontextid, $newcontextid); diff --git a/question/type/multichoice/renderer.php b/question/type/multichoice/renderer.php index 58545966ac21f..87d6d5cb534a4 100644 --- a/question/type/multichoice/renderer.php +++ b/question/type/multichoice/renderer.php @@ -36,22 +36,22 @@ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ abstract class qtype_multichoice_renderer_base extends qtype_with_combined_feedback_renderer { - abstract protected function get_input_type(); + protected abstract function get_input_type(); - abstract protected function get_input_name(question_attempt $qa, $value); + protected abstract function get_input_name(question_attempt $qa, $value); - abstract protected function get_input_value($value); + protected abstract function get_input_value($value); - abstract protected function get_input_id(question_attempt $qa, $value); + protected abstract function get_input_id(question_attempt $qa, $value); /** * Whether a choice should be considered right, wrong or partially right. * @param question_answer $ans representing one of the choices. * @return fload 1.0, 0.0 or something in between, respectively. */ - abstract protected function is_right(question_answer $ans); + protected abstract function is_right(question_answer $ans); - abstract protected function prompt(); + protected abstract function prompt(); public function formulation_and_controls(question_attempt $qa, question_display_options $options) { diff --git a/question/type/numerical/edit_numerical_form.php b/question/type/numerical/edit_numerical_form.php index 8999c85096bce..fc0f1b1fb708a 100644 --- a/question/type/numerical/edit_numerical_form.php +++ b/question/type/numerical/edit_numerical_form.php @@ -36,7 +36,7 @@ */ class question_edit_numerical_form extends question_edit_form { - function get_per_answer_fields(&$mform, $label, $gradeoptions, &$repeatedoptions, &$answersoption) { + protected function get_per_answer_fields($mform, $label, $gradeoptions, &$repeatedoptions, &$answersoption) { $repeated = parent::get_per_answer_fields($mform, $label, $gradeoptions, $repeatedoptions, $answersoption); $tolerance =& $mform->createElement('text', 'tolerance', get_string('acceptederror', 'qtype_numerical')); @@ -47,24 +47,18 @@ function get_per_answer_fields(&$mform, $label, $gradeoptions, &$repeatedoptions return $repeated; } - /** - * Add question-type specific form fields. - * - * @param MoodleQuickForm $mform the form being built. - */ - function definition_inner(&$mform) { + protected function definition_inner($mform) { global $QTYPES ; -//------------------------------------------------------------------------------------------ $creategrades = get_grade_options(); $this->add_per_answer_fields($mform, get_string('answerno', 'qtype_numerical', '{no}'), $creategrades->gradeoptions); -//------------------------------------------------------------------------------------------ + $QTYPES['numerical']->add_units_options($mform,$this); $QTYPES['numerical']->add_units_elements($mform,$this); } - function data_preprocessing($question) { + protected function data_preprocessing($question) { global $QTYPES ; if (isset($question->options)){ $answers = $question->options->answers; @@ -97,7 +91,7 @@ function data_preprocessing($question) { return $question; } - function validation($data, $files) { + public function validation($data, $files) { global $QTYPES; $errors = parent::validation($data, $files); @@ -131,7 +125,7 @@ function validation($data, $files) { return $errors; } - function qtype() { + public function qtype() { return 'numerical'; } } diff --git a/question/type/numerical/questiontype.php b/question/type/numerical/questiontype.php index a2f278651b26f..a67592ee69a8e 100644 --- a/question/type/numerical/questiontype.php +++ b/question/type/numerical/questiontype.php @@ -1037,7 +1037,7 @@ function apply_unit($rawresponse, $units) { * of edit_..._form.php for * numerical, calculated, calculatedsimple */ - function add_units_options(&$mform, &$that){ + protected function add_units_options(&$mform, &$that){ // Units are graded $mform->addElement('header', 'unithandling', get_string('unitshandling', 'qtype_numerical')); $mform->addElement('radio', 'unitrole', get_string('unitnotused', 'qtype_numerical'), get_string('onlynumerical', 'qtype_numerical'),0); @@ -1085,7 +1085,7 @@ function add_units_options(&$mform, &$that){ * of edit_..._form.php for * numerical, calculated, calculatedsimple */ - function add_units_elements(& $mform,& $that) { + protected function add_units_elements(& $mform,& $that) { $repeated = array(); $repeated[] =& $mform->createElement('header', 'unithdr', get_string('unithdr', 'qtype_numerical', '{no}')); diff --git a/question/type/numerical/simpletest/testquestiontype.php b/question/type/numerical/simpletest/testquestiontype.php index 8e4c0dea12bee..d122943e30a34 100644 --- a/question/type/numerical/simpletest/testquestiontype.php +++ b/question/type/numerical/simpletest/testquestiontype.php @@ -41,19 +41,19 @@ class question_numerical_qtype_test extends UnitTestCase { var $tolerance = 0.00000001; var $qtype; - function setUp() { + public function setUp() { $this->qtype = new question_numerical_qtype(); } - function tearDown() { + public function tearDown() { $this->qtype = null; } - function test_name() { + public function test_name() { $this->assertEqual($this->qtype->name(), 'numerical'); } - function test_get_tolerance_interval() { + public function test_get_tolerance_interval() { $answer = new stdClass(); $answer->tolerance = 0.01; $answer->tolerancetype = 'relative'; @@ -109,7 +109,7 @@ function test_get_tolerance_interval() { $this->assertWithinMargin($answer->max, 2.0, $this->tolerance); } - function test_apply_unit() { + public function test_apply_unit() { $units = array( (object) array('unit' => 'm', 'multiplier' => 1), (object) array('unit' => 'cm', 'multiplier' => 100), @@ -123,16 +123,6 @@ function test_apply_unit() { $this->assertWithinMargin($this->qtype->apply_unit('100m', $units), 100, $this->tolerance); $this->assertWithinMargin($this->qtype->apply_unit('1cm', $units), 0.01, $this->tolerance); $this->assertWithinMargin($this->qtype->apply_unit('12inch', $units), .3048, $this->tolerance); - // $this->assertIdentical($this->qtype->apply_unit('1km', $units), false); $this->assertWithinMargin($this->qtype->apply_unit('-100', array()), -100, $this->tolerance); - // $this->assertIdentical($this->qtype->apply_unit('1000 miles', array()), false); } - -// function test_backup() { -// } -// -// function test_restore() { -// } } - - diff --git a/question/type/opaque/edit_engine_form.php b/question/type/opaque/edit_engine_form.php index b7cdd0b63c361..83ae2a7018492 100644 --- a/question/type/opaque/edit_engine_form.php +++ b/question/type/opaque/edit_engine_form.php @@ -38,7 +38,7 @@ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class qtype_opaque_engine_edit_form extends moodleform { - public function definition() { + protected function definition() { $mform = $this->_form; $mform->addElement('text', 'enginename', get_string('enginename', 'qtype_opaque')); diff --git a/question/type/opaque/edit_opaque_form.php b/question/type/opaque/edit_opaque_form.php index b51c80d8d800f..dbf31d6f1e525 100644 --- a/question/type/opaque/edit_opaque_form.php +++ b/question/type/opaque/edit_opaque_form.php @@ -40,7 +40,7 @@ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class qtype_opaque_edit_form extends question_edit_form { - function definition() { + protected function definition() { parent::definition(); $mform = $this->_form; $mform->removeElement('questiontext'); @@ -51,7 +51,7 @@ function definition() { $mform->setDefault('defaultmark', 1); } - function definition_inner($mform) { + protected function definition_inner($mform) { $mform->addElement('select', 'engineid', get_string('questionengine', 'qtype_opaque'), qtype_opaque_installed_engine_choices()); $mform->setType('engineid', PARAM_INT); @@ -68,7 +68,7 @@ function definition_inner($mform) { $mform->addRule('remoteversion', null, 'required', null, 'client'); } - function validation($data, $files) { + public function validation($data, $files) { $errors = parent::validation($data, $files); // Check we can connect to this questoin engine. @@ -104,7 +104,7 @@ function validation($data, $files) { return $errors; } - function get_data($slashed = true) { + public function get_data($slashed = true) { // We override get_data to to add the defaultmark, which was determined during validation, // to the data that is returned. $data = parent::get_data($slashed); @@ -114,7 +114,7 @@ function get_data($slashed = true) { return $data; } - function qtype() { + public function qtype() { return 'opaque'; } } diff --git a/question/type/opaque/questiontype.php b/question/type/opaque/questiontype.php index 1b8d077e2b0e2..eae944ef88d43 100644 --- a/question/type/opaque/questiontype.php +++ b/question/type/opaque/questiontype.php @@ -58,11 +58,11 @@ public function can_analyse_responses() { return false; } - function extra_question_fields() { + public function extra_question_fields() { return array('question_opaque', 'engineid', 'remoteid', 'remoteversion'); } - function save_question($question, $form) { + public function save_question($question, $form) { $form->questiontext = ''; $form->questiontextformat = FORMAT_MOODLE; $form->unlimited = 0; @@ -81,7 +81,7 @@ public function get_random_guess_score($questiondata) { return null; } - function export_to_xml($question, $format, $extra=null) { + public function export_to_xml($question, $format, $extra=null) { $expout = ''; $expout .= ' ' . $question->options->remoteid . "\n"; $expout .= ' ' . $question->options->remoteversion . "\n"; @@ -99,7 +99,7 @@ function export_to_xml($question, $format, $extra=null) { return $expout; } - function import_from_xml($data, $question, $format, $extra = null) { + public function import_from_xml($data, $question, $format, $extra = null) { if (!isset($data['@']['type']) || $data['@']['type'] != 'opaque') { return false; } diff --git a/question/type/opaque/simpletest/testlocallib.php b/question/type/opaque/simpletest/testlocallib.php index b2c46f8168854..df7be3274bb2b 100644 --- a/question/type/opaque/simpletest/testlocallib.php +++ b/question/type/opaque/simpletest/testlocallib.php @@ -35,7 +35,7 @@ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class qtype_opaque_locallib_test extends UnitTestCase { - function test_is_same_engine() { + public function test_is_same_engine() { $manager = new qtype_opaque_engine_manager(); $engine1 = new stdClass(); diff --git a/question/type/oumultiresponse/backup/moodle2/restore_qtype_oumultiresponse_plugin.class.php b/question/type/oumultiresponse/backup/moodle2/restore_qtype_oumultiresponse_plugin.class.php index 55c39fb1b051b..c0aac4d3393a0 100644 --- a/question/type/oumultiresponse/backup/moodle2/restore_qtype_oumultiresponse_plugin.class.php +++ b/question/type/oumultiresponse/backup/moodle2/restore_qtype_oumultiresponse_plugin.class.php @@ -124,7 +124,7 @@ public function recode_state_answer($state) { /** * Return the contents of this qtype to be processed by the links decoder */ - static public function define_decode_contents() { + public static function define_decode_contents() { $contents = array(); diff --git a/question/type/oumultiresponse/edit_oumultiresponse_form.php b/question/type/oumultiresponse/edit_oumultiresponse_form.php index a352f26ff93d1..8422b07825520 100644 --- a/question/type/oumultiresponse/edit_oumultiresponse_form.php +++ b/question/type/oumultiresponse/edit_oumultiresponse_form.php @@ -36,7 +36,7 @@ */ class qtype_oumultiresponse_edit_form extends question_edit_form { - public function definition_inner($mform) { + protected function definition_inner($mform) { $mform->addElement('advcheckbox', 'shuffleanswers', get_string('shuffleanswers', 'qtype_multichoice'), null, null, array(0,1)); $mform->addHelpButton('shuffleanswers', 'shuffleanswers', 'qtype_multichoice'); $mform->setDefault('shuffleanswers', 1); @@ -74,7 +74,7 @@ protected function get_hint_fields($withclearwrong = false, $withshownumpartscor return array($repeated, $repeatedoptions); } - function data_preprocessing($question) { + protected function data_preprocessing($question) { $question = parent::data_preprocessing($question); $question = $this->data_preprocessing_answers($question, true); $question = $this->data_preprocessing_combined_feedback($question, true); diff --git a/question/type/oumultiresponse/question.php b/question/type/oumultiresponse/question.php index 8b0d2cebcf7d4..20811f4f8653c 100644 --- a/question/type/oumultiresponse/question.php +++ b/question/type/oumultiresponse/question.php @@ -164,7 +164,7 @@ public static function grade_computation($responsehistory, $answers, $penalty, $ return array_sum($scores); } - protected static function replace_char_at($string, $pos, $newchar) { + public static function replace_char_at($string, $pos, $newchar) { return substr($string, 0, $pos) . $newchar . substr($string, $pos + 1); } } diff --git a/question/type/oumultiresponse/questiontype.php b/question/type/oumultiresponse/questiontype.php index 15afe8592b4a5..5f94938f37b34 100644 --- a/question/type/oumultiresponse/questiontype.php +++ b/question/type/oumultiresponse/questiontype.php @@ -311,7 +311,7 @@ public function export_to_xml($question, $format, $extra = null) { return $output; } - function move_files($questionid, $oldcontextid, $newcontextid) { + public function move_files($questionid, $oldcontextid, $newcontextid) { $fs = get_file_storage(); parent::move_files($questionid, $oldcontextid, $newcontextid); diff --git a/question/type/oumultiresponse/simpletest/testquestion.php b/question/type/oumultiresponse/simpletest/testquestion.php index 1124a2e6d58d7..0c8be3075b14a 100644 --- a/question/type/oumultiresponse/simpletest/testquestion.php +++ b/question/type/oumultiresponse/simpletest/testquestion.php @@ -42,7 +42,7 @@ class qtype_oumultiresponse_question_test extends UnitTestCase { private $tolerance = 0.000001; - function replace_char_at() { + public function test_replace_char_at() { $this->assertEqual(qtype_oumultiresponse_question::replace_char_at('220', 0, '0'), '020'); } @@ -118,7 +118,7 @@ public function test_grade_responses_right_right_wrong_wrong() { $this->assertEqual($state, question_state::$gradedpartial); } - function test_grade_computation() { + public function test_grade_computation() { $right = new stdClass(); $right->fraction = 1.0; $wrong = new stdClass(); diff --git a/question/type/questionbase.php b/question/type/questionbase.php index 5b0a3332f148d..d98855709ada3 100644 --- a/question/type/questionbase.php +++ b/question/type/questionbase.php @@ -527,7 +527,7 @@ public function compute_final_grade($responses, $totaltries); */ abstract class question_with_responses extends question_definition implements question_manually_gradable { - function classify_response(array $response) { + public function classify_response(array $response) { return array(); } } diff --git a/question/type/questiontype.php b/question/type/questiontype.php index 7500e9e30a058..0d2c08f0b247e 100644 --- a/question/type/questiontype.php +++ b/question/type/questiontype.php @@ -318,7 +318,7 @@ public function set_default_options($questiondata) { * redisplayed with validation errors, from validation_errors field, which * is itself an object, shown next to the form fields. (I don't think this is accurate any more.) */ - function save_question($question, $form) { + public function save_question($question, $form) { global $USER, $DB, $OUTPUT; list($question->category) = explode(',', $form->category); @@ -773,7 +773,7 @@ public function actual_number_of_questions($question) { * @return number|null either a fraction estimating what the student would * score by guessing, or null, if it is not possible to estimate. */ - function get_random_guess_score($questiondata) { + public function get_random_guess_score($questiondata) { return 0; } @@ -804,7 +804,7 @@ function get_random_guess_score($questiondata) { * @return array keys are subquestionid, values are arrays of possible * responses to that subquestion. */ - function get_possible_responses($questiondata) { + public function get_possible_responses($questiondata) { return array(); } @@ -976,7 +976,7 @@ public function generate_test($name, $courseid=null) { * @param int $category * @return object $context */ - function get_context_by_category_id($category) { + protected function get_context_by_category_id($category) { global $DB; $contextid = $DB->get_field('question_categories', 'contextid', array('id'=>$category)); $context = get_context_instance_by_id($contextid); @@ -1083,7 +1083,7 @@ protected function delete_files_in_answers($questionid, $contextid, $answerstoo } } - function import_file($context, $component, $filearea, $itemid, $file) { + protected function import_file($context, $component, $filearea, $itemid, $file) { $fs = get_file_storage(); $record = new stdClass(); if (is_object($context)) { @@ -1099,7 +1099,7 @@ function import_file($context, $component, $filearea, $itemid, $file) { return $fs->create_file_from_string($record, $this->decode_file($file)); } - function decode_file($file) { + protected function decode_file($file) { switch ($file->encoding) { case 'base64': default: diff --git a/question/type/random/edit_random_form.php b/question/type/random/edit_random_form.php index ae19cd372ffcc..4fc01db79fe64 100644 --- a/question/type/random/edit_random_form.php +++ b/question/type/random/edit_random_form.php @@ -42,7 +42,7 @@ class qtype_random_edit_form extends question_edit_form { * If your question type does not support all these fields, then you can * override this method and remove the ones you don't want with $mform->removeElement(). */ - public function definition() { + protected function definition() { global $COURSE, $CFG; $qtype = $this->qtype(); diff --git a/question/type/random/questiontype.php b/question/type/random/questiontype.php index 52b4f8fd21f98..b15c23e678c92 100644 --- a/question/type/random/questiontype.php +++ b/question/type/random/questiontype.php @@ -114,7 +114,7 @@ protected function init_qtype_lists() { $this->manualqtypes = implode(',', $manualqtypes); } - function display_question_editing_page(&$mform, $question, $wizardnow){ + public function display_question_editing_page(&$mform, $question, $wizardnow){ global $OUTPUT; $heading = $this->get_heading(empty($question->id)); echo $OUTPUT->heading_with_help($heading, $this->name(), $this->plugin_name()); @@ -226,7 +226,7 @@ public function choose_other_question($questiondata, $excludedquestions, $allows return null; } - function get_random_guess_score($questiondata) { + public function get_random_guess_score($questiondata) { return null; } } diff --git a/question/type/randomsamatch/edit_randomsamatch_form.php b/question/type/randomsamatch/edit_randomsamatch_form.php index e275cde043204..f14d60336c1e0 100644 --- a/question/type/randomsamatch/edit_randomsamatch_form.php +++ b/question/type/randomsamatch/edit_randomsamatch_form.php @@ -40,7 +40,7 @@ class question_edit_randomsamatch_form extends question_edit_form { * * @param MoodleQuickForm $mform the form being built. */ - function definition_inner(&$mform) { + protected function definition_inner(&$mform) { $questionstoselect = array(); for ($i=2; $i<=QUESTION_NUMANS; $i++){ $questionstoselect[$i] = $i; @@ -53,7 +53,7 @@ function definition_inner(&$mform) { $mform->setType('fraction', PARAM_RAW); } - function data_preprocessing($question) { + protected function data_preprocessing($question) { if (empty($question->name)) { $question->name = get_string("randomsamatch", "quiz"); } @@ -64,7 +64,7 @@ function data_preprocessing($question) { return $question; } - function qtype() { + public function qtype() { return 'randomsamatch'; } diff --git a/question/type/rendererbase.php b/question/type/rendererbase.php index 887327ae72ff0..7e8309b469313 100644 --- a/question/type/rendererbase.php +++ b/question/type/rendererbase.php @@ -205,7 +205,7 @@ protected function feedback_class($fraction) { * @param bool $selected whether to show a big or small icon. (Deprecated) * @return string html fragment. */ - function feedback_image($fraction, $selected = true) { + protected function feedback_image($fraction, $selected = true) { $state = question_state::graded_state_for_fraction($fraction); if ($state == question_state::$gradedright) { diff --git a/question/type/shortanswer/edit_shortanswer_form.php b/question/type/shortanswer/edit_shortanswer_form.php index 9dde0130d7dd4..9a6c7513257d0 100644 --- a/question/type/shortanswer/edit_shortanswer_form.php +++ b/question/type/shortanswer/edit_shortanswer_form.php @@ -35,11 +35,7 @@ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class qtype_shortanswer_edit_form extends question_edit_form { - /** - * Add question-type specific form fields. - * - * @param MoodleQuickForm $mform the form being built. - */ + protected function definition_inner($mform) { $menu = array( get_string('caseno', 'qtype_shortanswer'), @@ -58,7 +54,7 @@ protected function definition_inner($mform) { $this->add_interactive_settings(); } - function data_preprocessing($question) { + protected function data_preprocessing($question) { $question = parent::data_preprocessing($question); $question = $this->data_preprocessing_answers($question); $question = $this->data_preprocessing_hints($question); diff --git a/question/type/shortanswer/questiontype.php b/question/type/shortanswer/questiontype.php index e88fded90f478..7138ba04b47fc 100644 --- a/question/type/shortanswer/questiontype.php +++ b/question/type/shortanswer/questiontype.php @@ -47,7 +47,7 @@ protected function questionid_column_name() { return 'question'; } - function move_files($questionid, $oldcontextid, $newcontextid) { + public function move_files($questionid, $oldcontextid, $newcontextid) { parent::move_files($questionid, $oldcontextid, $newcontextid); $this->move_files_in_answers($questionid, $oldcontextid, $newcontextid); } diff --git a/question/type/truefalse/questiontype.php b/question/type/truefalse/questiontype.php index 65f9b1fe21f1d..e457b2eee7623 100644 --- a/question/type/truefalse/questiontype.php +++ b/question/type/truefalse/questiontype.php @@ -143,14 +143,14 @@ protected function initialise_question_instance(question_definition $question, $ $question->falseanswerid = $questiondata->options->falseanswer; } - function delete_question($questionid, $contextid) { + public function delete_question($questionid, $contextid) { global $DB; $DB->delete_records('question_truefalse', array('question' => $questionid)); parent::delete_question($questionid, $contextid); } - function move_files($questionid, $oldcontextid, $newcontextid) { + public function move_files($questionid, $oldcontextid, $newcontextid) { parent::move_files($questionid, $oldcontextid, $newcontextid); $this->move_files_in_answers($questionid, $oldcontextid, $newcontextid); } @@ -160,11 +160,11 @@ protected function delete_files($questionid, $contextid) { $this->delete_files_in_answers($questionid, $contextid); } - function get_random_guess_score($questiondata) { + public function get_random_guess_score($questiondata) { return 0.5; } - function get_possible_responses($questiondata) { + public function get_possible_responses($questiondata) { return array( $questiondata->id => array( 0 => new question_possible_response(get_string('false', 'qtype_truefalse'),