Skip to content

Commit c688509

Browse files
author
Laur0r
authored
Merge pull request #79 from learnweb/feature/automatic-eval-request-disable-new-dates-for-evalrequest
Feature/automatic eval request disable new dates for evalrequest
2 parents ea8f418 + 73a9e7b commit c688509

12 files changed

+103
-43
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/build/post_dialog.min.js

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

amd/build/standardtime.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

+7
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ define(['jquery', 'core/notification', 'core/str'], function ($, notification, s
2020
$('[name=year_end]').last()[0].selectedIndex = end.getFullYear() - 2000;
2121
if ($('#reactivate').length > 0) {
2222
endenabled = !$('[name=minute_end]')[0].disabled;
23+
datedisabled = $('[name=minute_end]')[0].disabled && $('[name=minute_start]')[0].disabled;
2324
$(document).on("change", "#reactivate", function() {
2425
if (this.checked) {
2526
// Ask for confirmation, then enable all fields related to re-invitation.
@@ -51,6 +52,9 @@ define(['jquery', 'core/notification', 'core/str'], function ($, notification, s
5152
if ($('#only_end').length > 0) {
5253
$('#only_end').prop("value", false);
5354
}
55+
if ($('#datedisabled').length > 0) {
56+
$('#datedisabled').prop("value", false);
57+
}
5458
if ($('#evasyssubmitbutton').length > 0) {
5559
$('#evasyssubmitbutton').prop("disabled", false);
5660
$('#evasyssubmitbutton').val(s[4]);
@@ -81,6 +85,9 @@ define(['jquery', 'core/notification', 'core/str'], function ($, notification, s
8185
if ($('#only_end').length > 0) {
8286
$('#only_end').prop("value", true);
8387
}
88+
if ($('#datedisabled').length > 0) {
89+
$('#datedisabled').prop("value", true);
90+
}
8491
if ($('#evasyssubmitbutton').length > 0) {
8592
if (!endenabled) {
8693
$('#evasyssubmitbutton').prop("disabled", true);

amd/src/post_dialog.js

+13-1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,17 @@ define(['jquery', 'core/notification', 'core/str'], function($, notification, st
2222
).fail(notification.exception);
2323
};
2424

25+
var show_dialog_success_and_info = function() {
26+
str.get_strings([
27+
{'key' : 'title_success', component: 'block_evasys_sync'},
28+
{'key' : 'content_successandinfo', component: 'block_evasys_sync'},
29+
{'key' : 'confirm_box', component: 'block_evasys_sync'},
30+
]).done(function(s) {
31+
notification.alert(s[0], s[1], s[2]);
32+
}
33+
).fail(notification.exception);
34+
}
35+
2536
var show_dialog_nostudents = function() {
2637
str.get_strings([
2738
{'key' : 'title_failure', component: 'block_evasys_sync'},
@@ -48,6 +59,7 @@ define(['jquery', 'core/notification', 'core/str'], function($, notification, st
4859
show_dialog_failure: show_dialog_failure,
4960
show_dialog_no_students: show_dialog_nostudents,
5061
show_dialog_success: show_dialog_success,
51-
show_dialog_up_to_date: show_dialog_up_to_date
62+
show_dialog_up_to_date: show_dialog_up_to_date,
63+
show_dialog_success_and_info: show_dialog_success_and_info
5264
};
5365
});

amd/src/standardtime.js

+1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ define(['jquery', 'core/str'], function($, str) {
3434
$('[name=month_end]')[0].disabled = true;
3535
$('[name=year_end]')[0].disabled = true;
3636
$('#only_end').val(false);
37+
$('#datedisabled').val(true);
3738
};
3839

3940
var enable = function() {

block_evasys_sync.php

+7-2
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ public function get_content() {
9898
$enddisabled = false;
9999
$emailsentnotice = false;
100100
$periodsetnotice = false;
101+
$datedisabled = false;
101102

102103
// Set start to today and end to a week from now.
103104
$start = time();
@@ -115,6 +116,7 @@ public function get_content() {
115116
$first = array_key_first($evaluations->evaluations);
116117
$start = $evaluations->evaluations[$first]->start;
117118
$end = $evaluations->evaluations[$first]->end;
119+
$datedisabled = true;
118120
} elseif ($evasyscategory->default_period_set()) {
119121
$start = $evasyscategory->get('standard_time_start');
120122
$end = $evasyscategory->get('standard_time_end');
@@ -186,8 +188,9 @@ public function get_content() {
186188
'usestandardtimelayout' => $standardttimemode,
187189
// Choose mode.
188190
'direct' => false,
189-
'startdisabled' => $startdisabled || $standardttimemode,
190-
'enddisabled' => $enddisabled || $standardttimemode,
191+
'startdisabled' => $startdisabled || $standardttimemode || $datedisabled,
192+
'enddisabled' => $enddisabled || $standardttimemode || $datedisabled,
193+
'datedisabled' => $datedisabled,
191194
'onlyend' => $startdisabled && !$standardttimemode,
192195
'disablesubmit' => $enddisabled,
193196
// If the evaluation hasn't ended yet, display option to restart it.
@@ -223,6 +226,8 @@ public function display_status($status) {
223226
$this->page->requires->js_call_amd('block_evasys_sync/post_dialog', 'show_dialog_success');
224227
} else if ($status === 'uptodate') {
225228
$this->page->requires->js_call_amd('block_evasys_sync/post_dialog', 'show_dialog_up_to_date');
229+
} else if ($status === 'successandinfo') {
230+
$this->page->requires->js_call_amd('block_evasys_sync/post_dialog', 'show_dialog_success_and_info');
226231
} else if ($status === 'nostudents') {
227232
$this->page->requires->js_call_amd('block_evasys_sync/post_dialog', 'show_dialog_no_students');
228233
} else if ($status === 'failure') {

classes/evasys_synchronizer.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ static public function get_assigned_user($course) {
365365
* Set time period for evaluation.
366366
*
367367
* @param array $dates expects keys `start' and `end' with timestamp values.
368-
* @return bool true if the dates have changed or if the record is new.
368+
* @return bool true if the date record is new.
369369
* @throws \coding_exception
370370
* @throws \dml_missing_record_exception
371371
*/
@@ -375,10 +375,11 @@ public function set_evaluation_period($dates) : bool {
375375
if ($usestandardtime) {
376376
$dates = self::get_standard_timemode($course->category);
377377
}
378-
$changed = false;
378+
$new = false;
379379
$data = evaluation::for_course($this->courseid);
380380
if (!$data) {
381381
$data = new evaluation();
382+
$new = true;
382383
$data->courses = [$this->courseid];
383384
foreach ($this->courseinformation as $lsfid => $information) {
384385
$data->evaluations[$lsfid] = (object) [
@@ -392,15 +393,14 @@ public function set_evaluation_period($dates) : bool {
392393
} else {
393394
foreach ($data->evaluations as &$evaluation) {
394395
if ($evaluation->start != $dates['start'] || $evaluation->end != $dates['end']) {
395-
$changed = true;
396396
$evaluation->start = $dates['start'];
397397
$evaluation->end = $dates['end'];
398398
}
399399
}
400400
}
401401
$data->save();
402402

403-
return $changed;
403+
return $new;
404404
}
405405

406406
/**

0 commit comments

Comments
 (0)