|
@@ -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()
|