Polling for lesson updates (updates the menu and page navigation)
This commit is contained in:
parent
76daac0db5
commit
e422da4c64
@ -40,9 +40,10 @@ public class LessonProgressService {
|
||||
@RequestMapping(value = "/service/lessonprogress.mvc", produces = "application/json")
|
||||
@ResponseBody
|
||||
public Map getLessonInfo() {
|
||||
UserTracker userTracker = userTrackerRepository.findByUser(webSession.getUserName());
|
||||
LessonTracker lessonTracker = userTracker.getLessonTracker(webSession.getCurrentLesson());
|
||||
Map json = Maps.newHashMap();
|
||||
UserTracker userTracker = userTrackerRepository.findByUser(webSession.getUserName());
|
||||
if (webSession.getCurrentLesson() != null) {
|
||||
LessonTracker lessonTracker = userTracker.getLessonTracker(webSession.getCurrentLesson());
|
||||
String successMessage = "";
|
||||
boolean lessonCompleted = false;
|
||||
if (lessonTracker != null) {
|
||||
@ -51,6 +52,7 @@ public class LessonProgressService {
|
||||
}
|
||||
json.put("lessonCompleted", lessonCompleted);
|
||||
json.put("successMessage", successMessage);
|
||||
}
|
||||
return json;
|
||||
}
|
||||
|
||||
|
@ -7,9 +7,13 @@ define(['jquery',
|
||||
return Backbone.Collection.extend({
|
||||
model: MenuModel,
|
||||
url: 'service/lessonmenu.mvc',
|
||||
|
||||
initialize: function () {
|
||||
var self = this;
|
||||
this.fetch();
|
||||
setInterval(function () {
|
||||
this.fetch()
|
||||
}.bind(this), 5000);
|
||||
},
|
||||
|
||||
onDataLoaded: function () {
|
||||
|
@ -25,6 +25,9 @@ define(['jquery',
|
||||
self.navToPage(page);
|
||||
}
|
||||
});
|
||||
setInterval(function () {
|
||||
this.updatePagination();
|
||||
}.bind(this), 5000);
|
||||
},
|
||||
|
||||
findPage: function(assignment) {
|
||||
@ -60,7 +63,9 @@ define(['jquery',
|
||||
},
|
||||
|
||||
updatePagination: function() {
|
||||
if ( this.paginationControlView != undefined ) {
|
||||
this.paginationControlView.updateCollection();
|
||||
}
|
||||
},
|
||||
|
||||
getCurrentPage: function () {
|
||||
|
Loading…
x
Reference in New Issue
Block a user