hello,
I am trying to add two more features to facetoface which are listed below: (the post might be a little long, but I am trying to add as much detail as possible)
1) Under "Wait-listed message" (while adding/editing facetoface activity) I am trying to add "Disable Auto Enrollment xx days before a session starts"
2) Under adding/editing sessions, I am trying to add "Disable New Enrollment xx days before a session starts"
To add the above listed functionality these are the files I have edited so far:
I think the problem is in renderer.php (ANY SUGGESTIONS on how to display the session list and improving code is GREATLY APPRECIATED)
- ./lang/en/facetoface.php : I added the following lines
$string['disableautoenroll'] = 'Disable Auto Enrollment';
$string['disableautoenroll_help'] = 'Disable the waitlist auto enrollment option when within X days of a session';
$string['disablewithindays'] = 'Days before a session starts';
$string['disablewithindays_help'] = 'Set how many days before a session starts';
$string['disableoption'] = 'Disable New Enrollment';
$string['disableoption_help'] = 'Disable a new enrollment option when within X days of a session';
$string['disablenewenrolldays'] = 'Days before a session starts';
$string['disablenewenrolldays_help'] = 'Set how many days before a session starts';
- ./session_form.php : (to display the disable new enrollment in add/edit session page)
$mform->addElement('checkbox', 'disableoption', get_string('disableoption','facetoface'));
$mform->setType('disableoption', PARAM_INT);
$mform->setDefault('disableoption', 0);
$mform->addHelpButton('disableoption', 'disableoption', 'facetoface');
$disableperiod = array();
for ($i=0; $i<=365; $i += 1) {
$disableperiod[$i] = $i;
}
$mform->addElement('select', 'disablenewenrolldays', get_string('disablenewenrolldays', 'facetoface'), $disableperiod);
$mform->setType('disablenewenrolldays', PARAM_INT);
$mform->setDefault('disablenewenrolldays', 0);
$mform->disabledIf('disablenewenrolldays', 'disableoption');
$mform->addHelpButton('disablenewenrolldays', 'disablenewenrolldays', 'facetoface');
- ./mod_form.php : (to display the disable auto enroll in the add/edit facetoface page)
$mform->addElement('checkbox', 'disableautoenroll', get_string('disableautoenroll','facetoface'));
$mform->addHelpButton('disableautoenroll', 'disableautoenroll', 'facetoface');
$disableperiod = array();
for ($i=0; $i<=365; $i += 1) {
$disableperiod[$i] = $i;
}
$mform->addElement('select', 'disablewithindays', get_string('disablewithindays', 'facetoface'),$disableperiod);
$mform->setDefault('disablewithindays', 0);
$mform->disabledIf('disablewithindays', 'disableautoenroll');
$mform->addHelpButton('disablewithindays', 'disablewithindays', 'facetoface');
- ./renderer.php : I add the following lines
elseif (!$sessionstarted and !$bookedsession) {
// $options .= html_writer::link('signup.php?s='.$session->id.'&backtoallsessions='.$session->facetoface, get_string('signup', 'facetoface'));
//AB
// $options .= html_writer::link('signup.php?s='.$session->id.'&backtoallsessions='.$session->facetoface, get_string('signup', 'facetoface'));
$currenttime = new DateTime(date('c', time()));
$start = $DB->get_record('facetoface_sessions_dates', array('sessionid'=>$session->id));
$starttime = new DateTime(date('c', $start->timestart));
$interval = $starttime->diff($currenttime);
$diffdays = $interval->format('%a');
$disableddaysDB = $DB->get_record('facetoface_sessions', array('id'=>$session->id));
$disableddays = $disableddaysDB->disablenewenrolldays;
$disableoption = $disableddaysDB->disableoption;
if($disableoption)
{
if($diffdays > $disableddays)
{
$options .= html_writer::link('signup.php?s='.$session->id.'&backtoallsessions='.$session->facetoface, get_string('signup', 'facetoface')); }
}
else
{
$options .= html_writer::link('signup.php?s='.$session->id.'&backtoallsessions='.$session->facetoface, get_string('signup', 'facetoface'));
}
- ./db/upgrade.php :
if ($oldversion < 2012051100) {
$table = new xmldb_table('facetoface');
$field = new xmldb_field('disablewithindays', XMLDB_TYPE_INTEGER, '3', null, XMLDB_NOTNULL, null, '0', 'approvalreqd');
if (!$dbman->field_exists($table, $field)) {
$dbman->add_field($table, $field);
}
// facetoface savepoint reached
upgrade_mod_savepoint(true, 2012051100, 'facetoface');
}
if ($oldversion < 2012051200) {
$table = new xmldb_table('facetoface_sessions');
$field = new xmldb_field('disablenewenrolldays', XMLDB_TYPE_INTEGER, '3', null, XMLDB_NOTNULL, null, '0', 'timemodified');
if (!$dbman->field_exists($table, $field)) {
$dbman->add_field($table, $field);
}
// facetoface savepoint reached
upgrade_mod_savepoint(true, 2012051200, 'facetoface');
}
if ($oldversion < 2012053002) {
$table = new xmldb_table('facetoface_sessions');
$field = new xmldb_field('disableoption', XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, null, null, null, 'disablenewenrolldays');
if (!$dbman->field_exists($table, $field)) {
$dbman->add_field($table, $field);
}
// facetoface savepoint reached
upgrade_mod_savepoint(true, 2012053002, 'facetoface');
}
- ./db/install.xml
- under the table "facetoface"
<FIELD NAME="usercalentry" TYPE="int" LENGTH="1" NOTNULL="true" UNSIGNED="true" DEFAULT="1" SEQUENCE="false" PREVIOUS="approvalreqd" NEXT="disablewithindays"/>
<FIELD NAME="disablewithindays" TYPE="int" LENGTH="3" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="usercalentry"/>
-
- under table "facetoface_sessions"
<FIELD NAME="disablenewenrolldays" TYPE="int" LENGTH="3" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="timemodified" NEXT="disableoption"/>
<FIELD NAME="disableoption" TYPE="int" LENGTH="1" NOTNULL="false" UNSIGNED="true" SEQUENCE="false" PREVIOUS="disablenewenrolldays"/>