Reset lesson bug (#741)
* Remove old code from UI * Remove old code * Remove old functions * Remove unnecessary divs * Remove logging to console * Clear lesson messages (checkmark, output text etc) when lesson resets
This commit is contained in:
committed by
René Zubcevic
parent
5de82c0a06
commit
edd6b7d7cf
@ -3,22 +3,13 @@ define(['jquery',
|
||||
'libs/backbone',
|
||||
'goatApp/model/LessonContentModel',
|
||||
'goatApp/view/LessonContentView',
|
||||
// 'goatApp/view/PlanView',
|
||||
// 'goatApp/view/SourceView',
|
||||
// 'goatApp/view/SolutionView',
|
||||
'goatApp/view/HintView',
|
||||
'goatApp/view/HelpControlsView',
|
||||
'goatApp/view/ParamView',
|
||||
'goatApp/model/ParamModel',
|
||||
'goatApp/view/DeveloperControlsView',
|
||||
'goatApp/support/GoatUtils',
|
||||
'goatApp/view/UserAndInfoView',
|
||||
'goatApp/view/MenuButtonView',
|
||||
'goatApp/model/LessonInfoModel',
|
||||
'goatApp/view/TitleView',
|
||||
'goatApp/model/LessonProgressModel',
|
||||
'goatApp/view/LessonProgressView',
|
||||
'goatApp/view/LessonOverviewView'
|
||||
'goatApp/view/TitleView'
|
||||
],
|
||||
function($,
|
||||
_,
|
||||
@ -27,27 +18,18 @@ define(['jquery',
|
||||
LessonContentView,
|
||||
HintView,
|
||||
HelpControlsView,
|
||||
ParamView,
|
||||
ParamModel,
|
||||
DeveloperControlsView,
|
||||
GoatUtils,
|
||||
UserAndInfoView,
|
||||
MenuButtonView,
|
||||
LessonInfoModel,
|
||||
TitleView,
|
||||
LessonProgressModel,
|
||||
LessonProgressView,
|
||||
LessonOverviewView
|
||||
TitleView
|
||||
) {
|
||||
'use strict'
|
||||
|
||||
var Controller = function(options) {
|
||||
this.lessonContent = new LessonContentModel();
|
||||
this.lessonProgressModel = new LessonProgressModel();
|
||||
this.lessonProgressView = new LessonProgressView(this.lessonProgressModel);
|
||||
this.lessonContentView = options.lessonContentView;
|
||||
this.titleView = options.titleView;
|
||||
this.developerControlsView = new DeveloperControlsView();
|
||||
|
||||
_.extend(Controller.prototype,Backbone.Events);
|
||||
|
||||
@ -107,7 +89,6 @@ define(['jquery',
|
||||
this.listenTo(this.helpControlsView,'hints:show',this.showHintsView);
|
||||
|
||||
this.listenTo(this.helpControlsView,'lesson:restart',this.restartLesson);
|
||||
this.listenTo(this.developerControlsView, 'dev:labels', this.restartLesson);
|
||||
|
||||
this.helpControlsView.render();
|
||||
this.showHintsView();
|
||||
@ -129,18 +110,9 @@ define(['jquery',
|
||||
//TODO: consider moving hintView as child of lessonContentView ...
|
||||
this.createLessonHintView();
|
||||
|
||||
//TODO: instantiate model with values (not sure why was not working before)
|
||||
var paramModel = new ParamModel({});
|
||||
paramModel.set('scrParam',this.lessonContent.get('scrParam'));
|
||||
paramModel.set('menuParam',this.lessonContent.get('menuParam'));
|
||||
paramModel.set('stageParam',this.lessonContent.get('stageParam'));
|
||||
paramModel.set('numParam',this.lessonContent.get('numParam'));
|
||||
this.paramView = new ParamView({model:paramModel});
|
||||
|
||||
$('.lesson-help').hide();
|
||||
}
|
||||
//this.trigger('menu:reload');
|
||||
this.lessonProgressModel.completed();
|
||||
};
|
||||
|
||||
this.createLessonHintView = function () {
|
||||
@ -177,6 +149,7 @@ define(['jquery',
|
||||
self.loadLesson(self.name);
|
||||
self.updateMenu();
|
||||
self.callPaginationUpdate();
|
||||
self.lessonContentView.resetLesson();
|
||||
});
|
||||
};
|
||||
|
||||
@ -191,8 +164,5 @@ define(['jquery',
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
return Controller;
|
||||
});
|
||||
|
@ -32,7 +32,6 @@ define([
|
||||
labelStatusLoaded: function(data) {
|
||||
this.enabled = data.enabled;
|
||||
this.label = this.enabled ? this.labels['disable'] : this.labels['enable'];
|
||||
this.trigger('plugins:loaded', this, data);
|
||||
}
|
||||
|
||||
});
|
||||
|
@ -1,17 +0,0 @@
|
||||
define(['jquery',
|
||||
'underscore',
|
||||
'backbone',
|
||||
'goatApp/model/HTMLContentModel'],
|
||||
function($,
|
||||
_,
|
||||
Backbone,
|
||||
HTMLContentModel) {
|
||||
return HTMLContentModel.extend({
|
||||
url:'service/lessonplan.mvc',
|
||||
checkNullModel: function() {
|
||||
if (this.get('content').indexOf('Could not find lesson plan for') > -1) {
|
||||
this.set('content',null);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
@ -1,13 +0,0 @@
|
||||
define(['jquery',
|
||||
'underscore',
|
||||
'backbone'],
|
||||
function ($,
|
||||
_,
|
||||
Backbone) {
|
||||
return Backbone.Model.extend({
|
||||
url: 'service/lessonprogress.mvc',
|
||||
completed: function () {
|
||||
this.fetch();
|
||||
}
|
||||
});
|
||||
});
|
@ -1,12 +0,0 @@
|
||||
define([
|
||||
'backbone'],
|
||||
function(
|
||||
Backbone) {
|
||||
return Backbone.Model.extend({
|
||||
initialize: function(options) {
|
||||
for (var key in options) {
|
||||
this.set(key, options.key);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
@ -1,19 +0,0 @@
|
||||
define([
|
||||
'backbone'],
|
||||
function(
|
||||
Backbone) {
|
||||
return Backbone.Model.extend({
|
||||
url: 'service/reloadplugins.mvc',
|
||||
id: 'reload-plugins',
|
||||
label: 'Reload plugins',
|
||||
|
||||
load: function () {
|
||||
this.fetch().then(this.pluginsLoaded.bind(this));
|
||||
},
|
||||
|
||||
pluginsLoaded: function(data) {
|
||||
this.trigger('plugins:loaded', this, data);
|
||||
}
|
||||
|
||||
});
|
||||
});
|
@ -1,18 +0,0 @@
|
||||
define(['jquery',
|
||||
'underscore',
|
||||
'backbone',
|
||||
'goatApp/model/HTMLContentModel'],
|
||||
function($,
|
||||
_,
|
||||
Backbone,
|
||||
HTMLContentModel) {
|
||||
return HTMLContentModel.extend({
|
||||
url:'service/solution.mvc',
|
||||
checkNullModel: function() {
|
||||
if (this.get('content').indexOf('Could not find the solution file or solution file does not exist') === 0) {
|
||||
this.set('content',null);
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
});
|
@ -1,19 +0,0 @@
|
||||
define(['jquery',
|
||||
'underscore',
|
||||
'backbone',
|
||||
'goatApp/model/HTMLContentModel'],
|
||||
function($,
|
||||
_,
|
||||
Backbone,
|
||||
HTMLContentModel) {
|
||||
return HTMLContentModel.extend({
|
||||
url:'service/source.mvc',
|
||||
checkNullModel: function () {
|
||||
//TODO: move this function into HTMLContentModel and make the string a property of this 'child' model
|
||||
if (this.get('content').indexOf("Could not find the source file or") > -1) {
|
||||
this.set('content',null);
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
});
|
@ -1,77 +0,0 @@
|
||||
define(['jquery',
|
||||
'underscore',
|
||||
'backbone',
|
||||
'goatApp/model/PluginReloadModel',
|
||||
'goatApp/model/LabelDebugModel'],
|
||||
function(
|
||||
$,
|
||||
_,
|
||||
Backbone,
|
||||
PluginReloadModel,
|
||||
LabelDebugModel) {
|
||||
return Backbone.View.extend({
|
||||
el: '#developer-controls',
|
||||
|
||||
onControlClick: function(model) {
|
||||
$('#' + model.id).find('td').text('Loading...');
|
||||
model.load();
|
||||
},
|
||||
|
||||
onPluginsLoaded: function(model) {
|
||||
window.location.href = 'welcome.mvc';
|
||||
},
|
||||
|
||||
onLabelsLoaded: function(model) {
|
||||
this.models[1] = model;
|
||||
this.render();
|
||||
this.trigger('dev:labels')
|
||||
},
|
||||
|
||||
initialize: function(options) {
|
||||
this.addMenuListener();
|
||||
this.models = [new PluginReloadModel(), new LabelDebugModel()];
|
||||
this.listenTo(this.models[0], 'plugins:loaded', this.onPluginsLoaded);
|
||||
this.listenTo(this.models[1], 'plugins:loaded', this.onLabelsLoaded);
|
||||
this.render();
|
||||
},
|
||||
|
||||
addMenuListener: function() {
|
||||
var showHandler = function(e) {
|
||||
e.preventDefault();
|
||||
$('#developer-control-container').show();
|
||||
$(this).text('Hide developer controls').off().on('click', hideHandler);
|
||||
};
|
||||
|
||||
var hideHandler = function(e) {
|
||||
e.preventDefault();
|
||||
$('#developer-control-container').hide();
|
||||
$(this).text('Show developer controls').off().on('click', showHandler);
|
||||
};
|
||||
|
||||
$('a[href="#developer-controls"]').click(showHandler);
|
||||
},
|
||||
|
||||
render: function() {
|
||||
this.$el.html('');
|
||||
var table = $('<table>',{'class':'developer-controls-table table-nonfluid'});
|
||||
var self = this;
|
||||
_.each(this.models, function(model) {
|
||||
var newRow = $('<tr>', { id: model.id });
|
||||
var headerCell = $('<th>')
|
||||
var statusCell = $('<td>')
|
||||
|
||||
var link = $('<a>', {
|
||||
'text': model.label,
|
||||
'title': model.label
|
||||
});
|
||||
link.click(_.bind(self.onControlClick, self, model));
|
||||
|
||||
newRow.append(headerCell.append(link));
|
||||
newRow.append(statusCell);
|
||||
table.append(newRow);
|
||||
});
|
||||
|
||||
this.$el.append(table);
|
||||
}
|
||||
});
|
||||
});
|
@ -7,7 +7,6 @@ define(['jquery',
|
||||
'goatApp/controller/MenuController',
|
||||
'goatApp/view/LessonContentView',
|
||||
'goatApp/view/MenuView',
|
||||
'goatApp/view/DeveloperControlsView',
|
||||
'goatApp/view/TitleView'
|
||||
], function ($,
|
||||
$vuln,
|
||||
@ -18,7 +17,6 @@ define(['jquery',
|
||||
MenuController,
|
||||
LessonContentView,
|
||||
MenuView,
|
||||
DeveloperControlsView,
|
||||
TitleView) {
|
||||
|
||||
function getContentElement() {
|
||||
|
@ -41,14 +41,6 @@ function($,_,Backbone) {
|
||||
this.trigger('hints:show','hint');
|
||||
},
|
||||
|
||||
showSource: function() {
|
||||
this.trigger('source:show','source');
|
||||
},
|
||||
|
||||
showSolution: function() {
|
||||
this.trigger('solution:show','solution');
|
||||
},
|
||||
|
||||
restartLesson: function() {
|
||||
this.trigger('lesson:restart');
|
||||
}
|
||||
|
@ -1,23 +0,0 @@
|
||||
define(['jquery',
|
||||
'underscore',
|
||||
'backbone',
|
||||
'goatApp/model/SourceModel'],
|
||||
function($,
|
||||
_,
|
||||
Backbone,
|
||||
SourceModel) {
|
||||
return Backbone.View.extend({
|
||||
el:'#lessonHelpWrapper .lessonHelp.lessonPlan', //Check this
|
||||
initialize: function() {
|
||||
this.model = new SourceModel();
|
||||
this.listenTo(this.model,'loaded',this.onModelLoaded);
|
||||
this.model.loadData();
|
||||
},
|
||||
render:function(title) {
|
||||
|
||||
},
|
||||
onModelLoaded: function() {
|
||||
this.trigger(this.loadedMessage,this.helpElement);
|
||||
}
|
||||
});
|
||||
});
|
@ -79,7 +79,6 @@ function($,
|
||||
self.hintsToShow.push(hintModel.get('hint'));
|
||||
}
|
||||
});
|
||||
console.log(this.hintsToShow);
|
||||
},
|
||||
|
||||
onModelLoaded: function() {
|
||||
|
@ -186,7 +186,6 @@ define(['jquery',
|
||||
for (var i=0; i<pageForms.length; i++) {
|
||||
endpoints.push(pageForms[i].action);
|
||||
}
|
||||
console.log(endpoints);
|
||||
return endpoints;
|
||||
},
|
||||
|
||||
@ -208,6 +207,12 @@ define(['jquery',
|
||||
/* for testing */
|
||||
showTestParam: function (param) {
|
||||
this.$el.find('.lesson-content').html('test:' + param);
|
||||
},
|
||||
|
||||
resetLesson: function() {
|
||||
this.$el.find('.attack-feedback').hide();
|
||||
this.$el.find('.attack-output').hide();
|
||||
this.markAssignmentIncomplete();
|
||||
}
|
||||
|
||||
});
|
||||
|
@ -1,57 +0,0 @@
|
||||
define(['jquery',
|
||||
'underscore',
|
||||
'backbone',
|
||||
'goatApp/model/LessonOverviewCollection',
|
||||
'text!templates/lesson_overview.html'],
|
||||
function($,
|
||||
_,
|
||||
Backbone,
|
||||
LessonOverviewCollection,
|
||||
LessonOverviewTemplate) {
|
||||
return Backbone.View.extend({
|
||||
template: LessonOverviewTemplate,
|
||||
el:'#lesson-overview',
|
||||
initialize: function (lessonOverviewCollection) {
|
||||
this.collection = lessonOverviewModel;
|
||||
this.listenTo(this.collection, '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('');
|
||||
var t = _.template(this.template);
|
||||
this.$el.html(t({"assignments" : this.model.toJSON()}));
|
||||
},
|
||||
|
||||
render: function() {
|
||||
if (this.isVisible()) {
|
||||
this.$el.hide();
|
||||
} else {
|
||||
this.$el.show();
|
||||
}
|
||||
//this.showAssignments();
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
isVisible: function() {
|
||||
return this.$el.is(':visible');
|
||||
},
|
||||
|
||||
hideLessonOverview: function() {
|
||||
if (this.$el.is(':visible')) {
|
||||
this.$el.hide();
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
@ -1,26 +0,0 @@
|
||||
define(['jquery',
|
||||
'underscore',
|
||||
'backbone',
|
||||
'goatApp/model/LessonProgressModel'],
|
||||
function ($,
|
||||
_,
|
||||
Backbone,
|
||||
LessonProgressModel) {
|
||||
return Backbone.View.extend({
|
||||
el: '#lesson-progress',
|
||||
initialize: function (lessonProgressModel) {
|
||||
this.model = lessonProgressModel;
|
||||
|
||||
if (this.model) {
|
||||
this.listenTo(this.model, 'change', this.render);
|
||||
}
|
||||
},
|
||||
render: function () {
|
||||
if (this.model.get("assignmentCompleted")) {
|
||||
this.$el.html(this.model.get('successMessage'));
|
||||
} else {
|
||||
this.$el.html("");
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
@ -1,14 +0,0 @@
|
||||
define(['jquery',
|
||||
'underscore',
|
||||
'backbone'], function($,_,Backbone) {
|
||||
|
||||
return Backbone.View.extend({
|
||||
initialize: function(options) {
|
||||
options = options || {};
|
||||
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
|
||||
});
|
@ -1,36 +0,0 @@
|
||||
define(['jquery',
|
||||
'underscore',
|
||||
'backbone',
|
||||
'goatApp/model/ParamModel'],
|
||||
function($,
|
||||
_,
|
||||
Backbone,
|
||||
ParamModel) {
|
||||
return Backbone.View.extend({
|
||||
el:'#params-view',
|
||||
|
||||
initialize: function(options) {
|
||||
this.model = options.model;
|
||||
if (options.model) {
|
||||
this.listenTo(this.model,'change',this.render);
|
||||
}
|
||||
this.render();
|
||||
},
|
||||
|
||||
render: function() {
|
||||
this.$el.html('');
|
||||
var paramsTable = $('<table>',{'class':'param-table table-striped table-nonfluid'});
|
||||
var self = this;
|
||||
_.each(this.model.keys(), function(attribute) {
|
||||
var attributeLabel = attribute.replace(/Param/,'');
|
||||
var newRow = $('<tr>');
|
||||
newRow.append($('<th>',{text:_.escape(attributeLabel)}))
|
||||
newRow.append($('<td>',{text:_.escape(self.model.get(attribute))}));
|
||||
paramsTable.append(newRow);
|
||||
});
|
||||
|
||||
this.$el.append($('<h4>',{text:'Parameters'}));
|
||||
this.$el.append(paramsTable);
|
||||
}
|
||||
});
|
||||
});
|
@ -1,25 +0,0 @@
|
||||
define(['jquery',
|
||||
'underscore',
|
||||
'backbone',
|
||||
'goatApp/model/LessonPlanModel'],
|
||||
function($,
|
||||
_,
|
||||
Backbone,
|
||||
LessonPlanModel) {
|
||||
return Backbone.View.extend({
|
||||
el:'#lessonHelpWrapper .lessonHelp.lessonPlan', //Check this
|
||||
initialize: function() {
|
||||
this.model = new LessonPlanModel();
|
||||
this.listenTo(this.model,'loaded',this.onModelLoaded);
|
||||
this.model.loadData();
|
||||
},
|
||||
|
||||
render:function(title) {
|
||||
|
||||
},
|
||||
|
||||
onModelLoaded: function() {
|
||||
this.trigger('plan:loaded',{'helpElement':'plan','value':true});
|
||||
}
|
||||
});
|
||||
});
|
@ -1,22 +0,0 @@
|
||||
define(['jquery',
|
||||
'underscore',
|
||||
'backbone',
|
||||
'goatApp/model/SolutionModel'],
|
||||
//TODO: create a base 'HelpView class'
|
||||
function($,_,Backbone,SolutionModel) {
|
||||
return Backbone.View.extend({
|
||||
el:'#lessonHelpWrapper .lessonHelp.lessonSolution', //Check this
|
||||
initialize: function() {
|
||||
this.model = new SolutionModel();
|
||||
this.listenTo(this.model,'loaded',this.onModelLoaded);
|
||||
this.model.loadData();
|
||||
//TODO: handle error cases
|
||||
},
|
||||
render:function(title) {
|
||||
|
||||
},
|
||||
onModelLoaded: function() {
|
||||
this.trigger('solution:loaded',{'helpElement':'solution','value':true});
|
||||
}
|
||||
});
|
||||
});
|
@ -1,21 +0,0 @@
|
||||
define(['jquery',
|
||||
'underscore',
|
||||
'backbone',
|
||||
'goatApp/model/SourceModel',
|
||||
'goatApp/view/HelpView'],
|
||||
function($,
|
||||
_,
|
||||
Backbone,
|
||||
SourceModel,
|
||||
HelpView) {
|
||||
return HelpView.extend({
|
||||
helpElement:{'helpElement':'source','value':true},
|
||||
loadedMessage:'source:loaded',
|
||||
el:'#lessonHelpWrapper .lessonHelp.lessonPlan', //Check this
|
||||
initialize: function() {
|
||||
this.model = new SourceModel();
|
||||
this.listenTo(this.model,'loaded',this.onModelLoaded);
|
||||
this.model.loadData();
|
||||
}
|
||||
});
|
||||
});
|
Reference in New Issue
Block a user