Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alert coordinators #58

Merged
merged 5 commits into from
Oct 25, 2019
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions classes/course_evasys_courses_allocation.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,26 @@ protected static function define_properties() {
),
);
}

/** Returns array of evasysids that belong to this course.
* @param $courseid int id of moodle course
* @return array of evasysids
* @throws \dml_exception
*/
public static function get_evasyscourses($courseid) {
sevenseas-gists marked this conversation as resolved.
Show resolved Hide resolved
global $DB;
$courses = $DB->get_field(self::TABLE, 'evasyscourses', array('course' => $courseid));
$idcourse = $DB->get_field('course', 'idnumber', array('id' => $courseid));
if (!$courses) {
return array ($idcourse);
}
$coursearray = explode($courses, '#');
if ($idcourse) {
if (!in_array($idcourse, $coursearray)) {
$coursearray[] = $idcourse;
}
}
array_unique($coursearray);
return $coursearray;
}
}
25 changes: 25 additions & 0 deletions classes/evasys_inviter.php
Original file line number Diff line number Diff line change
Expand Up @@ -331,4 +331,29 @@ public static function getmode($category) {
$default = get_config('block_evasys_sync', 'default_evasys_mode');
return (bool)$default;
}

/**
* Alerts the Evaluation-coordinator of a given course, that a teacher has set a timeframe for the evaluation.
* @param $courseid int
* @param $startdate \DateTime Startdate
* @param $enddate \DateTime
* @throws \coding_exception
* @throws \dml_exception
*/
public static function alert_coordinator($courseid, $startdate, $enddate) {
global $USER;
$course = get_course($courseid);
$usercoordinator = evasys_synchronizer::get_assigned_user($course);
$data = array(
'name' => $course->fullname,
'teacher' => $USER->firstname . " " . $USER->lastname,
'start' => $startdate->format('d.m.Y H:i:s'),
'end' => $enddate->format('d.m.Y H:i:s'),
);
$subject = get_string("alert_email_subject", "block_evasys_sync", $course->fullname);
$message = get_string("alert_email_body", "block_evasys_sync", $data);

email_to_user($usercoordinator, $USER, $subject, $message, '', '' , '',
true, $USER->email, $USER->firstname . " " . $USER->lastname);
}
}
2 changes: 1 addition & 1 deletion invite.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@
)
);
$event->trigger();

\block_evasys_sync\evasys_inviter::alert_coordinator($courseid, $startdate, $enddate);

if ($invitedirect) {
$invitedusers = count_enrolled_users(context_course::instance($courseid), 'block/evasys_sync:mayevaluate');
Expand Down
10 changes: 10 additions & 0 deletions lang/de/block_evasys_sync.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,16 @@
$string['content_send_invalid'] = "Eine Evaluationsperiode beginnt nachdem sie endet! <br />" .
"Alle anderen Evaluationsperioden wurden wie gewohnt geändert.";

// Alert Coordinator mail.
$string['alert_email_subject'] = 'Evaluationszeitraum gesetzt für {$a}';
$string['alert_email_body'] = 'Sehr geehrte*r Evaluationskoordinator*in, ' . "\n" .
'Sie erhalten diese Email da im Kurs {$a->name} der Evaluationszeitraum wie folgt festgesetzt wurde:' . "\n\n" .
sevenseas-gists marked this conversation as resolved.
Show resolved Hide resolved
"\t".'Start: {$a->start}' . "\n" .
"\t".'Ende: {$a->end}' . "\n" .
"\t".'Verantwortlicher: {$a->teacher}' . "\n\n" .
'Mit freundlichen Grüßen' . "\n" .
'Ihr Learnweb-Support';

// New invite strings.
$string['title_success'] = "Erfolgreich";
$string['content_success_invite'] = "Die Evaluation wurde erfolgreich gestartet";
Expand Down
9 changes: 9 additions & 0 deletions lang/en/block_evasys_sync.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,15 @@
"This is not allowed. Some evaluationperiods may have been altered.<br />";
$string['content_confirm_reactivate'] = "Are you sure you want to reactivate the invite options? This will restart all surveys with at least one new participant";

// Alert Coordinator mail.
$string['alert_email_subject'] = 'Evaluationtimeframe configured for {$a}';
$string['alert_email_body'] = 'Dear Evaluationcoordinator, ' . "\n" .
'The Evaluationtimeframe for Course {$a->name} has been set to:' . "\n\n" .
"\t" . 'Start: {$a->start}' . "\n" .
"\t" . 'Ende: {$a->end}' . "\n" .
"\t" . 'by {$a->teacher} ' . "\n\n" .
'Sincerely Learnweb-Support';

// New invite strings.
$string['title_success'] = "Success";
$string['content_success_invite'] = "Evaluation has been started";
Expand Down