diff --git a/webgoat-container/src/main/resources/static/js/goatApp/controller/LessonController.js b/webgoat-container/src/main/resources/static/js/goatApp/controller/LessonController.js index 125b3cc15..57d5778c0 100644 --- a/webgoat-container/src/main/resources/static/js/goatApp/controller/LessonController.js +++ b/webgoat-container/src/main/resources/static/js/goatApp/controller/LessonController.js @@ -109,8 +109,7 @@ define(['jquery', this.listenTo(this,'hints:show',this.onShowHints); this.helpControlsView.render(); - this.lessonOverviewModel.fetch(); - + this.lessonOverview.hideLessonOverview(); this.titleView.render(this.lessonInfoModel.get('lessonTitle')); }; @@ -186,11 +185,10 @@ define(['jquery', this.showHints = function() { this.lessonHintView.render(); - //this.lessonHintView. }; this.showLessonOverview = function() { - this.lessonOverview.render(); + this.lessonOverviewModel.fetch().then(this.lessonOverview.render()); }; this.hideShowAttack = function (options) { // will likely expand this to encompass diff --git a/webgoat-container/src/main/resources/static/js/goatApp/model/AssignmentModel.js b/webgoat-container/src/main/resources/static/js/goatApp/model/AssignmentModel.js deleted file mode 100644 index 7d18b6bf4..000000000 --- a/webgoat-container/src/main/resources/static/js/goatApp/model/AssignmentModel.js +++ /dev/null @@ -1,8 +0,0 @@ -define([ - 'backbone'], - function( - Backbone) { - return Backbone.Model.extend({ - }); -}); - diff --git a/webgoat-container/src/main/resources/static/js/goatApp/templates/lesson_overview.html b/webgoat-container/src/main/resources/static/js/goatApp/templates/lesson_overview.html new file mode 100644 index 000000000..dfe289b3d --- /dev/null +++ b/webgoat-container/src/main/resources/static/js/goatApp/templates/lesson_overview.html @@ -0,0 +1,5 @@ +
+ <% _.each(assignments, function(assignment) { %> +
  • ><%= assignment.assignment.name %> (<%= assignment.solved %>)
  • + <% }) %> +
    \ No newline at end of file diff --git a/webgoat-container/src/main/resources/static/js/goatApp/view/AssignmentOverview.js b/webgoat-container/src/main/resources/static/js/goatApp/view/AssignmentOverview.js deleted file mode 100644 index f1f33dc18..000000000 --- a/webgoat-container/src/main/resources/static/js/goatApp/view/AssignmentOverview.js +++ /dev/null @@ -1,24 +0,0 @@ -define([ - 'backbone'], - function( - Backbone) { - return Backbone.View.extend({ - tagName: 'li', - template: _.template($('#assignmentTemplate').html() ), - - events: { - "click a": "clicked" - }, - - clicked: function(e){ - e.preventDefault(); - var id = $(e.currentTarget).data("id"); - Backbone.trigger('assignment:navTo',{'assignment': id}); - }, - - render: function() { - this.$el.html(this.template(this.model.toJSON())); - return this; - } - }); -}); diff --git a/webgoat-container/src/main/resources/static/js/goatApp/view/LessonOverviewView.js b/webgoat-container/src/main/resources/static/js/goatApp/view/LessonOverviewView.js index 58f1c2e80..f17b3e9aa 100644 --- a/webgoat-container/src/main/resources/static/js/goatApp/view/LessonOverviewView.js +++ b/webgoat-container/src/main/resources/static/js/goatApp/view/LessonOverviewView.js @@ -2,26 +2,35 @@ define(['jquery', 'underscore', 'backbone', 'goatApp/model/LessonOverviewModel', - 'goatApp/view/AssignmentOverview'], + 'text!templates/lesson_overview.html'], function($, _, Backbone, LessonOverviewModel, - AssignmentOverview) { + LessonOverviewTemplate) { return Backbone.View.extend({ + template: LessonOverviewTemplate, el:'#lesson-overview', initialize: function (lessonOverviewModel) { this.model = lessonOverviewModel; - this.listenTo(this.model, 'change add remove update', this.render); + this.listenTo(this.model, 'change add remove update reset', this.render); this.hideLessonOverview(); }, + events: { + "click a": "clickedAssignment" + }, + + clickedAssignment: function(e){ + e.preventDefault(); + var id = $(e.currentTarget).data("id"); + Backbone.trigger('assignment:navTo',{'assignment': id}); + }, + showAssignments: function() { this.$el.html(''); - this.model.each(function(assignment) { - var assignmentView = new AssignmentOverview({ model: assignment }); - this.$el.append(assignmentView.render().el); - }, this); + var t = _.template(this.template); + this.$el.html(t({"assignments" : this.model.toJSON()})); }, render: function() { diff --git a/webgoat-container/src/main/resources/templates/main_new.html b/webgoat-container/src/main/resources/templates/main_new.html index 3cd599165..91afb5e30 100644 --- a/webgoat-container/src/main/resources/templates/main_new.html +++ b/webgoat-container/src/main/resources/templates/main_new.html @@ -40,13 +40,6 @@ - -