Skip to content

Commit 63de62f

Browse files
author
rtschu
committed
Merge branch 'learnweb-master' into behat2
2 parents c91ae71 + ddce1ba commit 63de62f

11 files changed

+101
-51
lines changed

amd/build/initialize.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

amd/src/initialize.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
define(['jquery', 'core/notification', 'core/str'], function ($, notification, str) {
2-
var init = function(starttime, endtime) {
2+
var init = function(starttime, endtime, mode) {
33
var start = new Date(starttime * 1000);
44
var end = new Date(endtime * 1000);
55
var endenabled;
@@ -25,7 +25,7 @@ define(['jquery', 'core/notification', 'core/str'], function ($, notification, s
2525
// Ask for confirmation, then enable all fields related to re-invitation.
2626
str.get_strings([
2727
{'key': 'confirm'},
28-
{'key': 'content_confirm_reactivate', component: 'block_evasys_sync'},
28+
{'key': 'content_confirm_reactivate_'+mode, component: 'block_evasys_sync'},
2929
{'key': 'yes'},
3030
{'key': 'no'},
3131
{'key': 'requestagain', component: 'block_evasys_sync'}

block_evasys_sync.php

+22-12
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ public function get_content() {
5555
// If there has been a status in the url, show the prompt.
5656
$this->display_status($status);
5757

58+
// Get the evasys-persistenceclass for the current course if it exists.
59+
// The persistencelass only gets created when the teacher sets the evaluation period or sends an email to the coordinator.
60+
$record = course_evaluation_allocation::get_record_by_course($this->page->course->id, false);
61+
5862
// If we are not in sync mode, we display either the course mapping or the check status button.
5963
if ($evasyssynccheck !== 1) {
6064
$inlsf = (!empty($this->page->course->idnumber) or $this->page->course->idnumber === '0');
@@ -79,8 +83,12 @@ public function get_content() {
7983
if ($ismodeautomated) {
8084
$this->page->requires->js_call_amd('block_evasys_sync/invite_manager', 'init');
8185
} else {
82-
$hasstandardtime = \block_evasys_sync\evasys_synchronizer::get_standard_timemode($this->page->course->category);
83-
$this->page->requires->js_call_amd('block_evasys_sync/standardtime', 'init');
86+
$categoryhasstandardtime = \block_evasys_sync\evasys_synchronizer::get_standard_timemode($this->page->course->category);
87+
88+
// Only use standardtime js if no record exists.
89+
if (!$record) {
90+
$this->page->requires->js_call_amd('block_evasys_sync/standardtime', 'init');
91+
}
8492
}
8593
$evasyssynchronizer = new \block_evasys_sync\evasys_synchronizer($this->page->course->id);
8694
try {
@@ -110,15 +118,13 @@ public function get_content() {
110118
$oneweeklater->add(new \DateInterval("P7D"));
111119
$end = $oneweeklater->getTimestamp();
112120

113-
// Get the evasys-persistenceclass for the current course if it exists.
114-
// The persistencelass only gets created when the teacher sets the evaluation period or sends an email to the coordinator.
115-
$record = course_evaluation_allocation::get_record_by_course($this->page->course->id, false);
116-
117121
// See if there are any students that can evaluate.
118122
// If there are no students we disable all controls.
119123
$nostudents = (count_enrolled_users(
120124
context_course::instance($this->page->course->id), 'block/evasys_sync:mayevaluate') == 0);
121125

126+
$recordhasstandardtime = false;
127+
122128
if ($record !== false) {
123129
$state = $record->get('state');
124130
if ($state == course_evaluation_allocation::STATE_MANUAL) {
@@ -144,14 +150,18 @@ public function get_content() {
144150
// Set start and end to match the period that had been set.
145151
$start = $record->get('startdate');
146152
$end = $record->get('enddate');
153+
$recordhasstandardtime = $record->get('usestandardtime');
147154
} else {
148-
if (!$ismodeautomated && $hasstandardtime) {
149-
$start = $hasstandardtime['start'];
150-
$end = $hasstandardtime['end'];
155+
if (!$ismodeautomated && $categoryhasstandardtime) {
156+
$start = $categoryhasstandardtime['start'];
157+
$end = $categoryhasstandardtime['end'];
158+
$recordhasstandardtime = true;
151159
}
152160
}
153161
// This javascript module sets the start and end fields to the correct values.
154-
$this->page->requires->js_call_amd('block_evasys_sync/initialize', 'init', array($start, $end));
162+
$jsmodestring = $ismodeautomated ? 'automated' : 'manual';
163+
$jsmodestring .= $enddisabled ? '_closed' : '_open';
164+
$this->page->requires->js_call_amd('block_evasys_sync/initialize', 'init', array($start, $end, $jsmodestring));
155165

156166
// Initialize variables to pass to mustache.
157167
$unknownidnumbercourse = false;
@@ -222,7 +232,7 @@ public function get_content() {
222232
// Append this course.
223233
$courses[] = $course;
224234
}
225-
$standardttimemode = (!$ismodeautomated && $hasstandardtime && !$record);
235+
$standardttimemode = (!$ismodeautomated && $recordhasstandardtime && !$record);
226236
// Create the data object for the mustache table.
227237
$data = array(
228238
'href' => $href,
@@ -233,7 +243,7 @@ public function get_content() {
233243
* In case of the automated workflow, we require surveys
234244
* in order to be able to automatically trigger the evaluation. */
235245
'showcontrols' => ($hassurveys || !$ismodeautomated) && count($evasyscourses) > 0 && !$invalidcourses,
236-
'usestandardtimelayout' => (!$ismodeautomated && $hasstandardtime && !$wasstarted),
246+
'usestandardtimelayout' => (!$ismodeautomated && $recordhasstandardtime && !$wasstarted && !$record),
237247
// Choose mode.
238248
'direct' => $ismodeautomated,
239249
'startdisabled' => $startdisabled || $standardttimemode,

classes/course_evaluation_allocation.php

+4
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@ protected static function define_properties() {
5353
'type' => PARAM_INT,
5454
'message' => new \lang_string('invaliddate', 'block_evasys_sync')
5555
),
56+
'usestandardtime' => array(
57+
'type' => PARAM_BOOL,
58+
'default' => false
59+
),
5660
'state' => array(
5761
'type' => PARAM_INT,
5862
'required' => true,

classes/evasys_synchronizer.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,8 @@ static public function get_assigned_user($course) {
355355
* @throws \dml_missing_record_exception
356356
*/
357357
public function set_evaluation_period($dates) : bool {
358-
if ($dates == 'Standard') {
358+
$usestandardtime = ($dates == 'Standard');
359+
if ($usestandardtime) {
359360
$course = get_course($this->courseid);
360361
$dates = self::get_standard_timemode($course->category);
361362
}
@@ -374,6 +375,7 @@ public function set_evaluation_period($dates) : bool {
374375

375376
$data->set('startdate', $dates['start']);
376377
$data->set('enddate', $dates['end']);
378+
$data->set('usestandardtime', $usestandardtime);
377379
$data->save();
378380

379381
return $changed;

db/upgrade.php

+15
Original file line numberDiff line numberDiff line change
@@ -222,5 +222,20 @@ function xmldb_block_evasys_sync_upgrade ($oldversion) {
222222
upgrade_block_savepoint(true, 2019201400, 'evasys_sync');
223223
}
224224

225+
if ($oldversion < 2019203100) {
226+
227+
// Define field usestandardtime to be added to block_evasys_sync_courseeval.
228+
$table = new xmldb_table('block_evasys_sync_courseeval');
229+
$field = new xmldb_field('usestandardtime', XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, '0', 'timemodified');
230+
231+
// Conditionally launch add field usestandardtime.
232+
if (!$dbman->field_exists($table, $field)) {
233+
$dbman->add_field($table, $field);
234+
}
235+
236+
// Evasys_sync savepoint reached.
237+
upgrade_block_savepoint(true, 2019203100, 'evasys_sync');
238+
}
239+
225240
return true;
226241
}

lang/de/block_evasys_sync.php

+9-3
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@
3737
$string['end'] = 'Ende';
3838
$string['direct_invite_checkbox'] = 'Evaluation sofort starten';
3939
$string['reactivate_invite'] = 'Einladung erneut durchführen';
40+
$string['reactivate_startdate'] = 'Startdatum anpassen';
41+
$string['warning_inconsistent_states'] = "Einige Umfragen sind geöffnet, aber alle Umfragen sollten geschlossen sein.";
4042
$string['change_mapping'] = "Weitere Veranstaltungen zuordnen";
4143
$string['semester'] = "Semester";
4244
$string['optional'] = "(Optional)";
@@ -127,9 +129,13 @@
127129
"Bitte wenden Sie sich an den Support.";
128130

129131
$string['confirm_box'] = "Verstanden";
130-
$string['content_confirm_reactivate'] = "Diese Option wird die Startzeit erneut freigeben. Eine erneutes Setzen der Startzeit wird " .
131-
" alle Evaluationen neu anstoßen, für die mindestens ein*e neue*r Teilnehmer*in vorhanden ist. <br />" .
132-
"Sind Sie sicher, dass sie die Startzeit freigeben möchten?";
132+
$string['content_confirm_reactivate_automated_closed'] = 'Sind Sie sicher, dass Sie die Evaluation erneut beginnen möchten?';
133+
$string['content_confirm_reactivate_automated_open'] = 'Sind Sie sicher, dass Sie die Startzeit ändern möchten?';
134+
$string['content_confirm_reactivate_manual_closed'] = 'Sind Sie sicher, dass Sie die Evaluation erneut beginnen möchten? ' .
135+
'Evaluationskoordinator*innen werden über die Änderung informiert und können die Evaluation anschließend neu starten.';
136+
$string['content_confirm_reactivate_manual_open'] = 'Sind Sie sicher, dass Sie die Startzeit ändern möchten? ' .
137+
'Evaluationskoordinator*innen werden über die Änderung informiert und können die Evaluation anpassen, ' .
138+
'aber es ist nicht sicher, dass dies rechtzeitig geschieht.';
133139

134140
// Survey status.
135141
$string['surveystatusopen'] = 'offen';

lang/en/block_evasys_sync.php

+10-2
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@
3939
$string['semester'] = "Semester";
4040
$string['direct_invite_checkbox'] = 'Start evaluation immediately';
4141
$string['reactivate_invite'] = 'Invite students again';
42+
$string['reactivate_startdate'] = 'Modify start date';
43+
$string['warning_inconsistent_states'] = "There are some open surveys, but all surveys should be closed.";
4244
$string['optional'] = '(optional)';
4345
$string['standard_period'] = "Standard evaluationperiod:";
4446
$string['different_period'] = "Exceptional evaluationperiod:";
@@ -106,8 +108,14 @@
106108
$string['direct_title_info'] = "Invitation already complete";
107109
$string['title_send_rejected'] = "Invalid Date";
108110
$string['content_send_rejected'] = "One or more dates have been set to a date in the past. <br />" .
109-
"This is not allowed. Some evaluationperiods may have been altered.<br />";
110-
$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";
111+
"This is not allowed. Some evaluation periods may have been altered.<br />";
112+
$string['content_confirm_reactivate_automated_closed'] = 'Are you sure you want to change the start date?';
113+
$string['content_confirm_reactivate_automated_open'] = 'Are you sure you want to restart the evaluation?';
114+
$string['content_confirm_reactivate_manual_closed'] = 'Are you sure you want to restart the evaluation? ' .
115+
'Submitting the form will cause the coordinator to be notified of the change, who is then able to restart the evaluation.';
116+
$string['content_confirm_reactivate_manual_open'] = 'Are you sure you want to change the start date? ' .
117+
'Submitting the form will cause the coordinator to be notified of the change, but there is no guarantee ' .
118+
'that the dates will be modified in time.';
111119

112120
// Alert Coordinator mail.
113121
$string['alert_email_subject'] = 'Evaluationszeitraum gesetzt für {$a}';

sync.php

+15-15
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,13 @@
1919

2020
require_once('../../config.php');
2121

22-
require_login();
23-
require_sesskey();
2422
$courseid = required_param('courseid', PARAM_INT);
23+
require_login($courseid);
24+
require_sesskey();
25+
26+
$returnurl = new moodle_url($CFG->wwwroot . '/course/view.php');
27+
$returnurl->param('id', $courseid);
28+
$returnurl->param('evasyssynccheck', 1);
2529

2630
if (!optional_param('activate_standard', false, PARAM_BOOL)) {
2731
if (optional_param('only_end', false, PARAM_BOOL)) {
@@ -57,6 +61,15 @@
5761
$enddate->setTime($endhour, $endmin);
5862

5963
$dates = ["start" => $startdate->getTimestamp(), "end" => $enddate->getTimestamp()];
64+
65+
if ($dates['start'] > $dates['end']) {
66+
redirect($returnurl, get_string('syncstartafterend', 'block_evasys_sync'), 0, \core\output\notification::NOTIFY_ERROR);
67+
exit();
68+
}
69+
if (time() > $dates['end']) {
70+
redirect($returnurl, get_string('syncendinthepast', 'block_evasys_sync'), 0, \core\output\notification::NOTIFY_ERROR);
71+
exit();
72+
}
6073
} else {
6174
$dates = "Standard";
6275
// We can't detect that anyways since we don't know the dates.
@@ -79,19 +92,6 @@
7992
$PAGE->set_context(context_course::instance($courseid));
8093
require_capability('block/evasys_sync:synchronize', context_course::instance($courseid));
8194

82-
$returnurl = new moodle_url($CFG->wwwroot . '/course/view.php');
83-
$returnurl->param('id', $courseid);
84-
$returnurl->param('evasyssynccheck', 1);
85-
86-
if ($dates['start'] > $dates['end']) {
87-
redirect($returnurl, get_string('syncstartafterend', 'block_evasys_sync'), 0, \core\output\notification::NOTIFY_ERROR);
88-
exit();
89-
}
90-
if (time() > $dates['end']) {
91-
redirect($returnurl, get_string('syncendinthepast', 'block_evasys_sync'), 0, \core\output\notification::NOTIFY_ERROR);
92-
exit();
93-
}
94-
9595
try {
9696
if (count_enrolled_users(context_course::instance($courseid), 'block/evasys_sync:mayevaluate') == 0) {
9797
$returnurl->param('status', 'nostudents');

0 commit comments

Comments
 (0)