From aeb15530b8a8bcda137a4de9fdaac716a8085db1 Mon Sep 17 00:00:00 2001 From: Petr Skoda Date: Wed, 4 Nov 2009 11:57:52 +0000 Subject: [PATCH] MDL-20700 coding style cleanup - cvs keywords removed, closign php tag removed, trailing whitespace cleanup --- mod/quiz/report/default.php | 22 +-- mod/quiz/report/grading/report.php | 12 +- mod/quiz/report/overview/db/upgrade.php | 4 +- mod/quiz/report/overview/overview_table.php | 6 +- mod/quiz/report/overview/overviewgraph.php | 4 +- .../report/overview/overviewsettings_form.php | 6 +- mod/quiz/report/overview/report.php | 67 ++++--- mod/quiz/report/overview/version.php | 4 +- mod/quiz/report/reportlib.php | 6 +- mod/quiz/report/responses/report.php | 68 +++---- mod/quiz/report/responses/responses_table.php | 10 +- .../responses/responsessettings_form.php | 3 +- mod/quiz/report/simpletest/testreportlib.php | 12 +- mod/quiz/report/statistics/cron.php | 4 +- mod/quiz/report/statistics/db/install.php | 2 +- mod/quiz/report/statistics/db/upgrade.php | 2 +- mod/quiz/report/statistics/qstats.php | 20 +- mod/quiz/report/statistics/report.php | 3 +- .../statistics/simpletest/test_qstats.php | 10 +- .../report/statistics/statistics_form.php | 4 +- .../report/statistics/statistics_graph.php | 8 +- .../statistics/statistics_question_table.php | 18 +- .../report/statistics/statistics_table.php | 34 ++-- mod/quiz/simpletest/testaccessrules.php | 2 +- mod/quiz/simpletest/testeditlib.php | 2 +- question/addquestion.php | 4 +- question/backuplib.php | 4 +- question/category.php | 4 +- question/category_class.php | 4 +- question/category_form.php | 4 +- question/category_form_randomquestion.php | 4 +- question/contextmove.php | 4 +- question/contextmove_form.php | 4 +- question/contextmoveq.php | 4 +- question/contextmoveq_form.php | 4 +- question/edit.php | 4 +- question/editlib.php | 6 +- question/export.php | 4 +- question/export_form.php | 10 +- question/exportfile.php | 4 +- question/format.php | 4 +- question/format/README.txt | 10 +- question/format/aiken/format.php | 6 +- question/format/blackboard/format.php | 38 ++-- question/format/blackboard_six/format.php | 182 +++++++++--------- question/format/examview/format.php | 4 +- question/format/gift/examples.txt | 12 +- question/format/gift/format.php | 72 +++---- question/format/hotpot/format.php | 10 +- question/format/learnwise/format.php | 18 +- question/format/missingword/format.php | 22 +-- question/format/multianswer/format.php | 6 +- question/format/qti_two/custommediafilter.php | 14 +- question/format/qti_two/format.php | 4 +- question/format/qti_two/qt_common.php | 22 +-- question/format/qti_two/templates/choice.tpl | 4 +- .../qti_two/templates/choiceMultiple.tpl | 6 +- .../format/qti_two/templates/composite.tpl | 4 +- .../format/qti_two/templates/extendedText.tpl | 2 +- .../templates/extendedText_simpleEssay.tpl | 2 +- .../format/qti_two/templates/imsmanifest.tpl | 4 +- question/format/qti_two/templates/match.tpl | 2 +- .../qti_two/templates/mmchoiceMultiple.tpl | 2 +- .../qti_two/templates/notimplemented.tpl | 2 +- .../format/qti_two/templates/numerical.tpl | 2 +- .../format/qti_two/templates/textEntry.tpl | 2 +- question/format/webct/format.php | 32 +-- question/format/xhtml/format.php | 18 +- question/format/xhtml/xhtml.css | 12 +- question/format/xml/format.php | 2 +- question/import.php | 4 +- question/import_form.php | 12 +- question/move_form.php | 4 +- question/preview.php | 4 +- question/question.php | 6 +- question/restorelib.php | 12 +- question/tabs.php | 4 +- question/toggleflag.php | 5 +- .../calculated/datasetdefinitions_form.php | 4 +- .../type/calculated/datasetitems_form.php | 28 +-- question/type/calculated/db/upgrade.php | 10 +- .../type/calculated/edit_calculated_form.php | 60 +++--- question/type/calculated/questiontype.php | 106 +++++----- question/type/calculated/version.php | 4 +- .../edit_calculatedsimple_form.php | 154 +++++++-------- .../type/calculatedsimple/questiontype.php | 10 +- .../description/edit_description_form.php | 3 +- question/type/description/question.html | 2 +- question/type/description/questiontype.php | 4 +- question/type/edit_question_form.php | 4 +- question/type/essay/db/upgrade.php | 10 +- question/type/essay/edit_essay_form.php | 4 +- question/type/essay/questiontype.php | 4 +- question/type/essay/version.php | 4 +- question/type/match/db/upgrade.php | 10 +- question/type/match/edit_match_form.php | 3 +- question/type/match/questiontype.php | 10 +- question/type/match/version.php | 4 +- .../missingtype/edit_missingtype_form.php | 4 +- question/type/missingtype/questiontype.php | 4 +- question/type/multianswer/db/upgrade.php | 6 +- .../multianswer/edit_multianswer_form.php | 80 ++++---- question/type/multianswer/questiontype.php | 30 +-- question/type/multianswer/version.php | 4 +- question/type/multichoice/db/upgrade.php | 8 +- .../multichoice/edit_multichoice_form.php | 3 +- question/type/multichoice/questiontype.php | 6 +- question/type/multichoice/version.php | 4 +- question/type/numerical/db/upgrade.php | 8 +- question/type/numerical/display.html | 96 ++++----- .../type/numerical/edit_numerical_form.php | 5 +- question/type/numerical/questiontype.php | 69 ++++--- .../numerical/simpletest/testquestiontype.php | 4 +- question/type/numerical/version.php | 4 +- question/type/question.html | 4 +- question/type/questiontype.php | 4 +- question/type/random/edit_random_form.php | 5 +- question/type/random/questiontype.php | 6 +- question/type/randomsamatch/db/upgrade.php | 10 +- .../randomsamatch/edit_randomsamatch_form.php | 4 +- question/type/randomsamatch/questiontype.php | 10 +- question/type/randomsamatch/version.php | 4 +- question/type/shortanswer/db/upgrade.php | 10 +- question/type/shortanswer/display.html | 2 +- .../shortanswer/edit_shortanswer_form.php | 3 +- question/type/shortanswer/questiontype.php | 10 +- .../simpletest/testquestiontype.php | 4 +- question/type/shortanswer/version.php | 4 +- question/type/simpletest/testquestiontype.php | 4 +- question/type/truefalse/db/upgrade.php | 10 +- question/type/truefalse/display.html | 2 +- .../type/truefalse/edit_truefalse_form.php | 3 +- question/type/truefalse/questiontype.php | 4 +- question/type/truefalse/version.php | 4 +- question/upgrade.php | 4 +- theme/orangewhitepda/styles_pda.css | 2 - 136 files changed, 922 insertions(+), 936 deletions(-) diff --git a/mod/quiz/report/default.php b/mod/quiz/report/default.php index cda0d1a4978..4fd7cf9599f 100644 --- a/mod/quiz/report/default.php +++ b/mod/quiz/report/default.php @@ -1,15 +1,15 @@ -id" or q=$quiz->id", and "mode=reportname". //////////////////////////////////////////////////////////////////// @@ -30,17 +30,17 @@ class quiz_default_report { $PAGE->set_title(format_string($quiz->name)); $PAGE->set_button($OUTPUT->update_module_button($cm->id, 'quiz')); echo $OUTPUT->header(); - /// Print the tabs + /// Print the tabs $currenttab = 'reports'; $mode = $reportmode; require($CFG->dirroot . '/mod/quiz/tabs.php'); $course_context = get_context_instance(CONTEXT_COURSE, $course->id); if (has_capability('gradereport/grader:view', $course_context) && has_capability('moodle/grade:viewall', $course_context)) { - echo '
' + echo ''; } } } -?> + diff --git a/mod/quiz/report/grading/report.php b/mod/quiz/report/grading/report.php index 60993cf9b93..84fab2cba97 100644 --- a/mod/quiz/report/grading/report.php +++ b/mod/quiz/report/grading/report.php @@ -1,4 +1,4 @@ -id)))){ print_error('invalidattemptid', 'quiz_grading'); } - + // Load the state for this attempt (The questions array was created earlier) $states = get_question_states($questions, $quiz, $attempt); // The $states array is indexed by question id but because we are dealing // with only one question there is only one entry in this array $state = &$states[$question->id]; - + // the following will update the state and attempt $error = question_process_comment($question, $state, $attempt, $response['comment'], $response['grade']); if (is_string($error)) { @@ -205,7 +205,7 @@ class quiz_grading_report extends quiz_default_report { // our 2 different views - // the first view allows a user to select a question and + // the first view allows a user to select a question and // displays the users who have answered the essay question // and all of their attempts at answering the question @@ -456,7 +456,7 @@ class quiz_grading_report extends quiz_default_report { $where = "WHERE u.id $usql "; $params = array_merge($params, $u_params); } - + $where .= ' AND qs.event IN ('.QUESTION_EVENTS_CLOSED_OR_GRADED.')'; $where .= ' AND u.id = qa.userid AND qa.quiz = ?'; @@ -471,4 +471,4 @@ class quiz_grading_report extends quiz_default_report { } -?> + diff --git a/mod/quiz/report/overview/db/upgrade.php b/mod/quiz/report/overview/db/upgrade.php index 6c6ccaf4c3d..45c6c8b9392 100644 --- a/mod/quiz/report/overview/db/upgrade.php +++ b/mod/quiz/report/overview/db/upgrade.php @@ -1,4 +1,4 @@ - + diff --git a/mod/quiz/report/overview/overview_table.php b/mod/quiz/report/overview/overview_table.php index cf3420c02b5..1bad73b924a 100644 --- a/mod/quiz/report/overview/overview_table.php +++ b/mod/quiz/report/overview/overview_table.php @@ -1,4 +1,4 @@ -attempt&question=$question->id", $grade); $link->add_action(new popup_action('click', $link->url, 'reviewquestion', array('height' => 450, 'width' => 650))); $link->title = get_string('reviewresponsetoq', 'quiz', $question->formattedname); - $linktopopup = $OUTPUT->link($link); + $linktopopup = $OUTPUT->link($link); if (($this->questions[$questionid]->maxgrade != 0)){ $fractionofgrade = $stateforqinattempt->grade @@ -331,4 +331,4 @@ class quiz_report_overview_table extends table_sql { } } } -?> + diff --git a/mod/quiz/report/overview/overviewgraph.php b/mod/quiz/report/overview/overviewgraph.php index 6b9abb930b9..9fb13b66abb 100644 --- a/mod/quiz/report/overview/overviewgraph.php +++ b/mod/quiz/report/overview/overviewgraph.php @@ -1,4 +1,4 @@ -dirroot."/lib/graphlib.php"; include $CFG->dirroot."/mod/quiz/report/reportlib.php"; @@ -96,4 +96,4 @@ while ($gridlines >= 10){ $line->parameter['y_axis_gridlines'] = $gridlines+1; $line->draw(); -?> + diff --git a/mod/quiz/report/overview/overviewsettings_form.php b/mod/quiz/report/overview/overviewsettings_form.php index ed2690a64f3..7e9e1ad555e 100644 --- a/mod/quiz/report/overview/overviewsettings_form.php +++ b/mod/quiz/report/overview/overviewsettings_form.php @@ -1,4 +1,4 @@ -libdir/formslib.php"; class mod_quiz_report_overview_settings extends moodleform { @@ -42,7 +42,7 @@ class mod_quiz_report_overview_settings extends moodleform { } if ($showattemptsgrp){ $mform->addGroup($showattemptsgrp, null, get_string('showattempts', 'quiz_overview'), '
', false); - } + } //------------------------------------------------------------------------------- $mform->addElement('header', 'preferencesuser', get_string('preferencesuser', 'quiz_overview')); @@ -54,4 +54,4 @@ class mod_quiz_report_overview_settings extends moodleform { $this->add_action_buttons(false, get_string('preferencessave', 'quiz_overview')); } } -?> + diff --git a/mod/quiz/report/overview/report.php b/mod/quiz/report/overview/report.php index 2f21b1b7a7a..2fb9174b042 100644 --- a/mod/quiz/report/overview/report.php +++ b/mod/quiz/report/overview/report.php @@ -2,7 +2,6 @@ /** * This script lists student attempts * - * @version $Id$ * @author Martin Dougiamas, Tim Hunt and others. * @license http://www.gnu.org/copyleft/gpl.html GNU Public License * @package quiz @@ -32,7 +31,7 @@ class quiz_overview_report extends quiz_default_report { $showgrades = quiz_has_grades($quiz) && $reviewoptions->scores; $download = optional_param('download', '', PARAM_ALPHA); - + /// find out current groups mode $currentgroup = groups_get_activity_group($cm, true); if (!$students = get_users_by_capability($this->context, array('mod/quiz:reviewmyattempts', 'mod/quiz:attempt'),'','','','','','',false)){ @@ -54,7 +53,7 @@ class quiz_overview_report extends quiz_default_report { } $allowed = $groupstudents; } - + if (empty($currentgroup)||$groupstudents) { if (optional_param('delete', 0, PARAM_BOOL)){ if($attemptids = optional_param('attemptid', array(), PARAM_INT)) { @@ -129,7 +128,7 @@ class quiz_overview_report extends quiz_default_report { } else if ($attemptsmode === null){ //default $attemptsmode = QUIZ_REPORT_ATTEMPTS_ALL; - } + } if (!$reviewoptions->scores) { $detailedmarks = 0; } @@ -162,7 +161,7 @@ class quiz_overview_report extends quiz_default_report { // Only print headers if not asked to download data $this->print_header_and_tabs($cm, $course, $quiz, "overview"); } - + if ($regradeall){ $this->regrade_all(false, $quiz, $groupstudents); } else if ($regradealldry){ @@ -173,14 +172,14 @@ class quiz_overview_report extends quiz_default_report { if ($regradeall || $regradealldry || $regradealldrydo){ redirect($reporturl->out(false, $displayoptions, false), '', 5); } - + if ($groupmode = groups_get_activity_groupmode($cm)) { // Groups are being used if (!$table->is_downloading()) { groups_print_activity_menu($cm, $reporturl->out(false, $displayoptions)); } } - + // Print information on the number of existing attempts if (!$table->is_downloading()) { //do not print notices when downloading if ($strattemptnum = quiz_num_attempt_summary($quiz, $cm, true, $currentgroup)) { @@ -200,14 +199,14 @@ class quiz_overview_report extends quiz_default_report { $mform->set_data($displayoptions +compact('detailedmarks', 'pagesize')); $mform->display(); } - - + + if (!$nostudents || ($attemptsmode == QUIZ_REPORT_ATTEMPTS_ALL)){ - - - + + + // Construct the SQL $fields = $DB->sql_concat('u.id', '\'#\'', 'COALESCE(qa.attempt, \'0\')').' AS uniqueid, '; if ($qmsubselect) { @@ -217,7 +216,7 @@ class quiz_overview_report extends quiz_default_report { " ELSE 0 " . "END) AS gradedattempt, "; } - + $fields .='qa.uniqueid AS attemptuniqueid, qa.id AS attempt, ' . 'u.id AS userid, u.idnumber, u.firstname, u.lastname, u.picture, u.imagealt, '. 'qa.sumgrades, qa.timefinish, qa.timestart, qa.timefinish - qa.timestart AS duration '; @@ -226,7 +225,7 @@ class quiz_overview_report extends quiz_default_report { $from = '{user} u '; $from .= 'LEFT JOIN {quiz_attempts} qa ON qa.userid = u.id AND qa.quiz = :quizid'; $params = array('quizid' => $quiz->id); - + if ($qmsubselect && $qmfilter){ $from .= ' AND '.$qmsubselect; } @@ -254,7 +253,7 @@ class quiz_overview_report extends quiz_default_report { $where = "u.id $allowed_usql AND (qa.preview = 0 OR qa.preview IS NULL)"; break; } - + $table->set_count_sql("SELECT COUNT(1) FROM $from WHERE $where", $params); $sqlobject = new object; @@ -272,7 +271,7 @@ class quiz_overview_report extends quiz_default_report { $where .= ' AND COALESCE((SELECT MAX(qqr.regraded) FROM {quiz_question_regrade} qqr WHERE qqr.attemptid = qa.uniqueid),-1) !=\'-1\''; } $table->set_sql($fields, $from, $where, $params); - + // Define table columns $columns = array(); $headers = array(); @@ -311,12 +310,12 @@ class quiz_overview_report extends quiz_default_report { echo '
' . $strattempthighlight . '
'; } } - + if (!$table->is_downloading() && $candelete) { $columns[]= 'checkbox'; $headers[]= NULL; } - + if (!$table->is_downloading() && $CFG->grade_report_showuserimage) { $columns[]= 'picture'; $headers[]= ''; @@ -330,21 +329,21 @@ class quiz_overview_report extends quiz_default_report { $columns[]= 'firstname'; $headers[]= get_string('firstname'); } - + if ($CFG->grade_report_showuseridnumber) { $columns[]= 'idnumber'; $headers[]= get_string('idnumber'); } - + $columns[]= 'timestart'; $headers[]= get_string('startedon', 'quiz'); - + $columns[]= 'timefinish'; $headers[]= get_string('timecompleted','quiz'); - + $columns[]= 'duration'; $headers[]= get_string('attemptduration', 'quiz'); - + if ($detailedmarks) { foreach ($questions as $id => $question) { // Ignore questions of zero length @@ -368,35 +367,35 @@ class quiz_overview_report extends quiz_default_report { $columns[] = 'sumgrades'; $headers[] = get_string('grade', 'quiz').'/'.quiz_format_grade($quiz, $quiz->grade); } - + if ($hasfeedback) { $columns[] = 'feedbacktext'; $headers[] = get_string('feedback', 'quiz'); } - + $table->define_columns($columns); $table->define_headers($headers); $table->sortable(true, 'uniqueid'); - + // Set up the table $table->define_baseurl($reporturl->out(false, $displayoptions)); - + $table->collapsible(false); - + $table->column_suppress('picture'); $table->column_suppress('fullname'); $table->column_suppress('idnumber'); - + $table->no_sorting('feedbacktext'); - + $table->column_class('picture', 'picture'); $table->column_class('lastname', 'bold'); $table->column_class('firstname', 'bold'); $table->column_class('fullname', 'bold'); $table->column_class('sumgrades', 'bold'); - + $table->set_attribute('id', 'attempts'); - + $table->out($pagesize, true); } if (!$table->is_downloading() && $showgrades) { @@ -648,7 +647,7 @@ class quiz_overview_report extends quiz_default_report { list($asql, $aparams) = $DB->get_in_or_equal($attemptids); $where = "qa.id $asql AND "; $params = array_merge($params, $aparams); - + $where .= "qa.quiz = ? AND qa.preview = 0"; $params[] = $quiz->id; if (!$attempts = $DB->get_records_sql('SELECT qa.* FROM {quiz_attempts} qa WHERE '. $where, $params)) { @@ -671,4 +670,4 @@ class quiz_overview_report extends quiz_default_report { } -?> + diff --git a/mod/quiz/report/overview/version.php b/mod/quiz/report/overview/version.php index 837fbf593ab..61cc45d9f6b 100644 --- a/mod/quiz/report/overview/version.php +++ b/mod/quiz/report/overview/version.php @@ -1,4 +1,4 @@ -version = 2009091400; // The (date) version of this module -?> + diff --git a/mod/quiz/report/reportlib.php b/mod/quiz/report/reportlib.php index a0b47aefb80..0534c54a93f 100644 --- a/mod/quiz/report/reportlib.php +++ b/mod/quiz/report/reportlib.php @@ -119,7 +119,7 @@ function quiz_get_average_grade_for_questions($quiz, $userids){ list($usql, $params) = $DB->get_in_or_equal($userids); $params[] = $quiz->id; $questionavgssql = "SELECT qns.questionid, AVG(qs.grade) FROM - {quiz_attempts} qa + {quiz_attempts} qa LEFT JOIN {question_sessions} qns ON (qns.attemptid = qa.uniqueid) LEFT JOIN {question_states} qs ON (qns.newgraded = qs.id AND qs.event IN (".QUESTION_EVENTS_GRADED.")) WHERE " . @@ -135,7 +135,7 @@ function quiz_get_total_qas_graded_and_ungraded($quiz, $questionids, $userids){ $params = array($quiz->id); list($u_sql, $u_params) = $DB->get_in_or_equal($userids); list($q_sql, $q_params) = $DB->get_in_or_equal($questionids); - + $params = array_merge($params, $u_params, $q_params); $sql = "SELECT qs.question, COUNT(1) AS totalattempts, SUM(CASE WHEN (qs.event IN(".QUESTION_EVENTS_GRADED.")) THEN 1 ELSE 0 END) AS gradedattempts @@ -382,4 +382,4 @@ function quiz_report_list($context){ return $reportlist; } -?> + diff --git a/mod/quiz/report/responses/report.php b/mod/quiz/report/responses/report.php index 2e0babcc532..a9a3cddf081 100644 --- a/mod/quiz/report/responses/report.php +++ b/mod/quiz/report/responses/report.php @@ -1,4 +1,4 @@ -wwwroot.'/mod/quiz/report.php', $pageoptions); $qmsubselect = quiz_report_qm_filter_select($quiz); - + /// find out current groups mode $currentgroup = groups_get_activity_group($cm, true); @@ -131,7 +131,7 @@ class quiz_responses_report extends quiz_default_report { $table->is_downloading($download, get_string('reportresponses','quiz_responses'), "$COURSE->shortname ".format_string($quiz->name,true)); if (!$table->is_downloading()) { - + // Only print headers if not asked to download data $PAGE->requires->css('mod/quiz/report/responses/styles.css'); $this->print_header_and_tabs($cm, $course, $quiz, 'responses', ''); @@ -170,12 +170,12 @@ class quiz_responses_report extends quiz_default_report { echo '
' . $strattempthighlight . '
'; } } - - + + $showgrades = quiz_has_grades($quiz) && $reviewoptions->scores; $hasfeedback = quiz_has_feedback($quiz); - - + + // Construct the SQL $fields = $DB->sql_concat('u.id', '\'#\'', 'COALESCE(qa.attempt, \'0\')').' AS concattedid, '; if ($qmsubselect) { @@ -185,17 +185,17 @@ class quiz_responses_report extends quiz_default_report { " ELSE 0 " . "END) AS gradedattempt, "; } - + $fields .='qa.uniqueid, qa.id AS attempt, u.id AS userid, u.idnumber, u.firstname,'. ' u.lastname, u.institution, u.department, u.email, u.picture, u.imagealt, '. 'qa.sumgrades, qa.timefinish, qa.timestart, qa.timefinish - qa.timestart AS duration, ' . 'qa.layout '; - + // This part is the same for all cases - join users and quiz_attempts tables $from = '{user} u '; $from .= 'LEFT JOIN {quiz_attempts} qa ON qa.userid = u.id AND qa.quiz = :quizid'; $params = array('quizid' => $quiz->id); - + if ($qmsubselect && $qmfilter){ $from .= ' AND '.$qmsubselect; } @@ -223,23 +223,23 @@ class quiz_responses_report extends quiz_default_report { $where = "u.id $allowed_usql AND (qa.preview = 0 OR qa.preview IS NULL)"; break; } - + $table->set_count_sql("SELECT COUNT(1) FROM $from WHERE $where", $params); - - - + + + $table->set_sql($fields, $from, $where, $params); - + // Define table columns $columns = array(); $headers = array(); - - + + if (!$table->is_downloading() && $candelete) { $columns[]= 'checkbox'; $headers[]= NULL; } - + if (!$table->is_downloading() && $CFG->grade_report_showuserimage) { $columns[]= 'picture'; $headers[]= ''; @@ -253,7 +253,7 @@ class quiz_responses_report extends quiz_default_report { $columns[]= 'firstname'; $headers[]= get_string('firstname'); } - + if ($CFG->grade_report_showuseridnumber) { $columns[]= 'idnumber'; $headers[]= get_string('idnumber'); @@ -270,14 +270,14 @@ class quiz_responses_report extends quiz_default_report { $columns[]= 'timestart'; $headers[]= get_string('startedon', 'quiz'); - + $columns[]= 'timefinish'; $headers[]= get_string('timecompleted','quiz'); - + $columns[]= 'duration'; $headers[]= get_string('attemptduration', 'quiz'); } - + if ($showgrades) { $columns[] = 'sumgrades'; $headers[] = get_string('grade', 'quiz').'/'.quiz_format_grade($quiz, $quiz->grade); @@ -287,7 +287,7 @@ class quiz_responses_report extends quiz_default_report { $columns[] = 'feedbacktext'; $headers[] = get_string('feedback', 'quiz'); } - + // we want to display responses for all questions foreach ($questions as $id => $question) { // Ignore questions of zero length @@ -295,36 +295,36 @@ class quiz_responses_report extends quiz_default_report { $headers[] = '#'.$question->number; $question->formattedname = strip_tags(format_string($question->name)); } - - + + // Load the question type specific information if (!get_question_options($questions)) { print_error('cannotloadoptions', 'quiz_responses'); } - + $table->define_columns($columns); $table->define_headers($headers); $table->sortable(true, 'concattedid'); - + // Set up the table $table->define_baseurl($reporturl->out(false, $displayoptions)); - + $table->collapsible(true); - + $table->column_suppress('picture'); $table->column_suppress('fullname'); $table->column_suppress('idnumber'); - + $table->no_sorting('feedbacktext'); - + $table->column_class('picture', 'picture'); $table->column_class('lastname', 'bold'); $table->column_class('firstname', 'bold'); $table->column_class('fullname', 'bold'); $table->column_class('sumgrades', 'bold'); - + $table->set_attribute('id', 'attempts'); - + $table->out($pagesize, true); } return true; @@ -333,4 +333,4 @@ class quiz_responses_report extends quiz_default_report { } -?> + diff --git a/mod/quiz/report/responses/responses_table.php b/mod/quiz/report/responses/responses_table.php index 2f968b4ba85..898cad1fbd0 100644 --- a/mod/quiz/report/responses/responses_table.php +++ b/mod/quiz/report/responses/responses_table.php @@ -1,4 +1,4 @@ -questions[$questionid]; restore_question_state($question, $stateforqinattempt); - + if (!$this->is_downloading() || $this->is_downloading() == 'xhtml'){ $formathtml = true; } else { @@ -182,7 +182,7 @@ class quiz_report_responses_table extends table_sql { } else { return ''; } - + } else { return $summary; } @@ -241,4 +241,4 @@ class quiz_report_responses_table extends table_sql { } } } -?> + diff --git a/mod/quiz/report/responses/responsessettings_form.php b/mod/quiz/report/responses/responsessettings_form.php index 9f281854512..a3c9024960a 100644 --- a/mod/quiz/report/responses/responsessettings_form.php +++ b/mod/quiz/report/responses/responsessettings_form.php @@ -1,4 +1,4 @@ -libdir/formslib.php"; class mod_quiz_report_responses_settings extends moodleform { @@ -44,4 +44,3 @@ class mod_quiz_report_responses_settings extends moodleform { $this->add_action_buttons(false, get_string('preferencessave', 'quiz_overview')); } } -?> \ No newline at end of file diff --git a/mod/quiz/report/simpletest/testreportlib.php b/mod/quiz/report/simpletest/testreportlib.php index 67db041ce52..be39c3bc666 100644 --- a/mod/quiz/report/simpletest/testreportlib.php +++ b/mod/quiz/report/simpletest/testreportlib.php @@ -25,21 +25,21 @@ class question_reportlib_test extends UnitTestCase { $object->response = ''; $object->grade = 3; $datum[] = $object; - + $indexed = quiz_report_index_by_keys($datum, array('aid','qid')); - + $this->assertEqual($indexed[101][3]->qid, 3); $this->assertEqual($indexed[101][3]->aid, 101); $this->assertEqual($indexed[101][3]->response, ''); $this->assertEqual($indexed[101][3]->grade, 3); - + $indexed = quiz_report_index_by_keys($datum, array('aid','qid'), false); - + $this->assertEqual($indexed[101][3][0]->qid, 3); $this->assertEqual($indexed[101][3][0]->aid, 101); $this->assertEqual($indexed[101][3][0]->response, ''); $this->assertEqual($indexed[101][3][0]->grade, 3); - + } } -?> + diff --git a/mod/quiz/report/statistics/cron.php b/mod/quiz/report/statistics/cron.php index c6f6aab077c..7ddd3bbe2f3 100644 --- a/mod/quiz/report/statistics/cron.php +++ b/mod/quiz/report/statistics/cron.php @@ -1,4 +1,4 @@ -get_records_select_menu('quiz_statistics', 'timemodified < ?', array(time()-5*HOURSECS))){ @@ -12,4 +12,4 @@ function quiz_report_statistics_cron(){ } return true; } -?> + diff --git a/mod/quiz/report/statistics/db/install.php b/mod/quiz/report/statistics/db/install.php index 5d2ffd2e2da..0c9b3bfc2b8 100644 --- a/mod/quiz/report/statistics/db/install.php +++ b/mod/quiz/report/statistics/db/install.php @@ -1,4 +1,4 @@ -s = $s; $this->sumgradesavg = $sumgradesavg; - + foreach (array_keys($questions) as $qid){ $questions[$qid]->_stats = $this->stats_init_object(); } @@ -58,7 +58,7 @@ class qstats{ print_error('errorstatisticsquestions', 'quiz_statistics'); } } - + function _initial_states_walker($state, &$stats, $positionstat = true){ $stats->s++; $stats->totalgrades += $state->grade; @@ -113,12 +113,12 @@ class qstats{ } } - /** + /** * Get the data for the individual question response analysis table. */ function _process_actual_responses($question, $state){ global $QTYPES; - if ($question->qtype != 'random' && + if ($question->qtype != 'random' && $QTYPES[$question->qtype]->show_analysis_of_responses()){ $restoredstate = clone($state); restore_question_state($question, $restoredstate); @@ -159,7 +159,7 @@ class qstats{ } //avoid divide by zero if ($stats->gradevariance * $stats->othergradevariance){ - $stats->discriminationindex = 100*$stats->covariance + $stats->discriminationindex = 100*$stats->covariance / sqrt($stats->gradevariance * $stats->othergradevariance); } else { $stats->discriminationindex = null; @@ -170,7 +170,7 @@ class qstats{ $stats->discriminativeefficiency = null; } } - + function process_states(){ global $DB, $OUTPUT; set_time_limit(0); @@ -276,7 +276,7 @@ class qstats{ } } } - + function process_responses(){ foreach ($this->states as $state){ if ($this->questions[$state->question]->qtype == 'random'){ @@ -296,4 +296,4 @@ class qstats{ return $this->sumofgradevariance; } } -?> + diff --git a/mod/quiz/report/statistics/report.php b/mod/quiz/report/statistics/report.php index 954ea542d34..94e5711b76a 100644 --- a/mod/quiz/report/statistics/report.php +++ b/mod/quiz/report/statistics/report.php @@ -2,7 +2,6 @@ /** * This script calculates various statistics about student attempts * - * @version $Id$ * @author Martin Dougiamas, Jamie Pratt, Tim Hunt and others. * @license http://www.gnu.org/copyleft/gpl.html GNU Public License * @package quiz @@ -662,4 +661,4 @@ function quiz_report_attempts_sql($quizid, $currentgroup, $groupstudents, $allat return array($fromqa, $whereqa, $qaparams); } -?> + diff --git a/mod/quiz/report/statistics/simpletest/test_qstats.php b/mod/quiz/report/statistics/simpletest/test_qstats.php index e69edb97125..d629c550759 100644 --- a/mod/quiz/report/statistics/simpletest/test_qstats.php +++ b/mod/quiz/report/statistics/simpletest/test_qstats.php @@ -17,8 +17,8 @@ require_once($CFG->dirroot.'/mod/quiz/locallib.php'); require_once($CFG->dirroot.'/mod/quiz/report/reportlib.php'); /** - * This class contains the test cases for the functions in qstats.php. - * + * This class contains the test cases for the functions in qstats.php. + * * */ class quiz_report_qstats_test extends UnitTestCase { public static $includecoverage = array('mod/quiz/report/reportlib.php'); @@ -36,7 +36,7 @@ class quiz_report_qstats_test extends UnitTestCase { $this->qstats = new qstats($questions, 22, 10045.45455); $this->qstats->states = $states; $this->qstats->process_states(); - + //values expected are taken from contrib/tools/quiz_tools/stats.xls $facility = array(0,0,0,0,null,null,null,41.19318182,81.36363636,71.36363636,65.45454545,65.90909091,36.36363636,59.09090909,50,59.09090909,63.63636364,45.45454545,27.27272727,50); $this->qstats_q_fields('facility', $facility, 100); @@ -80,7 +80,7 @@ class quiz_report_qstats_test extends UnitTestCase { } return $items; } - + function get_records_from_csv($filename){ $filecontents = file($filename, FILE_IGNORE_NEW_LINES); $records = array(); @@ -105,4 +105,4 @@ class quiz_report_qstats_test extends UnitTestCase { //$test = new quiz_report_qstats_test(); //$test->test_qstats(); -?> + diff --git a/mod/quiz/report/statistics/statistics_form.php b/mod/quiz/report/statistics/statistics_form.php index 4c599c544d1..9deb6d14f4d 100644 --- a/mod/quiz/report/statistics/statistics_form.php +++ b/mod/quiz/report/statistics/statistics_form.php @@ -1,4 +1,4 @@ -libdir/formslib.php"; class mod_quiz_report_statistics extends moodleform { @@ -17,4 +17,4 @@ class mod_quiz_report_statistics extends moodleform { $this->add_action_buttons(false, get_string('preferencessave', 'quiz_overview')); } } -?> + diff --git a/mod/quiz/report/statistics/statistics_graph.php b/mod/quiz/report/statistics/statistics_graph.php index 9283d074256..08a8af5976d 100644 --- a/mod/quiz/report/statistics/statistics_graph.php +++ b/mod/quiz/report/statistics/statistics_graph.php @@ -1,4 +1,4 @@ -dirroot."/lib/graphlib.php"; include $CFG->dirroot."/mod/quiz/locallib.php"; @@ -47,7 +47,7 @@ $line->parameter['legend_border'] = 'black'; $line->parameter['legend_offset'] = 4; -$line->parameter['bar_size'] = 1; +$line->parameter['bar_size'] = 1; $line->parameter['zero_axis'] = 'grayEE'; @@ -97,8 +97,8 @@ $line->parameter['y_axis_gridlines'] = $gridlines+1; $line->parameter['y_min_left'] = $min; $line->parameter['y_max_left'] = $max; -$line->parameter['y_decimal_left'] = 0; +$line->parameter['y_decimal_left'] = 0; $line->draw(); -?> + diff --git a/mod/quiz/report/statistics/statistics_question_table.php b/mod/quiz/report/statistics/statistics_question_table.php index 90e2474f411..fa45a8d613e 100644 --- a/mod/quiz/report/statistics/statistics_question_table.php +++ b/mod/quiz/report/statistics/statistics_question_table.php @@ -1,4 +1,4 @@ -libdir.'/tablelib.php'); class quiz_report_statistics_question_table extends flexible_table { @@ -20,7 +20,7 @@ class quiz_report_statistics_question_table extends flexible_table { // Define table columns $columns = array(); $headers = array(); - + if ($hassubqs){ $columns[]= 'subq'; $headers[]= ''; @@ -28,11 +28,11 @@ class quiz_report_statistics_question_table extends flexible_table { $columns[]= 'response'; $headers[]= get_string('response', 'quiz_statistics'); - + $columns[]= 'credit'; $headers[]= get_string('optiongrade', 'quiz_statistics'); - + $columns[]= 'rcount'; $headers[]= get_string('count', 'quiz_statistics'); @@ -56,7 +56,7 @@ class quiz_report_statistics_question_table extends flexible_table { parent::setup(); } - + function col_response($response){ global $QTYPES; if (!$this->is_downloading() || $this->is_downloading() == 'xhtml'){ @@ -65,11 +65,11 @@ class quiz_report_statistics_question_table extends flexible_table { return $response->response; } } - + function col_subq($response){ return $response->subq; } - + function col_credit($response){ if (!is_null($response->credit)){ return ($response->credit*100).'%'; @@ -77,7 +77,7 @@ class quiz_report_statistics_question_table extends flexible_table { return ''; } } - + function col_frequency($response){ if ($this->question->_stats->s){ return format_float((($response->rcount / $this->question->_stats->s)*100),2).'%'; @@ -89,4 +89,4 @@ class quiz_report_statistics_question_table extends flexible_table { } -?> + diff --git a/mod/quiz/report/statistics/statistics_table.php b/mod/quiz/report/statistics/statistics_table.php index 5d4efa3f37f..3f9c1ba04a7 100644 --- a/mod/quiz/report/statistics/statistics_table.php +++ b/mod/quiz/report/statistics/statistics_table.php @@ -1,10 +1,10 @@ -libdir.'/tablelib.php'); class quiz_report_statistics_table extends flexible_table { - - var $quiz; - + + var $quiz; + function quiz_report_statistics_table(){ parent::flexible_table('mod-quiz-report-statistics-report'); } @@ -19,10 +19,10 @@ class quiz_report_statistics_table extends flexible_table { // Define table columns $columns = array(); $headers = array(); - + $columns[]= 'number'; $headers[]= get_string('questionnumber', 'quiz_statistics'); - + if (!$this->is_downloading()){ $columns[]= 'icon'; $headers[]= ''; @@ -34,29 +34,29 @@ class quiz_report_statistics_table extends flexible_table { } $columns[]= 'name'; $headers[]= get_string('questionname', 'quiz'); - + $columns[]= 's'; $headers[]= get_string('attempts', 'quiz_statistics'); if ($s>1){ $columns[]= 'facility'; $headers[]= get_string('facility', 'quiz_statistics'); - + $columns[]= 'sd'; $headers[]= get_string('standarddeviationq', 'quiz_statistics'); } $columns[]= 'random_guess_score'; $headers[]= get_string('random_guess_score', 'quiz_statistics'); - + $columns[]= 'intended_weight'; $headers[]= get_string('intended_weight', 'quiz_statistics'); - + $columns[]= 'effective_weight'; $headers[]= get_string('effective_weight', 'quiz_statistics'); - + $columns[]= 'discrimination_index'; $headers[]= get_string('discrimination_index', 'quiz_statistics'); - + $columns[]= 'discriminative_efficiency'; $headers[]= get_string('discriminative_efficiency', 'quiz_statistics'); @@ -119,11 +119,11 @@ class quiz_report_statistics_table extends flexible_table { return $question->_stats->discriminativeefficiency < 15; } } - + function col_icon($question){ return print_question_icon($question, true); } - + function col_number($question){ if (!$question->_stats->subquestion){ return $question->number; @@ -180,7 +180,7 @@ class quiz_report_statistics_table extends flexible_table { return $randomguessscore; // empty string returned by random question. } } - + function col_sd($question){ if (!is_null($question->_stats->sd) && ($question->_stats->maxgrade!=0)){ return number_format($question->_stats->sd*100 / $question->_stats->maxgrade, 2).'%'; @@ -202,6 +202,6 @@ class quiz_report_statistics_table extends flexible_table { return ''; } } - + } -?> + diff --git a/mod/quiz/simpletest/testaccessrules.php b/mod/quiz/simpletest/testaccessrules.php index 05a4305bb34..12448defa12 100644 --- a/mod/quiz/simpletest/testaccessrules.php +++ b/mod/quiz/simpletest/testaccessrules.php @@ -424,4 +424,4 @@ class securewindow_access_rule_test extends UnitTestCase { } } -?> + diff --git a/mod/quiz/simpletest/testeditlib.php b/mod/quiz/simpletest/testeditlib.php index f3c894e729e..c70299da666 100644 --- a/mod/quiz/simpletest/testeditlib.php +++ b/mod/quiz/simpletest/testeditlib.php @@ -60,4 +60,4 @@ class quiz_editlib_test extends UnitTestCase { $this->assertEqual(quiz_add_page_break_at('1,2,0', 3), '1,2,0'); } } -?> + diff --git a/question/addquestion.php b/question/addquestion.php index 266416d095d..7a3ee303afc 100644 --- a/question/addquestion.php +++ b/question/addquestion.php @@ -1,4 +1,4 @@ -box_end(); echo $OUTPUT->footer(); -?> + diff --git a/question/backuplib.php b/question/backuplib.php index 51061ccf089..94f6735438a 100644 --- a/question/backuplib.php +++ b/question/backuplib.php @@ -1,4 +1,4 @@ - + diff --git a/question/category.php b/question/category.php index 03652e7e48c..7ac6930e202 100644 --- a/question/category.php +++ b/question/category.php @@ -1,4 +1,4 @@ -display_user_interface(); } echo $OUTPUT->footer(); -?> + diff --git a/question/category_class.php b/question/category_class.php index 935120427d3..fa76965ca8d 100644 --- a/question/category_class.php +++ b/question/category_class.php @@ -1,4 +1,4 @@ - + diff --git a/question/category_form.php b/question/category_form.php index 53a8be5cb7c..1fd9b6e0962 100644 --- a/question/category_form.php +++ b/question/category_form.php @@ -1,4 +1,4 @@ -libdir.'/formslib.php'); @@ -36,4 +36,4 @@ class question_category_edit_form extends moodleform { $mform->setType('id', PARAM_INT); } } -?> + diff --git a/question/category_form_randomquestion.php b/question/category_form_randomquestion.php index 8806feb3ee0..8e6315036dd 100644 --- a/question/category_form_randomquestion.php +++ b/question/category_form_randomquestion.php @@ -1,4 +1,4 @@ -libdir.'/formslib.php'); @@ -35,4 +35,4 @@ class question_category_edit_form_randomquestion extends moodleform { $mform->setType('addonpage', PARAM_SEQUENCE); } } -?> + diff --git a/question/contextmove.php b/question/contextmove.php index c8526415c32..5982dee61d3 100644 --- a/question/contextmove.php +++ b/question/contextmove.php @@ -1,4 +1,4 @@ -display(); echo $OUTPUT->footer(); -?> + diff --git a/question/contextmove_form.php b/question/contextmove_form.php index f2f20d8b41c..76965bb64db 100644 --- a/question/contextmove_form.php +++ b/question/contextmove_form.php @@ -1,4 +1,4 @@ -libdir.'/formslib.php'); @@ -100,4 +100,4 @@ class question_context_move_form extends moodleform { } } } -?> + diff --git a/question/contextmoveq.php b/question/contextmoveq.php index 277d6be47b9..f19b80fc5af 100644 --- a/question/contextmoveq.php +++ b/question/contextmoveq.php @@ -1,4 +1,4 @@ -display(); echo $OUTPUT->footer(); -?> + diff --git a/question/contextmoveq_form.php b/question/contextmoveq_form.php index ee0232de87e..25b65ed2b5b 100644 --- a/question/contextmoveq_form.php +++ b/question/contextmoveq_form.php @@ -1,4 +1,4 @@ -libdir.'/formslib.php'); @@ -104,4 +104,4 @@ class question_context_move_question_form extends moodleform { } } } -?> + diff --git a/question/edit.php b/question/edit.php index 984f32990f1..01f5936c1dd 100644 --- a/question/edit.php +++ b/question/edit.php @@ -1,4 +1,4 @@ -\n"; echo $OUTPUT->footer(); -?> + diff --git a/question/editlib.php b/question/editlib.php index 5c2dca3893f..30dad125f17 100644 --- a/question/editlib.php +++ b/question/editlib.php @@ -1,4 +1,4 @@ -params($this->baseurl->params()); - + echo $OUTPUT->confirm(get_string("deletequestionscheck", "quiz", $questionnames), $baseurl->out_action(array('deleteselected'=>$questionlist, 'confirm'=>md5($questionlist))), $baseurl); @@ -1945,4 +1945,4 @@ function create_new_question_button($categoryid, $params, $caption, $tooltip = ' } } -?> + diff --git a/question/export.php b/question/export.php index cb389cb89ee..1e999843cd4 100644 --- a/question/export.php +++ b/question/export.php @@ -1,4 +1,4 @@ -display(); echo $OUTPUT->footer(); -?> + diff --git a/question/export_form.php b/question/export_form.php index 598cedb26f6..4a52accfa8d 100644 --- a/question/export_form.php +++ b/question/export_form.php @@ -1,4 +1,4 @@ -libdir.'/formslib.php'); @@ -20,7 +20,7 @@ class question_export_form extends moodleform { $radioarray[] = $radioelement; } $mform->addGroup($radioarray,'format','',array('
'),false); - $mform->addRule('format',null,'required',null,'client'); + $mform->addRule('format',null,'required',null,'client'); //-------------------------------------------------------------------------------- $mform->addElement('header','general', get_string('general', 'form')); @@ -36,7 +36,7 @@ class question_export_form extends moodleform { $mform->disabledIf('categorygroup', 'cattofile', 'notchecked'); $mform->setDefault('cattofile', 1); $mform->setDefault('contexttofile', 1); - + // $fileformatnames = get_import_export_formats('export'); // $mform->addElement('select', 'format', get_string('fileformat','quiz'), $fileformatnames); @@ -47,7 +47,7 @@ class question_export_form extends moodleform { $mform->setDefault('exportfilename', $defaultfilename); $mform->setType('exportfilename', PARAM_FILE); - // set a template for the format select elements + // set a template for the format select elements $renderer =& $mform->defaultRenderer(); $template = "{help} {element}\n"; $renderer->setGroupElementTemplate($template, 'format'); @@ -57,4 +57,4 @@ class question_export_form extends moodleform { //-------------------------------------------------------------------------------- } } -?> + diff --git a/question/exportfile.php b/question/exportfile.php index 0b3261d875f..c22fb4a45a8 100644 --- a/question/exportfile.php +++ b/question/exportfile.php @@ -1,4 +1,4 @@ -libdir . '/filelib.php'); @@ -14,4 +14,4 @@ $pathname = $CFG->dataroot . '/temp/questionexport/' . $USER->id . '/' . $relativepath; send_temp_file($pathname, $relativepath); -?> + diff --git a/question/format.php b/question/format.php index 74d40c8aa52..1a53ca1bbf9 100644 --- a/question/format.php +++ b/question/format.php @@ -1,4 +1,4 @@ - + diff --git a/question/format/README.txt b/question/format/README.txt index 677e9256a64..f2436d2cf3a 100644 --- a/question/format/README.txt +++ b/question/format/README.txt @@ -1,19 +1,19 @@ FILE FORMATS FOR QUESTION IMPORT/EXPORT ------------------------------------ -This directory contains plug-in sub-modules to add +This directory contains plug-in sub-modules to add import-export formats for Moodle questions -Each sub-module must contain at least a format.php file -containing a class that contains functions for reading, +Each sub-module must contain at least a format.php file +containing a class that contains functions for reading, writing, importing and exporting questions. For correct operation the class name must be based on the name of the containing directory, e.g., directory: webct -class: class qformat_webct extends qformat_default { +class: class qformat_webct extends qformat_default { -Most of them are based on the class found in question/format.php. +Most of them are based on the class found in question/format.php. See the comments therein for more information. diff --git a/question/format/aiken/format.php b/question/format/aiken/format.php index cde6211dbe2..f738938e56b 100644 --- a/question/format/aiken/format.php +++ b/question/format/aiken/format.php @@ -1,4 +1,4 @@ -defaultquestion(); - $endchar = chr(13); + $endchar = chr(13); foreach ($lines as $line) { $stp = strpos($line, $endchar, 0); $newlines = explode($endchar, $line); @@ -105,4 +105,4 @@ class qformat_aiken extends qformat_default { } } -?> + diff --git a/question/format/blackboard/format.php b/question/format/blackboard/format.php index 45bcad84262..23fd4cd3811 100644 --- a/question/format/blackboard/format.php +++ b/question/format/blackboard/format.php @@ -1,4 +1,4 @@ -defaultquestion(); - + $question->qtype = ESSAY; - + // determine if the question is already escaped html $ishtml = $essayquestion["#"]["BODY"][0]["#"]["FLAGS"][0]["#"]["ISHTML"][0]["@"]["value"]; @@ -68,13 +68,13 @@ function process_essay($xml, &$questions ) { if ($ishtml) { $question->questiontext = html_entity_decode_php4(trim($essayquestion["#"]["BODY"][0]["#"]["TEXT"][0]["#"])); } - + // put name in question object $question->name = substr($question->questiontext, 0, 254); $question->answer = ''; $question->feedback = ''; $question->fraction = 0; - + $questions[] = $question; } } @@ -92,7 +92,7 @@ function process_tf($xml, &$questions) { } for ($i = 0; $i < sizeof ($tfquestions); $i++) { - + $question = $this->defaultquestion(); $question->qtype = TRUEFALSE; @@ -250,7 +250,7 @@ function process_ma($xml, &$questions) { } } - if ($iscorrect) { + 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 { @@ -305,14 +305,14 @@ function process_fib($xml, &$questions) { } 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; } } @@ -355,9 +355,9 @@ function process_matching($xml, &$questions) { $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++) { @@ -385,13 +385,13 @@ function process_matching($xml, &$questions) { } } - + } $questions[] = $question; - + } } } -?> + diff --git a/question/format/blackboard_six/format.php b/question/format/blackboard_six/format.php index 1cf7e36942b..202599495b9 100644 --- a/question/format/blackboard_six/format.php +++ b/question/format/blackboard_six/format.php @@ -19,12 +19,12 @@ class qformat_blackboard_six extends qformat_default { function provide_import() { return true; } - - + + //Function to check and create the needed dir to unzip file to function check_and_create_import_dir($unique_code) { - global $CFG; + global $CFG; $status = $this->check_dir_exists($CFG->dataroot."/temp",true); if ($status) { @@ -33,18 +33,18 @@ class qformat_blackboard_six extends qformat_default { if ($status) { $status = $this->check_dir_exists($CFG->dataroot."/temp/bbquiz_import/".$unique_code,true); } - + return $status; } - + function clean_temp_dir($dir='') { - // for now we will just say everything happened okay note + // for now we will just say everything happened okay note // that a mess may be piling up in $CFG->dataroot/temp/bbquiz_import // TODO return true at top of the function renders all the following code useless return true; - + if ($dir == '') { - $dir = $this->temp_dir; + $dir = $this->temp_dir; } $slash = "/"; @@ -94,16 +94,16 @@ class qformat_blackboard_six extends qformat_default { // Close directory closedir($handle); if (rmdir($this->temp_dir) == FALSE) { - return false; + return false; } // Success, every thing is gone return true return true; } - + //Function to check if a directory exists and, optionally, create it function check_dir_exists($dir,$create=false) { - global $CFG; + global $CFG; $status = true; if(!is_dir($dir)) { @@ -119,9 +119,9 @@ class qformat_blackboard_six extends qformat_default { function importpostprocess() { /// Does any post-processing that may be desired - /// Argument is a simple array of question ids that + /// Argument is a simple array of question ids that /// have just been added. - + // need to clean up temporary directory return $this->clean_temp_dir(); } @@ -131,9 +131,9 @@ class qformat_blackboard_six extends qformat_default { $filename = str_replace('\\','/',$filename); $fullpath = $this->temp_dir.'/res00001/'.$filename; $basename = basename($filename); - + $copy_to = $CFG->dataroot.'/'.$COURSE->id.'/bb_import'; - + if ($this->check_dir_exists($copy_to,true)) { if(is_readable($fullpath)) { $copy_to.= '/'.$basename; @@ -146,24 +146,24 @@ class qformat_blackboard_six extends qformat_default { } } else { - return false; + return false; } } function readdata($filename) { /// Returns complete file with an array, one item per line global $CFG; - + // if the extension is .dat we just return that, // if .zip we unzip the file and get the data - $ext = substr($this->realfilename, strpos($this->realfilename,'.'), strlen($this->realfilename)-1); + $ext = substr($this->realfilename, strpos($this->realfilename,'.'), strlen($this->realfilename)-1); if ($ext=='.dat') { if (!is_readable($filename)) { - print_error('filenotreadable', 'error'); - } + print_error('filenotreadable', 'error'); + } return file($filename); - } - + } + $unique_code = time(); $temp_dir = $CFG->dataroot."/temp/bbquiz_import/".$unique_code; $this->temp_dir = $temp_dir; @@ -188,33 +188,33 @@ class qformat_blackboard_six extends qformat_default { } } else { - print_error('cannotfindquestionfile', 'questioni'); + print_error('cannotfindquestionfile', 'questioni'); } } else { print "filename: $filename
tempdir: $temp_dir
"; - print_error('cannotunzip', 'question'); + print_error('cannotunzip', 'question'); } } else { - print_error('cannotreaduploadfile'); + print_error('cannotreaduploadfile'); } } else { - print_error('cannotcreatetempdir'); + print_error('cannotcreatetempdir'); } } - + function save_question_options($question) { - return true; + 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(). + /// readquestion(). $text = implode($lines, " "); $xml = xmlize($text, 0); @@ -260,14 +260,14 @@ class qformat_blackboard_six extends qformat_default { // creates a cleaner object to deal with for processing into moodle // the object created is NOT a moodle question object function create_raw_question($quest) { - + $question = new StdClass; $question->qtype = $quest['#']['itemmetadata'][0]['#']['bbmd_questiontype'][0]['#']; $question->id = $quest['#']['itemmetadata'][0]['#']['bbmd_asi_object_id'][0]['#']; $presentation->blocks = $quest['#']['presentation'][0]['#']['flow'][0]['#']['flow']; foreach($presentation->blocks as $pblock) { - + $block = NULL; $block->type = $pblock['@']['class']; @@ -276,7 +276,7 @@ function create_raw_question($quest) { $sub_blocks = $pblock['#']['flow']; foreach($sub_blocks as $sblock) { //echo "Calling process_block from line 263
"; - $this->process_block($sblock, $block); + $this->process_block($sblock, $block); } break; @@ -314,7 +314,7 @@ function create_raw_question($quest) { foreach($mc_choices as $mc_choice) { $choices = NULL; $choices = $this->process_block($mc_choice, $choices); - $block->choices[] = $choices; + $block->choices[] = $choices; } break; case 'Short Response': @@ -348,8 +348,8 @@ function create_raw_question($quest) { } $question->{$block->type} = $block; } - - // determine response processing + + // determine response processing // there is a section called 'outcomes' that I don't know what to do with $resprocessing = $quest['#']['resprocessing']; $respconditions = $resprocessing[0]['#']['respcondition']; @@ -374,11 +374,11 @@ function process_block($cur_block, &$block) { $cur_type = $cur_block['@']['class']; switch($cur_type) { case 'FORMATTED_TEXT_BLOCK': - $block->text = $this->strip_applet_tags_get_mathml($cur_block['#']['material'][0]['#']['mat_extension'][0]['#']['mat_formattedtext'][0]['#']); + $block->text = $this->strip_applet_tags_get_mathml($cur_block['#']['material'][0]['#']['mat_extension'][0]['#']['mat_formattedtext'][0]['#']); break; case 'FILE_BLOCK': //revisit this to make sure it is working correctly - // Commented out ['matapplication']..., etc. because I + // Commented out ['matapplication']..., etc. because I // noticed that when I imported a new Blackboard 6 file // and printed out the block, the tree did not extend past ['material'][0]['#'] - CT 8/3/06 $block->file = $cur_block['#']['material'][0]['#'];//['matapplication'][0]['@']['uri']; @@ -404,7 +404,7 @@ function process_block($cur_block, &$block) { } } foreach($sub_blocks['#']['flow_mat'] as $sub_block) { - $this->process_block($sub_block, $block); + $this->process_block($sub_block, $block); } } else { @@ -430,8 +430,8 @@ function process_block($cur_block, &$block) { else { $block->link = ''; } - break; - } + break; + } return $block; } @@ -448,18 +448,18 @@ function process_choices($bb_choices, &$choices) { // Reset $cur_choice to NULL because process_block is expecting an object // for the second argument and not a string, which is what is was set as // originally - CT 8/7/06 - $cur_choice = null; + $cur_choice = null; $this->process_block($cur_block, $cur_choice); } elseif (isset($choice['#']['response_label'])) { // Reset $cur_choice to NULL because process_block is expecting an object // for the second argument and not a string, which is what is was set as // originally - CT 8/7/06 - $cur_choice = null; + $cur_choice = null; $this->process_block($choice, $cur_choice); } $choices[] = $cur_choice; - } + } } function process_matching_responses($bb_responses, &$responses) { @@ -485,30 +485,30 @@ function process_responses($bb_responses, &$responses) { // gets added to the array $response = null; if (isset($bb_response['@']['title'])) { - $response->title = $bb_response['@']['title']; + $response->title = $bb_response['@']['title']; } else { $reponse->title = $bb_response['#']['displayfeedback'][0]['@']['linkrefid']; } $reponse->ident = array(); if (isset($bb_response['#']['conditionvar'][0]['#'])){//['varequal'][0]['#'])) { - $response->ident[0] = $bb_response['#']['conditionvar'][0]['#'];//['varequal'][0]['#']; + $response->ident[0] = $bb_response['#']['conditionvar'][0]['#'];//['varequal'][0]['#']; } else if (isset($bb_response['#']['conditionvar'][0]['#']['other'][0]['#'])) { - $response->ident[0] = $bb_response['#']['conditionvar'][0]['#']['other'][0]['#']; + $response->ident[0] = $bb_response['#']['conditionvar'][0]['#']['other'][0]['#']; } - + if (isset($bb_response['#']['conditionvar'][0]['#']['and'])){//[0]['#'])) { $responseset = $bb_response['#']['conditionvar'][0]['#']['and'];//[0]['#']['varequal']; foreach($responseset as $rs) { $response->ident[] = $rs['#']; if(!isset($response->feedback) and isset( $rs['@'] ) ) { $response->feedback = $rs['@']['respident']; - } + } } } else { - $response->feedback = $bb_response['#']['displayfeedback'][0]['@']['linkrefid']; + $response->feedback = $bb_response['#']['displayfeedback'][0]['@']['linkrefid']; } // determine what point value to give response @@ -518,7 +518,7 @@ function process_responses($bb_responses, &$responses) { $response->fraction = 1; break; default: - // I have only seen this being 0 or unset + // I have only seen this being 0 or unset // there are probably fractional values of SCORE.max, but I'm not sure what they look like $response->fraction = 0; break; @@ -528,7 +528,7 @@ function process_responses($bb_responses, &$responses) { // just going to assume this is the case this is probably not correct. $response->fraction = 0; } - + $responses[] = $response; } } @@ -537,7 +537,7 @@ function process_feedback($feedbackset, &$feedbacks) { foreach($feedbackset as $bb_feedback) { // Added line $feedback=null so that $feedback does not get reused in the loop // and added the the $feedbacks[] array multiple times - $feedback = null; + $feedback = null; $feedback->ident = $bb_feedback['@']['ident']; if (isset($bb_feedback['#']['flow_mat'][0])) { $this->process_block($bb_feedback['#']['flow_mat'][0], $feedback); @@ -572,16 +572,16 @@ function process_tf($quest, &$questions) { $responses = $quest->responses; $correctresponse = $responses[0]->ident[0]['varequal'][0]['#']; if ($correctresponse != 'false') { - $correct = true; + $correct = true; } else { - $correct = false; + $correct = false; } - + foreach($quest->feedback as $fb) { - $fback->{$fb->ident} = $fb->text; + $fback->{$fb->ident} = $fb->text; } - + if ($correct) { // true is correct $question->answer = 1; $question->feedbacktrue = $fback->correct; @@ -607,7 +607,7 @@ function process_fblank($quest, &$questions) { $answers = array(); $fractions = array(); $feedbacks = array(); - + // extract the feedback $feedback = array(); foreach($quest->feedback as $fback) { @@ -617,7 +617,7 @@ function process_fblank($quest, &$questions) { } } } - + foreach($quest->responses as $response) { if(isset($response->title)) { if (isset($response->ident[0]['varequal'][0]['#'])) { @@ -633,11 +633,11 @@ function process_fblank($quest, &$questions) { } } } - + } } - //Adding catchall to so that students can see feedback for incorrect answers when they enter something the + //Adding catchall to so that students can see feedback for incorrect answers when they enter something the //instructor did not enter $answers[] = '*'; $fractions[] = 0; @@ -647,7 +647,7 @@ function process_fblank($quest, &$questions) { else { $feedbacks[] = ''; } - + $question->answer = $answers; $question->fraction = $fractions; $question->feedback = $feedbacks; // Changed to assign $feedbacks to $question->feedback instead of @@ -665,12 +665,12 @@ function process_mc($quest, &$questions) { $question = $this->process_common( $quest ); $question->qtype = MULTICHOICE; $question->single = 1; - + $feedback = array(); foreach($quest->feedback as $fback) { $feedback[$fback->ident] = $fback->text; } - + foreach($quest->responses as $response) { if (isset($response->title)) { if ($response->title == 'correct') { @@ -703,9 +703,9 @@ function process_mc($quest, &$questions) { } else { // failsafe feedback (should be '' instead?) - $question->feedback[$i] = "correct"; + $question->feedback[$i] = "correct"; } - } + } else { $question->fraction[$i] = 0; if (!empty($feedback['incorrect'])) { @@ -745,11 +745,11 @@ function process_ma($quest, &$questions) { } } } - + foreach ($quest->feedback as $fb) { $feedback->{$fb->ident} = trim($fb->text); } - + $correct_answer_count = count($correct_answers); $choiceset = $quest->RESPONSE_BLOCK->choices; $i = 0; @@ -761,7 +761,7 @@ function process_ma($quest, &$questions) { $question->feedback[$i] = $feedback->correct; } else { - // wrong answer + // wrong answer $question->fraction[$i] = 0; $question->feedback[$i] = $feedback->incorrect; } @@ -781,7 +781,7 @@ function process_essay($quest, &$questions) { // treat as short answer $question = $this->process_common( $quest ); // copied this from process_mc $question->qtype = ESSAY; - + $question->feedback = array(); // not sure where to get the correct answer from foreach($quest->feedback as $feedback) { @@ -791,9 +791,9 @@ function process_essay($quest, &$questions) { $question->feedback = $feedback->text; } } - //Added because essay/questiontype.php:save_question_option is expecting a + //Added because essay/questiontype.php:save_question_option is expecting a //fraction property - CT 8/10/06 - $question->fraction[] = 1; + $question->fraction[] = 1; if (!empty($question)) { $questions[]=$question; } @@ -815,15 +815,15 @@ function process_matching($quest, &$questions) { $question = $this->process_common( $quest ); $question->valid = true; $question->qtype = 'renderedmatch'; - + foreach($quest->RESPONSE_BLOCK->subquestions as $qid => $subq) { foreach($quest->responses as $rid => $resp) { if ($resp->ident == $subq->ident) { $correct = $resp->correct; - $feedback = $resp->feedback; + $feedback = $resp->feedback; } } - + foreach($subq->choices as $cid => $choice) { if ($choice == $correct) { $question->subquestions[] = $subq->text; @@ -831,7 +831,7 @@ function process_matching($quest, &$questions) { } } } - + // check format $status = true; if ( count($quest->RESPONSE_BLOCK->subquestions) > count($quest->RIGHT_MATCH_BLOCK->matching_answerset) || count($question->subquestions) < 2) { @@ -842,24 +842,24 @@ function process_matching($quest, &$questions) { foreach($question->subanswers as $qstn) { if(isset($previous)) { if ($qstn == $previous) { - $status = false; - } + $status = false; + } } $previous = $qstn; if ($qstn == '') { - $status = false; + $status = false; } } } - + if ($status) { - $questions[] = $question; + $questions[] = $question; } else { global $COURSE, $CFG; print ''; - print ''; - + print ''; + print ""; print "'; - + print '
This matching question is malformed. Please ensure there are no blank answers, no two questions have the same answer, and/or there are correct answers for each question. There must be at least as many subanswers as subquestions, and at least one subquestion.
This matching question is malformed. Please ensure there are no blank answers, no two questions have the same answer, and/or there are correct answers for each question. There must be at least as many subanswers as subquestions, and at least one subquestion.
Question:".$quest->QUESTION_BLOCK->text; if (isset($quest->QUESTION_BLOCK->file)) { print '
There is a subfile contained in the zipfile that has been copied to course files: bb_import/'.basename($quest->QUESTION_BLOCK->file).''; @@ -870,7 +870,7 @@ function process_matching($quest, &$questions) { print "
Subquestions:
    "; foreach($quest->responses as $rs) { - $correct_responses->{$rs->ident} = $rs->correct; + $correct_responses->{$rs->ident} = $rs->correct; } foreach($quest->RESPONSE_BLOCK->subquestions as $subq) { print '
  • '.$subq->text.'
      '; @@ -887,7 +887,7 @@ function process_matching($quest, &$questions) { print '
    '; } print '
Feedback:
    '; foreach($quest->feedback as $fb) { print '
  • '.$fb->ident.': '.$fb->text.'
  • '; @@ -904,7 +904,7 @@ function process_matching($quest, &$questions) { function strip_applet_tags_get_mathml($string) { if(stristr($string, '') === FALSE) { - return $string; + return $string; } else { // strip all applet tags keeping stuff before/after and inbetween (if mathml) them @@ -912,9 +912,9 @@ function strip_applet_tags_get_mathml($string) { preg_match("/(.*)\.*\<\/math\>)\".*\<\/applet\>(.*)/i",$string, $mathmls); $string = $mathmls[1].$mathmls[2].$mathmls[3]; } - return $string; + return $string; } } } // close object -?> + diff --git a/question/format/examview/format.php b/question/format/examview/format.php index 3448d79574b..29b46447c85 100755 --- a/question/format/examview/format.php +++ b/question/format/examview/format.php @@ -1,4 +1,4 @@ - + diff --git a/question/format/gift/examples.txt b/question/format/gift/examples.txt index 7dfed889582..c0c1e0e2b7c 100644 --- a/question/format/gift/examples.txt +++ b/question/format/gift/examples.txt @@ -57,7 +57,7 @@ Matching Question. { =subquestion2 -> subanswer2 =subquestion3 -> subanswer3 } - + Match the following countries with their corresponding capitals. { =Canada -> Ottawa =Italy -> Rome @@ -77,7 +77,7 @@ When was Ulysses S. Grant born? {# =1822:0 =%50%1822:2} -// OPTIONS +// OPTIONS // ===Line Comments=== @@ -90,7 +90,7 @@ What's 2 plus 2? {#4} ::Kanji Origins::Japanese characters originally came from what country? {=China} -::Thanksgiving Date::The American holiday of Thanksgiving is +::Thanksgiving Date::The American holiday of Thanksgiving is celebrated on the {~second ~third =fourth} Thursday of November. // ===Feedback=== @@ -99,7 +99,7 @@ What's the answer to this multiple-choice question?{ ~wrong answer#feedback comment on the wrong answer ~another wrong answer#feedback comment on this wrong answer =right answer#Very good!} - + Who's buried in Grant's tomb?{ =no one#excellent answer! =nobody#excellent answer!} @@ -113,13 +113,13 @@ Who's buried in Grant's tomb?{ Grant is buried in Grant's tomb.{FALSE#No one is buried in Grant's tomb.} Difficult question.{~wrong answer ~%50%half credit answer =full credit answer} - + ::Jesus' hometown::Jesus Christ was from { ~Jerusalem#This was an important city, but the wrong answer. ~%25%Bethlehem#He was born here, but not raised here. ~%50%Galilee#You need to be more specific. =Nazareth#Yes! That's right!}. - + ::Jesus' hometown:: Jesus Christ was from { =Nazareth#Yes! That's right! =%75%Nazereth#Right, but misspelled. diff --git a/question/format/gift/format.php b/question/format/gift/format.php index bb3bc13c81e..9ad9d32d2e2 100755 --- a/question/format/gift/format.php +++ b/question/format/gift/format.php @@ -1,7 +1,7 @@ -Ottawa =Italy->Rome =Japan->Tokyo} // -// Comment lines start with a double backslash (//). -// Optional question names are enclosed in double colon(::). +// Comment lines start with a double backslash (//). +// Optional question names are enclosed in double colon(::). // Answer feedback is indicated with hash mark (#). // Percentage answer weights immediately follow the tilde (for // multiple choice) or equal sign (for short answer and numerical), // and are enclosed in percent signs (% %). See docs and examples.txt for more. -// -// This filter was written through the collaboration of numerous -// members of the Moodle community. It was originally based on +// +// This filter was written through the collaboration of numerous +// members of the Moodle community. It was originally based on // the missingword format, which included code from Thomas Robb // and others. Paul Tsuchido Shew wrote this filter in December 2003. ////////////////////////////////////////////////////////////////////////// @@ -79,10 +79,10 @@ class qformat_gift extends qformat_default { } return $feedback; } - + function escapedchar_pre($string) { //Replaces escaped control characters with a placeholder BEFORE processing - + $escapedcharacters = array("\\:", "\\#", "\\=", "\\{", "\\}", "\\~", "\\n" ); //dlnsk $placeholders = array("&&058;", "&&035;", "&&061;", "&&123;", "&&125;", "&&126;", "&&010" ); //dlnsk @@ -119,7 +119,7 @@ class qformat_gift extends qformat_default { $question = $this->defaultquestion(); $comment = NULL; // define replaced by simple assignment, stop redefine notices - $gift_answerweight_regex = "/^%\-*([0-9]{1,2})\.?([0-9]*)%/"; + $gift_answerweight_regex = "/^%\-*([0-9]{1,2})\.?([0-9]*)%/"; // REMOVED COMMENTED LINES and IMPLODE foreach ($lines as $key => $line) { @@ -148,7 +148,7 @@ class qformat_gift extends qformat_default { $question->category = $newcategory; return $question; } - + // QUESTION NAME parser if (substr($text, 0, 2) == "::") { $text = substr($text, 2); @@ -209,7 +209,7 @@ class qformat_gift extends qformat_default { $questiontext = substr( $questiontext, $rh_brace+1 ); if (!$questiontextformat = text_format_name( $qtformat )) { $questiontext = $oldquestiontext; - } + } } $question->questiontextformat = $questiontextformat; $question->questiontext = trim($this->escapedchar_post($questiontext)); @@ -245,17 +245,17 @@ class qformat_gift extends qformat_default { } elseif (strpos($answertext, "~") !== false) { // only Multiplechoice questions contain tilde ~ $question->qtype = MULTICHOICE; - - } elseif (strpos($answertext, "=") !== false + + } elseif (strpos($answertext, "=") !== false && strpos($answertext, "->") !== false) { // only Matching contains both = and -> $question->qtype = MATCH; } else { // either TRUEFALSE or SHORTANSWER - + // TRUEFALSE question check $truefalse_check = $answertext; - if (strpos($answertext,"#") > 0){ + if (strpos($answertext,"#") > 0){ // strip comments to check for TrueFalse question $truefalse_check = trim(substr($answertext, 0, strpos($answertext,"#"))); } @@ -288,7 +288,7 @@ class qformat_gift extends qformat_default { break; case MULTICHOICE: if (strpos($answertext,"=") === false) { - $question->single = 0; // multiple answers are enabled if no single answer is 100% correct + $question->single = 0; // multiple answers are enabled if no single answer is 100% correct } else { $question->single = 1; // only one answer allowed (the default) } @@ -301,9 +301,9 @@ class qformat_gift extends qformat_default { if (empty($answers[0])) { array_shift($answers); } - + $countanswers = count($answers); - + if (!$this->check_answer_count( 2,$answers,$text )) { return false; break; @@ -316,10 +316,10 @@ class qformat_gift extends qformat_default { if ($answer[0] == "=") { $answer_weight = 1; $answer = substr($answer, 1); - + } elseif (preg_match($gift_answerweight_regex, $answer)) { // check for properly formatted answer weight $answer_weight = $this->answerweightparser($answer); - + } else { //default, i.e., wrong anwer $answer_weight = 0; } @@ -330,7 +330,7 @@ class qformat_gift extends qformat_default { $question->partiallycorrectfeedback = ''; $question->incorrectfeedback = ''; } // end foreach answer - + //$question->defaultgrade = 1; //$question->image = ""; // No images with this format return $question; @@ -344,12 +344,12 @@ class qformat_gift extends qformat_default { if (empty($answers[0])) { array_shift($answers); } - + if (!$this->check_answer_count( 2,$answers,$text )) { return false; break; } - + foreach ($answers as $key => $answer) { $answer = trim($answer); if (strpos($answer, "->") === false) { @@ -364,10 +364,10 @@ class qformat_gift extends qformat_default { $question->subanswers[$key] = trim($this->escapedchar_post(substr($answer, $marker+2))); } // end foreach answer - + return $question; break; - + case TRUEFALSE: $answer = $answertext; $comment = $this->commentparser($answer); // commentparser also removes comment from $answer @@ -388,7 +388,7 @@ class qformat_gift extends qformat_default { return $question; break; - + case SHORTANSWER: // SHORTANSWER Question $answers = explode("=", $answertext); @@ -398,7 +398,7 @@ class qformat_gift extends qformat_default { if (empty($answers[0])) { array_shift($answers); } - + if (!$this->check_answer_count( 1,$answers,$text )) { return false; break; @@ -443,7 +443,7 @@ class qformat_gift extends qformat_default { if (empty($answers[0])) { array_shift($answers); } - + if (count($answers) == 0) { // invalid question $giftnonumericalanswers = get_string('giftnonumericalanswers','quiz'); @@ -479,14 +479,14 @@ class qformat_gift extends qformat_default { $tol = 0; $ans = trim($answer); } - + if (!(is_numeric($ans) || $ans = '*') || !is_numeric($tol)) { $errornotnumbers = get_string( 'errornotnumbers' ); $this->error( $errornotnumbers, $text ); return false; break; } - + // store results $question->answer[$key] = $ans; $question->tolerance[$key] = $tol; @@ -507,8 +507,8 @@ class qformat_gift extends qformat_default { $giftnovalidquestion = get_string('giftnovalidquestion','quiz'); $this->error( $giftnovalidquestion, $text ); return false; - break; - + break; + } // end switch ($question->qtype) } // end function readquestion($lines) @@ -519,7 +519,7 @@ function repchar( $text, $format=0 ) { $reserved = array( '#', '=', '~', '{', '}', ':', "\n","\r"); $escaped = array( '\#','\=','\~','\{','\}','\:','\n','' ); //dlnsk - $newtext = str_replace( $reserved, $escaped, $text ); + $newtext = str_replace( $reserved, $escaped, $text ); $format = 0; // turn this off for now if ($format) { $newtext = format_text( $format ); @@ -550,7 +550,7 @@ function writequestion( $question ) { switch($question->qtype) { case 'category': // not a real question, used to insert category switch - $expout .= "\$CATEGORY: $question->category\n"; + $expout .= "\$CATEGORY: $question->category\n"; break; case DESCRIPTION: $expout .= '::'.$this->repchar($question->name).'::'; @@ -656,4 +656,4 @@ function writequestion( $question ) { return $expout; } } -?> + diff --git a/question/format/hotpot/format.php b/question/format/hotpot/format.php index 68d9afb2b24..3c95de161a1 100644 --- a/question/format/hotpot/format.php +++ b/question/format/hotpot/format.php @@ -1,4 +1,4 @@ -libdir.'/filelib.php'); $baseurl = get_file_url($courseid).'/'; @@ -159,7 +159,7 @@ class qformat_hotpot extends qformat_default { $gap_count ++; $positionkey = $q+1; $question->questiontext .= '{#'.$positionkey.'}'; - + // initialize answer settings $wrapped = new stdClass(); $wrapped->qtype = SHORTANSWER; @@ -170,7 +170,7 @@ class qformat_hotpot extends qformat_default { $wrapped->fraction = array(); $wrapped->feedback = array(); $answers = array(); - + // add answers $a = 0; while (($answer=$question_record."['answer'][$a]['#']") && $xml->xml_value($tags, $answer)) { @@ -450,7 +450,7 @@ class qformat_hotpot extends qformat_default { $a++; } if ($correct_answers_all_zero) { - // correct answers all have score of 0%, + // correct answers all have score of 0%, // so reset score for correct answers 100% foreach ($correct_answers as $aa) { $question->fraction[$aa] = 1; diff --git a/question/format/learnwise/format.php b/question/format/learnwise/format.php index a65037d6fa4..88b4dd0a0d3 100755 --- a/question/format/learnwise/format.php +++ b/question/format/learnwise/format.php @@ -1,8 +1,8 @@ -stringbetween($option, ' correct="', '">'); $answer = $this->stringbetween($option, '">', ''); - $optionscorrect[$n] = $correct; + $optionscorrect[$n] = $correct; $optionstext[$n] = $this->unhtmlentities($answer); ++$n; } @@ -84,7 +84,7 @@ class qformat_learnwise extends qformat_default { $answer = $this->stringbetween($option, '">', ''); - $optionscorrect[$n] = $correct; + $optionscorrect[$n] = $correct; $optionstext[$n] = $this->unhtmlentities($answer); $optionsaward[$n] = $award; ++$n; @@ -111,13 +111,13 @@ class qformat_learnwise extends qformat_default { if ($optionstext[$n]) { if (!isset($numcorrect)) { // single answer if ($optionscorrect[$n] == 'yes') { - $fraction = (int) $questionaward; + $fraction = (int) $questionaward; } else { $fraction = 0; - } + } } else { // mulitple answers if ($optionscorrect[$n] == 'yes') { - $fraction = $optionsaward[$n] / $totalaward; + $fraction = $optionsaward[$n] / $totalaward; } else { $fraction = -$optionsaward[$n] / count($optionstext); } @@ -144,8 +144,8 @@ class qformat_learnwise extends qformat_default { $transtable = get_html_translation_table(HTML_ENTITIES); $transtable = array_flip($transtable); return strtr($string, $transtable); - } + } } -?> + diff --git a/question/format/missingword/format.php b/question/format/missingword/format.php index ec3666481a0..ce0fd902393 100644 --- a/question/format/missingword/format.php +++ b/question/format/missingword/format.php @@ -1,18 +1,18 @@ -defaultquestion(); @@ -100,7 +100,7 @@ class qformat_missingword extends qformat_default { $question->answer[] = $answer; $question->fraction[] = 1; $question->feedback[] = ""; - + return $question; default: @@ -118,7 +118,7 @@ class qformat_missingword extends qformat_default { $answeight = round(($answeight0/100),2); $answer = substr($answer,(strspn($answer,"1234567890%"))); } - } + } if ($answer[0] == "="){ $answeight = 1; } @@ -148,10 +148,10 @@ class qformat_missingword extends qformat_default { $question->answer[$key] = $answer; $question->feedback[$key] = $comment; } - + return $question; } } } -?> + diff --git a/question/format/multianswer/format.php b/question/format/multianswer/format.php index ce42e6321b0..531330c0db5 100644 --- a/question/format/multianswer/format.php +++ b/question/format/multianswer/format.php @@ -1,4 +1,4 @@ -name = $lines[0]; - + $questions[] = $thequestion; } @@ -40,4 +40,4 @@ class qformat_multianswer extends qformat_default { } } -?> + diff --git a/question/format/qti_two/custommediafilter.php b/question/format/qti_two/custommediafilter.php index c7fcba8cf24..5cbdc4b2fd2 100644 --- a/question/format/qti_two/custommediafilter.php +++ b/question/format/qti_two/custommediafilter.php @@ -1,4 +1,4 @@ -'; $replace .= ''; $replace .= ' '; - + $text = preg_replace($search, $replace, $text); } @@ -59,7 +59,7 @@ function custom_mediaplugin_filter($text, $width = null, $height = null) { $replace .= ' pluginspage="http://www.macromedia.com/go/getflashplayer">'; $replace .= ''; $replace .= '

    ';*/ - + $text = preg_replace($search, $replace, $text); } @@ -116,7 +116,7 @@ function custom_mediaplugin_filter($text, $width = null, $height = null) { $width = 240; $height = 180; } - + if (empty($CFG->filter_mediaplugin_ignore_mpg)) { $search = '/]*)>(.*?)<\/a>/i'; @@ -126,7 +126,7 @@ function custom_mediaplugin_filter($text, $width = null, $height = null) { $replace .= ''; $replace .= ' '; $replace .= '

    '; - + $text = preg_replace($search, $replace, $text); } @@ -139,12 +139,12 @@ function custom_mediaplugin_filter($text, $width = null, $height = null) { $replace .= ''; $replace .= ' '; $replace .= ' '; - + $text = preg_replace($search, $replace, $text); } return $text; } -?> + diff --git a/question/format/qti_two/format.php b/question/format/qti_two/format.php index a5dfa597c89..eee76a347ba 100644 --- a/question/format/qti_two/format.php +++ b/question/format/qti_two/format.php @@ -1,4 +1,4 @@ -dirroot/question/format/qti_two/qt_common.php"); //////////////////////////////////////////////////////////////////////////// @@ -917,4 +917,4 @@ function xml_entitize(&$collection) { } -?> + diff --git a/question/format/qti_two/qt_common.php b/question/format/qti_two/qt_common.php index a94394f3213..65bb7fd3f3f 100644 --- a/question/format/qti_two/qt_common.php +++ b/question/format/qti_two/qt_common.php @@ -11,16 +11,16 @@ * * @param int courseid * @return array containing filenames - * @calledfrom type//editquestion.php + * @calledfrom type//editquestion.php * @package questionbank * @subpackage importexport */ -function get_course_media_files($courseid) +function get_course_media_files($courseid) { // this code lifted from mod/quiz/question.php and modified global $CFG; $images = null; - + make_upload_directory("$course->id"); // Just in case $coursefiles = get_directory_list("$CFG->dataroot/$courseid", $CFG->moddata); foreach ($coursefiles as $filename) { @@ -29,7 +29,7 @@ function get_course_media_files($courseid) } } return $images; -} +} /** * determines whether or not a file is an image, based on the file extension @@ -94,7 +94,7 @@ function is_sizable_multimedia($file) { * @param string $file the filename * @param string $courseid the course id * @param string $alt to specify the alt tag - * @return string either an image tag, or html for an embedded object + * @return string either an image tag, or html for an embedded object */ function get_media_tag($file, $courseid = 0, $alt = 'media file', $width = 0, $height = 0) { global $CFG; @@ -112,14 +112,14 @@ function get_media_tag($file, $courseid = 0, $alt = 'media file', $width = 0, $h if (!$isimage = is_image_by_extension($file)) { $ismultimedia = is_multimedia_by_extension($file); } - + // if there is no known width and height, try to get one if ($width == 0) { if ($isimage || is_sizable_multimedia($file)) { - + } - - } + + } // create either an image link or a generic link. // if the moodle multimedia filter is turned on, it'll catch multimedia content in the generic link if (is_image_by_extension($file)) { @@ -134,7 +134,7 @@ function get_media_tag($file, $courseid = 0, $alt = 'media file', $width = 0, $h /** * determines the x and y size of the given file * - * @param string $file the filename + * @param string $file the filename * @return array looks like array('x'=>171, 'y'=>323), or array('x'=>0, 'y'=>0) if size can't be determined */ function get_file_dimensions($file) { @@ -146,4 +146,4 @@ function get_file_dimensions($file) { } } -?> + diff --git a/question/format/qti_two/templates/choice.tpl b/question/format/qti_two/templates/choice.tpl index 3a06d3378e0..33333c202c7 100755 --- a/question/format/qti_two/templates/choice.tpl +++ b/question/format/qti_two/templates/choice.tpl @@ -19,7 +19,7 @@
    {section name=answer loop=$answers} - {$answers[answer].answer} + {$answers[answer].answer} {if $answers[answer].feedback != ''} {if $answers[answer].answer != $correctresponse.answer} {$answers[answer].feedback} @@ -33,7 +33,7 @@ {if $hassize == 1} {else} - + {/if} {/if} diff --git a/question/format/qti_two/templates/choiceMultiple.tpl b/question/format/qti_two/templates/choiceMultiple.tpl index 9b6ac0d8ae4..7e4bcb33f17 100755 --- a/question/format/qti_two/templates/choiceMultiple.tpl +++ b/question/format/qti_two/templates/choiceMultiple.tpl @@ -26,14 +26,14 @@ {if $hassize == 1} {else} - + {/if} {/if}
    {section name=answer loop=$answers} - {$answers[answer].answer} + {$answers[answer].answer} {if $answers[answer].feedback != ''} {if $answers[answer].answer != $correctresponse.answer} {$answers[answer].feedback} @@ -44,7 +44,7 @@
    - + {section name=answer loop=$answers} diff --git a/question/format/qti_two/templates/composite.tpl b/question/format/qti_two/templates/composite.tpl index 802cd08a57d..7be2a4ff13e 100755 --- a/question/format/qti_two/templates/composite.tpl +++ b/question/format/qti_two/templates/composite.tpl @@ -64,7 +64,7 @@ {if $hassize == 1} {else} - + {/if} {/if} @@ -96,6 +96,6 @@ {if $answers[answer].subanswers[subanswer].feedback != ''} {$answers[answer].subanswers[subanswer].feedback} {/if}{/section} - {/if} + {/if} {/section} diff --git a/question/format/qti_two/templates/extendedText.tpl b/question/format/qti_two/templates/extendedText.tpl index 52d2bd94ed0..641b07ce350 100755 --- a/question/format/qti_two/templates/extendedText.tpl +++ b/question/format/qti_two/templates/extendedText.tpl @@ -9,7 +9,7 @@ {if $hassize == 1} {else} - + {/if} {/if} diff --git a/question/format/qti_two/templates/extendedText_simpleEssay.tpl b/question/format/qti_two/templates/extendedText_simpleEssay.tpl index 76d7d23ee26..1acd89bd6d1 100755 --- a/question/format/qti_two/templates/extendedText_simpleEssay.tpl +++ b/question/format/qti_two/templates/extendedText_simpleEssay.tpl @@ -15,7 +15,7 @@ {if $hassize == 1} {else} - + {/if} {/if} diff --git a/question/format/qti_two/templates/imsmanifest.tpl b/question/format/qti_two/templates/imsmanifest.tpl index 570d35a7cf6..8f431634bd3 100755 --- a/question/format/qti_two/templates/imsmanifest.tpl +++ b/question/format/qti_two/templates/imsmanifest.tpl @@ -3,8 +3,8 @@ ADL SCORM 1.2 - <langstring xml:lang="{$lang}">{$quiztitle}</langstring> diff --git a/question/format/qti_two/templates/match.tpl b/question/format/qti_two/templates/match.tpl index e1246320115..fba30f34d61 100644 --- a/question/format/qti_two/templates/match.tpl +++ b/question/format/qti_two/templates/match.tpl @@ -35,7 +35,7 @@ {if $hassize == 1} {else} - + {/if} {/if} diff --git a/question/format/qti_two/templates/mmchoiceMultiple.tpl b/question/format/qti_two/templates/mmchoiceMultiple.tpl index 558e0774145..e4f7ab97590 100755 --- a/question/format/qti_two/templates/mmchoiceMultiple.tpl +++ b/question/format/qti_two/templates/mmchoiceMultiple.tpl @@ -41,7 +41,7 @@ {if $hassize == 1} {else} - + {/if} {/if} diff --git a/question/format/qti_two/templates/notimplemented.tpl b/question/format/qti_two/templates/notimplemented.tpl index e431354f25b..51c189e066f 100755 --- a/question/format/qti_two/templates/notimplemented.tpl +++ b/question/format/qti_two/templates/notimplemented.tpl @@ -12,7 +12,7 @@ {if $hassize == 1} {else} - + {/if} {/if} diff --git a/question/format/qti_two/templates/numerical.tpl b/question/format/qti_two/templates/numerical.tpl index d15992ecd06..2f2846bd5c3 100755 --- a/question/format/qti_two/templates/numerical.tpl +++ b/question/format/qti_two/templates/numerical.tpl @@ -19,7 +19,7 @@ {if $hassize == 1} {else} - + {/if} {/if} diff --git a/question/format/qti_two/templates/textEntry.tpl b/question/format/qti_two/templates/textEntry.tpl index 6c03937998b..101c20bd9be 100755 --- a/question/format/qti_two/templates/textEntry.tpl +++ b/question/format/qti_two/templates/textEntry.tpl @@ -25,7 +25,7 @@ {if $hassize == 1} {else} - + {/if} {/if} diff --git a/question/format/webct/format.php b/question/format/webct/format.php index 9c64a4c1b36..81ae23a902c 100644 --- a/question/format/webct/format.php +++ b/question/format/webct/format.php @@ -1,4 +1,4 @@ -answer as $key => $dataanswer) { if(!isset( $question->feedback[$key])){ $question->feedback[$key] = ''; @@ -288,15 +288,15 @@ class qformat_webct extends qformat_default { if (isset($question->tempgeneralfeedback)){ if (isset($question->generalfeedback)) { $question->generalfeedback = $question->tempgeneralfeedback; - } else { + } else { foreach ($question->answer as $key => $dataanswer) { if ($question->tempgeneralfeedback !=''){ $question->feedback[$key] = $question->tempgeneralfeedback.'
    '.$question->feedback[$key]; } } } - unset($question->tempgeneralfeedback); - } + unset($question->tempgeneralfeedback); + } $maxfraction = -1; $totalfraction = 0; foreach($question->fraction as $fraction) { @@ -325,7 +325,7 @@ class qformat_webct extends qformat_default { } } else { $totalfraction = round($totalfraction,2); - if ($totalfraction != 1) { + if ($totalfraction != 1) { $totalfraction = $totalfraction * 100; $errors[] = "'$question->name': ".get_string("wronggrade", "quiz", $nLineCounter).' '.get_string("fractionsaddwrong", "quiz", $totalfraction); $QuestionOK = FALSE; @@ -352,24 +352,24 @@ class qformat_webct extends qformat_default { foreach ($question->subquestions as $id=>$subquestion) { $temp = $question->subquestions[$id]; $question->subquestions[$id] = $question->subanswers[$id]; - $question->subanswers[$id] = $temp; + $question->subanswers[$id] = $temp; } if (count($question->answer) < 3){ // add a dummy missing question $question->name = 'Dummy question added '.$question->name ; $question->answer[] = 'dummy'; $question->subanswers[] = 'dummy'; - $question->subquestions[] = 'dummy'; + $question->subquestions[] = 'dummy'; $question->fraction[] = '0.0'; $question->feedback[] = ''; - } - break; + } + break; default: // No problemo } } - if ($QuestionOK) { + if ($QuestionOK) { // echo "
    "; print_r ($question);
                             $questions[] = $question;    // store it
                             unset($question);            // and prepare a new one
    @@ -484,7 +484,7 @@ class qformat_webct extends qformat_default {
                 // if question isn't defined yet there is nothing to do here (avoid notices)
                 if (!isset($question)) {
                     continue;
    -            } 
    +            }
                 if (isset($question->qtype ) && CALCULATED == $question->qtype && preg_match(
                         "~^:([[:lower:]].*|::.*)-(MIN|MAX|DEC|VAL([0-9]+))::?:?($webctnumberregex)~", $line, $webct_options)) {
                     $datasetname = preg_replace('/^::/', '', $webct_options[1]);
    @@ -548,8 +548,8 @@ class qformat_webct extends qformat_default {
                     foreach ($datasetnames as $datasetname) {
                         $question->dataset[$datasetname] = new stdClass();
                         $question->dataset[$datasetname]->datasetitem = array();
    -                    $question->dataset[$datasetname]->name = $datasetname ; 
    -                    $question->dataset[$datasetname]->distribution = 'uniform'; 
    +                    $question->dataset[$datasetname]->name = $datasetname ;
    +                    $question->dataset[$datasetname]->distribution = 'uniform';
                         $question->dataset[$datasetname]->status ='private';
                     }
                     continue;
    @@ -558,7 +558,7 @@ class qformat_webct extends qformat_default {
                 if (preg_match("~^:L([0-9]+)~i",$line,$webct_options)) {
                     $answertext="";                 // Start gathering next lines
                     $currentchoice=$webct_options[1];
    -                $question->fraction[$currentchoice]=1; 
    +                $question->fraction[$currentchoice]=1;
                     continue;
                 }
     
    @@ -583,7 +583,7 @@ class qformat_webct extends qformat_default {
                     continue;
                 }
                 if (preg_match('~^:LAYOUT:(.*)~i',$line,$webct_options)) {
    -            //    ignore  since layout in question_multichoice  is no more used in moodle       
    +            //    ignore  since layout in question_multichoice  is no more used in moodle
                 //    $webct_options[1] contains either vertical or horizontal ;
                     continue;
                 }
    diff --git a/question/format/xhtml/format.php b/question/format/xhtml/format.php
    index 5e89e2798a9..bb73ff5cdb8 100755
    --- a/question/format/xhtml/format.php
    +++ b/question/format/xhtml/format.php
    @@ -1,4 +1,4 @@
    -$question->name\n";
    - 
    +
         // format and add question text
         $questiontext = $question->questiontext;
         $format = $question->questiontextformat;
         $formatted_text = format_text( $questiontext, $format );
    -    $expout .= "

    $formatted_text

    \n"; + $expout .= "

    $formatted_text

    \n"; // selection depends on question type switch($question->qtype) { @@ -85,9 +85,9 @@ function writequestion( $question ) { $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 = "id\" $name $checked $type value=\"$mcanswer->id\" />"; if ($options->correct_responses && $mcanswer->fraction > 0) { @@ -520,18 +520,18 @@ class embedded_cloze_qtype extends default_questiontype { $a->feedbackimg = question_get_feedback_image($mcanswer->fraction, $chosen && $options->feedback); } } - + // Print the answer text: no automatic numbering $a->text =format_text($mcanswer->answer, FORMAT_MOODLE, $formatoptions, $cmoptions->course); - + // Print feedback if feedback is on if (($options->feedback || $options->correct_responses) && ($checked )) { //|| $options->readonly $a->feedback = format_text($mcanswer->feedback, true, $formatoptions, $cmoptions->course); } else { $a->feedback = ''; } - + $anss[] = clone($a); } ?> @@ -557,7 +557,7 @@ class embedded_cloze_qtype extends default_questiontype {
options->layout == 2 ){ ?> - + @@ -576,16 +576,16 @@ class embedded_cloze_qtype extends default_questiontype {
- type = $wrapped->qtype ; + $a->type = $wrapped->qtype ; $a->sub = $positionkey; print_error('unknownquestiontypeofsubquestion', 'qtype_multianswer','',$a); break; @@ -654,7 +654,7 @@ class embedded_cloze_qtype extends default_questiontype { } return $responses; } - + /** * @param object $question * @return mixed either a integer score out of 1 that the average random diff --git a/question/type/multianswer/version.php b/question/type/multianswer/version.php index 6d0f10af814..3185c4892f6 100644 --- a/question/type/multianswer/version.php +++ b/question/type/multianswer/version.php @@ -1,6 +1,6 @@ -version = 2008050800; $plugin->requires = 2007101509; -?> + diff --git a/question/type/multichoice/db/upgrade.php b/question/type/multichoice/db/upgrade.php index 04087a1bc82..501af6ce8c4 100644 --- a/question/type/multichoice/db/upgrade.php +++ b/question/type/multichoice/db/upgrade.php @@ -1,6 +1,6 @@ -libdir . '/questionlib.php'); // Get all categories containing random questions. @@ -56,4 +56,4 @@ function xmldb_qtype_multichoice_upgrade($oldversion) { return $result; } -?> + diff --git a/question/type/multichoice/edit_multichoice_form.php b/question/type/multichoice/edit_multichoice_form.php index f8c9661c630..3e1c056af57 100644 --- a/question/type/multichoice/edit_multichoice_form.php +++ b/question/type/multichoice/edit_multichoice_form.php @@ -1,4 +1,4 @@ - \ No newline at end of file diff --git a/question/type/multichoice/questiontype.php b/question/type/multichoice/questiontype.php index 8fd8eb12e3b..856b59af9a8 100644 --- a/question/type/multichoice/questiontype.php +++ b/question/type/multichoice/questiontype.php @@ -1,4 +1,4 @@ -format_text($response, $format); } @@ -712,4 +712,4 @@ class question_multichoice_qtype extends default_questiontype { // Register this question type with the question bank. question_register_questiontype(new question_multichoice_qtype()); -?> + diff --git a/question/type/multichoice/version.php b/question/type/multichoice/version.php index c52c71debbf..0d354e821d2 100644 --- a/question/type/multichoice/version.php +++ b/question/type/multichoice/version.php @@ -1,6 +1,6 @@ -version = 2009021800; $plugin->requires = 2007101000; -?> + diff --git a/question/type/numerical/db/upgrade.php b/question/type/numerical/db/upgrade.php index 930f91cfb10..f6d89464552 100644 --- a/question/type/numerical/db/upgrade.php +++ b/question/type/numerical/db/upgrade.php @@ -1,6 +1,6 @@ -table_exists($table)) { // $dbman->create_table doesnt return a result, we just have to trust it $dbman->create_table($table); - }//else + }//else upgrade_plugin_savepoint($result, 2009100100, 'qtype', 'numerical'); } return $result; } -?> + diff --git a/question/type/numerical/display.html b/question/type/numerical/display.html index 678b788aa26..ab34b86f34f 100644 --- a/question/type/numerical/display.html +++ b/question/type/numerical/display.html @@ -1,17 +1,17 @@ -name_prefix."unit\""; $nameanswer = "name=\"".$question->name_prefix."answer\""; -//if left unit is placed before answer so we need to answer field text and a center pice for the show units options +//if left unit is placed before answer so we need to answer field text and a center pice for the show units options // split the respnse in 2 element numerical and units /*if (!empty($question->options->showunits)){ if(isset($question->options->units) && count($question->options->units)){ $length = 0; $goodkey = 0 ; foreach ($question->options->units as $key => $unit){ - if (false === stripos($value, $unit->unit)){ + if (false === stripos($value, $unit->unit)){ }else{ - + if(strlen($unit->unit)> $length) {$length =strlen($unit->unit); $goodkey = $key ; } @@ -22,7 +22,7 @@ } $state->responses['unit']=$goodkey ;
} - + }*/ if (isset($state->responses['answer']) && $state->responses['answer']!='') { $valueanswer = ' value="'.s($state->responses['answer']).'" '; @@ -32,13 +32,13 @@ if (isset($state->responses['unit']) && $state->responses['unit']!='') { $valueunit = ' value="'.s($state->responses['unit']).'" '; } else { - + $valueunit = ' value="" '; if ($question->options->showunits == 2 ){ - $valueunit = ' value="'.s($question->options->units[0]->unit).'" '; - } + $valueunit = ' value="'.s($question->options->units[0]->unit).'" '; + } } - // put a div to enclose the answer and unit elements
+ // put a div to enclose the answer and unit elements
$textlength = 20 ; ?> @@ -55,28 +55,28 @@
- - + + feedback){ $classunit = question_get_feedback_class(1-$this->raw_unitpenalty); $feedbackimgunit = question_get_feedback_image(1-$this->raw_unitpenalty, $options->feedback); } if ($question->options->showunits == 3 || (isset($question->options->units) && count($question->options->units) == 0 )) {// no unit display or tested - + ?>
- + value ="" />
options->showunits == 0 ) {// display unit text input -?> + } else if ($question->options->showunits == 0 ) {// display unit text input +?>
@@ -87,49 +87,49 @@
-options->showunits == 2 ) {// display text - + ?>
- options->units[0]->unit ; ?> - + ?> /> options->units[0]->unit ; - echo '  ' ; + echo '  ' ; ?>
- + options->showunits == 1){?> - -options->showunits == 1 && isset($question->options->units)){?>
-options->units as $key => $unit) { +options->units as $key => $unit) { $checked = ''; $chosen = false; - + $type = 'type="radio"'; // $nameunit = "name=\"".$question->name_prefix;//."unit\""; if (isset($state->responses['unit'])){ @@ -141,8 +141,8 @@ $checked = 'checked="checked"'; $chosen = true; } - - $aid = $question->id ; + + $aid = $question->id ; $a = new stdClass; $a->id = $question->name_prefix."unit" ;//. "2" $a->class = ''; @@ -181,15 +181,15 @@
- -
+ +
options->unitsleft == 1 ){?> - +
@@ -199,8 +199,8 @@ ?> size=""/>
-
- + put a div to enclose the answer and unit elements ?> @@ -217,15 +217,15 @@ - + options->instructions)){?>
options->instructions, true, $formatoptions, $cmoptions->course);?> -
- - - + + + + diff --git a/question/type/numerical/edit_numerical_form.php b/question/type/numerical/edit_numerical_form.php index 2933439f644..6eae9bb8715 100644 --- a/question/type/numerical/edit_numerical_form.php +++ b/question/type/numerical/edit_numerical_form.php @@ -1,4 +1,4 @@ -addElement('header', 'unithandling', get_string("Units handling", 'qtype_numerical')); $currentgrp1 = array(); - + $currentgrp1[] =& $mform->createElement('text', 'unitpenalty', get_string('Penalty for bad unit', 'qtype_numerical') , array('size' => 3)); $currentgrp1[] =& $mform->createElement('static', 'penalty1','hello', get_string('as decimal fraction (0-1) of', 'qtype_numerical')); @@ -179,4 +179,3 @@ class question_edit_numerical_form extends question_edit_form { return 'numerical'; } } -?> \ No newline at end of file diff --git a/question/type/numerical/questiontype.php b/question/type/numerical/questiontype.php index e2d85dc260d..6b8f90e66a9 100644 --- a/question/type/numerical/questiontype.php +++ b/question/type/numerical/questiontype.php @@ -1,6 +1,5 @@ -options->unitsleft = $options->unitsleft ; $question->options->instructions = $options->instructions ; } - - + + return true; } function get_numerical_units(&$question) { @@ -219,7 +218,7 @@ class question_numerical_qtype extends question_shortanswer_qtype { global $DB; $result = new stdClass; // numerical options - $update = true ; + $update = true ; $options = $DB->get_record("question_numerical_options", array("question" => $question->id)); if (!$options) { $update = false; @@ -303,13 +302,13 @@ class question_numerical_qtype extends question_shortanswer_qtype { /* if ($question->options->showunits == 1){ $state->responses['unit'] = '0'; }*/ - + return true; } function restore_session_and_responses(&$question, &$state) { if(false === strpos($state->responses[''], '|||||')){ // temporary - $state->responses['answer']= $state->responses['']; + $state->responses['answer']= $state->responses['']; $state->responses['unit'] = ''; split_old_answer($state->responses[''], $question->options->units, $state->responses['answer'] ,$state->responses['unit'] ); }else { @@ -319,7 +318,7 @@ class question_numerical_qtype extends question_shortanswer_qtype { } // echo "

restore response $responses ||

";print_r($state);echo "

"; - /* + /* if ($question->options->showunits == 1 && isset($question->options->units)){ $state->responses['unit']=$this->find_unit_index($question,$state->responses['unit']); }*/ @@ -333,7 +332,7 @@ class question_numerical_qtype extends question_shortanswer_qtype { if($unit->unit ==$value ) { return $key ; } - } + } return 0 ; } @@ -384,14 +383,14 @@ class question_numerical_qtype extends question_shortanswer_qtype { $DB->delete_records("question_numerical_units", array("question" => $questionid)); return true; } - + function compare_responses(&$question, $state, $teststate) { if ($question->options->showunits == 1 && isset($question->options->units) && isset($question->options->units[$state->responses['unit']] )){ $state->responses['unit']=$question->options->units[$state->responses['unit']]->unit; }; - + $responses = ''; $testresponses = ''; if (isset($state->responses['answer'])){ @@ -434,11 +433,11 @@ class question_numerical_qtype extends question_shortanswer_qtype { $state->responses['']= $state->responses['answer'].$state->responses['unit'] ;// why? } // echo "

test response numerical state before apply

";print_r($state);echo "

"; - + $response = $this->apply_unit($state->responses[''], $question->options->units); // $this->valid_numerical_unit = $this->valid_unit($state->responses[''], $question->options->units); - // if ($this->valid_numerical_unit) echo "

test responses valid unit

"; - // if (!$this->valid_numerical_unit) echo "

test responses not valid unit

"; + // if ($this->valid_numerical_unit) echo "

test responses valid unit

"; + // if (!$this->valid_numerical_unit) echo "

test responses not valid unit

"; // echo "

state response test $response

";print_r($state);echo "

"; // $this->raw_unitpenalty = 0.1 ; @@ -458,17 +457,17 @@ class question_numerical_qtype extends question_shortanswer_qtype { // first one that matches. It also sets the marks and penalty. // This should be good enought for most simple question types. // echo "

grade responses

";print_r($state->responses);echo "

"; - - //first the split response from unit choice display is converted as + + //first the split response from unit choice display is converted as // standard numerical response value.unit /* if (!empty($question->options->showunits) && isset($state->responses['unit'])){ $state->responses[''] .= $question->options->units[$state->responses['unit']]->unit ; } - */ + */ //to apply the unit penalty we need to analyse the response in a more complex way //the apply_unit() function analysis could be used to obtain the infos - // however it is used to detect good or bad numbers but also - // gives false + // however it is used to detect good or bad numbers but also + // gives false $state->raw_grade = 0; foreach($question->options->answers as $answer) { if($this->test_response($question, $state, $answer)) { @@ -482,8 +481,8 @@ class question_numerical_qtype extends question_shortanswer_qtype { break; } } - // if ($this->valid_numerical_unit) echo "

grade responses valid unit

"; - // if (!$this->valid_numerical_unit) echo "

grade responses not valid unit

"; + // if ($this->valid_numerical_unit) echo "

grade responses valid unit

"; + // if (!$this->valid_numerical_unit) echo "

grade responses not valid unit

"; // apply unit penalty $this->raw_unitpenalty = 0 ; if(!empty($question->options->unitpenalty)&& !$this->valid_numerical_unit ){ @@ -510,8 +509,8 @@ class question_numerical_qtype extends question_shortanswer_qtype { return true; } - - + + function get_correct_responses(&$question, &$state) { $correct = parent::get_correct_responses($question, $state); $unit = $this->get_default_numerical_unit($question); @@ -519,7 +518,7 @@ class question_numerical_qtype extends question_shortanswer_qtype { if (isset($correct['']) && $correct[''] != '*' && $unit) { $correct[''] .= ' '.$unit->unit; $correct['unit']= $unit->unit; - } + } return $correct; } @@ -551,17 +550,17 @@ class question_numerical_qtype extends question_shortanswer_qtype { } function get_actual_response($question, $state) { // echo "

state response numerical GET ACTUAL RESPONSE $question->id $question->qtype

";print_r($state);echo "

"; - if (!empty($state->responses) && !empty($state->responses[''])) { + if (!empty($state->responses) && !empty($state->responses[''])) { if(false === strpos($state->responses[''], '|||||')){ $responses[] = $state->responses['']; }else { $resp = explode('|||||', $state->responses['']); - $responses[] = $resp[0].$resp[1]; + $responses[] = $resp[0].$resp[1]; } } else { $responses[] = ''; } - + return $responses; } @@ -647,7 +646,7 @@ class question_numerical_qtype extends question_shortanswer_qtype { // Valid number with unit. return (float)$responseparts[1] / $tmpunits[$responseparts[5]]; } else { - // Valid number with invalid unit. + // Valid number with invalid unit. return (float)$responseparts[1]; } @@ -662,7 +661,7 @@ class question_numerical_qtype extends question_shortanswer_qtype { function edit_numerical_options(&$mform, &$that){ $mform->addElement('header', 'unithandling', get_string("Units handling", 'qtype_numerical')); $currentgrp1 = array(); - + $currentgrp1[] =& $mform->createElement('text', 'unitpenalty', get_string('Penalty for bad unit', 'qtype_numerical') , array('size' => 3)); $currentgrp1[] =& $mform->createElement('static', 'penalty1','hello', get_string('as decimal fraction (0-1) of', 'qtype_numerical')); @@ -691,16 +690,16 @@ class question_numerical_qtype extends question_shortanswer_qtype { $mform->setType('instructions', PARAM_RAW); $mform->setHelpButton('instructions', array('instructions', get_string('instructions', 'quiz'), 'quiz')); - + } function print_question_grading_details(&$question, &$state, $cmoptions, $options) { // echo "

state uestion_grading_details $question->id $question->qtype

";print_r($state);echo "

"; parent::print_question_grading_details($question, $state, $cmoptions, $options); - - } - + + } + function valid_unit($rawresponse, $units) { // Make units more useful $tmpunits = array(); @@ -877,4 +876,4 @@ class question_numerical_qtype extends question_shortanswer_qtype { // INITIATION - Without this line the question type is not in use. question_register_questiontype(new question_numerical_qtype()); -?> + diff --git a/question/type/numerical/simpletest/testquestiontype.php b/question/type/numerical/simpletest/testquestiontype.php index f425c033b65..24f2346a480 100644 --- a/question/type/numerical/simpletest/testquestiontype.php +++ b/question/type/numerical/simpletest/testquestiontype.php @@ -1,4 +1,4 @@ - + diff --git a/question/type/numerical/version.php b/question/type/numerical/version.php index c033bef16bc..168f4ff99cc 100644 --- a/question/type/numerical/version.php +++ b/question/type/numerical/version.php @@ -1,6 +1,6 @@ -version = 2009100100; $plugin->requires = 2007101000; -?> + diff --git a/question/type/question.html b/question/type/question.html index 3ba083bad5a..f59ebe8bf30 100644 --- a/question/type/question.html +++ b/question/type/question.html @@ -1,5 +1,5 @@ - diff --git a/question/type/questiontype.php b/question/type/questiontype.php index e5d8a278fb0..e683167d593 100644 --- a/question/type/questiontype.php +++ b/question/type/questiontype.php @@ -1,4 +1,4 @@ - + diff --git a/question/type/random/edit_random_form.php b/question/type/random/edit_random_form.php index e563d3ed75a..35eddb91b71 100644 --- a/question/type/random/edit_random_form.php +++ b/question/type/random/edit_random_form.php @@ -1,4 +1,4 @@ -addElement('header', 'generalheader', get_string("general", 'form')); - $mform->addElement('questioncategory', 'category', get_string('category', 'quiz'), + $mform->addElement('questioncategory', 'category', get_string('category', 'quiz'), array('contexts' => $this->contexts->having_cap('moodle/question:useall'))); $mform->addElement('advcheckbox', 'questiontext', get_string("recurse", "quiz"), null, null, array(0, 1)); @@ -88,4 +88,3 @@ class question_edit_random_form extends question_edit_form { return 'random'; } } -?> \ No newline at end of file diff --git a/question/type/random/questiontype.php b/question/type/random/questiontype.php index 1af28840613..9fa059edfe6 100644 --- a/question/type/random/questiontype.php +++ b/question/type/random/questiontype.php @@ -1,4 +1,4 @@ - + diff --git a/question/type/randomsamatch/db/upgrade.php b/question/type/randomsamatch/db/upgrade.php index dcefd68934a..761e4a513ca 100644 --- a/question/type/randomsamatch/db/upgrade.php +++ b/question/type/randomsamatch/db/upgrade.php @@ -1,6 +1,6 @@ -get_manager(); $result = true; -/// And upgrade begins here. For each one, you'll need one -/// block of code similar to the next one. Please, delete +/// And upgrade begins here. For each one, you'll need one +/// block of code similar to the next one. Please, delete /// this comment lines once this file start handling proper /// upgrade code. @@ -38,4 +38,4 @@ function xmldb_qtype_randomsamatch_upgrade($oldversion) { return $result; } -?> + diff --git a/question/type/randomsamatch/edit_randomsamatch_form.php b/question/type/randomsamatch/edit_randomsamatch_form.php index f6adcd72ddb..24b9502e175 100644 --- a/question/type/randomsamatch/edit_randomsamatch_form.php +++ b/question/type/randomsamatch/edit_randomsamatch_form.php @@ -1,4 +1,4 @@ - + diff --git a/question/type/randomsamatch/questiontype.php b/question/type/randomsamatch/questiontype.php index 5f9bba05f3d..710fea31790 100644 --- a/question/type/randomsamatch/questiontype.php +++ b/question/type/randomsamatch/questiontype.php @@ -1,4 +1,4 @@ -notification("Couldn't get question options (id=$response[0])!"); return false; } - + // Now we overwrite the $question->options->answers field to only // *one* (the first) correct answer. This loop can be deleted to // take all answers into account (i.e. put them all into the @@ -292,14 +292,14 @@ class question_randomsamatch_qtype extends question_match_qtype { } else { $categorylist = $question->category; } - + $question->options->subquestions = $this->get_sa_candidates($categorylist); foreach ($question->options->subquestions as $key => $wrappedquestion) { if (!$QTYPES[$wrappedquestion->qtype] ->get_question_options($wrappedquestion)) { return false; } - + // Now we overwrite the $question->options->answers field to only // *one* (the first) correct answer. This loop can be deleted to // take all answers into account (i.e. put them all into the @@ -454,4 +454,4 @@ class question_randomsamatch_qtype extends question_match_qtype { //// INITIATION - Without this line the question type is not in use... /// ////////////////////////////////////////////////////////////////////////// question_register_questiontype(new question_randomsamatch_qtype()); -?> + diff --git a/question/type/randomsamatch/version.php b/question/type/randomsamatch/version.php index fd7780c1c1a..3e15273118d 100644 --- a/question/type/randomsamatch/version.php +++ b/question/type/randomsamatch/version.php @@ -1,6 +1,6 @@ -version = 2006042800; $plugin->requires = 2007101000; -?> + diff --git a/question/type/shortanswer/db/upgrade.php b/question/type/shortanswer/db/upgrade.php index e0097e0abb7..34351562d8f 100644 --- a/question/type/shortanswer/db/upgrade.php +++ b/question/type/shortanswer/db/upgrade.php @@ -1,6 +1,6 @@ -get_manager(); $result = true; -/// And upgrade begins here. For each one, you'll need one -/// block of code similar to the next one. Please, delete +/// And upgrade begins here. For each one, you'll need one +/// block of code similar to the next one. Please, delete /// this comment lines once this file start handling proper /// upgrade code. @@ -38,4 +38,4 @@ function xmldb_qtype_shortanswer_upgrade($oldversion) { return $result; } -?> + diff --git a/question/type/shortanswer/display.html b/question/type/shortanswer/display.html index 375a20b4280..0a8944fdbb1 100644 --- a/question/type/shortanswer/display.html +++ b/question/type/shortanswer/display.html @@ -10,7 +10,7 @@
- qtype == 'numerical' || $question->qtype == 'calculated' || $question->qtype == 'calculatedsimple' ){ + qtype == 'numerical' || $question->qtype == 'calculated' || $question->qtype == 'calculatedsimple' ){ include("$CFG->dirroot/question/type/numerical/display.html");?>
diff --git a/question/type/shortanswer/edit_shortanswer_form.php b/question/type/shortanswer/edit_shortanswer_form.php index cede3cc74bb..fae996e4642 100644 --- a/question/type/shortanswer/edit_shortanswer_form.php +++ b/question/type/shortanswer/edit_shortanswer_form.php @@ -1,4 +1,4 @@ - \ No newline at end of file diff --git a/question/type/shortanswer/questiontype.php b/question/type/shortanswer/questiontype.php index 061fdec38ea..e023f003475 100644 --- a/question/type/shortanswer/questiontype.php +++ b/question/type/shortanswer/questiontype.php @@ -1,4 +1,4 @@ -feedback) { $class = question_get_feedback_class(0); $feedbackimg = question_get_feedback_image(0); - //this is OK for the first answer with a good response + //this is OK for the first answer with a good response foreach($question->options->answers as $answer) { if ($this->test_response($question, $state, $answer)) { @@ -322,7 +322,7 @@ class question_shortanswer_qtype extends default_questiontype { } // let student know wether the answer was correct - $class = question_get_feedback_class($state->last_graded->raw_grade / + $class = question_get_feedback_class($state->last_graded->raw_grade / $question->maxgrade); echo '
' . get_string($class, 'quiz'); if ($correctanswer && ($class == 'partiallycorrect' || $class == 'incorrect')) { @@ -348,7 +348,7 @@ class question_shortanswer_qtype extends default_questiontype { // A penalty was applied so display it echo ' '.$grade->numerical; //print_string('gradingdetailspenalty', 'quiz', question_format_grade($cmoptions, $this->raw_unitpenalty)); - echo ' '; + echo ' '; print_string('gradingdetailspenalty', 'quiz', question_format_grade($cmoptions, $state->last_graded->penalty)); } else { /* No penalty was applied even though the answer was @@ -399,4 +399,4 @@ class question_shortanswer_qtype extends default_questiontype { //// INITIATION - Without this line the question type is not in use... /// ////////////////////////////////////////////////////////////////////////// question_register_questiontype(new question_shortanswer_qtype()); -?> + diff --git a/question/type/shortanswer/simpletest/testquestiontype.php b/question/type/shortanswer/simpletest/testquestiontype.php index 523819975d3..ddb09c88094 100644 --- a/question/type/shortanswer/simpletest/testquestiontype.php +++ b/question/type/shortanswer/simpletest/testquestiontype.php @@ -1,4 +1,4 @@ - + diff --git a/question/type/shortanswer/version.php b/question/type/shortanswer/version.php index c39730578d9..1950094efc8 100644 --- a/question/type/shortanswer/version.php +++ b/question/type/shortanswer/version.php @@ -1,6 +1,6 @@ -version = 2006032200; $plugin->requires = 2007101000; -?> + diff --git a/question/type/simpletest/testquestiontype.php b/question/type/simpletest/testquestiontype.php index 7a9be84d68f..77e07b15471 100644 --- a/question/type/simpletest/testquestiontype.php +++ b/question/type/simpletest/testquestiontype.php @@ -1,4 +1,4 @@ - + diff --git a/question/type/truefalse/db/upgrade.php b/question/type/truefalse/db/upgrade.php index c2b85e99bbc..5495c6251e0 100644 --- a/question/type/truefalse/db/upgrade.php +++ b/question/type/truefalse/db/upgrade.php @@ -1,6 +1,6 @@ -get_manager(); $result = true; -/// And upgrade begins here. For each one, you'll need one -/// block of code similar to the next one. Please, delete +/// And upgrade begins here. For each one, you'll need one +/// block of code similar to the next one. Please, delete /// this comment lines once this file start handling proper /// upgrade code. @@ -38,4 +38,4 @@ function xmldb_qtype_truefalse_upgrade($oldversion) { return $result; } -?> + diff --git a/question/type/truefalse/display.html b/question/type/truefalse/display.html index 6cc2e49bd4b..2bd99a5702c 100644 --- a/question/type/truefalse/display.html +++ b/question/type/truefalse/display.html @@ -8,7 +8,7 @@
- : + :
diff --git a/question/type/truefalse/edit_truefalse_form.php b/question/type/truefalse/edit_truefalse_form.php index 4ee306d0e75..1bc8604b053 100644 --- a/question/type/truefalse/edit_truefalse_form.php +++ b/question/type/truefalse/edit_truefalse_form.php @@ -1,4 +1,4 @@ -dirroot.'/question/type/edit_question_form.php'); /** * Defines the editing form for the thruefalse question type. @@ -50,4 +50,3 @@ class question_edit_truefalse_form extends question_edit_form { return 'truefalse'; } } -?> \ No newline at end of file diff --git a/question/type/truefalse/questiontype.php b/question/type/truefalse/questiontype.php index db745801d61..87ae461e071 100644 --- a/question/type/truefalse/questiontype.php +++ b/question/type/truefalse/questiontype.php @@ -1,4 +1,4 @@ - + diff --git a/question/type/truefalse/version.php b/question/type/truefalse/version.php index c39730578d9..1950094efc8 100644 --- a/question/type/truefalse/version.php +++ b/question/type/truefalse/version.php @@ -1,6 +1,6 @@ -version = 2006032200; $plugin->requires = 2007101000; -?> + diff --git a/question/upgrade.php b/question/upgrade.php index ab51ad7c9e5..8f0c952097f 100644 --- a/question/upgrade.php +++ b/question/upgrade.php @@ -1,4 +1,4 @@ -execute("UPDATE {question} SET parent = id WHERE qtype = 'random' AND parent <> id"); } -?> + diff --git a/theme/orangewhitepda/styles_pda.css b/theme/orangewhitepda/styles_pda.css index 39d58bc9db3..eca14d0a95f 100644 --- a/theme/orangewhitepda/styles_pda.css +++ b/theme/orangewhitepda/styles_pda.css @@ -1,5 +1,3 @@ -/* $Id$ */ - /************************************************* *** *** pda