Modification to hide CourseID from Faculty

Modification to hide CourseID from Faculty

by Van Howell -
Number of replies: 2

I had a problem with Faculty changing the CourseID number in a course that had been autocreated using enrol_database_sync.php.
So I have made a modification to course/edit_form.pnp that hides the courseID from anyone without the Admin role
at Line 78 I have added this test...

if(has_capability('moodle/site:doanything',$categorycontext)) {
       $mform->addElement('text','idnumber', get_string('idnumbercourse'),'maxlength="100"  size="10"');
       $mform->setHelpButton('idnumber', array('courseidnumber', get_string('idnumbercourse')), true);
       $mform->setType('idnumber', PARAM_RAW);
 }else{
      $mvorm->addElement('hidden','idnumber', getstring('idnumbercourse'));
        }
It seems to work. My question is do I need the else that adds the hidden element. I had assumed that without it the data in the database would be removed.

If this works I want to hide other fields like user/idnumber that is my key for ldap auth.

V

Average of ratings: -
In reply to Van Howell

Re: Modification to hide CourseID from Faculty

by Van Howell -

I noticed the error

$mvorm->addElement('hidden','idnumber', getstring('idnumbercourse'));
should be
$mform->addElement('hidden','idnumber', get_string('idnumbercourse'));

Sorry

V

In reply to Van Howell

Re: Modification to hide CourseID from Faculty

by Iñaki Arenaza -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

My question is do I need the else that adds the hidden element. I had assumed that without it the data in the database would be removed.

I'm not a moodleform's expert by any means, but a fast read of the code makes me think your assumption is right.

Saludos. Iñaki.