Merging from 'injection-updates' into local develop branch

This commit is contained in:
Jason White 2017-07-03 15:22:02 -04:00
commit fb65534355
9 changed files with 75 additions and 65 deletions

View File

@ -973,15 +973,8 @@ cookie-container {
padding-top:2px;
}
.attack-link.solved-true {
color:#88FB88;
}
.attack-link.solved-false {
color:#f2baba;
}
.attack-link.cur-page, .page-link.cur-page {
background-color:#ac2925;
color:#fff;
}
@ -989,6 +982,17 @@ cookie-container {
color:#eee;
}
.attack-link.solved-true {
/*color:#88FB88;*/
background-color:#247506;
color:#fff;
}
.attack-link.cur-page, .page-link.cur-page {
color:#fff;
font-weight:bold;
}
.page-link-wrapper {
display:inline-block;
}

View File

@ -18,17 +18,13 @@ define(['jquery',
'goatApp/view/TitleView',
'goatApp/model/LessonProgressModel',
'goatApp/view/LessonProgressView',
'goatApp/view/LessonOverviewView',
'goatApp/model/LessonOverviewModel'
'goatApp/view/LessonOverviewView'
],
function($,
_,
Backbone,
LessonContentModel,
LessonContentView,
// PlanView,
// SourceView,
// SolutionView,
HintView,
HelpControlsView,
ParamView,
@ -41,8 +37,7 @@ define(['jquery',
TitleView,
LessonProgressModel,
LessonProgressView,
LessonOverviewView,
LessonOverviewModel
LessonOverviewView
) {
'use strict'
@ -50,8 +45,6 @@ define(['jquery',
this.lessonContent = new LessonContentModel();
this.lessonProgressModel = new LessonProgressModel();
this.lessonProgressView = new LessonProgressView(this.lessonProgressModel);
this.lessonOverviewModel = new LessonOverviewModel();
this.lessonOverview = new LessonOverviewView(this.lessonOverviewModel);
this.lessonContentView = options.lessonContentView;
this.titleView = options.titleView;
this.developerControlsView = new DeveloperControlsView();
@ -63,7 +56,6 @@ define(['jquery',
this.userAndInfoView = new UserAndInfoView();
this.menuButtonView = new MenuButtonView();
this.listenTo(this.lessonContentView, 'assignment:complete', this.updateMenu);
this.listenTo(this.lessonContentView, 'assignment:complete', this.updateLessonOverview);
this.listenTo(this.lessonContentView, 'endpoints:filtered', this.filterPageHints);
};
@ -111,13 +103,11 @@ define(['jquery',
});
this.listenTo(this.helpControlsView,'hints:show',this.showHints);
this.listenTo(this.helpControlsView,'lessonOverview:show',this.showLessonOverview)
this.listenTo(this.helpControlsView,'lesson:restart',this.restartLesson);
this.listenTo(this.developerControlsView, 'dev:labels', this.restartLesson);
this.helpControlsView.render();
this.lessonOverview.hideLessonOverview();
this.titleView.render(this.lessonInfoModel.get('lessonTitle'));
};
@ -125,10 +115,6 @@ define(['jquery',
this.trigger('menu:reload')
};
this.updateLessonOverview = function() {
this.lessonOverviewModel.fetch();
}
this.onContentLoaded = function(loadHelps) {
this.lessonInfoModel = new LessonInfoModel();
this.listenTo(this.lessonInfoModel,'info:loaded',this.onInfoLoaded);
@ -198,10 +184,6 @@ define(['jquery',
this.lessonHintView.render();
};
this.showLessonOverview = function() {
this.lessonOverviewModel.fetch().then(this.lessonOverview.render());
};
this.restartLesson = function() {
var self=this;
$.ajax({
@ -210,6 +192,7 @@ define(['jquery',
}).done(function(lessonLink) {
self.loadLesson(self.name);
self.updateMenu();
self.callPaginationUpdate();
});
};
@ -218,9 +201,14 @@ define(['jquery',
this.lessonContentView.showTestParam(param);
};
this.callPaginationUpdate = function () {
this.lessonContentView.updatePagination();
}
};
return Controller;
});

View File

@ -0,0 +1,6 @@
define([
'backbone'],
function(
Backbone) {
return Backbone.Model.extend({});
});

View File

@ -0,0 +1,14 @@
define([
'backbone',
'goatApp/model/AssignmentStatusModel'
],
function(
Backbone,
AssignmentStatusModel) {
return Backbone.Collection.extend({
//tagName: 'ul',
url: 'service/lessonoverview.mvc',
model: AssignmentStatusModel
});
});

View File

@ -1,10 +0,0 @@
define([
'backbone'],
function(
Backbone) {
return Backbone.Collection.extend({
//tagName: 'ul',
url: 'service/lessonoverview.mvc'
});
});

View File

@ -34,7 +34,6 @@ function($,_,Backbone) {
this.$el.find('#show-solution-button').unbind().on('click',_.bind(this.showSolution,this)).show();
}
//this.$el.find('#show-lesson-overview-button').unbind().on('click', _.bind(this.showLessonOverview, this)).show();
this.$el.find('#restart-lesson-button').unbind().on('click',_.bind(this.restartLesson,this)).show();
},
@ -52,9 +51,6 @@ function($,_,Backbone) {
restartLesson: function() {
this.trigger('lesson:restart');
},
showLessonOverview: function() {
this.trigger('lessonOverview:show');
}
});
});

View File

@ -60,6 +60,10 @@ define(['jquery',
this.paginationControlView = new PaginationControlView(this.$contentPages,this.model.get('lessonUrl'));
},
updatePagination: function() {
this.paginationControlView.updateCollection();
},
getCurrentPage: function () {
return this.currentPage;
},
@ -120,6 +124,7 @@ define(['jquery',
markAssignmentComplete: function () {
this.curForm.reset();
$(this.curForm).siblings('.assignment-success').find('i').removeClass('hidden');
this.paginationControlView.updateCollection();
},
markAssignmentIncomplete: function () {

View File

@ -1,19 +1,19 @@
define(['jquery',
'underscore',
'backbone',
'goatApp/model/LessonOverviewModel',
'goatApp/model/LessonOverviewCollection',
'text!templates/lesson_overview.html'],
function($,
_,
Backbone,
LessonOverviewModel,
LessonOverviewCollection,
LessonOverviewTemplate) {
return Backbone.View.extend({
template: LessonOverviewTemplate,
el:'#lesson-overview',
initialize: function (lessonOverviewModel) {
this.model = lessonOverviewModel;
this.listenTo(this.model, 'change add remove update reset', this.render);
initialize: function (lessonOverviewCollection) {
this.collection = lessonOverviewModel;
this.listenTo(this.collection, 'change add remove update reset', this.render);
this.hideLessonOverview();
},

View File

@ -1,12 +1,12 @@
define(['jquery',
'underscore',
'backbone',
'goatApp/model/LessonOverviewModel',
'goatApp/model/LessonOverviewCollection',
'text!templates/paging_controls.html'],
function ($,
_,
Backbone,
LessonOverviewModel,
LessonOverviewCollection,
PaginationTemplate) {
return Backbone.View.extend({
template: PaginationTemplate,
@ -14,17 +14,16 @@ define(['jquery',
initialize: function ($contentPages,baseLessonUrl) {
this.$contentPages = $contentPages;
this.model = new LessonOverviewModel();
this.listenTo(this.model, 'change add remove update reset', this.render);
this.collection = new LessonOverviewCollection();
this.listenTo(this.collection, 'reset', this.render);
this.numPages = this.$contentPages.length;
this.baseUrl = baseLessonUrl;
this.model.fetch();
this.collection.fetch({reset:true});
this.initPagination();
this.render();
//this.render();
},
render: function () {
render: function (e) {
this.parseLinks();
var t = _.template(this.template);
this.$el.html(t({'overview':this.lessonOverview}));
@ -32,6 +31,10 @@ define(['jquery',
this.hideShowNavButtons();
},
updateCollection: function() {
this.collection.fetch({reset:true});
},
bindNavButtons: function() {
this.$el.find('span.glyphicon-class.glyphicon.glyphicon-circle-arrow-right.show-next-page').unbind().on('click',this.incrementPageView.bind(this));
this.$el.find('span.glyphicon-class.glyphicon.glyphicon-circle-arrow-left.show-prev-page').unbind().on('click', this.decrementPageView.bind(this));
@ -42,17 +45,20 @@ define(['jquery',
var assignmentCount = this.$contentPages.find('.attack-container');
var solvedMap = {};
var pages = [];
// one pass on solved assignmets
_.each(this.model.toJSON(), function(assignment) {
if (assignment.solved) {
var key = assignment.assignment.path; //.replace(/\//g,'');
solvedMap[key] = assignment.assignment.name;
_.each(this.collection.models, function(model) {
//alert (model.get('solved'));
if (model.get('solved')) {
var key = model.get('assignment').path.replace(/\//g,'');
solvedMap[key] = model.get('assignment').name;
}
});
isAttackSolved = function (path) {
//strip
var newPath = path.replace(/^\/WebGoat/,'');
var newPath = newPath.replace(/\//g,'');
if (typeof solvedMap[newPath] !== 'undefined') {
return true;
}
@ -68,7 +74,7 @@ define(['jquery',
pageClass = 'page-link';
pages.push({content:'content',pageClass:pageClass,curPageClass:curPageClass});
} else {
var $assignmentForms = $(page).find('.attack-container form');
var $assignmentForms = $(page).find('.attack-container form.attack-form');
// use for loop to avoid anonymous function scope hell
//var pageAssignments = {content:'attack',attacks:[]}
pageClass = 'attack-link'
@ -87,6 +93,7 @@ define(['jquery',
pages.push({solvedClass:solvedClass,content:'assignment',curPageClass:curPageClass,pageClass:pageClass});
}
});
//assign to the view
this.lessonOverview = {
baseUrl: this.baseUrl,
@ -134,7 +141,7 @@ define(['jquery',
this.hideNextPageButton();
this.showPrevPageButton;
}
this.render();
this.collection.fetch({reset:true});
},
decrementPageView: function() {
@ -151,7 +158,7 @@ define(['jquery',
this.hidePrevPageButton();
this.showNextPageButton()
}
this.render();
this.collection.fetch({reset:true});
},
hideShowNavButtons: function () {