Skip to content

Commit 49145f9

Browse files
author
Laur0r
authored
Merge pull request #71 from learnweb/feature/automatic-eval-request
Prototype for starting evaluations as evasys coordinator
2 parents 70e46e2 + 1b7a1eb commit 49145f9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+4288
-568
lines changed

.travis.yml

Lines changed: 0 additions & 96 deletions
This file was deleted.

addcourse.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,8 @@
2525
$PAGE->set_context(context_course::instance($id));
2626
$PAGE->set_title(get_string('add_course_header', 'block_evasys_sync'));
2727

28-
$record = $DB->get_record('block_evasys_sync_courseeval', array('course' => $id));
29-
if ($record !== false and ($record->state > \block_evasys_sync\course_evaluation_allocation::STATE_AUTO_NOTOPENED) and
30-
!is_siteadmin() or !get_config('block_evasys_sync', 'default_his_connection')) {
28+
$evaluation = \block_evasys_sync\evaluation::for_course($id);
29+
if ($evaluation and !is_siteadmin() or !get_config('block_evasys_sync', 'default_his_connection')) {
3130
echo $OUTPUT->header();
3231
echo get_string('forbidden', 'block_evasys_sync');
3332
echo $OUTPUT->footer();

adminsettings.php

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,14 @@
3434
if (has_capability('moodle/site:config', context_system::instance())) {
3535
admin_externalpage_setup('block_evasys_sync');
3636

37+
$evasysroleid = $DB->get_record('role', ['shortname' => 'evasysmanager'])->id;
38+
3739
if (!empty($delid) && !empty($confirm)) {
3840
// Course category user is deleted.
39-
$persistent = new \block_evasys_sync\user_cat_allocation($delid);
41+
$persistent = new \block_evasys_sync\evasys_category($delid);
42+
if ($evasysroleid) {
43+
role_unassign($evasysroleid, $persistent->get('userid'), context_coursecat::instance($persistent->get('course_category'))->id);
44+
}
4045
$persistent->delete();
4146

4247
redirect($PAGE->url);
@@ -58,6 +63,7 @@
5863
} else if ($data = $mform->get_data()) {
5964
// Form is submitted.
6065
// Added course category.
66+
6167
if (isset($data->addcatbutton)) {
6268
// Insert new record.
6369
$record = new stdClass();
@@ -68,9 +74,13 @@
6874
} else {
6975
$record->category_mode = 0;
7076
}
71-
$persistent = new \block_evasys_sync\user_cat_allocation(0, $record);
77+
$record->mode_flags = 0;
78+
$persistent = new \block_evasys_sync\evasys_category(0, $record);
7279
$persistent->create();
73-
80+
if ($evasysroleid) {
81+
role_assign($evasysroleid, $record->userid, context_coursecat::instance($record->course_category));
82+
}
83+
\block_evasys_sync\evalcat_manager::get_instance()->purge();
7484
redirect($PAGE->url);
7585
exit();
7686
} else if (isset($data->submitbutton)) {
@@ -101,7 +111,7 @@
101111
set_config('default_his_connection', 0, 'block_evasys_sync');
102112
}
103113

104-
$records = \block_evasys_sync\user_cat_allocation::get_records();
114+
$records = \block_evasys_sync\evasys_category::get_records();
105115
foreach ($records as $allocation) {
106116
$newvalue = 'category_' . $allocation->get('id');
107117
$oldvalue = $allocation->get('userid');
@@ -121,13 +131,19 @@
121131
// Update db entry.
122132
if ($data->$newvalue != $oldvalue or
123133
$newvaluemode != $oldvaluemode) {
124-
134+
if ($evasysroleid && $data->$newvalue != $oldvalue) {
135+
role_unassign($evasysroleid, $oldvalue, context_coursecat::instance($allocation->get('course_category'))->id);
136+
}
125137
$allocation->set('userid', $data->$newvalue);
126138
$allocation->set('category_mode', $newvaluemode);
127139
$allocation->update();
128140
}
141+
if ($evasysroleid) {
142+
role_assign($evasysroleid, $data->$newvalue, context_coursecat::instance($allocation->get('course_category')));
143+
}
129144
}
130145
}
146+
\block_evasys_sync\evalcat_manager::get_instance()->purge();
131147
}
132148

133149
echo $OUTPUT->header();

amd/build/edit_timeframe.min.js

Lines changed: 3 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

amd/build/edit_timeframe.min.js.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)