mirror of
https://github.com/moodle/moodle.git
synced 2025-01-18 14:03:52 +01:00
MDL-31414: Separate settings to control notifications for submissions, late submissions and submission receipts
This adds separate controls for the sending of notifications from the mod_assign. The separate notifications are: student submission receipt (for students), feedback available (for students) and submission updated (for graders). The grader notifications can be enabled for all submissions or just late ones. Added code to reset the message providers on upgrade (only applies for a 2.3 dev version)
This commit is contained in:
parent
5a5cdaf92e
commit
75f87a5795
@ -51,6 +51,7 @@ class backup_assign_activity_structure_step extends backup_activity_structure_st
|
||||
'preventlatesubmissions',
|
||||
'submissiondrafts',
|
||||
'sendnotifications',
|
||||
'sendlatenotifications',
|
||||
'duedate',
|
||||
'allowsubmissionsfromdate',
|
||||
'grade',
|
||||
|
@ -15,8 +15,9 @@
|
||||
<FIELD NAME="nosubmissions" TYPE="int" LENGTH="2" NOTNULL="true" DEFAULT="0" SEQUENCE="false" COMMENT="This field is a cache for is_any_submission_plugin_enabled() which allows Moodle pages to distinguish offline assignment types without loading the assignment class." PREVIOUS="alwaysshowdescription" NEXT="preventlatesubmissions"/>
|
||||
<FIELD NAME="preventlatesubmissions" TYPE="int" LENGTH="2" NOTNULL="true" DEFAULT="0" SEQUENCE="false" COMMENT="If true, submissions will not be accepted past the due date." PREVIOUS="nosubmissions" NEXT="submissiondrafts"/>
|
||||
<FIELD NAME="submissiondrafts" TYPE="int" LENGTH="2" NOTNULL="true" DEFAULT="0" SEQUENCE="false" COMMENT="If true, assignment submissions will be considered drafts until the student clicks on the submit assignmnet button." PREVIOUS="preventlatesubmissions" NEXT="sendnotifications"/>
|
||||
<FIELD NAME="sendnotifications" TYPE="int" LENGTH="2" NOTNULL="true" DEFAULT="0" SEQUENCE="false" COMMENT="Allows the disabling of email notifications in the assign module." PREVIOUS="submissiondrafts" NEXT="duedate"/>
|
||||
<FIELD NAME="duedate" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false" COMMENT="The due date for the assignment. Displayed to students." PREVIOUS="sendnotifications" NEXT="allowsubmissionsfromdate"/>
|
||||
<FIELD NAME="sendnotifications" TYPE="int" LENGTH="2" NOTNULL="true" DEFAULT="0" SEQUENCE="false" COMMENT="Allows the disabling of email notifications in the assign module." PREVIOUS="submissiondrafts" NEXT="sendlatenotifications"/>
|
||||
<FIELD NAME="sendlatenotifications" TYPE="int" LENGTH="2" NOTNULL="true" DEFAULT="0" SEQUENCE="false" COMMENT="Allows separate enabling of notifications for late assignment submissions." PREVIOUS="sendnotifications" NEXT="duedate"/>
|
||||
<FIELD NAME="duedate" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false" COMMENT="The due date for the assignment. Displayed to students." PREVIOUS="sendlatenotifications" NEXT="allowsubmissionsfromdate"/>
|
||||
<FIELD NAME="allowsubmissionsfromdate" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false" COMMENT="If set, submissions will only be accepted after this date." PREVIOUS="duedate" NEXT="grade"/>
|
||||
<FIELD NAME="grade" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false" COMMENT="The maximum grade for this assignment. Can be negative to indicate the use of a scale." PREVIOUS="allowsubmissionsfromdate" NEXT="timemodified"/>
|
||||
<FIELD NAME="timemodified" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false" COMMENT="The time the settings for this assign module instance were last modified." PREVIOUS="grade"/>
|
||||
|
@ -24,8 +24,12 @@
|
||||
|
||||
$messageproviders = array (
|
||||
|
||||
// Ordinary assignment submissions
|
||||
'assign_updates' => array (
|
||||
/// Ordinary assignment submissions
|
||||
'assign_student_notification' => array (
|
||||
'capability' => 'mod/assign:submit'
|
||||
),
|
||||
'assign_grader_notification' => array (
|
||||
'capability' => 'mod/assign:grade'
|
||||
)
|
||||
|
||||
);
|
||||
|
@ -28,6 +28,9 @@
|
||||
* @return bool
|
||||
*/
|
||||
function xmldb_assign_upgrade($oldversion) {
|
||||
if ($oldversion < 2012051700) {
|
||||
message_update_providers('mod_assign');
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -90,23 +90,34 @@ $string['duedatereached'] = 'The due date for this assignment has now passed';
|
||||
$string['duedatevalidation'] = 'Due date must be after the allow submissions from date.';
|
||||
$string['editsubmission'] = 'Edit my submission';
|
||||
$string['editaction'] = 'Actions...';
|
||||
$string['emailgradermail'] = '{$a->username} has updated their assignment submission
|
||||
$string['gradersubmissionupdatedtext'] = '{$a->username} has updated their assignment submission
|
||||
for \'{$a->assignment}\' at {$a->timeupdated}
|
||||
|
||||
It is available here:
|
||||
|
||||
{$a->url}';
|
||||
$string['emailgradermailhtml'] = '{$a->username} has updated their assignment submission
|
||||
$string['gradersubmissionupdatedhtml'] = '{$a->username} has updated their assignment submission
|
||||
for <i>\'{$a->assignment}\' at {$a->timeupdated}</i><br /><br />
|
||||
It is <a href="{$a->url}">available on the web site</a>.';
|
||||
$string['gradersubmissionupdatedsmall'] = '{$a->username} has updated their submission for assignment {$a->assignment}.';
|
||||
$string['enabled'] = 'Enabled';
|
||||
$string['errornosubmissions'] = 'There are no submissions to download';
|
||||
$string['errorquickgradingvsadvancedgrading'] = 'The grades were not saved because this assignment is currently using advanced grading';
|
||||
$string['errorrecordmodified'] = 'The grades were not saved because someone has modified one or more records more recently than when you loaded the page.';
|
||||
$string['feedbackcomments'] = 'Feedback comments';
|
||||
$string['feedback'] = 'Feedback';
|
||||
$string['feedbackavailabletext'] = '{$a->username} has posted some feedback on your
|
||||
assignment submission for \'{$a->assignment}\'
|
||||
|
||||
You can see it appended to your assignment submission:
|
||||
|
||||
{$a->url}';
|
||||
$string['feedbackavailablehtml'] = '{$a->username} has posted some feedback on your
|
||||
assignment submission for \'<i>{$a->assignment}</i>\'<br /><br />
|
||||
You can see it appended to your <a href="{$a->url}">assignment submission</a>.';
|
||||
$string['feedbackavailablesmall'] = '{$a->username} has given feedback for assignment {$a->assignment}';
|
||||
$string['feedbackplugins'] = 'Feedback plugins';
|
||||
$string['feedbackpluginforgradebook'] = 'Feedback plugin that will push comments to the gradebook';
|
||||
$string['feedbackpluginforgradebook_help'] = 'Only one assignment feedback plugin can push feedback into the gradebook.';
|
||||
$string['feedbackplugin'] = 'Feedback plugin';
|
||||
$string['feedbacksettings'] = 'Feedback settings';
|
||||
$string['filesubmissions'] = 'File submissions';
|
||||
@ -139,7 +150,8 @@ $string['locksubmissionforstudent'] = 'Prevent any more submissions for student:
|
||||
$string['locksubmissions'] = 'Lock submissions';
|
||||
$string['manageassignfeedbackplugins'] = 'Manage assignment feedback plugins';
|
||||
$string['manageassignsubmissionplugins'] = 'Manage assignment submission plugins';
|
||||
$string['messageprovider:assign_updates'] = 'Assignment notifications';
|
||||
$string['messageprovider:assign_student_notification'] = 'Assignment student notifications';
|
||||
$string['messageprovider:assign_grader_notification'] = 'Assignment grader notifications';
|
||||
$string['modulename'] = 'Assignment';
|
||||
$string['modulename_help'] = 'The assignment activity module enables a teacher to assess students’ learning by setting work and then reviewing it and providing feedback and grades.
|
||||
|
||||
@ -160,6 +172,7 @@ $string['notgradedyet'] = 'Not graded yet';
|
||||
$string['notsubmittedyet'] = 'Not submitted yet';
|
||||
$string['notifications'] = 'Notifications';
|
||||
$string['nousersselected'] = 'No users selected';
|
||||
$string['notification'] = 'Notification';
|
||||
$string['numberofdraftsubmissions'] = 'Drafts';
|
||||
$string['numberofparticipants'] = 'Participants';
|
||||
$string['numberofsubmittedassignments'] = 'Submitted';
|
||||
@ -186,9 +199,13 @@ $string['reviewed'] = 'Reviewed';
|
||||
$string['savechanges'] = 'Save changes';
|
||||
$string['saveallchanges'] = 'Save all changes';
|
||||
$string['savenext'] = 'Save and show next';
|
||||
$string['sendnotifications'] = 'Send notifications to graders';
|
||||
$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...';
|
||||
$string['sendlatenotifications'] = 'Notify graders about late submissions';
|
||||
$string['sendlatenotifications_help'] = 'If enabled, graders (usually teachers) receive a message whenever a student submits an assignment late. Message methods are configurable.';
|
||||
$string['sendsubmissionreceipts'] = 'Send submission receipt to students';
|
||||
$string['sendsubmissionreceipts_help'] = 'This switch will enable submission receipts for students. Students will receive a notification every time they successfully submit an assignment';
|
||||
$string['settings'] = 'Assignment settings';
|
||||
$string['showrecentsubmissions'] = 'Show recent submissions';
|
||||
$string['submissiondrafts'] = 'Require students click submit button';
|
||||
@ -196,6 +213,16 @@ $string['submissiondrafts_help'] = 'If enabled, students will have to click a Su
|
||||
$string['submissionnotready'] = 'This assignment is not ready to submit:';
|
||||
$string['submissionplugins'] = 'Submission plugins';
|
||||
$string['submissionreceipts'] = 'Send submission receipts';
|
||||
$string['submissionreceipttext'] = 'You have submitted an
|
||||
assignment submission for \'{$a->assignment}\'
|
||||
|
||||
You can see the status of your assignment submission:
|
||||
|
||||
{$a->url}';
|
||||
$string['submissionreceipthtml'] = 'You have submitted an
|
||||
assignment submission for \'<i>{$a->assignment}</i>\'<br /><br />
|
||||
You can the status of your <a href="{$a->url}">assignment submission</a>.';
|
||||
$string['submissionreceiptsmall'] = 'You have submitted your assignment submission for {$a->assignment}';
|
||||
$string['submissionslocked'] = 'This assignment is not accepting submissions';
|
||||
$string['submissionslockedshort'] = 'Submission changes not allowed';
|
||||
$string['submissions'] = 'Submissions';
|
||||
|
@ -674,7 +674,8 @@ function assign_cron() {
|
||||
global $CFG;
|
||||
|
||||
require_once($CFG->dirroot . '/mod/assign/locallib.php');
|
||||
//assignment::cron();
|
||||
assign::cron();
|
||||
|
||||
$plugins = get_plugin_list('assignsubmission');
|
||||
|
||||
foreach ($plugins as $name => $plugin) {
|
||||
|
@ -419,6 +419,7 @@ class assign {
|
||||
$update->preventlatesubmissions = $formdata->preventlatesubmissions;
|
||||
$update->submissiondrafts = $formdata->submissiondrafts;
|
||||
$update->sendnotifications = $formdata->sendnotifications;
|
||||
$update->sendlatenotifications = $formdata->sendlatenotifications;
|
||||
$update->duedate = $formdata->duedate;
|
||||
$update->allowsubmissionsfromdate = $formdata->allowsubmissionsfromdate;
|
||||
$update->grade = $formdata->grade;
|
||||
@ -636,6 +637,7 @@ class assign {
|
||||
$update->preventlatesubmissions = $formdata->preventlatesubmissions;
|
||||
$update->submissiondrafts = $formdata->submissiondrafts;
|
||||
$update->sendnotifications = $formdata->sendnotifications;
|
||||
$update->sendlatenotifications = $formdata->sendlatenotifications;
|
||||
$update->duedate = $formdata->duedate;
|
||||
$update->allowsubmissionsfromdate = $formdata->allowsubmissionsfromdate;
|
||||
$update->grade = $formdata->grade;
|
||||
@ -1068,7 +1070,6 @@ class assign {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Cron function to be run periodically according to the moodle cron
|
||||
* Finds all assignment notifications that have yet to be mailed out, and mails them
|
||||
@ -1076,8 +1077,93 @@ class assign {
|
||||
* @return bool
|
||||
*/
|
||||
static function cron() {
|
||||
global $CFG, $USER, $DB;
|
||||
global $CFG, $DB;
|
||||
|
||||
// used to cache DB lookups
|
||||
$croncache = array();
|
||||
|
||||
// only ever send a max of one days worth of updates
|
||||
$yesterday = time() - (24 * 3600);
|
||||
$timenow = time();
|
||||
|
||||
// email students about new feedback
|
||||
$submissions = $DB->get_records_sql("SELECT s.*, a.course, a.name, g.*, g.id as gradeid, g.timemodified as lastmodified
|
||||
FROM {assign} a
|
||||
JOIN {assign_grades} g ON g.assignment = a.id
|
||||
LEFT JOIN {assign_submission} s ON s.assignment = a.id AND s.userid = g.userid
|
||||
WHERE g.timemodified >= :yesterday
|
||||
AND g.timemodified <= :today
|
||||
AND g.mailed = 0", array('yesterday'=>$yesterday, 'today'=>$timenow));
|
||||
|
||||
mtrace('Processing ' . count($submissions) . ' assignment submissions ...');
|
||||
|
||||
foreach ($submissions as $submission) {
|
||||
|
||||
mtrace("Processing assignment submission $submission->id ...");
|
||||
|
||||
// do not cache user lookups - could be too many
|
||||
if (! $user = $DB->get_record("user", array("id"=>$submission->userid))) {
|
||||
mtrace("Could not find user $submission->userid");
|
||||
continue;
|
||||
}
|
||||
|
||||
// use a cache to prevent the same DB queries happening over and over
|
||||
if (! $course = array_search('course_' . $submission->course, $croncache)) {
|
||||
if (! $course = $DB->get_record("course", array("id"=>$submission->course))) {
|
||||
mtrace("Could not find course $submission->course");
|
||||
continue;
|
||||
}
|
||||
$croncache['course_' . $submission->course] = $course;
|
||||
}
|
||||
|
||||
/// Override the language and timezone of the "current" user, so that
|
||||
/// mail is customised for the receiver.
|
||||
cron_setup_user($user, $course);
|
||||
|
||||
// context lookups are already cached
|
||||
$coursecontext = context_course::instance($submission->course);
|
||||
$courseshortname = format_string($course->shortname, true, array('context' => $coursecontext));
|
||||
if (!is_enrolled($coursecontext, $user->id)) {
|
||||
mtrace(fullname($user)." not an active participant in " . $courseshortname);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (! $grader = $DB->get_record("user", array("id"=>$submission->grader))) {
|
||||
mtrace("Could not find grader $submission->grader");
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
if (! $mod = array_search('mod_' . $submission->assignment, $croncache)) {
|
||||
if (! $mod = get_coursemodule_from_instance("assign", $submission->assignment, $course->id)) {
|
||||
mtrace("Could not find course module for assignment id $submission->assignment");
|
||||
continue;
|
||||
}
|
||||
$croncache['mod_' . $submission->assignment] = $mod;
|
||||
}
|
||||
|
||||
// context lookups are already cached
|
||||
$contextmodule = context_module::instance($mod->id);
|
||||
|
||||
if (! $mod->visible) { /// Hold mail notification for hidden assignments until later
|
||||
continue;
|
||||
}
|
||||
|
||||
// need to send this to the student
|
||||
self::send_assignment_notification($grader, $user, 'feedbackavailable', 'assign_student_notification', $submission->lastmodified, $mod, $contextmodule, $course, get_string('modulename', 'assign'), $submission->name);
|
||||
|
||||
$grade = new stdClass();
|
||||
$grade->id = $submission->gradeid;
|
||||
$grade->mailed = 1;
|
||||
$DB->update_record('assign_grades', $grade);
|
||||
|
||||
mtrace('Done');
|
||||
}
|
||||
mtrace('Done processing ' . count($submissions) . ' assignment submissions');
|
||||
|
||||
cron_setup_user();
|
||||
// free up memory
|
||||
unset($croncache);
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -2162,19 +2248,19 @@ class assign {
|
||||
/**
|
||||
* Returns a list of teachers that should be grading given submission
|
||||
*
|
||||
* @param stdClass $user
|
||||
* @param int $userid
|
||||
* @return array
|
||||
*/
|
||||
private function get_graders(stdClass $user) {
|
||||
private function get_graders($userid) {
|
||||
//potential graders
|
||||
$potentialgraders = get_users_by_capability($this->context, 'mod/assign:grade', '', '', '', '', '', '', false, false);
|
||||
$potentialgraders = get_enrolled_users($this->context, "mod/assign:grade");
|
||||
|
||||
$graders = array();
|
||||
if (groups_get_activity_groupmode($this->get_course_module()) == SEPARATEGROUPS) { // Separate groups are being used
|
||||
if ($groups = groups_get_all_groups($this->get_course()->id, $user->id)) { // Try to find all groups
|
||||
if ($groups = groups_get_all_groups($this->get_course()->id, $userid)) { // Try to find all groups
|
||||
foreach ($groups as $group) {
|
||||
foreach ($potentialgraders as $grader) {
|
||||
if ($grader->id == $user->id) {
|
||||
if ($grader->id == $userid) {
|
||||
continue; // do not send self
|
||||
}
|
||||
if (groups_is_member($group->id, $grader->id)) {
|
||||
@ -2185,7 +2271,7 @@ class assign {
|
||||
} else {
|
||||
// user not in group, try to find graders without group
|
||||
foreach ($potentialgraders as $grader) {
|
||||
if ($grader->id == $user->id) {
|
||||
if ($grader->id == $userid) {
|
||||
continue; // do not send self
|
||||
}
|
||||
if (!groups_has_membership($this->get_course_module(), $grader->id)) {
|
||||
@ -2195,7 +2281,7 @@ class assign {
|
||||
}
|
||||
} else {
|
||||
foreach ($potentialgraders as $grader) {
|
||||
if ($grader->id == $user->id) {
|
||||
if ($grader->id == $userid) {
|
||||
continue; // do not send self
|
||||
}
|
||||
// must be enrolled
|
||||
@ -2208,88 +2294,158 @@ class assign {
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the text content for emails to grader
|
||||
* Format a notification based on it's type
|
||||
*
|
||||
* @param array $info The info used by the 'emailgradermail' language string
|
||||
* @return string
|
||||
* @param string $messagetype
|
||||
* @param stdClass $info
|
||||
* @param stdClass $course
|
||||
* @param stdClass $context
|
||||
* @param string $modulename
|
||||
* @param string $assignmentname
|
||||
*/
|
||||
private function format_email_grader_text($info) {
|
||||
$posttext = format_string($this->get_course()->shortname, true, array('context' => $this->get_course_context())).' -> '.
|
||||
$this->get_module_name().' -> '.
|
||||
format_string($this->get_instance()->name, true, array('context' => $this->context))."\n";
|
||||
private static function format_notification_message_text($messagetype, $info, $course, $context, $modulename, $assignmentname) {
|
||||
$posttext = format_string($course->shortname, true, array('context' => $context->get_course_context())).' -> '.
|
||||
$modulename.' -> '.
|
||||
format_string($assignmentname, true, array('context' => $context))."\n";
|
||||
$posttext .= '---------------------------------------------------------------------'."\n";
|
||||
$posttext .= get_string("emailgradermail", "assign", $info)."\n";
|
||||
$posttext .= get_string($messagetype . 'text', "assign", $info)."\n";
|
||||
$posttext .= "\n---------------------------------------------------------------------\n";
|
||||
return $posttext;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the html content for emails to graders
|
||||
/**
|
||||
* Format a notification based on it's type
|
||||
*
|
||||
* @param array $info The info used by the 'emailgradermailhtml' language string
|
||||
* @return string
|
||||
* @param string $messagetype
|
||||
* @param stdClass $info
|
||||
*/
|
||||
private function format_email_grader_html($info) {
|
||||
private static function format_notification_message_html($messagetype, $info, $course, $context, $modulename, $coursemodule, $assignmentname) {
|
||||
global $CFG;
|
||||
$posthtml = '<p><font face="sans-serif">'.
|
||||
'<a href="'.$CFG->wwwroot.'/course/view.php?id='.$this->get_course()->id.'">'.format_string($this->get_course()->shortname, true, array('context' => $this->get_course_context())).'</a> ->'.
|
||||
'<a href="'.$CFG->wwwroot.'/mod/assignment/index.php?id='.$this->get_course()->id.'">'.$this->get_module_name().'</a> ->'.
|
||||
'<a href="'.$CFG->wwwroot.'/mod/assignment/view.php?id='.$this->get_course_module()->id.'">'.format_string($this->get_instance()->name, true, array('context' => $this->context)).'</a></font></p>';
|
||||
'<a href="'.$CFG->wwwroot.'/course/view.php?id='.$course->id.'">'.format_string($course->shortname, true, array('context' => $context->get_course_context())).'</a> ->'.
|
||||
'<a href="'.$CFG->wwwroot.'/mod/assignment/index.php?id='.$course->id.'">'.$modulename.'</a> ->'.
|
||||
'<a href="'.$CFG->wwwroot.'/mod/assignment/view.php?id='.$coursemodule->id.'">'.format_string($assignmentname, true, array('context' => $context)).'</a></font></p>';
|
||||
$posthtml .= '<hr /><font face="sans-serif">';
|
||||
$posthtml .= '<p>'.get_string('emailgradermailhtml', 'assign', $info).'</p>';
|
||||
$posthtml .= '<p>'.get_string($messagetype . 'html', 'assign', $info).'</p>';
|
||||
$posthtml .= '</font><hr />';
|
||||
return $posthtml;
|
||||
}
|
||||
|
||||
/**
|
||||
* email graders upon student submissions
|
||||
* email someone about something (static so it can be called from cron)
|
||||
*
|
||||
* @global stdClass $CFG
|
||||
* @global moodle_database $DB
|
||||
* @param stdClass $userfrom
|
||||
* @param stdClass $userto
|
||||
* @param string $messagetype
|
||||
* @param string $eventtype
|
||||
* @param int $updatetime
|
||||
* @param stdClass $coursemodule
|
||||
* @param stdClass $context
|
||||
* @param stdClass $course
|
||||
* @param string $modulename
|
||||
* @param string $moduleplural
|
||||
* @param string $assignmentname
|
||||
* @return void
|
||||
*/
|
||||
public static function send_assignment_notification($userfrom, $userto, $messagetype, $eventtype,
|
||||
$updatetime, $coursemodule, $context, $course,
|
||||
$modulename, $assignmentname) {
|
||||
global $CFG, $DB;
|
||||
|
||||
$strnotification = get_string('notification', 'assign');
|
||||
|
||||
$info = new stdClass();
|
||||
$info->username = fullname($userfrom, true);
|
||||
$info->assignment = format_string($assignmentname,true, array('context'=>$context));
|
||||
$info->url = $CFG->wwwroot.'/mod/assign/view.php?id='.$coursemodule->id;
|
||||
$info->timeupdated = strftime('%c',$updatetime);
|
||||
|
||||
$postsubject = get_string($messagetype . 'small', 'assign', $info);
|
||||
$posttext = self::format_notification_message_text($messagetype, $info, $course, $context, $modulename, $assignmentname);
|
||||
$posthtml = ($userto->mailformat == 1) ? self::format_notification_message_html($messagetype, $info, $course, $context, $modulename, $coursemodule, $assignmentname) : '';
|
||||
|
||||
$eventdata = new stdClass();
|
||||
$eventdata->modulename = 'assign';
|
||||
$eventdata->userfrom = $userfrom;
|
||||
$eventdata->userto = $userto;
|
||||
$eventdata->subject = $postsubject;
|
||||
$eventdata->fullmessage = $posttext;
|
||||
$eventdata->fullmessageformat = FORMAT_PLAIN;
|
||||
$eventdata->fullmessagehtml = $posthtml;
|
||||
$eventdata->smallmessage = $postsubject;
|
||||
|
||||
$eventdata->name = $eventtype;
|
||||
$eventdata->component = 'mod_assign';
|
||||
$eventdata->notification = 1;
|
||||
$eventdata->contexturl = $info->url;
|
||||
$eventdata->contexturlname = $info->assignment;
|
||||
|
||||
message_send($eventdata);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* email someone about something
|
||||
*
|
||||
* @global stdClass $CFG
|
||||
* @global moodle_database $DB
|
||||
* @param stdClass $submission
|
||||
* @return void
|
||||
*/
|
||||
private function email_graders(stdClass $submission) {
|
||||
global $CFG, $DB;
|
||||
public function send_notification($userfrom, $userto, $messagetype, $eventtype, $updatetime) {
|
||||
self::send_assignment_notification($userfrom, $userto, $messagetype, $eventtype, $updatetime, $this->get_course_module(), $this->get_context(), $this->get_course(), $this->get_module_name(), $this->get_instance()->name);
|
||||
}
|
||||
|
||||
if (empty($this->get_instance()->sendnotifications)) { // No need to do anything
|
||||
/**
|
||||
* email student upon successful submission
|
||||
*
|
||||
* @global stdClass $CFG
|
||||
* @global moodle_database $DB
|
||||
* @param stdClass $submission
|
||||
* @return void
|
||||
*/
|
||||
private function email_student_submission_receipt(stdClass $submission) {
|
||||
global $DB;
|
||||
|
||||
$adminconfig = $this->get_admin_config();
|
||||
if (!$adminconfig->submissionreceipts) { // No need to do anything
|
||||
return;
|
||||
}
|
||||
|
||||
$user = $DB->get_record('user', array('id'=>$submission->userid), '*', MUST_EXIST);
|
||||
|
||||
if ($teachers = $this->get_graders($user)) {
|
||||
$this->send_notification($user, $user, 'submissionreceipt', 'assign_student_notification', $submission->timemodified);
|
||||
}
|
||||
|
||||
/**
|
||||
* email graders upon student submissions
|
||||
*
|
||||
* @global stdClass $CFG
|
||||
* @global moodle_database $DB
|
||||
* @param stdClass $submission
|
||||
* @return void
|
||||
*/
|
||||
private function email_graders(stdClass $submission) {
|
||||
global $DB;
|
||||
|
||||
$late = $this->get_instance()->duedate && ($this->get_instance()->duedate < time());
|
||||
|
||||
if (!$this->get_instance()->sendnotifications && !($late && $this->get_instance()->sendlatenotifications)) { // No need to do anything
|
||||
return;
|
||||
}
|
||||
|
||||
$user = $DB->get_record('user', array('id'=>$submission->userid), '*', MUST_EXIST);
|
||||
|
||||
if ($teachers = $this->get_graders($user->id)) {
|
||||
|
||||
$strassignments = $this->get_module_name_plural();
|
||||
$strassignment = $this->get_module_name();
|
||||
$strsubmitted = get_string('submitted', 'assign');
|
||||
|
||||
foreach ($teachers as $teacher) {
|
||||
$info = new stdClass();
|
||||
$info->username = fullname($user, true);
|
||||
$info->assignment = format_string($this->get_instance()->name,true, array('context'=>$this->get_context()));
|
||||
$info->url = $CFG->wwwroot.'/mod/assign/view.php?id='.$this->get_course_module()->id;
|
||||
$info->timeupdated = strftime('%c',$submission->timemodified);
|
||||
|
||||
$postsubject = $strsubmitted.': '.$info->username.' -> '.$this->get_instance()->name;
|
||||
$posttext = $this->format_email_grader_text($info);
|
||||
$posthtml = ($teacher->mailformat == 1) ? $this->format_email_grader_html($info) : '';
|
||||
|
||||
$eventdata = new stdClass();
|
||||
$eventdata->modulename = 'assign';
|
||||
$eventdata->userfrom = $user;
|
||||
$eventdata->userto = $teacher;
|
||||
$eventdata->subject = $postsubject;
|
||||
$eventdata->fullmessage = $posttext;
|
||||
$eventdata->fullmessageformat = FORMAT_PLAIN;
|
||||
$eventdata->fullmessagehtml = $posthtml;
|
||||
$eventdata->smallmessage = $postsubject;
|
||||
|
||||
$eventdata->name = 'assign_updates';
|
||||
$eventdata->component = 'mod_assign';
|
||||
$eventdata->notification = 1;
|
||||
$eventdata->contexturl = $info->url;
|
||||
$eventdata->contexturlname = $info->assignment;
|
||||
|
||||
message_send($eventdata);
|
||||
$this->send_notification($user, $teacher, 'gradersubmissionupdated', 'assign_grader_notification', $submission->timemodified);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2318,6 +2474,7 @@ class assign {
|
||||
$this->update_submission($submission);
|
||||
$this->add_to_log('submit for grading', $this->format_submission_for_log($submission));
|
||||
$this->email_graders($submission);
|
||||
$this->email_student_submission_receipt($submission);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2549,6 +2706,7 @@ class assign {
|
||||
$this->add_to_log('submit', $this->format_submission_for_log($submission));
|
||||
|
||||
if (!$this->get_instance()->submissiondrafts) {
|
||||
$this->email_student_submission_receipt($submission);
|
||||
$this->email_graders($submission);
|
||||
}
|
||||
return true;
|
||||
@ -2998,6 +3156,9 @@ class assign {
|
||||
}
|
||||
}
|
||||
$this->process_outcomes($userid, $formdata);
|
||||
|
||||
$grade->mailed = 0;
|
||||
|
||||
$this->update_grade($grade);
|
||||
|
||||
$user = $DB->get_record('user', array('id' => $userid), '*', MUST_EXIST);
|
||||
|
@ -92,6 +92,10 @@ class mod_assign_mod_form extends moodleform_mod {
|
||||
$mform->addElement('selectyesno', 'sendnotifications', get_string('sendnotifications', 'assign'));
|
||||
$mform->addHelpButton('sendnotifications', 'sendnotifications', 'assign');
|
||||
$mform->setDefault('sendnotifications', 1);
|
||||
$mform->addElement('selectyesno', 'sendlatenotifications', get_string('sendlatenotifications', 'assign'));
|
||||
$mform->addHelpButton('sendlatenotifications', 'sendlatenotifications', 'assign');
|
||||
$mform->setDefault('sendlatenotifications', 1);
|
||||
$mform->disabledIf('sendlatenotifications', 'sendnotifications', 'eq', 1);
|
||||
|
||||
// plagiarism enabling form
|
||||
if (!empty($CFG->enableplagiarism)) {
|
||||
|
@ -36,9 +36,6 @@ $ADMIN->add('assignmentplugins', new admin_category('assignfeedbackplugins',
|
||||
$ADMIN->add('assignfeedbackplugins', new assign_admin_page_manage_assign_plugins('assignfeedback'));
|
||||
|
||||
|
||||
assign_plugin_manager::add_admin_assign_plugin_settings('assignsubmission', $ADMIN, $settings, $module);
|
||||
assign_plugin_manager::add_admin_assign_plugin_settings('assignfeedback', $ADMIN, $settings, $module);
|
||||
|
||||
if ($ADMIN->fulltree) {
|
||||
$menu = array();
|
||||
foreach (get_plugin_list('assignfeedback') as $type => $notused) {
|
||||
@ -55,6 +52,7 @@ if ($ADMIN->fulltree) {
|
||||
$settings->add(new admin_setting_configcheckbox('assign/showrecentsubmissions',
|
||||
new lang_string('showrecentsubmissions', 'assign'),
|
||||
new lang_string('configshowrecentsubmissions', 'assign'), 0));
|
||||
|
||||
$settings->add(new admin_setting_configcheckbox('assign/submissionreceipts',
|
||||
get_string('sendsubmissionreceipts', 'mod_assign'), get_string('sendsubmissionreceipts_help', 'mod_assign'), 1));
|
||||
|
||||
}
|
||||
|
@ -25,7 +25,7 @@
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
$module->component = 'mod_assign';
|
||||
$module->version = 2012050300;
|
||||
$module->version = 2012051700;
|
||||
$module->requires = 2012050300; // Requires this Moodle version
|
||||
$module->cron = 60;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user