@@ -174,8 +174,11 @@ private void sendAnnotationNotificationToStudent(Annotation annotation) {
174174 try {
175175 Notification notification = this .createNotificationForAnnotation (annotation );
176176 Long toWorkgroupId = notification .getToWorkgroup ().getId ();
177- broadcastAnnotationToStudent (toWorkgroupId , annotation );
178- broadcastNotificationToStudent (toWorkgroupId , notification );
177+ this .broadcastAnnotationToStudent (toWorkgroupId , annotation );
178+ if (annotation .getType ().equals ("inappropriateFlag" )) {
179+ this .broadcastAnnotationToClassroom (annotation );
180+ }
181+ this .broadcastNotificationToStudent (toWorkgroupId , notification );
179182 } catch (Exception e ) {
180183 e .printStackTrace ();
181184 }
@@ -217,7 +220,7 @@ private Notification createNotificationForAnnotation(Annotation annotation) {
217220 return notification ;
218221 }
219222
220- public void broadcastAnnotationToStudent (Long toWorkgroupId , Annotation annotation )
223+ private void broadcastAnnotationToStudent (Long toWorkgroupId , Annotation annotation )
221224 throws JSONException {
222225 annotation .convertToClientAnnotation ();
223226 JSONObject message = new JSONObject ();
@@ -227,7 +230,17 @@ public void broadcastAnnotationToStudent(Long toWorkgroupId, Annotation annotati
227230 redisPublisher .publish (message .toString ());
228231 }
229232
230- public void broadcastNotificationToStudent (Long toWorkgroupId , Notification notification )
233+ private void broadcastAnnotationToClassroom (Annotation annotation ) throws JSONException {
234+ annotation .convertToClientAnnotation ();
235+ JSONObject message = new JSONObject ();
236+ message .put ("type" , "annotationToClassroom" );
237+ message .put ("topic" , String .format ("/topic/classroom/%s/%s" , annotation .getRun ().getId (),
238+ annotation .getPeriod ().getId ()));
239+ message .put ("annotation" , annotation .toJSON ());
240+ redisPublisher .publish (message .toString ());
241+ }
242+
243+ private void broadcastNotificationToStudent (Long toWorkgroupId , Notification notification )
231244 throws JSONException {
232245 notification .convertToClientNotification ();
233246 JSONObject message = new JSONObject ();
@@ -236,4 +249,5 @@ public void broadcastNotificationToStudent(Long toWorkgroupId, Notification noti
236249 message .put ("notification" , notification .toJSON ());
237250 redisPublisher .publish (message .toString ());
238251 }
252+
239253}
0 commit comments