Skip to content

Commit

Permalink
Merge pull request #6 from ucl-isd/CTP-3685-Coursework-removed-mysql-…
Browse files Browse the repository at this point in the history
…functions

CTP-3685 remove has_disability()
  • Loading branch information
aspark21 authored Aug 20, 2024
2 parents 4cc98a7 + 9b078ae commit 3024b55
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 58 deletions.
11 changes: 0 additions & 11 deletions classes/models/submission.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
47 changes: 0 additions & 47 deletions lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 3024b55

Please sign in to comment.