-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathfile
More file actions
191 lines (177 loc) · 7.53 KB
/
file
File metadata and controls
191 lines (177 loc) · 7.53 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
diff --git a/admin.html b/admin.html
index 6d6cf49..70ef865 100644
--- a/admin.html
+++ b/admin.html
@@ -292,6 +292,8 @@
</div>
</div>
</div>
+
+
<div role="tabpanel" class="tab-pane" id="view">
<div class="col-md-12">
<h3>Class View</h3>
diff --git a/js/admin.js b/js/admin.js
index 8f89880..9e6c2f1 100644
--- a/js/admin.js
+++ b/js/admin.js
@@ -162,7 +162,11 @@ $(function() {
//
$add_button.bind('click', function() {
// Tell the server to create a new group for the class in the database
- socket.add_group(sessionStorage.getItem('admin_class_id'), $secret);
+ var colors = [], minimum = 0, maximum = 255;
+ colors.push(Math.floor(Math.random() * (maximum - minimum + 1)) + minimum);
+ colors.push(Math.floor(Math.random() * (maximum - minimum + 1)) + minimum);
+ colors.push(Math.floor(Math.random() * (maximum - minimum + 1)) + minimum);
+ socket.add_group(sessionStorage.getItem('admin_class_id'), $secret, colors);
});
//
@@ -527,7 +531,7 @@ $(function() {
'</h4><div class="geogebrawebapplet" id="appletContainer'+ i +
'"style="width:100%;height:650px;display:block;"></div></div>';
- var checkbox = '<label><input checked type="checkbox" onchange="views_change(this)" value="applet'+i+'" name="views_group_'+ i
+ var checkbox = '<label style = "color:red;"><input checked type="checkbox" onchange="views_change(this)" value="applet'+i+'" name="views_group_'+ i
+ '">Group '+ i + '</label>';
$('#views_jsapp').append(newgroup);
diff --git a/js/admin_functions.js b/js/admin_functions.js
index 5825cc8..9fc44cf 100644
--- a/js/admin_functions.js
+++ b/js/admin_functions.js
@@ -454,6 +454,8 @@ function view_merge(event){
var applet = document['applet' + numgroups];
applet.setPerspective('G');
$('#views_checkboxes :checkbox').hide();
+ debugger;
+ //$('#views_checkboxes').style.color = "blue";
$('.merge_group').show();
}
@@ -529,10 +531,10 @@ function rename_labels(xml, num, counter){
for (var i = 0; i < array.length; i++){
if(array[i]["_type"] === 'point'){
- array[i]["_label"] = array[i]["_label"] + 'g' + num;
+ array[i]["_label"] = array[i]["_label"];
if ("caption" in array[i]){
var elem = array[i]["caption"]["_val"];
- array[i]["caption"]["_val"] = elem + 'g' + num;
+ array[i]["caption"]["_val"] = elem;
}
if(elem.includes("admin")){
counter = 1;
@@ -553,7 +555,7 @@ function rename_labels(xml, num, counter){
for (var i = 0; i < array.length; i++){
for (var point in array[i].input){
- array[i]["input"][point] = array[i]["input"][point] + 'g' + num;
+ array[i]["input"][point] = array[i]["input"][point];
}
}
xml.geogebra.construction.command = array;
diff --git a/js/admin_sockets.js b/js/admin_sockets.js
index a042d24..c11f29b 100644
--- a/js/admin_sockets.js
+++ b/js/admin_sockets.js
@@ -42,8 +42,8 @@
// This function takes a class name provided by the user.
// The socket then emits this data to the server to create a
// group for the class.
- var add_group = function (class_id, secret) {
- socket.emit('add-group', class_id, secret);
+ var add_group = function (class_id, secret, colors) {
+ socket.emit('add-group', class_id, secret, colors);
}
// This function takes a class name provided by the user.
diff --git a/js/ggbapplet_functions.js b/js/ggbapplet_functions.js
index ad9e7db..479e799 100644
--- a/js/ggbapplet_functions.js
+++ b/js/ggbapplet_functions.js
@@ -147,6 +147,7 @@ function randomizeColors(appletName, r, g, b) {
} //this is your color
}
+ console.log(colors[0]);
var numelems = appletName.getObjectNumber();
for (i = 0; i < numelems; i++){
var name = appletName.getObjectName(i);
@@ -154,6 +155,13 @@ function randomizeColors(appletName, r, g, b) {
}
}
+function updateColors(appletName)
+{
+ var colors = sessionStorage.getItem('group_colors');
+ colors = colors.split("-");
+ randomizeColors(document.applet, colors[0], colors[1] , colors[2]);
+}
+
//This function grabs all objects in the construction, and sets a lock on them
//if the username in the caption is not the current user.
function checkLocks(appletName){
@@ -163,7 +171,7 @@ function checkLocks(appletName){
var ggb_user = appletName.getCaption(name);
var username = sessionStorage.getItem('username');
- console.log(ggb_user);
+ //console.log(ggb_user);
if ((username !== ggb_user) && ggb_user != "admin"){
appletName.setFixed(name, true);
} else if (username === ggb_user ){
diff --git a/js/student_functions.js b/js/student_functions.js
index 31178de..23e841b 100644
--- a/js/student_functions.js
+++ b/js/student_functions.js
@@ -201,6 +201,7 @@ function xml_change_response(username, class_id, group_id, xml, toolbar) {
var $messages = $('#messages');
$messages.prepend(username + ' has changed the xml.<br/>');
+socket.group_color(sessionStorage.getItem('class_id'),sessionStorage.getItem('group_id'));
appletSetExtXML(xml, toolbar);
ggbOnInit('socket_call');
}
@@ -258,10 +259,18 @@ function delete_student_class_response() {
delete sessionStorage.group_id;
delete sessionStorage.username;
}
+
+function group_color_response(colors) {
+
+ sessionStorage.setItem('group_colors', colors);
+
+}
//This function registers listeners on geogebra initialization
function ggbOnInit(arg) {
document.applet.registerAddListener("addLock");
document.applet.registerUpdateListener("checkUser");
+ document.applet.registerAddListener("updateColors");
+ socket.group_color(sessionStorage.getItem('class_id'),sessionStorage.getItem('group_id'));
console.log(arg);
if(arg != 'socket_call'){
socket.get_xml(sessionStorage.getItem('username'),sessionStorage.getItem('class_id'),sessionStorage.getItem('group_id'));
diff --git a/js/student_sockets.js b/js/student_sockets.js
index 70178d7..32e2648 100644
--- a/js/student_sockets.js
+++ b/js/student_sockets.js
@@ -48,6 +48,12 @@
socket.emit('group_info', username, class_id, group_id, status);
}
+ //This function takes class_id and group_id,
+ // It then emits the socket event to get the color of the group
+ var group_color = function(class_id, group_id) {
+ socket.emit('group-color', class_id, group_id);
+ }
+
//This function takes a username, class_id, group_id, x, y, and info
//It then emits a socket event to change the username's coordinates and info in group_id
//given x, y, and info.
@@ -149,6 +155,10 @@
delete_student_class_response();
});
+ socket.on('group-color-response', function(data) {
+ group_color_response(data[0].group_color);
+ });
+
return {
login: login,
@@ -157,6 +167,7 @@
group_join: group_join,
group_leave: group_leave,
group_info: group_info,
+ group_color: group_color,
coordinate_change: coordinate_change,
xml_change: xml_change,
get_xml: get_xml,