Browse Source

Merge branch 'requiredip'

MOODLE_32_STABLE
Dan Marsden 8 years ago
parent
commit
5b6b317208
  1. 7
      attendance.php
  2. 4
      classes/structure.php
  3. 5
      db/install.xml
  4. 10
      db/upgrade.php
  5. 5
      lang/en/attendance.php
  6. 14
      mod_form.php
  7. 4
      version.php

7
attendance.php

@ -43,6 +43,13 @@ if (empty(get_config('attendance', 'studentscanmark')) || empty($attforsession->
redirect(new moodle_url('/mod/attendance/view.php', array('id' => $cm->id))); redirect(new moodle_url('/mod/attendance/view.php', array('id' => $cm->id)));
exit; exit;
} }
// Check if subnet is set and if the user is in the allowed range.
if (!empty($attendance->subnet) && !address_in_subnet(getremoteaddr(), $attendance->subnet)) {
notice(get_string('subnetwrong', 'attendance'));
exit; // Notice calls this anyway.
}
$pageparams->sessionid = $id; $pageparams->sessionid = $id;
$att = new mod_attendance_structure($attendance, $cm, $course, $PAGE->context, $pageparams); $att = new mod_attendance_structure($attendance, $cm, $course, $PAGE->context, $pageparams);

4
classes/structure.php

@ -59,6 +59,8 @@ class mod_attendance_structure {
/** current page parameters */ /** current page parameters */
public $pageparams; public $pageparams;
public $subnet;
private $groupmode; private $groupmode;
private $statuses; private $statuses;
@ -1063,4 +1065,4 @@ class mod_attendance_structure {
return null; return null;
} }
} }

5
db/install.xml

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?> <?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" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../../../lib/xmldb/xmldb.xsd" xsi:noNamespaceSchemaLocation="../../../lib/xmldb/xmldb.xsd"
> >
@ -11,6 +11,7 @@
<FIELD NAME="name" TYPE="char" LENGTH="255" NOTNULL="false" SEQUENCE="false"/> <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="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="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="Restrict ability for students to mark by subnet."/>
</FIELDS> </FIELDS>
<KEYS> <KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="id" COMMENT="Primary key for attendance"/> <KEY NAME="primary" TYPE="primary" FIELDS="id" COMMENT="Primary key for attendance"/>
@ -103,4 +104,4 @@
</INDEXES> </INDEXES>
</TABLE> </TABLE>
</TABLES> </TABLES>
</XMLDB> </XMLDB>

10
db/upgrade.php

@ -192,6 +192,14 @@ function xmldb_attendance_upgrade($oldversion=0) {
// Attendance savepoint reached. // Attendance savepoint reached.
upgrade_mod_savepoint(true, 2016082900, 'attendance'); upgrade_mod_savepoint(true, 2016082900, 'attendance');
} }
if ($oldversion < 2016112100) {
$table = new xmldb_table('attendance');
$newfield = $table->add_field('subnet', XMLDB_TYPE_CHAR, '255', null, null, null, null, 'timemodified');
if (!$dbman->field_exists($table, $newfield)) {
$dbman->add_field($table, $newfield);
}
upgrade_mod_savepoint(true, 2016112100, 'attendance');
}
return $result; return $result;
} }

5
lang/en/attendance.php

@ -332,4 +332,7 @@ $string['repeatuntil'] = 'Repeat until';
$string['repeaton'] = 'Repeat on'; $string['repeaton'] = 'Repeat on';
$string['invalidsessionendtime'] = 'The end time must be greater than start time'; $string['invalidsessionendtime'] = 'The end time must be greater than start time';
$string['deletedgroup'] = 'The group associated with this session has been deleted'; $string['deletedgroup'] = 'The group associated with this session has been deleted';
$string['search:activity'] = 'Attendance - activity information'; $string['extrarestrictions'] = 'Extra restrictions';
$string['requiresubnet'] = '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.';

14
mod_form.php

@ -39,6 +39,10 @@ class mod_attendance_mod_form extends moodleform_mod {
* @return void * @return void
*/ */
public function definition() { public function definition() {
$attendanceconfig = get_config('attendance');
if (!isset($attendanceconfig->subnet)) {
$attendanceconfig->subnet = '';
}
$mform =& $this->_form; $mform =& $this->_form;
$mform->addElement('header', 'general', get_string('general', 'form')); $mform->addElement('header', 'general', get_string('general', 'form'));
@ -52,6 +56,14 @@ class mod_attendance_mod_form extends moodleform_mod {
$this->standard_grading_coursemodule_elements(); $this->standard_grading_coursemodule_elements();
$this->standard_coursemodule_elements(true); $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(); $this->add_action_buttons();
} }
} }

4
version.php

@ -23,9 +23,9 @@
*/ */
defined('MOODLE_INTERNAL') || die(); defined('MOODLE_INTERNAL') || die();
$plugin->version = 2016082900; $plugin->version = 2016112100;
$plugin->requires = 2016052300; $plugin->requires = 2016052300;
$plugin->release = '3.1.1.1'; $plugin->release = '3.1.1.1';
$plugin->maturity = MATURITY_STABLE; $plugin->maturity = MATURITY_STABLE;
$plugin->cron = 0; $plugin->cron = 0;
$plugin->component = 'mod_attendance'; $plugin->component = 'mod_attendance';
Loading…
Cancel
Save