|
@@ -1,5 +1,7 @@
|
1
|
1
|
<?php
|
2
|
2
|
|
|
3
|
+use Illuminate\Support\Facades\Log;
|
|
4
|
+
|
3
|
5
|
class
|
4
|
6
|
CoursesController extends \BaseController
|
5
|
7
|
{
|
|
@@ -50,6 +52,176 @@ CoursesController extends \BaseController
|
50
|
52
|
return View::make('local.professors.course', compact('title', 'course', 'activities', 'students', 'outcomes', 'outcomes_achieved', 'outcomes_attempted', 'active_semesters'));
|
51
|
53
|
}
|
52
|
54
|
|
|
55
|
+ public function editView()
|
|
56
|
+ {
|
|
57
|
+ $title = 'Create/Edit Course';
|
|
58
|
+ switch (Auth::user()->role) {
|
|
59
|
+ case 1:
|
|
60
|
+
|
|
61
|
+ $programs = Program::with('school')->orderBy('name', 'asc')->get();
|
|
62
|
+ $professors = User::select(array('id', 'first_name', 'surnames'))->orderBy('surnames', 'asc')->orderBy('first_name', 'asc')->get();
|
|
63
|
+ break;
|
|
64
|
+ case 2:
|
|
65
|
+ $programs = Program::where("school_id", Auth::user()->school->id);
|
|
66
|
+ $professors = User::fromSchool(Auth::user()->school->id)->select(array('id', 'first_name', 'surnames'))->orderBy('surnames', 'asc')->orderBy('first_name', 'asc')->get();
|
|
67
|
+ break;
|
|
68
|
+ case 3:
|
|
69
|
+ $programs = Auth::user()->programs;
|
|
70
|
+ $program_ids = Program::join('program_user', 'program_user.program_id', '=', 'programs.id')
|
|
71
|
+ ->where('program_user.user_id', Auth::user()->id)
|
|
72
|
+ ->lists('programs.id');
|
|
73
|
+
|
|
74
|
+ $professors = User::fromPrograms($program_ids)->select(array('id', 'first_name', 'surnames'))->orderBy('surnames', 'asc')->orderBy('first_name', 'asc')->get();
|
|
75
|
+ break;
|
|
76
|
+ }
|
|
77
|
+ //$users = User::select(array('id', 'first_name', 'surnames'))->orderBy('surnames', 'asc')->orderBy('first_name', 'asc')->get();
|
|
78
|
+ $semesters = Semester::where('is_visible', '1')->orderBy('start', 'desc')->get();
|
|
79
|
+ $modalities = DB::table("courses")
|
|
80
|
+ ->groupBy("modality")
|
|
81
|
+ ->lists("modality");
|
|
82
|
+
|
|
83
|
+ return View::make('local.managers.shared.course_edit', compact('title', 'programs', 'professors', 'modalities', 'semesters'));
|
|
84
|
+ }
|
|
85
|
+
|
|
86
|
+ public function create()
|
|
87
|
+ {
|
|
88
|
+
|
|
89
|
+ $all_input = Input::all();
|
|
90
|
+ $name = $all_input['name'];
|
|
91
|
+ $code = $all_input['code'];
|
|
92
|
+ $number = $all_input['number'];
|
|
93
|
+ $section = $all_input['section'];
|
|
94
|
+ $program = $all_input['program'];
|
|
95
|
+ $professor_id = $all_input['professor_id'];
|
|
96
|
+ $semester_id = $all_input['semester_id'];
|
|
97
|
+ //Input::file('students')//->move('course_student/', 'test.txt');
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+ Log::info($all_input);
|
|
102
|
+
|
|
103
|
+ /** Instantiate new Objective */
|
|
104
|
+ $course = new Course;
|
|
105
|
+ $course->name = $name;
|
|
106
|
+ $course->code = $code;
|
|
107
|
+ $course->number = $number;
|
|
108
|
+ $course->section = $section;
|
|
109
|
+ $course->program_id = $program;
|
|
110
|
+ $course->user_id = $professor_id;
|
|
111
|
+ $course->semester_id = $semester_id;
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+ /** If Objective is saved, send success message */
|
|
120
|
+ if ($course->save()) {
|
|
121
|
+
|
|
122
|
+ //$students->move('./course_student', 'test.txt');
|
|
123
|
+ $student_nums = file(Input::file('students'));
|
|
124
|
+
|
|
125
|
+ if ($student_nums) {
|
|
126
|
+ foreach ($student_nums as $stu_num) {
|
|
127
|
+ Log::info($stu_num);
|
|
128
|
+ Log::info("Stunum");
|
|
129
|
+ $student_id = DB::select("select id from students where number = " . $stu_num);
|
|
130
|
+ /*DB::table("students")
|
|
131
|
+ ->where('number', '=', $stu_num)
|
|
132
|
+ ->first();
|
|
133
|
+ */
|
|
134
|
+ if ($student_id) {
|
|
135
|
+ $student_id = $student_id[0]->id;
|
|
136
|
+ DB::table("course_student")
|
|
137
|
+ ->insert(array(
|
|
138
|
+ 'course_id' => $course->id,
|
|
139
|
+ 'student_id' => $student_id,
|
|
140
|
+ 'semester_id' => $course->semester_id
|
|
141
|
+ ));
|
|
142
|
+ } else {
|
|
143
|
+ $course->forceDelete();
|
|
144
|
+ Session::flash('status', 'danger');
|
|
145
|
+ Session::flash('message', '<p>Error Enrolling students. Please try again later.</p>');
|
|
146
|
+ return Redirect::to('editCourses')->withInput();
|
|
147
|
+ }
|
|
148
|
+ }
|
|
149
|
+
|
|
150
|
+ Session::flash('status', 'success');
|
|
151
|
+ Session::flash('message', 'Course created: "' . $course->name . '".');
|
|
152
|
+ return Redirect::to('editCourses');
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+ //fclose($student_nums);
|
|
157
|
+ } else {
|
|
158
|
+ $course->forceDelete();
|
|
159
|
+ Session::flash('status', 'danger');
|
|
160
|
+ Session::flash('message', '<p>Error creating course. Please try again later.</p>');
|
|
161
|
+ return Redirect::to('editCourses')->withInput();
|
|
162
|
+ }
|
|
163
|
+ /*$objectiveId = $objective->id;
|
|
164
|
+
|
|
165
|
+ Log::info($clean_input['outcome_id']);
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+ foreach ($clean_input['program_id'] as $program_id) {
|
|
171
|
+ DB::insert("insert into objective_program (objective_id, program_id) values({$objectiveId},{$program_id})");
|
|
172
|
+ }
|
|
173
|
+ foreach ($clean_input['outcome_id'] as $outcome_id) {
|
|
174
|
+ DB::insert("insert into `objective_outcome` (objective_id, outcome_id) values ({$objectiveId}, {$outcome_id})");
|
|
175
|
+ //DB::raw("insert ignore into `objective_outcome` (objective_id, outcome_id) values ({$objectiveId}, {$outcome_id})");
|
|
176
|
+ /*if (!($objectiveOutcome->save())) {
|
|
177
|
+ Session::flash('status', 'danger');
|
|
178
|
+ Session::flash('message', '<p>Error creating objective. Please try again later.</p>');
|
|
179
|
+ return Redirect::to('objective')->withInput();
|
|
180
|
+ }
|
|
181
|
+ }
|
|
182
|
+ DB::table('criterion_objective_outcome')
|
|
183
|
+ ->join('program_criterion', 'criterion_objective_outcome.criterion_id', "=", 'program_criterion.criterion_id')
|
|
184
|
+ ->whereIn('program_id', $clean_input['program_id'])
|
|
185
|
+ ->whereIn('outcome_id', $clean_input['outcome_id'])
|
|
186
|
+ ->where('objective_id', '=', 0)
|
|
187
|
+ ->update(array('objective_id' => $objectiveId));
|
|
188
|
+ // update("update criterion_objective_outcome coo join program_criterion pc on coo.criterion_id=pc.criterion_id set
|
|
189
|
+ // objective_id= {$objectiveId} where program_id in (".$clean_input['program_id'].") and objective_id=0 and outcome_id in (".$clean_input['outcome_id'].")");
|
|
190
|
+ */
|
|
191
|
+
|
|
192
|
+ /*$role = Auth::user()['role'];
|
|
193
|
+ switch ($role) {
|
|
194
|
+ case 1:
|
|
195
|
+ return Redirect::to('objective')->withInput(Input::only('outcome_id'));
|
|
196
|
+
|
|
197
|
+ case 2:
|
|
198
|
+ return Redirect::to('school-objective')->withInput(Input::only('outcome_id'));
|
|
199
|
+
|
|
200
|
+ case 3:
|
|
201
|
+ return Redirect::to('program-objective')->withInput(Input::only('outcome_id'));
|
|
202
|
+ }*/
|
|
203
|
+ }
|
|
204
|
+
|
|
205
|
+ /** If saving fails, send error message and old data */
|
|
206
|
+ else {
|
|
207
|
+ Session::flash('status', 'danger');
|
|
208
|
+ Session::flash('message', '<p>Error creating course. Please try again later.</p>');
|
|
209
|
+ return Redirect::to('editCourse')->withInput();
|
|
210
|
+ /*$role = Auth::user()['role'];
|
|
211
|
+ switch ($role) {
|
|
212
|
+ case 1:
|
|
213
|
+ return Redirect::to('objective')->withInput();
|
|
214
|
+
|
|
215
|
+ case 2:
|
|
216
|
+ return Redirect::to('school-objective')->withInput();
|
|
217
|
+
|
|
218
|
+ case 3:
|
|
219
|
+ return Redirect::to('program-objective')->withInput();
|
|
220
|
+ }*/
|
|
221
|
+ }
|
|
222
|
+ }
|
|
223
|
+
|
|
224
|
+
|
53
|
225
|
public function newShow($id)
|
54
|
226
|
{
|
55
|
227
|
$course = Course::findOrFail($id);
|
|
@@ -231,8 +403,8 @@ CoursesController extends \BaseController
|
231
|
403
|
->where('semester_id', $semester->id)
|
232
|
404
|
->groupBy(array('code', 'number'))->get();
|
233
|
405
|
|
234
|
|
-// Log::info($grouped_courses[0]->id);
|
235
|
|
-// exit();
|
|
406
|
+ // Log::info($grouped_courses[0]->id);
|
|
407
|
+ // exit();
|
236
|
408
|
$level = DB::table('courses')
|
237
|
409
|
->join('programs', 'programs.id', '=', 'courses.program_id')
|
238
|
410
|
->where('courses.id', $grouped_courses[0]->id)
|
|
@@ -242,7 +414,7 @@ CoursesController extends \BaseController
|
242
|
414
|
$outcomes = Outcome::active_by_semesters(array($semester), $level->is_graduate);
|
243
|
415
|
|
244
|
416
|
|
245
|
|
-// $outcomes = Outcome::orderBy('name', 'asc')->get();
|
|
417
|
+ // $outcomes = Outcome::orderBy('name', 'asc')->get();
|
246
|
418
|
$outcomeCount = Outcome::all()->count();
|
247
|
419
|
|
248
|
420
|
foreach ($grouped_courses as $index => $grouped_course) {
|
|
@@ -258,30 +430,30 @@ CoursesController extends \BaseController
|
258
|
430
|
|
259
|
431
|
// For each of the sections, add the attempted and achieved criteria per outcome
|
260
|
432
|
foreach ($sections as &$section) {
|
261
|
|
- if ($section->outcomes_ach()) {
|
262
|
|
- $section->outcomes_attempted=true;
|
263
|
|
- $course_outcomes_achieved = $section->outcomes_ach();
|
264
|
|
- $course_outcomes_attempted = $section->outcomes_att();
|
265
|
|
- foreach ($course_outcomes_achieved as $outcome => $score) {
|
266
|
|
- if (array_key_exists($outcome, $outcomes_achieved))
|
267
|
|
- $outcomes_achieved[$outcome] += $score;
|
268
|
|
- else $outcomes_achieved[$outcome] = $score;
|
269
|
|
- }
|
270
|
|
- foreach ($course_outcomes_attempted as $outcome => $score) {
|
271
|
|
- if (array_key_exists($outcome, $outcomes_attempted))
|
272
|
|
- $outcomes_attempted[$outcome] += $score;
|
273
|
|
- else $outcomes_attempted[$outcome] = $score;
|
274
|
|
- }
|
275
|
|
- }
|
276
|
|
-
|
277
|
|
-// if ($section->outcomes_achieved != NULL) {
|
278
|
|
-// $section_outcomes_achieved = json_decode($section->outcomes_achieved, true);
|
279
|
|
-// $section_outcomes_attempted = json_decode($section->outcomes_attempted, true);
|
280
|
|
-// for ($i = 1; $i <= count($outcomes_attempted); $i++) {
|
281
|
|
-// $outcomes_achieved[$i] += $section_outcomes_achieved[$i];
|
282
|
|
-// $outcomes_attempted[$i] += $section_outcomes_attempted[$i];
|
283
|
|
-// }
|
284
|
|
-// }
|
|
433
|
+ if ($section->outcomes_ach()) {
|
|
434
|
+ $section->outcomes_attempted = true;
|
|
435
|
+ $course_outcomes_achieved = $section->outcomes_ach();
|
|
436
|
+ $course_outcomes_attempted = $section->outcomes_att();
|
|
437
|
+ foreach ($course_outcomes_achieved as $outcome => $score) {
|
|
438
|
+ if (array_key_exists($outcome, $outcomes_achieved))
|
|
439
|
+ $outcomes_achieved[$outcome] += $score;
|
|
440
|
+ else $outcomes_achieved[$outcome] = $score;
|
|
441
|
+ }
|
|
442
|
+ foreach ($course_outcomes_attempted as $outcome => $score) {
|
|
443
|
+ if (array_key_exists($outcome, $outcomes_attempted))
|
|
444
|
+ $outcomes_attempted[$outcome] += $score;
|
|
445
|
+ else $outcomes_attempted[$outcome] = $score;
|
|
446
|
+ }
|
|
447
|
+ }
|
|
448
|
+
|
|
449
|
+ // if ($section->outcomes_achieved != NULL) {
|
|
450
|
+ // $section_outcomes_achieved = json_decode($section->outcomes_achieved, true);
|
|
451
|
+ // $section_outcomes_attempted = json_decode($section->outcomes_attempted, true);
|
|
452
|
+ // for ($i = 1; $i <= count($outcomes_attempted); $i++) {
|
|
453
|
+ // $outcomes_achieved[$i] += $section_outcomes_achieved[$i];
|
|
454
|
+ // $outcomes_attempted[$i] += $section_outcomes_attempted[$i];
|
|
455
|
+ // }
|
|
456
|
+ // }
|
285
|
457
|
}
|
286
|
458
|
}
|
287
|
459
|
|
|
@@ -291,7 +463,7 @@ CoursesController extends \BaseController
|
291
|
463
|
->lists('id');
|
292
|
464
|
|
293
|
465
|
// Activities with transforming actions
|
294
|
|
-// $activities = Activity::with('course')->whereNotNull('transforming_actions')->whereIn('course_id', $section_ids)->orderBy('name')->groupBy('transforming_actions')->get();
|
|
466
|
+ // $activities = Activity::with('course')->whereNotNull('transforming_actions')->whereIn('course_id', $section_ids)->orderBy('name')->groupBy('transforming_actions')->get();
|
295
|
467
|
$activities = Activity::with('course')->whereIn('course_id', $section_ids)->orderBy('name')->get();
|
296
|
468
|
|
297
|
469
|
return View::make('local.managers.shared.print_course', compact('role', 'title', 'grouped_courses', 'outcomes', 'outcomes_attempted', 'outcomes_achieved', 'sections', 'activities'));
|
|
@@ -334,14 +506,14 @@ CoursesController extends \BaseController
|
334
|
506
|
fputcsv($file, array($activity_name));
|
335
|
507
|
|
336
|
508
|
// Get assessments
|
337
|
|
-// $assessments = DB::table('assessments')
|
338
|
|
-// ->join('students', 'assessments.student_id', '=', 'students.id')
|
339
|
|
-// ->where('activity_id', '=', $activity->id)->orderBy('assessments.id', 'asc')->get();
|
|
509
|
+ // $assessments = DB::table('assessments')
|
|
510
|
+ // ->join('students', 'assessments.student_id', '=', 'students.id')
|
|
511
|
+ // ->where('activity_id', '=', $activity->id)->orderBy('assessments.id', 'asc')->get();
|
340
|
512
|
|
341
|
513
|
$assessments = DB::table('assessments')
|
342
|
|
- ->join('students', 'assessments.student_id', '=', 'students.id')
|
343
|
|
- ->join('activity_criterion', 'assessments.activity_criterion_id', '=', 'activity_criterion.id')
|
344
|
|
- ->where('activity_criterion.activity_id', '=', $activity->id)->orderBy('assessments.id', 'asc')->get();
|
|
514
|
+ ->join('students', 'assessments.student_id', '=', 'students.id')
|
|
515
|
+ ->join('activity_criterion', 'assessments.activity_criterion_id', '=', 'activity_criterion.id')
|
|
516
|
+ ->where('activity_criterion.activity_id', '=', $activity->id)->orderBy('assessments.id', 'asc')->get();
|
345
|
517
|
|
346
|
518
|
// Get rubric contents
|
347
|
519
|
$rubric_contents = json_decode($activity->rubric->contents);
|
|
@@ -542,4 +714,4 @@ CoursesController extends \BaseController
|
542
|
714
|
} else {
|
543
|
715
|
}
|
544
|
716
|
}
|
545
|
|
-}
|
|
717
|
+}
|