'submissiondrafts',
'sendnotifications',
'sendlatenotifications',
+ 'sendstudentnotifications',
'duedate',
'cutoffdate',
'allowsubmissionsfromdate',
<?xml version="1.0" encoding="UTF-8" ?>
-<XMLDB PATH="mod/assign/db" VERSION="20130314" COMMENT="XMLDB file for Moodle mod/assign"
+<XMLDB PATH="mod/assign/db" VERSION="20131220" COMMENT="XMLDB file for Moodle mod/assign"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../../../lib/xmldb/xmldb.xsd"
>
<FIELD NAME="maxattempts" TYPE="int" LENGTH="6" NOTNULL="true" DEFAULT="-1" SEQUENCE="false" COMMENT="What is the maximum number of student attempts allowed for this assignment? -1 means unlimited."/>
<FIELD NAME="markingworkflow" TYPE="int" LENGTH="2" NOTNULL="true" DEFAULT="0" SEQUENCE="false" COMMENT="If enabled, marking workflow features will be used in this assignment."/>
<FIELD NAME="markingallocation" TYPE="int" LENGTH="2" NOTNULL="true" DEFAULT="0" SEQUENCE="false" COMMENT="If enabled, marking allocation features will be used in this assignment"/>
+ <FIELD NAME="sendstudentnotifications" TYPE="int" LENGTH="2" NOTNULL="true" DEFAULT="1" SEQUENCE="false" COMMENT="Default for send student notifications checkbox when grading."/>
</FIELDS>
<KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="id" COMMENT="The unique id for this assignment instance."/>
</INDEXES>
</TABLE>
</TABLES>
-</XMLDB>
+</XMLDB>
\ No newline at end of file
// Moodle v2.6.0 release upgrade line.
// Put any upgrade step following this.
+ if ($oldversion < 2014010801) {
+
+ // Define field sendstudentnotifications to be added to assign.
+ $table = new xmldb_table('assign');
+ $field = new xmldb_field('sendstudentnotifications',
+ XMLDB_TYPE_INTEGER,
+ '2',
+ null,
+ XMLDB_NOTNULL,
+ null,
+ '1',
+ 'markingallocation');
+
+ // Conditionally launch add field sendstudentnotifications.
+ if (!$dbman->field_exists($table, $field)) {
+ $dbman->add_field($table, $field);
+ }
+
+ // Assign savepoint reached.
+ upgrade_mod_savepoint(true, 2014010801, 'assign');
+ }
+
return true;
}
unset($courses[$id]);
}
}
- $extrafields='m.id as assignmentid, m.course, m.nosubmissions, m.submissiondrafts, m.sendnotifications, '.
- 'm.sendlatenotifications, m.duedate, m.allowsubmissionsfromdate, m.grade, m.timemodified, '.
- 'm.completionsubmit, m.cutoffdate, m.teamsubmission, m.requireallteammemberssubmit, '.
- 'm.teamsubmissiongroupingid, m.blindmarking, m.revealidentities, m.attemptreopenmethod, '.
- 'm.maxattempts, m.markingworkflow, m.markingallocation, m.requiresubmissionstatement';
+ $extrafields='m.id as assignmentid, ' .
+ 'm.course, ' .
+ 'm.nosubmissions, ' .
+ 'm.submissiondrafts, ' .
+ 'm.sendnotifications, '.
+ 'm.sendlatenotifications, ' .
+ 'm.sendstudentnotifications, ' .
+ 'm.duedate, ' .
+ 'm.allowsubmissionsfromdate, '.
+ 'm.grade, ' .
+ 'm.timemodified, '.
+ 'm.completionsubmit, ' .
+ 'm.cutoffdate, ' .
+ 'm.teamsubmission, ' .
+ 'm.requireallteammemberssubmit, '.
+ 'm.teamsubmissiongroupingid, ' .
+ 'm.blindmarking, ' .
+ 'm.revealidentities, ' .
+ 'm.attemptreopenmethod, '.
+ 'm.maxattempts, ' .
+ 'm.markingworkflow, ' .
+ 'm.markingallocation, ' .
+ 'm.requiresubmissionstatement';
$coursearray = array();
foreach ($courses as $id => $course) {
$assignmentarray = array();
'submissiondrafts' => $module->submissiondrafts,
'sendnotifications' => $module->sendnotifications,
'sendlatenotifications' => $module->sendlatenotifications,
+ 'sendstudentnotifications' => $module->sendstudentnotifications,
'duedate' => $module->duedate,
'allowsubmissionsfromdate' => $module->allowsubmissionsfromdate,
'grade' => $module->grade,
'submissiondrafts' => new external_value(PARAM_INT, 'submissions drafts'),
'sendnotifications' => new external_value(PARAM_INT, 'send notifications'),
'sendlatenotifications' => new external_value(PARAM_INT, 'send notifications'),
+ 'sendstudentnotifications' => new external_value(PARAM_INT, 'send student notifications (default)'),
'duedate' => new external_value(PARAM_INT, 'assignment due date'),
'allowsubmissionsfromdate' => new external_value(PARAM_INT, 'allow submissions from date'),
'grade' => new external_value(PARAM_INT, 'grade type'),
$string['saveallquickgradingchanges'] = 'Save all quick grading changes';
$string['savenext'] = 'Save and show next';
$string['scale'] = 'Scale';
+$string['sendstudentnotificationsdefault'] = 'Default setting for "Notify students"';
+$string['sendstudentnotificationsdefault_help'] = 'Set the default value for the "Notify students" checkbox on the grading form.';
+$string['sendstudentnotifications'] = 'Notify students';
+$string['sendstudentnotifications_help'] = 'If enabled, students receive a message about the updated grade or feedback.';
$string['sendnotifications'] = 'Notify graders about submissions';
$string['sendnotifications_help'] = 'If enabled, graders (usually teachers) receive a message whenever a student submits an assignment, early, on time and late. Message methods are configurable.';
$string['selectlink'] = 'Select...';
*/
public function add_instance(stdClass $formdata, $callplugins) {
global $DB;
+ $adminconfig = $this->get_admin_config();
$err = '';
$update->requiresubmissionstatement = $formdata->requiresubmissionstatement;
$update->sendnotifications = $formdata->sendnotifications;
$update->sendlatenotifications = $formdata->sendlatenotifications;
+ $update->sendstudentnotifications = $adminconfig->sendstudentnotifications;
+ if (isset($formdata->sendstudentnotifications)) {
+ $update->sendstudentnotifications = $formdata->sendstudentnotifications;
+ }
$update->duedate = $formdata->duedate;
$update->cutoffdate = $formdata->cutoffdate;
$update->allowsubmissionsfromdate = $formdata->allowsubmissionsfromdate;
*/
public function update_instance($formdata) {
global $DB;
+ $adminconfig = $this->get_admin_config();
$update = new stdClass();
$update->id = $formdata->instance;
$update->requiresubmissionstatement = $formdata->requiresubmissionstatement;
$update->sendnotifications = $formdata->sendnotifications;
$update->sendlatenotifications = $formdata->sendlatenotifications;
+ $update->sendstudentnotifications = $adminconfig->sendstudentnotifications;
+ if (isset($formdata->sendstudentnotifications)) {
+ $update->sendstudentnotifications = $formdata->sendstudentnotifications;
+ }
$update->duedate = $formdata->duedate;
$update->cutoffdate = $formdata->cutoffdate;
$update->allowsubmissionsfromdate = $formdata->allowsubmissionsfromdate;
if ($showquickgrading && $quickgrading) {
$gradingtable = new assign_grading_table($this, $perpage, $filter, 0, true);
$table = $this->get_renderer()->render($gradingtable);
- $quickformparams = array('cm'=>$this->get_course_module()->id, 'gradingtable'=>$table);
+ $quickformparams = array('cm'=>$this->get_course_module()->id,
+ 'gradingtable'=>$table,
+ 'sendstudentnotifications'=>$this->get_instance()->sendstudentnotifications);
$quickgradingform = new mod_assign_quick_grading_form(null, $quickformparams);
$o .= $this->get_renderer()->render(new assign_form('quickgradingform', $quickgradingform));
$this->update_user_flags($flags);
}
$this->update_grade($grade);
- $this->notify_grade_modified($grade);
+ // Allow teachers to skip sending notifications.
+ if (optional_param('sendstudentnotifications', true, PARAM_BOOL)) {
+ $this->notify_grade_modified($grade);
+ }
// Save outcomes.
if ($CFG->enableoutcomes) {
$mform->setDefault('addattempt', 0);
}
}
+ $mform->addElement('selectyesno', 'sendstudentnotifications', get_string('sendstudentnotifications', 'assign'));
+ $mform->setDefault('sendstudentnotifications', $this->get_instance()->sendstudentnotifications);
$mform->addElement('hidden', 'action', 'submitgrade');
$mform->setType('action', PARAM_ALPHA);
}
}
$this->update_grade($grade);
- $this->notify_grade_modified($grade);
+ // Note the default if not provided for this option is true (e.g. webservices).
+ // This is for backwards compatibility.
+ if (!isset($formdata->sendstudentnotifications) || $formdata->sendstudentnotifications) {
+ $this->notify_grade_modified($grade);
+ }
$addtolog = $this->add_to_log('grade submission', $this->format_grade_for_log($grade), '', true);
$params = array(
$mform->addHelpButton('sendlatenotifications', 'sendlatenotifications', 'assign');
$mform->disabledIf('sendlatenotifications', 'sendnotifications', 'eq', 1);
+ $name = get_string('sendstudentnotificationsdefault', 'assign');
+ $mform->addElement('selectyesno', 'sendstudentnotifications', $name);
+ $mform->addHelpButton('sendstudentnotifications', 'sendstudentnotificationsdefault', 'assign');
+
// Plagiarism enabling form.
if (!empty($CFG->enableplagiarism)) {
require_once($CFG->libdir . '/plagiarismlib.php');
$mform->addElement('hidden', 'action', 'quickgrade');
$mform->setType('action', PARAM_ALPHA);
+ // Skip notifications option.
+ $mform->addElement('selectyesno', 'sendstudentnotifications', get_string('sendstudentnotifications', 'assign'));
+ $mform->setDefault('sendstudentnotifications', $instance['sendstudentnotifications']);
+
// Buttons.
$savemessage = get_string('saveallquickgradingchanges', 'assign');
$mform->addElement('submit', 'savequickgrades', $savemessage);
$setting->set_locked_flag_options(admin_setting_flag::ENABLED, false);
$settings->add($setting);
+ $name = new lang_string('sendstudentnotificationsdefault', 'mod_assign');
+ $description = new lang_string('sendstudentnotificationsdefault_help', 'mod_assign');
+ $setting = new admin_setting_configcheckbox('assign/sendstudentnotifications',
+ $name,
+ $description,
+ 1);
+ $setting->set_advanced_flag_options(admin_setting_flag::ENABLED, false);
+ $setting->set_locked_flag_options(admin_setting_flag::ENABLED, false);
+ $settings->add($setting);
+
$name = new lang_string('blindmarking', 'mod_assign');
$description = new lang_string('blindmarking_help', 'mod_assign');
$setting = new admin_setting_configcheckbox('assign/blindmarking',
'submissiondrafts' => 1,
'requiresubmissionstatement' => 0,
'sendnotifications' => 0,
+ 'sendstudentnotifications' => 1,
'sendlatenotifications' => 0,
'duedate' => 0,
'allowsubmissionsfromdate' => 0,
// Now create an assignment and add some feedback.
$this->setUser($this->editingteachers[0]);
- $assign = $this->create_instance();
+ $assign = $this->create_instance(array('sendstudentnotifications'=>1));
// Simulate adding a grade.
$this->setUser($this->teachers[0]);
$assign->testable_apply_grade_to_user($data, $this->students[0]->id, 0);
$assign->testable_apply_grade_to_user($data, $this->students[1]->id, 0);
+ $data->sendstudentnotifications = false;
+ $assign->testable_apply_grade_to_user($data, $this->students[2]->id, 0);
+
// Now run cron and see that one message was sent.
$this->preventResetByRollback();
$sink = $this->redirectMessages();
assign::cron();
$messages = $sink->get_messages();
+ // The sent count should be 2, because the 3rd one was marked as do not send notifications.
$this->assertEquals(2, count($messages));
$this->assertEquals(1, $messages[0]->notification);
$this->assertEquals($assign->get_instance()->name, $messages[0]->contexturlname);
This files describes API changes in the assign code.
+=== 2.7 ===
+* Added setting sendstudentnotifications to assign DB table with admin defaults. This sets the default value for the
+ "Notify students" option on the grading forms. This setting can be retrieved via webservices.
=== 2.6.1 ===
defined('MOODLE_INTERNAL') || die();
$module->component = 'mod_assign'; // Full name of the plugin (used for diagnostics).
-$module->version = 2014010700; // The current module version (Date: YYYYMMDDXX).
+$module->version = 2014010801; // The current module version (Date: YYYYMMDDXX).
$module->requires = 2013110500; // Requires this Moodle version.
$module->cron = 60;