mirror of
https://github.com/moodle/moodle.git
synced 2025-01-17 21:49:15 +01:00
MDL-20636 Add lots of missing public/protected/private.
This commit is contained in:
parent
c73c98365b
commit
c7df5006b9
@ -38,7 +38,7 @@ require_once($CFG->libdir.'/formslib.php');
|
||||
*/
|
||||
class quiz_add_random_form extends moodleform {
|
||||
|
||||
function definition() {
|
||||
protected function definition() {
|
||||
global $CFG, $DB;
|
||||
$mform =& $this->_form;
|
||||
|
||||
@ -78,7 +78,7 @@ class quiz_add_random_form extends moodleform {
|
||||
$mform->setType('returnurl', PARAM_LOCALURL);
|
||||
}
|
||||
|
||||
function validation($fromform, $files) {
|
||||
public function validation($fromform, $files) {
|
||||
$errors = parent::validation($fromform, $files);
|
||||
|
||||
if (!empty($fromform['newcategory']) && trim($fromform['name']) == '') {
|
||||
|
@ -40,7 +40,7 @@ defined('MOODLE_INTERNAL') || die();
|
||||
* @since Moodle 2.0
|
||||
*/
|
||||
class moodle_quiz_exception extends moodle_exception {
|
||||
function __construct($quizobj, $errorcode, $a = NULL, $link = '', $debuginfo = null) {
|
||||
public function __construct($quizobj, $errorcode, $a = NULL, $link = '', $debuginfo = null) {
|
||||
if (!$link) {
|
||||
$link = $quizobj->view_url();
|
||||
}
|
||||
@ -83,7 +83,7 @@ class quiz {
|
||||
* @param object $course the row from the course table for the course we belong to.
|
||||
* @param bool $getcontext intended for testing - stops the constructor getting the context.
|
||||
*/
|
||||
function __construct($quiz, $cm, $course, $getcontext = true) {
|
||||
public function __construct($quiz, $cm, $course, $getcontext = true) {
|
||||
$this->quiz = $quiz;
|
||||
$this->cm = $cm;
|
||||
$this->quiz->cmid = $this->cm->id;
|
||||
@ -101,7 +101,7 @@ class quiz {
|
||||
* @param int $userid the the userid.
|
||||
* @return quiz the new quiz object
|
||||
*/
|
||||
static public function create($quizid, $userid) {
|
||||
public static function create($quizid, $userid) {
|
||||
global $DB;
|
||||
|
||||
$quiz = $DB->get_record('quiz', array('id' => $quizid), '*', MUST_EXIST);
|
||||
@ -358,7 +358,7 @@ class quiz_attempt {
|
||||
* @param object $cm the course_module object for this quiz.
|
||||
* @param object $course the row from the course table for the course we belong to.
|
||||
*/
|
||||
function __construct($attempt, $quiz, $cm, $course) {
|
||||
public function __construct($attempt, $quiz, $cm, $course) {
|
||||
$this->attempt = $attempt;
|
||||
$this->quizobj = new quiz($quiz, $cm, $course);
|
||||
$this->quba = question_engine::load_questions_usage_by_activity($this->attempt->uniqueid);
|
||||
@ -370,7 +370,7 @@ class quiz_attempt {
|
||||
* Used by {create()} and {create_from_usage_id()}.
|
||||
* @param array $conditions passed to $DB->get_record('quiz_attempts', $conditions).
|
||||
*/
|
||||
static protected function create_helper($conditions) {
|
||||
protected static function create_helper($conditions) {
|
||||
global $DB;
|
||||
|
||||
// TODO deal with the issue that makes this necessary.
|
||||
@ -396,7 +396,7 @@ class quiz_attempt {
|
||||
* @param int $attemptid the attempt id.
|
||||
* @return quiz_attempt the new quiz_attempt object
|
||||
*/
|
||||
static public function create($attemptid) {
|
||||
public static function create($attemptid) {
|
||||
return self::create_helper(array('id' => $attemptid));
|
||||
}
|
||||
|
||||
@ -406,7 +406,7 @@ class quiz_attempt {
|
||||
* @param int $usageid the attempt usage id.
|
||||
* @return quiz_attempt the new quiz_attempt object
|
||||
*/
|
||||
static public function create_from_usage_id($usageid) {
|
||||
public static function create_from_usage_id($usageid) {
|
||||
return self::create_helper(array('uniqueid' => $usageid));
|
||||
}
|
||||
|
||||
@ -1200,9 +1200,9 @@ abstract class quiz_nav_panel_base {
|
||||
return '';
|
||||
}
|
||||
|
||||
abstract protected function get_end_bits();
|
||||
protected abstract function get_end_bits();
|
||||
|
||||
abstract protected function get_question_url($slot);
|
||||
protected abstract function get_question_url($slot);
|
||||
|
||||
protected function get_user_picture() {
|
||||
global $DB, $OUTPUT;
|
||||
|
@ -71,7 +71,7 @@ class backup_quiz_activity_task extends backup_activity_task {
|
||||
* Code the transformations to perform in the activity in
|
||||
* order to get transportable (encoded) links
|
||||
*/
|
||||
static public function encode_content_links($content) {
|
||||
public static function encode_content_links($content) {
|
||||
global $CFG;
|
||||
|
||||
$base = preg_quote($CFG->wwwroot,"/");
|
||||
|
@ -56,7 +56,7 @@ class restore_quiz_activity_task extends restore_activity_task {
|
||||
* Define the contents in the activity that must be
|
||||
* processed by the link decoder
|
||||
*/
|
||||
static public function define_decode_contents() {
|
||||
public static function define_decode_contents() {
|
||||
$contents = array();
|
||||
|
||||
$contents[] = new restore_decode_content('quiz', array('intro'), 'quiz');
|
||||
@ -69,7 +69,7 @@ class restore_quiz_activity_task extends restore_activity_task {
|
||||
* Define the decoding rules for links belonging
|
||||
* to the activity to be executed by the link decoder
|
||||
*/
|
||||
static public function define_decode_rules() {
|
||||
public static function define_decode_rules() {
|
||||
$rules = array();
|
||||
|
||||
$rules[] = new restore_decode_rule('QUIZVIEWBYID', '/mod/quiz/view.php?id=$1', 'course_module');
|
||||
@ -86,7 +86,7 @@ class restore_quiz_activity_task extends restore_activity_task {
|
||||
* quiz logs. It must return one array
|
||||
* of {@link restore_log_rule} objects
|
||||
*/
|
||||
static public function define_restore_log_rules() {
|
||||
public static function define_restore_log_rules() {
|
||||
$rules = array();
|
||||
|
||||
$rules[] = new restore_log_rule('quiz', 'add', 'view.php?id={course_module}', '{quiz}');
|
||||
@ -148,7 +148,7 @@ class restore_quiz_activity_task extends restore_activity_task {
|
||||
* by the restore final task, but are defined here at
|
||||
* activity level. All them are rules not linked to any module instance (cmid = 0)
|
||||
*/
|
||||
static public function define_restore_log_rules_for_course() {
|
||||
public static function define_restore_log_rules_for_course() {
|
||||
$rules = array();
|
||||
|
||||
$rules[] = new restore_log_rule('quiz', 'view all', 'index.php?id={course}', null);
|
||||
|
@ -54,7 +54,7 @@ class mod_quiz_mod_form extends moodleform_mod {
|
||||
parent::__construct($current, $section, $cm, $course);
|
||||
}
|
||||
|
||||
function definition() {
|
||||
protected function definition() {
|
||||
global $COURSE, $CFG, $DB, $PAGE;
|
||||
$quizconfig = get_config('quiz');
|
||||
$mform = $this->_form;
|
||||
@ -353,7 +353,7 @@ class mod_quiz_mod_form extends moodleform_mod {
|
||||
}
|
||||
}
|
||||
|
||||
function data_preprocessing(&$toform) {
|
||||
protected function data_preprocessing(&$toform) {
|
||||
if (isset($toform['grade'])) {
|
||||
$toform['grade'] = $toform['grade'] + 0; // Convert to a real number, so we don't get 0.0000.
|
||||
}
|
||||
@ -409,7 +409,7 @@ class mod_quiz_mod_form extends moodleform_mod {
|
||||
}
|
||||
}
|
||||
|
||||
function validation($data, $files) {
|
||||
public function validation($data, $files) {
|
||||
$errors = parent::validation($data, $files);
|
||||
|
||||
// Check open and close times are consistent.
|
||||
|
@ -58,7 +58,7 @@ class quiz_override_form extends moodleform {
|
||||
|
||||
}
|
||||
|
||||
public function definition() {
|
||||
protected function definition() {
|
||||
global $CFG, $USER, $DB;
|
||||
|
||||
$cm = $this->cm;
|
||||
|
@ -475,7 +475,7 @@ abstract class quiz_attempt_report_table extends table_sql {
|
||||
}
|
||||
}
|
||||
|
||||
function get_row_class($attempt) {
|
||||
protected function get_row_class($attempt) {
|
||||
if ($this->qmsubselect && $attempt->gradedattempt) {
|
||||
return 'gradedattempt';
|
||||
} else {
|
||||
@ -525,7 +525,7 @@ abstract class quiz_attempt_report_table extends table_sql {
|
||||
* @param float $fraction grade on a scale 0..1.
|
||||
* @return string html fragment.
|
||||
*/
|
||||
function icon_for_fraction($fraction) {
|
||||
protected function icon_for_fraction($fraction) {
|
||||
global $OUTPUT;
|
||||
|
||||
$state = question_state::graded_state_for_fraction($fraction);
|
||||
@ -551,7 +551,7 @@ abstract class quiz_attempt_report_table extends table_sql {
|
||||
* @param array $slots A list of slots for the questions you want to konw about.
|
||||
* @return array of records. See the SQL in this function to see the fields available.
|
||||
*/
|
||||
function load_question_latest_steps(qubaid_condition $qubaids) {
|
||||
protected function load_question_latest_steps(qubaid_condition $qubaids) {
|
||||
$dm = new question_engine_data_mapper();
|
||||
$latesstepdata = $dm->load_questions_usages_latest_steps(
|
||||
$qubaids, array_keys($this->questions));
|
||||
|
@ -50,17 +50,14 @@ abstract class quiz_default_report {
|
||||
* @param $course the coures we are in.
|
||||
* @param $quiz this quiz.
|
||||
*/
|
||||
abstract function display($cm, $course, $quiz);
|
||||
public abstract function display($cm, $course, $quiz);
|
||||
|
||||
function print_header_and_tabs($cm, $course, $quiz, $reportmode = "overview") {
|
||||
public function print_header_and_tabs($cm, $course, $quiz, $reportmode = 'overview') {
|
||||
global $PAGE, $OUTPUT;
|
||||
/// Define some strings
|
||||
$strquizzes = get_string("modulenameplural", "quiz");
|
||||
$strquiz = get_string("modulename", "quiz");
|
||||
/// Print the page header
|
||||
|
||||
// Print the page header
|
||||
$PAGE->set_title(format_string($quiz->name));
|
||||
$PAGE->set_heading($course->fullname);
|
||||
echo $OUTPUT->header();
|
||||
$course_context = get_context_instance(CONTEXT_COURSE, $course->id);
|
||||
}
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ class quiz_grading_settings extends moodleform {
|
||||
parent::__construct($CFG->wwwroot . '/mod/quiz/report.php', null, 'get');
|
||||
}
|
||||
|
||||
public function definition() {
|
||||
protected function definition() {
|
||||
$mform =& $this->_form;
|
||||
|
||||
$mform->addElement('header', 'options', get_string('options', 'quiz_grading'));
|
||||
|
@ -52,7 +52,7 @@ class quiz_grading_report extends quiz_default_report {
|
||||
protected $quiz;
|
||||
protected $context;
|
||||
|
||||
function display($quiz, $cm, $course) {
|
||||
public function display($quiz, $cm, $course) {
|
||||
global $CFG, $DB, $PAGE;
|
||||
|
||||
$this->quiz = $quiz;
|
||||
@ -519,7 +519,7 @@ class quiz_grading_report extends quiz_default_report {
|
||||
* Ignored if $orderby = random or $pagesize is null.
|
||||
* @param int $pagesize implements paging of the results. null = all.
|
||||
*/
|
||||
function get_usage_ids_where_question_in_state($summarystate, $slot,
|
||||
protected function get_usage_ids_where_question_in_state($summarystate, $slot,
|
||||
$questionid = null, $orderby = 'random', $page = 0, $pagesize = null) {
|
||||
global $CFG;
|
||||
$dm = new question_engine_data_mapper();
|
||||
|
@ -38,7 +38,7 @@ require_once($CFG->libdir . '/formslib.php');
|
||||
*/
|
||||
class mod_quiz_report_overview_settings extends moodleform {
|
||||
|
||||
public function definition() {
|
||||
protected function definition() {
|
||||
$mform = $this->_form;
|
||||
|
||||
$mform->addElement('header', 'preferencespage', get_string('preferencespage', 'quiz_overview'));
|
||||
|
@ -40,7 +40,7 @@ require_once($CFG->dirroot.'/mod/quiz/report/overview/overview_table.php');
|
||||
*/
|
||||
class quiz_overview_report extends quiz_attempt_report {
|
||||
|
||||
function display($quiz, $cm, $course) {
|
||||
public function display($quiz, $cm, $course) {
|
||||
global $CFG, $COURSE, $DB, $OUTPUT;
|
||||
|
||||
$this->context = get_context_instance(CONTEXT_MODULE, $cm->id);
|
||||
|
@ -48,7 +48,7 @@ require_once($CFG->dirroot.'/mod/quiz/report/responses/responses_table.php');
|
||||
*/
|
||||
class quiz_responses_report extends quiz_attempt_report {
|
||||
|
||||
function display($quiz, $cm, $course) {
|
||||
public function display($quiz, $cm, $course) {
|
||||
global $CFG, $COURSE, $DB, $PAGE, $OUTPUT;
|
||||
|
||||
$this->context = get_context_instance(CONTEXT_MODULE, $cm->id);
|
||||
|
@ -50,7 +50,7 @@ class quiz_report_responses_table extends quiz_attempt_report_table {
|
||||
}
|
||||
}
|
||||
|
||||
function wrap_html_start() {
|
||||
public function wrap_html_start() {
|
||||
global $PAGE;
|
||||
if ($this->is_downloading() || !$this->candelete) {
|
||||
return;
|
||||
|
@ -38,7 +38,7 @@ require_once($CFG->libdir . '/formslib.php');
|
||||
*/
|
||||
class mod_quiz_report_responses_settings extends moodleform {
|
||||
|
||||
public function definition() {
|
||||
protected function definition() {
|
||||
$mform = $this->_form;
|
||||
|
||||
$mform->addElement('header', 'preferencespage', get_string('preferencespage', 'quiz_overview'));
|
||||
|
@ -43,7 +43,7 @@ require_once($CFG->dirroot . '/mod/quiz/report/reportlib.php'); // Include the c
|
||||
class question_reportlib_test extends UnitTestCase {
|
||||
public static $includecoverage = array('mod/quiz/report/reportlib.php');
|
||||
|
||||
function test_quiz_report_index_by_keys() {
|
||||
public function test_quiz_report_index_by_keys() {
|
||||
$datum = array();
|
||||
$object = new stdClass();
|
||||
$object->qid = 3;
|
||||
@ -67,7 +67,7 @@ class question_reportlib_test extends UnitTestCase {
|
||||
$this->assertEqual($indexed[101][3][0]->grade, 3);
|
||||
}
|
||||
|
||||
function test_quiz_report_scale_summarks_as_percentage() {
|
||||
public function test_quiz_report_scale_summarks_as_percentage() {
|
||||
$quiz = new stdClass();
|
||||
$quiz->sumgrades = 10;
|
||||
$quiz->decimalpoints = 2;
|
||||
|
@ -43,6 +43,7 @@ class testable_quiz_statistics_question_stats extends quiz_statistics_question_s
|
||||
public function set_step_data($states) {
|
||||
$this->lateststeps = $states;
|
||||
}
|
||||
|
||||
protected function get_random_guess_score($questiondata) {
|
||||
return 0;
|
||||
}
|
||||
@ -61,7 +62,7 @@ class quiz_statistics_question_stats_test extends UnitTestCase {
|
||||
/** @var qstats object created to test class. */
|
||||
protected $qstats;
|
||||
|
||||
function test_qstats() {
|
||||
public function test_qstats() {
|
||||
global $CFG;
|
||||
//data is taken from randomly generated attempts data generated by contrib/tools/generators/qagenerator/
|
||||
$steps = $this->get_records_from_csv($CFG->dirroot.'/mod/quiz/report/statistics/simpletest/mdl_question_states.csv');
|
||||
@ -84,7 +85,7 @@ class quiz_statistics_question_stats_test extends UnitTestCase {
|
||||
$this->qstats_q_fields('discriminativeefficiency', $discriminativeefficiency);
|
||||
}
|
||||
|
||||
function qstats_q_fields($fieldname, $values, $multiplier=1) {
|
||||
public function qstats_q_fields($fieldname, $values, $multiplier=1) {
|
||||
foreach ($this->qstats->questions as $question) {
|
||||
$value = array_shift($values);
|
||||
if ($value !== null) {
|
||||
@ -95,7 +96,7 @@ class quiz_statistics_question_stats_test extends UnitTestCase {
|
||||
}
|
||||
}
|
||||
|
||||
function get_fields_from_csv($line) {
|
||||
public function get_fields_from_csv($line) {
|
||||
$line = trim($line);
|
||||
$items = preg_split('!,!', $line);
|
||||
while (list($key) = each($items)) {
|
||||
@ -116,7 +117,7 @@ class quiz_statistics_question_stats_test extends UnitTestCase {
|
||||
return $items;
|
||||
}
|
||||
|
||||
function get_records_from_csv($filename) {
|
||||
public function get_records_from_csv($filename) {
|
||||
$filecontents = file($filename, FILE_IGNORE_NEW_LINES);
|
||||
$records = array();
|
||||
$keys = $this->get_fields_from_csv(array_shift($filecontents));//first line is field names
|
||||
|
@ -37,7 +37,7 @@ require_once($CFG->libdir . '/formslib.php');
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class quiz_statistics_statistics_settings_form extends moodleform {
|
||||
function definition() {
|
||||
protected function definition() {
|
||||
$mform = $this->_form;
|
||||
|
||||
$mform->addElement('header', 'preferencespage', get_string('preferencespage', 'quiz_overview'));
|
||||
|
@ -47,7 +47,7 @@ class quiz_report_statistics_table extends flexible_table {
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
function __construct() {
|
||||
public function __construct() {
|
||||
parent::__construct('mod-quiz-report-statistics-report');
|
||||
}
|
||||
|
||||
@ -60,7 +60,7 @@ class quiz_report_statistics_table extends flexible_table {
|
||||
* @param moodle_url $reporturl the URL to redisplay this report.
|
||||
* @param int $s number of attempts included in the statistics.
|
||||
*/
|
||||
function setup($quiz, $cmid, $reporturl, $s) {
|
||||
public function setup($quiz, $cmid, $reporturl, $s) {
|
||||
$this->quiz = $quiz;
|
||||
$this->cmid = $cmid;
|
||||
|
||||
|
@ -38,7 +38,7 @@ require_once($CFG->dirroot . '/mod/quiz/locallib.php');
|
||||
*/
|
||||
class simple_rules_test extends UnitTestCase {
|
||||
public static $includecoverage = array('mod/quiz/locallib.php');
|
||||
function test_num_attempts_access_rule() {
|
||||
public function test_num_attempts_access_rule() {
|
||||
$quiz = new stdClass();
|
||||
$quiz->attempts = 3;
|
||||
$quiz->questions = '';
|
||||
@ -64,7 +64,7 @@ class simple_rules_test extends UnitTestCase {
|
||||
$this->assertFalse($rule->time_left($attempt, 1));
|
||||
}
|
||||
|
||||
function test_ipaddress_access_rule() {
|
||||
public function test_ipaddress_access_rule() {
|
||||
$quiz = new stdClass();
|
||||
$attempt = new stdClass();
|
||||
$cm = new stdClass();
|
||||
@ -95,7 +95,7 @@ class simple_rules_test extends UnitTestCase {
|
||||
$this->assertFalse($rule->time_left($attempt, 1));
|
||||
}
|
||||
|
||||
function test_time_limit_access_rule() {
|
||||
public function test_time_limit_access_rule() {
|
||||
$quiz = new stdClass();
|
||||
$quiz->timelimit = 3600;
|
||||
$quiz->questions = '';
|
||||
@ -124,7 +124,7 @@ class simple_rules_test extends UnitTestCase {
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class open_close_date_access_rule_test extends UnitTestCase {
|
||||
function test_no_dates() {
|
||||
public function test_no_dates() {
|
||||
$quiz = new stdClass();
|
||||
$quiz->timeopen = 0;
|
||||
$quiz->timeclose = 0;
|
||||
@ -151,7 +151,7 @@ class open_close_date_access_rule_test extends UnitTestCase {
|
||||
$this->assertFalse($rule->time_left($attempt, 0));
|
||||
}
|
||||
|
||||
function test_start_date() {
|
||||
public function test_start_date() {
|
||||
$quiz = new stdClass();
|
||||
$quiz->timeopen = 10000;
|
||||
$quiz->timeclose = 0;
|
||||
@ -177,7 +177,7 @@ class open_close_date_access_rule_test extends UnitTestCase {
|
||||
$this->assertFalse($rule->time_left($attempt, 0));
|
||||
}
|
||||
|
||||
function test_close_date() {
|
||||
public function test_close_date() {
|
||||
$quiz = new stdClass();
|
||||
$quiz->timeopen = 0;
|
||||
$quiz->timeclose = 20000;
|
||||
@ -209,7 +209,7 @@ class open_close_date_access_rule_test extends UnitTestCase {
|
||||
$this->assertEqual($rule->time_left($attempt, 20100), -100);
|
||||
}
|
||||
|
||||
function test_both_dates() {
|
||||
public function test_both_dates() {
|
||||
$quiz = new stdClass();
|
||||
$quiz->timeopen = 10000;
|
||||
$quiz->timeclose = 20000;
|
||||
@ -259,7 +259,7 @@ class open_close_date_access_rule_test extends UnitTestCase {
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class inter_attempt_delay_access_rule_test extends UnitTestCase {
|
||||
function test_just_first_delay() {
|
||||
public function test_just_first_delay() {
|
||||
$quiz = new stdClass();
|
||||
$quiz->attempts = 3;
|
||||
$quiz->timelimit = 0;
|
||||
@ -291,7 +291,7 @@ class inter_attempt_delay_access_rule_test extends UnitTestCase {
|
||||
$this->assertFalse($rule->prevent_new_attempt(2, $attempt));
|
||||
}
|
||||
|
||||
function test_just_second_delay() {
|
||||
public function test_just_second_delay() {
|
||||
$quiz = new stdClass();
|
||||
$quiz->attempts = 5;
|
||||
$quiz->timelimit = 0;
|
||||
@ -326,7 +326,7 @@ class inter_attempt_delay_access_rule_test extends UnitTestCase {
|
||||
$this->assertEqual($rule->prevent_new_attempt(4, $attempt), get_string('youmustwait', 'quiz', userdate(10001)));
|
||||
}
|
||||
|
||||
function test_just_both_delays() {
|
||||
public function test_just_both_delays() {
|
||||
$quiz = new stdClass();
|
||||
$quiz->attempts = 5;
|
||||
$quiz->timelimit = 0;
|
||||
@ -369,7 +369,7 @@ class inter_attempt_delay_access_rule_test extends UnitTestCase {
|
||||
$this->assertEqual($rule->prevent_new_attempt(4, $attempt), get_string('youmustwait', 'quiz', userdate(10001)));
|
||||
}
|
||||
|
||||
function test_with_close_date() {
|
||||
public function test_with_close_date() {
|
||||
$quiz = new stdClass();
|
||||
$quiz->attempts = 5;
|
||||
$quiz->timelimit = 0;
|
||||
@ -419,7 +419,7 @@ class inter_attempt_delay_access_rule_test extends UnitTestCase {
|
||||
$this->assertFalse($rule->prevent_new_attempt(2, $attempt));
|
||||
}
|
||||
|
||||
function test_time_limit_and_overdue() {
|
||||
public function test_time_limit_and_overdue() {
|
||||
$quiz = new stdClass();
|
||||
$quiz->attempts = 5;
|
||||
$quiz->timelimit = 100;
|
||||
@ -484,7 +484,7 @@ class inter_attempt_delay_access_rule_test extends UnitTestCase {
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class password_access_rule_test extends UnitTestCase {
|
||||
function test_password_access_rule() {
|
||||
public function test_password_access_rule() {
|
||||
$quiz = new stdClass();
|
||||
$quiz->password = 'frog';
|
||||
$quiz->questions = '';
|
||||
@ -510,7 +510,7 @@ class password_access_rule_test extends UnitTestCase {
|
||||
class securewindow_access_rule_test extends UnitTestCase {
|
||||
// Nothing very testable in this class, just test that it obeys the general access rule contact.
|
||||
|
||||
function test_securewindow_access_rule() {
|
||||
public function test_securewindow_access_rule() {
|
||||
$quiz = new stdClass();
|
||||
$quiz->popup = 1;
|
||||
$quiz->questions = '';
|
||||
|
@ -38,7 +38,7 @@ require_once($CFG->dirroot . '/mod/quiz/editlib.php');
|
||||
*/
|
||||
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 @@ class quiz_editlib_test extends UnitTestCase {
|
||||
$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 @@ class quiz_editlib_test extends UnitTestCase {
|
||||
$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 @@ class quiz_editlib_test extends UnitTestCase {
|
||||
$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 @@ class quiz_editlib_test extends UnitTestCase {
|
||||
$this->assertEqual(quiz_add_page_break_at('1,2,0', 3), '1,2,0');
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -36,7 +36,7 @@ require_once($CFG->dirroot . '/mod/quiz/lib.php');
|
||||
*/
|
||||
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 @@ class quiz_lib_test extends UnitTestCase {
|
||||
$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 @@ class quiz_lib_test extends UnitTestCase {
|
||||
$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;
|
||||
|
@ -38,7 +38,7 @@ require_once($CFG->dirroot . '/mod/quiz/locallib.php');
|
||||
*/
|
||||
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 @@ class quiz_locallib_test extends UnitTestCase {
|
||||
$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 @@ class quiz_locallib_test extends UnitTestCase {
|
||||
$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 @@ class quiz_locallib_test extends UnitTestCase {
|
||||
$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 @@ class quiz_locallib_test extends UnitTestCase {
|
||||
$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;
|
||||
|
@ -37,7 +37,7 @@ require_once($CFG->dirroot . '/mod/quiz/locallib.php');
|
||||
* @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;
|
||||
|
@ -322,7 +322,7 @@ abstract class question_behaviour {
|
||||
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
|
||||
|
@ -38,7 +38,7 @@ require_once($CFG->libdir.'/formslib.php');
|
||||
*/
|
||||
class question_category_edit_form extends moodleform {
|
||||
|
||||
function definition() {
|
||||
protected function definition() {
|
||||
global $CFG, $DB;
|
||||
$mform = $this->_form;
|
||||
|
||||
|
@ -193,7 +193,7 @@ abstract class question_bank_column_base {
|
||||
* @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 @@ abstract class question_bank_column_base {
|
||||
* @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 @@ abstract class question_bank_column_base {
|
||||
* @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 "</td>\n";
|
||||
|
@ -601,7 +601,7 @@ abstract class question_flags {
|
||||
* @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 @@ class question_attempt {
|
||||
* @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);
|
||||
}
|
||||
|
||||
|
@ -44,7 +44,7 @@ class question_bank_test extends UnitTestCase {
|
||||
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';
|
||||
|
@ -38,7 +38,7 @@ require_once($CFG->libdir . '/formslib.php');
|
||||
*/
|
||||
class question_export_form extends moodleform {
|
||||
|
||||
function definition() {
|
||||
protected function definition() {
|
||||
$mform = $this->_form;
|
||||
|
||||
$defaultcategory = $this->_customdata['defaultcategory'];
|
||||
|
@ -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 @@ class qformat_default {
|
||||
* @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 @@ class qformat_default {
|
||||
* 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 @@ class qformat_default {
|
||||
* 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 @@ class qformat_default {
|
||||
* 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 @@ class qformat_default {
|
||||
* 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 @@ class qformat_default {
|
||||
* 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 @@ class qformat_default {
|
||||
* (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 @@ class qformat_default {
|
||||
* set matchgrades
|
||||
* @param string matchgrades error or nearest for grades
|
||||
*/
|
||||
function setMatchgrades($matchgrades) {
|
||||
public function setMatchgrades($matchgrades) {
|
||||
$this->matchgrades = $matchgrades;
|
||||
}
|
||||
|
||||
@ -153,7 +153,7 @@ class qformat_default {
|
||||
* 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 @@ class qformat_default {
|
||||
* 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 @@ class qformat_default {
|
||||
* set cattofile
|
||||
* @param bool cattofile exports categories within export file
|
||||
*/
|
||||
function setCattofile($cattofile) {
|
||||
public function setCattofile($cattofile) {
|
||||
$this->cattofile = $cattofile;
|
||||
}
|
||||
|
||||
@ -177,7 +177,7 @@ class qformat_default {
|
||||
* set contexttofile
|
||||
* @param bool cattofile exports categories within export file
|
||||
*/
|
||||
function setContexttofile($contexttofile) {
|
||||
public function setContexttofile($contexttofile) {
|
||||
$this->contexttofile = $contexttofile;
|
||||
}
|
||||
|
||||
@ -185,7 +185,7 @@ class qformat_default {
|
||||
* 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 @@ class qformat_default {
|
||||
* @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 @@ class qformat_default {
|
||||
/**
|
||||
* Handle parsing error
|
||||
*/
|
||||
function error($message, $text='', $questionname='') {
|
||||
protected function error($message, $text='', $questionname='') {
|
||||
$importerrorquestion = get_string('importerrorquestion', 'question');
|
||||
|
||||
echo "<div class=\"importerror\">\n";
|
||||
@ -228,7 +228,7 @@ class qformat_default {
|
||||
* @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 @@ class qformat_default {
|
||||
* Perform any required pre-processing
|
||||
* @return bool success
|
||||
*/
|
||||
function importpreprocess() {
|
||||
protected function importpreprocess() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -272,7 +272,7 @@ class qformat_default {
|
||||
* @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 @@ class qformat_default {
|
||||
* @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 @@ class qformat_default {
|
||||
* @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 @@ class qformat_default {
|
||||
* @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 @@ class qformat_default {
|
||||
* @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 @@ class qformat_default {
|
||||
* 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 @@ class qformat_default {
|
||||
* @param $lines mixed data that represents question
|
||||
* @return object question object
|
||||
*/
|
||||
function readquestion($lines) {
|
||||
protected function readquestion($lines) {
|
||||
|
||||
$formatnotimplemented = get_string('formatnotimplemented', 'question');
|
||||
echo "<p>$formatnotimplemented</p>";
|
||||
@ -610,7 +610,7 @@ class qformat_default {
|
||||
* Override if any post-processing is required
|
||||
* @return bool success
|
||||
*/
|
||||
function importpostprocess() {
|
||||
protected function importpostprocess() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -627,7 +627,7 @@ class qformat_default {
|
||||
* @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 @@ class qformat_default {
|
||||
* Do any pre-processing that may be required
|
||||
* @param bool success
|
||||
*/
|
||||
function exportpreprocess() {
|
||||
public function exportpreprocess() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -654,7 +654,7 @@ class qformat_default {
|
||||
* @param string output text
|
||||
* @param string processed output text
|
||||
*/
|
||||
function presave_process($content) {
|
||||
protected function presave_process($content) {
|
||||
return $content;
|
||||
}
|
||||
|
||||
@ -663,7 +663,7 @@ class qformat_default {
|
||||
* 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 @@ class qformat_default {
|
||||
* @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 @@ class qformat_default {
|
||||
* Do an post-processing that may be required
|
||||
* @return bool success
|
||||
*/
|
||||
function exportpostprocess() {
|
||||
protected function exportpostprocess() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -831,7 +831,7 @@ class qformat_default {
|
||||
* @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 "<p>$formatnotimplemented</p>";
|
||||
@ -842,7 +842,7 @@ class qformat_default {
|
||||
* 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 @@ class qformat_default {
|
||||
* @param string encoding method
|
||||
* @return string $string
|
||||
*/
|
||||
function writefiles($files, $encoding='base64') {
|
||||
protected function writefiles($files, $encoding='base64') {
|
||||
if (empty($files)) {
|
||||
return '';
|
||||
}
|
||||
|
@ -55,11 +55,11 @@ defined('MOODLE_INTERNAL') || die();
|
||||
*/
|
||||
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 @@ class qformat_aiken extends qformat_default {
|
||||
return $questions;
|
||||
}
|
||||
|
||||
function readquestion($lines) {
|
||||
public function readquestion($lines) {
|
||||
//this is no longer needed but might still be called by default.php
|
||||
return;
|
||||
}
|
||||
|
@ -38,379 +38,371 @@ require_once ($CFG->libdir . '/xmlize.php');
|
||||
*/
|
||||
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) {
|
||||
|
||||
$question = $this->defaultquestion();
|
||||
|
||||
$question->qtype = ESSAY;
|
||||
|
||||
// determine if the question is already escaped html
|
||||
$ishtml = $essayquestion["#"]["BODY"][0]["#"]["FLAGS"][0]["#"]["ISHTML"][0]["@"]["value"];
|
||||
|
||||
// put questiontext in question object
|
||||
if ($ishtml) {
|
||||
$question->questiontext = html_entity_decode(trim($essayquestion["#"]["BODY"][0]["#"]["TEXT"][0]["#"]));
|
||||
if (isset($xml["POOL"]["#"]["QUESTION_ESSAY"])) {
|
||||
$essayquestions = $xml["POOL"]["#"]["QUESTION_ESSAY"];
|
||||
}
|
||||
else {
|
||||
return;
|
||||
}
|
||||
|
||||
// put name in question object
|
||||
$question->name = substr($question->questiontext, 0, 254);
|
||||
$question->answer = '';
|
||||
$question->feedback = '';
|
||||
$question->fraction = 0;
|
||||
foreach ($essayquestions as $essayquestion) {
|
||||
|
||||
$questions[] = $question;
|
||||
}
|
||||
}
|
||||
$question = $this->defaultquestion();
|
||||
|
||||
//----------------------------------------
|
||||
// Process True / False Questions
|
||||
//----------------------------------------
|
||||
function process_tf($xml, &$questions) {
|
||||
$question->qtype = ESSAY;
|
||||
|
||||
if (isset($xml["POOL"]["#"]["QUESTION_TRUEFALSE"])) {
|
||||
$tfquestions = $xml["POOL"]["#"]["QUESTION_TRUEFALSE"];
|
||||
}
|
||||
else {
|
||||
return;
|
||||
}
|
||||
// determine if the question is already escaped html
|
||||
$ishtml = $essayquestion["#"]["BODY"][0]["#"]["FLAGS"][0]["#"]["ISHTML"][0]["@"]["value"];
|
||||
|
||||
for ($i = 0; $i < sizeof ($tfquestions); $i++) {
|
||||
|
||||
$question = $this->defaultquestion();
|
||||
|
||||
$question->qtype = TRUEFALSE;
|
||||
$question->single = 1; // Only one answer is allowed
|
||||
|
||||
$thisquestion = $tfquestions[$i];
|
||||
|
||||
// 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 in question object
|
||||
$question->name = shorten_text($question->questiontext, 254);
|
||||
|
||||
$choices = $thisquestion["#"]["ANSWER"];
|
||||
|
||||
$correct_answer = $thisquestion["#"]["GRADABLE"][0]["#"]["CORRECTANSWER"][0]["@"]["answer_id"];
|
||||
|
||||
// first choice is true, second is false.
|
||||
$id = $choices[0]["@"]["id"];
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------
|
||||
// Process Multiple Choice Questions
|
||||
//----------------------------------------
|
||||
function process_mc($xml, &$questions) {
|
||||
|
||||
if (isset($xml["POOL"]["#"]["QUESTION_MULTIPLECHOICE"])) {
|
||||
$mcquestions = $xml["POOL"]["#"]["QUESTION_MULTIPLECHOICE"];
|
||||
}
|
||||
else {
|
||||
return;
|
||||
}
|
||||
|
||||
for ($i = 0; $i < sizeof ($mcquestions); $i++) {
|
||||
|
||||
$question = $this->defaultquestion();
|
||||
|
||||
$question->qtype = MULTICHOICE;
|
||||
$question->single = 1; // Only one answer is allowed
|
||||
|
||||
$thisquestion = $mcquestions[$i];
|
||||
|
||||
// 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, careful of length
|
||||
$question->name = shorten_text($question->questiontext, 254);
|
||||
|
||||
$choices = $thisquestion["#"]["ANSWER"];
|
||||
for ($j = 0; $j < sizeof ($choices); $j++) {
|
||||
|
||||
$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($essayquestion["#"]["BODY"][0]["#"]["TEXT"][0]["#"]));
|
||||
}
|
||||
$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];
|
||||
// put name in question object
|
||||
$question->name = substr($question->questiontext, 0, 254);
|
||||
$question->answer = '';
|
||||
$question->feedback = '';
|
||||
$question->fraction = 0;
|
||||
|
||||
$questions[] = $question;
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------
|
||||
// Process True / False Questions
|
||||
//----------------------------------------
|
||||
function process_tf($xml, &$questions) {
|
||||
|
||||
if (isset($xml["POOL"]["#"]["QUESTION_TRUEFALSE"])) {
|
||||
$tfquestions = $xml["POOL"]["#"]["QUESTION_TRUEFALSE"];
|
||||
}
|
||||
else {
|
||||
return;
|
||||
}
|
||||
|
||||
for ($i = 0; $i < sizeof ($tfquestions); $i++) {
|
||||
|
||||
$question = $this->defaultquestion();
|
||||
|
||||
$question->qtype = TRUEFALSE;
|
||||
$question->single = 1; // Only one answer is allowed
|
||||
|
||||
$thisquestion = $tfquestions[$i];
|
||||
|
||||
// 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 in question object
|
||||
$question->name = shorten_text($question->questiontext, 254);
|
||||
|
||||
$choices = $thisquestion["#"]["ANSWER"];
|
||||
|
||||
$correct_answer = $thisquestion["#"]["GRADABLE"][0]["#"]["CORRECTANSWER"][0]["@"]["answer_id"];
|
||||
|
||||
// first choice is true, second is false.
|
||||
$id = $choices[0]["@"]["id"];
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------
|
||||
// Process Multiple Choice Questions
|
||||
//----------------------------------------
|
||||
function process_mc($xml, &$questions) {
|
||||
|
||||
if (isset($xml["POOL"]["#"]["QUESTION_MULTIPLECHOICE"])) {
|
||||
$mcquestions = $xml["POOL"]["#"]["QUESTION_MULTIPLECHOICE"];
|
||||
}
|
||||
$questions[] = $question;
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------
|
||||
// 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;
|
||||
}
|
||||
|
||||
for ($i = 0; $i < sizeof ($maquestions); $i++) {
|
||||
|
||||
$question = $this->defaultquestion();
|
||||
|
||||
$question->qtype = MULTICHOICE;
|
||||
$question->defaultmark = 1;
|
||||
$question->single = 0; // More than one answers allowed
|
||||
$question->image = ""; // No images with this format
|
||||
|
||||
$thisquestion = $maquestions[$i];
|
||||
|
||||
// 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');
|
||||
else {
|
||||
return;
|
||||
}
|
||||
$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"];
|
||||
for ($i = 0; $i < sizeof ($mcquestions); $i++) {
|
||||
|
||||
for ($j = 0; $j < sizeof ($choices); $j++) {
|
||||
$question = $this->defaultquestion();
|
||||
|
||||
$choice = trim($choices[$j]["#"]["TEXT"][0]["#"]);
|
||||
// put this choice in the question object.
|
||||
$question->answer[$j] = $choice;
|
||||
$question->qtype = MULTICHOICE;
|
||||
$question->single = 1; // Only one answer is allowed
|
||||
|
||||
$correctanswercount = sizeof($correctanswers);
|
||||
$id = $choices[$j]["@"]["id"];
|
||||
$iscorrect = 0;
|
||||
for ($k = 0; $k < $correctanswercount; $k++) {
|
||||
$thisquestion = $mcquestions[$i];
|
||||
|
||||
$correct_answer_id = trim($correctanswers[$k]["@"]["answer_id"]);
|
||||
// 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, careful of length
|
||||
$question->name = shorten_text($question->questiontext, 254);
|
||||
|
||||
$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->answer[$j] = html_entity_decode($choice,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) {
|
||||
$iscorrect = 1;
|
||||
$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];
|
||||
}
|
||||
|
||||
}
|
||||
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) {
|
||||
|
||||
if (isset($xml["POOL"]["#"]["QUESTION_FILLINBLANK"])) {
|
||||
$fibquestions = $xml["POOL"]["#"]["QUESTION_FILLINBLANK"];
|
||||
}
|
||||
else {
|
||||
return;
|
||||
}
|
||||
|
||||
for ($i = 0; $i < sizeof ($fibquestions); $i++) {
|
||||
$question = $this->defaultquestion();
|
||||
//----------------------------------------
|
||||
// Process Multiple Choice Questions With Multiple Answers
|
||||
//----------------------------------------
|
||||
function process_ma($xml, &$questions) {
|
||||
|
||||
$question->qtype = SHORTANSWER;
|
||||
$question->usecase = 0; // Ignore case
|
||||
|
||||
$thisquestion = $fibquestions[$i];
|
||||
|
||||
// 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);
|
||||
|
||||
$answer = trim($thisquestion["#"]["ANSWER"][0]["#"]["TEXT"][0]["#"]);
|
||||
|
||||
$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]["#"]);
|
||||
if (isset($xml["POOL"]["#"]["QUESTION_MULTIPLEANSWER"])) {
|
||||
$maquestions = $xml["POOL"]["#"]["QUESTION_MULTIPLEANSWER"];
|
||||
}
|
||||
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] = '';
|
||||
return;
|
||||
}
|
||||
|
||||
$questions[] = $question;
|
||||
}
|
||||
}
|
||||
for ($i = 0; $i < sizeof ($maquestions); $i++) {
|
||||
|
||||
//----------------------------------------
|
||||
// Process Matching Questions
|
||||
//----------------------------------------
|
||||
function process_matching($xml, &$questions) {
|
||||
$question = $this->defaultquestion();
|
||||
|
||||
if (isset($xml["POOL"]["#"]["QUESTION_MATCH"])) {
|
||||
$matchquestions = $xml["POOL"]["#"]["QUESTION_MATCH"];
|
||||
}
|
||||
else {
|
||||
return;
|
||||
}
|
||||
$question->qtype = MULTICHOICE;
|
||||
$question->defaultmark = 1;
|
||||
$question->single = 0; // More than one answers allowed
|
||||
$question->image = ""; // No images with this format
|
||||
|
||||
for ($i = 0; $i < sizeof ($matchquestions); $i++) {
|
||||
$thisquestion = $maquestions[$i];
|
||||
|
||||
$question = $this->defaultquestion();
|
||||
// determine if the question is already escaped html
|
||||
$ishtml = $thisquestion["#"]["BODY"][0]["#"]["FLAGS"][0]["#"]["ISHTML"][0]["@"]["value"];
|
||||
|
||||
$question->qtype = MATCH;
|
||||
|
||||
$thisquestion = $matchquestions[$i];
|
||||
|
||||
// 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);
|
||||
|
||||
$choices = $thisquestion["#"]["CHOICE"];
|
||||
for ($j = 0; $j < sizeof ($choices); $j++) {
|
||||
|
||||
$subquestion = NULL;
|
||||
|
||||
$choice = $choices[$j]["#"]["TEXT"][0]["#"];
|
||||
$choice_id = $choices[$j]["@"]["id"];
|
||||
|
||||
$question->subanswers[] = trim($choice);
|
||||
// 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"];
|
||||
for ($k = 0; $k < sizeof ($correctanswers); $k++) {
|
||||
|
||||
if (strcmp($choice_id, $correctanswers[$k]["@"]["choice_id"]) == 0) {
|
||||
for ($j = 0; $j < sizeof ($choices); $j++) {
|
||||
|
||||
$answer_id = $correctanswers[$k]["@"]["answer_id"];
|
||||
$choice = trim($choices[$j]["#"]["TEXT"][0]["#"]);
|
||||
// put this choice in the question object.
|
||||
$question->answer[$j] = $choice;
|
||||
|
||||
$answers = $thisquestion["#"]["ANSWER"];
|
||||
for ($m = 0; $m < sizeof ($answers); $m++) {
|
||||
|
||||
$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;
|
||||
|
||||
}
|
||||
$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;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------
|
||||
// Process Fill in the Blank Questions
|
||||
//----------------------------------------
|
||||
function process_fib($xml, &$questions) {
|
||||
|
||||
if (isset($xml["POOL"]["#"]["QUESTION_FILLINBLANK"])) {
|
||||
$fibquestions = $xml["POOL"]["#"]["QUESTION_FILLINBLANK"];
|
||||
}
|
||||
else {
|
||||
return;
|
||||
}
|
||||
|
||||
$questions[] = $question;
|
||||
for ($i = 0; $i < sizeof ($fibquestions); $i++) {
|
||||
$question = $this->defaultquestion();
|
||||
|
||||
$question->qtype = SHORTANSWER;
|
||||
$question->usecase = 0; // Ignore case
|
||||
|
||||
$thisquestion = $fibquestions[$i];
|
||||
|
||||
// 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);
|
||||
|
||||
$answer = trim($thisquestion["#"]["ANSWER"][0]["#"]["TEXT"][0]["#"]);
|
||||
|
||||
$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] = '';
|
||||
}
|
||||
|
||||
$questions[] = $question;
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------
|
||||
// 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++) {
|
||||
|
||||
$question = $this->defaultquestion();
|
||||
|
||||
$question->qtype = MATCH;
|
||||
|
||||
$thisquestion = $matchquestions[$i];
|
||||
|
||||
// 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);
|
||||
|
||||
$choices = $thisquestion["#"]["CHOICE"];
|
||||
for ($j = 0; $j < sizeof ($choices); $j++) {
|
||||
|
||||
$subquestion = NULL;
|
||||
|
||||
$choice = $choices[$j]["#"]["TEXT"][0]["#"];
|
||||
$choice_id = $choices[$j]["@"]["id"];
|
||||
|
||||
$question->subanswers[] = trim($choice);
|
||||
|
||||
$correctanswers = $thisquestion["#"]["GRADABLE"][0]["#"]["CORRECTANSWER"];
|
||||
for ($k = 0; $k < sizeof ($correctanswers); $k++) {
|
||||
|
||||
if (strcmp($choice_id, $correctanswers[$k]["@"]["choice_id"]) == 0) {
|
||||
|
||||
$answer_id = $correctanswers[$k]["@"]["answer_id"];
|
||||
|
||||
$answers = $thisquestion["#"]["ANSWER"];
|
||||
for ($m = 0; $m < sizeof ($answers); $m++) {
|
||||
|
||||
$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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$questions[] = $question;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -63,19 +63,19 @@ defined('MOODLE_INTERNAL') || die();
|
||||
*/
|
||||
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 @@ class qformat_gift extends qformat_default {
|
||||
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 @@ class qformat_gift extends qformat_default {
|
||||
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 @@ class qformat_gift extends qformat_default {
|
||||
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 @@ class qformat_gift extends qformat_default {
|
||||
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 @@ class qformat_gift extends qformat_default {
|
||||
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 @@ class qformat_gift extends qformat_default {
|
||||
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 @@ class qformat_gift extends qformat_default {
|
||||
|
||||
}
|
||||
|
||||
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 @@ class qformat_gift extends qformat_default {
|
||||
* @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 @@ class qformat_gift extends qformat_default {
|
||||
* @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 @@ class qformat_gift extends qformat_default {
|
||||
return $output;
|
||||
}
|
||||
|
||||
function writequestion($question) {
|
||||
public function writequestion($question) {
|
||||
global $OUTPUT;
|
||||
|
||||
// Start with a comment
|
||||
|
@ -37,11 +37,11 @@ defined('MOODLE_INTERNAL') || die();
|
||||
*/
|
||||
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
|
||||
|
@ -139,7 +139,7 @@ class qformat_qti_two extends qformat_default {
|
||||
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 handle_questions_media(&$questions, $path, $courseid) {
|
||||
$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);
|
||||
}
|
||||
|
||||
|
@ -38,144 +38,142 @@ defined('MOODLE_INTERNAL') || die();
|
||||
*/
|
||||
class qformat_xhtml extends qformat_default {
|
||||
|
||||
function provide_export() {
|
||||
return true;
|
||||
public function provide_export() {
|
||||
return true;
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
// if a category switch, just ignore
|
||||
if ($question->qtype=='category') {
|
||||
return '';
|
||||
protected function repchar($text) {
|
||||
return $text;
|
||||
}
|
||||
|
||||
// initial string;
|
||||
$expout = "";
|
||||
$id = $question->id;
|
||||
protected function writequestion($question) {
|
||||
global $OUTPUT;
|
||||
// turns question into string
|
||||
// question reflects database fields for general question and specific to type
|
||||
|
||||
// add comment and div tags
|
||||
$expout .= "<!-- question: $id name: $question->name -->\n";
|
||||
$expout .= "<div class=\"question\">\n";
|
||||
// if a category switch, just ignore
|
||||
if ($question->qtype=='category') {
|
||||
return '';
|
||||
}
|
||||
|
||||
// add header
|
||||
$expout .= "<h3>$question->name</h3>\n";
|
||||
// initial string;
|
||||
$expout = "";
|
||||
$id = $question->id;
|
||||
|
||||
// Format and add the question text
|
||||
$expout .= '<p class="questiontext">' . format_text($question->questiontext,
|
||||
$question->questiontextformat) . "</p>\n";
|
||||
// add comment and div tags
|
||||
$expout .= "<!-- question: $id name: $question->name -->\n";
|
||||
$expout .= "<div class=\"question\">\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 .= "<ul class=\"truefalse\">\n";
|
||||
$expout .= " <li><input name=\"quest_$id\" type=\"radio\" value=\"$st_true\" />$st_true</li>\n";
|
||||
$expout .= " <li><input name=\"quest_$id\" type=\"radio\" value=\"$st_false\" />$st_false</li>\n";
|
||||
$expout .= "</ul>\n";
|
||||
break;
|
||||
case MULTICHOICE:
|
||||
$expout .= "<ul class=\"multichoice\">\n";
|
||||
foreach($question->options->answers as $answer) {
|
||||
$ans_text = $this->repchar( $answer->answer );
|
||||
if ($question->options->single) {
|
||||
$expout .= " <li><input name=\"quest_$id\" type=\"radio\" value=\"" . s($ans_text) . "\" />$ans_text</li>\n";
|
||||
// add header
|
||||
$expout .= "<h3>$question->name</h3>\n";
|
||||
|
||||
// Format and add the question text
|
||||
$expout .= '<p class="questiontext">' . format_text($question->questiontext,
|
||||
$question->questiontextformat) . "</p>\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 .= "<ul class=\"truefalse\">\n";
|
||||
$expout .= " <li><input name=\"quest_$id\" type=\"radio\" value=\"$st_true\" />$st_true</li>\n";
|
||||
$expout .= " <li><input name=\"quest_$id\" type=\"radio\" value=\"$st_false\" />$st_false</li>\n";
|
||||
$expout .= "</ul>\n";
|
||||
break;
|
||||
case MULTICHOICE:
|
||||
$expout .= "<ul class=\"multichoice\">\n";
|
||||
foreach($question->options->answers as $answer) {
|
||||
$ans_text = $this->repchar( $answer->answer );
|
||||
if ($question->options->single) {
|
||||
$expout .= " <li><input name=\"quest_$id\" type=\"radio\" value=\"" . s($ans_text) . "\" />$ans_text</li>\n";
|
||||
}
|
||||
else {
|
||||
$expout .= " <li><input name=\"quest_$id\" type=\"checkbox\" value=\"" . s($ans_text) . "\" />$ans_text</li>\n";
|
||||
}
|
||||
}
|
||||
else {
|
||||
$expout .= " <li><input name=\"quest_$id\" type=\"checkbox\" value=\"" . s($ans_text) . "\" />$ans_text</li>\n";
|
||||
$expout .= "</ul>\n";
|
||||
break;
|
||||
case SHORTANSWER:
|
||||
$expout .= "<ul class=\"shortanswer\">\n";
|
||||
$expout .= " <li><input name=\"quest_$id\" type=\"text\" /></li>\n";
|
||||
$expout .= "</ul>\n";
|
||||
break;
|
||||
case NUMERICAL:
|
||||
$expout .= "<ul class=\"numerical\">\n";
|
||||
$expout .= " <li><input name=\"quest_$id\" type=\"text\" /></li>\n";
|
||||
$expout .= "</ul>\n";
|
||||
break;
|
||||
case MATCH:
|
||||
$expout .= "<ul class=\"match\">\n";
|
||||
|
||||
// build answer list
|
||||
$ans_list = array();
|
||||
foreach($question->options->subquestions as $subquestion) {
|
||||
$ans_list[] = $this->repchar( $subquestion->answertext );
|
||||
}
|
||||
}
|
||||
$expout .= "</ul>\n";
|
||||
break;
|
||||
case SHORTANSWER:
|
||||
$expout .= "<ul class=\"shortanswer\">\n";
|
||||
$expout .= " <li><input name=\"quest_$id\" type=\"text\" /></li>\n";
|
||||
$expout .= "</ul>\n";
|
||||
break;
|
||||
case NUMERICAL:
|
||||
$expout .= "<ul class=\"numerical\">\n";
|
||||
$expout .= " <li><input name=\"quest_$id\" type=\"text\" /></li>\n";
|
||||
$expout .= "</ul>\n";
|
||||
break;
|
||||
case MATCH:
|
||||
$expout .= "<ul class=\"match\">\n";
|
||||
shuffle( $ans_list ); // random display order
|
||||
|
||||
// build answer list
|
||||
$ans_list = array();
|
||||
foreach($question->options->subquestions as $subquestion) {
|
||||
$ans_list[] = $this->repchar( $subquestion->answertext );
|
||||
}
|
||||
shuffle( $ans_list ); // random display order
|
||||
// build drop down for answers
|
||||
$dropdown = "<select name=\"quest_$id\">\n";
|
||||
foreach($ans_list as $ans) {
|
||||
$dropdown .= "<option value=\"" . s($ans) . "\">" . s($ans) . "</option>\n";
|
||||
}
|
||||
$dropdown .= "</select>\n";
|
||||
|
||||
// build drop down for answers
|
||||
$dropdown = "<select name=\"quest_$id\">\n";
|
||||
foreach($ans_list as $ans) {
|
||||
$dropdown .= "<option value=\"" . s($ans) . "\">" . s($ans) . "</option>\n";
|
||||
// finally display
|
||||
foreach($question->options->subquestions as $subquestion) {
|
||||
$quest_text = $this->repchar( $subquestion->questiontext );
|
||||
$expout .= " <li>$quest_text</li>\n";
|
||||
$expout .= $dropdown;
|
||||
}
|
||||
$expout .= "</ul>\n";
|
||||
break;
|
||||
case DESCRIPTION:
|
||||
break;
|
||||
case MULTIANSWER:
|
||||
$expout .= "<!-- CLOZE type is not supported -->\n";
|
||||
break;
|
||||
default:
|
||||
echo $OUTPUT->notification("No handler for qtype $question->qtype for GIFT export" );
|
||||
}
|
||||
$dropdown .= "</select>\n";
|
||||
|
||||
// finally display
|
||||
foreach($question->options->subquestions as $subquestion) {
|
||||
$quest_text = $this->repchar( $subquestion->questiontext );
|
||||
$expout .= " <li>$quest_text</li>\n";
|
||||
$expout .= $dropdown;
|
||||
}
|
||||
$expout .= "</ul>\n";
|
||||
break;
|
||||
case DESCRIPTION:
|
||||
break;
|
||||
case MULTIANSWER:
|
||||
$expout .= "<!-- CLOZE type is not supported -->\n";
|
||||
break;
|
||||
default:
|
||||
echo $OUTPUT->notification("No handler for qtype $question->qtype for GIFT export" );
|
||||
// close off div
|
||||
$expout .= "</div>\n\n\n";
|
||||
return $expout;
|
||||
}
|
||||
|
||||
|
||||
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 = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"\n";
|
||||
$xp .= " \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n";
|
||||
$xp .= "<html xmlns=\"http://www.w3.org/1999/xhtml\">\n";
|
||||
$xp .= "<head>\n";
|
||||
$xp .= "<meta http-equiv=\"content-type\" content=\"text/html; charset=UTF-8\" />\n";
|
||||
$xp .= "<title>Moodle Quiz XHTML Export</title>\n";
|
||||
$xp .= $css;
|
||||
$xp .= "</head>\n";
|
||||
$xp .= "<body>\n";
|
||||
$xp .= "<form action=\"...REPLACE ME...\" method=\"post\">\n\n";
|
||||
$xp .= $content;
|
||||
$xp .= "<p class=\"submit\">\n";
|
||||
$xp .= " <input type=\"submit\" />\n";
|
||||
$xp .= "</p>\n";
|
||||
$xp .= "</form>\n";
|
||||
$xp .= "</body>\n";
|
||||
$xp .= "</html>\n";
|
||||
|
||||
return $xp;
|
||||
}
|
||||
|
||||
public function export_file_extension() {
|
||||
return '.html';
|
||||
}
|
||||
// close off div
|
||||
$expout .= "</div>\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 = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"\n";
|
||||
$xp .= " \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n";
|
||||
$xp .= "<html xmlns=\"http://www.w3.org/1999/xhtml\">\n";
|
||||
$xp .= "<head>\n";
|
||||
$xp .= "<meta http-equiv=\"content-type\" content=\"text/html; charset=UTF-8\" />\n";
|
||||
$xp .= "<title>Moodle Quiz XHTML Export</title>\n";
|
||||
$xp .= $css;
|
||||
$xp .= "</head>\n";
|
||||
$xp .= "<body>\n";
|
||||
$xp .= "<form action=\"...REPLACE ME...\" method=\"post\">\n\n";
|
||||
$xp .= $content;
|
||||
$xp .= "<p class=\"submit\">\n";
|
||||
$xp .= " <input type=\"submit\" />\n";
|
||||
$xp .= "</p>\n";
|
||||
$xp .= "</form>\n";
|
||||
$xp .= "</body>\n";
|
||||
$xp .= "</html>\n";
|
||||
|
||||
return $xp;
|
||||
}
|
||||
|
||||
function export_file_extension() {
|
||||
return ".html";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -41,15 +41,15 @@ require_once($CFG->libdir . '/xmlize.php');
|
||||
*/
|
||||
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 @@ class qformat_xml extends qformat_default {
|
||||
* @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 @@ class qformat_xml extends qformat_default {
|
||||
* @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 @@ class qformat_xml extends qformat_default {
|
||||
* @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 @@ class qformat_xml extends qformat_default {
|
||||
* @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 @@ class qformat_xml extends qformat_default {
|
||||
* @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 @@ class qformat_xml extends qformat_default {
|
||||
* @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 @@ class qformat_xml extends qformat_default {
|
||||
* @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 @@ class qformat_xml extends qformat_default {
|
||||
* @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 @@ class qformat_xml extends qformat_default {
|
||||
* @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 @@ class qformat_xml extends qformat_default {
|
||||
* @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 @@ class qformat_xml extends qformat_default {
|
||||
* @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 @@ class qformat_xml extends qformat_default {
|
||||
* @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 @@ class qformat_xml extends qformat_default {
|
||||
* @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 @@ class qformat_xml extends qformat_default {
|
||||
* @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 @@ class qformat_xml extends qformat_default {
|
||||
return $qo;
|
||||
}
|
||||
|
||||
function import_calculated($question, $qtype) {
|
||||
public function import_calculated($question, $qtype) {
|
||||
// import calculated question
|
||||
|
||||
// get common parts
|
||||
@ -823,7 +823,7 @@ class qformat_xml extends qformat_default {
|
||||
* <category>tom/dick/harry</category>
|
||||
* </question>
|
||||
*/
|
||||
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 @@ class qformat_xml extends qformat_default {
|
||||
* @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 @@ class qformat_xml extends qformat_default {
|
||||
|
||||
// EXPORT FUNCTIONS START HERE
|
||||
|
||||
function export_file_extension() {
|
||||
public function export_file_extension() {
|
||||
return '.xml';
|
||||
}
|
||||
|
||||
@ -909,7 +909,7 @@ class qformat_xml extends qformat_default {
|
||||
* @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 @@ class qformat_xml extends qformat_default {
|
||||
* @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 @@ class qformat_xml extends qformat_default {
|
||||
* @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 @@ class qformat_xml extends qformat_default {
|
||||
* @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 @@ class qformat_xml extends qformat_default {
|
||||
return $xml;
|
||||
}
|
||||
|
||||
function presave_process($content) {
|
||||
protected function presave_process($content) {
|
||||
// Override to allow us to add xml headers and footers
|
||||
return '<?xml version="1.0" encoding="UTF-8"?>
|
||||
<quiz>
|
||||
@ -1010,7 +1010,7 @@ class qformat_xml extends qformat_default {
|
||||
* @param object $question the question data.
|
||||
* @return string xml segment
|
||||
*/
|
||||
function writequestion($question) {
|
||||
public function writequestion($question) {
|
||||
global $CFG, $OUTPUT;
|
||||
|
||||
$fs = get_file_storage();
|
||||
|
@ -38,7 +38,7 @@ require_once($CFG->libdir . '/formslib.php');
|
||||
*/
|
||||
class question_import_form extends moodleform {
|
||||
|
||||
function definition() {
|
||||
protected function definition() {
|
||||
global $COURSE;
|
||||
$mform = $this->_form;
|
||||
|
||||
|
@ -37,7 +37,7 @@ require_once($CFG->libdir . '/formslib.php');
|
||||
* @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'];
|
||||
|
@ -66,7 +66,8 @@ class question_dataset_dependent_definitions_form extends moodleform {
|
||||
$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);
|
||||
|
@ -100,7 +100,7 @@ class question_dataset_dependent_items_form extends moodleform {
|
||||
}
|
||||
parent::moodleform($submiturl);
|
||||
}
|
||||
function definition() {
|
||||
protected function definition() {
|
||||
$labelsharedwildcard = get_string("sharedwildcard", "qtype_calculated");
|
||||
|
||||
$mform =& $this->_form;
|
||||
|
@ -106,7 +106,7 @@ class question_edit_calculated_form extends question_edit_form {
|
||||
*
|
||||
* @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');
|
||||
|
@ -103,7 +103,7 @@ class question_edit_calculatedmulti_form extends question_edit_form {
|
||||
*
|
||||
* @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
|
||||
|
@ -305,7 +305,7 @@ class question_edit_calculatedsimple_form extends question_edit_form {
|
||||
*
|
||||
* @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);
|
||||
|
@ -124,7 +124,7 @@ class restore_qtype_ddwtos_plugin extends restore_qtype_plugin {
|
||||
/**
|
||||
* 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();
|
||||
|
||||
|
@ -37,7 +37,7 @@ require_once($CFG->dirroot . '/question/type/gapselect/edit_form_base.php');
|
||||
* @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';
|
||||
}
|
||||
|
||||
|
@ -110,7 +110,7 @@ class qtype_ddwtos extends qtype_gapselect_base {
|
||||
return $question;
|
||||
}
|
||||
|
||||
function export_to_xml($question, $format, $extra = null) {
|
||||
public function export_to_xml($question, $format, $extra = null) {
|
||||
$output = '';
|
||||
|
||||
$output .= ' <shuffleanswers>' . $question->options->shuffleanswers . "</shuffleanswers>\n";
|
||||
|
@ -86,7 +86,7 @@ abstract class question_edit_form extends moodleform {
|
||||
* 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 @@ abstract class question_edit_form extends moodleform {
|
||||
*
|
||||
* @param array $question - array to fill in with the default values
|
||||
*/
|
||||
function data_preprocessing($question) {
|
||||
protected function data_preprocessing($question) {
|
||||
return $question;
|
||||
}
|
||||
|
||||
|
@ -39,7 +39,7 @@ class qtype_essay extends question_type {
|
||||
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);
|
||||
}
|
||||
|
@ -124,7 +124,7 @@ class restore_qtype_gapselect_plugin extends restore_qtype_plugin {
|
||||
/**
|
||||
* 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();
|
||||
|
||||
|
@ -92,7 +92,7 @@ class qtype_gapselect_edit_form_base extends question_edit_form {
|
||||
* 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 @@ class qtype_gapselect_edit_form_base extends question_edit_form {
|
||||
return false;
|
||||
}
|
||||
|
||||
function qtype() {
|
||||
public function qtype() {
|
||||
return '';
|
||||
}
|
||||
}
|
@ -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';
|
||||
}
|
||||
}
|
||||
|
@ -57,7 +57,7 @@ class qtype_gapselect extends qtype_gapselect_base {
|
||||
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 @@ class qtype_gapselect extends qtype_gapselect_base {
|
||||
return $question;
|
||||
}
|
||||
|
||||
function export_to_xml($question, $format, $extra = null) {
|
||||
public function export_to_xml($question, $format, $extra = null) {
|
||||
$output = '';
|
||||
|
||||
$output .= ' <shuffleanswers>' . $question->options->shuffleanswers . "</shuffleanswers>\n";
|
||||
|
@ -308,7 +308,7 @@ abstract class qtype_gapselect_base extends question_type {
|
||||
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();
|
||||
|
@ -177,7 +177,7 @@ class restore_qtype_match_plugin extends restore_qtype_plugin {
|
||||
/**
|
||||
* 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();
|
||||
|
||||
|
@ -36,7 +36,7 @@ defined('MOODLE_INTERNAL') || die();
|
||||
*/
|
||||
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 @@ class qtype_match_edit_form extends question_edit_form {
|
||||
$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 @@ class qtype_match_edit_form extends question_edit_form {
|
||||
return $errors;
|
||||
}
|
||||
|
||||
function qtype() {
|
||||
public function qtype() {
|
||||
return 'match';
|
||||
}
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ require_once($CFG->dirroot . '/question/engine/lib.php');
|
||||
*/
|
||||
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 @@ class qtype_match extends question_type {
|
||||
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 @@ class qtype_match extends question_type {
|
||||
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 @@ class qtype_match extends question_type {
|
||||
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 @@ class qtype_match extends question_type {
|
||||
return $subqs;
|
||||
}
|
||||
|
||||
function move_files($questionid, $oldcontextid, $newcontextid) {
|
||||
public function move_files($questionid, $oldcontextid, $newcontextid) {
|
||||
global $DB;
|
||||
$fs = get_file_storage();
|
||||
|
||||
|
@ -88,7 +88,7 @@ class qtype_missingtype extends question_type {
|
||||
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'));
|
||||
|
||||
|
@ -76,7 +76,7 @@ class question_edit_multianswer_form extends question_edit_form {
|
||||
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);
|
||||
|
@ -130,7 +130,7 @@ class restore_qtype_multichoice_plugin extends restore_qtype_plugin {
|
||||
/**
|
||||
* 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();
|
||||
|
||||
|
@ -63,7 +63,7 @@ class qtype_multichoice_edit_form extends question_edit_form {
|
||||
$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);
|
||||
|
@ -88,9 +88,9 @@ abstract class qtype_multichoice_base extends question_graded_automatically {
|
||||
}
|
||||
}
|
||||
|
||||
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,
|
||||
|
@ -193,7 +193,7 @@ class qtype_multichoice extends question_type {
|
||||
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 @@ class qtype_multichoice extends question_type {
|
||||
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);
|
||||
|
@ -36,22 +36,22 @@ defined('MOODLE_INTERNAL') || die();
|
||||
* @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) {
|
||||
|
@ -36,7 +36,7 @@ defined('MOODLE_INTERNAL') || die();
|
||||
*/
|
||||
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 @@ class question_edit_numerical_form extends question_edit_form {
|
||||
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 @@ class question_edit_numerical_form extends question_edit_form {
|
||||
return $question;
|
||||
}
|
||||
|
||||
function validation($data, $files) {
|
||||
public function validation($data, $files) {
|
||||
global $QTYPES;
|
||||
$errors = parent::validation($data, $files);
|
||||
|
||||
@ -131,7 +125,7 @@ class question_edit_numerical_form extends question_edit_form {
|
||||
return $errors;
|
||||
}
|
||||
|
||||
function qtype() {
|
||||
public function qtype() {
|
||||
return 'numerical';
|
||||
}
|
||||
}
|
||||
|
@ -1037,7 +1037,7 @@ class question_numerical_qtype extends qtype_shortanswer {
|
||||
* 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 @@ class question_numerical_qtype extends qtype_shortanswer {
|
||||
* 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}'));
|
||||
|
||||
|
@ -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 @@ class question_numerical_qtype_test extends UnitTestCase {
|
||||
$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 @@ class question_numerical_qtype_test extends UnitTestCase {
|
||||
$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() {
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
|
@ -38,7 +38,7 @@ include_once($CFG->libdir . '/validateurlsyntax.php');
|
||||
* @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'));
|
||||
|
@ -40,7 +40,7 @@ require_once(dirname(__FILE__) . '/locallib.php');
|
||||
* @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 @@ class qtype_opaque_edit_form extends question_edit_form {
|
||||
$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 @@ class qtype_opaque_edit_form extends question_edit_form {
|
||||
$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 @@ class qtype_opaque_edit_form extends question_edit_form {
|
||||
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 @@ class qtype_opaque_edit_form extends question_edit_form {
|
||||
return $data;
|
||||
}
|
||||
|
||||
function qtype() {
|
||||
public function qtype() {
|
||||
return 'opaque';
|
||||
}
|
||||
}
|
||||
|
@ -58,11 +58,11 @@ class qtype_opaque extends question_type {
|
||||
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 @@ class qtype_opaque extends question_type {
|
||||
return null;
|
||||
}
|
||||
|
||||
function export_to_xml($question, $format, $extra=null) {
|
||||
public function export_to_xml($question, $format, $extra=null) {
|
||||
$expout = '';
|
||||
$expout .= ' <remoteid>' . $question->options->remoteid . "</remoteid>\n";
|
||||
$expout .= ' <remoteversion>' . $question->options->remoteversion . "</remoteversion>\n";
|
||||
@ -99,7 +99,7 @@ class qtype_opaque extends question_type {
|
||||
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;
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ defined('MOODLE_INTERNAL') || die();
|
||||
* @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();
|
||||
|
@ -124,7 +124,7 @@ class restore_qtype_oumultiresponse_plugin extends restore_qtype_plugin {
|
||||
/**
|
||||
* 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();
|
||||
|
||||
|
@ -36,7 +36,7 @@ defined('MOODLE_INTERNAL') || die();
|
||||
*/
|
||||
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 @@ class qtype_oumultiresponse_edit_form extends question_edit_form {
|
||||
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);
|
||||
|
@ -164,7 +164,7 @@ class qtype_oumultiresponse_question extends qtype_multichoice_multi_question
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -311,7 +311,7 @@ class qtype_oumultiresponse extends question_type {
|
||||
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);
|
||||
|
@ -42,7 +42,7 @@ require_once($CFG->dirroot . '/question/type/oumultiresponse/simpletest/helper.p
|
||||
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 @@ class qtype_oumultiresponse_question_test extends UnitTestCase {
|
||||
$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();
|
||||
|
@ -527,7 +527,7 @@ interface question_automatically_gradable_with_countback extends question_automa
|
||||
*/
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
@ -318,7 +318,7 @@ class question_type {
|
||||
* 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 @@ class question_type {
|
||||
* @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 @@ class question_type {
|
||||
* @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 @@ class question_type {
|
||||
* @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 @@ class question_type {
|
||||
}
|
||||
}
|
||||
|
||||
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 @@ class question_type {
|
||||
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:
|
||||
|
@ -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();
|
||||
|
@ -114,7 +114,7 @@ class qtype_random extends question_type {
|
||||
$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 @@ class qtype_random extends question_type {
|
||||
return null;
|
||||
}
|
||||
|
||||
function get_random_guess_score($questiondata) {
|
||||
public function get_random_guess_score($questiondata) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -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 @@ class question_edit_randomsamatch_form extends question_edit_form {
|
||||
$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 @@ class question_edit_randomsamatch_form extends question_edit_form {
|
||||
return $question;
|
||||
}
|
||||
|
||||
function qtype() {
|
||||
public function qtype() {
|
||||
return 'randomsamatch';
|
||||
}
|
||||
|
||||
|
@ -205,7 +205,7 @@ abstract class qtype_renderer extends plugin_renderer_base {
|
||||
* @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) {
|
||||
|
@ -35,11 +35,7 @@ defined('MOODLE_INTERNAL') || die();
|
||||
* @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 @@ class qtype_shortanswer_edit_form extends question_edit_form {
|
||||
$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);
|
||||
|
@ -47,7 +47,7 @@ class qtype_shortanswer extends question_type {
|
||||
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);
|
||||
}
|
||||
|
@ -143,14 +143,14 @@ class qtype_truefalse extends question_type {
|
||||
$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 @@ class qtype_truefalse extends question_type {
|
||||
$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'),
|
||||
|
Loading…
x
Reference in New Issue
Block a user