$output = $PAGE->get_renderer('mod_attendance');
echo $output->header();
-$mform->display();
+if (!empty ($attendance->subnet)) {
+ if (!address_in_subnet(getremoteaddr(), $attendance->subnet)) {
+ $wrongip = html_writer::tag('p', get_string('subnetwrong', 'attendance'));
+ $button = html_writer::tag('p', $output->continue_button($CFG->wwwroot . '/course/view.php?id=' . $course->id));
+ echo $output->box($wrongip ."\n\n".$button."\n", 'generalbox', 'notice');
+ } else {
+ $mform->display();
+ } else {
+ $mform->display();
+}
+
echo $output->footer();
/** current page parameters */
public $pageparams;
+ public $subnet;
+
private $groupmode;
private $statuses;
return null;
}
-}
+}
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8" ?>
-<XMLDB PATH="mod/attendance/db" VERSION="20160829" COMMENT="XMLDB file for Moodle mod/attendance"
+<XMLDB PATH="mod/attendance/db" VERSION="20161107" COMMENT="XMLDB file for Moodle mod/attendance"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../../../lib/xmldb/xmldb.xsd"
>
<FIELD NAME="name" TYPE="char" LENGTH="255" NOTNULL="false" SEQUENCE="false"/>
<FIELD NAME="grade" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="100" SEQUENCE="false" COMMENT="This is maximum grade for instance"/>
<FIELD NAME="timemodified" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false" COMMENT="The time the settings for this attendance instance were last modified."/>
+ <FIELD NAME="subnet" TYPE="char" LENGTH="255" NOTNULL="false" SEQUENCE="false" COMMENT="add ability to restrict by IP."/>
</FIELDS>
<KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="id" COMMENT="Primary key for attendance"/>
</INDEXES>
</TABLE>
</TABLES>
-</XMLDB>
\ No newline at end of file
+</XMLDB>
// Attendance savepoint reached.
upgrade_mod_savepoint(true, 2016082900, 'attendance');
}
+ if ($oldversion < 201611071400) {
+ $table = new xmldb_table('attendance');
+ $newfield = $table->add_field('subnet', XMLDB_TYPE_CHAR, '255', null, null, null, null);
+ if (!$dbman->field_exists($table, $newfield)) {
+ $dbman->add_field($table, $newfield);
+ }
+ upgrade_mod_savepoint(true, 201611071400, 'attendance');
+ }
return $result;
-}
+}
\ No newline at end of file
$string['repeaton'] = 'Repeat on';
$string['invalidsessionendtime'] = 'The end time must be greater than start time';
$string['deletedgroup'] = 'The group associated with this session has been deleted';
-$string['search:activity'] = 'Attendance - activity information';
\ No newline at end of file
+$string['extrarestrictions'] = 'Extra restrictions';
+$string['configrequiresubnet'] = 'Students can only record own attendance from these computers.';
+$string['subnetwrong'] = 'Attendance can only be recorded from certain locations, and this computer is not on the allowed list.';
+$string['requiresubnet_help'] = 'Attendance recording may be restricted to particular subnets by specifying a comma-separated list of partial or full IP addresses.';
\ No newline at end of file
* @return void
*/
public function definition() {
+ $attendanceconfig = get_config('attendance');
$mform =& $this->_form;
$mform->addElement('header', 'general', get_string('general', 'form'));
$this->standard_grading_coursemodule_elements();
$this->standard_coursemodule_elements(true);
+
+ $mform->addElement('header', 'security', get_string('extrarestrictions', 'attendance'));
+ // IP address.
+ $mform->addElement('text', 'subnet', get_string('requiresubnet', 'attendance'), array('size' => '164'));
+ $mform->setType('subnet', PARAM_TEXT);
+ $mform->addHelpButton('subnet', 'requiresubnet', 'attendance');
+ $mform->setDefault('subnet', $attendanceconfig->subnet);
+
$this->add_action_buttons();
}
-}
+}
\ No newline at end of file
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-$plugin->version = 2016082900;
+$plugin->version = 2016110714;
$plugin->requires = 2016052300;
$plugin->release = '3.1.1.1';
$plugin->maturity = MATURITY_STABLE;
$plugin->cron = 0;
-$plugin->component = 'mod_attendance';
+$plugin->component = 'mod_attendance';
\ No newline at end of file