-
Notifications
You must be signed in to change notification settings - Fork 58
/
Copy pathmod_form.js
151 lines (135 loc) · 4.89 KB
/
mod_form.js
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
// This file is for 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/>.
/**
* JavaScript functions for student view in mod_form.php
*
* @package mod
* @subpackage offlinequiz
* @author Juergen Zimmer <zimmerj7@univie.ac.at>
* @copyright 2015 Academic Moodle Cooperation {@link http://www.academic-moodle-cooperation.org}
* @since Moodle 2.4
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
function showStudentView() {
attempt = $('#id_attemptclosed').is(":checked") && !$('#id_attemptclosed').is(":disabled");
correctness = $('#id_correctnessclosed').is(":checked") && !$('#id_correctnessclosed').is(":disabled");
marks = $('#id_marksclosed').is(":checked") && !$('#id_marksclosed').is(":disabled");
specificfeedback = $('#id_specificfeedbackclosed').is(":checked") && !$('#id_specificfeedbackclosed').is(":disabled");
generalfeedback = $('#id_generalfeedbackclosed').is(":checked") && !$('#id_generalfeedbackclosed').is(":disabled");
rightanswer = $('#id_rightanswerclosed').is(":checked") && !$('#id_rightanswerclosed').is(":disabled");
sheet = $('#id_sheetclosed').is(":checked") && !$('#id_sheetclosed').is(":disabled");
gradedsheet = $('#id_gradedsheetclosed').is(":checked") && !$('#id_gradedsheetclosed').is(":disabled");
baseurl = $('#basefilename').val();
imagefile1 = '';
imagefile2 = '';
imagefile3 = '';
pagefile = '';
if (sheet || gradedsheet) {
imagefile1 = baseurl + '1';
pagefile = baseurl;
}
if (attempt) {
imagefile1 = baseurl + '1';
imagefile2 = baseurl + '2';
}
if (correctness) {
imagefile2 = imagefile2 + "_correctness";
}
if (marks) {
imagefile1 = baseurl + '1';
imagefile1 = imagefile1 + "_marks";
if (imagefile2 != '') {
imagefile2 = imagefile2 + "_marks";
}
}
if (specificfeedback) {
imagefile2 = imagefile2 + "_specific";
imagefile3 = baseurl + '3';
imagefile3 = imagefile3 + "_specific";
}
if (generalfeedback) {
if (imagefile3 == '') {
imagefile3 = baseurl + '3';
}
imagefile3 = imagefile3 + "_general";
}
if (rightanswer) {
if (imagefile2 == '') {
imagefile2 = baseurl + '2';
}
if (imagefile3 == '') {
imagefile3 = baseurl + '3';
}
imagefile3 = imagefile3 + "_rightanswer";
}
if (gradedsheet) {
imagefile1 = imagefile1 + "_pagelink";
pagefile = pagefile + "_gradedsheet.png";
} else if (sheet) {
imagefile1 = imagefile1 + "_pagelink";
pagefile = pagefile + "_sheet.png";
}
if (imagefile1 != '') {
imagefile1 = imagefile1 + '.png';
}
if (imagefile2 != '') {
imagefile2 = imagefile2 + '.png';
}
if (imagefile3 != '') {
imagefile3 = imagefile3 + '.png';
}
if (imagefile1 != '') {
$('<img />').attr({ 'id': 'image1', 'width': '100%', 'src': imagefile1}).appendTo($('.Popup'));
$('<br/>').appendTo($('.Popup'));
}
if (imagefile2 != '') {
$('<img />').attr({ 'id': 'image2', 'width': '100%', 'src': imagefile2}).appendTo($('.Popup'));
$('<br/>').appendTo($('.Popup'));
}
if (imagefile3 != '') {
$('<img />').attr({ 'id': 'image3', 'width': '100%', 'src': imagefile3}).appendTo($('.Popup'));
$('<br/>').appendTo($('.Popup'));
}
if (pagefile != '') {
$('<hr/>').appendTo($('.Popup'));
$('<img />').attr({ 'id': 'image4', 'width': '100%', 'src': pagefile}).appendTo($('.Popup'));
$('<br/>').appendTo($('.Popup'));
}
$('.Popup').fadeIn("slow");
$('#overlay').fadeIn("slow");
}
function closePopup () {
$('.Popup').fadeOut('slow');
$('#overlay').fadeOut('slow');
$('.Popup').children('img').remove();
$('.Popup').children('br').remove();
$('.Popup').children('hr').remove();
}
// Catch ESC key to close popup.
$(document).keyup(function(e) {
if (e.keyCode == 27) {
closePopup();
} // esc
});
// Close popup when user clicks on overlay.
$("#overlay").click(function(e){
if ($('.Popup').is(':visible')) {
closePopup();
}
});
// Prevent events from getting pass .popup.
$(".Popup").click(function(e){
e.stopPropagation();
});