Pagination fixes, lesson completion update
This commit is contained in:
parent
2803607901
commit
22a76624e6
@ -910,6 +910,10 @@ cookie-container {
|
||||
cursor:pointer;
|
||||
}
|
||||
|
||||
.show-prev-page {
|
||||
margin-right: 10px;
|
||||
}
|
||||
|
||||
.show-prev-page:hover {
|
||||
cursor:pointer;
|
||||
}
|
||||
|
@ -50,7 +50,7 @@ define(['jquery',
|
||||
this.lessonContent = new LessonContentModel();
|
||||
this.lessonProgressModel = new LessonProgressModel();
|
||||
this.lessonProgressView = new LessonProgressView(this.lessonProgressModel);
|
||||
this.lessonView = options.lessonView;
|
||||
this.lessonContentView = options.lessonContentView;
|
||||
this.developerControlsView = new DeveloperControlsView();
|
||||
|
||||
_.extend(Controller.prototype,Backbone.Events);
|
||||
@ -69,10 +69,6 @@ define(['jquery',
|
||||
}
|
||||
this.lessonContent.loadData({
|
||||
'name':name
|
||||
// 'scr': scr,
|
||||
// 'menu': menu,
|
||||
// 'stage': stage,
|
||||
// 'num': num,
|
||||
});
|
||||
this.planView = {};
|
||||
this.solutionView = {};
|
||||
@ -96,6 +92,7 @@ define(['jquery',
|
||||
this.listenTo(this.helpControlsView,'source:show',this.hideShowHelps);
|
||||
this.listenTo(this.helpControlsView,'lesson:restart',this.restartLesson);
|
||||
this.listenTo(this.developerControlsView, 'dev:labels', this.restartLesson);
|
||||
this.listenTo(this.lessonContentView, 'lesson:complete', this.updateMenu)
|
||||
|
||||
this.listenTo(this,'hints:show',this.onShowHints);
|
||||
|
||||
@ -104,14 +101,18 @@ define(['jquery',
|
||||
this.titleView.render(this.lessonInfoModel.get('lessonTitle'));
|
||||
};
|
||||
|
||||
this.updateMenu = function() {
|
||||
this.trigger('menu:reload')
|
||||
};
|
||||
|
||||
this.onContentLoaded = function(loadHelps) {
|
||||
this.lessonInfoModel = new LessonInfoModel();
|
||||
this.listenTo(this.lessonInfoModel,'info:loaded',this.onInfoLoaded);
|
||||
|
||||
if (loadHelps) {
|
||||
this.helpControlsView = null;
|
||||
this.lessonView.model = this.lessonContent;
|
||||
this.lessonView.render();
|
||||
this.lessonContentView.model = this.lessonContent;
|
||||
this.lessonContentView.render();
|
||||
|
||||
this.planView = new PlanView();
|
||||
this.solutionView = new SolutionView();
|
||||
@ -179,7 +180,7 @@ define(['jquery',
|
||||
});
|
||||
if (this.lessonInfoModel.get('numberHints') > 0) {
|
||||
|
||||
this.lessonView.$el.find('#show-hints-button').unbind().on('click',_.bind(this.showHints,this)).show();
|
||||
this.lessonContentView.$el.find('#show-hints-button').unbind().on('click',_.bind(this.showHints,this)).show();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -15,7 +15,7 @@ define(['jquery',
|
||||
MenuView,
|
||||
DeveloperControlsView) {
|
||||
|
||||
var lessonView = new LessonContentView();
|
||||
var lessonContentView = new LessonContentView();
|
||||
var menuView = new MenuView();
|
||||
var developerControlsView = new DeveloperControlsView();
|
||||
|
||||
@ -28,7 +28,7 @@ define(['jquery',
|
||||
},
|
||||
|
||||
lessonController: new LessonController({
|
||||
lessonView: lessonView
|
||||
lessonContentView: lessonContentView
|
||||
}),
|
||||
|
||||
menuController: new MenuController({
|
||||
|
@ -75,8 +75,11 @@ define(['jquery',
|
||||
onSuccessResponse: function(data) {
|
||||
console.log(data);
|
||||
this.renderFeedback(data.feedback);
|
||||
// update menu if lessonCompleted is true
|
||||
|
||||
this.renderOutput(data.output || "");
|
||||
if (data.lessonComplete) {
|
||||
this.trigger('lesson:complete');
|
||||
}
|
||||
return false;
|
||||
},
|
||||
|
||||
@ -107,17 +110,26 @@ define(['jquery',
|
||||
},
|
||||
|
||||
addPaginationControls: function() {
|
||||
var pagingControlsDiv
|
||||
this.$el.html();
|
||||
this.$prevPageButton = $('<span>',{class:'glyphicon-class glyphicon glyphicon-circle-arrow-left show-prev-page'});
|
||||
this.$prevPageButton.unbind().on('click',this.decrementPageView.bind(this));
|
||||
|
||||
this.$nextPageButton = $('<span>',{class:'glyphicon-class glyphicon glyphicon-circle-arrow-right show-next-page'});
|
||||
this.$nextPageButton.unbind().on('click',this.incrementPageView.bind(this));
|
||||
|
||||
var pagingControlsDiv = $('<div>',{class:'panel-body', id:'lessong-page-controls'});
|
||||
if (this.$el.find('#lesson-page-controls').length < 1) {
|
||||
pagingControlsDiv = $('<div>',{class:'panel-body', id:'lesson-page-controls'});
|
||||
pagingControlsDiv.append(this.$prevPageButton);
|
||||
pagingControlsDiv.append(this.$nextPageButton);
|
||||
this.$el.append(pagingControlsDiv);
|
||||
this.$prevPageButton.hide()
|
||||
}
|
||||
//
|
||||
if (this.numPages > 0 ) {
|
||||
this.$nextPageButton.show();
|
||||
}
|
||||
this.$prevPageButton.hide();
|
||||
|
||||
},
|
||||
|
||||
incrementPageView: function() {
|
||||
@ -126,6 +138,10 @@ define(['jquery',
|
||||
this.showCurContentPage(true);
|
||||
}
|
||||
|
||||
if (this.currentPage > 0) {
|
||||
this.$prevPageButton.show();
|
||||
}
|
||||
|
||||
if (this.currentPage >= this.numPages -1) {
|
||||
this.$nextPageButton.hide();
|
||||
this.$prevPageButton.show()
|
||||
@ -138,6 +154,10 @@ define(['jquery',
|
||||
this.showCurContentPage(false);
|
||||
}
|
||||
|
||||
if (this.currentPage < this.numPages -1) {
|
||||
this.$nextPageButton.show();
|
||||
}
|
||||
|
||||
if (this.currentPage == 0) {
|
||||
this.$prevPageButton.hide();
|
||||
this.$nextPageButton.show();
|
||||
|
Loading…
x
Reference in New Issue
Block a user