Browse Source

Added page for all outcomes

parent
commit
4456625cef

+ 55
- 7
app/controllers/OutcomesController.php View File

154
         return View::make('local.managers.admins.learning-outcome', compact('title', 'outcome', 'undergradResults', 'gradResults'));
154
         return View::make('local.managers.admins.learning-outcome', compact('title', 'outcome', 'undergradResults', 'gradResults'));
155
     }
155
     }
156
 
156
 
157
+    // TODO: Clean up and verify relationships are correct
157
     public function newShow($id)
158
     public function newShow($id)
158
     {
159
     {
159
 //        DB::disableQueryLog();
160
 //        DB::disableQueryLog();
160
         $outcome = Outcome::find($id);
161
         $outcome = Outcome::find($id);
161
         $title = $outcome->name;
162
         $title = $outcome->name;
162
-        $courses = Auth::user()->courses()->get();
163
-        $activities = [];
164
-        foreach ($courses as $course) {
165
-            foreach ($course->activities as $activity) {
166
-                $activities[] = $activity;
167
-            }
168
-        }
163
+        $objectives = $outcome->objectives;
164
+        $criteria = $outcome->criteria;
165
+        $programs = $objectives->map(function ($objective) { return $objective->program; })
166
+            ->merge($criteria->map(function ($criteria) { return $criteria->program; }))
167
+            ->filter(function ($program) { return $program->users->contains(Auth::user()); });
168
+        $courses = $programs->reduce(function ($carry, $program) {
169
+            return $carry->merge($program->courses);
170
+        }, new \Illuminate\Database\Eloquent\Collection);
171
+        $activities = $programs->reduce(function ($carry, $course) {
172
+            return $carry->merge(Activity::where('course_id', '=', $course->id)->get());
173
+        }, new \Illuminate\Database\Eloquent\Collection);
174
+
175
+        return View::make('local.managers.admins.new-learning-outcome', compact('title', 'outcome', 'courses', 'activities'));
176
+    }
177
+    public function newShowAll()
178
+    {
179
+//        DB::disableQueryLog();
180
+        $title = 'All Domains';
181
+        $outcome = Outcome::with('objectives', 'criteria')->get();
182
+        $objectives = $outcome->reduce(function ($carry, $outcome) {
183
+            return $carry->merge($outcome->objectives);
184
+        }, new \Illuminate\Database\Eloquent\Collection);
185
+        $criteria = $outcome->reduce(function ($carry, $outcome) {
186
+            return $carry->merge($outcome->criteria);
187
+        }, new \Illuminate\Database\Eloquent\Collection);
188
+        $programs = $objectives->map(function ($objective) { return $objective->program; })
189
+            ->merge($criteria->map(function ($criteria) { return $criteria->program; }))
190
+            ->filter(function ($program) { return $program->users->contains(Auth::user()); });
191
+
192
+        $courses = $programs->reduce(function ($carry, $program) {
193
+            return $carry->merge($program->courses);
194
+        }, new \Illuminate\Database\Eloquent\Collection);
195
+        $activities = $programs->reduce(function ($carry, $course) {
196
+            return $carry->merge(Activity::where('course_id', '=', $course->id)->get());
197
+        }, new \Illuminate\Database\Eloquent\Collection);
169
 
198
 
199
+        return View::make('local.managers.admins.new-learning-outcome', compact('title', 'outcome', 'courses', 'activities'));
200
+    }
201
+
202
+    public function newReport($id)
203
+    {
204
+        $outcome = Outcome::find($id);
205
+        $objectives = $outcome->objectives;
206
+        $criteria = $outcome->criteria;
207
+        $programs = $objectives->map(function ($objective) { return $objective->program; })
208
+            ->merge($criteria->map(function ($criteria) { return $criteria->program; }))
209
+            ->filter(function ($program) { return $program->users->contains(Auth::user()); });
210
+        $title = $outcome->name;
211
+        $courses = $programs->reduce(function ($carry, $program) {
212
+            return $carry->merge($program->courses);
213
+        }, new \Illuminate\Database\Eloquent\Collection);
214
+        $activities = $programs->reduce(function ($carry, $course) {
215
+            return $carry->merge(Activity::where('course_id', '=', $course->id)->get());
216
+        }, new \Illuminate\Database\Eloquent\Collection);
170
 
217
 
171
         return View::make('local.managers.admins.new-learning-outcome', compact('title', 'outcome', 'courses', 'activities'));
218
         return View::make('local.managers.admins.new-learning-outcome', compact('title', 'outcome', 'courses', 'activities'));
219
+
172
     }
220
     }
173
 
221
 
174
     public function update()
222
     public function update()

+ 2
- 0
app/routes.php View File

353
         Route::post('annual-plans/update', array('before' => 'csrf', 'uses'=>'AnnualPlansController@update'));
353
         Route::post('annual-plans/update', array('before' => 'csrf', 'uses'=>'AnnualPlansController@update'));
354
 
354
 
355
         Route::get('learning-outcomes/show/{id}', 'OutcomesController@show');
355
         Route::get('learning-outcomes/show/{id}', 'OutcomesController@show');
356
+        // TODO: Change route name
356
         Route::get('learning-outcomes/newshow/{id}', 'OutcomesController@newShow');
357
         Route::get('learning-outcomes/newshow/{id}', 'OutcomesController@newShow');
358
+        Route::get('learning-outcomes/newshowall', 'OutcomesController@newShowAll');
357
 
359
 
358
     });
360
     });
359
 
361
 

+ 4
- 1
app/views/local/managers/admins/new-learning-outcome.blade.php View File

13
 @section('main')
13
 @section('main')
14
 
14
 
15
     <div class="row">
15
     <div class="row">
16
-        <div class="col-md-12">
16
+        <div class="col-md-10">
17
             <h3>Courses</h3>
17
             <h3>Courses</h3>
18
         </div>
18
         </div>
19
+        <div class="col-md-2">
20
+            <a href="" class="btn btn-lg btn-default" role="button">Report</a>
21
+        </div>
19
     </div>
22
     </div>
20
     <div class="row">
23
     <div class="row">
21
         @foreach($courses as $course)
24
         @foreach($courses as $course)

+ 6
- 0
app/views/local/managers/admins/new-learning-outcomes.blade.php View File

13
 @section('main')
13
 @section('main')
14
 
14
 
15
     <div class="row">
15
     <div class="row">
16
+        <div class="col-md-6">
17
+            <a href="{{ URL::action('OutcomesController@newShowAll') }}" class="btn btn-lg btn-default">Show all domains</a>
18
+        </div>
19
+    </div>
20
+    <br>
21
+    <div class="row">
16
         <div class="col-md-12">
22
         <div class="col-md-12">
17
             @foreach($outcomes as $outcome)
23
             @foreach($outcomes as $outcome)
18
                 <div class="col-md-3">
24
                 <div class="col-md-3">

+ 2
- 0
readme.md View File

15
 ## Official Documentation
15
 ## Official Documentation
16
 
16
 
17
 Documentation for the entire framework can be found on the [Laravel website](http://laravel.com/docs).
17
 Documentation for the entire framework can be found on the [Laravel website](http://laravel.com/docs).
18
+[API Documentation for Laravel 4.2.](https://devdocs.io/laravel~4.2/)
18
 
19
 
19
 ### Contributing To Laravel
20
 ### Contributing To Laravel
20
 
21
 
23
 ### License
24
 ### License
24
 
25
 
25
 The Laravel framework is open-sourced software licensed under the [MIT license](http://opensource.org/licenses/MIT)
26
 The Laravel framework is open-sourced software licensed under the [MIT license](http://opensource.org/licenses/MIT)
27
+