From 9b078ae02c15d8a9f5088f937790a68e6da3313e Mon Sep 17 00:00:00 2001 From: David Watson <14983002+watson8@users.noreply.github.com> Date: Tue, 20 Aug 2024 11:54:18 +0100 Subject: [PATCH] CTP-3685 remove has_disability() --- classes/models/submission.php | 11 -------- lib.php | 47 ----------------------------------- 2 files changed, 58 deletions(-) diff --git a/classes/models/submission.php b/classes/models/submission.php index 2b848ffd..7151e527 100644 --- a/classes/models/submission.php +++ b/classes/models/submission.php @@ -285,17 +285,6 @@ public function has_feedback() { return (count($this->feedbacks) > 0); } - /** - * Returns whether or not the student that made the submission has a disability. - * - * @return bool - */ - public function has_disability() { - global $DB; - $user = user::get_object($this->userid); - return (!empty($user)) ? has_disability($user->username) : false; - } - /** * Gets the file options for file managers and submission save operations from the parent * coursework. diff --git a/lib.php b/lib.php index 8236a50b..c6bb773a 100644 --- a/lib.php +++ b/lib.php @@ -766,53 +766,6 @@ function coursework_supports($feature) { } } -/** - * Checks whether the student with the given username has been flagged - * as having a disability - * - * @param string $username - * @return bool - */ -function has_disability($username) { - global $CFG; - - // TODO we are assuming a lot here. - $dbhost = $CFG->dbhost; - $dbuser = $CFG->dbuser; - $dbpass = $CFG->dbpass; - - $disabilitydb = 'exuimport'; - $disabilitycolumn = 'DISABILITY_CODE'; - $disabilitytable = 'ELE_STUDENT_ACCOUNTS'; - $usernamefield = 'USERNAME'; - $hasdisabilityvalue = 'Y'; - - $sql = "SELECT {$disabilitycolumn} - FROM {$disabilitytable} - WHERE {$usernamefield} = '{$username}'"; - - // TODO make this use normal Moodle DB functions. - $dbconnection = mysql_connect($dbhost, $dbuser, $dbpass); - if (!$dbconnection) { - return false; - } - if (!mysql_select_db($disabilitydb, $dbconnection)) { - return false; - } - $disabilities = mysql_query($sql, $dbconnection); - if (!$disabilities) { - return false; - } - $row = mysql_fetch_assoc($disabilities); - if (!$row || empty($row[$disabilitycolumn])) { - return false; - } - // TODO get all data at once and cache it as a static variable - mysql_close($dbconnection); // Inefficient - we will be doing this a lot sometimes. - - return ($row[$disabilitycolumn] == $hasdisabilityvalue) ? true : false; -} - /** * Puts items in order of their configured display order within forms data, so that responses are * always displayed the same way the form was when the respondents filled it in.