show lesson solution
This commit is contained in:
parent
5f378a7520
commit
37aed7ffe1
@ -31,10 +31,7 @@
|
||||
package org.owasp.webgoat.service;
|
||||
|
||||
import javax.servlet.http.HttpSession;
|
||||
import static org.owasp.webgoat.LessonSource.END_SOURCE_SKIP;
|
||||
import static org.owasp.webgoat.LessonSource.START_SOURCE_SKIP;
|
||||
import org.owasp.webgoat.lessons.AbstractLesson;
|
||||
import org.owasp.webgoat.lessons.model.SourceListing;
|
||||
import org.owasp.webgoat.session.Course;
|
||||
import org.owasp.webgoat.session.WebSession;
|
||||
import org.springframework.stereotype.Controller;
|
||||
|
@ -76,7 +76,7 @@
|
||||
<button type="button" class="btn btn-primary btn-sm">Hints</button>
|
||||
<button type="button" class="btn btn-primary btn-sm">Lesson Plan</button>
|
||||
<button type="button" class="btn btn-primary btn-sm" ng-click="showSource('lg')">Java [Source]</button>
|
||||
<button type="button" class="btn btn-primary btn-sm">Solution</button>
|
||||
<button type="button" class="btn btn-primary btn-sm" ng-click="showSolution('lg')">Solution</button>
|
||||
</div><!--toggle navigation end-->
|
||||
</header>
|
||||
|
||||
@ -114,20 +114,7 @@
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!--
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<h4>Lesson Source Code</h4>
|
||||
<div class="panel" >
|
||||
<div class="panel-body">
|
||||
<pre>{{lessonSource}}</pre>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
-->
|
||||
</div>
|
||||
</section>
|
||||
</section>
|
||||
|
||||
@ -135,13 +122,7 @@
|
||||
|
||||
</section>
|
||||
|
||||
<!-- <script src="plugins/waypoints/waypoints.min.js"></script> -->
|
||||
<!-- <script src="js/application.js"></script> -->
|
||||
|
||||
<!-- Bootstrap core JavaScript
|
||||
================================================== -->
|
||||
<!-- Placed at the end of the document so the pages load faster -->
|
||||
<!-- <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> -->
|
||||
<!-- TODO pull source into project instead of loading from external -->
|
||||
<script src="http://malsup.github.com/jquery.form.js"></script>
|
||||
<script>
|
||||
//Load global functions
|
||||
@ -231,6 +212,20 @@
|
||||
<button class="btn btn-primary" ng-click="ok()">Close</button>
|
||||
</div>
|
||||
</script>
|
||||
|
||||
<script type="text/ng-template" id="showSolution.html">
|
||||
<div class="modal-header">
|
||||
<button class="btn btn-primary pull-right" ng-click="ok()">Close</button>
|
||||
<h3 class="modal-title">Lesson Solution</h3>
|
||||
|
||||
</div>
|
||||
<div class="modal-body" ng-include="lessonSolutionUrl">
|
||||
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button class="btn btn-primary" ng-click="ok()">Close</button>
|
||||
</div>
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
/** Menu Controller
|
||||
* prepares and updates menu topic items for the view
|
||||
*/
|
||||
goat.controller('goatLesson', function($scope, $http, $modal, $log) {
|
||||
goat.controller('goatLesson', function($scope, $http, $modal, $log, $templateCache) {
|
||||
//TODO: implement via separate promise and use config for menu (goat.data.loadMenuData())
|
||||
$http({method: 'GET', url: goatConstants.lessonService}).then(
|
||||
function(menuData) {
|
||||
@ -33,15 +33,6 @@ goat.controller('goatLesson', function($scope, $http, $modal, $log) {
|
||||
}
|
||||
}
|
||||
);
|
||||
/*
|
||||
console.log("Updating Lesson Source...");
|
||||
$http.get('service/source.mvc').success(function(data) {
|
||||
$scope.lessonSource = data.source;
|
||||
}).error(function(data) {
|
||||
$scope.lessonSource = data.message;
|
||||
console.log("LessonSource = '" + data.message + "'");
|
||||
});
|
||||
*/
|
||||
};
|
||||
//TODO: Move show Source into it's own angular controller
|
||||
/*
|
||||
@ -56,10 +47,9 @@ goat.controller('goatLesson', function($scope, $http, $modal, $log) {
|
||||
}).error(function(data) {
|
||||
$scope.lessonSource = data.message;
|
||||
console.log("LessonSource = '" + data.message + "'");
|
||||
$scope.openSourceModal(size);
|
||||
})
|
||||
|
||||
}
|
||||
$scope.openSourceModal(size);
|
||||
});
|
||||
};
|
||||
|
||||
$scope.openSourceModal = function(size) {
|
||||
var modalInstance = $modal.open({
|
||||
@ -75,7 +65,30 @@ goat.controller('goatLesson', function($scope, $http, $modal, $log) {
|
||||
modalInstance.result.then(function() {
|
||||
$log.info('Modal dismissed at: ' + new Date());
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
/*
|
||||
* Function to load lesson solution
|
||||
* @returns {undefined}
|
||||
*/
|
||||
$scope.showSolution = function(size) {
|
||||
$scope.lessonSolutionUrl = "service/solution.mvc";
|
||||
// clear the template cache otherwise we display stale lesson solutions
|
||||
$templateCache.remove($scope.lessonSolutionUrl);
|
||||
var modalInstance = $modal.open({
|
||||
templateUrl: 'showSolution.html',
|
||||
controller: showSolutionController,
|
||||
size: size,
|
||||
resolve: {
|
||||
lessonSolutionUrl: function() {
|
||||
return $scope.lessonSolutionUrl;
|
||||
}
|
||||
}
|
||||
});
|
||||
modalInstance.result.then(function() {
|
||||
$log.info('Modal dismissed at: ' + new Date());
|
||||
});
|
||||
};
|
||||
|
||||
}).animation('.slideDown', function() {
|
||||
var NgHideClassName = 'ng-hide';
|
||||
@ -90,7 +103,7 @@ goat.controller('goatLesson', function($scope, $http, $modal, $log) {
|
||||
$(element).hide().slideDown(done);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
|
||||
@ -108,5 +121,19 @@ var showSourceController = function($scope, $modalInstance, lessonSource) {
|
||||
};
|
||||
};
|
||||
|
||||
var showSolutionController = function($scope, $modalInstance, lessonSolutionUrl) {
|
||||
|
||||
$scope.lessonSolutionUrl = lessonSolutionUrl;
|
||||
|
||||
$scope.ok = function() {
|
||||
$modalInstance.close();
|
||||
};
|
||||
|
||||
$scope.cancel = function() {
|
||||
$modalInstance.dismiss('cancel');
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user