Gabriel Santiago Plaza 3 gadus atpakaļ
vecāks
revīzija
72cfe00634

+ 6
- 1
app/controllers/ActivitiesController.php Parādīt failu

@@ -113,6 +113,7 @@ class ActivitiesController extends \BaseController
113 113
     {
114 114
         $activity = Activity::find($id);
115 115
 
116
+
116 117
         // If activity does not exist, display 404
117 118
         if (!$activity)
118 119
             App::abort('404');
@@ -121,7 +122,7 @@ class ActivitiesController extends \BaseController
121 122
         $course = Course::where('id', '=', $activity->course_id)->firstOrFail();
122 123
 
123 124
         // If activity does not belong to the requesting user, display 403
124
-        if ($course->user_id != Auth::id() and Auth::user()->role==4)
125
+        if ($course->user_id != Auth::id() and Auth::user()->role == 4)
125 126
             App::abort('403', 'Access Forbidden');
126 127
 
127 128
         // Get active semesters
@@ -130,11 +131,15 @@ class ActivitiesController extends \BaseController
130 131
         foreach ($active_semesters_collection as $active_semester) {
131 132
             $active_semesters[] = $active_semester->id;
132 133
         }
134
+        Log::info($active_semesters);
133 135
         // Added the function htmlspecialchars to activity name string because it was corrupting Jquery code while using quotes on page rendering. - Carlos R Caraballo 1/18/2019
134 136
         $title = $course->code . $course->number . '-' . $course->section . ': ' . htmlspecialchars($activity->name, ENT_QUOTES) . ' <span class="small attention">(' . $course->semester->code . ')</span>';
135 137
         $outcomes = Outcome::orderBy('name', 'asc')->get();
136 138
         $outcomes_achieved = json_decode($activity->outcomes_achieved, true);
137 139
         $outcomes_attempted = json_decode($activity->outcomes_attempted, true);
140
+        $tru = is_null($activity->rubric) ? "brr anuel"  : "ye ye ye";
141
+        Log::info($tru);
142
+        Log::info(count($activity->rubric));
138 143
 
139 144
         return View::make('local.professors.activity', compact('activity', 'title', 'outcomes', 'outcomes_achieved', 'outcomes_attempted', 'course', 'student_count', 'active_semesters'));
140 145
     }

+ 2
- 2
app/controllers/AnnualPlansController.php Parādīt failu

@@ -43,7 +43,7 @@ class AnnualPlansController extends \BaseController
43 43
   public function viewAllPlans($program_id)
44 44
   {
45 45
     $title = "Annual Plans";
46
-    $annual_plans = DB::select("select * from annual_plans order by id desc");
46
+    $annual_plans = DB::select("select * from annual_plans  where program_id ={$program_id} order by id desc");
47 47
 
48 48
 
49 49
     return View::make('local.managers.sCoords.view-annual-plans', compact('title', 'program_id', 'annual_plans'));
@@ -138,7 +138,7 @@ class AnnualPlansController extends \BaseController
138 138
     } else {
139 139
       $current_typ = DB::select("select * from three_year_plan where id ={$typ_id}")[0];
140 140
     }
141
-    Log::info($current_typ);
141
+
142 142
 
143 143
 
144 144
     $program = Program::where('id', '=', $program_id)->first();

+ 18
- 3
app/controllers/CriteriaController.php Parādīt failu

@@ -50,10 +50,25 @@ class CriteriaController extends \BaseController
50 50
         return View::make('local.managers.sCoords.criteria', compact('title', 'outcomes', 'schools', 'criteria', 'programs', 'objectives'));
51 51
     }
52 52
 
53
+    public function fetchCriterionWithTemplate()
54
+    {
55
+        $json_to_send = array();
56
+        $json_to_send['criterion'] = DB::table('new_criteria')->where('id', '=', Input::get('id'))->first();
57
+
58
+
53 59
 
60
+
61
+        return json_encode($json_to_send);
62
+    }
54 63
     public function fetchCriterion()
55 64
     {
56
-        return Criterion::find(Input::get('id'));
65
+        $json_to_send = array();
66
+        $json_to_send['criterion'] = DB::table('new_criteria')->where('id', '=', Input::get('id'))->first();
67
+
68
+
69
+
70
+
71
+        return $json_to_send['criterion'];
57 72
     }
58 73
     public function fetchAllCriterion()
59 74
     {
@@ -61,13 +76,14 @@ class CriteriaController extends \BaseController
61 76
         $outcome_id = Input::get('outcome_fetch');
62 77
         $json = array();
63 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})");
79
+
64 80
         return json_encode($json);
65 81
     }
66 82
     public function fetchObjectivesForSelect()
67 83
     {
68 84
 
69 85
         $json = array();
70
-        Log::info("GET COCKEd");
86
+
71 87
         Log::info(Input::get('allOutcomes'));
72 88
         foreach (Input::get('allOutcomes') as $id) {
73 89
             $json['outcomes'][$id] = DB::select("select name from outcomes where id = {$id}");
@@ -586,7 +602,6 @@ class CriteriaController extends \BaseController
586 602
 
587 603
         // se annadio la nueva variable
588 604
         return View::make('global.view-learning-outcomes-criteria', compact('title', 'outcomes', 'schools', 'criteria', 'semesters'));
589
-
590 605
     }
591 606
 
592 607
 

+ 217
- 195
app/controllers/OutcomesController.php Parādīt failu

@@ -43,169 +43,164 @@ class OutcomesController extends \BaseController
43 43
         $undergradResults = array("names" => array(), "schools" => array(), "achieved" => array(), "attempted" => array(), "successRate" => array());
44 44
         $gradResults = array("names" => array(), "schools" => array(), "achieved" => array(), "attempted" => array(), "successRate" => array());
45 45
         foreach ($programs as $program_id) {
46
- //        	var_dump($program_id);
47
-//         	exit();
48
-        	$program = Program::where('id', '=', $program_id->id)->first();
49
-        	$school = School::where('id', '=', $program->school_id)->first();
50
-        	if($program->is_graduate)
51
-        	{
52
-        		$gradResults['names'][] = $program->name;
53
-        		$gradResults['schools'][] = $school->name;
54
-        		$attempted = $program->attempted_criteria_by_outcome($id, $selected_semesters);
55
-        		$gradResults['attempted'][] = $attempted;
56
-        		$achieved = $program->achieved_criteria_by_outcome($id, $selected_semesters);
57
-        		$gradResults['achieved'][] = $achieved;
58
-        		$gradResults['successRate'][] = sprintf("%.2f",100*$achieved/$attempted);
59
-
60
-        	}
61
-        	else
62
-        	{
63
-        		$undergradResults['names'][] = $program->name;
64
-        		$undergradResults['schools'][] = $school->name;
65
-        		$attempted = $program->attempted_criteria_by_outcome($id,$selected_semesters);
66
-        		$undergradResults['attempted'][] = $attempted;
67
-        		$achieved = $program->achieved_criteria_by_outcome($id,$selected_semesters);
68
-        		$undergradResults['achieved'][] = $achieved;
69
-        		$undergradResults['successRate'][] = sprintf("%.2f",100*$achieved/$attempted);
70
-        	}
71
-
46
+            //        	var_dump($program_id);
47
+            //         	exit();
48
+            $program = Program::where('id', '=', $program_id->id)->first();
49
+            $school = School::where('id', '=', $program->school_id)->first();
50
+            if ($program->is_graduate) {
51
+                $gradResults['names'][] = $program->name;
52
+                $gradResults['schools'][] = $school->name;
53
+                $attempted = $program->attempted_criteria_by_outcome($id, $selected_semesters);
54
+                $gradResults['attempted'][] = $attempted;
55
+                $achieved = $program->achieved_criteria_by_outcome($id, $selected_semesters);
56
+                $gradResults['achieved'][] = $achieved;
57
+                $gradResults['successRate'][] = sprintf("%.2f", 100 * $achieved / $attempted);
58
+            } else {
59
+                $undergradResults['names'][] = $program->name;
60
+                $undergradResults['schools'][] = $school->name;
61
+                $attempted = $program->attempted_criteria_by_outcome($id, $selected_semesters);
62
+                $undergradResults['attempted'][] = $attempted;
63
+                $achieved = $program->achieved_criteria_by_outcome($id, $selected_semesters);
64
+                $undergradResults['achieved'][] = $achieved;
65
+                $undergradResults['successRate'][] = sprintf("%.2f", 100 * $achieved / $attempted);
66
+            }
72 67
         }
73 68
 
74
-	   	$title = "Outcome Results: ".$outcome->name;
69
+        $title = "Outcome Results: " . $outcome->name;
75 70
 
76 71
 
77
-//  		$undergradResults["successRate"]
72
+        //  		$undergradResults["successRate"]
78 73
 
79 74
         return View::make('local.managers.admins.learning-outcome_new', compact('title', 'outcome', 'undergradResults', 'gradResults'));
80 75
     }
81 76
 
82
-//     public function show($id)
83
-//     {
84
-//         DB::disableQueryLog();
85
-//         $outcome = Outcome::find($id);
86
-//
87
-//         $undergradResults=array("names"=>array(), "schools"=>array(), "achieved"=>array(), "attempted"=>array(), "successRate"=>array());
88
-//         $gradResults = array("names"=>array(), "schools"=>array(), "achieved"=>array(), "attempted"=>array(), "successRate"=>array());
89
-//
90
-//         //Calculate performance for this outcome for each undergrad program
91
-//         $undergradPrograms = Program::where('is_graduate','=', 0)
92
-//             ->where(function($query)
93
-//             {
94
-//                 if(Auth::user()->school_id)
95
-//                 {
96
-//                     $query->where('school_id', Auth::user()->school_id);
97
-//                 }
98
-//             })
99
-//             ->with('courses')
100
-//             ->orderBy('name', 'asc')->get();
101
-//
102
-//         foreach($undergradPrograms as $program)
103
-//         {
104
-//             $undergradResults["names"][$program->id]=$program->name;
105
-//             $undergradResults["schools"][$program->id]=$program->school->name;
106
-//             $programAssessed=false;
107
-//
108
-//             $undergradResults["attempted"][$program->id]=0;
109
-//             $undergradResults["achieved"][$program->id]=0;
110
-//
111
-//             foreach($program->courses as $course)
112
-//             {
113
-//                 $course_outcomes_achieved = json_decode($course->outcomes_achieved, true);
114
-//                 $course_outcomes_attempted = json_decode($course->outcomes_attempted, true);
115
-//
116
-//                 $attemptedCriteriaCount=0;
117
-//                 $achievedCriteriaCount=0;
118
-//
119
-//                 // If this outcome was evaluated
120
-//                 if(
121
-//                     $course_outcomes_attempted
122
-//                     && array_key_exists($outcome->id, $course_outcomes_attempted)
123
-//                     && $course_outcomes_attempted[$outcome->id]!=0)
124
-//                 {
125
-//                     // Count +1 for attempted and achieved in the program
126
-//                     $attemptedCriteriaCount+=$course_outcomes_attempted[$outcome->id];
127
-//                     $achievedCriteriaCount+=$course_outcomes_achieved[$outcome->id];
128
-//                     $programAssessed=true;
129
-//
130
-//                     if($attemptedCriteriaCount>0  &&(float)$achievedCriteriaCount/$attemptedCriteriaCount*100 > $outcome->expected_outcome)
131
-//                     {
132
-//                         $undergradResults["achieved"][$program->id]+=1;
133
-//                     }
134
-//                     $undergradResults["attempted"][$program->id]+=1;
135
-//                 }
136
-//             }
137
-//
138
-//             // Calculate success rate for this program
139
-//             if($programAssessed && $undergradResults["attempted"][$program->id]>0)
140
-//                 $undergradResults["successRate"][$program->id]= round((float)$undergradResults["achieved"][$program->id]/$undergradResults["attempted"][$program->id]*100, 2).'%';
141
-//             else
142
-//                 $undergradResults["successRate"][$program->id]= 'N/M';
143
-//         }
144
-//
145
-//
146
-//         //Calculate performance for this outcome for each grad program
147
-//         $gradPrograms = Program::where('is_graduate','=', 1)
148
-//             ->where(function($query)
149
-//             {
150
-//                 if(Auth::user()->school_id)
151
-//                 {
152
-//                     $query->where('school_id', Auth::user()->school_id);
153
-//                 }
154
-//             })
155
-//             ->with(array('courses'=>function($query)
156
-//             {
157
-//                 $query->whereNotNull('outcomes_attempted');
158
-//             }))
159
-//             ->orderBy('name', 'asc')->get();
160
-//
161
-//         foreach($gradPrograms as $program)
162
-//         {
163
-//             $gradResults["names"][$program->id]=$program->name;
164
-//             $gradResults["schools"][$program->id]=$program->school->name;
165
-//
166
-//             $programAssessed=false;
167
-//
168
-//             $gradResults["attempted"][$program->id]=0;
169
-//             $gradResults["achieved"][$program->id]=0;
170
-//
171
-//             foreach($program->courses as $course)
172
-//             {
173
-//                 $course_outcomes_achieved = json_decode($course->outcomes_achieved, true);
174
-//                 $course_outcomes_attempted = json_decode($course->outcomes_attempted, true);
175
-//
176
-//                 $attemptedCriteriaCount=0;
177
-//                 $achievedCriteriaCount=0;
178
-//
179
-//                 // If this outcome was evaluated
180
-//                 if(
181
-//                     $course_outcomes_attempted
182
-//                     && array_key_exists($outcome->id, $course_outcomes_attempted)
183
-//                     && $course_outcomes_attempted[$outcome->id]!=0)
184
-//                 {
185
-//                     // Count +1 for attempted and achieved in the program
186
-//                     $attemptedCriteriaCount+=$course_outcomes_attempted[$outcome->id];
187
-//                     $achievedCriteriaCount+=$course_outcomes_achieved[$outcome->id];
188
-//                     $programAssessed=true;
189
-//
190
-//                     if($attemptedCriteriaCount>0  &&(float)$achievedCriteriaCount/$attemptedCriteriaCount*100 > $outcome->expected_outcome)
191
-//                     {
192
-//                         $gradResults["achieved"][$program->id]+=1;
193
-//                     }
194
-//                     $gradResults["attempted"][$program->id]+=1;
195
-//                 }
196
-//             }
197
-//
198
-//             // Calculate success rate for this program
199
-//             if($programAssessed && $gradResults["attempted"][$program->id]>0)
200
-//                 $gradResults["successRate"][$program->id]= round((float)$gradResults["achieved"][$program->id]/$gradResults["attempted"][$program->id]*100, 2).'%';
201
-//             else
202
-//                 $gradResults["successRate"][$program->id]= 'N/M';
203
-//         }
204
-//
205
-//         $title = "Outcome Results: ".$outcome->name;
206
-//
207
-//         return View::make('local.managers.admins.learning-outcome', compact('title', 'outcome', 'undergradResults', 'gradResults'));
208
-//     }
77
+    //     public function show($id)
78
+    //     {
79
+    //         DB::disableQueryLog();
80
+    //         $outcome = Outcome::find($id);
81
+    //
82
+    //         $undergradResults=array("names"=>array(), "schools"=>array(), "achieved"=>array(), "attempted"=>array(), "successRate"=>array());
83
+    //         $gradResults = array("names"=>array(), "schools"=>array(), "achieved"=>array(), "attempted"=>array(), "successRate"=>array());
84
+    //
85
+    //         //Calculate performance for this outcome for each undergrad program
86
+    //         $undergradPrograms = Program::where('is_graduate','=', 0)
87
+    //             ->where(function($query)
88
+    //             {
89
+    //                 if(Auth::user()->school_id)
90
+    //                 {
91
+    //                     $query->where('school_id', Auth::user()->school_id);
92
+    //                 }
93
+    //             })
94
+    //             ->with('courses')
95
+    //             ->orderBy('name', 'asc')->get();
96
+    //
97
+    //         foreach($undergradPrograms as $program)
98
+    //         {
99
+    //             $undergradResults["names"][$program->id]=$program->name;
100
+    //             $undergradResults["schools"][$program->id]=$program->school->name;
101
+    //             $programAssessed=false;
102
+    //
103
+    //             $undergradResults["attempted"][$program->id]=0;
104
+    //             $undergradResults["achieved"][$program->id]=0;
105
+    //
106
+    //             foreach($program->courses as $course)
107
+    //             {
108
+    //                 $course_outcomes_achieved = json_decode($course->outcomes_achieved, true);
109
+    //                 $course_outcomes_attempted = json_decode($course->outcomes_attempted, true);
110
+    //
111
+    //                 $attemptedCriteriaCount=0;
112
+    //                 $achievedCriteriaCount=0;
113
+    //
114
+    //                 // If this outcome was evaluated
115
+    //                 if(
116
+    //                     $course_outcomes_attempted
117
+    //                     && array_key_exists($outcome->id, $course_outcomes_attempted)
118
+    //                     && $course_outcomes_attempted[$outcome->id]!=0)
119
+    //                 {
120
+    //                     // Count +1 for attempted and achieved in the program
121
+    //                     $attemptedCriteriaCount+=$course_outcomes_attempted[$outcome->id];
122
+    //                     $achievedCriteriaCount+=$course_outcomes_achieved[$outcome->id];
123
+    //                     $programAssessed=true;
124
+    //
125
+    //                     if($attemptedCriteriaCount>0  &&(float)$achievedCriteriaCount/$attemptedCriteriaCount*100 > $outcome->expected_outcome)
126
+    //                     {
127
+    //                         $undergradResults["achieved"][$program->id]+=1;
128
+    //                     }
129
+    //                     $undergradResults["attempted"][$program->id]+=1;
130
+    //                 }
131
+    //             }
132
+    //
133
+    //             // Calculate success rate for this program
134
+    //             if($programAssessed && $undergradResults["attempted"][$program->id]>0)
135
+    //                 $undergradResults["successRate"][$program->id]= round((float)$undergradResults["achieved"][$program->id]/$undergradResults["attempted"][$program->id]*100, 2).'%';
136
+    //             else
137
+    //                 $undergradResults["successRate"][$program->id]= 'N/M';
138
+    //         }
139
+    //
140
+    //
141
+    //         //Calculate performance for this outcome for each grad program
142
+    //         $gradPrograms = Program::where('is_graduate','=', 1)
143
+    //             ->where(function($query)
144
+    //             {
145
+    //                 if(Auth::user()->school_id)
146
+    //                 {
147
+    //                     $query->where('school_id', Auth::user()->school_id);
148
+    //                 }
149
+    //             })
150
+    //             ->with(array('courses'=>function($query)
151
+    //             {
152
+    //                 $query->whereNotNull('outcomes_attempted');
153
+    //             }))
154
+    //             ->orderBy('name', 'asc')->get();
155
+    //
156
+    //         foreach($gradPrograms as $program)
157
+    //         {
158
+    //             $gradResults["names"][$program->id]=$program->name;
159
+    //             $gradResults["schools"][$program->id]=$program->school->name;
160
+    //
161
+    //             $programAssessed=false;
162
+    //
163
+    //             $gradResults["attempted"][$program->id]=0;
164
+    //             $gradResults["achieved"][$program->id]=0;
165
+    //
166
+    //             foreach($program->courses as $course)
167
+    //             {
168
+    //                 $course_outcomes_achieved = json_decode($course->outcomes_achieved, true);
169
+    //                 $course_outcomes_attempted = json_decode($course->outcomes_attempted, true);
170
+    //
171
+    //                 $attemptedCriteriaCount=0;
172
+    //                 $achievedCriteriaCount=0;
173
+    //
174
+    //                 // If this outcome was evaluated
175
+    //                 if(
176
+    //                     $course_outcomes_attempted
177
+    //                     && array_key_exists($outcome->id, $course_outcomes_attempted)
178
+    //                     && $course_outcomes_attempted[$outcome->id]!=0)
179
+    //                 {
180
+    //                     // Count +1 for attempted and achieved in the program
181
+    //                     $attemptedCriteriaCount+=$course_outcomes_attempted[$outcome->id];
182
+    //                     $achievedCriteriaCount+=$course_outcomes_achieved[$outcome->id];
183
+    //                     $programAssessed=true;
184
+    //
185
+    //                     if($attemptedCriteriaCount>0  &&(float)$achievedCriteriaCount/$attemptedCriteriaCount*100 > $outcome->expected_outcome)
186
+    //                     {
187
+    //                         $gradResults["achieved"][$program->id]+=1;
188
+    //                     }
189
+    //                     $gradResults["attempted"][$program->id]+=1;
190
+    //                 }
191
+    //             }
192
+    //
193
+    //             // Calculate success rate for this program
194
+    //             if($programAssessed && $gradResults["attempted"][$program->id]>0)
195
+    //                 $gradResults["successRate"][$program->id]= round((float)$gradResults["achieved"][$program->id]/$gradResults["attempted"][$program->id]*100, 2).'%';
196
+    //             else
197
+    //                 $gradResults["successRate"][$program->id]= 'N/M';
198
+    //         }
199
+    //
200
+    //         $title = "Outcome Results: ".$outcome->name;
201
+    //
202
+    //         return View::make('local.managers.admins.learning-outcome', compact('title', 'outcome', 'undergradResults', 'gradResults'));
203
+    //     }
209 204
 
210 205
     // TODO: Clean up and verify relationships are correct
211 206
     public function newShow($id)
@@ -415,7 +410,12 @@ class OutcomesController extends \BaseController
415 410
         if (Input::get('filter')) {
416 411
             switch (Input::get('filter')) {
417 412
                 case 'all':
418
-                    return Outcome::find(Input::get('id'))->criteria;
413
+                    return DB::table('new_criteria')
414
+                        ->join('criterion_objective_outcome', 'criterion_objective_outcome.criterion_id', '=', 'new_criteria.id')
415
+                        ->where('criterion_objective_outcome.outcome_id', '=', Input::get('id'))
416
+                        ->select('criterion_id as id', 'name')
417
+                        ->orderBy('name', 'ASC')
418
+                        ->get();
419 419
                     break;
420 420
 
421 421
                 case 'school':
@@ -424,12 +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
-
428
-                        // Return all criteria belonging to any of those programs
429
-                        return Criterion::where('outcome_id', Input::get('id'))
430
-                            ->whereIn('program_id', $program_ids)
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')
430
+                            ->where('criterion_objective_outcome.outcome_id', '=', Input::get('id'))
431
+                            ->whereIn('program_criterion.program_id', $program_ids)
432
+                            ->select('criterion_id as id', 'name')
431 433
                             ->orderBy('name', 'ASC')
432 434
                             ->get();
435
+                        // Return all criteria belonging to any of those programs
436
+                        return $new_criteria;
433 437
                     }
434 438
 
435 439
                     // If pcoord
@@ -438,8 +442,12 @@ class OutcomesController extends \BaseController
438 442
                         // Fetch all the programs from the user's school;
439 443
                         $program_ids = DB::table('programs')->where('school_id', Auth::user()->programs[0]->school->id)->lists('id');
440 444
 
441
-                        return Criterion::where('outcome_id', Input::get('id'))
442
-                            ->whereIn('program_id', $program_ids)
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')
448
+                            ->where('criterion_objective_outcome.outcome_id', '=', Input::get('id'))
449
+                            ->whereIn('program_criterion.program_id', $program_ids)
450
+                            ->select('criterion_id as id', 'name')
443 451
                             ->orderBy('name', 'ASC')
444 452
                             ->get();
445 453
                     }
@@ -447,18 +455,33 @@ class OutcomesController extends \BaseController
447 455
                     break;
448 456
 
449 457
                 case 'program':
450
-                    return Criterion::where('outcome_id', Input::get('id'))
451
-                        ->whereIn('program_id', Auth::user()->programs->lists('id'))
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')
461
+                        ->where('criterion_objective_outcome.outcome_id', '=', Input::get('id'))
462
+                        ->whereIn('program_criterion.program_id', Auth::user()->programs->lists('id'))
463
+                        ->select('criterion_id as id', 'name')
452 464
                         ->orderBy('name', 'ASC')
453 465
                         ->get();
466
+                    return $new_criteria;
454 467
                     break;
455 468
 
456 469
                 default:
457
-                    return Outcome::find(Input::get('id'))->criteria;
470
+                    return DB::table('new_criteria')
471
+                        ->join('criterion_objective_outcome', 'criterion_objective_outcome.criterion_id', '=', 'new_criteria.id')
472
+                        ->where('criterion_objective_outcome.outcome_id', '=', Input::get('id'))
473
+                        ->select('criterion_id as id', 'name')
474
+                        ->orderBy('name', 'ASC')
475
+                        ->get();
458 476
                     break;
459 477
             }
460 478
         } else {
461
-            return Outcome::find(Input::get('id'))->criteria;
479
+            return DB::table('new_criteria')
480
+                ->join('criterion_objective_outcome', 'criterion_objective_outcome.criterion_id', '=', 'new_criteria.id')
481
+                ->where('criterion_objective_outcome.outcome_id', '=', Input::get('id'))
482
+                ->select('criterion_id as id', 'name')
483
+                ->orderBy('name', 'ASC')
484
+                ->get();
462 485
         }
463 486
     }
464 487
 
@@ -541,25 +564,25 @@ class OutcomesController extends \BaseController
541 564
 
542 565
         $outcome->criteria = array();
543 566
         foreach ($diferent_levels as $level) {
544
-          $level = $level->levels;
545
-
546
-          // buscar todos los criterios con el level y ponerlos en un array
547
-          $outcome_criterias = DB::table('criterion_objective_outcome')
548
-              ->join('new_criteria', 'new_criteria.id', '=', 'criterion_objective_outcome.criterion_id')
549
-              ->join('objectives', 'objectives.id', '=', 'criterion_objective_outcome.objective_id')
550
-              ->where('criterion_objective_outcome.outcome_id', $id)
551
-              ->where('new_criteria.number_of_scales', $level)
552
-              ->whereNull('new_criteria.deleted_at')
553
-              ->select('new_criteria.id','new_criteria.name')
554
-              ->orderBy('new_criteria.name', 'asc')
555
-              ->get();
556
-          $outcome_criterias = $outcome_criterias;
557
-
558
-          foreach ($outcome_criterias as $criteria_id) {
559
-
560
-            $scales =
561
-              DB::select(
562
-                  DB::raw("
567
+            $level = $level->levels;
568
+
569
+            // buscar todos los criterios con el level y ponerlos en un array
570
+            $outcome_criterias = DB::table('criterion_objective_outcome')
571
+                ->join('new_criteria', 'new_criteria.id', '=', 'criterion_objective_outcome.criterion_id')
572
+                ->join('objectives', 'objectives.id', '=', 'criterion_objective_outcome.objective_id')
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')
578
+                ->get();
579
+            $outcome_criterias = $outcome_criterias;
580
+
581
+            foreach ($outcome_criterias as $criteria_id) {
582
+
583
+                $scales =
584
+                    DB::select(
585
+                        DB::raw("
563 586
                   SELECT *
564 587
                   FROM (
565 588
                     SELECT new_criteria.id as criterion_id,
@@ -579,16 +602,15 @@ class OutcomesController extends \BaseController
579 602
                   WHERE rn = 1
580 603
                   ORDER BY `a`.`position` ASC
581 604
                       ")
582
-              );
583
-              // insertar la informacion de los criterios con N niveles en el arreglo de arreglos
584
-              $criteria_id->scales = $scales;
585
-              // $i++;
586
-            }//ends foreach criteria_id
587
-            array_push($outcome->criteria, array($outcome_criterias,'amount_of_levels'=>$level));
588
-        }//ends foreach level
589
-
590
-        return array
591
-        (
605
+                    );
606
+                // insertar la informacion de los criterios con N niveles en el arreglo de arreglos
607
+                $criteria_id->scales = $scales;
608
+                // $i++;
609
+            } //ends foreach criteria_id
610
+            array_push($outcome->criteria, array($outcome_criterias, 'amount_of_levels' => $level));
611
+        } //ends foreach level
612
+
613
+        return array(
592 614
             'outcome' => $outcome,
593 615
         );
594 616
     }

+ 55
- 31
app/controllers/RubricsController.php Parādīt failu

@@ -45,20 +45,18 @@ class RubricsController extends \BaseController
45 45
         if (!$activity)
46 46
             App::abort('404');
47 47
 
48
-        $title = 'Rubric for <em>'.$activity->name.'</em>';
48
+        $title = 'Rubric for <em>' . $activity->name . '</em>';
49 49
 
50 50
         // Select templates that belong to everyone or belong to the activity's course's school
51
-        $templates = Template::
52
-        where('is_visible', '=', 1)
53
-        ->where(function($query) use ($activity)
54
-        {
55
-            if(Auth::user()->role != 1){
56
-                $query
57
-                ->where('school_id', $activity->course->program->school->id)
58
-                ->orWhere('school_id', '=', NULL);
59
-            }
60
-        })
61
-        ->orderBy('name', 'ASC')->get();
51
+        $templates = Template::where('is_visible', '=', 1)
52
+            ->where(function ($query) use ($activity) {
53
+                if (Auth::user()->role != 1) {
54
+                    $query
55
+                        ->where('school_id', $activity->course->program->school->id)
56
+                        ->orWhere('school_id', '=', NULL);
57
+                }
58
+            })
59
+            ->orderBy('name', 'ASC')->get();
62 60
 
63 61
         $rubrics = Auth::user()->rubrics;
64 62
         $outcomes = Outcome::orderBy('name', 'ASC')->get();
@@ -78,38 +76,63 @@ class RubricsController extends \BaseController
78 76
 
79 77
         DB::beginTransaction();
80 78
 
81
-        try {
82
-            // Get rubric contents
83
-            $rubric_contents = json_decode(Input::get('contents'));
84
-
85
-            // Process rubric
86
-            $rubric = new Rubric;
87
-            $rubric->name = Input::get('name');
88
-            $rubric->contents = json_encode($rubric_contents);
89
-            $rubric->expected_percentage = Input::get('expected_percentage');
90
-            $rubric->expected_points = Input::get('expected_points');
91
-            $rubric->user_id = Auth::id();
92
-            $rubric->save();
79
+
80
+        // Get rubric contents
81
+        $rubric_contents = json_decode(Input::get('contents'));
82
+        $scales = Input::get('scales');
83
+        $criteria = Input::get('criteria');
84
+
85
+        // Process rubric
86
+        $rubric = new Rubric;
87
+        $rubric->name = Input::get('name');
88
+        $rubric->contents = json_encode($rubric_contents);
89
+        $rubric->expected_percentage = Input::get('expected_percentage');
90
+        $rubric->expected_points = Input::get('expected_points');
91
+        $rubric->user_id = Auth::id();
92
+        $rubric->num_scales = count($scales[0]);
93
+        $rubric->max_score = Input::get('max_score');
94
+        $division = $rubric->max_score / count($scales[0]);
95
+        if ($rubric->save()) {
93 96
 
94 97
             // Process activity
95
-//             $activity = Activity::find(Input::get('activity_id'));
96
-//             $activity->rubric_id = $rubric->id;
97
-//             $activity->save();
98
+            //             $activity = Activity::find(Input::get('activity_id'));
99
+            //             $activity->rubric_id = $rubric->id;
100
+            //             $activity->save();
98 101
 
99
-			DB::table('new_rubric_activity')->insert(array('activity_id'=>Input::get('activity_id'),'rubric_id'=> $rubric->id));
102
+            DB::table('new_rubric_activity')->insert(array('activity_id' => Input::get('activity_id'), 'rubric_id' => $rubric->id));
100 103
             DB::commit();
101 104
 
105
+            $rubricId = $rubric->id;
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)
109
+                    ->where('criterion_id', '=', $criterion_id)->first();
110
+
111
+                for ($i = 0; $i < count($scales[$index]); $i++) {
112
+                    $scale = new Scale;
113
+                    $scale->description = $scales[$index][$i];
114
+                    $scale->min_score = 1 + ($division * $i);
115
+                    $scale->max_score = ($division * ($i + 1));
116
+                    if ($scale->save()) {
117
+                        DB::insert("insert into `rubric_criteria_scale` (`rubric_criterion_id`, `scale_id`, `position`) values ({$rubric_criterion_id->id},{$scale->id}, {$i})");
118
+                    } else {
119
+                        Session::flash('status', 'danger');
120
+                        Session::flash('message', 'Rubric could not be created.');
121
+                    }
122
+                }
123
+            }
102 124
             Session::flash('status', 'success');
103 125
             Session::flash('message', 'Rubric assigned.');
104 126
 
105 127
             return action('ActivitiesController@show', array(Input::get('activity_id')));
106
-
128
+        } else {
107 129
             DB::rollBack();
108 130
             Session::flash('status', 'danger');
109
-            Session::flash('message', 'Error creating Rubric. Try again later.'.$e);
131
+            Session::flash('message', 'Error creating Rubric. Try again later.' . $e);
110 132
         }
111 133
     }
112 134
 
135
+
113 136
     /**
114 137
      * Return a specific template
115 138
      *
@@ -251,8 +274,9 @@ class RubricsController extends \BaseController
251 274
         // If activity does not belong to the requesting user, display 403
252 275
         if ($course->user_id != Auth::id())
253 276
             App::abort('403', 'Access Forbidden');
277
+        Log::info($activity->rubric[0]->id);
254 278
 
255
-        $rubric = Rubric::where('id', '=', $activity->rubric_id)->firstOrFail();
279
+        $rubric = Rubric::where('id', '=', $activity->rubric[0]->id)->firstOrFail();
256 280
         $title = $activity->name . ': ' . $rubric->name;
257 281
         return View::make('local.professors.viewrubric', compact('rubric', 'activity', 'title', 'course'));
258 282
     }

+ 86
- 61
app/controllers/TemplatesController.php Parādīt failu

@@ -1,6 +1,7 @@
1 1
 <?php
2 2
 
3
-class TemplatesController extends \BaseController {
3
+class TemplatesController extends \BaseController
4
+{
4 5
 
5 6
 	/**
6 7
 	 * List all templates, grouped by program
@@ -12,12 +13,12 @@ class TemplatesController extends \BaseController {
12 13
 		$global_templates = Template::whereNull('school_id')->whereNull('program_id')->get();
13 14
 
14 15
 		$schools = School::with('programs.templates')
15
-		->orderBy('name')
16
-		->get();
16
+			->orderBy('name')
17
+			->get();
17 18
 
18 19
 		$templates = Template::orderBy('name')->get();
19 20
 
20
-		return View::make('local.managers.admins.rubric_list', compact('title', 'global_templates','schools', 'templates'));
21
+		return View::make('local.managers.admins.rubric_list', compact('title', 'global_templates', 'schools', 'templates'));
21 22
 	}
22 23
 
23 24
 	public function schoolCoordinatorIndex()
@@ -27,18 +28,18 @@ class TemplatesController extends \BaseController {
27 28
 		$global_templates = Template::whereNull('school_id')->whereNull('program_id')->get();
28 29
 
29 30
 		$schools = School::with('programs.templates')
30
-		->orderBy('name')
31
-		->get();
31
+			->orderBy('name')
32
+			->get();
32 33
 
33 34
 		$templates = Template::orderBy('name')->get();
34 35
 
35
-		return View::make('local.managers.admins.rubric_list', compact('title', 'global_templates','schools', 'templates'));
36
+		return View::make('local.managers.admins.rubric_list', compact('title', 'global_templates', 'schools', 'templates'));
36 37
 	}
37 38
 
38 39
 	public function show(Template $template)
39 40
 	{
40
-	    $title = $template->name;
41
-	    return View::make('local.managers.admins.view_template', compact('template', 'title'));
41
+		$title = $template->name;
42
+		return View::make('local.managers.admins.view_template', compact('template', 'title'));
42 43
 	}
43 44
 
44 45
 	/**
@@ -48,7 +49,7 @@ class TemplatesController extends \BaseController {
48 49
 	 */
49 50
 	public function newTemplate()
50 51
 	{
51
-		$title= "Rubric Builder";
52
+		$title = "Rubric Builder";
52 53
 
53 54
 		$templates = Template::orderBy('name', 'ASC')->get();
54 55
 		$outcomes = Outcome::orderBy('name', 'ASC')->get();
@@ -59,18 +60,13 @@ class TemplatesController extends \BaseController {
59 60
 		$templates = NULL;
60 61
 		$programs = NULL;
61 62
 		// Returns templates depending on the type of user
62
-		if( $role == 1)
63
-		{
63
+		if ($role == 1) {
64 64
 			$templates = Template::orderBy('name', 'ASC')->get();
65 65
 			$programs = Program::orderBy('name', 'ASC')->get();
66
-
67
-		} elseif ($role == 2)
68
-		{
69
-			$templates = Template::where('school_id', '=', Auth::user()->school->id )->orWhere('school_id', '=', NULL)->orderBy('name', 'ASC')->get();
66
+		} elseif ($role == 2) {
67
+			$templates = Template::where('school_id', '=', Auth::user()->school->id)->orWhere('school_id', '=', NULL)->orderBy('name', 'ASC')->get();
70 68
 			$programs = Auth::user()->school->programs;
71
-		}
72
-		elseif ($role == 3)
73
-		{
69
+		} elseif ($role == 3) {
74 70
 			$templates = Template::where('school_id', '=', Auth::user()->programs[0]->school->id)->orWhere('school_id', '=', NULL)->orderBy('name', 'ASC')->get();
75 71
 			$programs = Auth::user()->programs()->get();
76 72
 		}
@@ -96,21 +92,19 @@ class TemplatesController extends \BaseController {
96 92
 
97 93
 		// If user can set the school (that is, if school_id is not undefined)
98 94
 		// set the school id or set to null
99
-		if(is_numeric(Input::get('school_id')))
100
-		{
101
-			if(Input::get('school_id')!=0)
95
+		if (is_numeric(Input::get('school_id'))) {
96
+			if (Input::get('school_id') != 0)
102 97
 				$template->school_id = Input::get('school_id');
103
-			elseif(Input::get('school_id')==0)
98
+			elseif (Input::get('school_id') == 0)
104 99
 				$template->school_id = NULL;
105 100
 		}
106 101
 
107 102
 		// If user can set the program (that is, if program_id is not undefined)
108 103
 		// set the program id or set to null
109
-		if(is_numeric(Input::get('program_id')))
110
-		{
111
-			if(Input::get('program_id')!=0)
104
+		if (is_numeric(Input::get('program_id'))) {
105
+			if (Input::get('program_id') != 0)
112 106
 				$template->program_id = Input::get('program_id');
113
-			elseif(Input::get('program_id')==0)
107
+			elseif (Input::get('program_id') == 0)
114 108
 				$template->program_id = NULL;
115 109
 		}
116 110
 
@@ -126,14 +120,40 @@ class TemplatesController extends \BaseController {
126 120
 				$template->program_id = Auth::user()->programs[0]->id;
127 121
 				break;
128 122
 		}
129
-
130
-		if($template->save())
131
-		{
123
+		$scales = Input::get('scales');
124
+		$criteria = Input::get('criteria');
125
+
126
+		$max_score = Input::get('max_score');
127
+		Log::info($scales);
128
+		Log::info($criteria);
129
+
130
+
131
+		$template->num_scales = count($scales[0]);
132
+		$template->max_score = $max_score;
133
+		$division = $max_score / count($scales[0]);
134
+		if ($template->save()) {
135
+			$templateId = $template->id;
136
+			foreach ($criteria as $index => $criterion_id) {
137
+				DB::insert("insert into template_criterion (`template_id`,`criterion_id`) values ({$templateId},{$criterion_id})");
138
+				$template_criterion_id = DB::table('template_criterion')->where('template_id', '=', $templateId)
139
+					->where('criterion_id', '=', $criterion_id)->first();
140
+
141
+				for ($i = 0; $i < count($scales[$index]); $i++) {
142
+					$scale = new Scale;
143
+					$scale->description = $scales[$index][$i];
144
+					$scale->min_score = 1 + ($division * $i);
145
+					$scale->max_score = ($division * ($i + 1));
146
+					if ($scale->save()) {
147
+						DB::insert("insert into `template_criterion_scale` (`template_criterion_id`, `scale_id`, `position`) values ({$template_criterion_id->id},{$scale->id}, {$i})");
148
+					} else {
149
+						Session::flash('status', 'danger');
150
+						Session::flash('message', 'Rubric could not be created.');
151
+					}
152
+				}
153
+			}
132 154
 			Session::flash('status', 'success');
133 155
 			Session::flash('message', 'Rubric created. You can now select it from the list.');
134
-		}
135
-		else
136
-		{
156
+		} else {
137 157
 			Session::flash('status', 'danger');
138 158
 			Session::flash('message', 'Rubric could not be created.');
139 159
 		}
@@ -146,7 +166,22 @@ class TemplatesController extends \BaseController {
146 166
 	 */
147 167
 	public function fetch()
148 168
 	{
149
-		return Template::find(Input::get('id'));
169
+		$template_info = [];
170
+		$template_info['template'] = Template::find(Input::get('id'));
171
+		$template_info['criterion'] = DB::table('new_criteria')
172
+			->join('template_criterion', 'template_criterion.criterion_id', '=', 'new_criteria.id')
173
+			->where("template_criterion.template_id", '=', Input::get('id'))
174
+			->get();
175
+		foreach ($template_info['criterion'] as $temp_crit) {
176
+			$template_info['scales'][$temp_crit->id] = DB::table('scales')
177
+				->join('template_criterion_scale', 'template_criterion_scale.scale_id', '=', 'scales.id')
178
+				->where('template_criterion_scale.template_criterion_id', '=', $temp_crit->id)
179
+				->orderBy('position', 'ASC')
180
+				->get();
181
+		}
182
+		Log::info($template_info);
183
+
184
+		return json_encode($template_info);
150 185
 	}
151 186
 
152 187
 	/**
@@ -166,33 +201,28 @@ class TemplatesController extends \BaseController {
166 201
 
167 202
 		// If user can set the school (that is, if school_id is not undefined)
168 203
 		// set the school id or set to null
169
-		if(is_numeric(Input::get('school_id')))
170
-		{
171
-			if(Input::get('school_id')!=0)
204
+		if (is_numeric(Input::get('school_id'))) {
205
+			if (Input::get('school_id') != 0)
172 206
 				$template->school_id = Input::get('school_id');
173
-			elseif(Input::get('school_id')==0)
207
+			elseif (Input::get('school_id') == 0)
174 208
 				$template->school_id = NULL;
175 209
 		}
176 210
 
177 211
 		// If user can set the program (that is, if program_id is not undefined)
178 212
 		// set the program id or set to null
179
-		if(is_numeric(Input::get('program_id')))
180
-		{
181
-			if(Input::get('program_id')!=0)
213
+		if (is_numeric(Input::get('program_id'))) {
214
+			if (Input::get('program_id') != 0)
182 215
 				$template->program_id = Input::get('program_id');
183
-			elseif(Input::get('program_id')==0)
216
+			elseif (Input::get('program_id') == 0)
184 217
 				$template->program_id = NULL;
185 218
 		}
186 219
 
187
-		if($template->save())
188
-		{
220
+		if ($template->save()) {
189 221
 			Session::flash('status', 'success');
190
-			Session::flash('message', 'Rubric updated ('.date('m/d/y, h:i:s a').').');
191
-		}
192
-		else
193
-		{
222
+			Session::flash('message', 'Rubric updated (' . date('m/d/y, h:i:s a') . ').');
223
+		} else {
194 224
 			Session::flash('status', 'danger');
195
-			Session::flash('message', 'Rubric could not be updated ('.date('m/d/y, h:i:s a').').');
225
+			Session::flash('message', 'Rubric could not be updated (' . date('m/d/y, h:i:s a') . ').');
196 226
 		}
197 227
 	}
198 228
 
@@ -205,13 +235,10 @@ class TemplatesController extends \BaseController {
205 235
 	{
206 236
 		$template = Template::find(Input::get('id'));
207 237
 
208
-		if($template->delete())
209
-		{
238
+		if ($template->delete()) {
210 239
 			Session::flash('status', 'success');
211 240
 			Session::flash('message', 'Rubric deleted.');
212
-		}
213
-		else
214
-		{
241
+		} else {
215 242
 			Session::flash('status', 'danger');
216 243
 			Session::flash('message', 'Rubric could not be deleted.');
217 244
 		}
@@ -226,23 +253,21 @@ class TemplatesController extends \BaseController {
226 253
 
227 254
 			$title = $template->name;
228 255
 
229
-			if($template->school_id!=NULL)
230
-				$school= $template->school->name;
256
+			if ($template->school_id != NULL)
257
+				$school = $template->school->name;
231 258
 			else
232 259
 				$school = 'All Schools';
233 260
 
234
-			if($template->program_id!=NULL)
235
-				$program= $template->program->name;
261
+			if ($template->program_id != NULL)
262
+				$program = $template->program->name;
236 263
 			else
237 264
 				$program = 'All Programs';
238 265
 
239 266
 			return View::make('local.managers.shared.print_rubric', compact('title', 'template', 'school', 'program'));
240
-		}
241
-		catch (Exception $e) {
267
+		} catch (Exception $e) {
242 268
 			Session::flash('status', 'danger');
243 269
 			Session::flash('message', $e->getMessage());
244 270
 			return Redirect::back();
245 271
 		}
246 272
 	}
247
-
248 273
 }

+ 11
- 18
app/controllers/ThreeYearPlanController.php Parādīt failu

@@ -420,14 +420,9 @@ class ThreeYearPlanController extends \BaseController
420 420
           foreach ($result_objectives as $objectives_) {
421 421
             $objective_id = $objectives_->objective_id;
422 422
             $program_id = $objectives_->program_id;
423
-            $result_courses = DB::table('objective_program')
424
-              ->join('objectives', 'objectives.id', '=', 'objective_program.objective_id')
425
-              ->join('courses', 'courses.program_id', '=', 'objective_program.program_id')
426
-              ->where('objective_program.objective_id', $objective_id)
427
-              ->where('objective_program.program_id', $program_id)
428
-              ->where('courses.semester_id', $semester_id)
429
-              ->distinct('courses.name', 'courses.code')
430
-              ->select('courses.id as course_id', 'courses.name', 'courses.code', 'objective_program.objective_id', 'objective_program.program_id')
423
+            $result_courses = DB::table('courses')
424
+              ->where('courses.program_id', '=', $program_id)
425
+              ->select('courses.id as course_id', 'courses.name', 'courses.code', 'courses.program_id')
431 426
               ->orderBy('courses.name', 'asc')
432 427
               ->groupBy('courses.name', 'courses.code')
433 428
               ->get();
@@ -539,13 +534,14 @@ class ThreeYearPlanController extends \BaseController
539 534
     }
540 535
     return 'update succes?';
541 536
   }
542
-
543 537
   public function createAnnualPlan($program_id)
544 538
   {
545 539
     $current_typ = DB::select("select * from three_year_plan where year_start <=" . date('Y') . " and year_end >=" . date('Y'))[0];
546 540
     $count = 0;
547 541
     $yearStartPlusOne = $current_typ->year_start + 1;
548 542
     $yearStart = $current_typ->year_start;
543
+    Log::info($yearStart);
544
+    Log::info($yearStartPlusOne);
549 545
     while ($count < 3) {
550 546
 
551 547
 
@@ -554,19 +550,16 @@ class ThreeYearPlanController extends \BaseController
554 550
 
555 551
       $secondSemester = DB::select("select * from semesters where name like 'Second Semester {$yearStart}-{$yearStartPlusOne}'");
556 552
       if (count($firstSemester) && count($secondSemester)) {
553
+        Log::info($firstSemester);
554
+        Log::info($secondSemester);
557 555
         $query = DB::select("select * from annual_plans where semester_start ={$firstSemester[0]->id} and semester_end ={$secondSemester[0]->id} and program_id = {$program_id}");
558 556
         if (!count($query)) {
559
-          DB::insert("insert into annual_plans (academic_year, semester_start, semester_end, program_id) values ('{$yearStart}-{$yearStartPlusOne}', {$firstSemester->id}, {$secondSemester->id}, {$program_id})");
557
+          DB::insert("insert into annual_plans (academic_year, semester_start, semester_end, program_id) values ('{$yearStart}-{$yearStartPlusOne}', {$firstSemester[0]->id}, {$secondSemester[0]->id}, {$program_id})");
560 558
         }
561
-        $count++;
562
-        $yearStart++;
563
-        $yearStartPlusOne++;
564
-      } else {
565
-        $count++;
566
-        $yearStart++;
567
-        $yearStartPlusOne++;
568
-        continue;
569 559
       }
560
+      $count++;
561
+      $yearStart++;
562
+      $yearStartPlusOne++;
570 563
     }
571 564
   }
572 565
 }

+ 50
- 0
app/database/migrations/2021_05_20_134522_fix_every_table_for_rubric.php Parādīt failu

@@ -0,0 +1,50 @@
1
+<?php
2
+
3
+use Illuminate\Database\Schema\Blueprint;
4
+use Illuminate\Database\Migrations\Migration;
5
+use Illuminate\Support\Facades\Schema;
6
+
7
+class FixEveryTableForRubric extends Migration
8
+{
9
+
10
+	/**
11
+	 * Run the migrations.
12
+	 *
13
+	 * @return void
14
+	 */
15
+	public function up()
16
+	{
17
+		Schema::table('rubrics', function (Blueprint $table) {
18
+			$table->integer('num_scales')->unsigned();
19
+			$table->integer('max_score')->unsigned();
20
+		});
21
+		Schema::table('templates', function (Blueprint $table) {
22
+			$table->integer('num_scales')->unsigned();
23
+			$table->integer('max_score')->unsigned();
24
+		});
25
+		Schema::table('scales', function (Blueprint $table) {
26
+			$table->dropColumn('title');
27
+			$table->dropColumn('position');
28
+		});
29
+	}
30
+
31
+	/**
32
+	 * Reverse the migrations.
33
+	 *
34
+	 * @return void
35
+	 */
36
+	public function down()
37
+	{
38
+		Schema::table('rubrics', function (Blueprint $table) {
39
+			$table->dropColumn('num_scales');
40
+			$table->dropColumn('max_score');
41
+		});
42
+		Schema::table('templates', function (Blueprint $table) {
43
+			$table->dropColumn('num_scales');
44
+			$table->dropColumn('max_score');
45
+		});
46
+		Schema::table('scales', function (Blueprint $table) {
47
+			$table->text('title');
48
+		});
49
+	}
50
+}

+ 44
- 0
app/database/migrations/2021_05_20_184230_create_rubric_scales.php Parādīt failu

@@ -0,0 +1,44 @@
1
+<?php
2
+
3
+use Illuminate\Database\Schema\Blueprint;
4
+use Illuminate\Database\Migrations\Migration;
5
+use Illuminate\Support\Facades\Schema;
6
+
7
+class CreateRubricScales extends Migration
8
+{
9
+
10
+	/**
11
+	 * Run the migrations.
12
+	 *
13
+	 * @return void
14
+	 */
15
+	public function up()
16
+	{
17
+		Schema::create("rubric_criteria_scale", function (Blueprint $table) {
18
+			$table->increments('id');
19
+			$table->integer('rubric_criterion_id')->unsigned();
20
+			$table->integer('scale_id')->unsigned();
21
+			$table->foreign('scale_id')
22
+				->references('id')
23
+				->on('scales')
24
+				->onDelete('cascade')
25
+				->onUpdate('cascade');
26
+			$table->foreign('rubric_criterion_id')
27
+				->references('id')
28
+				->on('new_criterion_rubric')
29
+				->onDelete('cascade')
30
+				->onUpdate('cascade');
31
+			$table->integer('position');
32
+		});
33
+	}
34
+
35
+	/**
36
+	 * Reverse the migrations.
37
+	 *
38
+	 * @return void
39
+	 */
40
+	public function down()
41
+	{
42
+		Schema::drop('rubric_criteria_scale');
43
+	}
44
+}

+ 42
- 0
app/database/migrations/2021_05_20_212410_create_template_criterion.php Parādīt failu

@@ -0,0 +1,42 @@
1
+<?php
2
+
3
+use Illuminate\Database\Schema\Blueprint;
4
+use Illuminate\Database\Migrations\Migration;
5
+
6
+class CreateTemplateCriterion extends Migration
7
+{
8
+
9
+	/**
10
+	 * Run the migrations.
11
+	 *
12
+	 * @return void
13
+	 */
14
+	public function up()
15
+	{
16
+		Schema::create('template_criterion', function (Blueprint $table) {
17
+			$table->increments('id');
18
+			$table->integer('template_id')->unsigned();
19
+			$table->integer('criterion_id')->unsigned();
20
+			$table->foreign('criterion_id')
21
+				->references('id')
22
+				->on('new_criteria')
23
+				->onDelete('cascade')
24
+				->onUpdate('cascade');
25
+			$table->foreign('template_id')
26
+				->references('id')
27
+				->on('templates')
28
+				->onDelete('cascade')
29
+				->onUpdate('cascade');
30
+		});
31
+	}
32
+
33
+	/**
34
+	 * Reverse the migrations.
35
+	 *
36
+	 * @return void
37
+	 */
38
+	public function down()
39
+	{
40
+		Schema::drop('template_criterion');
41
+	}
42
+}

+ 43
- 0
app/database/migrations/2021_05_20_212437_create_template_criterion_son_scale.php Parādīt failu

@@ -0,0 +1,43 @@
1
+<?php
2
+
3
+use Illuminate\Database\Schema\Blueprint;
4
+use Illuminate\Database\Migrations\Migration;
5
+
6
+class CreateTemplateCriterionSonScale extends Migration
7
+{
8
+
9
+	/**
10
+	 * Run the migrations.
11
+	 *
12
+	 * @return void
13
+	 */
14
+	public function up()
15
+	{
16
+		Schema::create('template_criterion_scale', function (Blueprint $table) {
17
+			$table->increments('id');
18
+			$table->integer('template_criterion_id')->unsigned();
19
+			$table->integer('scale_id')->unsigned();
20
+			$table->foreign('template_criterion_id')
21
+				->references('id')
22
+				->on('template_criterion')
23
+				->onDelete('cascade')
24
+				->onUpdate('cascade');
25
+			$table->foreign('scale_id')
26
+				->references('id')
27
+				->on('scales')
28
+				->onDelete('cascade')
29
+				->onUpdate('cascade');
30
+			$table->integer('position');
31
+		});
32
+	}
33
+
34
+	/**
35
+	 * Reverse the migrations.
36
+	 *
37
+	 * @return void
38
+	 */
39
+	public function down()
40
+	{
41
+		Schema::drop('template_criterion_scale');
42
+	}
43
+}

+ 44
- 0
app/database/unusedMigrations/2021_05_14_072542_create_rubric_outcome.php Parādīt failu

@@ -0,0 +1,44 @@
1
+<?php
2
+
3
+use Illuminate\Database\Schema\Blueprint;
4
+use Illuminate\Database\Migrations\Migration;
5
+
6
+class CreateRubricOutcome extends Migration
7
+{
8
+
9
+	/**
10
+	 * Run the migrations.
11
+	 *
12
+	 * @return void
13
+	 */
14
+	public function up()
15
+	{
16
+		Schema::create('rubric_outcome', function (Blueprint $table) {
17
+			$table->increments('id');
18
+
19
+			$table->integer('rubric_id')->unsigned();
20
+			$table->foreign('rubric_id')
21
+				->references('id')
22
+				->on('rubrics')
23
+				->onDelete('cascade')
24
+				->onUpdate('cascade');
25
+
26
+			$table->integer('outcome_id')->unsigned();
27
+			$table->foreign('outcome_id')
28
+				->references('id')
29
+				->on('outcomes')
30
+				->onDelete('cascade')
31
+				->onUpdate('cascade');
32
+		});
33
+	}
34
+
35
+	/**
36
+	 * Reverse the migrations.
37
+	 *
38
+	 * @return void
39
+	 */
40
+	public function down()
41
+	{
42
+		Schema::drop('rubric_outcome');
43
+	}
44
+}

+ 4
- 0
app/routes.php Parādīt failu

@@ -172,6 +172,10 @@ Route::group(array('before' => 'auth|has_access'), function () {
172 172
         'as' => 'fetchCriteria',
173 173
         'uses' => 'OutcomesController@fetchCriteria'
174 174
     ));
175
+    Route::post('fetchCriterionWithTemplate', array(
176
+        'as' => 'fetchCriterionWithTemplate',
177
+        'uses' => 'CriteriaController@fetchCriterionWithTemplate'
178
+    ));
175 179
 
176 180
     // Fetch a criterion for a rubric
177 181
     Route::post('fetchCriterion', array(

+ 3
- 1
app/views/global/view-three-year-plan.blade.php Parādīt failu

@@ -345,7 +345,9 @@ $(document).ready(function()
345 345
 $('.go-to-temp').on('click', function(){
346 346
   $.post(
347 347
     "{{ URL::action('ThreeYearPlanController@createAnnualPlan', array($program_id))}}");
348
-});
348
+    window.location.href = "{{URL::action('AnnualPlansController@showPlan',array($program_id))}}";
349
+
350
+  });
349 351
 
350 352
     // When list item is clicked, load corresponding info
351 353
     //section 1

+ 64
- 42
app/views/local/managers/pCoords/criteria.blade.php Parādīt failu

@@ -19,7 +19,6 @@
19 19
                         <label>Associated Outcomes</label>
20 20
 
21 21
                         {{ Form::select('outcome[]', $outcomes, reset($outcomes),  ['class'=>'form-control selectpicker', 'id' =>'outcome0', 'onchange'=>'fetchObjectiveForSelect("outcome0")']) }}
22
-
23 22
                     </div>
24 23
                 </div>
25 24
                 <input type='hidden' name='counterOutcome' id='counterOutcome' value=1>
@@ -409,7 +408,7 @@ $('.filterSection').hide();
409 408
             'name': "outcome[]",
410 409
             'data-live-search': 'true',
411 410
             'id': 'outcome' + counter.toString(),
412
-            'onchange': 'fetchObjectiveForSelect("outcome' + counter.toString() + '")'
411
+            'onchange': 'fetchObjectiveForSelect("outcomeGroup", "objectiveGroup")'
413 412
 
414 413
         });
415 414
         var $div = $('<div/>', {
@@ -425,8 +424,8 @@ $('.filterSection').hide();
425 424
         var $button = $('<button/>', {
426 425
             'type': 'button',
427 426
             'class': 'btn btn-primary',
428
-            'onclick': 'deleteLast("outcomeForm' + counter.toString() + '", "' + outcomeString + (counter).toString() + '", "close' + counter.toString() + '","objective_")'
429
-        });
427
+            'onclick': 'deleteLast("outcomeForm'+counter.toString()+'", "outcomeGroup", "close' + counter.toString() + '", "objectiveGroup")'
428
+   });
430 429
 
431 430
         $button.append('X');
432 431
         $divForButton.append($button);
@@ -435,7 +434,7 @@ $('.filterSection').hide();
435 434
         $select.append(selectOptions);
436 435
 
437 436
         $select.appendTo('#outcomeForm' + counter.toString()).selectpicker('refresh');
438
-        fetchObjectiveForSelect('outcome' + counter.toString());
437
+        fetchObjectiveForSelect('outcomeGroup', "objectiveGroup");
439 438
         counter += 1;
440 439
         $divForButton.appendTo('#outcomeGroup');
441 440
 
@@ -448,19 +447,14 @@ $('.filterSection').hide();
448 447
 
449 448
     //Delete Outcome and OptGroup associated
450 449
 
451
-    function deleteLast(outcomeForm, outcomeOptGroup, closeButton, objective) {
452
-        $div = document.getElementById(outcomeForm);
450
+    function deleteLast(outcomeForm, outcomeDiv, closeButton, objectiveGroup) {
451
+        $div = document.getElementById(outcomeForm );
453 452
         $div.remove();
454
-        $div = document.getElementById(outcomeOptGroup);
453
+        $div = document.getElementById(closeButton);
455 454
         $div.remove();
456
-        $div = document.getElementById(closeButton)
457
-        $div.remove();
458
-
459
-        for (var i = 0; i < counterObj; i++) {
460
-
461
-
462
-            $('#' + objective + i.toString()).selectpicker('refresh');
463
-        }
455
+        if(outcomeDiv =='outcomeGroup'){
456
+        $('#' + outcomeDiv).data('value',parseInt($('#' + outcomeDiv).data('value')) - 1);
457
+        fetchObjectiveForSelect(outcomeDiv, objectiveGroup);}
464 458
 
465 459
     }
466 460
     //Delete Objective
@@ -579,8 +573,8 @@ $('.filterSection').hide();
579 573
         var $button = $('<button/>', {
580 574
             'type': 'button',
581 575
             'class': 'btn btn-primary',
582
-            'onclick': 'deleteLast("assoc_outcomeForm' + assocOutcomeCounter.toString() + '", "' + 'Associated_Outcome' + (assocOutcomeCounter).toString() + '", "assoc_close' + assocOutcomeCounter.toString() + '","assoc_objective_")'
583
-        });
576
+            'onclick': 'deleteLast("assoc_outcomeForm' + assocOutcomeCounter.toString() + '", "assocOutcomeGroup", "assoc_close' + assocOutcomeCounter.toString() + '","assoc_objectiveGroup")'
577
+         });
584 578
 
585 579
         $button.append('X');
586 580
         $divForButton.append($button);
@@ -644,37 +638,66 @@ $('.filterSection').hide();
644 638
     //Fetch objective at creating criteria
645 639
     counterForPost = 0;
646 640
 
647
-    function fetchObjectiveForSelect(outcomeInput) {
648
-
649
-
650
-        var id = $('#' + outcomeInput).find(':selected').val();
641
+    function fetchObjectiveForSelect(outcomeDiv, objectiveGroup) {
642
+        var count = $("#" + outcomeDiv).data('value');
643
+        var allOutcomes = [];
644
+        $("#" + outcomeDiv + ' select').each(function() {
645
+            allOutcomes.push( this.value);
646
+
647
+        })
648
+        var allObjectives = [];
649
+        $("#" + objectiveGroup + ' select').each(function() {
650
+            var temp = {
651
+                id: this.id,
652
+                value: this.value
653
+            }
654
+            allObjectives.push(temp);
655
+        })
651 656
 
652 657
         $.post(
653 658
             "{{ URL::action('CriteriaController@fetchObjectivesForSelect') }}", {
654
-                id: id
659
+                allOutcomes: allOutcomes
655 660
             },
656 661
             function(varArray) {
662
+                counterOutcome =0;
663
+                optionName = '';
664
+                for(outcome in varArray.outcomes){
665
+                    optionName += '<optgroup label="' + varArray.outcomes[outcome][0].name + '"';
666
+                    var objectiveForOutcome = varArray.objectives;
667
+                    var objectives = objectiveForOutcome[outcome];
668
+                    for (objective in varArray.objectives[outcome]) {
669
+                
657 670
 
658
-                var optionName = '<optgroup id="' + outcomeString + (counter - 1).toString() + '"label="' + varArray[0].name + '"';
659
-                for (var i = 0; i < varArray.length; i++) {
660
-                    var option = '<option value ="' + varArray[i].id.toString() + '">' + varArray[i].text + '</option>'
661
-                    optionName += (option)
662
-
663
-                }
664
-                optGroup = document.getElementById(outcomeString + (counter - 1).toString());
665
-                if (optGroup != null) {
666
-                    optGroup.remove()
667
-
671
+                        var obj= objectives[objective];
672
+                        var option = '<option value ="' + obj.id + '">' +obj.text + '</option>';
673
+                        optionName += (option);
674
+                    }
668 675
                 }
676
+                
669 677
 
678
+                
670 679
 
671
-                $('#objective_0').append(optionName);
680
+                $('#objective_0').html(optionName);
672 681
                 $('#objective_0').selectpicker('refresh');
682
+                if($("#objective_0 option[value='"+allObjectives[0].value+"']").length>0){
683
+                    $("#objective_0").val(allObjectives[0].value);
684
+                    $('#objective_0').selectpicker('refresh');
685
+                }
686
+                
673 687
 
674
-                for (var i = counterObj - 1; i > 0; i--) {
675
-                    deleteObjective('objectiveForm' + i.toString(), 'closeObj' + i.toString())
688
+                for (var i = allObjectives.length - 1; i > 0; i--) {
689
+                    deleteObjective('objectiveForm' + i.toString(), 'closeObj' + i.toString(), 'objectiveGroup');
676 690
                 }
677
-                counterObj = 1;
691
+                for(var i =1; i<allObjectives.length; i++){
692
+                    addObjectiveTest();
693
+                    $('#objective_'+i.toString()).selectpicker('refresh');
694
+                    if($("#objective_"+i.toString()+" option[value='"+allObjectives[i].value+"']").length>0){
695
+                    $("#objective_"+i.toString()).val(allObjectives[i].value);
696
+                    $("#objective_"+i.toString()).selectpicker("refresh");
697
+                }
698
+                }
699
+
700
+                
678 701
 
679 702
 
680 703
 
@@ -683,7 +706,6 @@ $('.filterSection').hide();
683 706
             'json'
684 707
         );
685 708
     }
686
-
687 709
     //after post
688 710
 
689 711
     fetchAllCriterion("select-program", "assoc_outcomes_fetch");
@@ -793,8 +815,8 @@ $('.filterSection').hide();
793 815
                 // Select associated outcome
794 816
                 try {
795 817
                     for (var i = assocOutcomeCounter - 1; i > 0; i--) {
796
-                        deleteLast("assoc_outcomeForm" + (i).toString(), 'Associated_Outcome' + (i).toString(), "assoc_close" + (i).toString(), "assoc_objective_");
797
-                    }
818
+                        deleteLast("assoc_outcomeForm" + i.toString() , "assocOutcomeGroup", "assoc_close" + i.toString() ,"assoc_objectiveGroup");
819
+                               }
798 820
                 } catch (err) {
799 821
                     var Notran = true;
800 822
                 }
@@ -974,7 +996,7 @@ $('.panel-group .panel-body').hide();
974 996
 $('#outcome-display').parent().hide();
975 997
 
976 998
 fetchCriterionForEditing();
977
-fetchObjectiveForSelect('outcome0');
999
+fetchObjectiveForSelect('outcomeGroup', 'objectiveGroup');
978 1000
 // setCriterionStatus();
979 1001
 
980 1002
 
@@ -1032,7 +1054,7 @@ $(this).next().stop().slideToggle();
1032 1054
 })
1033 1055
 
1034 1056
 $('#outcome[0]').on('change', function(){
1035
-fetchObjectiveForSelect(0);
1057
+
1036 1058
 $('.selectpicker').selectpicker('refresh');
1037 1059
 })
1038 1060
 // When list item is clicked, load corresponding info

+ 10
- 7
app/views/local/managers/sCoords/annual-plans.blade.php Parādīt failu

@@ -189,7 +189,7 @@ $(document).ready(function()
189 189
            var $button = $('<button/>', {
190 190
            'type': 'button',
191 191
       'class': 'btn btn-secondary',
192
-      'onclick': 'addObjectiveTest("forObjective-'+objectives[objective].id+"-course-"+courses[objectives[objective].id][course].id+'", "'+objectives[objective].id+"-course-"+courses[objectives[objective].id][course].id+'", '+courses[objectives[objective].id][course].typ_course_id+', null, "'+options+'")'
192
+      'onclick': 'addCriteriaTest("forObjective-'+objectives[objective].id+"-course-"+courses[objectives[objective].id][course].id+'", "'+objectives[objective].id+"-course-"+courses[objectives[objective].id][course].id+'", '+courses[objectives[objective].id][course].typ_course_id+', null, "'+options+'")'
193 193
   });
194 194
            
195 195
           $button.append("+ Add criteria");
@@ -265,9 +265,9 @@ $(document).ready(function()
265 265
 
266 266
 
267 267
           $divForTA.append($divForTASelects);
268
-          
269
-          $divForTA.append($buttonTA)
270 268
           $divForTA.append('<br>');
269
+          $divForTA.append($buttonTA)
270
+          
271 271
 
272 272
 
273 273
            table.row.add([
@@ -295,7 +295,7 @@ $(document).ready(function()
295 295
          
296 296
             
297 297
             for(i =0; i<json.selected_criteria[objectives[objective].id][course_id].length; i++){
298
-              addObjectiveTest("forObjective-"+objectives[objective].id+"-course-"+course_id, ""+objectives[objective].id+"-course-"+course_id, ""+json.selected_criteria[objectives[objective].id][course_id][i].typ_course_id+"", i, options);
298
+              addCriteriaTest("forObjective-"+objectives[objective].id+"-course-"+course_id, ""+objectives[objective].id+"-course-"+course_id, ""+json.selected_criteria[objectives[objective].id][course_id][i].typ_course_id+"", i, options);
299 299
               $('#criteriaFor'+objectives[objective].id+"-course-"+course_id+'_'+i).val(json.selected_criteria[objectives[objective].id][course_id][i].criteria_id);
300 300
               $('#criteriaFor'+objectives[objective].id+"-course-"+course_id+'_'+i).data('old-criteria', json.selected_criteria[objectives[objective].id][course_id][i].criteria_id);
301 301
               $('#criteriaFor'+objectives[objective].id+"-course-"+course_id+'_'+i).selectpicker('refresh');
@@ -306,7 +306,7 @@ $(document).ready(function()
306 306
        
307 307
           else{
308 308
            
309
-            addObjectiveTest("forObjective-"+objectives[objective].id+"-course-"+course_id, ""+objectives[objective].id+"-course-"+course_id+"", ""+courses[objectives[objective].id][course].typ_course_id+"", 0, options);
309
+            addCriteriaTest("forObjective-"+objectives[objective].id+"-course-"+course_id, ""+objectives[objective].id+"-course-"+course_id+"", ""+courses[objectives[objective].id][course].typ_course_id+"", 0, options);
310 310
             $('#criteriaFor'+objectives[objective].id+"-course-"+course_id+'_0').val(0);
311 311
               $('#criteriaFor'+objectives[objective].id+"-course-"+course_id+'_0').data('old-criteria', 0);
312 312
               $('#criteriaFor'+objectives[objective].id+"-course-"+course_id+'_0').selectpicker('refresh');
@@ -385,7 +385,9 @@ function addTAselect(options, master_div, annual_plan_id, objective_id, typ_obje
385 385
   }).html('x');
386 386
   $span.appendTo($div);
387 387
   $div.append("<br><br>");
388
-  $div.appendTo('#'+master_div);
388
+  $('#'+master_div).append("<br>");
389
+  
390
+  $div.appendTo($('#'+master_div));
389 391
   $('#'+master_div).data('amount-ta', counter+1);
390 392
 
391 393
 
@@ -431,7 +433,7 @@ function postToAnnualPlans(typ_course_id, criteria_select){
431 433
 }
432 434
 
433 435
 
434
-function addObjectiveTest(div, new_id_for_select, typ_course_id, i=null, options) {
436
+function addCriteriaTest(div, new_id_for_select, typ_course_id, i=null, options) {
435 437
   
436 438
   if(!i) amount_select = $('#'+div).data("amount-select");
437 439
   else amount_select = i;
@@ -459,6 +461,7 @@ function addObjectiveTest(div, new_id_for_select, typ_course_id, i=null, options
459 461
   }).html('x');
460 462
   $div.append($span);
461 463
  $div.append("<br><br>")
464
+ $("#forObjective-"+new_id_for_select).append("<br>");
462 465
   $div.appendTo($("#forObjective-"+new_id_for_select));
463 466
   
464 467
 

+ 286
- 104
app/views/local/managers/shared/rubrics.blade.php Parādīt failu

@@ -129,6 +129,8 @@
129 129
                     </div>
130 130
                     @endif
131 131
                 </form>
132
+          
133
+               
132 134
 
133 135
                 <label for="">Select the lower bound for passing criteria</label>
134 136
                 <form class="form-inline">
@@ -146,9 +148,12 @@
146 148
                         </select>
147 149
                         % of all students must score at least
148 150
 
151
+
152
+
153
+                        
149 154
                         <!-- Select points. If there is a rubric, select the saved value -->
150 155
                         <select id="expected_points" class="form-control selectpicker">
151
-                            @for($i = 5; $i <= 8; $i++)
156
+                            @for($i = 0; $i <= 8; $i++)
152 157
                                 @if($i==5)
153 158
                                     <option selected="selected" value="{{ $i }}">{{ $i }}</option>
154 159
                                 @else
@@ -196,7 +201,39 @@
196 201
                         @endforeach
197 202
                     </select>
198 203
                 </div>
204
+                    <div class="form-group">
205
+                        <label>Select the Maximum Score</label>
206
+                    <select id="max_score" class="form-control selectpicker">
207
+                        @for($i = 1; $i <= 100; $i++)
208
+                            @if($i==8)
209
+                                <option selected="selected" value="{{ $i }}">{{ $i }}</option>
210
+                            @else
211
+                                <option value="{{ $i }}">{{ $i }}</option>
212
+                            @endif
213
+                        @endfor
214
+                        
215
+                    </select>
216
+                    
217
+                </div>
218
+                <div class="form-group">
219
+                    <label>Select the Type of Rubric</label>
220
+                <select id="number_of_scales" class="form-control selectpicker">
221
+                    @for($i = 1; $i <= 20; $i++)
222
+                    @if(8%$i == 0)
223
+                    @if($i==1)
224
+                    <option value="{{ $i }}">Cuantitative Rubric</option>
225
+                    
226
+                        @elseif($i==4)
227
+                        <option selected="selected" value="{{ $i }}">{{ $i }}-Scale Rubric</option>
228
+                        @else
229
+                        <option value="{{ $i }}">{{ $i }}-Scale Rubric</option>
230
+                    @endif
231
+                    @endif
232
+                    @endfor
233
+                    
234
+                </select>
199 235
 
236
+                <div>
200 237
                 @if(Auth::user()->role != '1')
201 238
 
202 239
                     <label>Filter Criteria</label>
@@ -229,20 +266,15 @@
229 266
 
230 267
 <div id="rubric-container" class="row">
231 268
     <div class="col-md-12">
232
-        <table class="table table-striped table-condensed">
233
-            <thead><tr><th colspan="6 "><input id="rubric-name" type="text" class="form-control input-lg" placeholder="Rubric Name"></th></tr></thead>
269
+        <table class="table table-striped table-condensed" style="table-layout: fixed">
270
+            <thead id="theHead"><tr><th colspan="7 "><input id="rubric-name" type="text" class="form-control input-lg" placeholder="Rubric Name"></th></tr></thead>
234 271
             <thead>
235
-                <tr>
272
+                <tr id ="criterion-header">
236 273
                     <th></th>
237
-                    <th>Criterion</th>
238
-                    <th>Beginning (1-2)</th>
239
-                    <th>In Progress (3-4)</th>
240
-                    <th>Good (5-6)</th>
241
-                    <th>Excellent (7-8)</th>
242 274
                     <th></th>
243 275
                 </tr>
244 276
             </thead>
245
-            <tbody>
277
+            <tbody id = "allCriteria">
246 278
             </tbody>
247 279
         </table>
248 280
 
@@ -273,52 +305,8 @@
273 305
         </div>
274 306
     </div>
275 307
 </div>
276
-@stop
277
-
278
-@section('included-js')
279
-
280
-<!-- jQuery Sortable Tables -->
281
-<script src="{{ asset('vendor/jQuerySortable/jquery-sortable-min.js') }}"></script>
282
-
283
-<!-- X-Editable js -->
284
-<script src="{{ asset('vendor/xeditable/bootstrap-editable.min.js') }}"></script>
285
-
286
-@stop
287
-
288
-@section('javascript')
289
-
290
-// --------------------------------------------------------------------------
291
-// Page load
292
-// --------------------------------------------------------------------------
293
-$('#updated-text').hide();
294
-
295
-// Enable/disable program selection depending on school selection if user is
296
-// admin
297
-if({{Auth::user()->role}}==1)
298
-    toggleProgramSelect($('#select-school'));
299
-
300
-// Fetch criteria of first outcome
301
-fetchCriteria($('#select-outcome'));
302
-
303
-// Hide table
304
-$('#rubric-container').hide();
305
-
306
-// Disable Update and Delete Buttons by default
307
-$('#button-confirm-update-rubric').prop('disabled', true);
308
-$('#button-confirm-delete-rubric').prop('disabled', true);
309
-$('#button-print-rubric').prop('disabled', true);
310
-
311
-
312
-// Sortable rows
313
-$('.table').sortable({
314
-    handle: 'span.glyphicon.glyphicon-move',
315
-    containerSelector: 'table',
316
-    itemPath: '> tbody',
317
-    itemSelector: 'tr',
318
-    placeholder: '<tr class="placeholder"><th><span class="glyphicon glyphicon-arrow-right"></span></th></tr>'
319
-});
320
-
321
-// --------------------------------------------------------------------------
308
+<script>
309
+    // --------------------------------------------------------------------------
322 310
 // Functions
323 311
 // --------------------------------------------------------------------------
324 312
 
@@ -362,6 +350,8 @@ function fetchCriteria(outcome)
362 350
             $('#updated-text').fadeIn('slow').fadeOut('slow');
363 351
 
364 352
             refreshSelects();
353
+
354
+
365 355
         }
366 356
     );
367 357
 }
@@ -407,18 +397,17 @@ function addCriterion()
407 397
     // Fetch information of the criterion selected
408 398
     $.post
409 399
     (
410
-        "{{ URL::route('fetchCriterion') }}",
400
+        "{{ URL::route('fetchCriterionWithTemplate') }}",
411 401
         { id: id},
412 402
         function(data)
413 403
         {
414 404
             // Append the fetched data
415
-            var str ='<tr data-assoc-outcome-id="'+data.outcome_id+'"'
416
-                +'data-criterion-id="'+data.id+'" data-criterion-copyright="'+data.copyright+'" data-criterion-notes="'+data.notes+'"><th><span class="glyphicon glyphicon-move"></span></th><td>';
405
+            var str ='<tr data-criterion-id="'+data.criterion.id+'" data-criterion-copyright="'+data.criterion.copyright+'" data-criterion-notes="'+data.criterion.notes+'"><th><span class="glyphicon glyphicon-move"></span></th><td>';
417 406
 
418 407
             var subcriteria = '';
419
-            if(data.subcriteria){
408
+            if(data.criterion.subcriteria){
420 409
 
421
-                var subcriteria_array = JSON.parse(data.subcriteria);
410
+                var subcriteria_array = JSON.parse(data.criterion.subcriteria);
422 411
                 subcriteria = '<ul class="subcriteria list-unstyled">';
423 412
                 subcriteria_array.forEach(function (value) {
424 413
                     subcriteria += '<li>'+value+'</li>';
@@ -427,20 +416,21 @@ function addCriterion()
427 416
 
428 417
             }
429 418
 
430
-            if(data.notes)
419
+            if(data.criterion.notes)
431 420
             {
432
-                str+='<span><em data-toggle="tooltip" data-placement="top" title="'+data.notes+'">'+data.name+'</em></span><sup></sup>'+subcriteria;
421
+                str+='<span><em data-toggle="tooltip" data-placement="top" title="'+data.criterion.notes+'">'+data.criterion.name+'</em></span><sup></sup>'+subcriteria+'</td>';
433 422
             }
434 423
             else
435 424
             {
436
-                str+='<span>'+data.name+'</span><sup></sup>'+subcriteria;
425
+                str+='<span>'+data.criterion.name+'</span><sup></sup>'+subcriteria+'</td>';
426
+            }
427
+            numberOfScale = $('#number_of_scales').find(':selected').val();
428
+            for(i=0; i<numberOfScale; i++){
429
+                str+='<td class="editable" data-type="textarea"></td>';
430
+          
437 431
             }
438 432
 
439
-            str+='</td><td class="editable" data-type="textarea">'+data.description12+'</td>'
440
-                +'<td class="editable" data-type="textarea">'+data.description34+'</td>'
441
-                +'<td class="editable" data-type="textarea">'+data.description56+'</td>'
442
-                +'<td class="editable" data-type="textarea">'+data.description78+'</td>'
443
-                +'<th><span class="glyphicon glyphicon-remove icon-btn" aria-hidden="true"></span></th></tr>';
433
+            str +='<th><span class="glyphicon glyphicon-remove icon-btn" aria-hidden="true"></span></th></tr>';
444 434
 
445 435
             $('table tbody').append(str);
446 436
 
@@ -464,7 +454,8 @@ function addCriterion()
464 454
                 itemSelector: 'tr',
465 455
                 placeholder: '<tr class="placeholder"><th><span class="glyphicon glyphicon-arrow-right"></span></th></tr>'
466 456
             });
467
-        }
457
+        },
458
+        'json',
468 459
     );
469 460
 }
470 461
 
@@ -571,6 +562,7 @@ function refreshSelects()
571 562
     $('#select-criterion').selectpicker('refresh');
572 563
     $('#expected_percentage').selectpicker('refresh');
573 564
     $('#expected_points').selectpicker('refresh');
565
+    $('#number_of_scales').selectpicker('refresh');
574 566
 }
575 567
 
576 568
 // Fetch programs associated to a specific school
@@ -617,27 +609,37 @@ function loadTemplate()
617 609
             $('tbody').empty();
618 610
 
619 611
             //Set the name of the rubric
620
-            $('#rubric-name').val(data.name);
612
+            $('#rubric-name').val(data.template.name);
621 613
 
622 614
             // Set school id to 0, then to the saved value if it exists
623 615
             $('#select-school option[data-school-id="0"]').prop('selected', true);
624
-            $('#select-school option[data-school-id="'+data.school_id+'"]').prop('selected', true);
616
+            $('#select-school option[data-school-id="'+data.template.school_id+'"]').prop('selected', true);
625 617
 
626 618
             // Fetch programs associated to that school
627 619
             fetchPrograms($('#select-school'));
628 620
 
629 621
             // Set program id to 0, then to the saved value if it exists
630 622
             $('#select-program option[data-program-id="0"]').prop('selected', true);
631
-            $('#select-program option[data-program-id="'+data.program_id+'"]').prop('selected', true);
623
+            $('#select-program option[data-program-id="'+data.template.program_id+'"]').prop('selected', true);
632 624
 
633 625
             // Set expected values
634
-            console.log(data.expected_percentage);
635
-            console.log(data.expected_points);
636
-            $('#expected_percentage option[value="'+data.expected_percentage+'"]').attr('selected', true);
637
-            $('#expected_points option[value="'+data.expected_points+'"]').attr('selected', true);
638
-
626
+            console.log(data.template.expected_percentage);
627
+
628
+            console.log(data.template.expected_points);
629
+            console.log(data.template.max_score);
630
+        
631
+        $('#max_score').val(data.template.max_score);
632
+          
633
+        $('#max_score').trigger("change");
634
+            
635
+            $('#expected_percentage').val(data.template.expected_percentage);
636
+            
637
+            $('#expected_points').val(data.template.expected_points);
638
+            $('#number_of_scales').val(data.template.num_scales);
639
+            refreshSelects();
640
+            changeTable();
639 641
             // Set visibility
640
-            var is_visible = JSON.parse(data.is_visible);
642
+            var is_visible = data.template.is_visible;
641 643
             if(is_visible)
642 644
             {
643 645
                 $('#is_visible0').prop('checked', false);
@@ -651,12 +653,64 @@ function loadTemplate()
651 653
 
652 654
 
653 655
             // Set the contents of the rubric
656
+            var temp_criterion = data.criterion;
657
+            for(temp_c in temp_criterion){
658
+                var str = '<tr data-criterion-id="'+temp_criterion[temp_c].criterion_id+'" data-criterion-copyright="'+temp_criterion[temp_c].copyright+'" data-criterion-notes="'+temp_criterion[temp_c].notes+'"><th><span class="glyphicon glyphicon-move"></span></th><td>';
659
+                current_criterion = temp_criterion[temp_c]
660
+                var subcriteria ='';
661
+                if(current_criterion.subcriteria){
662
+                    var subcriteria_array = current_criterion.subcriteria;
663
+                    subcriteria = '<ul class="subcriteria list-unstyled">';
664
+                    subcriteria_array.forEach(function (value) {
665
+                        subcriteria += '<li>'+value+'</li>';
666
+                    });
667
+                    subcriteria += '</ul>';
668
+                }
669
+                if(current_criterion.notes)
670
+                {
671
+                    str+='<span><em data-toggle="tooltip" data-placement="top" title="'+current_criterion.notes+'">'+current_criterion.name+'</em></span><sup></sup>'+subcriteria;
672
+                }
673
+                else
674
+                {
675
+                    str+='<span>'+current_criterion.name+'</span><sup></sup>'+subcriteria;
676
+                }
677
+                str+= '</td>';
678
+                
679
+                for(scaleIndex in data.scales[current_criterion.id]){
680
+
681
+                    scale = data.scales[current_criterion.id][scaleIndex];
682
+
683
+                    str+='<td class="editable" data-id-value ="'+scale.scale_id+'" data-type="textarea">'+scale.description+'</td>';
684
+
685
+                }
686
+
687
+                str+='<th><span class="glyphicon glyphicon-remove" aria-hidden="true"></span></th></tr>';
688
+
689
+    $('table tbody').append(str);
690
+
691
+    buildCopyrightList();
692
+
693
+                // Enable X-Edtable on this new row
694
+                $('.editable').editable({
695
+                    unsavedclass: null,
696
+                    rows: 4
697
+                });
698
+
699
+                // Turn on tooltips again (because content is dynamic)
700
+                $('[data-toggle="tooltip"]').tooltip();
701
+
702
+
703
+                refreshSelects();
704
+            
705
+
706
+            
707
+            }
708
+            /*
654 709
             var contents = JSON.parse(data.contents);
655 710
             contents.forEach(function (data)
656 711
             {
657 712
                 // Append the fetched data
658
-                var str ='<tr data-assoc-outcome-id="'+data.outcome_id+'"'
659
-                    +'data-criterion-id="'+data.id+'" data-criterion-copyright="'+data.copyright+'" data-criterion-notes="'+data.notes+'"><th><span class="glyphicon glyphicon-move"></span></th><td>';
713
+                var str ='<tr data-criterion-id="'+data.id+'" data-criterion-copyright="'+data.copyright+'" data-criterion-notes="'+data.notes+'"><th><span class="glyphicon glyphicon-move"></span></th><td>';
660 714
 
661 715
 
662 716
                 var subcriteria = '';
@@ -702,7 +756,7 @@ function loadTemplate()
702 756
 
703 757
 
704 758
                 refreshSelects();
705
-            });
759
+            }); */
706 760
 
707 761
             // Sortable rows
708 762
             $('.table').sortable({
@@ -715,7 +769,8 @@ function loadTemplate()
715 769
 
716 770
             // Build Copyright List
717 771
             buildCopyrightList();
718
-        }
772
+        }, 
773
+        'json',
719 774
     );
720 775
 }
721 776
 
@@ -740,7 +795,7 @@ function nameExists()
740 795
 //Enable disable program select
741 796
 function toggleProgramSelect(school)
742 797
 {
743
-    if(school.find(':selected').data('school-id')<1)
798
+    if(school.find(':selected').data('school-id') <1)
744 799
     {
745 800
         $('#select-program option[data-program-id="0"]').prop('selected', true);
746 801
         $('#select-program').prop('disabled', true);
@@ -776,6 +831,7 @@ $('.panel-heading').on('click', function()
776 831
     $(this).siblings('.panel-body').stop().slideToggle();
777 832
 });
778 833
 
834
+
779 835
 // When trying to change the template, ask the user to confirm and reset the
780 836
 // rubric if s/he does
781 837
 $('#select-template').on('change', function()
@@ -828,12 +884,81 @@ $('#select-template').on('change', function()
828 884
 
829 885
 });
830 886
 
887
+function changeTable(){
888
+    
889
+ 
890
+            amount_of_scales = parseInt($('#number_of_scales').find(':selected').val());
891
+            counter2 = 0;
892
+            maximum = parseInt($('#max_score').find(":selected").val());
893
+            
894
+           
895
+            newScaleHeaders = '<th></th><th>Criterion</th>';
896
+            counter = 0;
897
+            division = maximum/amount_of_scales;
898
+            if(amount_of_scales==1){
899
+                newScaleHeaders+= "<th>Score (1 - "+maximum+")</th>";
900
+            }
901
+            else if(maximum!= amount_of_scales){
902
+            while(counter <amount_of_scales){
903
+                
904
+                minimumScore = 1+(counter*division);
905
+                maximumScore = (1+counter)*division;
906
+                newScaleHeaders+= "<th>Scale "+ (counter +1) + " ("+minimumScore+" - "+maximumScore+")</th>";
907
+                counter++;
908
+            }
909
+            }else{
910
+                while(counter <amount_of_scales){
911
+                
912
+       
913
+                newScaleHeaders+= "<th>Scale "+ (counter +1) + " </th>";
914
+                counter++;
915
+            }
916
+            }
917
+            newScaleHeaders += '<th></th>';
918
+            
919
+            $("#criterion-header").html(newScaleHeaders);
920
+            $('#allCriteria').html(' ');
921
+}
922
+
923
+
831 924
 // When a school changes, update its programs. If all is selected, disable
832 925
 $('#select-school').on('change', function()
833 926
 {
834 927
     toggleProgramSelect($(this));
835 928
 });
836 929
 
930
+$('#max_score').on('change', function(){
931
+    var max = parseInt($('#max_score').find(':selected').val());
932
+    var stringToScales = "<option value= '1'>Cuantitative Rubric </option>";
933
+    selectedValue = 1;
934
+    valueBefore = 0;
935
+    
936
+    for(i=2; i<=20; i++){
937
+        if(max%i==0){
938
+        stringToScales += "<option value= '"+i+"'>"+i+"-Scale Rubric</option>";
939
+        selectedValue = i - valueBefore;
940
+        valueBefore = i;
941
+        }
942
+    }
943
+    $('#number_of_scales').html(stringToScales);
944
+
945
+    $('#number_of_scales').selectpicker('refresh');
946
+    $('#number_of_scales').val(selectedValue);
947
+    $('#number_of_scales').selectpicker('refresh');
948
+    var expected_points = Math.floor(max *0.7);
949
+    var expected_points_html = '';
950
+    for(i=1; i<max; i++){
951
+        expected_points_html += '<option value="'+i+'"> '+i+'</option>';
952
+    }
953
+    $('#expected_points').html(expected_points_html);
954
+    refreshSelects();
955
+    $('#expected_points').val(expected_points);
956
+    refreshSelects();
957
+    changeTable();
958
+})
959
+$('#number_of_scales').on('change', function(){
960
+    changeTable();
961
+})
837 962
 // When a learning outcome changes, update its criteria
838 963
 $('#select-outcome, input[name=criteria-filter]').on('change', function()
839 964
 {
@@ -859,7 +984,7 @@ $('.save').on('click', function(e)
859 984
     // Empty field validation
860 985
     var emptyFields=false;
861 986
 
862
-    $('td').each(function()
987
+    $('#allCriteria').children('td').each(function()
863 988
     {
864 989
         if ($(this).text() == "" || $(this).text() == "Empty")
865 990
         {
@@ -867,11 +992,12 @@ $('.save').on('click', function(e)
867 992
         }
868 993
     });
869 994
 
995
+
870 996
     // If any fields are empty, display error
871 997
     if(emptyFields || $.trim($('#rubric-name').val())=='')
872 998
     {
873 999
         $('#js-error-row').show();
874
-        $('#js-error-row').find('#error-message').text('Error: Please fill all the fields. Make sure your rubric has a name.');
1000
+        $('#js-error-row').find('#error-message').text('Error: Please fill all the fields. Make sure your rubric has a name and all scale scores are filled.');
875 1001
         return;
876 1002
     }
877 1003
     else
@@ -894,29 +1020,33 @@ $('.save').on('click', function(e)
894 1020
     var criterionObject = new Object();
895 1021
     var criteriaArray = new Array();
896 1022
 
1023
+    var criteria = [];
1024
+    scales = [];
1025
+    scalesMaxArray =[];
1026
+    scalesMinArray =[];
1027
+    scales_id =[];
1028
+
1029
+    
1030
+    var amount_of_scales =parseInt($('#number_of_scales').find(':selected').val())+2;
1031
+    var max = parseInt($('#max_score').find(':selected').val());
897 1032
     // For each criterion in the rubric, get its value and put it into an array
898 1033
     $('tbody tr').each(function( index )
899 1034
     {
900
-            criterionObject.id = $(this).data('criterion-id');
901
-            criterionObject.outcome_id = $(this).data('assoc-outcome-id');
902
-            criterionObject.name = $(this).children('td:nth-child(2)').find('span').text();
1035
+            criteria.push($(this).data('criterion-id'));
1036
+            each_criterion_scale = [];
1037
+            for(i=2; i<amount_of_scales; i++){
1038
+               each_criterion_scale.push($(this.children[i]).text());
903 1039
 
904
-            var subcriteriaArray = new Array();
905
-            $(this).children('td:nth-child(2)').find('.subcriteria li').each(function(index){
906
-                subcriteriaArray.push($(this).text());
907
-            });
908
-            criterionObject.subcriteria = subcriteriaArray;
1040
+            }
1041
+            scales.push(each_criterion_scale);
1042
+
1043
+            
1044
+            
909 1045
 
910
-            criterionObject.description12 = $(this).children('td:nth-child(3)').text();
911
-            criterionObject.description34 = $(this).children('td:nth-child(4)').text();
912
-            criterionObject.description56 = $(this).children('td:nth-child(5)').text();
913
-            criterionObject.description78 = $(this).children('td:nth-child(6)').text();
914
-            criterionObject.copyright = $(this).data('criterion-copyright');
915
-            criterionObject.notes = $(this).data('criterion-notes');
1046
+            
916 1047
 
917 1048
             // Clone the object and push it into the array
918
-            var clone = jQuery.extend({}, criterionObject);
919
-            criteriaArray.push(clone);
1049
+           
920 1050
 
921 1051
     });
922 1052
 
@@ -931,12 +1061,16 @@ $('.save').on('click', function(e)
931 1061
             "{{ URL::to('saveTemplate') }}",
932 1062
             {
933 1063
                 name: $('#rubric-name').val(),
934
-                contents: JSON.stringify(criteriaArray),
1064
+                contents: " ",
935 1065
                 school_id: $('#select-school').find(':selected').data('school-id'),
936 1066
                 program_id: $('#select-program').find(':selected').data('program-id'),
937 1067
                 expected_percentage: $('#expected_percentage').find(':selected').val(),
938 1068
                 expected_points: $('#expected_points').find(':selected').val(),
939
-                is_visible: $('input[name=is_visible]:checked').val()
1069
+                is_visible: $('input[name=is_visible]:checked').val(),
1070
+                criteria : criteria,
1071
+                scales: scales,
1072
+                max_score : max
1073
+
940 1074
             },
941 1075
             function(data)
942 1076
             {
@@ -1012,4 +1146,52 @@ $('#button-print-rubric').on('click', function(e)
1012 1146
 
1013 1147
 });
1014 1148
 
1149
+    </script>
1150
+@stop
1151
+
1152
+@section('included-js')
1153
+
1154
+<!-- jQuery Sortable Tables -->
1155
+<script src="{{ asset('vendor/jQuerySortable/jquery-sortable-min.js') }}"></script>
1156
+
1157
+<!-- X-Editable js -->
1158
+<script src="{{ asset('vendor/xeditable/bootstrap-editable.min.js') }}"></script>
1159
+
1160
+@stop
1161
+
1162
+@section('javascript')
1163
+
1164
+// --------------------------------------------------------------------------
1165
+// Page load
1166
+// --------------------------------------------------------------------------
1167
+$('#updated-text').hide();
1168
+
1169
+// Enable/disable program selection depending on school selection if user is
1170
+// admin
1171
+if({{Auth::user()->role}}==1)
1172
+    toggleProgramSelect($('#select-school'));
1173
+
1174
+// Fetch criteria of first outcome
1175
+fetchCriteria($('#select-outcome'));
1176
+changeTable();
1177
+
1178
+// Hide table
1179
+$('#rubric-container').hide();
1180
+
1181
+// Disable Update and Delete Buttons by default
1182
+$('#button-confirm-update-rubric').prop('disabled', true);
1183
+$('#button-confirm-delete-rubric').prop('disabled', true);
1184
+$('#button-print-rubric').prop('disabled', true);
1185
+
1186
+
1187
+// Sortable rows
1188
+$('.table').sortable({
1189
+    handle: 'span.glyphicon.glyphicon-move',
1190
+    containerSelector: 'table',
1191
+    itemPath: '> tbody',
1192
+    itemSelector: 'tr',
1193
+    placeholder: '<tr class="placeholder"><th><span class="glyphicon glyphicon-arrow-right"></span></th></tr>'
1194
+});
1195
+
1196
+
1015 1197
 @stop

+ 2
- 2
app/views/local/professors/activity.blade.php Parādīt failu

@@ -164,7 +164,7 @@
164 164
             @endif
165 165
 
166 166
             <!-- If no rubric is assigned and the semester is active -->
167
-            @if($activity->rubric == NULL && in_array($course->semester->id, $active_semesters))
167
+            @if(count($activity->rubric) == 0 && in_array($course->semester->id, $active_semesters))
168 168
                 {{ HTML::linkAction('RubricsController@newRubric', 'Assign Rubric', array($activity->id), array('class'=>'btn btn-primary btn-sm btn-block')) }}
169 169
                 {{ HTML::linkAction('RubricsController@newOtherMethod', 'Assign Other Assessment Method', array($activity->id), array('class'=>'btn btn-primary btn-sm btn-block')) }}
170 170
             @else
@@ -274,7 +274,7 @@ $(function () {
274 274
             title: {
275 275
                 text: 'Percentage'
276 276
             },
277
-            @if($activity->rubric!=NULL)
277
+            @if(isset($activity->rubric->expected_percentage)  )
278 278
             plotLines:[{
279 279
                 value:{{ $activity->rubric->expected_percentage }},
280 280
                 color: '#000',

+ 194
- 20
app/views/local/professors/rubrics.blade.php Parādīt failu

@@ -59,7 +59,8 @@
59 59
           @endforeach
60 60
         </select>
61 61
       </div>
62
-
62
+      <input type='hidden' id='max' name= 'max' value="0">
63
+      <input type ='hidden' id='num_of_scales' name ='num_of_scales' value ='0'>
63 64
       <div class="form-group">
64 65
         <label>Expected Criteria Outcome: </label>
65 66
         <!-- Select percentage. If there is a rubric, select the saved value -->
@@ -85,7 +86,7 @@
85 86
 
86 87
     <table class="table">
87 88
       <thead><tr><th colspan="6 "><h3 id="rubric-name"></h3></th></tr></thead>
88
-      <thead><tr><th>Criterion</th><th>Beginning (1-2)</th><th>In Progress (3-4)</th><th>Good (5-6)</th><th>Excellent (7-8)</th></tr></thead>
89
+      <thead><tr id ="criterion-header"><th>Criterion</th><th>Beginning (1-2)</th><th>In Progress (3-4)</th><th>Good (5-6)</th><th>Excellent (7-8)</th></tr></thead>
89 90
       <tbody>
90 91
 
91 92
       </tbody>
@@ -107,6 +108,46 @@
107 108
     </div>
108 109
   </div>
109 110
 </div>
111
+
112
+<script>
113
+  
114
+function changeTable(){
115
+    
116
+ 
117
+            amount_of_scales = parseInt($('#num_of_scales').val());
118
+            counter2 = 0;
119
+            maximum = parseInt($('#max').val());
120
+            
121
+           
122
+            newScaleHeaders = '<th>Criterion</th>';
123
+            counter = 0;
124
+            division = maximum/amount_of_scales;
125
+            if(amount_of_scales==1){
126
+                newScaleHeaders+= "<th>Score (1 - "+maximum+")</th>";
127
+            }
128
+            else if(maximum!= amount_of_scales){
129
+            while(counter <amount_of_scales){
130
+                
131
+                minimumScore = 1+(counter*division);
132
+                maximumScore = (1+counter)*division;
133
+                newScaleHeaders+= "<th>Scale "+ (counter +1) + " ("+minimumScore+" - "+maximumScore+")</th>";
134
+                counter++;
135
+            }
136
+            }else{
137
+                while(counter <amount_of_scales){
138
+                
139
+       
140
+                newScaleHeaders+= "<th>Scale "+ (counter +1) + " </th>";
141
+                counter++;
142
+            }
143
+            }
144
+            newScaleHeaders += '';
145
+            
146
+            $("#criterion-header").html(newScaleHeaders);
147
+            
148
+}
149
+
150
+  </script>
110 151
 @stop
111 152
 
112 153
 @section('javascript')
@@ -231,23 +272,142 @@ function buildCopyrightList()
231 272
 }
232 273
 
233 274
 // Load a template
275
+
234 276
 function loadTemplate()
235 277
 {
236
-  $.post
237
-  (
238
-    "{{ URL::to('loadTemplate') }}",
239
-    { id: $('#select-template').find(':selected').data('template-id')},
240
-    function(data)
241
-    {
242
-      //alert(JSON.stringify(data));
278
+    $.post
279
+    (
280
+        "{{ URL::to('loadTemplate') }}",
281
+        { id: $('#select-template').find(':selected').data('template-id')},
282
+        function(data)
283
+        {
284
+            // Show the container and empty all rows
285
+            $('#rubric-container').show();
286
+            $('tbody').empty();
287
+
288
+            //Set the name of the rubric
289
+            $('#rubric-name').val(data.template.name);
290
+
291
+            $('#expected_percentage').text(data.template.expected_percentage);
292
+            $('#expected_points').text(data.template.expected_points)
293
+            $('#max').val(data.template.max_score);
294
+            $('#num_of_scales').val(data.template.num_scales);
295
+            changeTable();
296
+
297
+
298
+            // Set the contents of the rubric
299
+            var temp_criterion = data.criterion;
300
+            for(temp_c in temp_criterion){
301
+                var str = '<tr data-criterion-id="'+temp_criterion[temp_c].criterion_id+'" data-criterion-copyright="'+temp_criterion[temp_c].copyright+'" data-criterion-notes="'+temp_criterion[temp_c].notes+'">';
302
+                current_criterion = temp_criterion[temp_c]
303
+                var subcriteria ='';
304
+                if(current_criterion.subcriteria){
305
+                    var subcriteria_array = current_criterion.subcriteria;
306
+                    subcriteria = '<ul class="subcriteria list-unstyled">';
307
+                    subcriteria_array.forEach(function (value) {
308
+                        subcriteria += '<li>'+value+'</li>';
309
+                    });
310
+                    subcriteria += '</ul>';
311
+                }
312
+                if(current_criterion.notes)
313
+                {
314
+                    str+='<td><span><em data-toggle="tooltip" data-placement="top" title="'+current_criterion.notes+'">'+current_criterion.name+'</em></span><sup></sup>'+subcriteria+'</td>';
315
+                }
316
+                else
317
+                {
318
+                    str+='<td><span>'+current_criterion.name+'</span><sup></sup>'+subcriteria+'</td>';
319
+                }
320
+                
321
+                
322
+                for(scaleIndex in data.scales[current_criterion.id]){
323
+
324
+                    scale = data.scales[current_criterion.id][scaleIndex];
325
+
326
+                    str+='<td data-scale-id ="'+scale.id+'">'+scale.description+'</td>';
327
+
328
+                }
329
+
330
+                str+='</tr>';
331
+
332
+    $('table tbody').append(str);
333
+
334
+    buildCopyrightList();
335
+
336
+                
337
+
338
+                // Turn on tooltips again (because content is dynamic)
339
+                $('[data-toggle="tooltip"]').tooltip();
340
+
341
+
342
+                
343
+            
344
+
345
+            
346
+            }
347
+            /*
348
+            var contents = JSON.parse(data.contents);
349
+            contents.forEach(function (data)
350
+            {
351
+                // Append the fetched data
352
+                var str ='<tr data-criterion-id="'+data.id+'" data-criterion-copyright="'+data.copyright+'" data-criterion-notes="'+data.notes+'"><th><span class="glyphicon glyphicon-move"></span></th><td>';
353
+
354
+
355
+                var subcriteria = '';
356
+                if(data.subcriteria){
357
+
358
+                    var subcriteria_array = data.subcriteria;
359
+                    subcriteria = '<ul class="subcriteria list-unstyled">';
360
+                    subcriteria_array.forEach(function (value) {
361
+                        subcriteria += '<li>'+value+'</li>';
362
+                    });
363
+                    subcriteria += '</ul>';
364
+
365
+                }
366
+
367
+                if(data.notes)
368
+                {
369
+                    str+='<span><em data-toggle="tooltip" data-placement="top" title="'+data.notes+'">'+data.name+'</em></span><sup></sup>'+subcriteria;
370
+                }
371
+                else
372
+                {
373
+                    str+='<span>'+data.name+'</span><sup></sup>'+subcriteria;
374
+                }
375
+
376
+                str+='</td><td class="editable" data-type="textarea">'+data.description12+'</td>'
377
+                    +'<td class="editable" data-type="textarea">'+data.description34+'</td>'
378
+                    +'<td class="editable" data-type="textarea">'+data.description56+'</td>'
379
+                    +'<td class="editable" data-type="textarea">'+data.description78+'</td>'
380
+                    +'<th><span class="glyphicon glyphicon-remove" aria-hidden="true"></span></th></tr>';
381
+
382
+                $('table tbody').append(str);
383
+
384
+                // Build copyright list
385
+                buildCopyrightList();
386
+
387
+                // Enable X-Edtable on this new row
388
+                $('.editable').editable({
389
+                    unsavedclass: null,
390
+                    rows: 4
391
+                });
392
+
393
+                // Turn on tooltips again (because content is dynamic)
394
+                $('[data-toggle="tooltip"]').tooltip();
243 395
 
244
-      // Show the container and empty all rows
245
-      $('#rubric-container').show();
246
-      $('tbody').empty();
247 396
 
248
-      //Set the name of the rubric
249
-      $('#rubric-name').val(data.name);
397
+               
398
+            }); */
399
+
400
+          
401
+
402
+            // Build Copyright List
403
+            buildCopyrightList();
404
+        }, 
405
+        'json',
406
+    );
407
+}
250 408
 
409
+
410
+/*
251 411
       console.log($('#expected_percentage').text());
252 412
       console.log($('#expected_points').text());
253 413
 
@@ -305,7 +465,7 @@ function loadTemplate()
305 465
     }
306 466
   );
307 467
 }
308
-
468
+*/
309 469
 // --------------------------------------------------------------------------
310 470
 // Events
311 471
 // --------------------------------------------------------------------------
@@ -329,12 +489,22 @@ $('#button-save-rubric').on('click', function(e)
329 489
   //Prevent page refresh
330 490
   e.preventDefault();
331 491
 
332
-  var criterionObject = new Object();
333
-  var criteriaArray = new Array();
492
+  var criteria = [];
493
+  scales = [];
494
+  max_score = $('#max').val();
334 495
 
335 496
   // For each criterion in the rubric, get its value and put it into an array
336 497
   $('tbody tr').each(function( index )
337 498
   {
499
+
500
+    criteria.push($(this).data('criterion-id'));
501
+    each_criterion_scale =[];
502
+    $(this).children('td').each(function(index){
503
+      if(index!=0)
504
+      each_criterion_scale.push($(this).text());
505
+    })
506
+    scales.push(each_criterion_scale);
507
+    /*
338 508
       criterionObject.id = $(this).data('criterion-id');
339 509
       criterionObject.outcome_id = $(this).data('assoc-outcome-id');
340 510
       criterionObject.name = $(this).children('td:nth-child(1)').find('span').text();
@@ -356,7 +526,7 @@ $('#button-save-rubric').on('click', function(e)
356 526
       // Clone the object and push it into the array
357 527
       var clone = jQuery.extend({}, criterionObject);
358 528
       criteriaArray.push(clone);
359
-
529
+*/
360 530
   });
361 531
 
362 532
   // If activity does not have a rubric, create it
@@ -371,9 +541,13 @@ $('#button-save-rubric').on('click', function(e)
371 541
       {
372 542
         name: $('#select-template').find(':selected').text(),
373 543
         activity_id: parseInt($('#activity_id').val()),
374
-        contents: JSON.stringify(criteriaArray),
544
+        contents: " ",
375 545
         expected_percentage: $('#expected_percentage').text(),
376
-        expected_points: $('#expected_points').text()
546
+        expected_points: $('#expected_points').text(),
547
+        criteria: criteria,
548
+        scales: scales,
549
+        max_score:max_score
550
+
377 551
 
378 552
       },
379 553
       function(data)

+ 49
- 0
script.php Parādīt failu

@@ -0,0 +1,49 @@
1
+<?php
2
+
3
+
4
+$servername = "127.0.0.1";
5
+$username = "root";
6
+$password = "";
7
+$database = "trabajoolas5";
8
+
9
+// Create connection
10
+$conn = mysqli_connect($servername, $username, $password, $database);
11
+
12
+// Check connection
13
+if (!$conn) {
14
+    die("Connection failed: " . mysqli_connect_error());
15
+}
16
+echo "Connected successfully\n";
17
+
18
+$allrubrics = mysqli_query($conn, 'select id, contents from `rubrics`');
19
+
20
+while ($row = mysqli_fetch_array($allrubrics)) {
21
+
22
+    foreach (json_decode($row['contents']) as $criterion) {
23
+
24
+        $outcome_id = $criterion->outcome_id;
25
+        $querySelect = "select * from rubric_outcome where rubric_id ={$row['id']} and outcome_id = {$outcome_id}";
26
+        $makeQuery = mysqli_query($conn, $querySelect);
27
+        if (!mysqli_num_rows($makeQuery)) {
28
+
29
+            $query2 = "insert into `rubric_outcome` (`rubric_id`, `outcome_id`) values ({$row['id']}, {$outcome_id});";
30
+            $makeQuery = mysqli_query($conn, $query2);
31
+            if (!$makeQuery) {
32
+                die("Connection failed: " . mysqli_error($conn) . $query2);
33
+            }
34
+        }
35
+
36
+
37
+
38
+        $criteria_id = $criterion->id;
39
+        $querySelect = "select * from rubric_criterion where rubric_id ={$row['id']} and criterion_id = {$criteria_id}";
40
+        $makeQuery = mysqli_query($conn, $querySelect);
41
+        if (!mysqli_num_rows($makeQuery)) {
42
+            $query2 = "insert into `rubric_criterion` (`rubric_id`, `criterion_id`) values ({$row['id']}, {$criteria_id});";
43
+            $makeQuery = mysqli_query($conn, $query2);
44
+            if (!$makeQuery) {
45
+                echo "Connection failed: " . mysqli_error($conn) . $query2;
46
+            }
47
+        }
48
+    }
49
+}

+ 46
- 0
script_template_fix.php Parādīt failu

@@ -0,0 +1,46 @@
1
+<?php
2
+
3
+
4
+$servername = "127.0.0.1";
5
+$username = "root";
6
+$password = "";
7
+$database = "trabajoolas5";
8
+
9
+// Create connection
10
+$conn = mysqli_connect($servername, $username, $password, $database);
11
+
12
+// Check connection
13
+if (!$conn) {
14
+    die("Connection failed: " . mysqli_connect_error());
15
+}
16
+echo "Connected successfully\n";
17
+
18
+$allrubrics = mysqli_query($conn, 'select id, num_scales, max_score from `rubrics`');
19
+
20
+while ($row = mysqli_fetch_array($allrubrics)) {
21
+
22
+if($row['num_scales']==0 && $row['max_score']==0){
23
+    $query = "update rubrics set num_scales = 4, max_score =8 where id ={$row['id']} ";
24
+    $makeQuery = mysqli_query($conn, $query);
25
+    if(!$query){
26
+        die("Connection failed: " . mysqli_error($conn) . $query1);
27
+    }
28
+
29
+}
30
+
31
+}
32
+
33
+$allrubrics = mysqli_query($conn, 'select id, num_scales, max_score from `templates`');
34
+
35
+while ($row = mysqli_fetch_array($allrubrics)) {
36
+
37
+if($row['num_scales']==0 && $row['max_score']==0){
38
+    $query = "update templates set num_scales = 4, max_score =8 where id ={$row['id']} ";
39
+    $makeQuery = mysqli_query($conn, $query);
40
+    if(!$query){
41
+        die("Connection failed: " . mysqli_error($conn) . $query1);
42
+    }
43
+
44
+}
45
+
46
+}

+ 36
- 0
script_template_scales.php Parādīt failu

@@ -0,0 +1,36 @@
1
+<?php
2
+
3
+
4
+$servername = "127.0.0.1";
5
+$username = "root";
6
+$password = "";
7
+$database = "trabajoolas5";
8
+
9
+// Create connection
10
+$conn = mysqli_connect($servername, $username, $password, $database);
11
+
12
+// Check connection
13
+if (!$conn) {
14
+    die("Connection failed: " . mysqli_connect_error());
15
+}
16
+echo "Connected successfully\n";
17
+
18
+$allrubrics = mysqli_query($conn, 'select id, contents from `templates`');
19
+
20
+while ($row = mysqli_fetch_array($allrubrics)) {
21
+
22
+    foreach (json_decode($row['contents']) as $criterion) {
23
+
24
+        $criterion_id = $criterion->id;
25
+        $querySelect = "select * from template_criterion where template_id ={$row['id']} and criterion_id = {$criterion_id}";
26
+        $makeQuery = mysqli_query($conn, $querySelect);
27
+        if (!mysqli_num_rows($makeQuery)) {
28
+
29
+            $query2 = "insert into `template_criterion` (`template_id`, `criterion_id`) values ({$row['id']}, {$criterion_id});";
30
+            $makeQuery = mysqli_query($conn, $query2);
31
+            if (!$makeQuery) {
32
+                echo "Connection failed: " . mysqli_error($conn) . $query2;
33
+            }
34
+        }
35
+    }
36
+}

+ 111
- 0
script_template_scales_to_scales.php Parādīt failu

@@ -0,0 +1,111 @@
1
+<?php
2
+
3
+
4
+$servername = "127.0.0.1";
5
+$username = "root";
6
+$password = "";
7
+$database = "trabajoolas5";
8
+
9
+// Create connection
10
+$conn = mysqli_connect($servername, $username, $password, $database);
11
+
12
+// Check connection
13
+if (!$conn) {
14
+    die("Connection failed: " . mysqli_connect_error());
15
+}
16
+echo "Connected successfully\n";
17
+
18
+$allrubrics = mysqli_query($conn, 'select id, contents from `templates`');
19
+
20
+while ($row = mysqli_fetch_array($allrubrics)) {
21
+
22
+    foreach (json_decode($row['contents']) as $criterion) {
23
+
24
+        $criterion_id = $criterion->id;
25
+        $querySelect = "select * from template_criterion where template_id ={$row['id']} and criterion_id = {$criterion_id}";
26
+        $makeQuery = mysqli_query($conn, $querySelect);
27
+        if (mysqli_num_rows($makeQuery)) {
28
+
29
+            $row2 = mysqli_fetch_array($makeQuery);
30
+            $template_criterion_id = $row2['id'];
31
+            $description12 = mysqli_escape_string($conn, $criterion->description12);
32
+            $queryForScale = "insert into scales (`description`, `min_score`, `max_score`) values ('{$description12}', 1, 2)";
33
+            $makeQueryForScale = mysqli_query($conn, $queryForScale);
34
+            if ($makeQueryForScale) {
35
+                $toFindScale = "select * from scales order by id DESC";
36
+                $findScale = mysqli_query($conn, $toFindScale);
37
+                if (mysqli_num_rows($findScale)) {
38
+                    $scale = mysqli_fetch_array($findScale);
39
+                    $queryToInsert = "insert into `template_criterion_scale` (`template_criterion_id`,`scale_id`, `position`) values ({$template_criterion_id}, {$scale['id']}, 0)";
40
+                    $insertIntoTemplate = mysqli_query($conn, $queryToInsert);
41
+                    if (!$insertIntoTemplate) {
42
+                        echo "Scales problem: " . mysqli_error($conn) . $queryToInsert;
43
+                        die;
44
+                    }
45
+                }
46
+            } else {
47
+                echo "Couldnt insert scale: " . mysqli_error($conn) . $queryForScale;
48
+                die;
49
+            }
50
+            $description34 = mysqli_escape_string($conn, $criterion->description34);
51
+            $queryForScale = "insert into scales (`description`, `min_score`, `max_score`) values ('{$description34}', 3, 4)";
52
+            $makeQueryForScale = mysqli_query($conn, $queryForScale);
53
+            if ($makeQueryForScale) {
54
+                $toFindScale = "select * from scales order by id DESC";
55
+                $findScale = mysqli_query($conn, $toFindScale);
56
+                if (mysqli_num_rows($findScale)) {
57
+                    $scale = mysqli_fetch_array($findScale);
58
+                    $queryToInsert = "insert into `template_criterion_scale` (`template_criterion_id`,`scale_id`, `position`) values ({$template_criterion_id}, {$scale['id']}, 1)";
59
+                    $insertIntoTemplate = mysqli_query($conn, $queryToInsert);
60
+                    if (!$insertIntoTemplate) {
61
+                        echo "Scales problem: " . mysqli_error($conn) . $queryToInsert;
62
+                        die;
63
+                    }
64
+                }
65
+            } else {
66
+                echo "Couldnt insert scale: " . mysqli_error($conn) . $queryForScale;
67
+                die;
68
+            }
69
+            $description56 = mysqli_escape_string($conn, $criterion->description56);
70
+            $queryForScale = "insert into scales (`description`, `min_score`, `max_score`) values ('{$description56}', 5, 6)";
71
+            $makeQueryForScale = mysqli_query($conn, $queryForScale);
72
+            if ($makeQueryForScale) {
73
+                $toFindScale = "select * from scales order by id DESC";
74
+                $findScale = mysqli_query($conn, $toFindScale);
75
+                if (mysqli_num_rows($findScale)) {
76
+                    $scale = mysqli_fetch_array($findScale);
77
+                    $queryToInsert = "insert into `template_criterion_scale` (`template_criterion_id`,`scale_id`, `position`) values ({$template_criterion_id}, {$scale['id']}, 2)";
78
+                    $insertIntoTemplate = mysqli_query($conn, $queryToInsert);
79
+                    if (!$insertIntoTemplate) {
80
+                        echo "Scales problem: " . mysqli_error($conn) . $queryToInsert;
81
+                        die;
82
+                    }
83
+                }
84
+            } else {
85
+                echo "Couldnt insert scale: " . mysqli_error($conn) . $queryForScale;
86
+                die;
87
+            }
88
+            $description78 = mysqli_escape_string($conn, $criterion->description78);
89
+            $queryForScale = "insert into scales (`description`, `min_score`, `max_score`) values ('{$description78}', 7, 8)";
90
+            $makeQueryForScale = mysqli_query($conn, $queryForScale);
91
+            if ($makeQueryForScale) {
92
+                $toFindScale = "select * from scales order by id DESC";
93
+                $findScale = mysqli_query($conn, $toFindScale);
94
+                if (mysqli_num_rows($findScale)) {
95
+                    $scale = mysqli_fetch_array($findScale);
96
+                    $queryToInsert = "insert into `template_criterion_scale` (`template_criterion_id`,`scale_id`, `position`) values ({$template_criterion_id}, {$scale['id']}, 3)";
97
+                    $insertIntoTemplate = mysqli_query($conn, $queryToInsert);
98
+                    if (!$insertIntoTemplate) {
99
+                        echo "Scales problem: " . mysqli_error($conn) . $queryToInsert;
100
+                        die;
101
+                    }
102
+                }
103
+            } else {
104
+                echo "Couldnt insert scale: " . mysqli_error($conn) . $queryForScale;
105
+                die;
106
+            }
107
+        } else {
108
+            echo "no creo que hay problema no?";
109
+        }
110
+    }
111
+}