MDL-20636 Merge remote-tracking branch 'moodle/master' into upgrade

Conflicts:
	lib/filestorage/file_storage.php
	mod/quiz/attemptlib.php
	mod/quiz/lib.php
	mod/quiz/mod_form.php
	mod/quiz/report/overview/overview_table.php
	mod/quiz/report/overview/report.php
	mod/quiz/report/responses/report.php
	mod/quiz/report/responses/responses_table.php
	mod/quiz/report/statistics/db/install.xml
	mod/quiz/report/statistics/qstats.php
	mod/quiz/report/statistics/report.php
	mod/quiz/report/statistics/statistics_question_table.php
	mod/quiz/report/statistics/statistics_table.php
	mod/quiz/report/statistics/version.php
	mod/quiz/review.php
	mod/quiz/reviewquestion.php
	mod/quiz/startattempt.php
	mod/quiz/styles.css
	mod/quiz/view.php
	question/type/essay/questiontype.php
	question/type/match/backup/moodle2/backup_qtype_match_plugin.class.php
	question/type/match/backup/moodle2/restore_qtype_match_plugin.class.php
	question/type/numerical/display.html
	question/type/numerical/questiontype.php
	question/type/questiontype.php
	question/type/random/questiontype.php
	question/type/shortanswer/questiontype.php
	theme/base/style/question.css
This commit is contained in:
Tim Hunt
2011-05-11 20:29:49 +01:00
1225 changed files with 22803 additions and 8568 deletions
+1 -1
View File
@@ -1106,7 +1106,7 @@ class question_bank_view {
} else {
$categoryids = array($category->id);
}
list($catidtest, $params) = $DB->get_in_or_equal($categoryids, SQL_PARAMS_NAMED, 'cat0000');
list($catidtest, $params) = $DB->get_in_or_equal($categoryids, SQL_PARAMS_NAMED, 'cat');
$tests[] = 'q.category ' . $catidtest;
$this->sqlparams = $params;
+1 -1
View File
@@ -328,7 +328,7 @@ class question_finder {
public function get_questions_from_categories($categoryids, $extraconditions, $extraparams = array()) {
global $DB;
list($qcsql, $qcparams) = $DB->get_in_or_equal($categoryids, SQL_PARAMS_NAMED, 'qc0000');
list($qcsql, $qcparams) = $DB->get_in_or_equal($categoryids, SQL_PARAMS_NAMED, 'qc');
if ($extraconditions) {
$extraconditions = ' AND (' . $extraconditions . ')';
+11 -10
View File
@@ -282,7 +282,7 @@ ORDER BY
* @return array of records. See the SQL in this function to see the fields available.
*/
public function load_questions_usages_latest_steps(qubaid_condition $qubaids, $slots) {
list($slottest, $params) = $this->db->get_in_or_equal($slots, SQL_PARAMS_NAMED, 'slot0000');
list($slottest, $params) = $this->db->get_in_or_equal($slots, SQL_PARAMS_NAMED, 'slot');
$records = $this->db->get_records_sql("
SELECT
@@ -331,7 +331,7 @@ WHERE
* $manuallygraded and $all.
*/
public function load_questions_usages_question_state_summary(qubaid_condition $qubaids, $slots) {
list($slottest, $params) = $this->db->get_in_or_equal($slots, SQL_PARAMS_NAMED, 'slot0000');
list($slottest, $params) = $this->db->get_in_or_equal($slots, SQL_PARAMS_NAMED, 'slot');
$rs = $this->db->get_recordset_sql("
SELECT
@@ -486,7 +486,7 @@ $sqlorderby
*/
public function load_average_marks(qubaid_condition $qubaids, $slots = null) {
if (!empty($slots)) {
list($slottest, $slotsparams) = $this->db->get_in_or_equal($slots, SQL_PARAMS_NAMED, 'slot0000');
list($slottest, $slotsparams) = $this->db->get_in_or_equal($slots, SQL_PARAMS_NAMED, 'slot');
$slotwhere = " AND qa.slot $slottest";
} else {
$slotwhere = '';
@@ -501,7 +501,7 @@ $sqlorderby
question_state::$mangaveup,
question_state::$mangrwrong,
question_state::$mangrpartial,
question_state::$mangrright), SQL_PARAMS_NAMED, 'st00');
question_state::$mangrright), SQL_PARAMS_NAMED, 'st');
return $this->db->get_records_sql("
SELECT
@@ -642,7 +642,7 @@ ORDER BY
$contextids = $this->db->get_records_sql_menu("
SELECT DISTINCT contextid, 1
FROM {question_usages}
WHERE id {$qubaids->usage_id_in()}", $params);
WHERE id {$qubaids->usage_id_in()}", $qubaids->usage_id_in_params());
foreach ($contextids as $contextid => $notused) {
$this->delete_response_files($contextid, "IN (
SELECT qas.id
@@ -663,10 +663,11 @@ ORDER BY
WHERE $where)", $params);
$this->db->delete_records_select('question_attempts',
"{question_attempts}.questionusageid {$qubaids->usage_id_in()}", $params);
"{question_attempts}.questionusageid {$qubaids->usage_id_in()}",
$qubaids->usage_id_in_params());
$this->db->delete_records_select('question_usages',
"{question_usages}.id {$qubaids->usage_id_in()}", $params);
"{question_usages}.id {$qubaids->usage_id_in()}", $qubaids->usage_id_in_params());
}
/**
@@ -764,7 +765,7 @@ ORDER BY
*/
public function in_summary_state_test($summarystate, $equal = true, $prefix = 'summarystates') {
$states = question_state::get_all_for_summary_state($summarystate);
return $this->db->get_in_or_equal($states, SQL_PARAMS_NAMED, $prefix . '00', $equal);
return $this->db->get_in_or_equal($states, SQL_PARAMS_NAMED, $prefix, $equal);
}
/**
@@ -1147,7 +1148,7 @@ class qubaid_list extends qubaid_condition {
$this->params = array();
return '1 = 0';
}
list($where, $this->params) = $DB->get_in_or_equal($this->qubaids, SQL_PARAMS_NAMED, 'qubaid0000');
list($where, $this->params) = $DB->get_in_or_equal($this->qubaids, SQL_PARAMS_NAMED, 'qubaid');
return $this->columntotest . ' ' . $this->usage_id_in();
}
@@ -1162,7 +1163,7 @@ class qubaid_list extends qubaid_condition {
if (empty($this->qubaids)) {
return '= 0';
}
list($where, $this->params) = $DB->get_in_or_equal($this->qubaids, SQL_PARAMS_NAMED, 'qubaid0000');
list($where, $this->params) = $DB->get_in_or_equal($this->qubaids, SQL_PARAMS_NAMED, 'qubaid');
return $where;
}
+7 -7
View File
@@ -64,8 +64,8 @@ class qubaid_condition_test extends UnitTestCase {
$this->check_typical_question_attempts_query($qubaids,
"SELECT qa.id, qa.maxmark
FROM {question_attempts} qa
WHERE qa.questionusageid = :qubaid0000 AND qa.slot = :slot",
array('qubaid0000' => 1, 'slot' => 1));
WHERE qa.questionusageid = :qubaid8 AND qa.slot = :slot",
array('qubaid8' => 1, 'slot' => 1));
}
public function test_qubaid_list_several_join() {
@@ -73,8 +73,8 @@ class qubaid_condition_test extends UnitTestCase {
$this->check_typical_question_attempts_query($qubaids,
"SELECT qa.id, qa.maxmark
FROM {question_attempts} qa
WHERE qa.questionusageid IN (:qubaid0000,:qubaid0001,:qubaid0002) AND qa.slot = :slot",
array('qubaid0000' => 1, 'qubaid0001' => 3, 'qubaid0002' => 7, 'slot' => 1));
WHERE qa.questionusageid IN (:qubaid12,:qubaid13,:qubaid14) AND qa.slot = :slot",
array('qubaid12' => 1, 'qubaid13' => 3, 'qubaid14' => 7, 'slot' => 1));
}
public function test_qubaid_join() {
@@ -103,7 +103,7 @@ class qubaid_condition_test extends UnitTestCase {
$this->check_typical_in_query($qubaids,
"SELECT qa.id, qa.maxmark
FROM {question_attempts} qa
WHERE qa.questionusageid = :qubaid0000", array('qubaid0000' => 1));
WHERE qa.questionusageid = :qubaid15", array('qubaid15' => 1));
}
public function test_qubaid_list_several_in() {
@@ -112,8 +112,8 @@ class qubaid_condition_test extends UnitTestCase {
$this->check_typical_in_query($qubaids,
"SELECT qa.id, qa.maxmark
FROM {question_attempts} qa
WHERE qa.questionusageid IN (:qubaid0000,:qubaid0001,:qubaid0002)",
array('qubaid0000' => 1, 'qubaid0001' => 2, 'qubaid0002' => 3));
WHERE qa.questionusageid IN (:qubaid16,:qubaid17,:qubaid18)",
array('qubaid16' => 1, 'qubaid17' => 2, 'qubaid18' => 3));
}
public function test_qubaid_join_in() {
@@ -124,8 +124,7 @@ class restore_qtype_match_plugin extends restore_qtype_plugin {
if ($sub) {
$this->set_mapping('question_match_sub', $oldid, $sub->id);
} else {
// Something went really wrong, cannot map subquestion for one match question
throw restore_step_exception('error_question_match_sub_missing_in_db', $data);
throw new restore_step_exception('error_question_match_sub_missing_in_db', $data);
}
}
}
+39 -4
View File
@@ -183,10 +183,6 @@ class embedded_cloze_qtype extends question_type {
}
$question->category = $authorizedquestion->category;
$form->course = $course; // To pass the course object to
// save_question_options, where it is
// needed to call type specific
// save_question methods.
$form->defaultgrade = $question->defaultgrade;
$form->questiontext = $question->questiontext;
$form->questiontextformat = 0;
@@ -616,6 +612,45 @@ class embedded_cloze_qtype extends question_type {
echo '</div>';
}
public function compare_responses($question, $state, $teststate) {
global $QTYPES;
foreach ($question->options->questions as $key => $wrapped) {
if (empty($wrapped)) {
continue;
}
$stateforquestion = clone($state);
if (isset($state->responses[$key])) {
$stateforquestion->responses[''] = $state->responses[$key];
} else {
$stateforquestion->responses[''] = '';
}
$teststateforquestion = clone($teststate);
if (isset($teststate->responses[$key])) {
$teststateforquestion->responses[''] = $teststate->responses[$key];
} else {
$teststateforquestion->responses[''] = '';
}
if ($wrapped->qtype == 'numerical') {
// Use shortanswer
if (!$QTYPES['shortanswer']->compare_responses($wrapped,
$stateforquestion, $teststateforquestion)) {
return false;
}
} else {
if (!$QTYPES[$wrapped->qtype]->compare_responses($wrapped,
$stateforquestion, $teststateforquestion)) {
return false;
}
}
}
return true;
}
function grade_responses(&$question, &$state, $cmoptions) {
global $QTYPES;
$teststate = clone($state);