From 56b0df7eac20aef920dfe4f6844232944e53d8d2 Mon Sep 17 00:00:00 2001 From: Tim Hunt Date: Fri, 11 Mar 2011 13:45:38 +0000 Subject: [PATCH] MDL-20636 Kill Left over addslashes in the question engine code. #223 --- .../report/statistics/responseanalysis.php | 2 +- question/engine/datalib.php | 28 +++++++++---------- question/engine/upgradefromoldqe/upgrade.php | 4 +-- question/format/xml/format.php | 2 +- question/type/opaque/locallib.php | 2 +- 5 files changed, 19 insertions(+), 19 deletions(-) diff --git a/mod/quiz/report/statistics/responseanalysis.php b/mod/quiz/report/statistics/responseanalysis.php index 0f9bea00f44..b3dd4336fa7 100644 --- a/mod/quiz/report/statistics/responseanalysis.php +++ b/mod/quiz/report/statistics/responseanalysis.php @@ -206,7 +206,7 @@ class quiz_statistics_response_analyser { } else { $row->aid = $responseclassid; } - $row->response = addslashes($response); + $row->response = $response; $row->rcount = $data->count; $row->credit = $data->fraction; $DB->insert_record('quiz_question_response_stats', $row, false); diff --git a/question/engine/datalib.php b/question/engine/datalib.php index 29a7052e382..4efafbe0c3f 100644 --- a/question/engine/datalib.php +++ b/question/engine/datalib.php @@ -62,8 +62,8 @@ class question_engine_data_mapper { public function insert_questions_usage_by_activity(question_usage_by_activity $quba) { $record = new stdClass(); $record->contextid = $quba->get_owning_context()->id; - $record->component = addslashes($quba->get_owning_component()); - $record->preferredbehaviour = addslashes($quba->get_preferred_behaviour()); + $record->component = $quba->get_owning_component(); + $record->preferredbehaviour = $quba->get_preferred_behaviour(); $newid = $this->db->insert_record('question_usages', $record); $quba->set_id_from_database($newid); @@ -82,14 +82,14 @@ class question_engine_data_mapper { $record = new stdClass(); $record->questionusageid = $qa->get_usage_id(); $record->slot = $qa->get_slot(); - $record->behaviour = addslashes($qa->get_behaviour_name()); + $record->behaviour = $qa->get_behaviour_name(); $record->questionid = $qa->get_question()->id; $record->maxmark = $qa->get_max_mark(); $record->minfraction = $qa->get_min_fraction(); $record->flagged = $qa->is_flagged(); - $record->questionsummary = addslashes($qa->get_question_summary()); - $record->rightanswer = addslashes($qa->get_right_answer_summary()); - $record->responsesummary = addslashes($qa->get_response_summary()); + $record->questionsummary = $qa->get_question_summary(); + $record->rightanswer = $qa->get_right_answer_summary(); + $record->responsesummary = $qa->get_response_summary(); $record->timemodified = time(); $record->id = $this->db->insert_record('question_attempts', $record); @@ -107,7 +107,7 @@ class question_engine_data_mapper { $record = new stdClass(); $record->questionattemptid = $questionattemptid; $record->sequencenumber = $seq; - $record->state = addslashes('' . $step->get_state()); + $record->state = '' . $step->get_state(); $record->fraction = $step->get_fraction(); $record->timecreated = $step->get_timecreated(); $record->userid = $step->get_user_id(); @@ -117,8 +117,8 @@ class question_engine_data_mapper { foreach ($step->get_all_data() as $name => $value) { $data = new stdClass(); $data->attemptstepid = $record->id; - $data->name = addslashes($name); - $data->value = addslashes($value); + $data->name = $name; + $data->value = $value; $this->db->insert_record('question_attempt_step_data', $data, false); } } @@ -596,8 +596,8 @@ ORDER BY $record = new stdClass(); $record->id = $quba->get_id(); $record->contextid = $quba->get_owning_context()->id; - $record->component = addslashes($quba->get_owning_component()); - $record->preferredbehaviour = addslashes($quba->get_preferred_behaviour()); + $record->component = $quba->get_owning_component(); + $record->preferredbehaviour = $quba->get_preferred_behaviour(); $this->db->update_record('question_usages', $record); } @@ -613,9 +613,9 @@ ORDER BY $record->maxmark = $qa->get_max_mark(); $record->minfraction = $qa->get_min_fraction(); $record->flagged = $qa->is_flagged(); - $record->questionsummary = addslashes($qa->get_question_summary()); - $record->rightanswer = addslashes($qa->get_right_answer_summary()); - $record->responsesummary = addslashes($qa->get_response_summary()); + $record->questionsummary = $qa->get_question_summary(); + $record->rightanswer = $qa->get_right_answer_summary(); + $record->responsesummary = $qa->get_response_summary(); $record->timemodified = time(); $this->db->update_record('question_attempts', $record); diff --git a/question/engine/upgradefromoldqe/upgrade.php b/question/engine/upgradefromoldqe/upgrade.php index 2c708c204c9..3496665e357 100644 --- a/question/engine/upgradefromoldqe/upgrade.php +++ b/question/engine/upgradefromoldqe/upgrade.php @@ -338,7 +338,7 @@ class question_engine_attempt_upgrader { protected function escape_fields($record) { foreach (get_object_vars($record) as $field => $value) { if (is_string($value)) { - $record->$field = addslashes($value); + $record->$field = $value; } } } @@ -747,7 +747,7 @@ abstract class qbehaviour_converter { $this->process_state($submitstate); } - $step->data['-comment'] = addslashes($this->qsession->manualcomment); + $step->data['-comment'] = $this->qsession->manualcomment; if ($this->question->maxmark > 0) { $step->fraction = $state->grade / $this->question->maxmark; $step->state = $this->manual_graded_state_for_fraction($step->fraction); diff --git a/question/format/xml/format.php b/question/format/xml/format.php index 9c22c7d750d..4176329d4d4 100644 --- a/question/format/xml/format.php +++ b/question/format/xml/format.php @@ -1251,7 +1251,7 @@ class qformat_xml extends qformat_default { case 'multianswer': $acount = 1; foreach ($question->options->questions as $question) { - $thispattern = addslashes("{#".$acount."}"); + $thispattern = "{#".$acount."}"; $thisreplace = $question->questiontext; $expout = preg_replace("~$thispattern~", $thisreplace, $expout ); $acount++; diff --git a/question/type/opaque/locallib.php b/question/type/opaque/locallib.php index 58da3925054..561f5bd866c 100644 --- a/question/type/opaque/locallib.php +++ b/question/type/opaque/locallib.php @@ -195,7 +195,7 @@ class qtype_opaque_engine_manager { if ($possibleengineids) { foreach ($possibleengineids as $engineid => $ignored) { $testengine = $this->load_engine_def($engineid); - $testengine->passkey = addslashes($testengine->passkey); + $testengine->passkey = $testengine->passkey; if ($this->is_same_engine($engine, $testengine)) { return $engineid; }