父节点
当前提交
9781a16d7e
共有 38 个文件被更改,包括 1538 次插入1593 次删除
  1. 9
    1
      app/controllers/ActivitiesController.php
  2. 571
    585
      app/controllers/AdministratorsController.php
  3. 5
    5
      app/controllers/AnnualPlansController.php
  4. 37
    33
      app/controllers/CriteriaController.php
  5. 11
    8
      app/controllers/Objective2Controller.php
  6. 32
    32
      app/controllers/OutcomesController.php
  7. 6
    6
      app/controllers/RubricsController.php
  8. 48
    6
      app/controllers/TemplatesController.php
  9. 23
    24
      app/database/old_migrations/2020_04_04_002657_create_new_criteria_table.php
  10. 14
    15
      app/database/old_migrations/2020_04_22_095649_create_new_criterion_rubric_table.php
  11. 14
    15
      app/database/old_migrations/2020_04_22_101110_create_new_rubric_activity_table.php
  12. 4
    5
      app/database/old_migrations/2020_10_04_142756_create_new_assessments_table.php
  13. 5
    7
      app/database/old_migrations/2020_10_05_130252_add_max_score_num_scales_new_criteria_table.php
  14. 2
    2
      app/database/old_migrations/2020_10_29_195413_MakeObjectiveNullable.php
  15. 1
    1
      app/database/old_migrations/2020_10_29_224846_Make_criterion_objective_outcome_changeForeignKey.php
  16. 1
    1
      app/database/old_migrations/2020_12_04_111708_dropDescriptionInCriteria.php
  17. 1
    1
      app/database/old_migrations/2020_12_10_175517_createProgramCriterion2.php
  18. 1
    1
      app/database/old_migrations/2021_03_03_090217_create_annual_plan_objective_table.php
  19. 1
    1
      app/database/old_migrations/2021_05_20_184230_create_rubric_scales.php
  20. 1
    1
      app/database/old_migrations/2021_05_20_212410_create_template_criterion.php
  21. 96
    104
      app/database/seeds/FillNewAssessmentActivityCriterion.php
  22. 62
    73
      app/database/seeds/FillNewCriterionRubric.php
  23. 5
    7
      app/database/unusedMigrations/2020_10_05_130252_add_max_score_num_scales_new_criteria_table.php
  24. 2
    2
      app/database/unusedMigrations/2020_10_08_203557_create_new_criteria_table2.php
  25. 2
    2
      app/database/unusedMigrations/2020_10_08_215013_drop_objective_id_new_criteria.php
  26. 1
    1
      app/database/unusedMigrations/2020_10_09_092810_drop_assessment_criteria.php
  27. 1
    1
      app/database/unusedMigrations/2020_10_09_094503_add_criterion_to_assessment.php
  28. 5
    6
      app/models/Activity.php
  29. 44
    52
      app/models/Course.php
  30. 52
    55
      app/models/Criterion.php
  31. 235
    263
      app/models/Outcome.php
  32. 216
    247
      app/models/Program.php
  33. 13
    16
      app/models/Rubric.php
  34. 3
    3
      app/views/local/managers/admins/criteria.blade.php
  35. 3
    3
      app/views/local/managers/pCoords/criteria.blade.php
  36. 3
    3
      app/views/local/managers/sCoords/criteria.blade.php
  37. 7
    4
      app/views/local/managers/shared/rubrics.blade.php
  38. 1
    1
      app/views/local/professors/rubrics.blade.php

+ 9
- 1
app/controllers/ActivitiesController.php 查看文件

@@ -164,7 +164,15 @@ class ActivitiesController extends \BaseController
164 164
         $students = $course->students;
165 165
 
166 166
         // Get rubric contents
167
-        $rubric = Rubric::find($activity->rubric_id);
167
+        $rubric = Rubric::find($activity->rubric[0]->id);
168
+        Log::info($rubric);
169
+        Log::info($activity);
170
+        $criterion_rubric = DB::table('criteria')
171
+            ->join("criterion_rubric", "criterion_rubric.criterion_id", "=", "criteria.id")
172
+            ->where('criterion_rubric.rubric_id', '=', $rubric->id)->get();
173
+        Log::info($rubric);
174
+        Log::info($criterion_rubric);
175
+
168 176
         $rubric_contents = json_decode($rubric->contents);
169 177
 
170 178
         // Get results

+ 571
- 585
app/controllers/AdministratorsController.php
文件差异内容过多而无法显示
查看文件


+ 5
- 5
app/controllers/AnnualPlansController.php 查看文件

@@ -193,14 +193,14 @@ class AnnualPlansController extends \BaseController
193 193
     //foreach ($typ_info['courses'] as $course) {
194 194
     //  $typ_info['courses_objective'][$course->id] = DB::select("select * from objectives where id in (select objective_id from typ_semester_objectives where typ_semester_course_id in (select id from typ_semester_courses where typ_semester_outcome_id in (select id from typ_semester_outcome where semester_id = {$semester->id} and typ_program_id in (select id from typ_program where program_id ={$program_id}))and course_id ={$course->id}))");
195 195
     //  foreach ($typ_info['courses_objective'][$course->id] as $objective) {
196
-    //    $typ_info['criteria'][$objective->id] = DB::select("select * from new_criteria where id in (select criterion_id from criterion_objective_outcome where outcome_id = ? and objective_id = {$objective->id})", array(Input::get('id')));
196
+    //    $typ_info['criteria'][$objective->id] = DB::select("select * from criteria where id in (select criterion_id from criterion_objective_outcome where outcome_id = ? and objective_id = {$objective->id})", array(Input::get('id')));
197 197
     //  }
198 198
     //}
199 199
     //$typ_info['courses'] = DB::select("select * from courses where id in (select course_id from typ_semester_courses where typ_semester_objective_id in (select id from typ_semester_objectives where typ_semester_outcome_id in (select id from type_semester_outcome where semester_id ={$semester->id} and typ_program_id in (select id from typ_program where program_id ={$program_id} )and outcome_id = ?)))", array(Input::get('id')));
200 200
     //$typ_info['unique_objective'] = DB::select("select * from objectives where id in (select distinct objective_id from typ_semester_objectives where  typ_semester_outcome_id in (select id from typ_semester_outcome where semester_id = {$semester->id} and outcome_id =? and typ_program_id in (select id from typ_program where program_id ={$program_id})))", array(Input::get('id')));
201 201
     //foreach ($typ_info['unique_objective'] as $objective) {
202 202
     //  $typ_info['courses_objective'][$objective->id] = DB::select("select * from courses where id in (SELECT course_id from typ_semester_courses where typ_semester_outcome_id in (select id from typ_semester_outcome where semester_id={$semester->id} and outcome_id =? and typ_program_id in (select id from typ_program where program_id = {$program_id})) and id in (select typ_semester_course_id from typ_semester_objectives where objective_id  = {$objective->id}))", array(Input::get('id')));
203
-    //  $typ_info['criteria'][$objective->id] = DB::select("select * from new_criteria where id in (select criterion_id from criterion_objective_outcome where outcome_id = ? and objective_id = {$objective->id})", array(Input::get('id')));
203
+    //  $typ_info['criteria'][$objective->id] = DB::select("select * from criteria where id in (select criterion_id from criterion_objective_outcome where outcome_id = ? and objective_id = {$objective->id})", array(Input::get('id')));
204 204
     //}
205 205
     $annual_plan = DB::select("select id from annual_plans where (semester_start = {$semester->id} or semester_end ={$semester->id}) and program_id ={$program_id}")[0];
206 206
     $typ_info['objectives'] = DB::select("select * from objectives where id in (select objective_id from typ_semester_objectives where typ_semester_outcome_id in(select id from typ_semester_outcome where outcome_id = ? and semester_id = {$semester->id} and typ_program_id in (select id from typ_program where program_id ={$program_id})))", array(Input::get('id')));
@@ -209,7 +209,7 @@ class AnnualPlansController extends \BaseController
209 209
 
210 210
       $typ_info['courses'][$objective->id] = DB::select("select c.id, c.number, c.code, typ.id typ_course_id from courses c, typ_semester_courses typ, (select course_id, id  from typ_semester_courses where typ_semester_objective_id in (select id from typ_semester_objectives where objective_id ={$objective->id} and typ_semester_outcome_id in (select id from typ_semester_outcome where outcome_id =? and semester_id ={$semester->id} and typ_program_id in(select id from typ_program where program_id ={$program_id})))) rel where typ.course_id =c.id and rel.course_id = c.id and typ.id = rel.id ", array(Input::get('id')));
211 211
 
212
-      $typ_info['criteria'][$objective->id] = DB::select("select * from new_criteria where id in (select criterion_id from criterion_objective_outcome where outcome_id = ? and objective_id = {$objective->id})", array(Input::get('id')));
212
+      $typ_info['criteria'][$objective->id] = DB::select("select * from criteria where id in (select criterion_id from criterion_objective_outcome where outcome_id = ? and objective_id = {$objective->id})", array(Input::get('id')));
213 213
       Log::info($typ_info['criteria'][$objective->id]);
214 214
       $typ_info['typ_objective_id'][$objective->id] = DB::select("select id from typ_semester_objectives where objective_id = {$objective->id} and typ_semester_outcome_id in (select id from typ_semester_outcome where outcome_id =? and semester_id ={$semester->id} and typ_program_id in (select id from typ_program where program_id ={$program_id}))", array(Input::get('id')));
215 215
       Log::info($typ_info['typ_objective_id'][$objective->id]);
@@ -332,7 +332,7 @@ class AnnualPlansController extends \BaseController
332 332
         $annual_plan['first']['typ_objective_id'][$objective->id] = DB::select("select id from typ_semester_objectives where objective_id = {$objective->id} and  typ_semester_outcome_id in (select id from typ_semester_outcome where outcome_id ={$outcomes->id} and semester_id ={$an_semesters->semester_start} and typ_program_id in(select id from typ_program where program_id ={$an_semesters->program_id})) ")[0];
333 333
         $annual_plan['first']['courses'][$objective->id] = DB::select("select typ.id typ_id, typ.course_id, c.code, c.number from (select course_id, id from typ_semester_courses where typ_semester_objective_id = {$annual_plan['first']['typ_objective_id'][$objective->id]->id}) typ, courses c where c.id = typ.course_id");
334 334
         foreach ($annual_plan['first']['courses'][$objective->id] as $course) {
335
-          $annual_plan['first']['criteria'][$objective->id][$course->course_id] = DB::select("select * from new_criteria where id in(select criteria_id from annual_plan_objective where annual_plan_id = {$an_id} and typ_semester_course_id = {$course->typ_id} )");
335
+          $annual_plan['first']['criteria'][$objective->id][$course->course_id] = DB::select("select * from criteria where id in(select criteria_id from annual_plan_objective where annual_plan_id = {$an_id} and typ_semester_course_id = {$course->typ_id} )");
336 336
         }
337 337
         Log::info($objective->id);
338 338
         $annual_plan['first']['trans_actions'][$objective->id] = DB::select("select * from transformative_actions where id in (select trans_id from annual_plan_transformative where typ_semester_objective_id ={$annual_plan['first']['typ_objective_id'][$objective->id]->id})");
@@ -355,7 +355,7 @@ class AnnualPlansController extends \BaseController
355 355
 
356 356
         $annual_plan['second']['courses'][$objective->id] = DB::select("select typ.id typ_id, typ.course_id, c.code, c.number from (select course_id, id from typ_semester_courses where typ_semester_objective_id = {$annual_plan['second']['typ_objective_id'][$objective->id]->id}) typ, courses c where c.id = typ.course_id");
357 357
         foreach ($annual_plan['second']['courses'][$objective->id] as $course) {
358
-          $annual_plan['second']['criteria'][$objective->id][$course->course_id] = DB::select("select * from new_criteria where id in(select criteria_id from annual_plan_objective where annual_plan_id = {$an_id} and typ_semester_course_id ={$course->typ_id})");
358
+          $annual_plan['second']['criteria'][$objective->id][$course->course_id] = DB::select("select * from criteria where id in(select criteria_id from annual_plan_objective where annual_plan_id = {$an_id} and typ_semester_course_id ={$course->typ_id})");
359 359
         }
360 360
 
361 361
         $annual_plan['second']['trans_actions'][$objective->id] = DB::select("select * from transformative_actions where id in (select trans_id from annual_plan_transformative where typ_semester_objective_id ={$annual_plan['second']['typ_objective_id'][$objective->id]->id})");

+ 37
- 33
app/controllers/CriteriaController.php 查看文件

@@ -18,7 +18,7 @@ class CriteriaController extends \BaseController
18 18
         $userProgram = DB::select("select program_user.program_id from program_user where user_id = {$userProgram}");
19 19
         Log::info($userProgram);
20 20
         $title = "Criteria";
21
-        $outcomes = Outcome::orderBy('name', 'ASC')->lists('name', 'id');
21
+        $outcomes = Outcome::where("deactivation_date", '=', null)->orderBy('name', 'ASC')->lists('name', 'id');
22 22
 
23 23
         $criteria = Criterion::withTrashed()->orderBy('name', 'ASC')->get();
24 24
         $programs = Program::where("id", "=", $userProgram[0]->program_id)->get();
@@ -30,7 +30,7 @@ class CriteriaController extends \BaseController
30 30
         $userSchool = Auth::user()['school_id'];
31 31
         Log::info($userSchool);
32 32
         $title = "Criteria";
33
-        $outcomes = Outcome::orderBy('name', 'ASC')->lists('name', 'id');
33
+        $outcomes = Outcome::where("deactivation_date", '=', null)->orderBy('name', 'ASC')->lists('name', 'id');
34 34
 
35 35
         $schools = School::find($userSchool)->get();
36 36
         $criteria = Criterion::withTrashed()->orderBy('name', 'ASC')->get();
@@ -53,7 +53,7 @@ class CriteriaController extends \BaseController
53 53
     public function fetchCriterionWithTemplate()
54 54
     {
55 55
         $json_to_send = array();
56
-        $json_to_send['criterion'] = DB::table('new_criteria')->where('id', '=', Input::get('id'))->first();
56
+        $json_to_send['criterion'] = DB::table('criteria')->where('id', '=', Input::get('id'))->first();
57 57
 
58 58
 
59 59
 
@@ -63,7 +63,7 @@ class CriteriaController extends \BaseController
63 63
     public function fetchCriterion()
64 64
     {
65 65
         $json_to_send = array();
66
-        $json_to_send['criterion'] = DB::table('new_criteria')->where('id', '=', Input::get('id'))->first();
66
+        $json_to_send['criterion'] = DB::table('criteria')->where('id', '=', Input::get('id'))->first();
67 67
 
68 68
 
69 69
 
@@ -75,7 +75,7 @@ class CriteriaController extends \BaseController
75 75
         $program_id = Input::get('program_fetch');
76 76
         $outcome_id = Input::get('outcome_fetch');
77 77
         $json = array();
78
-        $json['criterion'] = DB::select("SELECT * FROM `new_criteria` where id in (select criterion_id from criterion_objective_outcome where outcome_id ={$outcome_id}) and id in(select criterion_id from program_criterion where program_id = {$program_id})");
78
+        $json['criterion'] = DB::select("SELECT * FROM `criteria` where id in (select criterion_id from criterion_objective_outcome where outcome_id ={$outcome_id}) and id in(select criterion_id from program_criterion where program_id = {$program_id})");
79 79
 
80 80
         return json_encode($json);
81 81
     }
@@ -96,12 +96,12 @@ class CriteriaController extends \BaseController
96 96
     {
97 97
 
98 98
         $json = array();
99
-        $json['criteria'] = DB::select(" select * from new_criteria where id = ?", array(Input::get('id')));
99
+        $json['criteria'] = DB::select(" select * from criteria where id = ?", array(Input::get('id')));
100 100
         $json['outcomes'] = DB::select("select  DISTINCT outcomes.id, outcomes.name from outcomes , criterion_objective_outcome where criterion_objective_outcome.criterion_id = ? and outcomes.id = criterion_objective_outcome.outcome_id order by outcomes.id", array(Input::get('id')));
101 101
         $json['objectives'] = DB::select("SELECT DISTINCT objectives.id, objectives.text FROM objectives, criterion_objective_outcome where criterion_objective_outcome.criterion_id = ? and criterion_objective_outcome.objective_id= objectives.id ", array(Input::get('id')));
102 102
         $json['objectives_outcome'] = DB::select("select objectives.id, objectives.text, objective_outcome.outcome_id from objective_outcome, objectives where objective_outcome.outcome_id in(select  DISTINCT outcomes.id from outcomes , criterion_objective_outcome where criterion_objective_outcome.criterion_id = ? and outcomes.id = criterion_objective_outcome.outcome_id) and objectives.id = objective_outcome.objective_id ORDER BY outcome_id", array(Input::get('id')));
103 103
         $json['program'] = DB::select("select criterion_id, program_id from program_criterion where criterion_id =?", array(Input::get('id')));
104
-        $json['activity_criterion'] = DB::select("select * from new_assessments where activity_criterion_id  in (select id from activity_criterion where criterion_id = ?)", array(Input::get('id')));
104
+        $json['activity_criterion'] = DB::select("select * from assessments where activity_criterion_id  in (select id from activity_criterion where criterion_id = ?)", array(Input::get('id')));
105 105
 
106 106
         foreach ($json['outcomes'] as $id) {
107 107
             $outId = $id->id;
@@ -114,7 +114,7 @@ class CriteriaController extends \BaseController
114 114
 
115 115
     public function delete()
116 116
     {
117
-        DB::delete("delete from new_criteria where id = ?", array(Input::get('criterion_delete')));
117
+        DB::delete("delete from criteria where id = ?", array(Input::get('criterion_delete')));
118 118
         $role = Auth::user()['role'];
119 119
         switch ($role) {
120 120
             case 1:
@@ -186,13 +186,13 @@ class CriteriaController extends \BaseController
186 186
 
187 187
         $clean_input['copyright'] = trim(preg_replace('/\t+/', '', Input::get('copyright')));
188 188
         $clean_input['notes'] = trim(preg_replace('/\t+/', '', Input::get('notes')));
189
-        $clean_input['maximum_score'] =  (int) Input::get('maximum_score');
190
-        $clean_input['scale_title'] = Input::get('title');
191
-        $clean_input['scale_description'] = Input::get('Scales');
192
-        $clean_input['min_score'] = Input::get('min');
193
-        $clean_input['max_score'] = Input::get('max');
189
+        // $clean_input['maximum_score'] =  (int) Input::get('maximum_score');
190
+        // $clean_input['scale_title'] = Input::get('title');
191
+        //$clean_input['scale_description'] = Input::get('Scales');
192
+        // $clean_input['min_score'] = Input::get('min');
193
+        //$clean_input['max_score'] = Input::get('max');
194 194
 
195
-        $clean_input['number_of_scales'] = sizeof($clean_input['scale_title']);
195
+        // $clean_input['number_of_scales'] = sizeof($clean_input['scale_title']);
196 196
 
197 197
 
198 198
         return $clean_input;
@@ -207,8 +207,8 @@ class CriteriaController extends \BaseController
207 207
                 'subcriteria' => $clean_input['subcriteria'],
208 208
                 'outcome_id' => $clean_input['outcome_id'],
209 209
                 'notes' => $clean_input['notes'],
210
-                'copyright' => $clean_input['copyright'],
211
-                'maximum_score' => $clean_input['maximum_score']
210
+                'copyright' => $clean_input['copyright']
211
+                //'maximum_score' => $clean_input['maximum_score']
212 212
             ),
213 213
             array(
214 214
                 'name' => 'required|string',
@@ -216,8 +216,8 @@ class CriteriaController extends \BaseController
216 216
                 'outcome_id' => 'required|array',
217 217
 
218 218
                 'notes' => 'string',
219
-                'copyright' => 'string',
220
-                'maximum_score' => 'required|integer'
219
+                'copyright' => 'string'
220
+                //'maximum_score' => 'required|integer'
221 221
             )
222 222
 
223 223
         );
@@ -277,8 +277,8 @@ class CriteriaController extends \BaseController
277 277
 
278 278
             //gabriel añadió aqui
279 279
 
280
-            $criterion->number_of_scales = $clean_input['number_of_scales'];
281
-            $criterion->maximum_score = $clean_input['maximum_score'];
280
+            //$criterion->number_of_scales = $clean_input['number_of_scales'];
281
+            //$criterion->maximum_score = $clean_input['maximum_score'];
282 282
 
283 283
             if (Input::get('copyright'))
284 284
                 $criterion->copyright = $clean_input['copyright'];
@@ -295,11 +295,11 @@ class CriteriaController extends \BaseController
295 295
                 foreach ($clean_input['outcome_id'] as $outcome_id) {
296 296
                     foreach ($clean_input['objective_id'] as $objective_id) {
297 297
 
298
-                        DB::insert("insert into `criterion_objective_outcome` (`objective_id`, `outcome_id`, `criterion_id`, `objective_outcome_id`) values ({$objective_id},{$outcome_id}, {$criterionId}, 0)");
298
+                        DB::insert("insert into `criterion_objective_outcome` (`objective_id`, `outcome_id`, `criterion_id`) values ({$objective_id},{$outcome_id}, {$criterionId})");
299 299
                     }
300 300
                 }
301 301
 
302
-                for ($i = 0; $i < sizeof($clean_input['scale_title']); $i++) {
302
+                /*for ($i = 0; $i < sizeof($clean_input['scale_title']); $i++) {
303 303
                     $scale = new Scale;
304 304
                     $scale->title = $clean_input['scale_title'][$i];
305 305
                     $scale->position = $i + 1;
@@ -324,7 +324,7 @@ class CriteriaController extends \BaseController
324 324
                                 return Redirect::to('program-criteria')->withInput();
325 325
                         }
326 326
                     }
327
-                }
327
+                }*/
328 328
 
329 329
                 foreach ($clean_input['program_id'] as $program_id) {
330 330
                     DB::insert("insert into `program_criterion` (`criterion_id`, `program_id`) values({$criterionId},{$program_id})");
@@ -369,7 +369,7 @@ class CriteriaController extends \BaseController
369 369
     public function edit()
370 370
     {
371 371
         $title = "Criteria";
372
-        $outcomes = Outcome::orderBy('name', 'ASC')->lists('name', 'id');
372
+        $outcomes = Outcome::where("deactivation_date", '=', null)->orderBy('name', 'ASC')->lists('name', 'id');
373 373
 
374 374
         $schools = School::orderBy('name', 'ASC')->get();
375 375
         $criteria = Criterion::withTrashed()->orderBy('name', 'ASC')->get();
@@ -418,10 +418,10 @@ class CriteriaController extends \BaseController
418 418
 
419 419
         $clean_input['copyright'] = trim(preg_replace('/\t+/', '', Input::get('copyright')));
420 420
         $clean_input['notes'] = trim(preg_replace('/\t+/', '', Input::get('notes')));
421
-        $clean_input['maximum_score'] = (int) Input::get('assoc_maximum_score');
421
+        /* $clean_input['maximum_score'] = (int) Input::get('assoc_maximum_score');
422 422
         $clean_input['scale_title'] = Input::get('assoc_title');
423 423
         $clean_input['scale_description'] = Input::get('assoc_scales');
424
-        $clean_input['number_of_scales'] = sizeof($clean_input['scale_title']);
424
+        $clean_input['number_of_scales'] = sizeof($clean_input['scale_title']);*/
425 425
 
426 426
 
427 427
         return $clean_input;
@@ -509,11 +509,12 @@ class CriteriaController extends \BaseController
509 509
             if ($criterion->save()) {
510 510
                 $criterionId = $criterion->id;
511 511
                 DB::delete("delete from `criterion_objective_outcome` where `criterion_id` ={$criterionId}");
512
+                DB::delete("delete from `program_criterion` where `criterion_id` ={$criterionId}");
512 513
 
513 514
                 foreach ($clean_input['outcome_id'] as $outcome_id) {
514 515
                     foreach ($clean_input['objective_id'] as $objective_id) {
515 516
 
516
-                        DB::insert("insert into `criterion_objective_outcome` (`objective_id`, `outcome_id`, `criterion_id`,`objective_outcome_id`) values ({$objective_id},{$outcome_id}, {$criterionId}, 0)");
517
+                        DB::insert("insert into `criterion_objective_outcome` (`objective_id`, `outcome_id`, `criterion_id`) values ({$objective_id},{$outcome_id}, {$criterionId})");
517 518
                     }
518 519
                 }
519 520
                 /*DB::delete("delete from `scales` where id in (select scale_id id from criterion_scale where criterion_id = {$criterionId})");
@@ -541,6 +542,9 @@ class CriteriaController extends \BaseController
541 542
                         }
542 543
                     }
543 544
                 }*/
545
+                foreach ($clean_input['program_id'] as $program_id) {
546
+                    DB::insert("insert into `program_criterion` (`criterion_id`, `program_id`) values({$criterionId},{$program_id})");
547
+                }
544 548
 
545 549
 
546 550
 
@@ -549,13 +553,13 @@ class CriteriaController extends \BaseController
549 553
                 $role = Auth::user()['role'];
550 554
                 switch ($role) {
551 555
                     case 1:
552
-                        return Redirect::to('objective')->withInput();
556
+                        return Redirect::to('criteria')->withInput();
553 557
 
554 558
                     case 2:
555
-                        return Redirect::to('school-objective')->withInput();
559
+                        return Redirect::to('school-criteria')->withInput();
556 560
 
557 561
                     case 3:
558
-                        return Redirect::to('program-objective')->withInput();
562
+                        return Redirect::to('program-criteria')->withInput();
559 563
                 }
560 564
             }
561 565
 
@@ -566,13 +570,13 @@ class CriteriaController extends \BaseController
566 570
                 $role = Auth::user()['role'];
567 571
                 switch ($role) {
568 572
                     case 1:
569
-                        return Redirect::to('objective')->withInput();
573
+                        return Redirect::to('criteria')->withInput();
570 574
 
571 575
                     case 2:
572
-                        return Redirect::to('school-objective')->withInput();
576
+                        return Redirect::to('school-criteria')->withInput();
573 577
 
574 578
                     case 3:
575
-                        return Redirect::to('program-objective')->withInput();
579
+                        return Redirect::to('program-criteria')->withInput();
576 580
                 }
577 581
             }
578 582
         }

+ 11
- 8
app/controllers/Objective2Controller.php 查看文件

@@ -39,16 +39,17 @@ class Objective2Controller extends \BaseController
39 39
 		else
40 40
 			$program_id = NULL;
41 41
 
42
-		$saved_Objective = Objective::withTrashed()
43
-			->where('text', '=', $input['text'])
44
-			->where('outcome_id', '=', $input['outcome_id'])
45
-			->where('program_id', '=', $program_id)
42
+		$saved_Objective = DB::table('objectives')->join('objective_outcome', 'objective_outcome.objective_id', '=', 'objectives.id')
43
+			->join('objective_program', 'objective_program.objective_id', '=', 'objectives.id')
44
+			->where('objectives.text', '=', $input['text'])
45
+			->whereIn('objective_outcome.outcome_id', $input['outcome_id'])
46
+			->whereIn('objective_program.program_id', $input['program_id'])
46 47
 
47
-			->first();
48
+			->get();
48 49
 
49 50
 
50 51
 
51
-		if ($saved_Objective)
52
+		if (count($saved_Objective))
52 53
 			return false;
53 54
 		else
54 55
 			return true;
@@ -126,8 +127,10 @@ class Objective2Controller extends \BaseController
126 127
 		$json['program'] = DB::select("select program_id from objective_program where objective_id = ?", array(Input::get('id')));
127 128
 		$json['outcome'] = DB::select("select outcome_id from objective_outcome outc where outc.objective_id = ?", array(Input::get('id')));
128 129
 		$json['objective'] = DB::select("select text, id from objectives where id =?", array(Input::get('id')));
129
-		$json['assessment'] = DB::select("select * from assessments where activity_id  in (select activity_id from activity_criterion where criterion_id in (select criterion_id from criterion_objective_outcome where objective_id = ?))", array(Input::get('id')));
130
+		$json['assessment'] = DB::select("select * from assessments where activity_criterion_id  in (select id from activity_criterion where criterion_id in (select criterion_id from criterion_objective_outcome where objective_id = ?))", array(Input::get('id')));
131
+
130 132
 		$json['assoc_criteria'] = DB::select("select name from criteria where id in(select criterion_id from criterion_objective_outcome where objective_id =?)", array(Input::get('id')));
133
+		Log::info('is here');
131 134
 		return json_encode($json);
132 135
 	}
133 136
 	public function fetchAllobjectives()
@@ -301,7 +304,7 @@ class Objective2Controller extends \BaseController
301 304
 	public function edit()
302 305
 	{
303 306
 		$title = "Objective";
304
-		$outcomes = Outcome::orderBy('name', 'ASC')->lists('name', 'id');
307
+		$outcomes = Outcome::where('deactivation_date', '=', null)->orderBy('name', 'ASC')->lists('name', 'id');
305 308
 
306 309
 		$objectives = Objective::withTrashed()->orderBy('text', 'ASC')->get();
307 310
 		$programs = Program::orderBy('name', 'ASC')->get();

+ 32
- 32
app/controllers/OutcomesController.php 查看文件

@@ -410,8 +410,8 @@ class OutcomesController extends \BaseController
410 410
         if (Input::get('filter')) {
411 411
             switch (Input::get('filter')) {
412 412
                 case 'all':
413
-                    return DB::table('new_criteria')
414
-                        ->join('criterion_objective_outcome', 'criterion_objective_outcome.criterion_id', '=', 'new_criteria.id')
413
+                    return DB::table('criteria')
414
+                        ->join('criterion_objective_outcome', 'criterion_objective_outcome.criterion_id', '=', 'criteria.id')
415 415
                         ->where('criterion_objective_outcome.outcome_id', '=', Input::get('id'))
416 416
                         ->select('criterion_id as id', 'name')
417 417
                         ->orderBy('name', 'ASC')
@@ -424,16 +424,16 @@ class OutcomesController extends \BaseController
424 424
 
425 425
                         // Fetch all the programs whose school is the user's
426 426
                         $program_ids = DB::table('programs')->where('school_id', Auth::user()->school_id)->lists('id');
427
-                        $new_criteria = DB::table('new_criteria')
428
-                            ->join('criterion_objective_outcome', 'criterion_objective_outcome.criterion_id', '=', 'new_criteria.id')
429
-                            ->join('program_criterion', 'program_criterion.criterion_id', '=', 'new_criteria.id')
427
+                        $criteria = DB::table('criteria')
428
+                            ->join('criterion_objective_outcome', 'criterion_objective_outcome.criterion_id', '=', 'criteria.id')
429
+                            ->join('program_criterion', 'program_criterion.criterion_id', '=', 'criteria.id')
430 430
                             ->where('criterion_objective_outcome.outcome_id', '=', Input::get('id'))
431 431
                             ->whereIn('program_criterion.program_id', $program_ids)
432 432
                             ->select('criterion_id as id', 'name')
433 433
                             ->orderBy('name', 'ASC')
434 434
                             ->get();
435 435
                         // Return all criteria belonging to any of those programs
436
-                        return $new_criteria;
436
+                        return $criteria;
437 437
                     }
438 438
 
439 439
                     // If pcoord
@@ -442,9 +442,9 @@ class OutcomesController extends \BaseController
442 442
                         // Fetch all the programs from the user's school;
443 443
                         $program_ids = DB::table('programs')->where('school_id', Auth::user()->programs[0]->school->id)->lists('id');
444 444
 
445
-                        return DB::table('new_criteria')
446
-                            ->join('criterion_objective_outcome', 'criterion_objective_outcome.criterion_id', '=', 'new_criteria.id')
447
-                            ->join('program_criterion', 'program_criterion.criterion_id', '=', 'new_criteria.id')
445
+                        return DB::table('criteria')
446
+                            ->join('criterion_objective_outcome', 'criterion_objective_outcome.criterion_id', '=', 'criteria.id')
447
+                            ->join('program_criterion', 'program_criterion.criterion_id', '=', 'criteria.id')
448 448
                             ->where('criterion_objective_outcome.outcome_id', '=', Input::get('id'))
449 449
                             ->whereIn('program_criterion.program_id', $program_ids)
450 450
                             ->select('criterion_id as id', 'name')
@@ -455,20 +455,20 @@ class OutcomesController extends \BaseController
455 455
                     break;
456 456
 
457 457
                 case 'program':
458
-                    $new_criteria = DB::table('new_criteria')
459
-                        ->join('criterion_objective_outcome', 'criterion_objective_outcome.criterion_id', '=', 'new_criteria.id')
460
-                        ->join('program_criterion', 'program_criterion.criterion_id', '=', 'new_criteria.id')
458
+                    $criteria = DB::table('criteria')
459
+                        ->join('criterion_objective_outcome', 'criterion_objective_outcome.criterion_id', '=', 'criteria.id')
460
+                        ->join('program_criterion', 'program_criterion.criterion_id', '=', 'criteria.id')
461 461
                         ->where('criterion_objective_outcome.outcome_id', '=', Input::get('id'))
462 462
                         ->whereIn('program_criterion.program_id', Auth::user()->programs->lists('id'))
463 463
                         ->select('criterion_id as id', 'name')
464 464
                         ->orderBy('name', 'ASC')
465 465
                         ->get();
466
-                    return $new_criteria;
466
+                    return $criteria;
467 467
                     break;
468 468
 
469 469
                 default:
470
-                    return DB::table('new_criteria')
471
-                        ->join('criterion_objective_outcome', 'criterion_objective_outcome.criterion_id', '=', 'new_criteria.id')
470
+                    return DB::table('criteria')
471
+                        ->join('criterion_objective_outcome', 'criterion_objective_outcome.criterion_id', '=', 'criteria.id')
472 472
                         ->where('criterion_objective_outcome.outcome_id', '=', Input::get('id'))
473 473
                         ->select('criterion_id as id', 'name')
474 474
                         ->orderBy('name', 'ASC')
@@ -476,8 +476,8 @@ class OutcomesController extends \BaseController
476 476
                     break;
477 477
             }
478 478
         } else {
479
-            return DB::table('new_criteria')
480
-                ->join('criterion_objective_outcome', 'criterion_objective_outcome.criterion_id', '=', 'new_criteria.id')
479
+            return DB::table('criteria')
480
+                ->join('criterion_objective_outcome', 'criterion_objective_outcome.criterion_id', '=', 'criteria.id')
481 481
                 ->where('criterion_objective_outcome.outcome_id', '=', Input::get('id'))
482 482
                 ->select('criterion_id as id', 'name')
483 483
                 ->orderBy('name', 'ASC')
@@ -552,12 +552,12 @@ class OutcomesController extends \BaseController
552 552
         $outcome = $outcome_info[0];
553 553
 
554 554
         $diferent_levels = DB::table('criterion_objective_outcome')
555
-            ->join('new_criteria', 'new_criteria.id', '=', 'criterion_objective_outcome.criterion_id')
555
+            ->join('criteria', 'criteria.id', '=', 'criterion_objective_outcome.criterion_id')
556 556
             ->join('objectives', 'objectives.id', '=', 'criterion_objective_outcome.objective_id')
557 557
             ->where('criterion_objective_outcome.outcome_id', $id)
558
-            ->distinct('new_criteria.number_of_scales')
559
-            ->select('new_criteria.number_of_scales as levels')
560
-            ->orderBy('new_criteria.number_of_scales', 'asc')
558
+            ->distinct('criteria.number_of_scales')
559
+            ->select('criteria.number_of_scales as levels')
560
+            ->orderBy('criteria.number_of_scales', 'asc')
561 561
             ->get();
562 562
 
563 563
         $criteria_array = array();
@@ -568,13 +568,13 @@ class OutcomesController extends \BaseController
568 568
 
569 569
             // buscar todos los criterios con el level y ponerlos en un array
570 570
             $outcome_criterias = DB::table('criterion_objective_outcome')
571
-                ->join('new_criteria', 'new_criteria.id', '=', 'criterion_objective_outcome.criterion_id')
571
+                ->join('criteria', 'criteria.id', '=', 'criterion_objective_outcome.criterion_id')
572 572
                 ->join('objectives', 'objectives.id', '=', 'criterion_objective_outcome.objective_id')
573 573
                 ->where('criterion_objective_outcome.outcome_id', $id)
574
-                ->where('new_criteria.number_of_scales', $level)
575
-                ->whereNull('new_criteria.deleted_at')
576
-                ->select('new_criteria.id', 'new_criteria.name')
577
-                ->orderBy('new_criteria.name', 'asc')
574
+                ->where('criteria.number_of_scales', $level)
575
+                ->whereNull('criteria.deleted_at')
576
+                ->select('criteria.id', 'criteria.name')
577
+                ->orderBy('criteria.name', 'asc')
578 578
                 ->get();
579 579
             $outcome_criterias = $outcome_criterias;
580 580
 
@@ -585,20 +585,20 @@ class OutcomesController extends \BaseController
585 585
                         DB::raw("
586 586
                   SELECT *
587 587
                   FROM (
588
-                    SELECT new_criteria.id as criterion_id,
588
+                    SELECT criteria.id as criterion_id,
589 589
                       ROW_NUMBER() OVER(PARTITION BY scales.id) rn,
590 590
                       scales.position,
591 591
                       scales.title, scales.description,
592 592
                       criterion_objective_outcome.outcome_id,criterion_objective_outcome.objective_id,
593 593
                       criterion_scale.scale_id
594
-                    FROM new_criteria,criterion_scale,scales, criterion_objective_outcome, objectives
595
-                    where new_criteria.id=criterion_scale.criterion_id
594
+                    FROM criteria,criterion_scale,scales, criterion_objective_outcome, objectives
595
+                    where criteria.id=criterion_scale.criterion_id
596 596
                       and scales.id = criterion_scale.scale_id
597
-                      and new_criteria.id = criterion_objective_outcome.criterion_id
597
+                      and criteria.id = criterion_objective_outcome.criterion_id
598 598
                       and objectives.id = criterion_objective_outcome.objective_id
599 599
                       and criterion_objective_outcome.outcome_id = $id
600
-                      and new_criteria.id = $criteria_id->id
601
-                    ORDER BY new_criteria.name ASC) a
600
+                      and criteria.id = $criteria_id->id
601
+                    ORDER BY criteria.name ASC) a
602 602
                   WHERE rn = 1
603 603
                   ORDER BY `a`.`position` ASC
604 604
                       ")

+ 6
- 6
app/controllers/RubricsController.php 查看文件

@@ -78,14 +78,14 @@ class RubricsController extends \BaseController
78 78
 
79 79
 
80 80
         // Get rubric contents
81
-        $rubric_contents = json_decode(Input::get('contents'));
81
+
82 82
         $scales = Input::get('scales');
83 83
         $criteria = Input::get('criteria');
84 84
 
85 85
         // Process rubric
86 86
         $rubric = new Rubric;
87 87
         $rubric->name = Input::get('name');
88
-        $rubric->contents = json_encode($rubric_contents);
88
+
89 89
         $rubric->expected_percentage = Input::get('expected_percentage');
90 90
         $rubric->expected_points = Input::get('expected_points');
91 91
         $rubric->user_id = Auth::id();
@@ -99,13 +99,13 @@ class RubricsController extends \BaseController
99 99
             //             $activity->rubric_id = $rubric->id;
100 100
             //             $activity->save();
101 101
 
102
-            DB::table('new_rubric_activity')->insert(array('activity_id' => Input::get('activity_id'), 'rubric_id' => $rubric->id));
102
+            DB::table('rubric_activity')->insert(array('activity_id' => Input::get('activity_id'), 'rubric_id' => $rubric->id));
103 103
             DB::commit();
104 104
 
105 105
             $rubricId = $rubric->id;
106 106
             foreach ($criteria as $index => $criterion_id) {
107
-                DB::insert("insert into new_criterion_rubric (`rubric_id`,`criterion_id`) values ({$rubricId},{$criterion_id})");
108
-                $rubric_criterion_id = DB::table('new_criterion_rubric')->where('rubric_id', '=', $rubricId)
107
+                DB::insert("insert into criterion_rubric (`rubric_id`,`criterion_id`) values ({$rubricId},{$criterion_id})");
108
+                $rubric_criterion_id = DB::table('criterion_rubric')->where('rubric_id', '=', $rubricId)
109 109
                     ->where('criterion_id', '=', $criterion_id)->first();
110 110
 
111 111
                 for ($i = 0; $i < count($scales[$index]); $i++) {
@@ -152,7 +152,7 @@ class RubricsController extends \BaseController
152 152
     {
153 153
         $rubric = Rubric::find(Input::get('id'));
154 154
         $rubric->name = Input::get('name');
155
-        $rubric->contents = Input::get('contents');
155
+
156 156
         $rubric->expected_percentage = Input::get('expected_percentage');
157 157
         $rubric->expected_points = Input::get('expected_points');
158 158
 

+ 48
- 6
app/controllers/TemplatesController.php 查看文件

@@ -47,7 +47,7 @@ class TemplatesController extends \BaseController
47 47
 	{
48 48
 		$json_to_send = [];
49 49
 		$template_id = Input::get('id');
50
-		$json_to_send["criteria"] = DB::table("new_criteria")->join('template_criterion', 'template_criterion.criterion_id', '=', 'new_criteria.id')
50
+		$json_to_send["criteria"] = DB::table("criteria")->join('template_criterion', 'template_criterion.criterion_id', '=', 'criteria.id')
51 51
 			->where("template_criterion.template_id", '=', $template_id)
52 52
 			->get();
53 53
 		Log::info($json_to_send["criteria"]);
@@ -67,7 +67,7 @@ class TemplatesController extends \BaseController
67 67
 		$title = "Rubric Builder";
68 68
 
69 69
 		$templates = Template::orderBy('name', 'ASC')->get();
70
-		$outcomes = Outcome::orderBy('name', 'ASC')->get();
70
+		$outcomes = Outcome::where("deactivation_date", '=', null)->orderBy('name', 'ASC')->get();
71 71
 		$criteria = Criterion::orderBy('name', 'ASC')->get();
72 72
 		$schools = School::orderBy('name', 'ASC')->get();
73 73
 		$role = Auth::user()->role;
@@ -100,7 +100,7 @@ class TemplatesController extends \BaseController
100 100
 		$template = new Template;
101 101
 
102 102
 		$template->name = Input::get('name');
103
-		$template->contents = Input::get('contents');
103
+
104 104
 		$template->is_visible = Input::get('is_visible');
105 105
 		$template->expected_percentage = Input::get('expected_percentage');
106 106
 		$template->expected_points = Input::get('expected_points');
@@ -183,8 +183,8 @@ class TemplatesController extends \BaseController
183 183
 	{
184 184
 		$template_info = [];
185 185
 		$template_info['template'] = Template::find(Input::get('id'));
186
-		$template_info['criterion'] = DB::table('new_criteria')
187
-			->join('template_criterion', 'template_criterion.criterion_id', '=', 'new_criteria.id')
186
+		$template_info['criterion'] = DB::table('criteria')
187
+			->join('template_criterion', 'template_criterion.criterion_id', '=', 'criteria.id')
188 188
 			->where("template_criterion.template_id", '=', Input::get('id'))
189 189
 			->get();
190 190
 		foreach ($template_info['criterion'] as $temp_crit) {
@@ -208,7 +208,7 @@ class TemplatesController extends \BaseController
208 208
 	{
209 209
 		$template = Template::find(Input::get('id'));
210 210
 		$template->name = Input::get('name');
211
-		$template->contents = Input::get('contents');
211
+
212 212
 		$template->is_visible = Input::get('is_visible');
213 213
 		$template->expected_percentage = Input::get('expected_percentage');
214 214
 		$template->expected_points = Input::get('expected_points');
@@ -232,7 +232,49 @@ class TemplatesController extends \BaseController
232 232
 				$template->program_id = NULL;
233 233
 		}
234 234
 
235
+		switch (Auth::user()->role) {
236
+			case 2:
237
+				$template->school_id = Auth::user()->school->id;
238
+				break;
239
+
240
+			case 3:
241
+				$template->school_id = Auth::user()->programs[0]->school->id;
242
+				$template->program_id = Auth::user()->programs[0]->id;
243
+				break;
244
+		}
245
+
246
+		$scales = Input::get('scales');
247
+		$criteria = Input::get('criteria');
248
+
249
+		$max_score = Input::get('max_score');
250
+		Log::info($scales);
251
+		Log::info(Input::all());
252
+		$template->num_scales = count($scales[0]);
253
+		$template->max_score = $max_score;
254
+		$division = $max_score / count($scales[0]);
255
+
235 256
 		if ($template->save()) {
257
+			$templateId = $template->id;
258
+			DB::delete("delete from template_criterion where template_id ={$template->id}");
259
+			foreach ($criteria as $index => $criterion_id) {
260
+
261
+				DB::insert("insert into template_criterion (`template_id`,`criterion_id`) values ({$templateId},{$criterion_id})");
262
+				$template_criterion_id = DB::table('template_criterion')->where('template_id', '=', $templateId)
263
+					->where('criterion_id', '=', $criterion_id)->first();
264
+				DB::delete("delete from template_criterion_scale where template_criterion_id ={$template_criterion_id->id}");
265
+				for ($i = 0; $i < count($scales[$index]); $i++) {
266
+					$scale = new Scale;
267
+					$scale->description = $scales[$index][$i];
268
+					$scale->min_score = 1 + ($division * $i);
269
+					$scale->max_score = ($division * ($i + 1));
270
+					if ($scale->save()) {
271
+						DB::insert("insert into `template_criterion_scale` (`template_criterion_id`, `scale_id`, `position`) values ({$template_criterion_id->id},{$scale->id}, {$i})");
272
+					} else {
273
+						Session::flash('status', 'danger');
274
+						Session::flash('message', 'Rubric could not be created.');
275
+					}
276
+				}
277
+			}
236 278
 			Session::flash('status', 'success');
237 279
 			Session::flash('message', 'Rubric updated (' . date('m/d/y, h:i:s a') . ').');
238 280
 		} else {

+ 23
- 24
app/database/old_migrations/2020_04_04_002657_create_new_criteria_table.php 查看文件

@@ -3,7 +3,8 @@
3 3
 use Illuminate\Database\Migrations\Migration;
4 4
 use Illuminate\Database\Schema\Blueprint;
5 5
 
6
-class CreateNewCriteriaTable extends Migration {
6
+class CreateNewCriteriaTable extends Migration
7
+{
7 8
 
8 9
 	/**
9 10
 	 * Run the migrations.
@@ -12,27 +13,26 @@ class CreateNewCriteriaTable extends Migration {
12 13
 	 */
13 14
 	public function up()
14 15
 	{
15
-		Schema::create('new_criteria', function(Blueprint $table)
16
-		{
17
-            $table->increments('id');
18
-            $table->string('name');
19
-            $table->string('subcriteria')->nullable();
20
-            $table->text('description12');
21
-            $table->text('description34');
22
-            $table->text('description56');
23
-            $table->text('description78');
24
-            $table->integer('objective_id')->unsigned();
25
-            $table->integer('program_id')->unsigned()->nullable();
26
-            $table->integer('user_id')->unsigned()->nullable();
27
-            $table->text('copyright')->nullable();
28
-            $table->text('notes')->nullable();
29
-
30
-            $table->timestamps();
31
-            $table->timestamp('deleted_at')->nullable();
32
-
33
-            $table->foreign('objective_id')->references('id')->on('objectives')->onDelete('cascade')->onUpdate('cascade');
34
-            $table->foreign('program_id')->references('id')->on('programs')->onDelete('cascade')->onUpdate('cascade');
35
-            $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade')->onUpdate('cascade');
16
+		Schema::create('criteria', function (Blueprint $table) {
17
+			$table->increments('id');
18
+			$table->string('name');
19
+			$table->string('subcriteria')->nullable();
20
+			$table->text('description12');
21
+			$table->text('description34');
22
+			$table->text('description56');
23
+			$table->text('description78');
24
+			$table->integer('objective_id')->unsigned();
25
+			$table->integer('program_id')->unsigned()->nullable();
26
+			$table->integer('user_id')->unsigned()->nullable();
27
+			$table->text('copyright')->nullable();
28
+			$table->text('notes')->nullable();
29
+
30
+			$table->timestamps();
31
+			$table->timestamp('deleted_at')->nullable();
32
+
33
+			$table->foreign('objective_id')->references('id')->on('objectives')->onDelete('cascade')->onUpdate('cascade');
34
+			$table->foreign('program_id')->references('id')->on('programs')->onDelete('cascade')->onUpdate('cascade');
35
+			$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade')->onUpdate('cascade');
36 36
 		});
37 37
 	}
38 38
 
@@ -44,7 +44,6 @@ class CreateNewCriteriaTable extends Migration {
44 44
 	 */
45 45
 	public function down()
46 46
 	{
47
-		Schema::drop('new_criteria');
47
+		Schema::drop('criteria');
48 48
 	}
49
-
50 49
 }

+ 14
- 15
app/database/old_migrations/2020_04_22_095649_create_new_criterion_rubric_table.php 查看文件

@@ -3,7 +3,8 @@
3 3
 use Illuminate\Database\Migrations\Migration;
4 4
 use Illuminate\Database\Schema\Blueprint;
5 5
 
6
-class CreateNewCriterionRubricTable extends Migration {
6
+class CreateNewCriterionRubricTable extends Migration
7
+{
7 8
 
8 9
 	/**
9 10
 	 * Run the migrations.
@@ -12,25 +13,24 @@ class CreateNewCriterionRubricTable extends Migration {
12 13
 	 */
13 14
 	public function up()
14 15
 	{
15
-		Schema::create('new_criterion_rubric', function(Blueprint $table)
16
-		{
16
+		Schema::create('criterion_rubric', function (Blueprint $table) {
17 17
 			$table->increments('id');
18 18
 			$table->integer('criterion_id')->unsigned();
19 19
 			$table->integer('rubric_id')->unsigned();
20 20
 			$table->timestamps();
21 21
 
22 22
 			$table
23
-                ->foreign('criterion_id')
24
-                ->references('id')
25
-                ->on('new_criteria')
26
-                ->onDelete('cascade')
27
-                ->onUpdate('cascade');
23
+				->foreign('criterion_id')
24
+				->references('id')
25
+				->on('criteria')
26
+				->onDelete('cascade')
27
+				->onUpdate('cascade');
28 28
 			$table
29
-                ->foreign('rubric_id')
30
-                ->references('id')
31
-                ->on('rubrics')
32
-                ->onDelete('cascade')
33
-                ->onUpdate('cascade');
29
+				->foreign('rubric_id')
30
+				->references('id')
31
+				->on('rubrics')
32
+				->onDelete('cascade')
33
+				->onUpdate('cascade');
34 34
 		});
35 35
 	}
36 36
 
@@ -42,7 +42,6 @@ class CreateNewCriterionRubricTable extends Migration {
42 42
 	 */
43 43
 	public function down()
44 44
 	{
45
-		Schema::drop('new_criterion_rubric');
45
+		Schema::drop('criterion_rubric');
46 46
 	}
47
-
48 47
 }

+ 14
- 15
app/database/old_migrations/2020_04_22_101110_create_new_rubric_activity_table.php 查看文件

@@ -3,7 +3,8 @@
3 3
 use Illuminate\Database\Migrations\Migration;
4 4
 use Illuminate\Database\Schema\Blueprint;
5 5
 
6
-class CreateNewRubricActivityTable extends Migration {
6
+class CreateNewRubricActivityTable extends Migration
7
+{
7 8
 
8 9
 	/**
9 10
 	 * Run the migrations.
@@ -12,25 +13,24 @@ class CreateNewRubricActivityTable extends Migration {
12 13
 	 */
13 14
 	public function up()
14 15
 	{
15
-		Schema::create('new_rubric_activity', function(Blueprint $table)
16
-		{
16
+		Schema::create('rubric_activity', function (Blueprint $table) {
17 17
 			$table->increments('id');
18 18
 			$table->integer('rubric_id')->unsigned();
19 19
 			$table->integer('activity_id')->unsigned();
20 20
 			$table->timestamps();
21 21
 
22 22
 			$table
23
-                ->foreign('rubric_id')
24
-                ->references('id')
25
-                ->on('rubrics')
26
-                ->onDelete('cascade')
27
-                ->onUpdate('cascade');
23
+				->foreign('rubric_id')
24
+				->references('id')
25
+				->on('rubrics')
26
+				->onDelete('cascade')
27
+				->onUpdate('cascade');
28 28
 			$table
29
-                ->foreign('activity_id')
30
-                ->references('id')
31
-                ->on('activities')
32
-                ->onDelete('cascade')
33
-                ->onUpdate('cascade');
29
+				->foreign('activity_id')
30
+				->references('id')
31
+				->on('activities')
32
+				->onDelete('cascade')
33
+				->onUpdate('cascade');
34 34
 		});
35 35
 	}
36 36
 
@@ -42,7 +42,6 @@ class CreateNewRubricActivityTable extends Migration {
42 42
 	 */
43 43
 	public function down()
44 44
 	{
45
-		Schema::drop('new_rubric_activity');
45
+		Schema::drop('rubric_activity');
46 46
 	}
47
-
48 47
 }

+ 4
- 5
app/database/old_migrations/2020_10_04_142756_create_new_assessments_table.php 查看文件

@@ -3,7 +3,8 @@
3 3
 use Illuminate\Database\Schema\Blueprint;
4 4
 use Illuminate\Database\Migrations\Migration;
5 5
 
6
-class CreateNewAssessmentsTable extends Migration {
6
+class CreateNewAssessmentsTable extends Migration
7
+{
7 8
 
8 9
 	/**
9 10
 	 * Run the migrations.
@@ -12,8 +13,7 @@ class CreateNewAssessmentsTable extends Migration {
12 13
 	 */
13 14
 	public function up()
14 15
 	{
15
-		Schema::create('new_assessments', function(Blueprint $table)
16
-		{
16
+		Schema::create('assessments', function (Blueprint $table) {
17 17
 			$table->increments('id');
18 18
 			$table->integer('student_id')->unsigned();
19 19
 			$table->integer('activity_criterion_id')->unsigned();
@@ -41,7 +41,6 @@ class CreateNewAssessmentsTable extends Migration {
41 41
 	 */
42 42
 	public function down()
43 43
 	{
44
-		Schema::drop('new_assessments');
44
+		Schema::drop('assessments');
45 45
 	}
46
-
47 46
 }

+ 5
- 7
app/database/old_migrations/2020_10_05_130252_add_max_score_num_scales_new_criteria_table.php 查看文件

@@ -3,7 +3,8 @@
3 3
 use Illuminate\Database\Schema\Blueprint;
4 4
 use Illuminate\Database\Migrations\Migration;
5 5
 
6
-class AddMaxScoreNumScalesNewCriteriaTable extends Migration {
6
+class AddMaxScoreNumScalesNewCriteriaTable extends Migration
7
+{
7 8
 
8 9
 	/**
9 10
 	 * Run the migrations.
@@ -12,8 +13,7 @@ class AddMaxScoreNumScalesNewCriteriaTable extends Migration {
12 13
 	 */
13 14
 	public function up()
14 15
 	{
15
-		Schema::table('new_criteria', function(Blueprint $table)
16
-		{
16
+		Schema::table('criteria', function (Blueprint $table) {
17 17
 			$table->integer('maximum_score')->after('name');;
18 18
 			$table->integer('number_of_scales')->after('maximum_score');;
19 19
 		});
@@ -26,10 +26,8 @@ class AddMaxScoreNumScalesNewCriteriaTable extends Migration {
26 26
 	 */
27 27
 	public function down()
28 28
 	{
29
-		Schema::table('new_criteria', function(Blueprint $table)
30
-		{
31
-    		$table->dropColumn(array('maximum_score', 'number_of_scales'));
29
+		Schema::table('criteria', function (Blueprint $table) {
30
+			$table->dropColumn(array('maximum_score', 'number_of_scales'));
32 31
 		});
33 32
 	}
34
-
35 33
 }

+ 2
- 2
app/database/old_migrations/2020_10_29_195413_MakeObjectiveNullable.php 查看文件

@@ -13,8 +13,8 @@ class MakeObjectiveNullable extends Migration
13 13
 	 */
14 14
 	public function up()
15 15
 	{
16
-		Schema::table('new_criteria', function (Blueprint $table) {
17
-			$table->dropForeign('new_criteria_objective_id_foreign');
16
+		Schema::table('criteria', function (Blueprint $table) {
17
+			$table->dropForeign('criteria_objective_id_foreign');
18 18
 		});
19 19
 	}
20 20
 

+ 1
- 1
app/database/old_migrations/2020_10_29_224846_Make_criterion_objective_outcome_changeForeignKey.php 查看文件

@@ -15,7 +15,7 @@ class MakeCriterionObjectiveOutcomeChangeForeignKey extends Migration
15 15
 	{
16 16
 		Schema::table('criterion_objective_outcome', function (Blueprint $table) {
17 17
 			$table->dropForeign('criterion_objective_outcome_criterion_id_foreign');
18
-			$table->foreign('criterion_id')->references('id')->on('new_criteria')->onDelete('cascade')->onUpdate('cascade');
18
+			$table->foreign('criterion_id')->references('id')->on('criteria')->onDelete('cascade')->onUpdate('cascade');
19 19
 		});
20 20
 	}
21 21
 

+ 1
- 1
app/database/old_migrations/2020_12_04_111708_dropDescriptionInCriteria.php 查看文件

@@ -13,7 +13,7 @@ class DropDescriptionInCriteria extends Migration
13 13
 	 */
14 14
 	public function up()
15 15
 	{
16
-		Schema::table('new_criteria', function (Blueprint $table) {
16
+		Schema::table('criteria', function (Blueprint $table) {
17 17
 
18 18
 			$table->dropColumn('description12');
19 19
 			$table->dropColumn('description34');

+ 1
- 1
app/database/old_migrations/2020_12_10_175517_createProgramCriterion2.php 查看文件

@@ -26,7 +26,7 @@ class CreateProgramCriterion2 extends Migration
26 26
 			$table
27 27
 				->foreign('criterion_id')
28 28
 				->references('id')
29
-				->on('new_criteria')
29
+				->on('criteria')
30 30
 				->onDelete('cascade')
31 31
 				->onUpdate('cascade');
32 32
 		});

+ 1
- 1
app/database/old_migrations/2021_03_03_090217_create_annual_plan_objective_table.php 查看文件

@@ -33,7 +33,7 @@ class CreateAnnualPlanObjectiveTable extends Migration
33 33
 			$table->integer('criteria_id')->unsigned();
34 34
 			$table->foreign('criteria_id')
35 35
 				->references('id')
36
-				->on('new_criteria')
36
+				->on('criteria')
37 37
 				->onUpdate('cascade')
38 38
 				->onDelete('cascade');
39 39
 

+ 1
- 1
app/database/old_migrations/2021_05_20_184230_create_rubric_scales.php 查看文件

@@ -25,7 +25,7 @@ class CreateRubricScales extends Migration
25 25
 				->onUpdate('cascade');
26 26
 			$table->foreign('rubric_criterion_id')
27 27
 				->references('id')
28
-				->on('new_criterion_rubric')
28
+				->on('criterion_rubric')
29 29
 				->onDelete('cascade')
30 30
 				->onUpdate('cascade');
31 31
 			$table->integer('position');

+ 1
- 1
app/database/old_migrations/2021_05_20_212410_create_template_criterion.php 查看文件

@@ -19,7 +19,7 @@ class CreateTemplateCriterion extends Migration
19 19
 			$table->integer('criterion_id')->unsigned();
20 20
 			$table->foreign('criterion_id')
21 21
 				->references('id')
22
-				->on('new_criteria')
22
+				->on('criteria')
23 23
 				->onDelete('cascade')
24 24
 				->onUpdate('cascade');
25 25
 			$table->foreign('template_id')

+ 96
- 104
app/database/seeds/FillNewAssessmentActivityCriterion.php 查看文件

@@ -1,125 +1,117 @@
1 1
 <?php
2 2
 
3
-class FillNewAssessmentActivityCriterion extends Seeder {
3
+class FillNewAssessmentActivityCriterion extends Seeder
4
+{
4 5
 
5
-    public function run()
6
-    {
7
-    
8
-//   DB::enableQueryLog();
9
-    	$activities=DB::table('activities')
10
-    					->join('new_rubric_activity', 'activities.id', '=', 'new_rubric_activity.activity_id')
11
-    					->join('rubrics', 'rubrics.id', '=', 'new_rubric_activity.rubric_id')
12
-    					->join('new_criterion_rubric', 'rubrics.id', '=', 'new_criterion_rubric.rubric_id')
13
-						->select('activities.*','rubrics.expected_percentage','rubrics.expected_points','new_criterion_rubric.criterion_id')
14
-						->orderBy('activities.id')
15
-						->orderBy('new_criterion_rubric.criterion_id')
16
-    					->get();
17
-//   DB::enableQueryLog();
18
-// 		dd(DB::getQueryLog());
19
-// 		exit();
20
-		$activity_antes=-1;
21
-		foreach ($activities as $activity)
22
-		{
23
-			$activity_id=$activity->id;
24
-			$expected_percentage_students_achieving=$activity->expected_percentage;
25
-			$transformative_actions=$activity->transforming_actions;
26
-			$assessment_comments=$activity->assessment_comments;
27
-			$expected_student_score=$activity->expected_points;
28
-			$criterion_id=$activity->criterion_id;
29
-// 			$datos=json_decode($activity->criteria_achieved, true);
30
-// 			$i=0;
31
-// 			foreach($datos as $criterion_id=>$score)
32
-// 			{
33
-			$existe_ya=DB::table('activity_criterion')->where('activity_id', $activity_id)->where('criterion_id', $criterion_id)->first();
34
-			if(empty($existe_ya))
35
-			{			
36
-				if($activity_antes==$activity_id)
37
-				{
6
+	public function run()
7
+	{
8
+
9
+		//   DB::enableQueryLog();
10
+		$activities = DB::table('activities')
11
+			->join('rubric_activity', 'activities.id', '=', 'rubric_activity.activity_id')
12
+			->join('rubrics', 'rubrics.id', '=', 'rubric_activity.rubric_id')
13
+			->join('criterion_rubric', 'rubrics.id', '=', 'criterion_rubric.rubric_id')
14
+			->select('activities.*', 'rubrics.expected_percentage', 'rubrics.expected_points', 'criterion_rubric.criterion_id')
15
+			->orderBy('activities.id')
16
+			->orderBy('criterion_rubric.criterion_id')
17
+			->get();
18
+		//   DB::enableQueryLog();
19
+		// 		dd(DB::getQueryLog());
20
+		// 		exit();
21
+		$activity_antes = -1;
22
+		foreach ($activities as $activity) {
23
+			$activity_id = $activity->id;
24
+			$expected_percentage_students_achieving = $activity->expected_percentage;
25
+			$transformative_actions = $activity->transforming_actions;
26
+			$assessment_comments = $activity->assessment_comments;
27
+			$expected_student_score = $activity->expected_points;
28
+			$criterion_id = $activity->criterion_id;
29
+			// 			$datos=json_decode($activity->criteria_achieved, true);
30
+			// 			$i=0;
31
+			// 			foreach($datos as $criterion_id=>$score)
32
+			// 			{
33
+			$existe_ya = DB::table('activity_criterion')->where('activity_id', $activity_id)->where('criterion_id', $criterion_id)->first();
34
+			if (empty($existe_ya)) {
35
+				if ($activity_antes == $activity_id) {
38 36
 					DB::table('activity_criterion')->insert(
39
-					array("activity_id"=>$activity_id,
40
-						  "criterion_id"=>$criterion_id,
41
-						  "expected_percentage_students_achieving"=>$expected_percentage_students_achieving,
42
-						  "expected_student_score"=>$expected_student_score
43
-						  )
44
-						);
45
-				}
46
-				else
47
-				{
48
-					$activity_antes=$activity_id;
37
+						array(
38
+							"activity_id" => $activity_id,
39
+							"criterion_id" => $criterion_id,
40
+							"expected_percentage_students_achieving" => $expected_percentage_students_achieving,
41
+							"expected_student_score" => $expected_student_score
42
+						)
43
+					);
44
+				} else {
45
+					$activity_antes = $activity_id;
49 46
 					DB::table('activity_criterion')->insert(
50
-					array("activity_id"=>$activity_id,
51
-						  "criterion_id"=>$criterion_id,
52
-						  "expected_percentage_students_achieving"=>$expected_percentage_students_achieving,
53
-						  "expected_student_score"=>$expected_student_score,
54
-						  "transformative_actions"=>$transformative_actions,
55
-						  "assessment_comments"=>$assessment_comments
56
-						  )
57
-						);				
47
+						array(
48
+							"activity_id" => $activity_id,
49
+							"criterion_id" => $criterion_id,
50
+							"expected_percentage_students_achieving" => $expected_percentage_students_achieving,
51
+							"expected_student_score" => $expected_student_score,
52
+							"transformative_actions" => $transformative_actions,
53
+							"assessment_comments" => $assessment_comments
54
+						)
55
+					);
58 56
 				}
59
-				print $activity_id.':'.$criterion_id;print"\n";
57
+				print $activity_id . ':' . $criterion_id;
58
+				print "\n";
60 59
 			}
61
-// 				$i++;
62
-// 			}
60
+			// 				$i++;
61
+			// 			}
63 62
 		}
64
-    	
65
-//     exit();
66
-    	$assessments=DB::table('assessments')->get();
67
-    $i=0;
68
-		foreach ($assessments as $assessment)
69
-		{
70
-// 			var_dump($assessment);exit();
71
-			$student_id=$assessment->student_id;
72
-			$activity_id=$assessment->activity_id;
73
-			$datos=json_decode($assessment->scores, true);
74
-// 			$criterion=(array)DB::table('activity_criterion')->where('activity_id', $activity_id)->first();
75
-// 			var_dump($rubric);exit();
76
-// 			$criterion_id=$criterion["criterion_id"];
77
-// 			print_r($datos);
78
-// 			print"\n";
79
-// 			print $rubric->id;print"\t";
80
-			foreach($datos as $criterion_id=>$score)
81
-			{
82
-// 				print $dato["id"];print"\n";
83
-// 				var_dump($new_criterion);
84
-				$activity_criterion=DB::table('activity_criterion')->where('criterion_id', $criterion_id)->where('activity_id', $activity_id)->first();
85
-				if(empty($activity_criterion))
86
-				{
87
-// 					var_dump($criterion_id);
63
+
64
+		//     exit();
65
+		$assessments = DB::table('assessments')->get();
66
+		$i = 0;
67
+		foreach ($assessments as $assessment) {
68
+			// 			var_dump($assessment);exit();
69
+			$student_id = $assessment->student_id;
70
+			$activity_id = $assessment->activity_id;
71
+			$datos = json_decode($assessment->scores, true);
72
+			// 			$criterion=(array)DB::table('activity_criterion')->where('activity_id', $activity_id)->first();
73
+			// 			var_dump($rubric);exit();
74
+			// 			$criterion_id=$criterion["criterion_id"];
75
+			// 			print_r($datos);
76
+			// 			print"\n";
77
+			// 			print $rubric->id;print"\t";
78
+			foreach ($datos as $criterion_id => $score) {
79
+				// 				print $dato["id"];print"\n";
80
+				// 				var_dump($criterion);
81
+				$activity_criterion = DB::table('activity_criterion')->where('criterion_id', $criterion_id)->where('activity_id', $activity_id)->first();
82
+				if (empty($activity_criterion)) {
83
+					// 					var_dump($criterion_id);
88 84
 					var_dump($assessment);
89
-// 					$activities=DB::table('activities')->where('id', $activity_id)->first();
90
-// 					$criterion_rubric=DB::table('new_criterion_rubric')->where('criterion_id', $criterion_id)->first();
91
-// 					var_dump($activities);
92
-// 					var_dump($criterion_rubric);
93
-// 					exit();
94
-					$activity_criterion_id=DB::table('activity_criterion')->insertGetId(
95
-						array("activity_id"=>$activity_id,
96
-							  "criterion_id"=>$criterion_id,
97
-							  "transformative_actions"=>$transformative_actions,
98
-							  "assessment_comments"=>$assessment_comments
99
-							  )
100
-						);				
101
-					
102
-				}
103
-				else $activity_criterion_id=$activity_criterion->id;
104
-				$existe_ya=DB::table('new_assessments')->where('student_id', $student_id)->where('activity_criterion_id', $activity_criterion_id)->first();
105
-				if(empty($existe_ya))
106
-				{
107
-					DB::table('new_assessments')->insert(array("student_id"=>$student_id,"activity_criterion_id"=>$activity_criterion_id,'score'=>$score));
108
-					print".";
85
+					// 					$activities=DB::table('activities')->where('id', $activity_id)->first();
86
+					// 					$criterion_rubric=DB::table('criterion_rubric')->where('criterion_id', $criterion_id)->first();
87
+					// 					var_dump($activities);
88
+					// 					var_dump($criterion_rubric);
89
+					// 					exit();
90
+					$activity_criterion_id = DB::table('activity_criterion')->insertGetId(
91
+						array(
92
+							"activity_id" => $activity_id,
93
+							"criterion_id" => $criterion_id,
94
+							"transformative_actions" => $transformative_actions,
95
+							"assessment_comments" => $assessment_comments
96
+						)
97
+					);
98
+				} else $activity_criterion_id = $activity_criterion->id;
99
+				$existe_ya = DB::table('assessments')->where('student_id', $student_id)->where('activity_criterion_id', $activity_criterion_id)->first();
100
+				if (empty($existe_ya)) {
101
+					DB::table('assessments')->insert(array("student_id" => $student_id, "activity_criterion_id" => $activity_criterion_id, 'score' => $score));
102
+					print ".";
109 103
 				}
110 104
 			}
111
-// 			print $activity_id.':'.$criterion_id;print"\n";
105
+			// 			print $activity_id.':'.$criterion_id;print"\n";
112 106
 
113 107
 			$i++;
114 108
 		}
115 109
 
116 110
 
117
-// 		$course = Rubric::where('code', $code)->where('number', $number)->where('section', $section)->where('semester_id', $semester_id)->first();
111
+		// 		$course = Rubric::where('code', $code)->where('number', $number)->where('section', $section)->where('semester_id', $semester_id)->first();
118 112
 
119 113
 
120 114
 
121 115
 
122 116
 	}
123
-
124
-
125
-}
117
+}

+ 62
- 73
app/database/seeds/FillNewCriterionRubric.php 查看文件

@@ -1,94 +1,83 @@
1 1
 <?php
2 2
 
3
-class FillNewCriterionRubric extends Seeder {
3
+class FillNewCriterionRubric extends Seeder
4
+{
4 5
 
5
-    public function run()
6
-    {
7
-    	$rubrics=DB::table('rubrics')->get();
8
-    $i=0;
9
-		foreach ($rubrics as $rubric)
10
-		{
11
-			$datos=json_decode($rubric->contents, true);
12
-// 			print_r($datos);
13
-// 			print"\n";
14
-// 			print $rubric->id;print"\t";
15
-// 			if($rubric->id==29){var_dump($datos);}
16
-			foreach($datos as $dato)
17
-			{
18
-				if($rubric->id==29){print $dato["id"];print"Entrando\n";}
19
-				$new_criterion=(array)DB::table('criteria')->where('id', $dato["id"])->first();
20
-// 				var_dump($new_criterion);
21
-				$program_id=(array)DB::table('courses')
22
-				->join('activities', 'courses.id', '=', 'activities.course_id')
23
-				->join('new_rubric_activity', 'new_rubric_activity.activity_id', '=', 'activities.id')
24
-				->select('courses.program_id')
25
-				->where('new_rubric_activity.rubric_id',$rubric->id)
26
-				->first();
27
-				if(empty($program_id))$program_id['program_id']=1;
28
-	// 			else var_dump($program_id);
6
+	public function run()
7
+	{
8
+		$rubrics = DB::table('rubrics')->get();
9
+		$i = 0;
10
+		foreach ($rubrics as $rubric) {
11
+			$datos = json_decode($rubric->contents, true);
12
+			// 			print_r($datos);
13
+			// 			print"\n";
14
+			// 			print $rubric->id;print"\t";
15
+			// 			if($rubric->id==29){var_dump($datos);}
16
+			foreach ($datos as $dato) {
17
+				if ($rubric->id == 29) {
18
+					print $dato["id"];
19
+					print "Entrando\n";
20
+				}
21
+				$criterion = (array)DB::table('criteria')->where('id', $dato["id"])->first();
22
+				// 				var_dump($criterion);
23
+				$program_id = (array)DB::table('courses')
24
+					->join('activities', 'courses.id', '=', 'activities.course_id')
25
+					->join('rubric_activity', 'rubric_activity.activity_id', '=', 'activities.id')
26
+					->select('courses.program_id')
27
+					->where('rubric_activity.rubric_id', $rubric->id)
28
+					->first();
29
+				if (empty($program_id)) $program_id['program_id'] = 1;
30
+				// 			else var_dump($program_id);
29 31
 
30
-// 				var_dump($program_id);
31
-// 				var_dump($new_criterion);
32
-				if(!empty($new_criterion))
33
-				{
34
-					$existe=(array)DB::table('objectives')->where('id', $new_criterion["id"])->first();
35
-					$objective_id=$new_criterion["id"];
36
-					if(empty($existe))
37
-					{
38
-						$existe4=(array)DB::table('objectives')->where('program_id', $program_id['program_id'])->where('text', $new_criterion["name"])->first();
39
-	// 					print_r($existe4);print"\n";
40
-						if(!empty($existe4))
41
-						{
42
-	// 						DB::table('objectives')->insert(array("id"=> $new_criterion["id"],"program_id"=>$program_id['program_id'],"text"=>$new_criterion["name"],'outcome_id'=>$new_criterion['outcome_id']));
43
-							$objective_id=$existe4["id"];
44
-						}
45
-						else 
46
-						{
32
+				// 				var_dump($program_id);
33
+				// 				var_dump($criterion);
34
+				if (!empty($criterion)) {
35
+					$existe = (array)DB::table('objectives')->where('id', $criterion["id"])->first();
36
+					$objective_id = $criterion["id"];
37
+					if (empty($existe)) {
38
+						$existe4 = (array)DB::table('objectives')->where('program_id', $program_id['program_id'])->where('text', $criterion["name"])->first();
39
+						// 					print_r($existe4);print"\n";
40
+						if (!empty($existe4)) {
41
+							// 						DB::table('objectives')->insert(array("id"=> $criterion["id"],"program_id"=>$program_id['program_id'],"text"=>$criterion["name"],'outcome_id'=>$criterion['outcome_id']));
42
+							$objective_id = $existe4["id"];
43
+						} else {
47 44
 							print "A crear entrada en objectives:  $objective_id";
48
-// 							var_dump(array("id"=> $objective_id,"program_id"=>$program_id['program_id'],"text"=>$new_criterion["name"],'outcome_id'=>$new_criterion['outcome_id']));
49
-							DB::table('objectives')->insert(array("id"=> $objective_id,"program_id"=>$program_id['program_id'],"text"=>$new_criterion["name"],'outcome_id'=>$new_criterion['outcome_id']));
45
+							// 							var_dump(array("id"=> $objective_id,"program_id"=>$program_id['program_id'],"text"=>$criterion["name"],'outcome_id'=>$criterion['outcome_id']));
46
+							DB::table('objectives')->insert(array("id" => $objective_id, "program_id" => $program_id['program_id'], "text" => $criterion["name"], 'outcome_id' => $criterion['outcome_id']));
50 47
 						}
51
-					}
52
-					else
53
-					{
54
-						$existe4=(array)DB::table('objectives')->where('program_id', $program_id['program_id'])->where('text', $new_criterion["name"])->first();
55
-	// 					print_r($existe4);print"\n";
56
-						if(empty($existe4))
57
-						{
58
-							$objective_id=DB::table('objectives')->insertGetId(array("program_id"=>$program_id['program_id'],"text"=>$new_criterion["name"],'outcome_id'=>$new_criterion['outcome_id']));
48
+					} else {
49
+						$existe4 = (array)DB::table('objectives')->where('program_id', $program_id['program_id'])->where('text', $criterion["name"])->first();
50
+						// 					print_r($existe4);print"\n";
51
+						if (empty($existe4)) {
52
+							$objective_id = DB::table('objectives')->insertGetId(array("program_id" => $program_id['program_id'], "text" => $criterion["name"], 'outcome_id' => $criterion['outcome_id']));
59 53
 						}
60
-
61 54
 					}
62
-					$new_criterion["objective_id"]=$objective_id;
63
-					unset($new_criterion['outcome_id']);
64
-// 					var_dump($new_criterion);
65
-					$existe2=(array)DB::table('new_criteria')->where('id', $new_criterion["id"])->first();
66
-					if(empty($existe2))
67
-					{
68
-						DB::table('new_criteria')->insert($new_criterion);
55
+					$criterion["objective_id"] = $objective_id;
56
+					unset($criterion['outcome_id']);
57
+					// 					var_dump($criterion);
58
+					$existe2 = (array)DB::table('criteria')->where('id', $criterion["id"])->first();
59
+					if (empty($existe2)) {
60
+						DB::table('criteria')->insert($criterion);
69 61
 					}
70
-					$existe3=(array)DB::table('new_criterion_rubric')->where('criterion_id', $new_criterion["id"])->where('rubric_id', $rubric->id)->first();
71
-					if(empty($existe3))
72
-					{
73
-						DB::table('new_criterion_rubric')->insert(
74
-						array('criterion_id' => $dato["id"], 'rubric_id' => $rubric->id)
62
+					$existe3 = (array)DB::table('criterion_rubric')->where('criterion_id', $criterion["id"])->where('rubric_id', $rubric->id)->first();
63
+					if (empty($existe3)) {
64
+						DB::table('criterion_rubric')->insert(
65
+							array('criterion_id' => $dato["id"], 'rubric_id' => $rubric->id)
75 66
 						);
76 67
 					}
77 68
 				}
78
-	// 			if($i)exit();
79
-		
69
+				// 			if($i)exit();
70
+
80 71
 			}
81
-// 			if($rubric->id==29){exit();}
82
-		$i++;
72
+			// 			if($rubric->id==29){exit();}
73
+			$i++;
83 74
 		}
84 75
 
85 76
 
86
-// 		$course = Rubric::where('code', $code)->where('number', $number)->where('section', $section)->where('semester_id', $semester_id)->first();
77
+		// 		$course = Rubric::where('code', $code)->where('number', $number)->where('section', $section)->where('semester_id', $semester_id)->first();
87 78
 
88 79
 
89 80
 
90 81
 
91 82
 	}
92
-
93
-
94
-}
83
+}

+ 5
- 7
app/database/unusedMigrations/2020_10_05_130252_add_max_score_num_scales_new_criteria_table.php 查看文件

@@ -3,7 +3,8 @@
3 3
 use Illuminate\Database\Schema\Blueprint;
4 4
 use Illuminate\Database\Migrations\Migration;
5 5
 
6
-class AddMaxScoreNumScalesNewCriteriaTable extends Migration {
6
+class AddMaxScoreNumScalesNewCriteriaTable extends Migration
7
+{
7 8
 
8 9
 	/**
9 10
 	 * Run the migrations.
@@ -12,8 +13,7 @@ class AddMaxScoreNumScalesNewCriteriaTable extends Migration {
12 13
 	 */
13 14
 	public function up()
14 15
 	{
15
-		Schema::table('new_criteria', function(Blueprint $table)
16
-		{
16
+		Schema::table('criteria', function (Blueprint $table) {
17 17
 			$table->integer('maximum_score')->after('name');;
18 18
 			$table->integer('number_of_scales')->after('maximum_score');;
19 19
 		});
@@ -26,10 +26,8 @@ class AddMaxScoreNumScalesNewCriteriaTable extends Migration {
26 26
 	 */
27 27
 	public function down()
28 28
 	{
29
-		Schema::table('new_criteria', function(Blueprint $table)
30
-		{
31
-    		$table->dropColumn(array('maximum_score', 'number_of_scales'));
29
+		Schema::table('criteria', function (Blueprint $table) {
30
+			$table->dropColumn(array('maximum_score', 'number_of_scales'));
32 31
 		});
33 32
 	}
34
-
35 33
 }

+ 2
- 2
app/database/unusedMigrations/2020_10_08_203557_create_new_criteria_table2.php 查看文件

@@ -14,7 +14,7 @@ class CreateNewCriteriaTable2 extends Migration
14 14
 	 */
15 15
 	public function up()
16 16
 	{
17
-		Schema::table('new_criteria', function ($table) {
17
+		Schema::table('criteria', function ($table) {
18 18
 			$table->integer('outcome_id')->unsigned();
19 19
 
20 20
 			$table->foreign('outcome_id')->references('id')->on('outcomes')->onDelete('cascade')->onUpdate('cascade');
@@ -29,7 +29,7 @@ class CreateNewCriteriaTable2 extends Migration
29 29
 	 */
30 30
 	public function down()
31 31
 	{
32
-		Schema::table('new_criteria', function ($table) {
32
+		Schema::table('criteria', function ($table) {
33 33
 			$table->dropColumn('outcome_id');
34 34
 		});
35 35
 	}

+ 2
- 2
app/database/unusedMigrations/2020_10_08_215013_drop_objective_id_new_criteria.php 查看文件

@@ -13,7 +13,7 @@ class DropObjectiveIdNewCriteria extends Migration
13 13
 	 */
14 14
 	public function up()
15 15
 	{
16
-		Schema::table('new_criteria', function ($table) {
16
+		Schema::table('criteria', function ($table) {
17 17
 			$table->integer('objective_id')->nullable();
18 18
 		});
19 19
 	}
@@ -25,7 +25,7 @@ class DropObjectiveIdNewCriteria extends Migration
25 25
 	 */
26 26
 	public function down()
27 27
 	{
28
-		Schema::table('new_criteria', function ($table) {
28
+		Schema::table('criteria', function ($table) {
29 29
 
30 30
 			$table->dropColumn('objective_id');
31 31
 		});

+ 1
- 1
app/database/unusedMigrations/2020_10_09_092810_drop_assessment_criteria.php 查看文件

@@ -17,7 +17,7 @@ class DropAssessmentCriteria extends Migration
17 17
 			$table->dropForeign('assessments_criterion_id_foreign');
18 18
 			$table->integer('criterion_id')->unsigned();
19 19
 
20
-			$table->foreign('criterion_id')->references('id')->on('new_criteria')->onDelete('cascade')->onUpdate('cascade');
20
+			$table->foreign('criterion_id')->references('id')->on('criteria')->onDelete('cascade')->onUpdate('cascade');
21 21
 		});
22 22
 	}
23 23
 

+ 1
- 1
app/database/unusedMigrations/2020_10_09_094503_add_criterion_to_assessment.php 查看文件

@@ -17,7 +17,7 @@ class AddCriterionToAssessment extends Migration
17 17
 
18 18
 
19 19
 
20
-				$table->foreign('criterion_id')->references('id')->on('new_criteria')->onDelete('cascade')->onUpdate('cascade');
20
+				$table->foreign('criterion_id')->references('id')->on('criteria')->onDelete('cascade')->onUpdate('cascade');
21 21
 			});
22 22
 		}
23 23
 	}

+ 5
- 6
app/models/Activity.php 查看文件

@@ -10,8 +10,8 @@ class Activity extends Eloquent
10 10
 
11 11
   public function rubric()
12 12
   {
13
-//     return $this->belongsTo('Rubric');
14
-    return $this->belongsToMany('Rubric','new_rubric_activity');
13
+    //     return $this->belongsTo('Rubric');
14
+    return $this->belongsToMany('Rubric', 'rubric_activity');
15 15
   }
16 16
 
17 17
   public function course()
@@ -27,19 +27,18 @@ class Activity extends Eloquent
27 27
   // cap_array
28 28
   public function getCapArrayAttribute($value)
29 29
   {
30
-      return json_decode($this->criteria_achieved_percentage, true);
30
+    return json_decode($this->criteria_achieved_percentage, true);
31 31
   }
32 32
 
33 33
   // o_ach_array
34 34
   public function getOAchArrayAttribute($value)
35 35
   {
36
-      return json_decode($this->outcomes_achieved, true);
36
+    return json_decode($this->outcomes_achieved, true);
37 37
   }
38 38
 
39 39
   // o_att_array
40 40
   public function getOAttArrayAttribute($value)
41 41
   {
42
-      return json_decode($this->outcomes_attempted, true);
42
+    return json_decode($this->outcomes_attempted, true);
43 43
   }
44
-
45 44
 }

+ 44
- 52
app/models/Course.php 查看文件

@@ -12,7 +12,7 @@ class Course extends Eloquent
12 12
 
13 13
   public function students()
14 14
   {
15
-  	return $this->belongsToMany('Student')->orderBy('name', 'asc')->withTimestamps();
15
+    return $this->belongsToMany('Student')->orderBy('name', 'asc')->withTimestamps();
16 16
   }
17 17
 
18 18
   public function user()
@@ -28,7 +28,7 @@ class Course extends Eloquent
28 28
 
29 29
   public function activity()
30 30
   {
31
-      return $this->belongsTo('Activity');
31
+    return $this->belongsTo('Activity');
32 32
   }
33 33
 
34 34
   public function assessedActivities()
@@ -39,59 +39,52 @@ class Course extends Eloquent
39 39
   public function publishedActivities()
40 40
   {
41 41
     return $this->hasMany('Activity')->whereNotNull('activities.outcomes_attempted')->where('activities.draft', 0)->orderBy('date', 'asc');
42
-
43 42
   }
44 43
 
45 44
   public function outcomes_attempted()
46 45
   {
47
-	return DB::table('courses')
48
-	    	->join('activities', 'activities.course_id', '=', 'courses.id')
49
-	    	->join('activity_criterion', 'activity_criterion.activity_id', '=', 'activities.id')
50
-	    	->join('new_criteria', 'activity_criterion.criterion_id', '=', 'new_criteria.id')
51
-	    	->join('criterion_objective_outcome', 'criterion_objective_outcome.criterion_id', '=', 'new_criteria.id')
52
-	    	->where('courses.id','=',$this->id)
53
-	    	->select('criterion_objective_outcome.outcome_id')
54
-	    	->distinct()
55
-	    	->orderBy('criterion_objective_outcome.outcome_id')
56
-	    	->get();
57
-
58
-//   	SELECT distinct cr.outcome_id FROM  courses c, activities a, activity_criterion ac, criteria cr WHERE c.id=a.course_id and a.id=ac.activity_id and ac.criterion_id=cr.id and c.id=1
59
-// 	return $this->id;
46
+    return DB::table('courses')
47
+      ->join('activities', 'activities.course_id', '=', 'courses.id')
48
+      ->join('activity_criterion', 'activity_criterion.activity_id', '=', 'activities.id')
49
+      ->join('criteria', 'activity_criterion.criterion_id', '=', 'criteria.id')
50
+      ->join('criterion_objective_outcome', 'criterion_objective_outcome.criterion_id', '=', 'criteria.id')
51
+      ->where('courses.id', '=', $this->id)
52
+      ->select('criterion_objective_outcome.outcome_id')
53
+      ->distinct()
54
+      ->orderBy('criterion_objective_outcome.outcome_id')
55
+      ->get();
56
+
57
+    //   	SELECT distinct cr.outcome_id FROM  courses c, activities a, activity_criterion ac, criteria cr WHERE c.id=a.course_id and a.id=ac.activity_id and ac.criterion_id=cr.id and c.id=1
58
+    // 	return $this->id;
60 59
   }
61 60
 
62 61
   public function outcomes_achieved()
63 62
   {
64
-		 $criteria=DB::table('new_criteria')
65
-	    	->join('activity_criterion', 'activity_criterion.criterion_id', '=', 'new_criteria.id')
66
-	    	->join('activities', 'activity_criterion.activity_id', '=', 'activities.id')
67
-	    	->join('courses', 'activities.course_id', '=', 'courses.id')
68
-	    	->join('criterion_objective_outcome', 'criterion_objective_outcome.criterion_id', '=', 'new_criteria.id')
69
-	    	->where('courses.id','=',$this->id)
70
-	    	->select('new_criteria.id','expected_percentage_students_achieving','activity_criterion.activity_id')
71
-	    	->distinct()
72
-	    	->get()
73
-			;
74
-
75
-		$conteo=0;
76
-		foreach($criteria as $criterion)
77
-		{	
78
-			$students_attempted=Criterion::students_attempted($criterion->id, $criterion->activity_id);
79
-			$students_achieved=Criterion::students_achieved($criterion->id, $criterion->activity_id);
80
-		
81
-			if($students_attempted)
82
-			{
83
-				$percentage_students_who_achieved=100.0*$students_achieved/$students_attempted;
84
-			}
85
-			else
86
-			{
87
-				$percentage_students_who_achieved=0;
88
-			}
89
-			if($percentage_students_who_achieved>=$criterion->expected_percentage_students_achieving)
90
-			{
91
-				$conteo++;
92
-			}
93
-		}		
94
-		return $conteo;
63
+    $criteria = DB::table('criteria')
64
+      ->join('activity_criterion', 'activity_criterion.criterion_id', '=', 'criteria.id')
65
+      ->join('activities', 'activity_criterion.activity_id', '=', 'activities.id')
66
+      ->join('courses', 'activities.course_id', '=', 'courses.id')
67
+      ->join('criterion_objective_outcome', 'criterion_objective_outcome.criterion_id', '=', 'criteria.id')
68
+      ->where('courses.id', '=', $this->id)
69
+      ->select('criteria.id', 'expected_percentage_students_achieving', 'activity_criterion.activity_id')
70
+      ->distinct()
71
+      ->get();
72
+
73
+    $conteo = 0;
74
+    foreach ($criteria as $criterion) {
75
+      $students_attempted = Criterion::students_attempted($criterion->id, $criterion->activity_id);
76
+      $students_achieved = Criterion::students_achieved($criterion->id, $criterion->activity_id);
77
+
78
+      if ($students_attempted) {
79
+        $percentage_students_who_achieved = 100.0 * $students_achieved / $students_attempted;
80
+      } else {
81
+        $percentage_students_who_achieved = 0;
82
+      }
83
+      if ($percentage_students_who_achieved >= $criterion->expected_percentage_students_achieving) {
84
+        $conteo++;
85
+      }
86
+    }
87
+    return $conteo;
95 88
   }
96 89
 
97 90
   public function semester()
@@ -99,11 +92,10 @@ class Course extends Eloquent
99 92
     return $this->belongsTo('Semester');
100 93
   }
101 94
 
102
-  public function sectionsWithOutcome($outcome_id) 
95
+  public function sectionsWithOutcome($outcome_id)
103 96
   {
104
-      return Course::has('activities')->with(array('activities'=>function($query) use (&$outcome_id){
105
-        $query->where('outcomes_attempted', 'not like', '\'%"'.$outcome_id.'":0%\'');
106
-      }))->where('code',$this->code)->where('number',$this->number)->get();
107
-
97
+    return Course::has('activities')->with(array('activities' => function ($query) use (&$outcome_id) {
98
+      $query->where('outcomes_attempted', 'not like', '\'%"' . $outcome_id . '":0%\'');
99
+    }))->where('code', $this->code)->where('number', $this->number)->get();
108 100
   }
109 101
 }

+ 52
- 55
app/models/Criterion.php 查看文件

@@ -4,28 +4,28 @@ use Illuminate\Database\Eloquent\SoftDeletingTrait;
4 4
 
5 5
 class Criterion extends Eloquent
6 6
 {
7
-    use SoftDeletingTrait;
8
-    protected $dates = ['deleted_at'];
7
+	use SoftDeletingTrait;
8
+	protected $dates = ['deleted_at'];
9 9
 
10
-    protected $table = 'new_criteria';
10
+	protected $table = 'criteria';
11 11
 
12
-    public function outcomes()
13
-    {
14
-//	    return $this->belongs('Objective')->belongs('Outcome');
15
-//	    TODO: Changes here
16
-//		return $this->belongs('Outcome');
17
-        return $this->hasManyThrough('Outcome', 'Objective');
18
-    }
12
+	public function outcomes()
13
+	{
14
+		//	    return $this->belongs('Objective')->belongs('Outcome');
15
+		//	    TODO: Changes here
16
+		//		return $this->belongs('Outcome');
17
+		return $this->hasManyThrough('Outcome', 'Objective');
18
+	}
19 19
 
20
-    public function objectives()
21
-    {
22
-        return $this->belongsToMany('Objective');
23
-    }
20
+	public function objectives()
21
+	{
22
+		return $this->belongsToMany('Objective');
23
+	}
24 24
 
25
-    public function rubrics()
26
-    {
27
-        return $this->belongsToMany('Rubric', 'new_criterion_rubric');
28
-    }
25
+	public function rubrics()
26
+	{
27
+		return $this->belongsToMany('Rubric', 'criterion_rubric');
28
+	}
29 29
 
30 30
 	/**
31 31
 	 * Return the program that the criterion belongs to
@@ -37,65 +37,62 @@ class Criterion extends Eloquent
37 37
 		return $this->belongsTo('Program');
38 38
 	}
39 39
 
40
-// 	public function activities()
41
-// 	{
42
-// 		return $this->hasManyThrough('Activity','activity_criterion');
43
-// 	}
44
-// 
40
+	// 	public function activities()
41
+	// 	{
42
+	// 		return $this->hasManyThrough('Activity','activity_criterion');
43
+	// 	}
44
+	// 
45 45
 	public function subcriteria()
46 46
 	{
47 47
 		return json_decode($this->subcriteria);
48 48
 	}
49
-	
50
-	public static function students_attempted($criterion_id,$activity_id)	
49
+
50
+	public static function students_attempted($criterion_id, $activity_id)
51 51
 	{
52
-		$students_attempted=0;
53
-// 		var_dump($criterion_id);
54
-// 		var_dump($semester);
55
-// 		exit();
56
-		$activities_criterions=DB::table('activity_criterion')
52
+		$students_attempted = 0;
53
+		// 		var_dump($criterion_id);
54
+		// 		var_dump($semester);
55
+		// 		exit();
56
+		$activities_criterions = DB::table('activity_criterion')
57 57
 			->join('activities', 'activity_criterion.activity_id', '=', 'activities.id')
58 58
 			->join('courses', 'activities.course_id', '=', 'courses.id')
59
-			->where('activities.id','=',$activity_id)
60
-			->where('activity_criterion.criterion_id','=',$criterion_id)
59
+			->where('activities.id', '=', $activity_id)
60
+			->where('activity_criterion.criterion_id', '=', $criterion_id)
61 61
 			->select('activity_criterion.id')
62 62
 			->distinct()
63 63
 			->get();
64
-			
65
-		foreach($activities_criterions as $activity_criterion)
66
-		{
67
-		
68
-			 $students_attempted+=DB::table('new_assessments')
69
-				->join('activity_criterion', 'new_assessments.activity_criterion_id', '=', 'activity_criterion.id')
70
-				->where('activity_criterion.id',$activity_criterion->id)
64
+
65
+		foreach ($activities_criterions as $activity_criterion) {
66
+
67
+			$students_attempted += DB::table('assessments')
68
+				->join('activity_criterion', 'assessments.activity_criterion_id', '=', 'activity_criterion.id')
69
+				->where('activity_criterion.id', $activity_criterion->id)
71 70
 				->count();
72 71
 		}
73 72
 		return $students_attempted;
74 73
 	}
75 74
 
76
-	public static function students_achieved($criterion_id,$activity_id)	
75
+	public static function students_achieved($criterion_id, $activity_id)
77 76
 	{
78
-		$students_achieved=0;
79
-		$activities_criterions=DB::table('activity_criterion')
77
+		$students_achieved = 0;
78
+		$activities_criterions = DB::table('activity_criterion')
80 79
 			->join('activities', 'activity_criterion.activity_id', '=', 'activities.id')
81 80
 			->join('courses', 'activities.course_id', '=', 'courses.id')
82
-			->where('activities.id','=',$activity_id)
83
-			->where('activity_criterion.criterion_id','=',$criterion_id)
84
-			->select('activity_criterion.id','expected_student_score')
81
+			->where('activities.id', '=', $activity_id)
82
+			->where('activity_criterion.criterion_id', '=', $criterion_id)
83
+			->select('activity_criterion.id', 'expected_student_score')
85 84
 			->distinct()
86 85
 			->get();
87
-			
88
-		foreach($activities_criterions as $activity_criterion)
89
-		{
90
-		
91
-// 			$expected_student_score=DB::table('new_criteria')->where('id',$criterion_id)->select('expected_student_score')->get();
92
-			 $students_achieved+=DB::table('new_assessments')
93
-				->join('activity_criterion', 'new_assessments.activity_criterion_id', '=', 'activity_criterion.id')
94
-				->where('activity_criterion.id',$activity_criterion->id)
95
-				->where('new_assessments.score','>=',$activity_criterion->expected_student_score)
86
+
87
+		foreach ($activities_criterions as $activity_criterion) {
88
+
89
+			// 			$expected_student_score=DB::table('criteria')->where('id',$criterion_id)->select('expected_student_score')->get();
90
+			$students_achieved += DB::table('assessments')
91
+				->join('activity_criterion', 'assessments.activity_criterion_id', '=', 'activity_criterion.id')
92
+				->where('activity_criterion.id', $activity_criterion->id)
93
+				->where('assessments.score', '>=', $activity_criterion->expected_student_score)
96 94
 				->count();
97 95
 		}
98 96
 		return $students_achieved;
99 97
 	}
100
-
101 98
 }

+ 235
- 263
app/models/Outcome.php 查看文件

@@ -7,11 +7,11 @@ class Outcome extends Eloquent
7 7
 	use SoftDeletingTrait;
8 8
 	protected $dates = ['deleted_at'];
9 9
 
10
-	protected $fillable= array('name', 'definition');
10
+	protected $fillable = array('name', 'definition');
11 11
 
12 12
 	public function criteria()
13 13
 	{
14
-	   return $this->hasManyThrough('Criterion', 'Objective')->orderBy('name');
14
+		return $this->hasManyThrough('Criterion', 'Objective')->orderBy('name');
15 15
 	}
16 16
 
17 17
 	/**
@@ -21,214 +21,192 @@ class Outcome extends Eloquent
21 21
 	 */
22 22
 	public function objectives()
23 23
 	{
24
-	    return $this->hasMany('Objective');
25
-//		return $this->belongsToMany('Objective', 'objective_outcome');
24
+		return $this->hasMany('Objective');
25
+		//		return $this->belongsToMany('Objective', 'objective_outcome');
26 26
 	}
27
-// 	public function attempted($semester, $is_grad)
28
-// 	{
29
-// 		return DB::table('new_criteria')
30
-// 	    	->join('activity_criterion', 'activity_criterion.criterion_id', '=', 'new_criteria.id')
31
-// 	    	->join('activities', 'activity_criterion.activity_id', '=', 'activities.id')
32
-// 	    	->join('courses', 'activities.course_id', '=', 'courses.id')
33
-// 	    	->join('programs', 'programs.id', '=', 'courses.program_id')
34
-// 	    	->join('criterion_objective_outcome', 'criterion_objective_outcome.criterion_id', '=', 'new_criteria.id')
35
-// 	    	->where('criterion_objective_outcome.outcome_id','=',$this->id)
36
-// 	    	->where('programs.is_graduate','=',$is_grad)
37
-// 	    	->where('courses.semester_id','=',$semester)
38
-// 	    	->count(DB::raw('DISTINCT new_criteria.id,activity_criterion.activity_id'))
39
-// 			;
40
-//
41
-// 	}
42
-// 	public function attempted($semester, $is_grad)
43
-// 	{
44
-// 		 $criteria=DB::table('new_criteria')
45
-// 	    	->join('activity_criterion', 'activity_criterion.criterion_id', '=', 'new_criteria.id')
46
-// 	    	->join('activities', 'activity_criterion.activity_id', '=', 'activities.id')
47
-// 	    	->join('courses', 'activities.course_id', '=', 'courses.id')
48
-// 	    	->join('programs', 'programs.id', '=', 'courses.program_id')
49
-// 	    	->join('criterion_objective_outcome', 'criterion_objective_outcome.criterion_id', '=', 'new_criteria.id')
50
-// 	    	->where('criterion_objective_outcome.outcome_id','=',$this->id)
51
-// 	    	->where('programs.is_graduate','=',$is_grad)
52
-// 	    	->where('courses.semester_id','=',$semester)
53
-// 	    	->select('new_criteria.id','expected_percentage_students_achieving','activity_criterion.activity_id')
54
-// 	    	->distinct()
55
-// 	    	->get()
56
-// 			;
57
-// 		$conteo=0;
58
-// 		foreach($criteria as $criterion)
59
-// 		{
60
-// 			$students_attempted=Criterion::students_attempted($criterion->id, $criterion->activity_id);
61
-// 			if($students_attempted)
62
-// 			{
63
-// 				$conteo++;
64
-// 			}
65
-// 		}
66
-// 		return $conteo;
67
-// 	}
27
+	// 	public function attempted($semester, $is_grad)
28
+	// 	{
29
+	// 		return DB::table('criteria')
30
+	// 	    	->join('activity_criterion', 'activity_criterion.criterion_id', '=', 'criteria.id')
31
+	// 	    	->join('activities', 'activity_criterion.activity_id', '=', 'activities.id')
32
+	// 	    	->join('courses', 'activities.course_id', '=', 'courses.id')
33
+	// 	    	->join('programs', 'programs.id', '=', 'courses.program_id')
34
+	// 	    	->join('criterion_objective_outcome', 'criterion_objective_outcome.criterion_id', '=', 'criteria.id')
35
+	// 	    	->where('criterion_objective_outcome.outcome_id','=',$this->id)
36
+	// 	    	->where('programs.is_graduate','=',$is_grad)
37
+	// 	    	->where('courses.semester_id','=',$semester)
38
+	// 	    	->count(DB::raw('DISTINCT criteria.id,activity_criterion.activity_id'))
39
+	// 			;
40
+	//
41
+	// 	}
42
+	// 	public function attempted($semester, $is_grad)
43
+	// 	{
44
+	// 		 $criteria=DB::table('criteria')
45
+	// 	    	->join('activity_criterion', 'activity_criterion.criterion_id', '=', 'criteria.id')
46
+	// 	    	->join('activities', 'activity_criterion.activity_id', '=', 'activities.id')
47
+	// 	    	->join('courses', 'activities.course_id', '=', 'courses.id')
48
+	// 	    	->join('programs', 'programs.id', '=', 'courses.program_id')
49
+	// 	    	->join('criterion_objective_outcome', 'criterion_objective_outcome.criterion_id', '=', 'criteria.id')
50
+	// 	    	->where('criterion_objective_outcome.outcome_id','=',$this->id)
51
+	// 	    	->where('programs.is_graduate','=',$is_grad)
52
+	// 	    	->where('courses.semester_id','=',$semester)
53
+	// 	    	->select('criteria.id','expected_percentage_students_achieving','activity_criterion.activity_id')
54
+	// 	    	->distinct()
55
+	// 	    	->get()
56
+	// 			;
57
+	// 		$conteo=0;
58
+	// 		foreach($criteria as $criterion)
59
+	// 		{
60
+	// 			$students_attempted=Criterion::students_attempted($criterion->id, $criterion->activity_id);
61
+	// 			if($students_attempted)
62
+	// 			{
63
+	// 				$conteo++;
64
+	// 			}
65
+	// 		}
66
+	// 		return $conteo;
67
+	// 	}
68 68
 	public function active_by_semesters($selected_semesters, $level)
69 69
 	{
70
-		$min_start="9000-01-01 00:00:00";
71
-		$max_end="1000-01-01 00:00:00";
72
-		foreach($selected_semesters as $semester)
73
-		{
74
-			if($min_start>$semester->start)
75
-			{
76
-				$min_start=$semester->start;
70
+		$min_start = "9000-01-01 00:00:00";
71
+		$max_end = "1000-01-01 00:00:00";
72
+		foreach ($selected_semesters as $semester) {
73
+			if ($min_start > $semester->start) {
74
+				$min_start = $semester->start;
77 75
 			}
78
-			if($max_end<$semester->end)
79
-			{
80
-				$max_end=$semester->end;
76
+			if ($max_end < $semester->end) {
77
+				$max_end = $semester->end;
81 78
 			}
82 79
 		}
83
-		$outcomes = Outcome::where(function($query) use ($min_start)
84
-								   {
85
-										$query->where('deactivation_date', '>=', $min_start)
86
-											  ->orWhere('deactivation_date', null);
87
-								   })
88
-							->where('activation_date', '<=', $max_end)
89
-							->where(function($query2) use ($level)
90
-									{
91
-										$query2->where("level", $level+1)
92
-											   ->orWhere("level",3);
93
-									})
94
-							->orderBy('name', 'ASC')
95
-							->get();
80
+		$outcomes = Outcome::where(function ($query) use ($min_start) {
81
+			$query->where('deactivation_date', '>=', $min_start)
82
+				->orWhere('deactivation_date', null);
83
+		})
84
+			->where('activation_date', '<=', $max_end)
85
+			->where(function ($query2) use ($level) {
86
+				$query2->where("level", $level + 1)
87
+					->orWhere("level", 3);
88
+			})
89
+			->orderBy('name', 'ASC')
90
+			->get();
96 91
 
97
-// 		return array('outcomes'=>$outcomes,'outcomes_attempted'=>$outcomes_attempted, 'outcomes_achieved'=>$outcomes_achieved, 'attemptedProgramsPerOutcome'=>$attemptedProgramsPerOutcome, 'achievedProgramsPerOutcome'=>$achievedProgramsPerOutcome,'participating_programs'=>$participating_programs);
92
+		// 		return array('outcomes'=>$outcomes,'outcomes_attempted'=>$outcomes_attempted, 'outcomes_achieved'=>$outcomes_achieved, 'attemptedProgramsPerOutcome'=>$attemptedProgramsPerOutcome, 'achievedProgramsPerOutcome'=>$achievedProgramsPerOutcome,'participating_programs'=>$participating_programs);
98 93
 		return $outcomes;
99 94
 	}
100 95
 
101 96
 	public function programs_attempted($semesters)
102 97
 	{
103
-		$semesters_array=[];
104
-		foreach($semesters as $semester)
105
-		{
106
-			$semesters_array[]=$semester->id;
98
+		$semesters_array = [];
99
+		foreach ($semesters as $semester) {
100
+			$semesters_array[] = $semester->id;
107 101
 		}
108
-		 $programs=DB::table('programs')
109
-	    	->join('courses', 'programs.id', '=', 'courses.program_id')
110
-	    	->join('activities', 'activities.course_id', '=', 'courses.id')
111
-	    	->join('activity_criterion', 'activity_criterion.activity_id', '=', 'activities.id')
112
-	    	->join('new_criteria', 'activity_criterion.criterion_id', '=', 'new_criteria.id')
113
-	    	->join('criterion_objective_outcome', 'criterion_objective_outcome.criterion_id', '=', 'new_criteria.id')
114
-	    	->where('criterion_objective_outcome.outcome_id','=',$this->id)
115
-	    	->whereIn('courses.semester_id',$semesters_array)
116
-	    	->distinct()
117
-	    	->select('programs.id')
118
-	    	->get()
119
-			;
102
+		$programs = DB::table('programs')
103
+			->join('courses', 'programs.id', '=', 'courses.program_id')
104
+			->join('activities', 'activities.course_id', '=', 'courses.id')
105
+			->join('activity_criterion', 'activity_criterion.activity_id', '=', 'activities.id')
106
+			->join('criteria', 'activity_criterion.criterion_id', '=', 'criteria.id')
107
+			->join('criterion_objective_outcome', 'criterion_objective_outcome.criterion_id', '=', 'criteria.id')
108
+			->where('criterion_objective_outcome.outcome_id', '=', $this->id)
109
+			->whereIn('courses.semester_id', $semesters_array)
110
+			->distinct()
111
+			->select('programs.id')
112
+			->get();
120 113
 
121 114
 		return $programs;
122
-
123 115
 	}
124 116
 
125 117
 	public function attempted($semesters, $is_grad)
126 118
 	{
127
-		$semesters_array=[];
128
-		foreach($semesters as $semester)
129
-		{
130
-			$semesters_array[]=$semester->id;
119
+		$semesters_array = [];
120
+		foreach ($semesters as $semester) {
121
+			$semesters_array[] = $semester->id;
131 122
 		}
132
-		 $criteria=DB::table('new_criteria')
133
-	    	->join('activity_criterion', 'activity_criterion.criterion_id', '=', 'new_criteria.id')
134
-	    	->join('activities', 'activity_criterion.activity_id', '=', 'activities.id')
135
-	    	->join('courses', 'activities.course_id', '=', 'courses.id')
136
-	    	->join('programs', 'programs.id', '=', 'courses.program_id')
137
-	    	->join('criterion_objective_outcome', 'criterion_objective_outcome.criterion_id', '=', 'new_criteria.id')
138
-	    	->where('criterion_objective_outcome.outcome_id','=',$this->id)
139
-	    	->where('programs.is_graduate','=',$is_grad)
140
-	    	->whereIn('courses.semester_id',$semesters_array)
141
-	    	->select('new_criteria.id','expected_percentage_students_achieving','activity_criterion.activity_id')
142
-	    	->distinct()
143
-	    	->get()
144
-			;
145
-		$conteo=0;
146
-		foreach($criteria as $criterion)
147
-		{
148
-			$students_attempted=Criterion::students_attempted($criterion->id, $criterion->activity_id);
149
-			if($students_attempted)
150
-			{
123
+		$criteria = DB::table('criteria')
124
+			->join('activity_criterion', 'activity_criterion.criterion_id', '=', 'criteria.id')
125
+			->join('activities', 'activity_criterion.activity_id', '=', 'activities.id')
126
+			->join('courses', 'activities.course_id', '=', 'courses.id')
127
+			->join('programs', 'programs.id', '=', 'courses.program_id')
128
+			->join('criterion_objective_outcome', 'criterion_objective_outcome.criterion_id', '=', 'criteria.id')
129
+			->where('criterion_objective_outcome.outcome_id', '=', $this->id)
130
+			->where('programs.is_graduate', '=', $is_grad)
131
+			->whereIn('courses.semester_id', $semesters_array)
132
+			->select('criteria.id', 'expected_percentage_students_achieving', 'activity_criterion.activity_id')
133
+			->distinct()
134
+			->get();
135
+		$conteo = 0;
136
+		foreach ($criteria as $criterion) {
137
+			$students_attempted = Criterion::students_attempted($criterion->id, $criterion->activity_id);
138
+			if ($students_attempted) {
151 139
 				$conteo++;
152 140
 			}
153 141
 		}
154
-// 		var_dump($conteo);
155
-// 		exit();
142
+		// 		var_dump($conteo);
143
+		// 		exit();
156 144
 		return $conteo;
157 145
 	}
158 146
 
159 147
 	public function courses_attempted($courses)
160 148
 	{
161
-		$courses_array=[];
162
-		foreach($courses as $course)
163
-		{
164
-// 		var_dump($course);
165
-// 		exit();
166
-			$courses_array[]=$course->id;
149
+		$courses_array = [];
150
+		foreach ($courses as $course) {
151
+			// 		var_dump($course);
152
+			// 		exit();
153
+			$courses_array[] = $course->id;
167 154
 		}
168
-		 $criteria=DB::table('new_criteria')
169
-	    	->join('activity_criterion', 'activity_criterion.criterion_id', '=', 'new_criteria.id')
170
-	    	->join('activities', 'activity_criterion.activity_id', '=', 'activities.id')
171
-	    	->join('courses', 'activities.course_id', '=', 'courses.id')
172
-	    	->join('programs', 'programs.id', '=', 'courses.program_id')
173
-	    	->join('criterion_objective_outcome', 'criterion_objective_outcome.criterion_id', '=', 'new_criteria.id')
174
-	    	->where('criterion_objective_outcome.outcome_id','=',$this->id)
175
-	    	->whereIn('courses.id',$courses_array)
176
-	    	->select('new_criteria.id','expected_percentage_students_achieving','activity_criterion.activity_id')
177
-	    	->distinct()
178
-	    	->get()
179
-			;
180
-		$conteo=0;
181
-		foreach($criteria as $criterion)
182
-		{
183
-			$students_attempted=Criterion::students_attempted($criterion->id, $criterion->activity_id);
184
-			if($students_attempted)
185
-			{
155
+		//'expected_percentage_students_achieving'
156
+		$criteria = DB::table('criteria')
157
+			->join('activity_criterion', 'activity_criterion.criterion_id', '=', 'criteria.id')
158
+			->join('activities', 'activity_criterion.activity_id', '=', 'activities.id')
159
+			->join('courses', 'activities.course_id', '=', 'courses.id')
160
+			->join('programs', 'programs.id', '=', 'courses.program_id')
161
+			->join('criterion_objective_outcome', 'criterion_objective_outcome.criterion_id', '=', 'criteria.id')
162
+			->where('criterion_objective_outcome.outcome_id', '=', $this->id)
163
+			->whereIn('courses.id', $courses_array)
164
+			->select('criteria.id',  'activity_criterion.activity_id')
165
+			->distinct()
166
+			->get();
167
+		$conteo = 0;
168
+		foreach ($criteria as $criterion) {
169
+			$students_attempted = Criterion::students_attempted($criterion->id, $criterion->activity_id);
170
+			if ($students_attempted) {
186 171
 				$conteo++;
187 172
 			}
188 173
 		}
189
-// 		var_dump($conteo);
190
-// 		exit();
174
+		// 		var_dump($conteo);
175
+		// 		exit();
191 176
 		return $conteo;
192 177
 	}
193 178
 
194 179
 	public function courses_achieved($courses)
195 180
 	{
196
-		$courses_array=[];
197
-		foreach($courses as $course)
198
-		{
199
-			$courses_array[]=$course->id;
181
+		$courses_array = [];
182
+		foreach ($courses as $course) {
183
+			$courses_array[] = $course->id;
200 184
 		}
201
-
202
-		 $criteria=DB::table('new_criteria')
203
-	    	->join('activity_criterion', 'activity_criterion.criterion_id', '=', 'new_criteria.id')
204
-	    	->join('activities', 'activity_criterion.activity_id', '=', 'activities.id')
205
-	    	->join('courses', 'activities.course_id', '=', 'courses.id')
206
-	    	->join('programs', 'programs.id', '=', 'courses.program_id')
207
-	    	->join('criterion_objective_outcome', 'criterion_objective_outcome.criterion_id', '=', 'new_criteria.id')
208
-	    	->where('criterion_objective_outcome.outcome_id','=',$this->id)
209
-	    	->whereIn('courses.id',$courses_array)
210
-	    	->select('new_criteria.id','expected_percentage_students_achieving','activity_criterion.activity_id')
211
-	    	->distinct()
212
-	    	->get()
213
-			;
185
+		//'expected_percentage_students_achieving',
186
+		$criteria = DB::table('criteria')
187
+			->join('activity_criterion', 'activity_criterion.criterion_id', '=', 'criteria.id')
188
+			->join('activities', 'activity_criterion.activity_id', '=', 'activities.id')
189
+			->join('courses', 'activities.course_id', '=', 'courses.id')
190
+			->join('programs', 'programs.id', '=', 'courses.program_id')
191
+			->join('criterion_objective_outcome', 'criterion_objective_outcome.criterion_id', '=', 'criteria.id')
192
+			->where('criterion_objective_outcome.outcome_id', '=', $this->id)
193
+			->whereIn('courses.id', $courses_array)
194
+			->select('criteria.id',  'activity_criterion.activity_id')
195
+			->distinct()
196
+			->get();
214 197
 
215 198
 
216
-		$conteo=0;
217
-		foreach($criteria as $criterion)
218
-		{
219
-			$students_attempted=Criterion::students_attempted($criterion->id, $criterion->activity_id);
220
-			$students_achieved=Criterion::students_achieved($criterion->id, $criterion->activity_id);
199
+		$conteo = 0;
200
+		foreach ($criteria as $criterion) {
201
+			$students_attempted = Criterion::students_attempted($criterion->id, $criterion->activity_id);
202
+			$students_achieved = Criterion::students_achieved($criterion->id, $criterion->activity_id);
221 203
 
222
-			if($students_attempted)
223
-			{
224
-				$percentage_students_who_achieved=100.0*$students_achieved/$students_attempted;
225
-			}
226
-			else
227
-			{
228
-				$percentage_students_who_achieved=0;
204
+			if ($students_attempted) {
205
+				$percentage_students_who_achieved = 100.0 * $students_achieved / $students_attempted;
206
+			} else {
207
+				$percentage_students_who_achieved = 0;
229 208
 			}
230
-			if($percentage_students_who_achieved>=$criterion->expected_percentage_students_achieving)
231
-			{
209
+			if ($percentage_students_who_achieved >= $criterion->expected_percentage_students_achieving) {
232 210
 				$conteo++;
233 211
 			}
234 212
 		}
@@ -237,44 +215,38 @@ class Outcome extends Eloquent
237 215
 
238 216
 	public function achieved($semesters, $is_grad)
239 217
 	{
240
-		$semesters_array=[];
241
-		foreach($semesters as $semester)
242
-		{
243
-			$semesters_array[]=$semester->id;
218
+		$semesters_array = [];
219
+		foreach ($semesters as $semester) {
220
+			$semesters_array[] = $semester->id;
244 221
 		}
245 222
 
246
-//   DB::enableQueryLog();
247
-		 $criteria=DB::table('new_criteria')
248
-	    	->join('activity_criterion', 'activity_criterion.criterion_id', '=', 'new_criteria.id')
249
-	    	->join('activities', 'activity_criterion.activity_id', '=', 'activities.id')
250
-	    	->join('courses', 'activities.course_id', '=', 'courses.id')
251
-	    	->join('programs', 'programs.id', '=', 'courses.program_id')
252
-	    	->join('criterion_objective_outcome', 'criterion_objective_outcome.criterion_id', '=', 'new_criteria.id')
253
-	    	->where('criterion_objective_outcome.outcome_id','=',$this->id)
254
-	    	->where('programs.is_graduate','=',$is_grad)
255
-	    	->whereIn('courses.semester_id',$semesters_array)
256
-	    	->select('new_criteria.id','expected_percentage_students_achieving','activity_criterion.activity_id')
257
-	    	->distinct()
258
-	    	->get()
259
-			;
260
-// 		dd(DB::getQueryLog());
223
+		//   DB::enableQueryLog();
224
+		//'expected_percentage_students_achieving'
225
+		$criteria = DB::table('criteria')
226
+			->join('activity_criterion', 'activity_criterion.criterion_id', '=', 'criteria.id')
227
+			->join('activities', 'activity_criterion.activity_id', '=', 'activities.id')
228
+			->join('courses', 'activities.course_id', '=', 'courses.id')
229
+			->join('programs', 'programs.id', '=', 'courses.program_id')
230
+			->join('criterion_objective_outcome', 'criterion_objective_outcome.criterion_id', '=', 'criteria.id')
231
+			->where('criterion_objective_outcome.outcome_id', '=', $this->id)
232
+			->where('programs.is_graduate', '=', $is_grad)
233
+			->whereIn('courses.semester_id', $semesters_array)
234
+			->select('criteria.id',  'activity_criterion.activity_id')
235
+			->distinct()
236
+			->get();
237
+		// 		dd(DB::getQueryLog());
261 238
 
262
-		$conteo=0;
263
-		foreach($criteria as $criterion)
264
-		{
265
-			$students_attempted=Criterion::students_attempted($criterion->id, $criterion->activity_id);
266
-			$students_achieved=Criterion::students_achieved($criterion->id, $criterion->activity_id);
239
+		$conteo = 0;
240
+		foreach ($criteria as $criterion) {
241
+			$students_attempted = Criterion::students_attempted($criterion->id, $criterion->activity_id);
242
+			$students_achieved = Criterion::students_achieved($criterion->id, $criterion->activity_id);
267 243
 
268
-			if($students_attempted)
269
-			{
270
-				$percentage_students_who_achieved=100.0*$students_achieved/$students_attempted;
244
+			if ($students_attempted) {
245
+				$percentage_students_who_achieved = 100.0 * $students_achieved / $students_attempted;
246
+			} else {
247
+				$percentage_students_who_achieved = 0;
271 248
 			}
272
-			else
273
-			{
274
-				$percentage_students_who_achieved=0;
275
-			}
276
-			if($percentage_students_who_achieved>=$criterion->expected_percentage_students_achieving)
277
-			{
249
+			if ($percentage_students_who_achieved >= $criterion->expected_percentage_students_achieving) {
278 250
 				$conteo++;
279 251
 			}
280 252
 		}
@@ -282,68 +254,68 @@ class Outcome extends Eloquent
282 254
 	}
283 255
 
284 256
 
285
-// 	public function achieved($semester, $is_grad)
286
-// 	{
287
-//
288
-// //   DB::enableQueryLog();
289
-// 		 $criteria=DB::table('new_criteria')
290
-// 	    	->join('activity_criterion', 'activity_criterion.criterion_id', '=', 'new_criteria.id')
291
-// 	    	->join('activities', 'activity_criterion.activity_id', '=', 'activities.id')
292
-// 	    	->join('courses', 'activities.course_id', '=', 'courses.id')
293
-// 	    	->join('programs', 'programs.id', '=', 'courses.program_id')
294
-// 	    	->join('criterion_objective_outcome', 'criterion_objective_outcome.criterion_id', '=', 'new_criteria.id')
295
-// 	    	->where('criterion_objective_outcome.outcome_id','=',$this->id)
296
-// 	    	->where('programs.is_graduate','=',$is_grad)
297
-// 	    	->where('courses.semester_id','=',$semester)
298
-// 	    	->select('new_criteria.id','expected_percentage_students_achieving','activity_criterion.activity_id')
299
-// 	    	->distinct()
300
-// 	    	->get()
301
-// 			;
302
-// // 		dd(DB::getQueryLog());
303
-//
304
-// 		$conteo=0;
305
-// 		foreach($criteria as $criterion)
306
-// 		{
307
-// 			$outcome_performance=DB::table('outcome_performance')
308
-// 				->where('outcome_performance.outcome_id','=',$this->id)
309
-// 				->where('outcome_performance.criterion_id','=',$criterion->id)
310
-// 				->where('outcome_performance.semester_id','=',$semester)
311
-// 				->where('outcome_performance.level','=',$is_grad)
312
-// 				->select('students_attempted','students_achieved')
313
-// 				->first();
314
-// 			if(!empty($outcome_performance) and $outcome_performance->students_attempted)
315
-// 			{
316
-// 				$percentage_students_who_achieved=100.0*$outcome_performance->students_achieved/$outcome_performance->students_attempted;
317
-// 			}
318
-// 			else
319
-// 			{
320
-// 				$students_attempted=Criterion::students_attempted($criterion->id, $criterion->activity_id);
321
-// 				$students_achieved=Criterion::students_achieved($criterion->id, $criterion->activity_id);
322
-//
323
-// 				if($students_attempted)
324
-// 				{
325
-// 					$percentage_students_who_achieved=100.0*$students_achieved/$students_attempted;
326
-// 					DB::table('outcome_performance')->insert(array('criterion_id'=>$criterion->id,'outcome_id'=>$this->id,'semester_id'=>$semester,
327
-// 					'students_attempted' => $students_attempted,'students_achieved' => $students_achieved,'level'=>$is_grad));
328
-// 				}
329
-// 				else
330
-// 				{
331
-// 					$percentage_students_who_achieved=0;
332
-// 				}
333
-// 			}
334
-// 			if($percentage_students_who_achieved>=$criterion->expected_percentage_students_achieving)
335
-// 			{
336
-// 				$conteo++;
337
-// 			}
338
-// 		}
339
-// 		return $conteo;
340
-// 	}
341
-//
257
+	// 	public function achieved($semester, $is_grad)
258
+	// 	{
259
+	//
260
+	// //   DB::enableQueryLog();
261
+	// 		 $criteria=DB::table('criteria')
262
+	// 	    	->join('activity_criterion', 'activity_criterion.criterion_id', '=', 'criteria.id')
263
+	// 	    	->join('activities', 'activity_criterion.activity_id', '=', 'activities.id')
264
+	// 	    	->join('courses', 'activities.course_id', '=', 'courses.id')
265
+	// 	    	->join('programs', 'programs.id', '=', 'courses.program_id')
266
+	// 	    	->join('criterion_objective_outcome', 'criterion_objective_outcome.criterion_id', '=', 'criteria.id')
267
+	// 	    	->where('criterion_objective_outcome.outcome_id','=',$this->id)
268
+	// 	    	->where('programs.is_graduate','=',$is_grad)
269
+	// 	    	->where('courses.semester_id','=',$semester)
270
+	// 	    	->select('criteria.id','expected_percentage_students_achieving','activity_criterion.activity_id')
271
+	// 	    	->distinct()
272
+	// 	    	->get()
273
+	// 			;
274
+	// // 		dd(DB::getQueryLog());
275
+	//
276
+	// 		$conteo=0;
277
+	// 		foreach($criteria as $criterion)
278
+	// 		{
279
+	// 			$outcome_performance=DB::table('outcome_performance')
280
+	// 				->where('outcome_performance.outcome_id','=',$this->id)
281
+	// 				->where('outcome_performance.criterion_id','=',$criterion->id)
282
+	// 				->where('outcome_performance.semester_id','=',$semester)
283
+	// 				->where('outcome_performance.level','=',$is_grad)
284
+	// 				->select('students_attempted','students_achieved')
285
+	// 				->first();
286
+	// 			if(!empty($outcome_performance) and $outcome_performance->students_attempted)
287
+	// 			{
288
+	// 				$percentage_students_who_achieved=100.0*$outcome_performance->students_achieved/$outcome_performance->students_attempted;
289
+	// 			}
290
+	// 			else
291
+	// 			{
292
+	// 				$students_attempted=Criterion::students_attempted($criterion->id, $criterion->activity_id);
293
+	// 				$students_achieved=Criterion::students_achieved($criterion->id, $criterion->activity_id);
294
+	//
295
+	// 				if($students_attempted)
296
+	// 				{
297
+	// 					$percentage_students_who_achieved=100.0*$students_achieved/$students_attempted;
298
+	// 					DB::table('outcome_performance')->insert(array('criterion_id'=>$criterion->id,'outcome_id'=>$this->id,'semester_id'=>$semester,
299
+	// 					'students_attempted' => $students_attempted,'students_achieved' => $students_achieved,'level'=>$is_grad));
300
+	// 				}
301
+	// 				else
302
+	// 				{
303
+	// 					$percentage_students_who_achieved=0;
304
+	// 				}
305
+	// 			}
306
+	// 			if($percentage_students_who_achieved>=$criterion->expected_percentage_students_achieving)
307
+	// 			{
308
+	// 				$conteo++;
309
+	// 			}
310
+	// 		}
311
+	// 		return $conteo;
312
+	// 	}
313
+	//
342 314
 
343 315
 	public static function active()
344
-    {
345
-        //TODO: Check when semester doesnt exist or session is empty
346
-        $selected_semester = Semester::find(Session::get('semesters_ids')[0]);
347
-        return Outcome::withTrashed()->where('deactivation_date', '>=', $selected_semester->start)->orWhere('deactivation_date', null)->orderBy('name', 'ASC')->get();
348
-    }
316
+	{
317
+		//TODO: Check when semester doesnt exist or session is empty
318
+		$selected_semester = Semester::find(Session::get('semesters_ids')[0]);
319
+		return Outcome::withTrashed()->where('deactivation_date', '>=', $selected_semester->start)->orWhere('deactivation_date', null)->orderBy('name', 'ASC')->get();
320
+	}
349 321
 }

+ 216
- 247
app/models/Program.php 查看文件

@@ -45,11 +45,9 @@ class Program extends Eloquent
45 45
 	public function assessesOutcome($outcome_id)
46 46
 	{
47 47
 
48
-		foreach ($this->publishedActivities as $activity)
49
-		{
48
+		foreach ($this->publishedActivities as $activity) {
50 49
 			$outcomes_attempted = (array)$activity->o_att_array;
51
-			if(array_key_exists($outcome_id, $outcomes_attempted) && $outcomes_attempted[$outcome_id] != 0)
52
-			{
50
+			if (array_key_exists($outcome_id, $outcomes_attempted) && $outcomes_attempted[$outcome_id] != 0) {
53 51
 				return true;
54 52
 			}
55 53
 		}
@@ -70,18 +68,17 @@ class Program extends Eloquent
70 68
 	// Return learning objectives ordered by outcome
71 69
 	public function objectivesByOutcome()
72 70
 	{
73
-        // Objective::
71
+		// Objective::
74 72
 		$objectives = DB::table('outcomes')
75
-		->select('outcomes.id as outcome_id', 'outcomes.name as outcome_name', 'objectives.id as objective_id', 'objectives.text', 'objectives.active')
76
-		->leftJoin('objectives', function($join)
77
-		{
78
-			$join
79
-				->on('outcomes.id', '=', 'objectives.outcome_id')
80
-				->where('objectives.program_id', '=', $this->id);
81
-		})
82
-		->orderBy('outcome_name', 'ASC')
83
-		->orderBy('objectives.text', 'ASC')
84
-		->get();
73
+			->select('outcomes.id as outcome_id', 'outcomes.name as outcome_name', 'objectives.id as objective_id', 'objectives.text', 'objectives.active')
74
+			->leftJoin('objectives', function ($join) {
75
+				$join
76
+					->on('outcomes.id', '=', 'objectives.outcome_id')
77
+					->where('objectives.program_id', '=', $this->id);
78
+			})
79
+			->orderBy('outcome_name', 'ASC')
80
+			->orderBy('objectives.text', 'ASC')
81
+			->get();
85 82
 
86 83
 		return $objectives;
87 84
 	}
@@ -102,135 +99,121 @@ class Program extends Eloquent
102 99
 		return $this->hasMany('Criterion');
103 100
 	}
104 101
 
105
-// 	public function attempted_outcome($outcome_id, $semester)
106
-// 	{
107
-// 		$conteo= DB::table('activity_criterion')
108
-// 	    	->join('activities', 'activity_criterion.activity_id', '=', 'activities.id')
109
-// 	    	->join('courses', 'activities.course_id', '=', 'courses.id')
110
-// 	    	->join('programs', 'programs.id', '=', 'courses.program_id')
111
-// 	    	->join('criterion_objective_outcome', 'criterion_objective_outcome.criterion_id', '=', 'activity_criterion.criterion_id')
112
-// 	    	->where('criterion_objective_outcome.outcome_id','=',$outcome_id)
113
-// 	    	->where('programs.id','=',$this->id)
114
-// 	    	->where('courses.semester_id','=',$semester)
115
-// 	    	->count(DB::raw('DISTINCT criterion_objective_outcome.outcome_id'))
116
-// 			;	    	
117
-// 		return $conteo;		
118
-// 	}
102
+	// 	public function attempted_outcome($outcome_id, $semester)
103
+	// 	{
104
+	// 		$conteo= DB::table('activity_criterion')
105
+	// 	    	->join('activities', 'activity_criterion.activity_id', '=', 'activities.id')
106
+	// 	    	->join('courses', 'activities.course_id', '=', 'courses.id')
107
+	// 	    	->join('programs', 'programs.id', '=', 'courses.program_id')
108
+	// 	    	->join('criterion_objective_outcome', 'criterion_objective_outcome.criterion_id', '=', 'activity_criterion.criterion_id')
109
+	// 	    	->where('criterion_objective_outcome.outcome_id','=',$outcome_id)
110
+	// 	    	->where('programs.id','=',$this->id)
111
+	// 	    	->where('courses.semester_id','=',$semester)
112
+	// 	    	->count(DB::raw('DISTINCT criterion_objective_outcome.outcome_id'))
113
+	// 			;	    	
114
+	// 		return $conteo;		
115
+	// 	}
119 116
 
120 117
 	public function attempted_criteria_by_outcome($outcome_id, $semesters)
121 118
 	{
122
-		$semesters_array=[];
123
-		foreach($semesters as $semester)
124
-		{
125
-			$semesters_array[]=$semester->id;
119
+		$semesters_array = [];
120
+		foreach ($semesters as $semester) {
121
+			$semesters_array[] = $semester->id;
126 122
 		}
127
-		
128
-		$conteo= DB::table('activity_criterion')
129
-	    	->join('activities', 'activity_criterion.activity_id', '=', 'activities.id')
130
-	    	->join('courses', 'activities.course_id', '=', 'courses.id')
131
-	    	->join('programs', 'programs.id', '=', 'courses.program_id')
132
-	    	->join('criterion_objective_outcome', 'criterion_objective_outcome.criterion_id', '=', 'activity_criterion.criterion_id')
133
-	    	->where('criterion_objective_outcome.outcome_id','=',$outcome_id)
134
-	    	->where('programs.id','=',$this->id)
135
-	    	->whereIn('courses.semester_id',$semesters_array)
136
-	    	->count(DB::raw('DISTINCT criterion_objective_outcome.criterion_id'))
137
-			;	    	
138
-		return $conteo;		
123
+
124
+		$conteo = DB::table('activity_criterion')
125
+			->join('activities', 'activity_criterion.activity_id', '=', 'activities.id')
126
+			->join('courses', 'activities.course_id', '=', 'courses.id')
127
+			->join('programs', 'programs.id', '=', 'courses.program_id')
128
+			->join('criterion_objective_outcome', 'criterion_objective_outcome.criterion_id', '=', 'activity_criterion.criterion_id')
129
+			->where('criterion_objective_outcome.outcome_id', '=', $outcome_id)
130
+			->where('programs.id', '=', $this->id)
131
+			->whereIn('courses.semester_id', $semesters_array)
132
+			->count(DB::raw('DISTINCT criterion_objective_outcome.criterion_id'));
133
+		return $conteo;
139 134
 	}
140 135
 
141 136
 	public function attempted_outcome($outcome_id, $semesters)
142 137
 	{
143
-		$semesters_array=[];
144
-		foreach($semesters as $semester)
145
-		{
146
-			$semesters_array[]=$semester->id;
138
+		$semesters_array = [];
139
+		foreach ($semesters as $semester) {
140
+			$semesters_array[] = $semester->id;
147 141
 		}
148
-		
149
-		$conteo= DB::table('activity_criterion')
150
-	    	->join('activities', 'activity_criterion.activity_id', '=', 'activities.id')
151
-	    	->join('courses', 'activities.course_id', '=', 'courses.id')
152
-	    	->join('programs', 'programs.id', '=', 'courses.program_id')
153
-	    	->join('criterion_objective_outcome', 'criterion_objective_outcome.criterion_id', '=', 'activity_criterion.criterion_id')
154
-	    	->where('criterion_objective_outcome.outcome_id','=',$outcome_id)
155
-	    	->where('programs.id','=',$this->id)
156
-	    	->whereIn('courses.semester_id',$semesters_array)
157
-	    	->count(DB::raw('DISTINCT criterion_objective_outcome.outcome_id'))
158
-			;	    	
159
-		return $conteo;		
142
+
143
+		$conteo = DB::table('activity_criterion')
144
+			->join('activities', 'activity_criterion.activity_id', '=', 'activities.id')
145
+			->join('courses', 'activities.course_id', '=', 'courses.id')
146
+			->join('programs', 'programs.id', '=', 'courses.program_id')
147
+			->join('criterion_objective_outcome', 'criterion_objective_outcome.criterion_id', '=', 'activity_criterion.criterion_id')
148
+			->where('criterion_objective_outcome.outcome_id', '=', $outcome_id)
149
+			->where('programs.id', '=', $this->id)
150
+			->whereIn('courses.semester_id', $semesters_array)
151
+			->count(DB::raw('DISTINCT criterion_objective_outcome.outcome_id'));
152
+		return $conteo;
160 153
 	}
161
-	
154
+
162 155
 	public function achieved_criteria_by_outcome($outcome_id, $semesters)
163 156
 	{
164
-		$semesters_array=[];
165
-		foreach($semesters as $semester)
166
-		{
167
-			$semesters_array[]=$semester->id;
157
+		$semesters_array = [];
158
+		foreach ($semesters as $semester) {
159
+			$semesters_array[] = $semester->id;
168 160
 		}
169
-		
170
-//   DB::enableQueryLog();
171
-// 		dd(DB::getQueryLog());
172
-		 $criteria=DB::table('new_criteria')
173
-	    	->join('activity_criterion', 'activity_criterion.criterion_id', '=', 'new_criteria.id')
174
-	    	->join('activities', 'activity_criterion.activity_id', '=', 'activities.id')
175
-	    	->join('courses', 'activities.course_id', '=', 'courses.id')
176
-	    	->join('programs', 'programs.id', '=', 'courses.program_id')
177
-	    	->join('criterion_objective_outcome', 'criterion_objective_outcome.criterion_id', '=', 'new_criteria.id')
178
-	    	->where('criterion_objective_outcome.outcome_id','=',$outcome_id)
179
-	    	->where('programs.id','=',$this->id)
180
-	    	->whereIn('courses.semester_id',$semesters_array)
181
-	    	->select('new_criteria.id','expected_percentage_students_achieving','activity_criterion.activity_id')
182
-	    	->distinct()
183
-	    	->get()
184
-			;
185
-// 		dd(DB::getQueryLog());
186
-		 
187
-		$conteo=0;
188
-		$attempted_criteria_per_program_array=[];
189
-// 		$students_attempted=0;
190
-// 		$students_achieved=0;
191
-		foreach($criteria as $criterion)
192
-		{	
193
-			if(!isset($students_attempted[$criterion->id]))$students_attempted[$criterion->id]=0;
194
-			if(!isset($students_achieved[$criterion->id]))$students_achieved[$criterion->id]=0;
195
-			$attempted_criteria_per_program_array[$criterion->id]=1;
196
-			$students_attempted[$criterion->id]+=Criterion::students_attempted($criterion->id, $criterion->activity_id);
197
-			$students_achieved[$criterion->id]+=Criterion::students_achieved($criterion->id, $criterion->activity_id);
161
+
162
+		//   DB::enableQueryLog();
163
+		// 		dd(DB::getQueryLog());
164
+		$criteria = DB::table('criteria')
165
+			->join('activity_criterion', 'activity_criterion.criterion_id', '=', 'criteria.id')
166
+			->join('activities', 'activity_criterion.activity_id', '=', 'activities.id')
167
+			->join('courses', 'activities.course_id', '=', 'courses.id')
168
+			->join('programs', 'programs.id', '=', 'courses.program_id')
169
+			->join('criterion_objective_outcome', 'criterion_objective_outcome.criterion_id', '=', 'criteria.id')
170
+			->where('criterion_objective_outcome.outcome_id', '=', $outcome_id)
171
+			->where('programs.id', '=', $this->id)
172
+			->whereIn('courses.semester_id', $semesters_array)
173
+			->select('criteria.id', 'expected_percentage_students_achieving', 'activity_criterion.activity_id')
174
+			->distinct()
175
+			->get();
176
+		// 		dd(DB::getQueryLog());
177
+
178
+		$conteo = 0;
179
+		$attempted_criteria_per_program_array = [];
180
+		// 		$students_attempted=0;
181
+		// 		$students_achieved=0;
182
+		foreach ($criteria as $criterion) {
183
+			if (!isset($students_attempted[$criterion->id])) $students_attempted[$criterion->id] = 0;
184
+			if (!isset($students_achieved[$criterion->id])) $students_achieved[$criterion->id] = 0;
185
+			$attempted_criteria_per_program_array[$criterion->id] = 1;
186
+			$students_attempted[$criterion->id] += Criterion::students_attempted($criterion->id, $criterion->activity_id);
187
+			$students_achieved[$criterion->id] += Criterion::students_achieved($criterion->id, $criterion->activity_id);
198 188
 		}
199
-// 		var_dump($outcome_id);
200
-// 		var_dump($this->id);
201
-// 		if(isset($students_attempted))var_dump($students_attempted);
202
-// 		else{print "aqui hay algo";}
203
-// 		print "<br>";
204
-// 		if(isset($students_achieved))var_dump($students_achieved);
205
-// 		print "<br>";
206
-// 		print "<br>";
207
-// 			exit();
208
-		if(isset($students_attempted))
209
-		{
210
-			foreach($students_attempted as $criteria_id => $students_attempted_n)
211
-			{
212
-				if($students_attempted_n)
213
-				{
214
-					$percentage_students_who_achieved=100.0*$students_achieved[$criteria_id]/$students_attempted[$criteria_id];
189
+		// 		var_dump($outcome_id);
190
+		// 		var_dump($this->id);
191
+		// 		if(isset($students_attempted))var_dump($students_attempted);
192
+		// 		else{print "aqui hay algo";}
193
+		// 		print "<br>";
194
+		// 		if(isset($students_achieved))var_dump($students_achieved);
195
+		// 		print "<br>";
196
+		// 		print "<br>";
197
+		// 			exit();
198
+		if (isset($students_attempted)) {
199
+			foreach ($students_attempted as $criteria_id => $students_attempted_n) {
200
+				if ($students_attempted_n) {
201
+					$percentage_students_who_achieved = 100.0 * $students_achieved[$criteria_id] / $students_attempted[$criteria_id];
202
+				} else {
203
+					$percentage_students_who_achieved = 0;
215 204
 				}
216
-				else
217
-				{
218
-					$percentage_students_who_achieved=0;
219
-				}
220
-				if($percentage_students_who_achieved>=$criterion->expected_percentage_students_achieving)
221
-				{
205
+				if ($percentage_students_who_achieved >= $criterion->expected_percentage_students_achieving) {
222 206
 					$conteo++;
223 207
 				}
224
-			}		
208
+			}
225 209
 		}
226
-		$attempted_criteria_per_program=count($attempted_criteria_per_program_array);
227
-		$achievedProgramOutcome=0;
228
-		$outcome=Outcome::where('id',$outcome_id)->select('expected_outcome')->first();
229
-// 		var_dump($outcome->expected_outcome);
230
-// 		exit();
231
-		if($attempted_criteria_per_program!=0 && 100.0*$conteo/$attempted_criteria_per_program >= $outcome->expected_outcome)
232
-		{
233
-			$achievedProgramOutcome=1;
210
+		$attempted_criteria_per_program = count($attempted_criteria_per_program_array);
211
+		$achievedProgramOutcome = 0;
212
+		$outcome = Outcome::where('id', $outcome_id)->select('expected_outcome')->first();
213
+		// 		var_dump($outcome->expected_outcome);
214
+		// 		exit();
215
+		if ($attempted_criteria_per_program != 0 && 100.0 * $conteo / $attempted_criteria_per_program >= $outcome->expected_outcome) {
216
+			$achievedProgramOutcome = 1;
234 217
 			// $output[]= 'END OF PROGRAM: '.$program->name.'-'.json_encode($achievedProgramsPerOutcome);
235 218
 		}
236 219
 		return $conteo;
@@ -238,142 +221,128 @@ class Program extends Eloquent
238 221
 
239 222
 	public function achieved_outcome($outcome_id, $semesters)
240 223
 	{
241
-		$semesters_array=[];
242
-		foreach($semesters as $semester)
243
-		{
244
-			$semesters_array[]=$semester->id;
224
+		$semesters_array = [];
225
+		foreach ($semesters as $semester) {
226
+			$semesters_array[] = $semester->id;
245 227
 		}
246
-		
247
-//   DB::enableQueryLog();
248
-// 		dd(DB::getQueryLog());
249
-		 $criteria=DB::table('new_criteria')
250
-	    	->join('activity_criterion', 'activity_criterion.criterion_id', '=', 'new_criteria.id')
251
-	    	->join('activities', 'activity_criterion.activity_id', '=', 'activities.id')
252
-	    	->join('courses', 'activities.course_id', '=', 'courses.id')
253
-	    	->join('programs', 'programs.id', '=', 'courses.program_id')
254
-	    	->join('criterion_objective_outcome', 'criterion_objective_outcome.criterion_id', '=', 'new_criteria.id')
255
-	    	->where('criterion_objective_outcome.outcome_id','=',$outcome_id)
256
-	    	->where('programs.id','=',$this->id)
257
-	    	->whereIn('courses.semester_id',$semesters_array)
258
-	    	->select('new_criteria.id','expected_percentage_students_achieving','activity_criterion.activity_id')
259
-	    	->distinct()
260
-	    	->get()
261
-			;
262
-// 		dd(DB::getQueryLog());
263
-		 
264
-		$conteo=0;
265
-		$attempted_criteria_per_program_array=[];
266
-// 		$students_attempted=0;
267
-// 		$students_achieved=0;
268
-		foreach($criteria as $criterion)
269
-		{	
270
-			if(!isset($students_attempted[$criterion->id]))$students_attempted[$criterion->id]=0;
271
-			if(!isset($students_achieved[$criterion->id]))$students_achieved[$criterion->id]=0;
272
-			$attempted_criteria_per_program_array[$criterion->id]=1;
273
-			$students_attempted[$criterion->id]+=Criterion::students_attempted($criterion->id, $criterion->activity_id);
274
-			$students_achieved[$criterion->id]+=Criterion::students_achieved($criterion->id, $criterion->activity_id);
228
+
229
+		//   DB::enableQueryLog();
230
+		// 		dd(DB::getQueryLog());
231
+		$criteria = DB::table('criteria')
232
+			->join('activity_criterion', 'activity_criterion.criterion_id', '=', 'criteria.id')
233
+			->join('activities', 'activity_criterion.activity_id', '=', 'activities.id')
234
+			->join('courses', 'activities.course_id', '=', 'courses.id')
235
+			->join('programs', 'programs.id', '=', 'courses.program_id')
236
+			->join('criterion_objective_outcome', 'criterion_objective_outcome.criterion_id', '=', 'criteria.id')
237
+			->where('criterion_objective_outcome.outcome_id', '=', $outcome_id)
238
+			->where('programs.id', '=', $this->id)
239
+			->whereIn('courses.semester_id', $semesters_array)
240
+			->select('criteria.id', 'expected_percentage_students_achieving', 'activity_criterion.activity_id')
241
+			->distinct()
242
+			->get();
243
+		// 		dd(DB::getQueryLog());
244
+
245
+		$conteo = 0;
246
+		$attempted_criteria_per_program_array = [];
247
+		// 		$students_attempted=0;
248
+		// 		$students_achieved=0;
249
+		foreach ($criteria as $criterion) {
250
+			if (!isset($students_attempted[$criterion->id])) $students_attempted[$criterion->id] = 0;
251
+			if (!isset($students_achieved[$criterion->id])) $students_achieved[$criterion->id] = 0;
252
+			$attempted_criteria_per_program_array[$criterion->id] = 1;
253
+			$students_attempted[$criterion->id] += Criterion::students_attempted($criterion->id, $criterion->activity_id);
254
+			$students_achieved[$criterion->id] += Criterion::students_achieved($criterion->id, $criterion->activity_id);
275 255
 		}
276
-// 		var_dump($outcome_id);
277
-// 		var_dump($this->id);
278
-// 		if(isset($students_attempted))var_dump($students_attempted);
279
-// 		else{print "aqui hay algo";}
280
-// 		print "<br>";
281
-// 		if(isset($students_achieved))var_dump($students_achieved);
282
-// 		print "<br>";
283
-// 		print "<br>";
284
-// 			exit();
285
-		if(isset($students_attempted))
286
-		{
287
-			foreach($students_attempted as $criteria_id => $students_attempted_n)
288
-			{
289
-				if($students_attempted_n)
290
-				{
291
-					$percentage_students_who_achieved=100.0*$students_achieved[$criteria_id]/$students_attempted[$criteria_id];
256
+		// 		var_dump($outcome_id);
257
+		// 		var_dump($this->id);
258
+		// 		if(isset($students_attempted))var_dump($students_attempted);
259
+		// 		else{print "aqui hay algo";}
260
+		// 		print "<br>";
261
+		// 		if(isset($students_achieved))var_dump($students_achieved);
262
+		// 		print "<br>";
263
+		// 		print "<br>";
264
+		// 			exit();
265
+		if (isset($students_attempted)) {
266
+			foreach ($students_attempted as $criteria_id => $students_attempted_n) {
267
+				if ($students_attempted_n) {
268
+					$percentage_students_who_achieved = 100.0 * $students_achieved[$criteria_id] / $students_attempted[$criteria_id];
269
+				} else {
270
+					$percentage_students_who_achieved = 0;
292 271
 				}
293
-				else
294
-				{
295
-					$percentage_students_who_achieved=0;
296
-				}
297
-				if($percentage_students_who_achieved>=$criterion->expected_percentage_students_achieving)
298
-				{
272
+				if ($percentage_students_who_achieved >= $criterion->expected_percentage_students_achieving) {
299 273
 					$conteo++;
300 274
 				}
301
-			}		
275
+			}
302 276
 		}
303
-		$attempted_criteria_per_program=count($attempted_criteria_per_program_array);
304
-		$achievedProgramOutcome=0;
305
-		$outcome=Outcome::where('id',$outcome_id)->select('expected_outcome')->first();
306
-// 		var_dump($outcome->expected_outcome);
307
-// 		exit();
308
-		if($attempted_criteria_per_program!=0 && 100.0*$conteo/$attempted_criteria_per_program >= $outcome->expected_outcome)
309
-		{
310
-			$achievedProgramOutcome=1;
277
+		$attempted_criteria_per_program = count($attempted_criteria_per_program_array);
278
+		$achievedProgramOutcome = 0;
279
+		$outcome = Outcome::where('id', $outcome_id)->select('expected_outcome')->first();
280
+		// 		var_dump($outcome->expected_outcome);
281
+		// 		exit();
282
+		if ($attempted_criteria_per_program != 0 && 100.0 * $conteo / $attempted_criteria_per_program >= $outcome->expected_outcome) {
283
+			$achievedProgramOutcome = 1;
311 284
 			// $output[]= 'END OF PROGRAM: '.$program->name.'-'.json_encode($achievedProgramsPerOutcome);
312 285
 		}
313 286
 		return $achievedProgramOutcome;
314 287
 	}
315 288
 
316
-	public static function generalComponentPrograms(){
317
-		return self::whereIn('id', array(123,124,125,126,127,128,129))->get();
289
+	public static function generalComponentPrograms()
290
+	{
291
+		return self::whereIn('id', array(123, 124, 125, 126, 127, 128, 129))->get();
318 292
 	}
319 293
 
320
-	public function assessmentOverview(){
294
+	public function assessmentOverview()
295
+	{
321 296
 
322
-        $assessment_overview = array();
297
+		$assessment_overview = array();
323 298
 
324 299
 		$assessment_overview['program_courses'] = $this->courses;
325
-        $outcomeCount = Outcome::all()->count();
326
-
327
-
328
-        $assessment_overview['outcomes_achieved'] = array_fill(1, $outcomeCount, 0);
329
-        $assessment_overview['outcomes_attempted'] = array_fill(1, $outcomeCount, 0);
330
-
331
-        $assessment_overview['assessed_courses_count'] = 0;
332
-        foreach ($assessment_overview['program_courses'] as $course)
333
-        {
334
-            if($course->outcomes_achieved!=NULL)
335
-            {
336
-                $course_outcomes_achieved =json_decode($course->outcomes_achieved, true);
337
-                $course_outcomes_attempted =json_decode($course->outcomes_attempted, true);
338
-                for($i=1; $i<=count($assessment_overview['outcomes_attempted']); $i++)
339
-                {
340
-                  $assessment_overview['outcomes_achieved'][$i]+=$course_outcomes_achieved[$i];
341
-                  $assessment_overview['outcomes_attempted'][$i]+=$course_outcomes_attempted[$i];
342
-                }
343
-                $assessment_overview['assessed_courses_count']+=1;
344
-            }
345
-        }
346
-
347
-        /**
348
-         * List of grouped courses (grouped sections)
349
-         */
350
-
351
-        $assessment_overview['grouped_courses'] = Course::
352
-            select(DB::raw('name, code, number, max(outcomes_attempted) as outcomes_attempted, semester_id, program_id'))
353
-            ->with('semester')
354
-            ->with('program')
355
-            ->where('program_id', $this->id)
356
-            ->whereIn('semester_id', Session::get('semesters_ids'))
357
-            ->groupBy(array('code', 'number', 'semester_id'))
358
-            ->orderBy('code')
359
-            ->orderBy('number')
360
-            ->orderBy('semester_id')
361
-            ->get();
362
-
363
-            Log::info(Course::
364
-            select(DB::raw('name, code, number, max(outcomes_attempted) as outcomes_attempted, semester_id, program_id'))
365
-            ->with('semester')
366
-            ->with('program')
367
-            ->where('program_id', $this->id)
368
-            ->whereIn('semester_id', Session::get('semesters_ids'))
369
-            ->groupBy(array('code', 'number', 'semester_id'))
370
-            ->orderBy('code')
371
-            ->orderBy('number')
372
-            ->orderBy('semester_id')
373
-            ->toSql());
374
-
375
-
376
-        return $assessment_overview;
377
-	}
300
+		$outcomeCount = Outcome::all()->count();
301
+
302
+
303
+		$assessment_overview['outcomes_achieved'] = array_fill(1, $outcomeCount, 0);
304
+		$assessment_overview['outcomes_attempted'] = array_fill(1, $outcomeCount, 0);
378 305
 
306
+		$assessment_overview['assessed_courses_count'] = 0;
307
+		foreach ($assessment_overview['program_courses'] as $course) {
308
+			if ($course->outcomes_achieved != NULL) {
309
+				$course_outcomes_achieved = json_decode($course->outcomes_achieved, true);
310
+				$course_outcomes_attempted = json_decode($course->outcomes_attempted, true);
311
+				for ($i = 1; $i <= count($assessment_overview['outcomes_attempted']); $i++) {
312
+					$assessment_overview['outcomes_achieved'][$i] += $course_outcomes_achieved[$i];
313
+					$assessment_overview['outcomes_attempted'][$i] += $course_outcomes_attempted[$i];
314
+				}
315
+				$assessment_overview['assessed_courses_count'] += 1;
316
+			}
317
+		}
318
+
319
+		/**
320
+		 * List of grouped courses (grouped sections)
321
+		 */
322
+
323
+		$assessment_overview['grouped_courses'] = Course::select(DB::raw('name, code, number, max(outcomes_attempted) as outcomes_attempted, semester_id, program_id'))
324
+			->with('semester')
325
+			->with('program')
326
+			->where('program_id', $this->id)
327
+			->whereIn('semester_id', Session::get('semesters_ids'))
328
+			->groupBy(array('code', 'number', 'semester_id'))
329
+			->orderBy('code')
330
+			->orderBy('number')
331
+			->orderBy('semester_id')
332
+			->get();
333
+
334
+		Log::info(Course::select(DB::raw('name, code, number, max(outcomes_attempted) as outcomes_attempted, semester_id, program_id'))
335
+			->with('semester')
336
+			->with('program')
337
+			->where('program_id', $this->id)
338
+			->whereIn('semester_id', Session::get('semesters_ids'))
339
+			->groupBy(array('code', 'number', 'semester_id'))
340
+			->orderBy('code')
341
+			->orderBy('number')
342
+			->orderBy('semester_id')
343
+			->toSql());
344
+
345
+
346
+		return $assessment_overview;
347
+	}
379 348
 }

+ 13
- 16
app/models/Rubric.php 查看文件

@@ -3,16 +3,16 @@
3 3
 class Rubric extends Eloquent
4 4
 {
5 5
 
6
-    /**
7
-     * Searchable rules.
8
-     *
9
-     * @var array
10
-     */
11
-    protected $searchable = [
12
-        'columns' => [
13
-            'name' => 10,
14
-        ],
15
-    ];
6
+  /**
7
+   * Searchable rules.
8
+   *
9
+   * @var array
10
+   */
11
+  protected $searchable = [
12
+    'columns' => [
13
+      'name' => 10,
14
+    ],
15
+  ];
16 16
 
17 17
   public function professor()
18 18
   {
@@ -21,7 +21,7 @@ class Rubric extends Eloquent
21 21
 
22 22
   public function activities()
23 23
   {
24
-    return $this->belongsToMany('Activity', 'new_rubric_activity');
24
+    return $this->belongsToMany('Activity', 'rubric_activity');
25 25
   }
26 26
 
27 27
   public function getCriterion($id, $criterion_id)
@@ -30,13 +30,10 @@ class Rubric extends Eloquent
30 30
 
31 31
     $rubric_contents = json_decode($rubric->contents);
32 32
 
33
-    foreach ($rubric_contents as $key => $criterion)
34
-    {
35
-      if($criterion->id == $criterion_id)
36
-      {
33
+    foreach ($rubric_contents as $key => $criterion) {
34
+      if ($criterion->id == $criterion_id) {
37 35
         return $criterion;
38 36
       }
39 37
     }
40 38
   }
41
-
42 39
 }

+ 3
- 3
app/views/local/managers/admins/criteria.blade.php 查看文件

@@ -484,7 +484,7 @@
484 484
 
485 485
             function(json) {
486 486
 
487
-                optionName = '';
487
+                optionName = '<option value ="0">Nothing Selected</option>';
488 488
                 for(outcome in varArray.outcomes){
489 489
                     optionName += '<optgroup label="' + varArray.outcomes[outcome][0].name + '">';
490 490
                     var objectiveForOutcome = varArray.objectives;
@@ -551,7 +551,7 @@
551 551
             },
552 552
             function(varArray) {
553 553
                 counterOutcome =0;
554
-                optionName = '';
554
+                optionName = '<option value ="0">Nothing Selected</option>';
555 555
                 for(outcome in varArray.outcomes){
556 556
                     optionName += '<optgroup label="' + varArray.outcomes[outcome][0].name + '">';
557 557
                     var objectiveForOutcome = varArray.objectives;
@@ -756,7 +756,7 @@
756 756
 
757 757
                 assocOutcomeCounter = 0;
758 758
                 var i = 0;
759
-                optionName = '';
759
+                optionName = '<option value ="0">Nothing Selected</option>';
760 760
                 for(outcome in json.outcomes_assoc){
761 761
                     optionName += '<optgroup label="' + json.outcomes_assoc[outcome][0].name + '">';
762 762
                     var objectiveForOutcome = json.objectives_assoc;

+ 3
- 3
app/views/local/managers/pCoords/criteria.blade.php 查看文件

@@ -476,7 +476,7 @@ $('.filterSection').hide();
476 476
 
477 477
             function(json) {
478 478
 
479
-                optionName = '';
479
+                optionName = '<option value ="0">Nothing Selected</option>';
480 480
                 for(outcome in varArray.outcomes){
481 481
                     optionName += '<optgroup label="' + varArray.outcomes[outcome][0].name + '">';
482 482
                     var objectiveForOutcome = varArray.objectives;
@@ -543,7 +543,7 @@ $('.filterSection').hide();
543 543
             },
544 544
             function(varArray) {
545 545
                 counterOutcome =0;
546
-                optionName = '';
546
+                optionName = '<option value ="0">Nothing Selected</option>';
547 547
                 for(outcome in varArray.outcomes){
548 548
                     optionName += '<optgroup label="' + varArray.outcomes[outcome][0].name + '">';
549 549
                     var objectiveForOutcome = varArray.objectives;
@@ -745,7 +745,7 @@ $('#DeleteButton').prop('disabled', true);
745 745
 
746 746
                 assocOutcomeCounter = 0;
747 747
                 var i = 0;
748
-                optionName = '';
748
+                optionName = '<option value ="0">Nothing Selected</option>';
749 749
                 for(outcome in json.outcomes_assoc){
750 750
                     optionName += '<optgroup label="' + json.outcomes_assoc[outcome][0].name + '">';
751 751
                     var objectiveForOutcome = json.objectives_assoc;

+ 3
- 3
app/views/local/managers/sCoords/criteria.blade.php 查看文件

@@ -482,7 +482,7 @@
482 482
 
483 483
             function(json) {
484 484
 
485
-                optionName = '';
485
+                optionName = '<option value ="0">Nothing Selected</option>';
486 486
                 for(outcome in varArray.outcomes){
487 487
                     optionName += '<optgroup label="' + varArray.outcomes[outcome][0].name + '">';
488 488
                     var objectiveForOutcome = varArray.objectives;
@@ -549,7 +549,7 @@
549 549
             },
550 550
             function(varArray) {
551 551
                 counterOutcome =0;
552
-                optionName = '';
552
+                optionName = '<option value ="0">Nothing Selected</option>';
553 553
                 for(outcome in varArray.outcomes){
554 554
                     optionName += '<optgroup label="' + varArray.outcomes[outcome][0].name + '"';
555 555
                     var objectiveForOutcome = varArray.objectives;
@@ -753,7 +753,7 @@
753 753
 
754 754
                 assocOutcomeCounter = 0;
755 755
                 var i = 0;
756
-                optionName = '';
756
+                optionName = '<option value ="0">Nothing Selected</option>';
757 757
                 for(outcome in json.outcomes_assoc){
758 758
                     optionName += '<optgroup label="' + json.outcomes_assoc[outcome][0].name + '">';
759 759
                     var objectiveForOutcome = json.objectives_assoc;

+ 7
- 4
app/views/local/managers/shared/rubrics.blade.php 查看文件

@@ -659,7 +659,7 @@ function loadTemplate()
659 659
                 current_criterion = temp_criterion[temp_c]
660 660
                 var subcriteria ='';
661 661
                 if(current_criterion.subcriteria){
662
-                    var subcriteria_array = current_criterion.subcriteria;
662
+                    var subcriteria_array = JSON.parse(current_criterion.subcriteria);
663 663
                     subcriteria = '<ul class="subcriteria list-unstyled">';
664 664
                     subcriteria_array.forEach(function (value) {
665 665
                         subcriteria += '<li>'+value+'</li>';
@@ -1061,7 +1061,7 @@ $('.save').on('click', function(e)
1061 1061
             "{{ URL::to('saveTemplate') }}",
1062 1062
             {
1063 1063
                 name: $('#rubric-name').val(),
1064
-                contents: " ",
1064
+                
1065 1065
                 school_id: $('#select-school').find(':selected').data('school-id'),
1066 1066
                 program_id: $('#select-program').find(':selected').data('program-id'),
1067 1067
                 expected_percentage: $('#expected_percentage').find(':selected').val(),
@@ -1090,12 +1090,15 @@ $('.save').on('click', function(e)
1090 1090
             {
1091 1091
                 id: $('#select-template').find(':selected').data('template-id'),
1092 1092
                 name: $('#rubric-name').val(),
1093
-                contents: JSON.stringify(criteriaArray),
1093
+                
1094 1094
                 school_id: $('#select-school').find(':selected').data('school-id'),
1095 1095
                 program_id: $('#select-program').find(':selected').data('program-id'),
1096 1096
                 expected_percentage: $('#expected_percentage').find(':selected').val(),
1097 1097
                 expected_points: $('#expected_points').find(':selected').val(),
1098
-                is_visible: $('input[name=is_visible]:checked').val()
1098
+                is_visible: $('input[name=is_visible]:checked').val(),
1099
+                criteria : criteria,
1100
+                scales: scales,
1101
+                max_score : max
1099 1102
             },
1100 1103
             function(data)
1101 1104
             {

+ 1
- 1
app/views/local/professors/rubrics.blade.php 查看文件

@@ -302,7 +302,7 @@ function loadTemplate()
302 302
                 current_criterion = temp_criterion[temp_c]
303 303
                 var subcriteria ='';
304 304
                 if(current_criterion.subcriteria){
305
-                    var subcriteria_array = current_criterion.subcriteria;
305
+                    var subcriteria_array = JSON.parse(current_criterion.subcriteria);
306 306
                     subcriteria = '<ul class="subcriteria list-unstyled">';
307 307
                     subcriteria_array.forEach(function (value) {
308 308
                         subcriteria += '<li>'+value+'</li>';