Skip to content

Commit 3024b55

Browse files
authored
Merge pull request #6 from ucl-isd/CTP-3685-Coursework-removed-mysql-functions
CTP-3685 remove has_disability()
2 parents 4cc98a7 + 9b078ae commit 3024b55

File tree

2 files changed

+0
-58
lines changed

2 files changed

+0
-58
lines changed

classes/models/submission.php

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -285,17 +285,6 @@ public function has_feedback() {
285285
return (count($this->feedbacks) > 0);
286286
}
287287

288-
/**
289-
* Returns whether or not the student that made the submission has a disability.
290-
*
291-
* @return bool
292-
*/
293-
public function has_disability() {
294-
global $DB;
295-
$user = user::get_object($this->userid);
296-
return (!empty($user)) ? has_disability($user->username) : false;
297-
}
298-
299288
/**
300289
* Gets the file options for file managers and submission save operations from the parent
301290
* coursework.

lib.php

Lines changed: 0 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -766,53 +766,6 @@ function coursework_supports($feature) {
766766
}
767767
}
768768

769-
/**
770-
* Checks whether the student with the given username has been flagged
771-
* as having a disability
772-
*
773-
* @param string $username
774-
* @return bool
775-
*/
776-
function has_disability($username) {
777-
global $CFG;
778-
779-
// TODO we are assuming a lot here.
780-
$dbhost = $CFG->dbhost;
781-
$dbuser = $CFG->dbuser;
782-
$dbpass = $CFG->dbpass;
783-
784-
$disabilitydb = 'exuimport';
785-
$disabilitycolumn = 'DISABILITY_CODE';
786-
$disabilitytable = 'ELE_STUDENT_ACCOUNTS';
787-
$usernamefield = 'USERNAME';
788-
$hasdisabilityvalue = 'Y';
789-
790-
$sql = "SELECT {$disabilitycolumn}
791-
FROM {$disabilitytable}
792-
WHERE {$usernamefield} = '{$username}'";
793-
794-
// TODO make this use normal Moodle DB functions.
795-
$dbconnection = mysql_connect($dbhost, $dbuser, $dbpass);
796-
if (!$dbconnection) {
797-
return false;
798-
}
799-
if (!mysql_select_db($disabilitydb, $dbconnection)) {
800-
return false;
801-
}
802-
$disabilities = mysql_query($sql, $dbconnection);
803-
if (!$disabilities) {
804-
return false;
805-
}
806-
$row = mysql_fetch_assoc($disabilities);
807-
if (!$row || empty($row[$disabilitycolumn])) {
808-
return false;
809-
}
810-
// TODO get all data at once and cache it as a static variable
811-
mysql_close($dbconnection); // Inefficient - we will be doing this a lot sometimes.
812-
813-
return ($row[$disabilitycolumn] == $hasdisabilityvalue) ? true : false;
814-
}
815-
816769
/**
817770
* Puts items in order of their configured display order within forms data, so that responses are
818771
* always displayed the same way the form was when the respondents filled it in.

0 commit comments

Comments
 (0)