From f5fa94d19928dec726367442955f4edd7bc7ec36 Mon Sep 17 00:00:00 2001 From: PMKuipers Date: Fri, 25 Aug 2023 21:57:54 +0200 Subject: [PATCH] Replaced the last php variables in SQL statements with param --- classes/associationservice.php | 6 +++--- classes/local/ungradedscanners/assign_scanner.php | 8 ++++---- classes/local/ungradedscanners/quiz_scanner.php | 8 ++++---- version.php | 7 +++++++ 4 files changed, 18 insertions(+), 11 deletions(-) diff --git a/classes/associationservice.php b/classes/associationservice.php index 677f0ae..f64f00d 100644 --- a/classes/associationservice.php +++ b/classes/associationservice.php @@ -411,10 +411,10 @@ class associationservice extends \external_api { LEFT JOIN {cohort_members} cm ON u.id = cm.userid LEFT JOIN {local_treestudyplan_cohort} tc ON cm.cohortid = tc.cohort_id LEFT JOIN {local_treestudyplan_user} tu ON u.id = tu.user_id - WHERE tc.studyplan_id = {$studyplan->id()} - OR tu.studyplan_id = {$studyplan->id()} + WHERE tc.studyplan_id = :studyplanid + OR tu.studyplan_id = :studyplanidtoo ORDER BY u.lastname, u.firstname"; - $rs = $DB->get_recordset_sql($sql); + $rs = $DB->get_recordset_sql($sql,["studyplanid" => $studyplan->id(), "studyplanidtoo" => $studyplan->id()]); foreach ($rs as $u) { $users[] = self::make_user_model($u); diff --git a/classes/local/ungradedscanners/assign_scanner.php b/classes/local/ungradedscanners/assign_scanner.php index 5ffca41..1bb5e35 100644 --- a/classes/local/ungradedscanners/assign_scanner.php +++ b/classes/local/ungradedscanners/assign_scanner.php @@ -31,13 +31,13 @@ class assign_scanner extends scanner_base { JOIN {assign} a ON a.id = asgn_sub.assignment LEFT JOIN {assign_grades} ag ON ag.assignment = asgn_sub.assignment AND ag.userid = asgn_sub.userid AND asgn_sub.attemptnumber = ag.attemptnumber - WHERE a.id = {$this->gi->iteminstance} + WHERE a.id = :iteminstance AND asgn_sub.status = 'submitted' AND asgn_sub.userid > 0 AND a.grade <> 0 AND (ag.id IS NULL OR asgn_sub.timemodified >= ag.timemodified) "; - return $DB->get_fieldset_sql($sql); + return $DB->get_fieldset_sql($sql,['iteminstance' => $this->gi->iteminstance]); } protected function get_graded_users() { @@ -45,9 +45,9 @@ class assign_scanner extends scanner_base { $sql = "SELECT DISTINCT g.userid FROM {grade_grades} g LEFT JOIN {grade_items} gi on g.itemid = gi.id - WHERE gi.itemmodule = 'assign' AND gi.iteminstance = {$this->gi->iteminstance} + WHERE gi.itemmodule = 'assign' AND gi.iteminstance = :iteminstance AND g.finalgrade IS NOT NULL"; // MAy turn out to be needed, dunno. - return $DB->get_fieldset_sql($sql); + return $DB->get_fieldset_sql($sql,['iteminstance' => $this->gi->iteminstance]); } public function count_ungraded($courseuserids = []) { diff --git a/classes/local/ungradedscanners/quiz_scanner.php b/classes/local/ungradedscanners/quiz_scanner.php index b343e66..5164afd 100644 --- a/classes/local/ungradedscanners/quiz_scanner.php +++ b/classes/local/ungradedscanners/quiz_scanner.php @@ -37,9 +37,9 @@ class quiz_scanner extends scanner_base { FROM {question_attempt_steps} qas JOIN {question_attempts} qna ON qas.questionattemptid = qna.id JOIN {quiz_attempts} qza ON qna.questionusageid = qza.uniqueid - WHERE qas.state = 'needsgrading' AND qza.quiz = {$this->gi->iteminstance}"; + WHERE qas.state = 'needsgrading' AND qza.quiz = :iteminstance"; - $rs = $DB->get_recordset_sql($sql); + $rs = $DB->get_recordset_sql($sql,['iteminstance' => $this->gi->iteminstance]); $submissions = []; foreach ($rs as $r) { // Now, check if . @@ -69,10 +69,10 @@ class quiz_scanner extends scanner_base { $sql = "SELECT DISTINCT g.userid FROM {grade_grades} g LEFT JOIN {grade_items} gi on g.itemid = gi.id - WHERE gi.itemmodule = 'quiz' AND gi.iteminstance = {$this->gi->iteminstance} + WHERE gi.itemmodule = 'quiz' AND gi.iteminstance = :iteminstance AND g.finalgrade IS NOT NULL"; // MAy turn out to be needed, dunno. - $graded = $DB->get_fieldset_sql($sql); + $graded = $DB->get_fieldset_sql($sql,['iteminstance' => $this->gi->iteminstance]); if (count($courseuserids) > 0) { $graded = array_intersect($graded, $courseuserids); diff --git a/version.php b/version.php index 285ddb8..a66852a 100644 --- a/version.php +++ b/version.php @@ -25,6 +25,13 @@ $plugin->component = 'local_treestudyplan'; // Recommended since 2.0.2 (MDL-260 $plugin->version = 2023082101; // YYYYMMDDHH (year, month, day, iteration). $plugin->requires = 2021051700; // YYYYMMDDHH (This is the release version for Moodle 3.11). +$plugin->release = "1.0.0"; +$plugin->maturity = MATURITY_RC; +// Supported from Moodle 3.11 to 4.1 (4.2 not yet tested)/ +$plugin->supported = [ 311, 401 ]; + $plugin->dependencies = [ 'theme_boost' => 2019052000, ]; + +