if (isset($_REQUEST['add']) and confirm_sesskey()) { /// Add selected questions to the current quiz
foreach ($_POST as $key => $value) { // Parse input for question ids
- if (preg_match('!q([0-9]+)!', $key, $matches)) {
+ if (preg_match('!^q([0-9]+)$!', $key, $matches)) {
$key = $matches[1];
quiz_add_quiz_question($key, $quiz);
}
$rawgrades = $_POST;
unset($quiz->grades);
foreach ($rawgrades as $key => $value) { // Parse input for question -> grades
- if (preg_match('!q([0-9]+)!', $key, $matches)) {
+ if (preg_match('!^q([0-9]+)$!', $key, $matches)) {
$key = $matches[1];
$quiz->grades[$key] = $value;
quiz_update_question_instance($quiz->grades[$key], $key, $quiz->instance);
- } elseif (preg_match('!q([0-9]+)!', $key, $matches)) { // Parse input for ordering info
+ } elseif (preg_match('!^q([0-9]+)$!', $key, $matches)) { // Parse input for ordering info
$key = $matches[1];
$questions[$value] = $oldquestions[$key];
}
error(get_string('categorynoedit', 'quiz', $tocategory->name), $pageurl->out());
}
foreach ($_POST as $key => $value) { // Parse input for question ids
- if (preg_match('!q([0-9]+)!', $key, $matches)) {
+ if (preg_match('!^q([0-9]+)$!', $key, $matches)) {
$key = $matches[1];
if (!set_field('question', 'category', $tocategory->id, 'id', $key)) {
error('Could not update category field');
// an asterix in front of those that are in use
$inuse = false; // set to true if at least one of the questions is in use
foreach ($rawquestions as $key => $value) { // Parse input for question ids
- if (preg_match('!q([0-9]+)!', $key, $matches)) {
+ if (preg_match('!^q([0-9]+)$!', $key, $matches)) {
$key = $matches[1]; $questionlist .= $key.',';
if (record_exists('quiz_question_instances', 'question', $key) or
record_exists('question_states', 'originalquestion', $key)) {