CEHD Customizations

Customizations for COURSES15

From courses14 (php settings are on server not specific to an instance of moodle)

PHP Settings

Set max_input_vars = 5000 (default is 1000, 5000 may not be completely necessary, but works)

With a limit of 1000, manual backups may fail for complex courses since the number of options when making a backup is proportional to the number of topics, quizzes, assignments, etc.  1000 failed for Bob Hall's 435/635 course.


CAS Auth

COURSES15 is Moodle 2.7.  The CAS code changed so different changes will be needed

To increase the reliability of the login process, we are using the UIN rather than the NetID from the CAS payload. To make this happen, the following changes were made to the CAS module.


 Beginning around line 2805 within validateCAS20
 // CEHD Customization. Changed "user" to "tamuEduPersonUIN"
         if ( $success_elements->item(0)->getElementsByTagName("user")->length == 0) {
  Modified To 
       if ( $success_elements->item(0)->getElementsByTagName("tamuEduPersonUIN")->length == 0) {

The service to be sent to CAS is being constructed on the fly and is including the alternate ports we used on the backend.  This breaks CAS.  We have to disable this functionality.

In the function _getServerUrl (in Client.php), comment out the section that adds a port number if a non-standard one is being used.

// CEHD Customization
// We are running the backends on alternate ports which are confusing this function.
            if ( ($this->_isHttps() && $server_port!=443)
                || (!$this->_isHttps() && $server_port!=80)
            ) {
                $server_url .= ':';
                $server_url .= $server_port;



Moodle's CAS plugin presumes the existence of an LDAP server to check against.  The only consequence of this we have found is that it prevents the changing the username of a CAS user (since it assumes the user is in a LDAP DB and hence shouldn't be changed through Moodle).  This hack prevents that check so username changes can be performed.  Note.  There is little reason for the username to change (since we are using the UIN rather than Net ID-- see above -- but it is handy for testing purposes to be able to change the username=uin of a user.

To allow changing the username of a CAS user, comment out the check in auth/ldap/auth.php

function user_update($olduser, $newuser) {
    global $USER;
// CEHD. CAS builds on the LDAP library.  But, there is no reason to disallow username changes for CAS users in our case.
//    if (isset($olduser->username) and isset($newuser->username) and $olduser->username != $newuser->username) {
//        error_log($this->errorlogtag.get_string('renamingnotallowed', 'auth_ldap'));
//        return false;
//    }

CAS Language Update

Replace the language strings in auth/cas/lang/en/auth_cas.php for accessCAS and accessNOCAS with

  • $string['accesCAS'] = 'Login for Texas A&M Students, Faculty and Staff';
    $string['accesNOCAS'] = 'Login for others';

Add IP Address to Quiz Attempts Report


Changed function base_sql (function begins at approx line 387)

Appended the IP address to the SELECT list

// CEHD Customization to display IP address on quiz attempts report
$fields .= ', log.ip as ipaddress';

Joined the Log table (where the IP address is stored) to the query

        // CEHD Customization
//                     quiza.quiz=log.info
        $from .= " LEFT JOIN {logstore_standard_log} log ON (
                     AND component='mod_quiz'
                     AND action='submitted'
                     AND target='attempt'
                     AND log.timecreated BETWEEN quiza.timefinish-3 AND quiza.timefinish+3

// END CEHD Customization

We have seen a pretty large discrepancy between the quiz attempt time and the log time so have had to use a big time cushion.


Altered function add_time_columns (function begins at approx line 217)

Added these lines to display the IP address in the table just prior to the time start/finish columns

$columns[] = 'ipaddress';   // CEHD Customization
$headers[] = "IP Address";  // CEHD Customization

Certificate Module

The Backup/Restore process does not translate userids between system.  A single line was missing from the restore script (mod/certificate/backup/moodle2/restore_certificate_stepslib.php) -- see below.

    protected function process_certificate_issue($data) {
        global $DB;

        $data = (object)$data;
        $oldid = $data->id;

        $data->certificateid = $this->get_new_parentid('certificate');
        $data->timecreated = $this->apply_date_offset($data->timecreated);

        // CEHD Customization.  this line is needed to allow the the userid to be translated properly between sites
        $data->userid = $this->get_mappingid('user', $data->userid);

        $newitemid = $DB->insert_record('certificate_issues', $data);
        $this->set_mapping('certificate_issue', $oldid, $newitemid);

The Remaining Sections No Longer Appear to be Necessary

Correct Button Display (Skipping on 5/28/2013.  This may have been fixed since may 2012)

Apply Patch: http://tracker.moodle.org/secure/attachment/27782/patch.patch (5/29/2012)

  • I am skipping the 3rd part of the patch because it appears the file has changed with the latest upgrade.


Certificate Module (Skipping on 5/28/2013.  This may have been fixed since may 2012)

Awaiting confirmation from Michelle that this resolved the problem.

Edit mod/certificate/lib.php

function certificate_issue($course, $certrecord, $cm) {
    global $USER, $DB, $certificate;

function certificate_issue($course, $certificate, $certrecord, $cm) {
    global $USER, $DB;

  • This patch no longer seems necessary with the latest upgrade of this module