Browse Source

SubiendoInfo

parent
commit
72cfe00634

+ 6
- 1
app/controllers/ActivitiesController.php View File

113
     {
113
     {
114
         $activity = Activity::find($id);
114
         $activity = Activity::find($id);
115
 
115
 
116
+
116
         // If activity does not exist, display 404
117
         // If activity does not exist, display 404
117
         if (!$activity)
118
         if (!$activity)
118
             App::abort('404');
119
             App::abort('404');
121
         $course = Course::where('id', '=', $activity->course_id)->firstOrFail();
122
         $course = Course::where('id', '=', $activity->course_id)->firstOrFail();
122
 
123
 
123
         // If activity does not belong to the requesting user, display 403
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
             App::abort('403', 'Access Forbidden');
126
             App::abort('403', 'Access Forbidden');
126
 
127
 
127
         // Get active semesters
128
         // Get active semesters
130
         foreach ($active_semesters_collection as $active_semester) {
131
         foreach ($active_semesters_collection as $active_semester) {
131
             $active_semesters[] = $active_semester->id;
132
             $active_semesters[] = $active_semester->id;
132
         }
133
         }
134
+        Log::info($active_semesters);
133
         // 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
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
         $title = $course->code . $course->number . '-' . $course->section . ': ' . htmlspecialchars($activity->name, ENT_QUOTES) . ' <span class="small attention">(' . $course->semester->code . ')</span>';
136
         $title = $course->code . $course->number . '-' . $course->section . ': ' . htmlspecialchars($activity->name, ENT_QUOTES) . ' <span class="small attention">(' . $course->semester->code . ')</span>';
135
         $outcomes = Outcome::orderBy('name', 'asc')->get();
137
         $outcomes = Outcome::orderBy('name', 'asc')->get();
136
         $outcomes_achieved = json_decode($activity->outcomes_achieved, true);
138
         $outcomes_achieved = json_decode($activity->outcomes_achieved, true);
137
         $outcomes_attempted = json_decode($activity->outcomes_attempted, true);
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
         return View::make('local.professors.activity', compact('activity', 'title', 'outcomes', 'outcomes_achieved', 'outcomes_attempted', 'course', 'student_count', 'active_semesters'));
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 View File

43
   public function viewAllPlans($program_id)
43
   public function viewAllPlans($program_id)
44
   {
44
   {
45
     $title = "Annual Plans";
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
     return View::make('local.managers.sCoords.view-annual-plans', compact('title', 'program_id', 'annual_plans'));
49
     return View::make('local.managers.sCoords.view-annual-plans', compact('title', 'program_id', 'annual_plans'));
138
     } else {
138
     } else {
139
       $current_typ = DB::select("select * from three_year_plan where id ={$typ_id}")[0];
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
     $program = Program::where('id', '=', $program_id)->first();
144
     $program = Program::where('id', '=', $program_id)->first();

+ 18
- 3
app/controllers/CriteriaController.php View File

50
         return View::make('local.managers.sCoords.criteria', compact('title', 'outcomes', 'schools', 'criteria', 'programs', 'objectives'));
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
     public function fetchCriterion()
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
     public function fetchAllCriterion()
73
     public function fetchAllCriterion()
59
     {
74
     {
61
         $outcome_id = Input::get('outcome_fetch');
76
         $outcome_id = Input::get('outcome_fetch');
62
         $json = array();
77
         $json = array();
63
         $json['criterion'] = DB::select("SELECT * FROM `new_criteria` where id in (select criterion_id from criterion_objective_outcome where outcome_id ={$outcome_id}) and id in(select criterion_id from program_criterion where program_id = {$program_id})");
78
         $json['criterion'] = DB::select("SELECT * FROM `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
         return json_encode($json);
80
         return json_encode($json);
65
     }
81
     }
66
     public function fetchObjectivesForSelect()
82
     public function fetchObjectivesForSelect()
67
     {
83
     {
68
 
84
 
69
         $json = array();
85
         $json = array();
70
-        Log::info("GET COCKEd");
86
+
71
         Log::info(Input::get('allOutcomes'));
87
         Log::info(Input::get('allOutcomes'));
72
         foreach (Input::get('allOutcomes') as $id) {
88
         foreach (Input::get('allOutcomes') as $id) {
73
             $json['outcomes'][$id] = DB::select("select name from outcomes where id = {$id}");
89
             $json['outcomes'][$id] = DB::select("select name from outcomes where id = {$id}");
586
 
602
 
587
         // se annadio la nueva variable
603
         // se annadio la nueva variable
588
         return View::make('global.view-learning-outcomes-criteria', compact('title', 'outcomes', 'schools', 'criteria', 'semesters'));
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 View File

43
         $undergradResults = array("names" => array(), "schools" => array(), "achieved" => array(), "attempted" => array(), "successRate" => array());
43
         $undergradResults = array("names" => array(), "schools" => array(), "achieved" => array(), "attempted" => array(), "successRate" => array());
44
         $gradResults = array("names" => array(), "schools" => array(), "achieved" => array(), "attempted" => array(), "successRate" => array());
44
         $gradResults = array("names" => array(), "schools" => array(), "achieved" => array(), "attempted" => array(), "successRate" => array());
45
         foreach ($programs as $program_id) {
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
         return View::make('local.managers.admins.learning-outcome_new', compact('title', 'outcome', 'undergradResults', 'gradResults'));
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
     // TODO: Clean up and verify relationships are correct
205
     // TODO: Clean up and verify relationships are correct
211
     public function newShow($id)
206
     public function newShow($id)
415
         if (Input::get('filter')) {
410
         if (Input::get('filter')) {
416
             switch (Input::get('filter')) {
411
             switch (Input::get('filter')) {
417
                 case 'all':
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
                     break;
419
                     break;
420
 
420
 
421
                 case 'school':
421
                 case 'school':
424
 
424
 
425
                         // Fetch all the programs whose school is the user's
425
                         // Fetch all the programs whose school is the user's
426
                         $program_ids = DB::table('programs')->where('school_id', Auth::user()->school_id)->lists('id');
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
                             ->orderBy('name', 'ASC')
433
                             ->orderBy('name', 'ASC')
432
                             ->get();
434
                             ->get();
435
+                        // Return all criteria belonging to any of those programs
436
+                        return $new_criteria;
433
                     }
437
                     }
434
 
438
 
435
                     // If pcoord
439
                     // If pcoord
438
                         // Fetch all the programs from the user's school;
442
                         // Fetch all the programs from the user's school;
439
                         $program_ids = DB::table('programs')->where('school_id', Auth::user()->programs[0]->school->id)->lists('id');
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
                             ->orderBy('name', 'ASC')
451
                             ->orderBy('name', 'ASC')
444
                             ->get();
452
                             ->get();
445
                     }
453
                     }
447
                     break;
455
                     break;
448
 
456
 
449
                 case 'program':
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
                         ->orderBy('name', 'ASC')
464
                         ->orderBy('name', 'ASC')
453
                         ->get();
465
                         ->get();
466
+                    return $new_criteria;
454
                     break;
467
                     break;
455
 
468
 
456
                 default:
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
                     break;
476
                     break;
459
             }
477
             }
460
         } else {
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
 
564
 
542
         $outcome->criteria = array();
565
         $outcome->criteria = array();
543
         foreach ($diferent_levels as $level) {
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
                   SELECT *
586
                   SELECT *
564
                   FROM (
587
                   FROM (
565
                     SELECT new_criteria.id as criterion_id,
588
                     SELECT new_criteria.id as criterion_id,
579
                   WHERE rn = 1
602
                   WHERE rn = 1
580
                   ORDER BY `a`.`position` ASC
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
             'outcome' => $outcome,
614
             'outcome' => $outcome,
593
         );
615
         );
594
     }
616
     }

+ 55
- 31
app/controllers/RubricsController.php View File

45
         if (!$activity)
45
         if (!$activity)
46
             App::abort('404');
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
         // Select templates that belong to everyone or belong to the activity's course's school
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
         $rubrics = Auth::user()->rubrics;
61
         $rubrics = Auth::user()->rubrics;
64
         $outcomes = Outcome::orderBy('name', 'ASC')->get();
62
         $outcomes = Outcome::orderBy('name', 'ASC')->get();
78
 
76
 
79
         DB::beginTransaction();
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
             // Process activity
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
             DB::commit();
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
             Session::flash('status', 'success');
124
             Session::flash('status', 'success');
103
             Session::flash('message', 'Rubric assigned.');
125
             Session::flash('message', 'Rubric assigned.');
104
 
126
 
105
             return action('ActivitiesController@show', array(Input::get('activity_id')));
127
             return action('ActivitiesController@show', array(Input::get('activity_id')));
106
-
128
+        } else {
107
             DB::rollBack();
129
             DB::rollBack();
108
             Session::flash('status', 'danger');
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
      * Return a specific template
137
      * Return a specific template
115
      *
138
      *
251
         // If activity does not belong to the requesting user, display 403
274
         // If activity does not belong to the requesting user, display 403
252
         if ($course->user_id != Auth::id())
275
         if ($course->user_id != Auth::id())
253
             App::abort('403', 'Access Forbidden');
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
         $title = $activity->name . ': ' . $rubric->name;
280
         $title = $activity->name . ': ' . $rubric->name;
257
         return View::make('local.professors.viewrubric', compact('rubric', 'activity', 'title', 'course'));
281
         return View::make('local.professors.viewrubric', compact('rubric', 'activity', 'title', 'course'));
258
     }
282
     }

+ 86
- 61
app/controllers/TemplatesController.php View File

1
 <?php
1
 <?php
2
 
2
 
3
-class TemplatesController extends \BaseController {
3
+class TemplatesController extends \BaseController
4
+{
4
 
5
 
5
 	/**
6
 	/**
6
 	 * List all templates, grouped by program
7
 	 * List all templates, grouped by program
12
 		$global_templates = Template::whereNull('school_id')->whereNull('program_id')->get();
13
 		$global_templates = Template::whereNull('school_id')->whereNull('program_id')->get();
13
 
14
 
14
 		$schools = School::with('programs.templates')
15
 		$schools = School::with('programs.templates')
15
-		->orderBy('name')
16
-		->get();
16
+			->orderBy('name')
17
+			->get();
17
 
18
 
18
 		$templates = Template::orderBy('name')->get();
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
 	public function schoolCoordinatorIndex()
24
 	public function schoolCoordinatorIndex()
27
 		$global_templates = Template::whereNull('school_id')->whereNull('program_id')->get();
28
 		$global_templates = Template::whereNull('school_id')->whereNull('program_id')->get();
28
 
29
 
29
 		$schools = School::with('programs.templates')
30
 		$schools = School::with('programs.templates')
30
-		->orderBy('name')
31
-		->get();
31
+			->orderBy('name')
32
+			->get();
32
 
33
 
33
 		$templates = Template::orderBy('name')->get();
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
 	public function show(Template $template)
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
 	 */
49
 	 */
49
 	public function newTemplate()
50
 	public function newTemplate()
50
 	{
51
 	{
51
-		$title= "Rubric Builder";
52
+		$title = "Rubric Builder";
52
 
53
 
53
 		$templates = Template::orderBy('name', 'ASC')->get();
54
 		$templates = Template::orderBy('name', 'ASC')->get();
54
 		$outcomes = Outcome::orderBy('name', 'ASC')->get();
55
 		$outcomes = Outcome::orderBy('name', 'ASC')->get();
59
 		$templates = NULL;
60
 		$templates = NULL;
60
 		$programs = NULL;
61
 		$programs = NULL;
61
 		// Returns templates depending on the type of user
62
 		// Returns templates depending on the type of user
62
-		if( $role == 1)
63
-		{
63
+		if ($role == 1) {
64
 			$templates = Template::orderBy('name', 'ASC')->get();
64
 			$templates = Template::orderBy('name', 'ASC')->get();
65
 			$programs = Program::orderBy('name', 'ASC')->get();
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
 			$programs = Auth::user()->school->programs;
68
 			$programs = Auth::user()->school->programs;
71
-		}
72
-		elseif ($role == 3)
73
-		{
69
+		} elseif ($role == 3) {
74
 			$templates = Template::where('school_id', '=', Auth::user()->programs[0]->school->id)->orWhere('school_id', '=', NULL)->orderBy('name', 'ASC')->get();
70
 			$templates = Template::where('school_id', '=', Auth::user()->programs[0]->school->id)->orWhere('school_id', '=', NULL)->orderBy('name', 'ASC')->get();
75
 			$programs = Auth::user()->programs()->get();
71
 			$programs = Auth::user()->programs()->get();
76
 		}
72
 		}
96
 
92
 
97
 		// If user can set the school (that is, if school_id is not undefined)
93
 		// If user can set the school (that is, if school_id is not undefined)
98
 		// set the school id or set to null
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
 				$template->school_id = Input::get('school_id');
97
 				$template->school_id = Input::get('school_id');
103
-			elseif(Input::get('school_id')==0)
98
+			elseif (Input::get('school_id') == 0)
104
 				$template->school_id = NULL;
99
 				$template->school_id = NULL;
105
 		}
100
 		}
106
 
101
 
107
 		// If user can set the program (that is, if program_id is not undefined)
102
 		// If user can set the program (that is, if program_id is not undefined)
108
 		// set the program id or set to null
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
 				$template->program_id = Input::get('program_id');
106
 				$template->program_id = Input::get('program_id');
113
-			elseif(Input::get('program_id')==0)
107
+			elseif (Input::get('program_id') == 0)
114
 				$template->program_id = NULL;
108
 				$template->program_id = NULL;
115
 		}
109
 		}
116
 
110
 
126
 				$template->program_id = Auth::user()->programs[0]->id;
120
 				$template->program_id = Auth::user()->programs[0]->id;
127
 				break;
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
 			Session::flash('status', 'success');
154
 			Session::flash('status', 'success');
133
 			Session::flash('message', 'Rubric created. You can now select it from the list.');
155
 			Session::flash('message', 'Rubric created. You can now select it from the list.');
134
-		}
135
-		else
136
-		{
156
+		} else {
137
 			Session::flash('status', 'danger');
157
 			Session::flash('status', 'danger');
138
 			Session::flash('message', 'Rubric could not be created.');
158
 			Session::flash('message', 'Rubric could not be created.');
139
 		}
159
 		}
146
 	 */
166
 	 */
147
 	public function fetch()
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
 
201
 
167
 		// If user can set the school (that is, if school_id is not undefined)
202
 		// If user can set the school (that is, if school_id is not undefined)
168
 		// set the school id or set to null
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
 				$template->school_id = Input::get('school_id');
206
 				$template->school_id = Input::get('school_id');
173
-			elseif(Input::get('school_id')==0)
207
+			elseif (Input::get('school_id') == 0)
174
 				$template->school_id = NULL;
208
 				$template->school_id = NULL;
175
 		}
209
 		}
176
 
210
 
177
 		// If user can set the program (that is, if program_id is not undefined)
211
 		// If user can set the program (that is, if program_id is not undefined)
178
 		// set the program id or set to null
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
 				$template->program_id = Input::get('program_id');
215
 				$template->program_id = Input::get('program_id');
183
-			elseif(Input::get('program_id')==0)
216
+			elseif (Input::get('program_id') == 0)
184
 				$template->program_id = NULL;
217
 				$template->program_id = NULL;
185
 		}
218
 		}
186
 
219
 
187
-		if($template->save())
188
-		{
220
+		if ($template->save()) {
189
 			Session::flash('status', 'success');
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
 			Session::flash('status', 'danger');
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
 	{
235
 	{
206
 		$template = Template::find(Input::get('id'));
236
 		$template = Template::find(Input::get('id'));
207
 
237
 
208
-		if($template->delete())
209
-		{
238
+		if ($template->delete()) {
210
 			Session::flash('status', 'success');
239
 			Session::flash('status', 'success');
211
 			Session::flash('message', 'Rubric deleted.');
240
 			Session::flash('message', 'Rubric deleted.');
212
-		}
213
-		else
214
-		{
241
+		} else {
215
 			Session::flash('status', 'danger');
242
 			Session::flash('status', 'danger');
216
 			Session::flash('message', 'Rubric could not be deleted.');
243
 			Session::flash('message', 'Rubric could not be deleted.');
217
 		}
244
 		}
226
 
253
 
227
 			$title = $template->name;
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
 			else
258
 			else
232
 				$school = 'All Schools';
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
 			else
263
 			else
237
 				$program = 'All Programs';
264
 				$program = 'All Programs';
238
 
265
 
239
 			return View::make('local.managers.shared.print_rubric', compact('title', 'template', 'school', 'program'));
266
 			return View::make('local.managers.shared.print_rubric', compact('title', 'template', 'school', 'program'));
240
-		}
241
-		catch (Exception $e) {
267
+		} catch (Exception $e) {
242
 			Session::flash('status', 'danger');
268
 			Session::flash('status', 'danger');
243
 			Session::flash('message', $e->getMessage());
269
 			Session::flash('message', $e->getMessage());
244
 			return Redirect::back();
270
 			return Redirect::back();
245
 		}
271
 		}
246
 	}
272
 	}
247
-
248
 }
273
 }

+ 11
- 18
app/controllers/ThreeYearPlanController.php View File

420
           foreach ($result_objectives as $objectives_) {
420
           foreach ($result_objectives as $objectives_) {
421
             $objective_id = $objectives_->objective_id;
421
             $objective_id = $objectives_->objective_id;
422
             $program_id = $objectives_->program_id;
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
               ->orderBy('courses.name', 'asc')
426
               ->orderBy('courses.name', 'asc')
432
               ->groupBy('courses.name', 'courses.code')
427
               ->groupBy('courses.name', 'courses.code')
433
               ->get();
428
               ->get();
539
     }
534
     }
540
     return 'update succes?';
535
     return 'update succes?';
541
   }
536
   }
542
-
543
   public function createAnnualPlan($program_id)
537
   public function createAnnualPlan($program_id)
544
   {
538
   {
545
     $current_typ = DB::select("select * from three_year_plan where year_start <=" . date('Y') . " and year_end >=" . date('Y'))[0];
539
     $current_typ = DB::select("select * from three_year_plan where year_start <=" . date('Y') . " and year_end >=" . date('Y'))[0];
546
     $count = 0;
540
     $count = 0;
547
     $yearStartPlusOne = $current_typ->year_start + 1;
541
     $yearStartPlusOne = $current_typ->year_start + 1;
548
     $yearStart = $current_typ->year_start;
542
     $yearStart = $current_typ->year_start;
543
+    Log::info($yearStart);
544
+    Log::info($yearStartPlusOne);
549
     while ($count < 3) {
545
     while ($count < 3) {
550
 
546
 
551
 
547
 
554
 
550
 
555
       $secondSemester = DB::select("select * from semesters where name like 'Second Semester {$yearStart}-{$yearStartPlusOne}'");
551
       $secondSemester = DB::select("select * from semesters where name like 'Second Semester {$yearStart}-{$yearStartPlusOne}'");
556
       if (count($firstSemester) && count($secondSemester)) {
552
       if (count($firstSemester) && count($secondSemester)) {
553
+        Log::info($firstSemester);
554
+        Log::info($secondSemester);
557
         $query = DB::select("select * from annual_plans where semester_start ={$firstSemester[0]->id} and semester_end ={$secondSemester[0]->id} and program_id = {$program_id}");
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
         if (!count($query)) {
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 View File

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 View File

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 View File

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 View File

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 View File

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 View File

172
         'as' => 'fetchCriteria',
172
         'as' => 'fetchCriteria',
173
         'uses' => 'OutcomesController@fetchCriteria'
173
         'uses' => 'OutcomesController@fetchCriteria'
174
     ));
174
     ));
175
+    Route::post('fetchCriterionWithTemplate', array(
176
+        'as' => 'fetchCriterionWithTemplate',
177
+        'uses' => 'CriteriaController@fetchCriterionWithTemplate'
178
+    ));
175
 
179
 
176
     // Fetch a criterion for a rubric
180
     // Fetch a criterion for a rubric
177
     Route::post('fetchCriterion', array(
181
     Route::post('fetchCriterion', array(

+ 3
- 1
app/views/global/view-three-year-plan.blade.php View File

345
 $('.go-to-temp').on('click', function(){
345
 $('.go-to-temp').on('click', function(){
346
   $.post(
346
   $.post(
347
     "{{ URL::action('ThreeYearPlanController@createAnnualPlan', array($program_id))}}");
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
     // When list item is clicked, load corresponding info
352
     // When list item is clicked, load corresponding info
351
     //section 1
353
     //section 1

+ 64
- 42
app/views/local/managers/pCoords/criteria.blade.php View File

19
                         <label>Associated Outcomes</label>
19
                         <label>Associated Outcomes</label>
20
 
20
 
21
                         {{ Form::select('outcome[]', $outcomes, reset($outcomes),  ['class'=>'form-control selectpicker', 'id' =>'outcome0', 'onchange'=>'fetchObjectiveForSelect("outcome0")']) }}
21
                         {{ Form::select('outcome[]', $outcomes, reset($outcomes),  ['class'=>'form-control selectpicker', 'id' =>'outcome0', 'onchange'=>'fetchObjectiveForSelect("outcome0")']) }}
22
-
23
                     </div>
22
                     </div>
24
                 </div>
23
                 </div>
25
                 <input type='hidden' name='counterOutcome' id='counterOutcome' value=1>
24
                 <input type='hidden' name='counterOutcome' id='counterOutcome' value=1>
409
             'name': "outcome[]",
408
             'name': "outcome[]",
410
             'data-live-search': 'true',
409
             'data-live-search': 'true',
411
             'id': 'outcome' + counter.toString(),
410
             'id': 'outcome' + counter.toString(),
412
-            'onchange': 'fetchObjectiveForSelect("outcome' + counter.toString() + '")'
411
+            'onchange': 'fetchObjectiveForSelect("outcomeGroup", "objectiveGroup")'
413
 
412
 
414
         });
413
         });
415
         var $div = $('<div/>', {
414
         var $div = $('<div/>', {
425
         var $button = $('<button/>', {
424
         var $button = $('<button/>', {
426
             'type': 'button',
425
             'type': 'button',
427
             'class': 'btn btn-primary',
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
         $button.append('X');
430
         $button.append('X');
432
         $divForButton.append($button);
431
         $divForButton.append($button);
435
         $select.append(selectOptions);
434
         $select.append(selectOptions);
436
 
435
 
437
         $select.appendTo('#outcomeForm' + counter.toString()).selectpicker('refresh');
436
         $select.appendTo('#outcomeForm' + counter.toString()).selectpicker('refresh');
438
-        fetchObjectiveForSelect('outcome' + counter.toString());
437
+        fetchObjectiveForSelect('outcomeGroup', "objectiveGroup");
439
         counter += 1;
438
         counter += 1;
440
         $divForButton.appendTo('#outcomeGroup');
439
         $divForButton.appendTo('#outcomeGroup');
441
 
440
 
448
 
447
 
449
     //Delete Outcome and OptGroup associated
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
         $div.remove();
452
         $div.remove();
454
-        $div = document.getElementById(outcomeOptGroup);
453
+        $div = document.getElementById(closeButton);
455
         $div.remove();
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
     //Delete Objective
460
     //Delete Objective
579
         var $button = $('<button/>', {
573
         var $button = $('<button/>', {
580
             'type': 'button',
574
             'type': 'button',
581
             'class': 'btn btn-primary',
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
         $button.append('X');
579
         $button.append('X');
586
         $divForButton.append($button);
580
         $divForButton.append($button);
644
     //Fetch objective at creating criteria
638
     //Fetch objective at creating criteria
645
     counterForPost = 0;
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
         $.post(
657
         $.post(
653
             "{{ URL::action('CriteriaController@fetchObjectivesForSelect') }}", {
658
             "{{ URL::action('CriteriaController@fetchObjectivesForSelect') }}", {
654
-                id: id
659
+                allOutcomes: allOutcomes
655
             },
660
             },
656
             function(varArray) {
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
                 $('#objective_0').selectpicker('refresh');
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
             'json'
706
             'json'
684
         );
707
         );
685
     }
708
     }
686
-
687
     //after post
709
     //after post
688
 
710
 
689
     fetchAllCriterion("select-program", "assoc_outcomes_fetch");
711
     fetchAllCriterion("select-program", "assoc_outcomes_fetch");
793
                 // Select associated outcome
815
                 // Select associated outcome
794
                 try {
816
                 try {
795
                     for (var i = assocOutcomeCounter - 1; i > 0; i--) {
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
                 } catch (err) {
820
                 } catch (err) {
799
                     var Notran = true;
821
                     var Notran = true;
800
                 }
822
                 }
974
 $('#outcome-display').parent().hide();
996
 $('#outcome-display').parent().hide();
975
 
997
 
976
 fetchCriterionForEditing();
998
 fetchCriterionForEditing();
977
-fetchObjectiveForSelect('outcome0');
999
+fetchObjectiveForSelect('outcomeGroup', 'objectiveGroup');
978
 // setCriterionStatus();
1000
 // setCriterionStatus();
979
 
1001
 
980
 
1002
 
1032
 })
1054
 })
1033
 
1055
 
1034
 $('#outcome[0]').on('change', function(){
1056
 $('#outcome[0]').on('change', function(){
1035
-fetchObjectiveForSelect(0);
1057
+
1036
 $('.selectpicker').selectpicker('refresh');
1058
 $('.selectpicker').selectpicker('refresh');
1037
 })
1059
 })
1038
 // When list item is clicked, load corresponding info
1060
 // When list item is clicked, load corresponding info

+ 10
- 7
app/views/local/managers/sCoords/annual-plans.blade.php View File

189
            var $button = $('<button/>', {
189
            var $button = $('<button/>', {
190
            'type': 'button',
190
            'type': 'button',
191
       'class': 'btn btn-secondary',
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
           $button.append("+ Add criteria");
195
           $button.append("+ Add criteria");
265
 
265
 
266
 
266
 
267
           $divForTA.append($divForTASelects);
267
           $divForTA.append($divForTASelects);
268
-          
269
-          $divForTA.append($buttonTA)
270
           $divForTA.append('<br>');
268
           $divForTA.append('<br>');
269
+          $divForTA.append($buttonTA)
270
+          
271
 
271
 
272
 
272
 
273
            table.row.add([
273
            table.row.add([
295
          
295
          
296
             
296
             
297
             for(i =0; i<json.selected_criteria[objectives[objective].id][course_id].length; i++){
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
               $('#criteriaFor'+objectives[objective].id+"-course-"+course_id+'_'+i).val(json.selected_criteria[objectives[objective].id][course_id][i].criteria_id);
299
               $('#criteriaFor'+objectives[objective].id+"-course-"+course_id+'_'+i).val(json.selected_criteria[objectives[objective].id][course_id][i].criteria_id);
300
               $('#criteriaFor'+objectives[objective].id+"-course-"+course_id+'_'+i).data('old-criteria', json.selected_criteria[objectives[objective].id][course_id][i].criteria_id);
300
               $('#criteriaFor'+objectives[objective].id+"-course-"+course_id+'_'+i).data('old-criteria', json.selected_criteria[objectives[objective].id][course_id][i].criteria_id);
301
               $('#criteriaFor'+objectives[objective].id+"-course-"+course_id+'_'+i).selectpicker('refresh');
301
               $('#criteriaFor'+objectives[objective].id+"-course-"+course_id+'_'+i).selectpicker('refresh');
306
        
306
        
307
           else{
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
             $('#criteriaFor'+objectives[objective].id+"-course-"+course_id+'_0').val(0);
310
             $('#criteriaFor'+objectives[objective].id+"-course-"+course_id+'_0').val(0);
311
               $('#criteriaFor'+objectives[objective].id+"-course-"+course_id+'_0').data('old-criteria', 0);
311
               $('#criteriaFor'+objectives[objective].id+"-course-"+course_id+'_0').data('old-criteria', 0);
312
               $('#criteriaFor'+objectives[objective].id+"-course-"+course_id+'_0').selectpicker('refresh');
312
               $('#criteriaFor'+objectives[objective].id+"-course-"+course_id+'_0').selectpicker('refresh');
385
   }).html('x');
385
   }).html('x');
386
   $span.appendTo($div);
386
   $span.appendTo($div);
387
   $div.append("<br><br>");
387
   $div.append("<br><br>");
388
-  $div.appendTo('#'+master_div);
388
+  $('#'+master_div).append("<br>");
389
+  
390
+  $div.appendTo($('#'+master_div));
389
   $('#'+master_div).data('amount-ta', counter+1);
391
   $('#'+master_div).data('amount-ta', counter+1);
390
 
392
 
391
 
393
 
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
   if(!i) amount_select = $('#'+div).data("amount-select");
438
   if(!i) amount_select = $('#'+div).data("amount-select");
437
   else amount_select = i;
439
   else amount_select = i;
459
   }).html('x');
461
   }).html('x');
460
   $div.append($span);
462
   $div.append($span);
461
  $div.append("<br><br>")
463
  $div.append("<br><br>")
464
+ $("#forObjective-"+new_id_for_select).append("<br>");
462
   $div.appendTo($("#forObjective-"+new_id_for_select));
465
   $div.appendTo($("#forObjective-"+new_id_for_select));
463
   
466
   
464
 
467
 

+ 286
- 104
app/views/local/managers/shared/rubrics.blade.php View File

129
                     </div>
129
                     </div>
130
                     @endif
130
                     @endif
131
                 </form>
131
                 </form>
132
+          
133
+               
132
 
134
 
133
                 <label for="">Select the lower bound for passing criteria</label>
135
                 <label for="">Select the lower bound for passing criteria</label>
134
                 <form class="form-inline">
136
                 <form class="form-inline">
146
                         </select>
148
                         </select>
147
                         % of all students must score at least
149
                         % of all students must score at least
148
 
150
 
151
+
152
+
153
+                        
149
                         <!-- Select points. If there is a rubric, select the saved value -->
154
                         <!-- Select points. If there is a rubric, select the saved value -->
150
                         <select id="expected_points" class="form-control selectpicker">
155
                         <select id="expected_points" class="form-control selectpicker">
151
-                            @for($i = 5; $i <= 8; $i++)
156
+                            @for($i = 0; $i <= 8; $i++)
152
                                 @if($i==5)
157
                                 @if($i==5)
153
                                     <option selected="selected" value="{{ $i }}">{{ $i }}</option>
158
                                     <option selected="selected" value="{{ $i }}">{{ $i }}</option>
154
                                 @else
159
                                 @else
196
                         @endforeach
201
                         @endforeach
197
                     </select>
202
                     </select>
198
                 </div>
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
                 @if(Auth::user()->role != '1')
237
                 @if(Auth::user()->role != '1')
201
 
238
 
202
                     <label>Filter Criteria</label>
239
                     <label>Filter Criteria</label>
229
 
266
 
230
 <div id="rubric-container" class="row">
267
 <div id="rubric-container" class="row">
231
     <div class="col-md-12">
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
             <thead>
271
             <thead>
235
-                <tr>
272
+                <tr id ="criterion-header">
236
                     <th></th>
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
                     <th></th>
274
                     <th></th>
243
                 </tr>
275
                 </tr>
244
             </thead>
276
             </thead>
245
-            <tbody>
277
+            <tbody id = "allCriteria">
246
             </tbody>
278
             </tbody>
247
         </table>
279
         </table>
248
 
280
 
273
         </div>
305
         </div>
274
     </div>
306
     </div>
275
 </div>
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
 // Functions
310
 // Functions
323
 // --------------------------------------------------------------------------
311
 // --------------------------------------------------------------------------
324
 
312
 
362
             $('#updated-text').fadeIn('slow').fadeOut('slow');
350
             $('#updated-text').fadeIn('slow').fadeOut('slow');
363
 
351
 
364
             refreshSelects();
352
             refreshSelects();
353
+
354
+
365
         }
355
         }
366
     );
356
     );
367
 }
357
 }
407
     // Fetch information of the criterion selected
397
     // Fetch information of the criterion selected
408
     $.post
398
     $.post
409
     (
399
     (
410
-        "{{ URL::route('fetchCriterion') }}",
400
+        "{{ URL::route('fetchCriterionWithTemplate') }}",
411
         { id: id},
401
         { id: id},
412
         function(data)
402
         function(data)
413
         {
403
         {
414
             // Append the fetched data
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
             var subcriteria = '';
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
                 subcriteria = '<ul class="subcriteria list-unstyled">';
411
                 subcriteria = '<ul class="subcriteria list-unstyled">';
423
                 subcriteria_array.forEach(function (value) {
412
                 subcriteria_array.forEach(function (value) {
424
                     subcriteria += '<li>'+value+'</li>';
413
                     subcriteria += '<li>'+value+'</li>';
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
             else
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
             $('table tbody').append(str);
435
             $('table tbody').append(str);
446
 
436
 
464
                 itemSelector: 'tr',
454
                 itemSelector: 'tr',
465
                 placeholder: '<tr class="placeholder"><th><span class="glyphicon glyphicon-arrow-right"></span></th></tr>'
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
     $('#select-criterion').selectpicker('refresh');
562
     $('#select-criterion').selectpicker('refresh');
572
     $('#expected_percentage').selectpicker('refresh');
563
     $('#expected_percentage').selectpicker('refresh');
573
     $('#expected_points').selectpicker('refresh');
564
     $('#expected_points').selectpicker('refresh');
565
+    $('#number_of_scales').selectpicker('refresh');
574
 }
566
 }
575
 
567
 
576
 // Fetch programs associated to a specific school
568
 // Fetch programs associated to a specific school
617
             $('tbody').empty();
609
             $('tbody').empty();
618
 
610
 
619
             //Set the name of the rubric
611
             //Set the name of the rubric
620
-            $('#rubric-name').val(data.name);
612
+            $('#rubric-name').val(data.template.name);
621
 
613
 
622
             // Set school id to 0, then to the saved value if it exists
614
             // Set school id to 0, then to the saved value if it exists
623
             $('#select-school option[data-school-id="0"]').prop('selected', true);
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
             // Fetch programs associated to that school
618
             // Fetch programs associated to that school
627
             fetchPrograms($('#select-school'));
619
             fetchPrograms($('#select-school'));
628
 
620
 
629
             // Set program id to 0, then to the saved value if it exists
621
             // Set program id to 0, then to the saved value if it exists
630
             $('#select-program option[data-program-id="0"]').prop('selected', true);
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
             // Set expected values
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
             // Set visibility
641
             // Set visibility
640
-            var is_visible = JSON.parse(data.is_visible);
642
+            var is_visible = data.template.is_visible;
641
             if(is_visible)
643
             if(is_visible)
642
             {
644
             {
643
                 $('#is_visible0').prop('checked', false);
645
                 $('#is_visible0').prop('checked', false);
651
 
653
 
652
 
654
 
653
             // Set the contents of the rubric
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
             var contents = JSON.parse(data.contents);
709
             var contents = JSON.parse(data.contents);
655
             contents.forEach(function (data)
710
             contents.forEach(function (data)
656
             {
711
             {
657
                 // Append the fetched data
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
                 var subcriteria = '';
716
                 var subcriteria = '';
702
 
756
 
703
 
757
 
704
                 refreshSelects();
758
                 refreshSelects();
705
-            });
759
+            }); */
706
 
760
 
707
             // Sortable rows
761
             // Sortable rows
708
             $('.table').sortable({
762
             $('.table').sortable({
715
 
769
 
716
             // Build Copyright List
770
             // Build Copyright List
717
             buildCopyrightList();
771
             buildCopyrightList();
718
-        }
772
+        }, 
773
+        'json',
719
     );
774
     );
720
 }
775
 }
721
 
776
 
740
 //Enable disable program select
795
 //Enable disable program select
741
 function toggleProgramSelect(school)
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
         $('#select-program option[data-program-id="0"]').prop('selected', true);
800
         $('#select-program option[data-program-id="0"]').prop('selected', true);
746
         $('#select-program').prop('disabled', true);
801
         $('#select-program').prop('disabled', true);
776
     $(this).siblings('.panel-body').stop().slideToggle();
831
     $(this).siblings('.panel-body').stop().slideToggle();
777
 });
832
 });
778
 
833
 
834
+
779
 // When trying to change the template, ask the user to confirm and reset the
835
 // When trying to change the template, ask the user to confirm and reset the
780
 // rubric if s/he does
836
 // rubric if s/he does
781
 $('#select-template').on('change', function()
837
 $('#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
 // When a school changes, update its programs. If all is selected, disable
924
 // When a school changes, update its programs. If all is selected, disable
832
 $('#select-school').on('change', function()
925
 $('#select-school').on('change', function()
833
 {
926
 {
834
     toggleProgramSelect($(this));
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
 // When a learning outcome changes, update its criteria
962
 // When a learning outcome changes, update its criteria
838
 $('#select-outcome, input[name=criteria-filter]').on('change', function()
963
 $('#select-outcome, input[name=criteria-filter]').on('change', function()
839
 {
964
 {
859
     // Empty field validation
984
     // Empty field validation
860
     var emptyFields=false;
985
     var emptyFields=false;
861
 
986
 
862
-    $('td').each(function()
987
+    $('#allCriteria').children('td').each(function()
863
     {
988
     {
864
         if ($(this).text() == "" || $(this).text() == "Empty")
989
         if ($(this).text() == "" || $(this).text() == "Empty")
865
         {
990
         {
867
         }
992
         }
868
     });
993
     });
869
 
994
 
995
+
870
     // If any fields are empty, display error
996
     // If any fields are empty, display error
871
     if(emptyFields || $.trim($('#rubric-name').val())=='')
997
     if(emptyFields || $.trim($('#rubric-name').val())=='')
872
     {
998
     {
873
         $('#js-error-row').show();
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
         return;
1001
         return;
876
     }
1002
     }
877
     else
1003
     else
894
     var criterionObject = new Object();
1020
     var criterionObject = new Object();
895
     var criteriaArray = new Array();
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
     // For each criterion in the rubric, get its value and put it into an array
1032
     // For each criterion in the rubric, get its value and put it into an array
898
     $('tbody tr').each(function( index )
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
             // Clone the object and push it into the array
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
             "{{ URL::to('saveTemplate') }}",
1061
             "{{ URL::to('saveTemplate') }}",
932
             {
1062
             {
933
                 name: $('#rubric-name').val(),
1063
                 name: $('#rubric-name').val(),
934
-                contents: JSON.stringify(criteriaArray),
1064
+                contents: " ",
935
                 school_id: $('#select-school').find(':selected').data('school-id'),
1065
                 school_id: $('#select-school').find(':selected').data('school-id'),
936
                 program_id: $('#select-program').find(':selected').data('program-id'),
1066
                 program_id: $('#select-program').find(':selected').data('program-id'),
937
                 expected_percentage: $('#expected_percentage').find(':selected').val(),
1067
                 expected_percentage: $('#expected_percentage').find(':selected').val(),
938
                 expected_points: $('#expected_points').find(':selected').val(),
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
             function(data)
1075
             function(data)
942
             {
1076
             {
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
 @stop
1197
 @stop

+ 2
- 2
app/views/local/professors/activity.blade.php View File

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

+ 194
- 20
app/views/local/professors/rubrics.blade.php View File

59
           @endforeach
59
           @endforeach
60
         </select>
60
         </select>
61
       </div>
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
       <div class="form-group">
64
       <div class="form-group">
64
         <label>Expected Criteria Outcome: </label>
65
         <label>Expected Criteria Outcome: </label>
65
         <!-- Select percentage. If there is a rubric, select the saved value -->
66
         <!-- Select percentage. If there is a rubric, select the saved value -->
85
 
86
 
86
     <table class="table">
87
     <table class="table">
87
       <thead><tr><th colspan="6 "><h3 id="rubric-name"></h3></th></tr></thead>
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
       <tbody>
90
       <tbody>
90
 
91
 
91
       </tbody>
92
       </tbody>
107
     </div>
108
     </div>
108
   </div>
109
   </div>
109
 </div>
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
 @stop
151
 @stop
111
 
152
 
112
 @section('javascript')
153
 @section('javascript')
231
 }
272
 }
232
 
273
 
233
 // Load a template
274
 // Load a template
275
+
234
 function loadTemplate()
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
       console.log($('#expected_percentage').text());
411
       console.log($('#expected_percentage').text());
252
       console.log($('#expected_points').text());
412
       console.log($('#expected_points').text());
253
 
413
 
305
     }
465
     }
306
   );
466
   );
307
 }
467
 }
308
-
468
+*/
309
 // --------------------------------------------------------------------------
469
 // --------------------------------------------------------------------------
310
 // Events
470
 // Events
311
 // --------------------------------------------------------------------------
471
 // --------------------------------------------------------------------------
329
   //Prevent page refresh
489
   //Prevent page refresh
330
   e.preventDefault();
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
   // For each criterion in the rubric, get its value and put it into an array
496
   // For each criterion in the rubric, get its value and put it into an array
336
   $('tbody tr').each(function( index )
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
       criterionObject.id = $(this).data('criterion-id');
508
       criterionObject.id = $(this).data('criterion-id');
339
       criterionObject.outcome_id = $(this).data('assoc-outcome-id');
509
       criterionObject.outcome_id = $(this).data('assoc-outcome-id');
340
       criterionObject.name = $(this).children('td:nth-child(1)').find('span').text();
510
       criterionObject.name = $(this).children('td:nth-child(1)').find('span').text();
356
       // Clone the object and push it into the array
526
       // Clone the object and push it into the array
357
       var clone = jQuery.extend({}, criterionObject);
527
       var clone = jQuery.extend({}, criterionObject);
358
       criteriaArray.push(clone);
528
       criteriaArray.push(clone);
359
-
529
+*/
360
   });
530
   });
361
 
531
 
362
   // If activity does not have a rubric, create it
532
   // If activity does not have a rubric, create it
371
       {
541
       {
372
         name: $('#select-template').find(':selected').text(),
542
         name: $('#select-template').find(':selected').text(),
373
         activity_id: parseInt($('#activity_id').val()),
543
         activity_id: parseInt($('#activity_id').val()),
374
-        contents: JSON.stringify(criteriaArray),
544
+        contents: " ",
375
         expected_percentage: $('#expected_percentage').text(),
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
       function(data)
553
       function(data)

+ 49
- 0
script.php View File

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 View File

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 View File

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 View File

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
+}