Repository navigation
Expand file tree
/
Copy pathmodule.js
More file actions
264 lines (196 loc) · 8.55 KB
/
Copy pathmodule.js
File metadata and controls
264 lines (196 loc) · 8.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* This defines all javascript needed in the coursework module.
*
* @package mod
* @subpackage coursework
* @copyright 2011 University of London Computer Centre {@link https://www.cosector.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
M.mod_coursework = {
/**
* This is to set up the listeners etc for the page elements on the allocations page.
*/
init_allocate_page: function (e, wwwroot, coursemoduleid) {
"use strict";
// default select
var $menuassessorallocationstrategy = $('#assessorallocationstrategy');
var $selected = $menuassessorallocationstrategy.val();
/// var $newname = '.assessor-strategy-options #assessor-strategy-' + $selected;
var $newname = '#assessor-strategy-' + $selected;
$($newname).css('display', 'block');
// when page was refreshed, display current selection
$(window).on('unload', function () {
$menuassessorallocationstrategy.val($selected);
})
// Show the form elements that allow us to configure the allocatons
$menuassessorallocationstrategy.on('change', function (e) {
var newname = 'assessor-strategy-' + $(this).val();
$('.assessor-strategy-options').each(function () {
var $div = $(this);
var divid = $div.attr('id');
if (divid === newname) {
$div.css('display', 'block');
} else {
$div.css('display', 'none');
}
});
});
// Moderation set rules
$('input[name=addmodsetruletype]').on('click', function (e) {
var formdivname = 'rule-config-' + $(this).val();
$('.rule-config').each(function () {
var $div = $(this);
var divid = $div.attr('id');
if (divid === formdivname) {
$div.css('display', 'block');
} else {
$div.css('display', 'none');
}
});
});
var AUTOMATIC_SAMPLING = 1;
//assessor sampling strategy drop down
$('.assessor_sampling_strategy').each(function (e, element) {
var ele_id = $(this).attr('id').split('_');
if ($(this).val() != AUTOMATIC_SAMPLING) {
$('.' + ele_id[0] + '_' + ele_id[1]).each(function (n, ele) {
$(ele).attr('disabled', true);
});
}
if ($(this).val() == AUTOMATIC_SAMPLING) {
$('#' + ele_id[0] + '_' + ele_id[1] + "_automatic_rules").show();
} else {
$('#' + ele_id[0] + '_' + ele_id[1] + "_automatic_rules").hide();
}
$(element).on('change', function () {
var ele_id = $(this).attr('id').split('_');
var disabled = $(this).val() != AUTOMATIC_SAMPLING;
var eleid = '.' + ele_id[0] + '_' + ele_id[1];
$('.' + ele_id[0] + '_' + ele_id[1]).each(function (n, ele) {
$(ele).attr('disabled', disabled);
});
if ($(this).val() == AUTOMATIC_SAMPLING) {
$('#' + ele_id[0] + '_' + ele_id[1] + "_automatic_rules").show();
} else {
$('#' + ele_id[0] + '_' + ele_id[1] + "_automatic_rules").hide();
}
})
})
$('#save_assessor_allocation_strategy').click(function (e) {
e.preventDefault();
console.log('reallocating allocatables');
var customElement = $("<div>", {
id: "countdown",
css: {
"font-size": "15px",
"display": "block",
"padding-top": "90px"
},
text: 'The allocation strategy is being applied this may take some time please wait'
});
$("#coursework_input_buttons").append(customElement);
$("#coursework_input_buttons").toggleClass('my_overlay');
var allocationformdata = $('#allocation_form').serialize();
allocationformdata = allocationformdata + "&coursemoduleid=" + coursemoduleid;
$.ajax({
url: wwwroot + "/mod/coursework/actions/processallocation.php",
data: allocationformdata,
method: 'POST',
xhrFields: {
onprogress: function (e) {
}
},
success: function (text) {
$("#coursework_input_buttons").toggleClass('my_overlay');
location.reload(true);
}
});
});
$('#save_and_exit_assessor_allocation_strategy').click(function (e) {
e.preventDefault();
var customElement = $("<div>", {
id: "countdown",
css: {
"font-size": "15px",
"display": "block",
"padding-top": "90px"
},
text: 'The allocation strategy is being saved the page will exit shortly. Depending on the number of participants on this course you may not see the results of the allocations straight away in this event refresh the page'
});
$("#coursework_input_buttons").append(customElement);
$("#coursework_input_buttons").toggleClass('my_overlay');
var allocationformdata = $('#allocation_form').serialize();
allocationformdata = allocationformdata + "&coursemoduleid=" + coursemoduleid;
$.ajax({
url: wwwroot + "/mod/coursework/actions/processallocation.php",
data: allocationformdata,
method: 'POST',
xhrFields: {
onprogress: function (e) {
}
},
success: function (text) {
}
});
/* a 5 second delay has been placed before the window location is changed as exiting a page after ajax call
* can sometime lead to the call to the page being aborted. 5 seconds should be enought to allow the page call to occur*/
setTimeout(function () {
window.location = wwwroot + "/mod/coursework/view.php?id=" + coursemoduleid;
}, 5000);
});
},
/**
* This is to set up the listeners etc for the page elements on the allocations page.
*/
init_personaldeadlines_page: function () {
$('#selectall').change(function () {
if ($(this).is(":checked")) {
$('.date_select').prop('checked', true);
} else {
$('.date_select').prop('checked', false);
}
});
$('#selected_dates').click(function () {
var dateselected = false;
$('.date_select').each(function (n, element) {
if ($(element).is(":checked")) {
dateselected = true;
}
})
if (dateselected == true) {
$('#selectedtype').val('date');
$('#coursework_personaldeadline_form').submit();
} else {
alert('You must make at least one selection');
}
});
$('#selected_unfinalise').click( function () {
var unfinaliseselected = false;
$('.date_select').each(function (n, element) {
if ($(element).is(":checked")) {
unfinaliseselected = true;
}
})
if (unfinaliseselected == true) {
$('#selectedtype').val('unfinalise');
$('#coursework_personaldeadline_form').submit();
} else {
alert('You must make at least one selection');
}
});
}
};