parent
commit
10627d0e72

+ 16
- 4
app/controllers/CriteriaController.php View File

66
     public function fetchObjectivesForSelect()
66
     public function fetchObjectivesForSelect()
67
     {
67
     {
68
 
68
 
69
-        $outcome = DB::select("select objectives.id, objectives.text, outcomes.name from objectives, objective_outcome, outcomes where  objective_outcome.outcome_id =? and objective_outcome.objective_id = objectives.id and objectives.active=1 and outcomes.id = objective_outcome.outcome_id", array(Input::get('id')));
70
-        //
71
-        return json_encode($outcome);
69
+        $json = array();
70
+        Log::info("GET COCKEd");
71
+        Log::info(Input::get('allOutcomes'));
72
+        foreach (Input::get('allOutcomes') as $id) {
73
+            $json['outcomes'][$id] = DB::select("select name from outcomes where id = {$id}");
74
+            $json['objectives'][$id] = DB::select("select objectives.id, objectives.text, outcomes.name from objectives, objective_outcome, outcomes where  objective_outcome.outcome_id ={$id} and objective_outcome.objective_id = objectives.id and objectives.active=1 and outcomes.id = objective_outcome.outcome_id");
75
+        }
76
+        Log::info(print_r($json, true));
77
+        return json_encode($json);
72
     }
78
     }
73
     public function fetchCriterionWithTrashed()
79
     public function fetchCriterionWithTrashed()
74
     {
80
     {
80
         $json['objectives_outcome'] = DB::select("select objectives.id, objectives.text, objective_outcome.outcome_id from objective_outcome, objectives where objective_outcome.outcome_id in(select  DISTINCT outcomes.id from outcomes , criterion_objective_outcome where criterion_objective_outcome.criterion_id = ? and outcomes.id = criterion_objective_outcome.outcome_id) and objectives.id = objective_outcome.objective_id ORDER BY outcome_id", array(Input::get('id')));
86
         $json['objectives_outcome'] = DB::select("select objectives.id, objectives.text, objective_outcome.outcome_id from objective_outcome, objectives where objective_outcome.outcome_id in(select  DISTINCT outcomes.id from outcomes , criterion_objective_outcome where criterion_objective_outcome.criterion_id = ? and outcomes.id = criterion_objective_outcome.outcome_id) and objectives.id = objective_outcome.objective_id ORDER BY outcome_id", array(Input::get('id')));
81
         $json['scales'] = DB::select("select title, description, min_score, max_score from scales, criterion_scale where criterion_scale.scale_id = scales.id and criterion_id = ?", array(Input::get('id')));
87
         $json['scales'] = DB::select("select title, description, min_score, max_score from scales, criterion_scale where criterion_scale.scale_id = scales.id and criterion_id = ?", array(Input::get('id')));
82
         $json['program'] = DB::select("select criterion_id, program_id from program_criterion where criterion_id =?", array(Input::get('id')));
88
         $json['program'] = DB::select("select criterion_id, program_id from program_criterion where criterion_id =?", array(Input::get('id')));
83
-        $json['activity_criterion'] = DB::select("select * from assessments where activity_id  in (select activity_id from activity_criterion where criterion_id = ?)", array(Input::get('id')));
89
+        $json['activity_criterion'] = DB::select("select * from new_assessments where activity_criterion_id  in (select id from activity_criterion where criterion_id = ?)", array(Input::get('id')));
90
+
91
+        foreach ($json['outcomes'] as $id) {
92
+            $outId = $id->id;
93
+            $json['outcomes_assoc'][$outId] = DB::select("select name from outcomes where id = {$outId}");
94
+            $json['objectives_assoc'][$outId] = DB::select("select objectives.id, objectives.text, outcomes.name from objectives, objective_outcome, outcomes where  objective_outcome.outcome_id ={$outId} and objective_outcome.objective_id = objectives.id and objectives.active=1 and outcomes.id = objective_outcome.outcome_id");
95
+        }
84
 
96
 
85
         return json_encode($json);
97
         return json_encode($json);
86
     }
98
     }

+ 269
- 312
app/controllers/OutcomesController.php View File

2
 
2
 
3
 use Illuminate\Database\Eloquent\Collection;
3
 use Illuminate\Database\Eloquent\Collection;
4
 
4
 
5
-class OutcomesController extends \BaseController {
5
+class OutcomesController extends \BaseController
6
+{
6
 
7
 
7
 
8
 
8
     /**
9
     /**
25
     public function newIndex()
26
     public function newIndex()
26
     {
27
     {
27
         $title = "Learning Outcomes";
28
         $title = "Learning Outcomes";
28
-//        TODO: Check when semester doesnt exist or session is empty
29
+        //        TODO: Check when semester doesnt exist or session is empty
29
         $selected_semester = Semester::find(Session::get('semesters_ids')[0]);
30
         $selected_semester = Semester::find(Session::get('semesters_ids')[0]);
30
         $outcomes = Outcome::withTrashed()->where('deactivation_date', '>=', $selected_semester->start)->orWhere('deactivation_date', null)->orderBy('name', 'ASC')->get();
31
         $outcomes = Outcome::withTrashed()->where('deactivation_date', '>=', $selected_semester->start)->orWhere('deactivation_date', null)->orderBy('name', 'ASC')->get();
31
         $schools = School::orderBy('name', 'ASC')->get();
32
         $schools = School::orderBy('name', 'ASC')->get();
35
 
36
 
36
     public function show($id)
37
     public function show($id)
37
     {
38
     {
38
-    	$outcome = Outcome::find($id);
39
+        $outcome = Outcome::find($id);
39
         $selected_semesters = Semester::find(Session::get('semesters_ids'));
40
         $selected_semesters = Semester::find(Session::get('semesters_ids'));
40
-        $programs=$outcome->programs_attempted($selected_semesters);
41
-        
42
-        $undergradResults=array("names"=>array(), "schools"=>array(), "achieved"=>array(), "attempted"=>array(), "successRate"=>array());
43
-        $gradResults=array("names"=>array(), "schools"=>array(), "achieved"=>array(), "attempted"=>array(), "successRate"=>array());
44
-        foreach($programs as $program_id)
45
-        {
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
-        
41
+        $programs = $outcome->programs_attempted($selected_semesters);
42
+
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());
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
+                $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
-           	
74
-	   	$title = "Outcome Results: ".$outcome->name;
75
-    	
76
-        
77
-//  		$undergradResults["successRate"]
78
-	
68
+
69
+        $title = "Outcome Results: " . $outcome->name;
70
+
71
+
72
+        //  		$undergradResults["successRate"]
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)
212
     {
207
     {
213
-//        DB::disableQueryLog();
214
-//        $outcome = null;
208
+        //        DB::disableQueryLog();
209
+        //        $outcome = null;
215
         if ($id === 'all') {
210
         if ($id === 'all') {
216
             $outcome = Outcome::with('objectives.criteria')->get();
211
             $outcome = Outcome::with('objectives.criteria')->get();
217
             $title = 'All Outcomes';
212
             $title = 'All Outcomes';
218
-            $criteria = $outcome->reduce(function($carry, $outcome) {
213
+            $criteria = $outcome->reduce(function ($carry, $outcome) {
219
                 return $carry->merge($outcome->criteria);
214
                 return $carry->merge($outcome->criteria);
220
             }, Collection::make([]));
215
             }, Collection::make([]));
221
             $report_link = URL::action('OutcomesController@newReportAll');
216
             $report_link = URL::action('OutcomesController@newReportAll');
226
             $report_link = URL::action('OutcomesController@newReport', ['id' => $outcome->id]);
221
             $report_link = URL::action('OutcomesController@newReport', ['id' => $outcome->id]);
227
         }
222
         }
228
 
223
 
229
-//        $objectives = $outcome->objectives;
230
-//        var_dump(get_class_methods($criteria));
231
-//        var_dump($criteria);
232
-        $rubrics = $criteria->reduce(function($carry, $crit) {
224
+        //        $objectives = $outcome->objectives;
225
+        //        var_dump(get_class_methods($criteria));
226
+        //        var_dump($criteria);
227
+        $rubrics = $criteria->reduce(function ($carry, $crit) {
233
             return $carry->merge($crit->rubrics);
228
             return $carry->merge($crit->rubrics);
234
         }, Collection::make([]))->load('activities');
229
         }, Collection::make([]))->load('activities');
235
-        $activities = $rubrics->reduce(function($carry, $rubric) {
230
+        $activities = $rubrics->reduce(function ($carry, $rubric) {
236
             return $carry->merge($rubric->activities);
231
             return $carry->merge($rubric->activities);
237
         }, Collection::make([]));
232
         }, Collection::make([]));
238
-        $courses = $activities->reduce(function($carry, $activity) {
233
+        $courses = $activities->reduce(function ($carry, $activity) {
239
             if ($activity->course !== null) {
234
             if ($activity->course !== null) {
240
                 $carry->push($activity->course);
235
                 $carry->push($activity->course);
241
             }
236
             }
242
             return $carry;
237
             return $carry;
243
         }, Collection::make([]));
238
         }, Collection::make([]));
244
-        $activities = $activities->filter(function($activity) {
239
+        $activities = $activities->filter(function ($activity) {
245
             return ($activity->course === null);
240
             return ($activity->course === null);
246
         });
241
         });
247
 
242
 
248
-//        var_dump(DB::getQueryLog());
243
+        //        var_dump(DB::getQueryLog());
249
         return View::make('local.managers.admins.new-learning-outcome', compact('title', 'outcome', 'courses', 'activities', 'report_link'));
244
         return View::make('local.managers.admins.new-learning-outcome', compact('title', 'outcome', 'courses', 'activities', 'report_link'));
250
     }
245
     }
251
 
246
 
254
         $outcome = Outcome::find($id);
249
         $outcome = Outcome::find($id);
255
         $objectives = $outcome->objectives;
250
         $objectives = $outcome->objectives;
256
         $criteria = $outcome->criteria;
251
         $criteria = $outcome->criteria;
257
-        $programs = $objectives->map(function ($objective) { return $objective->program; })
258
-            ->merge($criteria->map(function ($criteria) { return $criteria->program; }))
259
-            ->filter(function ($program) { return $program->users->contains(Auth::user()); });
252
+        $programs = $objectives->map(function ($objective) {
253
+            return $objective->program;
254
+        })
255
+            ->merge($criteria->map(function ($criteria) {
256
+                return $criteria->program;
257
+            }))
258
+            ->filter(function ($program) {
259
+                return $program->users->contains(Auth::user());
260
+            });
260
         $title = $outcome->name . ' Report';
261
         $title = $outcome->name . ' Report';
261
 
262
 
262
 
263
 
263
         return View::make('local.managers.admins.new-report', compact('title', 'outcome', 'objectives'));
264
         return View::make('local.managers.admins.new-report', compact('title', 'outcome', 'objectives'));
264
-
265
     }
265
     }
266
 
266
 
267
     public function newReportAll()
267
     public function newReportAll()
270
         $title = 'All Outcomes Report';
270
         $title = 'All Outcomes Report';
271
 
271
 
272
         return View::make('local.managers.admins.new-report-all', compact('title', 'outcomes'));
272
         return View::make('local.managers.admins.new-report-all', compact('title', 'outcomes'));
273
-
274
     }
273
     }
275
 
274
 
276
     public function update()
275
     public function update()
279
         Session::flash('status', 'success');
278
         Session::flash('status', 'success');
280
         Session::flash('message', 'Learning Outcomes updated.');
279
         Session::flash('message', 'Learning Outcomes updated.');
281
 
280
 
282
-        foreach ($outcomeArray as $outcomeObject)
283
-        {
281
+        foreach ($outcomeArray as $outcomeObject) {
284
 
282
 
285
 
283
 
286
             $validator = Validator::make(
284
             $validator = Validator::make(
296
                 )
294
                 )
297
             );
295
             );
298
 
296
 
299
-            if(!$validator->fails())
300
-            {
301
-                try
302
-                {
297
+            if (!$validator->fails()) {
298
+                try {
303
                     $outcome = Outcome::withTrashed()
299
                     $outcome = Outcome::withTrashed()
304
-                        ->where('id','=', $outcomeObject['id'])
300
+                        ->where('id', '=', $outcomeObject['id'])
305
                         ->firstOrFail();
301
                         ->firstOrFail();
306
                     $outcome->name = $outcomeObject['name'];
302
                     $outcome->name = $outcomeObject['name'];
307
                     $outcome->definition = $outcomeObject['definition'];
303
                     $outcome->definition = $outcomeObject['definition'];
309
                     $outcome->save();
305
                     $outcome->save();
310
 
306
 
311
                     // If delete is 1, and outcome isn't already trashed, delete
307
                     // If delete is 1, and outcome isn't already trashed, delete
312
-                    if($outcomeObject['delete']==1 && !$outcome->trashed())
308
+                    if ($outcomeObject['delete'] == 1 && !$outcome->trashed())
313
                         $outcome->delete();
309
                         $outcome->delete();
314
                     // If delete is 0, and outcome is already trashed, restore
310
                     // If delete is 0, and outcome is already trashed, restore
315
-                    elseif($outcomeObject['delete']==0 && $outcome->trashed())
311
+                    elseif ($outcomeObject['delete'] == 0 && $outcome->trashed())
316
                         $outcome->restore();
312
                         $outcome->restore();
317
-                }
318
-
319
-                catch(Exception $e)
320
-                {
313
+                } catch (Exception $e) {
321
 
314
 
322
                     Session::flash('message', $e->getMessage());
315
                     Session::flash('message', $e->getMessage());
323
                 }
316
                 }
324
-            }
325
-            else
326
-            {
317
+            } else {
327
                 /** Prepare error message */
318
                 /** Prepare error message */
328
                 $message = 'Error(s) updating the Learning Outcomes: <ul>';
319
                 $message = 'Error(s) updating the Learning Outcomes: <ul>';
329
 
320
 
330
-                foreach ($validator->messages()->all('<li>:message</li>') as $validationError)
331
-                {
332
-                    $message.=$validationError;
321
+                foreach ($validator->messages()->all('<li>:message</li>') as $validationError) {
322
+                    $message .= $validationError;
333
                 }
323
                 }
334
 
324
 
335
-                $message.='</ul>';
325
+                $message .= '</ul>';
336
 
326
 
337
                 /** Send error message and old data */
327
                 /** Send error message and old data */
338
                 Session::flash('status', 'danger');
328
                 Session::flash('status', 'danger');
345
     }
335
     }
346
 
336
 
347
     /**
337
     /**
348
-    *Copy of update(), but also updates activation_date, deactivation_date and level
349
-    */
338
+     *Copy of update(), but also updates activation_date, deactivation_date and level
339
+     */
350
     public function updateMore()
340
     public function updateMore()
351
     {
341
     {
352
         $outcomeArray = json_decode(Input::get('outcomeArray'), true);
342
         $outcomeArray = json_decode(Input::get('outcomeArray'), true);
353
         Session::flash('status', 'success');
343
         Session::flash('status', 'success');
354
         Session::flash('message', 'Learning Outcomes updated.');
344
         Session::flash('message', 'Learning Outcomes updated.');
355
 
345
 
356
-        foreach ($outcomeArray as $outcomeObject)
357
-        {
346
+        foreach ($outcomeArray as $outcomeObject) {
358
 
347
 
359
 
348
 
360
             $validator = Validator::make(
349
             $validator = Validator::make(
372
                 )
361
                 )
373
             );
362
             );
374
 
363
 
375
-            if(!$validator->fails())
376
-            {
377
-                try
378
-                {
364
+            if (!$validator->fails()) {
365
+                try {
379
                     $outcome = Outcome::withTrashed()
366
                     $outcome = Outcome::withTrashed()
380
-                        ->where('id','=', $outcomeObject['id'])
367
+                        ->where('id', '=', $outcomeObject['id'])
381
                         ->firstOrFail();
368
                         ->firstOrFail();
382
                     $outcome->name = $outcomeObject['name'];
369
                     $outcome->name = $outcomeObject['name'];
383
                     $outcome->definition = $outcomeObject['definition'];
370
                     $outcome->definition = $outcomeObject['definition'];
388
                     $outcome->save();
375
                     $outcome->save();
389
 
376
 
390
                     // If delete is 1, and outcome isn't already trashed, delete
377
                     // If delete is 1, and outcome isn't already trashed, delete
391
-                    if($outcomeObject['delete']==1 && !$outcome->trashed())
378
+                    if ($outcomeObject['delete'] == 1 && !$outcome->trashed())
392
                         $outcome->delete();
379
                         $outcome->delete();
393
                     // If delete is 0, and outcome is already trashed, restore
380
                     // If delete is 0, and outcome is already trashed, restore
394
-                    elseif($outcomeObject['delete']==0 && $outcome->trashed())
381
+                    elseif ($outcomeObject['delete'] == 0 && $outcome->trashed())
395
                         $outcome->restore();
382
                         $outcome->restore();
396
-                }
397
-
398
-                catch(Exception $e)
399
-                {
383
+                } catch (Exception $e) {
400
 
384
 
401
                     Session::flash('message', $e->getMessage());
385
                     Session::flash('message', $e->getMessage());
402
                 }
386
                 }
403
-            }
404
-            else
405
-            {
387
+            } else {
406
                 /** Prepare error message */
388
                 /** Prepare error message */
407
                 $message = 'Error(s) updating the Learning Outcomes: <ul>';
389
                 $message = 'Error(s) updating the Learning Outcomes: <ul>';
408
 
390
 
409
-                foreach ($validator->messages()->all('<li>:message</li>') as $validationError)
410
-                {
411
-                    $message.=$validationError;
391
+                foreach ($validator->messages()->all('<li>:message</li>') as $validationError) {
392
+                    $message .= $validationError;
412
                 }
393
                 }
413
 
394
 
414
-                $message.='</ul>';
395
+                $message .= '</ul>';
415
 
396
 
416
                 /** Send error message and old data */
397
                 /** Send error message and old data */
417
                 Session::flash('status', 'danger');
398
                 Session::flash('status', 'danger');
426
     public function fetchCriteria()
407
     public function fetchCriteria()
427
     {
408
     {
428
 
409
 
429
-        if(Input::get('filter'))
430
-        {
431
-            switch (Input::get('filter'))
432
-            {
410
+        if (Input::get('filter')) {
411
+            switch (Input::get('filter')) {
433
                 case 'all':
412
                 case 'all':
434
                     return Outcome::find(Input::get('id'))->criteria;
413
                     return Outcome::find(Input::get('id'))->criteria;
435
                     break;
414
                     break;
436
 
415
 
437
                 case 'school':
416
                 case 'school':
438
                     // If scoord
417
                     // If scoord
439
-                    if(Auth::user()->role == '2')
440
-                    {
418
+                    if (Auth::user()->role == '2') {
441
 
419
 
442
                         // Fetch all the programs whose school is the user's
420
                         // Fetch all the programs whose school is the user's
443
                         $program_ids = DB::table('programs')->where('school_id', Auth::user()->school_id)->lists('id');
421
                         $program_ids = DB::table('programs')->where('school_id', Auth::user()->school_id)->lists('id');
444
 
422
 
445
                         // Return all criteria belonging to any of those programs
423
                         // Return all criteria belonging to any of those programs
446
-                        return Criterion::
447
-                            where('outcome_id', Input::get('id'))
424
+                        return Criterion::where('outcome_id', Input::get('id'))
448
                             ->whereIn('program_id', $program_ids)
425
                             ->whereIn('program_id', $program_ids)
449
                             ->orderBy('name', 'ASC')
426
                             ->orderBy('name', 'ASC')
450
                             ->get();
427
                             ->get();
451
-
452
                     }
428
                     }
453
 
429
 
454
                     // If pcoord
430
                     // If pcoord
455
-                    else
456
-                    {
431
+                    else {
457
 
432
 
458
                         // Fetch all the programs from the user's school;
433
                         // Fetch all the programs from the user's school;
459
                         $program_ids = DB::table('programs')->where('school_id', Auth::user()->programs[0]->school->id)->lists('id');
434
                         $program_ids = DB::table('programs')->where('school_id', Auth::user()->programs[0]->school->id)->lists('id');
460
 
435
 
461
-                        return Criterion::
462
-                            where('outcome_id', Input::get('id'))
436
+                        return Criterion::where('outcome_id', Input::get('id'))
463
                             ->whereIn('program_id', $program_ids)
437
                             ->whereIn('program_id', $program_ids)
464
                             ->orderBy('name', 'ASC')
438
                             ->orderBy('name', 'ASC')
465
                             ->get();
439
                             ->get();
468
                     break;
442
                     break;
469
 
443
 
470
                 case 'program':
444
                 case 'program':
471
-                    return Criterion::
472
-                        where('outcome_id', Input::get('id'))
445
+                    return Criterion::where('outcome_id', Input::get('id'))
473
                         ->whereIn('program_id', Auth::user()->programs->lists('id'))
446
                         ->whereIn('program_id', Auth::user()->programs->lists('id'))
474
                         ->orderBy('name', 'ASC')
447
                         ->orderBy('name', 'ASC')
475
                         ->get();
448
                         ->get();
479
                     return Outcome::find(Input::get('id'))->criteria;
452
                     return Outcome::find(Input::get('id'))->criteria;
480
                     break;
453
                     break;
481
             }
454
             }
482
-        }
483
-        else
484
-        {
455
+        } else {
485
             return Outcome::find(Input::get('id'))->criteria;
456
             return Outcome::find(Input::get('id'))->criteria;
486
         }
457
         }
487
     }
458
     }
504
         );
475
         );
505
 
476
 
506
         /** If validation fails */
477
         /** If validation fails */
507
-        if ($validator->fails())
508
-        {
478
+        if ($validator->fails()) {
509
             /** Prepare error message */
479
             /** Prepare error message */
510
             $message = '<p>Error(s) creating a new Learning Outcome</p><ul>';
480
             $message = '<p>Error(s) creating a new Learning Outcome</p><ul>';
511
 
481
 
512
-            foreach ($validator->messages()->all('<li>:message</li>') as $validationError)
513
-            {
514
-                $message.=$validationError;
482
+            foreach ($validator->messages()->all('<li>:message</li>') as $validationError) {
483
+                $message .= $validationError;
515
             }
484
             }
516
 
485
 
517
-            $message.='</ul>';
486
+            $message .= '</ul>';
518
 
487
 
519
             /** Send error message and old data */
488
             /** Send error message and old data */
520
             Session::flash('status', 'warning');
489
             Session::flash('status', 'warning');
521
             Session::flash('message', $message);
490
             Session::flash('message', $message);
522
             return Redirect::to('learning-outcomes')->withInput();
491
             return Redirect::to('learning-outcomes')->withInput();
523
-        }
524
-        else
525
-        {
492
+        } else {
526
             /** Instantiate new outcome */
493
             /** Instantiate new outcome */
527
             $outcome = new Outcome;
494
             $outcome = new Outcome;
528
-            $outcome->name= Input::get('name');
495
+            $outcome->name = Input::get('name');
529
             $outcome->definition = Input::get('definition');
496
             $outcome->definition = Input::get('definition');
530
 
497
 
531
             /** If outcome is saved, send success message */
498
             /** If outcome is saved, send success message */
532
-            if($outcome->save())
533
-            {
499
+            if ($outcome->save()) {
534
                 Session::flash('status', 'success');
500
                 Session::flash('status', 'success');
535
                 Session::flash('message', '<p>Learning Outcome added.</p>');
501
                 Session::flash('message', '<p>Learning Outcome added.</p>');
536
                 return Redirect::to('learning-outcomes');
502
                 return Redirect::to('learning-outcomes');
537
             }
503
             }
538
 
504
 
539
             /** If saving fails, send error message and old data */
505
             /** If saving fails, send error message and old data */
540
-            else
541
-            {
506
+            else {
542
                 Session::flash('status', 'warning');
507
                 Session::flash('status', 'warning');
543
                 Session::flash('message', '<p>Error adding Learning Outcome. Please try again later.</p>');
508
                 Session::flash('message', '<p>Error adding Learning Outcome. Please try again later.</p>');
544
                 return Redirect::to('learning-outcomes')->withInput();
509
                 return Redirect::to('learning-outcomes')->withInput();
554
 
519
 
555
         $outcome->criteria;
520
         $outcome->criteria;
556
 
521
 
557
-        return array
558
-        (
522
+        return array(
559
             'outcome' => $outcome
523
             'outcome' => $outcome
560
         );
524
         );
561
     }
525
     }
582
                 App::abort('404');
546
                 App::abort('404');
583
                 break;
547
                 break;
584
         }
548
         }
585
-
586
     }
549
     }
587
 
550
 
588
     /**
551
     /**
592
     {
555
     {
593
         $outcome = Outcome::find($outcome_id);
556
         $outcome = Outcome::find($outcome_id);
594
 
557
 
595
-        if(!$outcome)
558
+        if (!$outcome)
596
             App::abort('404');
559
             App::abort('404');
597
-        $title = "Assessment Report: ".$outcome->name;
560
+        $title = "Assessment Report: " . $outcome->name;
598
 
561
 
599
 
562
 
600
-        $schools = School::
601
-            has('courses')
602
-            ->with(array('programs'=>function($query) use($outcome_id){
563
+        $schools = School::has('courses')
564
+            ->with(array('programs' => function ($query) use ($outcome_id) {
603
                 $query
565
                 $query
604
-                ->has('courses')
605
-                ->with(array('courses'=>function($query2) use($outcome_id){
606
-                    $query2
607
-                    ->has('activities')
608
-                    ->whereNotNull('outcomes_attempted')
609
-                    // ->where('outcomes_attempted', 'NOT LIKE', '%"'.$outcome_id.'":0%')
610
-                    ->whereIn('semester_id', Session::get('semesters_ids'))
611
-                    ->groupBy(array('code', 'number'));
612
-                }));
566
+                    ->has('courses')
567
+                    ->with(array('courses' => function ($query2) use ($outcome_id) {
568
+                        $query2
569
+                            ->has('activities')
570
+                            ->whereNotNull('outcomes_attempted')
571
+                            // ->where('outcomes_attempted', 'NOT LIKE', '%"'.$outcome_id.'":0%')
572
+                            ->whereIn('semester_id', Session::get('semesters_ids'))
573
+                            ->groupBy(array('code', 'number'));
574
+                    }));
613
             }))
575
             }))
614
-         ->get();
576
+            ->get();
615
 
577
 
616
         return View::make('local.managers.admins.assessment_report', compact('title', 'outcome', 'schools'));
578
         return View::make('local.managers.admins.assessment_report', compact('title', 'outcome', 'schools'));
617
     }
579
     }
621
     {
583
     {
622
         $outcome = Outcome::find($outcome_id);
584
         $outcome = Outcome::find($outcome_id);
623
 
585
 
624
-        if(!$outcome)
586
+        if (!$outcome)
625
             App::abort('404');
587
             App::abort('404');
626
-        $title = "Assessment Report: ".$outcome->name;
588
+        $title = "Assessment Report: " . $outcome->name;
627
 
589
 
628
-        $schools = School::
629
-        has('courses')
630
-            ->with(array('programs'=>function($query) use($outcome_id){
590
+        $schools = School::has('courses')
591
+            ->with(array('programs' => function ($query) use ($outcome_id) {
631
                 $query
592
                 $query
632
                     ->has('courses')
593
                     ->has('courses')
633
-                    ->with(array('courses'=>function($query2) use($outcome_id){
594
+                    ->with(array('courses' => function ($query2) use ($outcome_id) {
634
                         $query2
595
                         $query2
635
                             ->has('activities')
596
                             ->has('activities')
636
                             ->whereNotNull('outcomes_attempted')
597
                             ->whereNotNull('outcomes_attempted')
651
     {
612
     {
652
         $outcome = Outcome::find($outcome_id);
613
         $outcome = Outcome::find($outcome_id);
653
 
614
 
654
-        if(!$outcome)
615
+        if (!$outcome)
655
             App::abort('404');
616
             App::abort('404');
656
-        $title = "Assessment Report: ".$outcome->name;
617
+        $title = "Assessment Report: " . $outcome->name;
657
 
618
 
658
 
619
 
659
-        $school = School::
660
-            where('id', Auth::user()->school_id)
661
-            ->has('courses')
662
-            ->with(array('programs'=>function($query){
663
-            $query
620
+        $school = School::where('id', Auth::user()->school_id)
664
             ->has('courses')
621
             ->has('courses')
665
-            ->with(array('courses'=>function($query2){
666
-                $query2
667
-                ->has('activities')
668
-                ->whereNotNull('outcomes_attempted')
669
-                ->whereIn('semester_id', Session::get('semesters_ids'))
670
-                ->groupBy(array('code', 'number'));
671
-            }));
672
-         }))
673
-         ->first();
622
+            ->with(array('programs' => function ($query) {
623
+                $query
624
+                    ->has('courses')
625
+                    ->with(array('courses' => function ($query2) {
626
+                        $query2
627
+                            ->has('activities')
628
+                            ->whereNotNull('outcomes_attempted')
629
+                            ->whereIn('semester_id', Session::get('semesters_ids'))
630
+                            ->groupBy(array('code', 'number'));
631
+                    }));
632
+            }))
633
+            ->first();
674
 
634
 
675
         return View::make('local.managers.sCoords.assessment_report', compact('title', 'outcome', 'school'));
635
         return View::make('local.managers.sCoords.assessment_report', compact('title', 'outcome', 'school'));
676
     }
636
     }
682
     {
642
     {
683
         $outcome = Outcome::find($outcome_id);
643
         $outcome = Outcome::find($outcome_id);
684
 
644
 
685
-        if(!$outcome)
645
+        if (!$outcome)
686
             App::abort('404');
646
             App::abort('404');
687
-        $title = "Assessment Report: ".$outcome->name;
647
+        $title = "Assessment Report: " . $outcome->name;
688
 
648
 
689
 
649
 
690
-        $program = Program::
691
-            where('id', $program_id)
650
+        $program = Program::where('id', $program_id)
692
             ->has('courses')
651
             ->has('courses')
693
-            ->with(array('courses'=>function($query){
652
+            ->with(array('courses' => function ($query) {
694
                 $query
653
                 $query
695
-                ->has('activities')
696
-                ->whereNotNull('outcomes_attempted')
697
-                ->whereIn('semester_id', Session::get('semesters_ids'))
698
-                ->groupBy(array('code', 'number'));
654
+                    ->has('activities')
655
+                    ->whereNotNull('outcomes_attempted')
656
+                    ->whereIn('semester_id', Session::get('semesters_ids'))
657
+                    ->groupBy(array('code', 'number'));
699
             }))
658
             }))
700
             ->first();
659
             ->first();
701
 
660
 
709
         $title = "My Courses' Assessment Reports";
668
         $title = "My Courses' Assessment Reports";
710
 
669
 
711
         return View::make('local.professors.assessment_reports', compact('title', 'outcomes'));
670
         return View::make('local.professors.assessment_reports', compact('title', 'outcomes'));
712
-
713
     }
671
     }
714
 
672
 
715
 
673
 
718
     {
676
     {
719
         $outcome = Outcome::find($outcome_id);
677
         $outcome = Outcome::find($outcome_id);
720
 
678
 
721
-        if(!$outcome)
679
+        if (!$outcome)
722
             App::abort('404');
680
             App::abort('404');
723
-        $title = "My Courses' Assessment Report: ".$outcome->name;
681
+        $title = "My Courses' Assessment Report: " . $outcome->name;
724
 
682
 
725
 
683
 
726
-        $courses = Course::
727
-            where('user_id', Auth::user()->id)
684
+        $courses = Course::where('user_id', Auth::user()->id)
728
             ->has('activities')
685
             ->has('activities')
729
             ->whereNotNull('outcomes_attempted')
686
             ->whereNotNull('outcomes_attempted')
730
             ->whereIn('semester_id', Session::get('semesters_ids'))
687
             ->whereIn('semester_id', Session::get('semesters_ids'))

+ 45
- 0
app/controllers/UsersController.php View File

16
 			->orderBy('surnames')
16
 			->orderBy('surnames')
17
 			->orderBy('first_name')
17
 			->orderBy('first_name')
18
 			->get();
18
 			->get();
19
+		Log::info('LmaOOOOO get cocked');
20
+
19
 
21
 
20
 		$schools = School::orderBy('name', 'asc')->get();
22
 		$schools = School::orderBy('name', 'asc')->get();
21
 		$access_level  = count(User::select('role')->where('has_access', 1)->groupBy('role')->get());
23
 		$access_level  = count(User::select('role')->where('has_access', 1)->groupBy('role')->get());
24
+		try {
25
+			Log::info("Schools");
26
+			foreach ($schools as $school) {
27
+				Log::info(print_r($school, true));
28
+			}
29
+			foreach ($users as $user) {
30
+				Log::info("ID");
31
+				Log::info($user->id);
32
+				Log::info("Name");
33
+				Log::info($user->surname . $user->first_name);
34
+				Log::info("if funciona??");
35
+				Log::info($user->school_id);
36
+				Log::info("elseif??");
37
+				Log::info(count($user->programs));
38
+				if ($user->school_id) {
39
+					Log::info("Schoool");
40
+					Log::info($user->school->name);
41
+					Log::info($user->school_id);
42
+				} elseif (count($user->programs) > 0) {
43
+					Log::info("Entre aqui");
44
+					Log::info($user->programs[0]->school_id);
45
+					Log::info($user->programs[0]->school->name);
46
+				} else Log::info("Not so cocked");
47
+
48
+				Log::info("bueno vamos a ver que hay???");
49
+				Log::info(count($user->programs));
50
+				if (count($user->programs)) {
51
+					foreach ($user->programs as $program) {
52
+						Log::info($program->id);
53
+						Log::info($program->name);
54
+					}
55
+				} else Log::info("Tal vez cocked");
56
+				Log::info("email");
57
+				Log::info($user->email);
58
+				Log::info("Role" . $user->role);
59
+				Log::info($user->office_phone);
60
+				Log::info($user->cell_phone);
61
+			}
62
+		} catch (Exception $e) {
63
+			Log::info("get Cocked" . $e);
64
+		}
65
+		Log::info("el error era en la base de datos XDDDDDDD");
66
+
22
 
67
 
23
 		return View::make('local.managers.admins.users', compact('title', 'users', 'schools', 'access_level'));
68
 		return View::make('local.managers.admins.users', compact('title', 'users', 'schools', 'access_level'));
24
 	}
69
 	}

+ 39
- 0
app/database/migrations/2021_02_16_142747_create_cycles_table.php View File

1
+<?php
2
+
3
+use Illuminate\Database\Schema\Blueprint;
4
+use Illuminate\Database\Migrations\Migration;
5
+
6
+class CreateCyclesTable extends Migration {
7
+
8
+	/**
9
+	 * Run the migrations.
10
+	 *
11
+	 * @return void
12
+	 */
13
+	 public function up()
14
+ 	{
15
+ 		Schema::create('cycles', function(Blueprint $table)
16
+ 		{
17
+			// 		id unico
18
+ 			$table->increments('id');
19
+			// 		cuando a~nos tiene el ciclo('3')
20
+			$table->integer('years_in_cycle');
21
+			// 		cuando comienza el ciclo ('2019')
22
+			$table->integer('start');
23
+			// 		cuando termina  el ciclo ('2022')
24
+			$table->integer('end');
25
+ 			$table->timestamps();
26
+ 		});
27
+ 	}
28
+
29
+ 	/**
30
+ 	 * Reverse the migrations.
31
+ 	 *
32
+ 	 * @return void
33
+ 	 */
34
+ 	public function down()
35
+ 	{
36
+ 		Schema::drop('cycles');
37
+ 	}
38
+
39
+}

+ 50
- 0
app/database/migrations/2021_02_16_142832_create_cycles_semesters_table.php View File

1
+<?php
2
+
3
+use Illuminate\Database\Schema\Blueprint;
4
+use Illuminate\Database\Migrations\Migration;
5
+
6
+class CreateCyclesSemestersTable extends Migration {
7
+
8
+	/**
9
+	 * Run the migrations.
10
+	 *
11
+	 * @return void
12
+	 */
13
+	public function up()
14
+	{
15
+		Schema::create('cycles_semesters', function(Blueprint $table)
16
+		{
17
+			// id unico
18
+			$table->increments('id');
19
+			// id del ciclo que pertenece
20
+			$table->integer('cycle_id')->unsigned();
21
+			// semestre n
22
+			$table->integer('semester_id')->unsigned();
23
+			$table
24
+				->foreign('cycle_id')
25
+				->references('id')
26
+				->on('cycles')
27
+				->onDelete('cascade')
28
+				->onUpdate('cascade');
29
+			$table
30
+				->foreign('semester_id')
31
+				->references('id')
32
+				->on('semesters')
33
+				->onDelete('cascade')
34
+				->onUpdate('cascade');
35
+			$table->timestamps();
36
+		});
37
+	}
38
+
39
+	/**
40
+	 * Reverse the migrations.
41
+	 *
42
+	 * @return void
43
+	 */
44
+	public function down()
45
+	{
46
+		//
47
+		Schema::drop('cycles_semesters');
48
+	}
49
+
50
+}

+ 4
- 4
app/routes.php View File

226
 
226
 
227
     // Show users all learning outcomes and criteria
227
     // Show users all learning outcomes and criteria
228
     Route::get('learning-outcomes-criteria', 'CriteriaController@index');
228
     Route::get('learning-outcomes-criteria', 'CriteriaController@index');
229
-    Route::post('fetchOutcome', array('before' => 'csrf', 'uses'=>'OutcomesController@fetchOutcome'));
229
+    Route::post('fetchOutcome', array('before' => 'csrf', 'uses' => 'OutcomesController@fetchOutcome'));
230
     // Show users all objectives and criteria
230
     // Show users all objectives and criteria
231
     Route::get('learning-objectives-criteria', 'CriteriaController@objectivesIndex');
231
     Route::get('learning-objectives-criteria', 'CriteriaController@objectivesIndex');
232
-    Route::post('fetchObjectiveForCriteria', array('before' => 'csrf', 'uses'=>'ObjectivesController@fetchObjectiveForCriteria'));
232
+    Route::post('fetchObjectiveForCriteria', array('before' => 'csrf', 'uses' => 'ObjectivesController@fetchObjectiveForCriteria'));
233
 
233
 
234
     // Show professor overview to users with courses
234
     // Show professor overview to users with courses
235
     Route::get('professor', 'ProfessorsController@overview');
235
     Route::get('professor', 'ProfessorsController@overview');
259
         Route::post('learning-outcomes/update', array('before' => 'csrf', 'uses' => 'OutcomesController@updateMore'));
259
         Route::post('learning-outcomes/update', array('before' => 'csrf', 'uses' => 'OutcomesController@updateMore'));
260
         Route::post('learning-outcomes/update', array('before' => 'csrf', 'uses' => 'OutcomesController@update'));
260
         Route::post('learning-outcomes/update', array('before' => 'csrf', 'uses' => 'OutcomesController@update'));
261
         Route::post('learning-outcomes/update', array('before' => 'csrf', 'uses' => 'OutcomesController@updateMore'));
261
         Route::post('learning-outcomes/update', array('before' => 'csrf', 'uses' => 'OutcomesController@updateMore'));
262
-        Route::post('crtiteria/update', array('before' => 'csrf', 'uses'=>'CriteriaController@update'));
263
-        Route::delete('crtiteria/delete', array('before' => 'csrf', 'uses'=>'CriteriaController@destroy'));
262
+        Route::post('crtiteria/update', array('before' => 'csrf', 'uses' => 'CriteriaController@update'));
263
+        Route::delete('crtiteria/delete', array('before' => 'csrf', 'uses' => 'CriteriaController@destroy'));
264
 
264
 
265
         Route::get('administrator/users/{query?}', 'UsersController@index');
265
         Route::get('administrator/users/{query?}', 'UsersController@index');
266
 
266
 

+ 179
- 116
app/views/local/managers/admins/criteria.blade.php View File

14
             </div>
14
             </div>
15
             <div class="panel-body">
15
             <div class="panel-body">
16
                 {{ Form::open(array('action' => 'CriteriaController@create')) }}
16
                 {{ Form::open(array('action' => 'CriteriaController@create')) }}
17
-                <div id='outcomeGroup'>
17
+                <div id='outcomeGroup' data-value="1">
18
                     <div class="form-group col-md-11">
18
                     <div class="form-group col-md-11">
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("outcomeGroup", "objectiveGroup")']) }}
22
 
22
 
23
                     </div>
23
                     </div>
24
                 </div>
24
                 </div>
29
                     </span>
29
                     </span>
30
                     Add another Outcome
30
                     Add another Outcome
31
                 </button>
31
                 </button>
32
-                <div id='objectiveGroup'>
32
+                <div id='objectiveGroup' data-value = '1'>
33
                     <div class="form-group">
33
                     <div class="form-group">
34
                         <label>Associated Objectives</label>
34
                         <label>Associated Objectives</label>
35
                         <select id="objective_0" name="objective[]" class="form-control selectpicker">
35
                         <select id="objective_0" name="objective[]" class="form-control selectpicker">
141
                 </div>
141
                 </div>
142
 
142
 
143
                 <!-- Associated Outcome -->
143
                 <!-- Associated Outcome -->
144
-                <div id='assocOutcomeGroup'>
144
+                <div id='assocOutcomeGroup' data-value="1">
145
                     <div class="form-group">
145
                     <div class="form-group">
146
                         <label>Associated Outcome</label>
146
                         <label>Associated Outcome</label>
147
                         {{ Form::select('assoc_outcome[]', $outcomes, null, ['class'=>'form-control selectpicker', 'id'=>'assoc_outcome_0', 'onchange'=>'fetchAssocObjective("assoc_outcome_0")']) }}
147
                         {{ Form::select('assoc_outcome[]', $outcomes, null, ['class'=>'form-control selectpicker', 'id'=>'assoc_outcome_0', 'onchange'=>'fetchAssocObjective("assoc_outcome_0")']) }}
155
                     Add another Outcome
155
                     Add another Outcome
156
                 </button>
156
                 </button>
157
 
157
 
158
-                <div id='assoc_objectiveGroup'>
158
+                <div id='assoc_objectiveGroup' data-value ='1'>
159
                     <div class="form-group">
159
                     <div class="form-group">
160
                         <label>Associated Objectives</label>
160
                         <label>Associated Objectives</label>
161
                         <select id="assoc_objective_0" name="assoc_objective[]" class="form-control selectpicker">
161
                         <select id="assoc_objective_0" name="assoc_objective[]" class="form-control selectpicker">
162
+                            <option value="0">No associated objectives</option>
162
                         </select>
163
                         </select>
163
 
164
 
164
                     </div>
165
                     </div>
387
 
388
 
388
     //Add outcome Button
389
     //Add outcome Button
389
     function addOutcomeTest() {
390
     function addOutcomeTest() {
391
+        counter = parseInt($('#outcomeGroup').data("value"));
390
         var $select = $('<select/>', {
392
         var $select = $('<select/>', {
391
             'class': "selectpicker form-control",
393
             'class': "selectpicker form-control",
392
             'name': "outcome[]",
394
             'name': "outcome[]",
393
             'data-live-search': 'true',
395
             'data-live-search': 'true',
394
             'id': 'outcome' + counter.toString(),
396
             'id': 'outcome' + counter.toString(),
395
-            'onchange': 'fetchObjectiveForSelect("outcome' + counter.toString() + '")'
397
+            'onchange': 'fetchObjectiveForSelect("outcomeGroup", "objectiveGroup")'
396
 
398
 
397
         });
399
         });
398
         var $div = $('<div/>', {
400
         var $div = $('<div/>', {
408
         var $button = $('<button/>', {
410
         var $button = $('<button/>', {
409
             'type': 'button',
411
             'type': 'button',
410
             'class': 'btn btn-primary',
412
             'class': 'btn btn-primary',
411
-            'onclick': 'deleteLast("outcomeForm' + counter.toString() + '", "' + outcomeString + (counter).toString() + '", "close' + counter.toString() + '","objective_")'
413
+            'onclick': 'deleteLast("outcomeForm'+counter.toString()+'", "outcomeGroup", "close' + counter.toString() + '", "objectiveGroup")'
412
         });
414
         });
413
 
415
 
414
         $button.append('X');
416
         $button.append('X');
418
         $select.append(selectOptions);
420
         $select.append(selectOptions);
419
 
421
 
420
         $select.appendTo('#outcomeForm' + counter.toString()).selectpicker('refresh');
422
         $select.appendTo('#outcomeForm' + counter.toString()).selectpicker('refresh');
421
-        fetchObjectiveForSelect('outcome' + counter.toString());
422
-        counter += 1;
423
+        
424
+        $('#outcomeGroup').data("value", counter +1);
425
+        fetchObjectiveForSelect('outcomeGroup', "objectiveGroup");
426
+        
423
         $divForButton.appendTo('#outcomeGroup');
427
         $divForButton.appendTo('#outcomeGroup');
424
 
428
 
425
-        $('#counterOutcome').val(counter)
429
+       
426
 
430
 
427
 
431
 
428
     }
432
     }
431
 
435
 
432
     //Delete Outcome and OptGroup associated
436
     //Delete Outcome and OptGroup associated
433
 
437
 
434
-    function deleteLast(outcomeForm, outcomeOptGroup, closeButton, objective) {
435
-        $div = document.getElementById(outcomeForm);
438
+    function deleteLast(outcomeForm, outcomeDiv, closeButton, objectiveGroup) {
439
+        $div = document.getElementById(outcomeForm );
436
         $div.remove();
440
         $div.remove();
437
-        $div = document.getElementById(outcomeOptGroup);
438
-        $div.remove();
439
-        $div = document.getElementById(closeButton)
441
+        $div = document.getElementById(closeButton);
440
         $div.remove();
442
         $div.remove();
443
+        if(outcomeDiv =='outcomeGroup'){
444
+        $('#' + outcomeDiv).data('value',parseInt($('#' + outcomeDiv).data('value')) - 1);
445
+        fetchObjectiveForSelect(outcomeDiv, objectiveGroup);}
446
+        
447
+
441
 
448
 
442
-        for (var i = 0; i < counterObj; i++) {
443
 
449
 
444
 
450
 
445
-            $('#' + objective + i.toString()).selectpicker('refresh');
446
-        }
447
 
451
 
448
     }
452
     }
449
     //Delete Objective
453
     //Delete Objective
450
-    function deleteObjective(objectiveForm, closeObj) {
454
+    function deleteObjective(objectiveForm, closeObj, objectiveGroup) {
451
         $div = document.getElementById(objectiveForm);
455
         $div = document.getElementById(objectiveForm);
452
         $div.remove();
456
         $div.remove();
453
         $div = document.getElementById(closeObj);
457
         $div = document.getElementById(closeObj);
454
         $div.remove();
458
         $div.remove();
459
+        counter = parseInt($('#'+objectiveGroup).data("value"));
460
+        $('#'+objectiveGroup).data("value", counter-1);
455
 
461
 
456
 
462
 
457
     }
463
     }
460
 
466
 
461
     function addAssocObjective() {
467
     function addAssocObjective() {
462
         selectObj = document.getElementById('assoc_objective_0').innerHTML;
468
         selectObj = document.getElementById('assoc_objective_0').innerHTML;
469
+        assocObjectiveCounter = parseInt($('#assoc_objectiveGroup').data('value'));
463
         var $select = $('<select/>', {
470
         var $select = $('<select/>', {
464
             'class': "selectpicker form-control",
471
             'class': "selectpicker form-control",
465
             'name': "assoc_objective[]",
472
             'name': "assoc_objective[]",
480
         var $button = $('<button/>', {
487
         var $button = $('<button/>', {
481
             'type': 'button',
488
             'type': 'button',
482
             'class': 'btn btn-primary',
489
             'class': 'btn btn-primary',
483
-            'onclick': 'deleteObjective("assoc_objectiveForm' + assocObjectiveCounter.toString() + '", "assoc_closeObj' + assocObjectiveCounter.toString() + '")'
490
+            'onclick': 'deleteObjective("assoc_objectiveForm' + assocObjectiveCounter.toString() + '", "assoc_closeObj' + assocObjectiveCounter.toString() + ', assoc_objectiveGroup")'
484
         });
491
         });
485
 
492
 
486
         $button.append('X');
493
         $button.append('X');
490
         $select.append(selectObj);
497
         $select.append(selectObj);
491
 
498
 
492
         $select.appendTo('#assoc_objectiveForm' + assocObjectiveCounter.toString()).selectpicker('refresh');
499
         $select.appendTo('#assoc_objectiveForm' + assocObjectiveCounter.toString()).selectpicker('refresh');
493
-        counterObj += 1;
500
+        $('#assoc_objectiveGroup').data("value", assocObjectiveCounter +1);
494
 
501
 
495
         $divForButton.appendTo('#assoc_objectiveGroup');
502
         $divForButton.appendTo('#assoc_objectiveGroup');
496
 
503
 
500
     //Add objective when creating a criteria
507
     //Add objective when creating a criteria
501
     function addObjectiveTest() {
508
     function addObjectiveTest() {
502
         selectObj = document.getElementById('objective_0').innerHTML;
509
         selectObj = document.getElementById('objective_0').innerHTML;
510
+        counter = $("#objectiveGroup").data('value');
511
+        $('#objectiveGroup')
503
         var $select = $('<select/>', {
512
         var $select = $('<select/>', {
504
             'class': "selectpicker form-control",
513
             'class': "selectpicker form-control",
505
             'name': "objective[]",
514
             'name': "objective[]",
506
             'data-live-search': 'true',
515
             'data-live-search': 'true',
507
-            'id': 'objective_' + counterObj.toString()
516
+            'id': 'objective_' + counter.toString()
508
 
517
 
509
         });
518
         });
510
         var $div = $('<div/>', {
519
         var $div = $('<div/>', {
511
-            'id': 'objectiveForm' + counterObj.toString(),
520
+            'id': 'objectiveForm' + counter.toString(),
512
             'class': 'form-group col-md-11'
521
             'class': 'form-group col-md-11'
513
         });
522
         });
514
         var $divForButton = $('<div/>', {
523
         var $divForButton = $('<div/>', {
515
             'class': 'col-md-1',
524
             'class': 'col-md-1',
516
-            'id': 'closeObj' + counterObj.toString()
525
+            'id': 'closeObj' + counter.toString()
517
 
526
 
518
         });
527
         });
519
         var $button = $('<button/>', {
528
         var $button = $('<button/>', {
520
             'type': 'button',
529
             'type': 'button',
521
             'class': 'btn btn-primary',
530
             'class': 'btn btn-primary',
522
-            'onclick': 'deleteObjective("objectiveForm' + counterObj.toString() + '", "closeObj' + counterObj.toString() + '")'
531
+            'onclick': 'deleteObjective("objectiveForm' + counter.toString() + '", "closeObj' + counter.toString() + '","objectiveGroup")'
523
         });
532
         });
524
 
533
 
525
         $button.append('X');
534
         $button.append('X');
528
         $div.appendTo('#objectiveGroup')
537
         $div.appendTo('#objectiveGroup')
529
         $select.append(selectObj);
538
         $select.append(selectObj);
530
 
539
 
531
-        $select.appendTo('#objectiveForm' + counterObj.toString()).selectpicker('refresh');
532
-        counterObj += 1;
533
-
540
+        $select.appendTo('#objectiveForm' + counter.toString()).selectpicker('refresh');
541
+        
534
         $divForButton.appendTo('#objectiveGroup');
542
         $divForButton.appendTo('#objectiveGroup');
535
-        $('#counterObjective').val(counterObj)
543
+        $('#objectiveGroup').data('value', counter +1);
536
     }
544
     }
537
 
545
 
538
     //Create outcome for editing
546
     //Create outcome for editing
541
 
549
 
542
 
550
 
543
     function addAssocOutcome() {
551
     function addAssocOutcome() {
552
+        assocOutcomeCounter = parseInt($('#assocOutcomeGroup').data('value'));
544
         var $select = $('<select/>', {
553
         var $select = $('<select/>', {
545
             'class': "selectpicker form-control",
554
             'class': "selectpicker form-control",
546
             'name': "assoc_outcome[]",
555
             'name': "assoc_outcome[]",
562
         var $button = $('<button/>', {
571
         var $button = $('<button/>', {
563
             'type': 'button',
572
             'type': 'button',
564
             'class': 'btn btn-primary',
573
             'class': 'btn btn-primary',
565
-            'onclick': 'deleteLast("assoc_outcomeForm' + assocOutcomeCounter.toString() + '", "' + 'Associated_Outcome' + (assocOutcomeCounter).toString() + '", "assoc_close' + assocOutcomeCounter.toString() + '","assoc_objective_")'
574
+            'onclick': 'deleteLast("assoc_outcomeForm' + assocOutcomeCounter.toString() + '", "assocOutcomeGroup", "assoc_close' + assocOutcomeCounter.toString() + '","assoc_objectiveGroup")'
566
         });
575
         });
567
 
576
 
568
         $button.append('X');
577
         $button.append('X');
572
         $select.append(selectOptions);
581
         $select.append(selectOptions);
573
 
582
 
574
         $select.appendTo('#assoc_outcomeForm' + assocOutcomeCounter.toString()).selectpicker('refresh');
583
         $select.appendTo('#assoc_outcomeForm' + assocOutcomeCounter.toString()).selectpicker('refresh');
575
-        //fetchAssocObjective('assoc_outcome_' + assocOutcomeCounter.toString());
584
+        
576
         assocOutcomeCounter += 1;
585
         assocOutcomeCounter += 1;
586
+        $('#assocOutcomeGroup').data('value', assocOutcomeCounter);
587
+
577
         $divForButton.appendTo('#assocOutcomeGroup');
588
         $divForButton.appendTo('#assocOutcomeGroup');
578
 
589
 
579
 
590
 
585
 
596
 
586
     var assocObjectiveCounter = 1;
597
     var assocObjectiveCounter = 1;
587
 
598
 
588
-    function fetchAssocObjective(outcomeId) {
589
-        var id = $('#' + outcomeId).find(':selected').val();
599
+    function fetchAssocObjective(outcomeDiv, objectiveGroup) {
600
+        var count = $('#'+outcomeDiv).data('value');
601
+        var allOutcomes =[];
602
+
603
+         $("#" + outcomeDiv + ' select').each(function() {
604
+            allOutcomes.push( this.value);
605
+
606
+        })
607
+        var allObjectives = [];
608
+        $("#" + objectiveGroup + ' select').each(function() {
609
+            var temp = {
610
+                id: this.id,
611
+                value: this.value
612
+            }
613
+            allObjectives.push(temp);
614
+        })
590
 
615
 
591
 
616
 
592
         $.post(
617
         $.post(
593
             "{{ URL::action('CriteriaController@fetchObjectivesForSelect') }}", {
618
             "{{ URL::action('CriteriaController@fetchObjectivesForSelect') }}", {
594
-                id: id
619
+                allOutcomes: allOutcomes
595
             },
620
             },
596
 
621
 
597
             function(json) {
622
             function(json) {
598
 
623
 
599
-                var optionName = '<optgroup id="' + 'Associated_Outcome' + (assocOutcomeCounter - 1).toString() + '"label="' + 'Associated Outcome' + (assocOutcomeCounter).toString() + '"';
600
-                for (var i = 0; i < json.length; i++) {
601
-                    var option = '<option value ="' + json[i].id.toString() + '">' + json[i].text + '</option>'
602
-                    optionName += (option)
603
-
604
-                }
605
-                optGroup = document.getElementById('Associated_Outcome' + (assocOutcomeCounter - 1).toString());
606
-                if (optGroup != null) {
607
-                    optGroup.remove()
608
-
624
+                optionName = '';
625
+                for(outcome in varArray.outcomes){
626
+                    optionName += '<optgroup label="' + varArray.outcomes[outcome][0].name + '"';
627
+                    var objectiveForOutcome = varArray.objectives;
628
+                    var objectives = objectiveForOutcome[outcome];
629
+                    for (objective in objectives) {
630
+                
631
+
632
+                        var obj= objectives[objective];
633
+                        var option = '<option value ="' + obj.id + '">' +obj.text + '</option>';
634
+                        optionName += (option);
635
+                    }
609
                 }
636
                 }
610
 
637
 
611
 
638
 
612
-                $('#assoc_objective_0').append(optionName);
639
+                $('#assoc_objective_0').html(optionName);
613
                 $('#assoc_objective_0').selectpicker('refresh');
640
                 $('#assoc_objective_0').selectpicker('refresh');
641
+                if($("#assoc_objective_0 option[value='"+allObjectives[0].value+"']").length>0){
642
+                    $("#assoc_objective_0").val(allObjectives[0].value);
643
+                    $('#assoc_objective_0').selectpicker('refresh');
644
+                }
614
 
645
 
615
-                for (var i = assocObjectiveCounter - 1; i > 0; i--) {
616
-                    deleteObjective('assoc_objectiveForm' + i.toString(), 'assoc_closeObj' + i.toString())
646
+                for (var i = allObjectives.length - 1; i > 0; i--) {
647
+                    deleteObjective('assoc_objectiveForm' + i.toString(), 'assoc_closeObj' + i.toString(), 'assoc_objectiveGroup');
648
+                }
649
+                for(var i=1; i<allObjectives.length; i++){
650
+                    addAssocObjective();
651
+                    $('#assoc_objective_'+i.toString()).selectpicker('refresh');
652
+                    if($("#assoc_objective_"+i.toString()+" option[value='"+allObjectives[i].value+"']").length>0){
653
+                    $("#assoc_objective_"+i.toString()).val(allObjectives[i].value);
654
+                    $("#assoc_objective_"+i.toString()).selectpicker("refresh");
655
+                    }
617
                 }
656
                 }
618
-                assocObjectiveCounter = 1;
619
 
657
 
620
 
658
 
621
 
659
 
627
     //Fetch objective at creating criteria
665
     //Fetch objective at creating criteria
628
     counterForPost = 0;
666
     counterForPost = 0;
629
 
667
 
630
-    function fetchObjectiveForSelect(outcomeInput) {
631
-
632
-
633
-        var id = $('#' + outcomeInput).find(':selected').val();
668
+    function fetchObjectiveForSelect(outcomeDiv, objectiveGroup) {
669
+        var count = $("#" + outcomeDiv).data('value');
670
+        var allOutcomes = [];
671
+        $("#" + outcomeDiv + ' select').each(function() {
672
+            allOutcomes.push( this.value);
673
+
674
+        })
675
+        var allObjectives = [];
676
+        $("#" + objectiveGroup + ' select').each(function() {
677
+            var temp = {
678
+                id: this.id,
679
+                value: this.value
680
+            }
681
+            allObjectives.push(temp);
682
+        })
634
 
683
 
635
         $.post(
684
         $.post(
636
             "{{ URL::action('CriteriaController@fetchObjectivesForSelect') }}", {
685
             "{{ URL::action('CriteriaController@fetchObjectivesForSelect') }}", {
637
-                id: id
686
+                allOutcomes: allOutcomes
638
             },
687
             },
639
             function(varArray) {
688
             function(varArray) {
640
-
641
-                var optionName = '<optgroup id="' + outcomeString + (counter - 1).toString() + '"label="' + varArray[0].name + '"';
642
-                for (var i = 0; i < varArray.length; i++) {
643
-                    var option = '<option value ="' + varArray[i].id.toString() + '">' + varArray[i].text + '</option>'
644
-                    optionName += (option)
645
-
646
-                }
647
-                optGroup = document.getElementById(outcomeString + (counter - 1).toString());
648
-                if (optGroup != null) {
649
-                    optGroup.remove()
650
-
689
+                counterOutcome =0;
690
+                optionName = '';
691
+                for(outcome in varArray.outcomes){
692
+                    optionName += '<optgroup label="' + varArray.outcomes[outcome][0].name + '"';
693
+                    var objectiveForOutcome = varArray.objectives;
694
+                    var objectives = objectiveForOutcome[outcome];
695
+                    for (objective in varArray.objectives[outcome]) {
696
+                
697
+
698
+                        var obj= objectives[objective];
699
+                        var option = '<option value ="' + obj.id + '">' +obj.text + '</option>';
700
+                        optionName += (option);
701
+                    }
651
                 }
702
                 }
703
+                
652
 
704
 
705
+                
653
 
706
 
654
-                $('#objective_0').append(optionName);
707
+                $('#objective_0').html(optionName);
655
                 $('#objective_0').selectpicker('refresh');
708
                 $('#objective_0').selectpicker('refresh');
709
+                if($("#objective_0 option[value='"+allObjectives[0].value+"']").length>0){
710
+                    $("#objective_0").val(allObjectives[0].value);
711
+                    $('#objective_0').selectpicker('refresh');
712
+                }
713
+                
656
 
714
 
657
-                for (var i = counterObj - 1; i > 0; i--) {
658
-                    deleteObjective('objectiveForm' + i.toString(), 'closeObj' + i.toString())
715
+                for (var i = allObjectives.length - 1; i > 0; i--) {
716
+                    deleteObjective('objectiveForm' + i.toString(), 'closeObj' + i.toString(), 'objectiveGroup');
717
+                }
718
+                for(var i =1; i<allObjectives.length; i++){
719
+                    addObjectiveTest();
720
+                    $('#objective_'+i.toString()).selectpicker('refresh');
721
+                    if($("#objective_"+i.toString()+" option[value='"+allObjectives[i].value+"']").length>0){
722
+                    $("#objective_"+i.toString()).val(allObjectives[i].value);
723
+                    $("#objective_"+i.toString()).selectpicker("refresh");
659
                 }
724
                 }
660
-                counterObj = 1;
725
+                }
726
+
727
+                
661
 
728
 
662
 
729
 
663
 
730
 
719
 
786
 
720
                 if (!(json.activity_criterion.length)) {
787
                 if (!(json.activity_criterion.length)) {
721
 
788
 
722
-                    $('#DeleteButton').prop('enabled', true);
789
+                    $('#DeleteButton').prop('disabled', true);
723
 
790
 
724
                 } else {
791
                 } else {
725
-                    $('#DeleteButton').prop('disabled', true);
792
+                    $('#DeleteButton').prop('enabled', true);
726
                 }
793
                 }
727
 
794
 
728
                 if (!(json.criteria.length)) {
795
                 if (!(json.criteria.length)) {
739
                     var name = json.criteria[0].name;
806
                     var name = json.criteria[0].name;
740
                     if (json.criteria[0].subcriteria) {
807
                     if (json.criteria[0].subcriteria) {
741
                         subcriteria = JSON.parse(json.criteria[0].subcriteria).join('\n');
808
                         subcriteria = JSON.parse(json.criteria[0].subcriteria).join('\n');
809
+                    } else {
810
+                        subcriteria = "";
811
+                    }
812
+                    if (json.criteria[0].copyright) {
813
+                        var copyright = json.criteria[0].copyright;
814
+                    } else {
815
+                        var copyright = ''
742
                     }
816
                     }
743
-                    var copyright = json.criteria[0].copyright;
744
-                    var notes = json.criteria[0].notes;
817
+                    if (json.criteria[0].notes) notes = json.criteria[0].notes;
818
+                    else notes = '';
745
 
819
 
746
                     // Display info
820
                     // Display info
747
                     $('#criterion_name').val(name);
821
                     $('#criterion_name').val(name);
758
                 }
832
                 }
759
 
833
 
760
 
834
 
761
-                if (copyright) {
762
-                    $('#criterion_copyright').text(copyright);
763
-                } else {
764
-                    $('#criterion_copyright').text('');
765
-                }
766
-                if (notes) {
767
-                    $('#criterion_notes').text(notes);
768
-                } else {
769
-                    $('#criterion_notes').text('');
770
-                }
835
+
836
+                $('#criterion_copyright').text(copyright);
837
+
838
+
839
+                $('#criterion_notes').text(notes);
840
+
771
 
841
 
772
 
842
 
773
 
843
 
776
 
846
 
777
                 // Select associated outcome
847
                 // Select associated outcome
778
                 try {
848
                 try {
849
+                    assocOutcomeCounter= parseInt($("#assocOutcomeGroup").data('value'));
779
                     for (var i = assocOutcomeCounter - 1; i > 0; i--) {
850
                     for (var i = assocOutcomeCounter - 1; i > 0; i--) {
780
-                        deleteLast("assoc_outcomeForm" + (i).toString(), 'Associated_Outcome' + (i).toString(), "assoc_close" + (i).toString(), "assoc_objective_");
851
+                        deleteLast("assoc_outcomeForm" + i.toString() , "assocOutcomeGroup", "assoc_close" + i.toString() ,"assoc_objectiveGroup");
781
                     }
852
                     }
782
                 } catch (err) {
853
                 } catch (err) {
783
                     var Notran = true;
854
                     var Notran = true;
802
 
873
 
803
 
874
 
804
 
875
 
876
+                counterObj =$('#assoc_objectiveGroup').data('value');
877
+                
805
 
878
 
806
                 try {
879
                 try {
807
                     for (var i = counterObj - 1; i > 0; i--) {
880
                     for (var i = counterObj - 1; i > 0; i--) {
808
-                        deleteObjective('objectiveForm' + i.toString(), 'closeObj' + i.toString())
881
+                        deleteObjective('assoc_objectiveForm' + i.toString(), 'assoc_closeObj' + i.toString(), 'assoc_objectiveGroup')
809
                     }
882
                     }
810
                 } catch (err) {
883
                 } catch (err) {
811
                     var noEntro = true;
884
                     var noEntro = true;
812
                 }
885
                 }
813
-                counterObj = 1;
886
+                $('#assoc_objectiveGroup').data('value', 1);
814
 
887
 
815
 
888
 
816
 
889
 
818
 
891
 
819
                 assocOutcomeCounter = 0;
892
                 assocOutcomeCounter = 0;
820
                 var i = 0;
893
                 var i = 0;
821
-                for (var j = 0; j < json.outcomes.length; j++) {
822
-                    assocOutcomeCounter += 1;
823
-                    var optionName = '<optgroup id="' + 'Associated_Outcome' + (assocOutcomeCounter - 1).toString() + '"label="' + json.outcomes[j].name + '"';
824
-                    for (; i < json.objectives_outcome.length; i++) {
825
-                        if (json.objectives_outcome[i].outcome_id != json.outcomes[j].id) break;
826
-
827
-                        var option = '<option value ="' + json.objectives_outcome[i].id.toString() + '">' + json.objectives_outcome[i].text + '</option>'
828
-                        optionName += (option)
829
-
894
+                optionName = '';
895
+                for(outcome in json.outcomes_assoc){
896
+                    optionName += '<optgroup label="' + json.outcomes_assoc[outcome][0].name + '"';
897
+                    var objectiveForOutcome = json.objectives_assoc;
898
+                    var objectives = objectiveForOutcome[outcome];
899
+                    for (objective in objectives) {
900
+                
901
+
902
+                        var obj= objectives[objective];
903
+                        var option = '<option value ="' + obj.id + '">' +obj.text + '</option>';
904
+                        optionName += (option);
830
                     }
905
                     }
831
-                    optGroup = document.getElementById('Associated_Outcome' + (assocOutcomeCounter - 1).toString());
832
-                    if (optGroup != null) {
833
-                        optGroup.remove()
834
-
835
-                    }
836
-                    $('#assoc_objective_0').append(optionName);
837
-                    $('#assoc_objective_0').selectpicker('refresh');
838
-                }
839
-
840
-
841
-
842
-
843
-                for (var i = assocObjectiveCounter - 1; i > 0; i--) {
844
-                    deleteObjective('assoc_objectiveForm' + i.toString(), 'assoc_closeObj' + i.toString())
845
                 }
906
                 }
846
-                assocObjectiveCounter = 1;
847
 
907
 
848
 
908
 
909
+                $('#assoc_objective_0').html(optionName);
910
+                $('#assoc_objective_0').selectpicker('refresh');
911
+                
849
 
912
 
850
 
913
 
851
 
914
 
857
                         $('#assoc_objective_0').val(0);
920
                         $('#assoc_objective_0').val(0);
858
                         $('#assoc_objective_0').selectpicker('refresh');
921
                         $('#assoc_objective_0').selectpicker('refresh');
859
                     }
922
                     }
860
-                    var thereIsNoObjective = true;
923
+                 
861
                 }
924
                 }
862
 
925
 
863
                 for (var i = 1; i < json.objectives.length; i++) {
926
                 for (var i = 1; i < json.objectives.length; i++) {
865
                     $('#assoc_objective_' + i.toString()).val(json.objectives[i].id);
928
                     $('#assoc_objective_' + i.toString()).val(json.objectives[i].id);
866
                     $('#assoc_objective_' + i.toString()).selectpicker('refresh');
929
                     $('#assoc_objective_' + i.toString()).selectpicker('refresh');
867
                 }
930
                 }
868
-                assocObjectiveCounter = json.objectives.length;
931
+                $('assoc_objectiveGroup').data('value',json.objectives.length);
869
 
932
 
870
 
933
 
871
 
934
 
964
 $('#outcome-display').parent().hide();
1027
 $('#outcome-display').parent().hide();
965
 
1028
 
966
 fetchCriterionForEditing();
1029
 fetchCriterionForEditing();
967
-fetchObjectiveForSelect('outcome0');
1030
+fetchObjectiveForSelect('outcomeGroup', 'objectiveGroup');
968
 // setCriterionStatus();
1031
 // setCriterionStatus();
969
 
1032
 
970
 
1033
 
1014
 $(this).next().stop().slideToggle();
1077
 $(this).next().stop().slideToggle();
1015
 })
1078
 })
1016
 
1079
 
1017
-$('#outcome[0]').on('change', function(){
1018
-fetchObjectiveForSelect(0);
1019
-$('.selectpicker').selectpicker('refresh');
1020
-})
1080
+//$('#outcome[0]').on('change', function(){
1081
+//fetchObjectiveForSelect(0);
1082
+//$('.selectpicker').selectpicker('refresh');
1083
+//})
1021
 // When list item is clicked, load corresponding info
1084
 // When list item is clicked, load corresponding info
1022
 
1085
 
1023
 
1086
 

+ 1044
- 0
app/views/local/managers/admins/new_criteria.blade.php
File diff suppressed because it is too large
View File


+ 471
- 471
app/views/local/managers/admins/overview.blade.php
File diff suppressed because it is too large
View File


+ 4
- 7
app/views/local/managers/shared/program.blade.php View File

263
 }
263
 }
264
 },
264
 },
265
 tooltip: {
265
 tooltip: {
266
-headerFormat: '<span style="font-size:10px">{point.key}</span>
267
-<table>',
268
-    pointFormat: '<tr>
269
-        <td style="color:{series.color};padding : 0">{series.name}: </td>' +
270
-        '<td style="padding:0"><b>{point.y:.2f}</b></td>
271
-    </tr>',
266
+headerFormat: '<span style="font-size:10px">{point.key}</span><table>',
267
+    pointFormat: '<tr><td style="color:{series.color};padding : 0">{series.name}: </td>' +
268
+        '<td style="padding:0"><b>{point.y:.2f}</b></td></tr>',
272
     footerFormat: '</table>',
269
     footerFormat: '</table>',
273
 shared: true,
270
 shared: true,
274
 useHTML: true
271
 useHTML: true
343
 // Include dummy graph for outcomes
340
 // Include dummy graph for outcomes
344
 @include('global.dummy-outcomes')
341
 @include('global.dummy-outcomes')
345
 
342
 
346
-@stop
343
+@stop