ソースを参照

Added page for all outcomes

コミット
4456625cef

+ 55
- 7
app/controllers/OutcomesController.php ファイルの表示

@@ -154,21 +154,69 @@ class OutcomesController extends \BaseController {
154 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 158
     public function newShow($id)
158 159
     {
159 160
 //        DB::disableQueryLog();
160 161
         $outcome = Outcome::find($id);
161 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 218
         return View::make('local.managers.admins.new-learning-outcome', compact('title', 'outcome', 'courses', 'activities'));
219
+
172 220
     }
173 221
 
174 222
     public function update()

+ 2
- 0
app/routes.php ファイルの表示

@@ -353,7 +353,9 @@ Route::group(array('before' => 'auth|has_access'), function()
353 353
         Route::post('annual-plans/update', array('before' => 'csrf', 'uses'=>'AnnualPlansController@update'));
354 354
 
355 355
         Route::get('learning-outcomes/show/{id}', 'OutcomesController@show');
356
+        // TODO: Change route name
356 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 ファイルの表示

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

+ 6
- 0
app/views/local/managers/admins/new-learning-outcomes.blade.php ファイルの表示

@@ -13,6 +13,12 @@
13 13
 @section('main')
14 14
 
15 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 22
         <div class="col-md-12">
17 23
             @foreach($outcomes as $outcome)
18 24
                 <div class="col-md-3">

+ 2
- 0
readme.md ファイルの表示

@@ -15,6 +15,7 @@ Laravel is accessible, yet powerful, providing powerful tools needed for large,
15 15
 ## Official Documentation
16 16
 
17 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 20
 ### Contributing To Laravel
20 21
 
@@ -23,3 +24,4 @@ Documentation for the entire framework can be found on the [Laravel website](htt
23 24
 ### License
24 25
 
25 26
 The Laravel framework is open-sourced software licensed under the [MIT license](http://opensource.org/licenses/MIT)
27
+