|
34 | 34 | $returnurl->param('evasyssynccheck', 1);
|
35 | 35 |
|
36 | 36 | if (!optional_param('activate_standard', false, PARAM_BOOL)) {
|
37 |
| - if (optional_param('only_end', false, PARAM_BOOL)) { |
38 |
| - // Existing start date should not be changed; just the end date. Fetch start date from record. |
| 37 | + |
| 38 | + if (optional_param('datedisabled', false, PARAM_BOOL)) { |
| 39 | + |
39 | 40 | $record = course_evaluation_allocation::get_record_by_course($courseid);
|
40 | 41 | $startdate = new \DateTime('@' . $record->get('startdate'), \core_date::get_server_timezone_object());
|
| 42 | + $enddate = new \DateTime('@' . $record->get('enddate'), \core_date::get_server_timezone_object()); |
| 43 | + |
41 | 44 | } else {
|
42 |
| - $startyear = required_param('year_start', PARAM_TEXT); |
43 |
| - $startmonth = date_decoder::decode_from_localised_string(required_param('month_start', PARAM_TEXT)); |
44 |
| - $startday = required_param('day_start', PARAM_TEXT); |
45 |
| - $starthour = required_param('hour_start', PARAM_TEXT); |
46 |
| - $startmin = required_param('minute_start', PARAM_TEXT); |
47 |
| - |
48 |
| - $startdate = new DateTime(); |
49 |
| - $startdate->setTimezone(\core_date::get_server_timezone_object()); |
50 |
| - $startdate->setDate($startyear, $startmonth, $startday); |
51 |
| - $startdate->setTime($starthour, $startmin); |
52 |
| - if (time() > $startdate->getTimestamp()) { |
53 |
| - // Start date is in the past; change to now (just for the record). |
54 |
| - $startdate = new \DateTime('now', \core_date::get_server_timezone_object()); |
| 45 | + |
| 46 | + if (optional_param('only_end', false, PARAM_BOOL)) { |
| 47 | + // Existing start date should not be changed; just the end date. Fetch start date from record. |
| 48 | + $record = course_evaluation_allocation::get_record_by_course($courseid); |
| 49 | + $startdate = new \DateTime('@' . $record->get('startdate'), \core_date::get_server_timezone_object()); |
| 50 | + } else { |
| 51 | + $startyear = required_param('year_start', PARAM_TEXT); |
| 52 | + $startmonth = date_decoder::decode_from_localised_string(required_param('month_start', PARAM_TEXT)); |
| 53 | + $startday = required_param('day_start', PARAM_TEXT); |
| 54 | + $starthour = required_param('hour_start', PARAM_TEXT); |
| 55 | + $startmin = required_param('minute_start', PARAM_TEXT); |
| 56 | + |
| 57 | + $startdate = new DateTime(); |
| 58 | + $startdate->setTimezone(\core_date::get_server_timezone_object()); |
| 59 | + $startdate->setDate($startyear, $startmonth, $startday); |
| 60 | + $startdate->setTime($starthour, $startmin); |
| 61 | + if (time() > $startdate->getTimestamp()) { |
| 62 | + // Start date is in the past; change to now (just for the record). |
| 63 | + $startdate = new \DateTime('now', \core_date::get_server_timezone_object()); |
| 64 | + } |
55 | 65 | }
|
56 |
| - } |
57 | 66 |
|
58 |
| - $endyear = required_param('year_end', PARAM_TEXT); |
59 |
| - $endmonth = date_decoder::decode_from_localised_string(required_param('month_end', PARAM_TEXT)); |
60 |
| - $endday = required_param('day_end', PARAM_TEXT); |
61 |
| - $endhour = required_param('hour_end', PARAM_TEXT); |
62 |
| - $endmin = required_param('minute_end', PARAM_TEXT); |
| 67 | + $endyear = required_param('year_end', PARAM_TEXT); |
| 68 | + $endmonth = date_decoder::decode_from_localised_string(required_param('month_end', PARAM_TEXT)); |
| 69 | + $endday = required_param('day_end', PARAM_TEXT); |
| 70 | + $endhour = required_param('hour_end', PARAM_TEXT); |
| 71 | + $endmin = required_param('minute_end', PARAM_TEXT); |
| 72 | + |
| 73 | + $enddate = new DateTime(); |
| 74 | + $enddate->setTimezone(\core_date::get_server_timezone_object()); |
| 75 | + $enddate->setDate($endyear, $endmonth, $endday); |
| 76 | + $enddate->setTime($endhour, $endmin); |
63 | 77 |
|
64 |
| - $enddate = new DateTime(); |
65 |
| - $enddate->setTimezone(\core_date::get_server_timezone_object()); |
66 |
| - $enddate->setDate($endyear, $endmonth, $endday); |
67 |
| - $enddate->setTime($endhour, $endmin); |
| 78 | + } |
68 | 79 |
|
69 | 80 | $dates = ["start" => $startdate->getTimestamp(), "end" => $enddate->getTimestamp()];
|
70 | 81 |
|
|
79 | 90 | } else {
|
80 | 91 | $dates = "Standard";
|
81 | 92 | // We can't detect that anyways since we don't know the dates.
|
82 |
| - $datechanged = false; |
| 93 | + $datenew = false; |
83 | 94 | }
|
84 | 95 |
|
85 | 96 | try {
|
86 | 97 | $evasyssynchronizer = new \block_evasys_sync\evasys_synchronizer($courseid);
|
87 |
| - $datechanged = $evasyssynchronizer->set_evaluation_period($dates); |
| 98 | + $datenew = $evasyssynchronizer->set_evaluation_period($dates); |
88 | 99 | } catch (\dml_missing_record_exception $e) {
|
89 | 100 | debugging($e);
|
90 | 101 | $returnurl->param('status', 'failure');
|
|
104 | 115 |
|
105 | 116 | \block_evasys_sync\evaluation_manager::clear_error($courseid);
|
106 | 117 |
|
107 |
| - if ($newparticipantsadded || $datechanged) { |
108 |
| - $evasyssynchronizer->notify_evaluation_responsible_person($dates, $newparticipantsadded, $datechanged); |
| 118 | + if ($newparticipantsadded || $datenew) { |
| 119 | + if ($datenew) { |
| 120 | + // Only send an email if it's the first time requesting this evaluation |
| 121 | + $evasyssynchronizer->notify_evaluation_responsible_person($dates, $newparticipantsadded, $datenew); |
| 122 | + } |
109 | 123 |
|
110 | 124 | // Log event.
|
111 | 125 | $event = \block_evasys_sync\event\evaluation_requested::create(array(
|
|
0 commit comments