6
6
/** Menu Controller
7
7
* prepares and updates menu topic items for the view
8
8
*/
9
- goat . controller ( 'goatLesson' , function ( $scope , $http , $modal , $log ) {
9
+ goat . controller ( 'goatLesson' , function ( $scope , $http , $modal , $log , $templateCache ) {
10
10
//TODO: implement via separate promise and use config for menu (goat.data.loadMenuData())
11
11
$http ( { method : 'GET' , url : goatConstants . lessonService } ) . then (
12
12
function ( menuData ) {
@@ -33,15 +33,6 @@ goat.controller('goatLesson', function($scope, $http, $modal, $log) {
33
33
}
34
34
}
35
35
) ;
36
- /*
37
- console.log("Updating Lesson Source...");
38
- $http.get('service/source.mvc').success(function(data) {
39
- $scope.lessonSource = data.source;
40
- }).error(function(data) {
41
- $scope.lessonSource = data.message;
42
- console.log("LessonSource = '" + data.message + "'");
43
- });
44
- */
45
36
} ;
46
37
//TODO: Move show Source into it's own angular controller
47
38
/*
@@ -56,10 +47,9 @@ goat.controller('goatLesson', function($scope, $http, $modal, $log) {
56
47
} ) . error ( function ( data ) {
57
48
$scope . lessonSource = data . message ;
58
49
console . log ( "LessonSource = '" + data . message + "'" ) ;
59
- $scope . openSourceModal ( size ) ;
60
- } )
61
-
62
- }
50
+ $scope . openSourceModal ( size ) ;
51
+ } ) ;
52
+ } ;
63
53
64
54
$scope . openSourceModal = function ( size ) {
65
55
var modalInstance = $modal . open ( {
@@ -75,7 +65,30 @@ goat.controller('goatLesson', function($scope, $http, $modal, $log) {
75
65
modalInstance . result . then ( function ( ) {
76
66
$log . info ( 'Modal dismissed at: ' + new Date ( ) ) ;
77
67
} ) ;
78
- }
68
+ } ;
69
+
70
+ /*
71
+ * Function to load lesson solution
72
+ * @returns {undefined }
73
+ */
74
+ $scope . showSolution = function ( size ) {
75
+ $scope . lessonSolutionUrl = "service/solution.mvc" ;
76
+ // clear the template cache otherwise we display stale lesson solutions
77
+ $templateCache . remove ( $scope . lessonSolutionUrl ) ;
78
+ var modalInstance = $modal . open ( {
79
+ templateUrl : 'showSolution.html' ,
80
+ controller : showSolutionController ,
81
+ size : size ,
82
+ resolve : {
83
+ lessonSolutionUrl : function ( ) {
84
+ return $scope . lessonSolutionUrl ;
85
+ }
86
+ }
87
+ } ) ;
88
+ modalInstance . result . then ( function ( ) {
89
+ $log . info ( 'Modal dismissed at: ' + new Date ( ) ) ;
90
+ } ) ;
91
+ } ;
79
92
80
93
} ) . animation ( '.slideDown' , function ( ) {
81
94
var NgHideClassName = 'ng-hide' ;
@@ -90,7 +103,7 @@ goat.controller('goatLesson', function($scope, $http, $modal, $log) {
90
103
$ ( element ) . hide ( ) . slideDown ( done ) ;
91
104
}
92
105
}
93
- }
106
+ } ;
94
107
} ) ;
95
108
96
109
@@ -108,5 +121,19 @@ var showSourceController = function($scope, $modalInstance, lessonSource) {
108
121
} ;
109
122
} ;
110
123
124
+ var showSolutionController = function ( $scope , $modalInstance , lessonSolutionUrl ) {
125
+
126
+ $scope . lessonSolutionUrl = lessonSolutionUrl ;
127
+
128
+ $scope . ok = function ( ) {
129
+ $modalInstance . close ( ) ;
130
+ } ;
131
+
132
+ $scope . cancel = function ( ) {
133
+ $modalInstance . dismiss ( 'cancel' ) ;
134
+ } ;
135
+ } ;
136
+
137
+
111
138
112
139
0 commit comments