Browse Source

Merge remote-tracking branch 'origin/gabriel_branch' into merge-oniel-gabriel

onielm 3 years ago
parent
commit
76bec8df4f
58 changed files with 7168 additions and 1384 deletions
  1. BIN
      Documentacion.docx
  2. 6
    5
      app/config/app.php
  3. 6
    5
      app/config/database.php
  4. 171
    261
      app/controllers/ActivitiesController.php
  5. 393
    136
      app/controllers/CriteriaController.php
  6. 437
    0
      app/controllers/Objective2Controller.php
  7. 86
    0
      app/controllers/Objective_OutcomeController.php
  8. 49
    75
      app/controllers/RubricsController.php
  9. 315
    358
      app/controllers/UsersController.php
  10. 47
    0
      app/database/migrations/2020_10_04_142756_create_new_assessments_table.php
  11. 52
    0
      app/database/migrations/2020_10_05_124915_create_activity_criterion_table.php
  12. 35
    0
      app/database/migrations/2020_10_05_130252_add_max_score_num_scales_new_criteria_table.php
  13. 35
    0
      app/database/migrations/2020_10_05_142424_create_scales_table.php
  14. 47
    0
      app/database/migrations/2020_10_05_142912_create_criterion_scale_table.php
  15. 34
    0
      app/database/migrations/2020_10_05_232429_add_assessment_comments_to_activity_criterion.php
  16. 36
    0
      app/database/migrations/2020_10_09_131800_add_level_activation_date_to_outcomes.php
  17. 53
    0
      app/database/migrations/2020_10_16_190923_create_criterion_objective_outcome_table.php
  18. 57
    0
      app/database/migrations/2020_10_18_145108_create_outcome_performance_table.php
  19. 30
    0
      app/database/migrations/2020_10_29_122332_MakeOutcomeNullable.php
  20. 30
    0
      app/database/migrations/2020_10_29_195413_MakeObjectiveNullable.php
  21. 30
    0
      app/database/migrations/2020_10_29_224846_Make_criterion_objective_outcome_changeForeignKey.php
  22. 35
    0
      app/database/migrations/2020_11_06_011242_changeCriteriaObjOutcome.php
  23. 35
    0
      app/database/migrations/2020_12_04_111708_dropDescriptionInCriteria.php
  24. 44
    0
      app/database/migrations/2020_12_10_175517_createProgramCriterion2.php
  25. 34
    0
      app/database/migrations/2020_12_10_223135_addMinMaxInScales.php
  26. 30
    0
      app/database/migrations/emails/feedback-email-copy.blade.php
  27. 9
    11
      app/database/unusedMigrations/2018_08_28_140328_remove_outcome_id_from_objectives_table.php
  28. 0
    0
      app/database/unusedMigrations/2020_04_04_005817_add_outcome_id_to_objectives_table.php
  29. 52
    0
      app/database/unusedMigrations/2020_10_05_124915_create_activity_criterion_table.php
  30. 35
    0
      app/database/unusedMigrations/2020_10_05_130252_add_max_score_num_scales_new_criteria_table.php
  31. 35
    0
      app/database/unusedMigrations/2020_10_05_142424_create_scales_table.php
  32. 47
    0
      app/database/unusedMigrations/2020_10_05_142912_create_criterion_scale_table.php
  33. 34
    0
      app/database/unusedMigrations/2020_10_05_232429_add_assessment_comments_to_activity_criterion.php
  34. 36
    0
      app/database/unusedMigrations/2020_10_08_203557_create_new_criteria_table2.php
  35. 33
    0
      app/database/unusedMigrations/2020_10_08_215013_drop_objective_id_new_criteria.php
  36. 34
    0
      app/database/unusedMigrations/2020_10_09_085334_add_activities_rubric_id.php
  37. 35
    0
      app/database/unusedMigrations/2020_10_09_092810_drop_assessment_criteria.php
  38. 35
    0
      app/database/unusedMigrations/2020_10_09_094503_add_criterion_to_assessment.php
  39. 29
    0
      app/database/unusedMigrations/2020_10_09_095246_drop_foreign_assesment_criterion.php
  40. 36
    0
      app/database/unusedMigrations/2020_10_09_131800_add_level_activation_date_to_outcomes.php
  41. 28
    53
      app/filters.php
  42. 29
    26
      app/models/Objective.php
  43. 38
    0
      app/models/Objective_Outcome.php
  44. 0
    7
      app/models/Outcome.php
  45. 17
    0
      app/models/Scale.php
  46. 13
    12
      app/models/User.php
  47. 125
    118
      app/routes.php
  48. 20
    18
      app/views/local/managers/admins/_navigation.blade.php
  49. 977
    268
      app/views/local/managers/admins/criteria.blade.php
  50. 420
    0
      app/views/local/managers/admins/objectives.blade.php
  51. 16
    15
      app/views/local/managers/pCoords/_navigation.blade.php
  52. 1023
    0
      app/views/local/managers/pCoords/criteria.blade.php
  53. 419
    0
      app/views/local/managers/pCoords/objectives.blade.php
  54. 15
    15
      app/views/local/managers/sCoords/_navigation.blade.php
  55. 1029
    0
      app/views/local/managers/sCoords/criteria.blade.php
  56. 420
    0
      app/views/local/managers/sCoords/objectives.blade.php
  57. 1
    1
      bootstrap/start.php
  58. 1
    0
      public/.htaccess

BIN
Documentacion.docx View File


+ 6
- 5
app/config/app.php View File

@@ -13,8 +13,9 @@ return array(
13 13
 	|
14 14
 	*/
15 15
 
16
-	'debug' => $_ENV['APP_DEBUG'] ?: false,
16
+	//'debug' => $_ENV['APP_DEBUG'] ?: false,
17 17
 
18
+	'debug' => true,
18 19
 	/*
19 20
 	|--------------------------------------------------------------------------
20 21
 	| Application URL
@@ -24,9 +25,9 @@ return array(
24 25
 	| the Artisan command line tool. You should set this to the root of
25 26
 	| your application so that it is used when running Artisan tasks.
26 27
 	|
27
-	*/
28
+	*/ //$_ENV['APP_URL'] ?:
28 29
 
29
-	'url' => $_ENV['APP_URL'] ?: 'http://localhost',
30
+	'url' =>  'https://localhost',
30 31
 
31 32
 	/*
32 33
 	|--------------------------------------------------------------------------
@@ -139,7 +140,7 @@ return array(
139 140
 	|
140 141
 	*/
141 142
 
142
-	'manifest' => storage_path().'/meta',
143
+	'manifest' => storage_path() . '/meta',
143 144
 
144 145
 	/*
145 146
 	|--------------------------------------------------------------------------
@@ -193,7 +194,7 @@ return array(
193 194
 		'Validator'         => 'Illuminate\Support\Facades\Validator',
194 195
 		'View'              => 'Illuminate\Support\Facades\View',
195 196
 		'PDF'				=> 'Barryvdh\DomPDF\Facade',
196
-        'Entrust' => 'Zizaco\Entrust\EntrustFacade'
197
+		'Entrust' => 'Zizaco\Entrust\EntrustFacade'
197 198
 
198 199
 
199 200
 	),

+ 6
- 5
app/config/database.php View File

@@ -47,15 +47,16 @@ return array(
47 47
 	'connections' => array(
48 48
 
49 49
 		'mysql' => array(
50
+
50 51
 			'driver'    => 'mysql',
51
-			'host'      => $_ENV['MYSQL_HOST'] ?: 'localhost',
52
-			'database'  => $_ENV['MYSQL_DATABASE'] ?: 'laravel',
53
-			'username'  => $_ENV['MYSQL_USERNAME'] ?: 'root',
54
-			'password'  => $_ENV['MYSQL_PASSWORD'] ?: '',
52
+			'host'      =>  '127.0.0.1',
53
+			'database'  =>  'trabajoolas5',
54
+			'username'  =>  'root',
55
+			'password'  =>  '',
55 56
 			'charset'   => 'utf8',
56 57
 			'collation' => 'utf8_unicode_ci',
57 58
 			'prefix'    => '',
58
-            'engine'    => 'InnoDB',
59
+			'engine'    => 'InnoDB',
59 60
 		),
60 61
 	),
61 62
 

+ 171
- 261
app/controllers/ActivitiesController.php View File

@@ -2,7 +2,8 @@
2 2
 
3 3
 use Illuminate\Database\Eloquent\Collection;
4 4
 
5
-class ActivitiesController extends \BaseController {
5
+class ActivitiesController extends \BaseController
6
+{
6 7
 
7 8
     /**
8 9
      * Save a new activity
@@ -13,55 +14,51 @@ class ActivitiesController extends \BaseController {
13 14
     public function create($id)
14 15
     {
15 16
         /** Validation rules */
17
+
16 18
         $validator = Validator::make(
17 19
             array(
18 20
                 'name' => Input::get('name'),
19 21
                 'description' => Input::get('description')
20 22
             ),
21 23
             array(
22
-                'name' => 'required|unique:activities,course_id,'.$id,
24
+                'name' => 'required|unique:activities,course_id,' . $id,
23 25
                 'description' => 'required|min:10'
24 26
             )
25 27
         );
26 28
 
29
+
27 30
         /** If validation fails */
28
-        if ($validator->fails())
29
-        {
31
+        if ($validator->fails()) {
30 32
             /** Prepare error message */
31 33
             $message = 'Error(s) creating a new Activity<ul>';
32 34
 
33
-            foreach ($validator->messages()->all('<li>:message</li>') as $validationError)
34
-            {
35
-                $message.=$validationError;
35
+            foreach ($validator->messages()->all('<li>:message</li>') as $validationError) {
36
+                $message .= $validationError;
36 37
             }
37 38
 
38
-            $message.='</ul>';
39
+            $message .= '</ul>';
39 40
 
40 41
             /** Send error message and old data */
41 42
             Session::flash('status', 'danger');
42 43
             Session::flash('message', $message);
43 44
             return Redirect::back()->withInput();
44
-        }
45
-        else
46
-        {
45
+        } else {
47 46
             /** Instantiate new activity */
48 47
             $activity = new Activity;
49
-            $activity->name= Input::get('name');
48
+            $activity->name = Input::get('name');
50 49
             $activity->description = Input::get('description');
51 50
             $activity->course_id = $id;
52 51
             $activity->date = date('Y-m-d');
53 52
 
54 53
             /** If activity is saved, send success message */
55
-            if($activity->save())
56
-            {
54
+            if ($activity->save()) {
57 55
                 Session::flash('status', 'success');
58 56
                 Session::flash('message', 'Activity created.');
59 57
                 return Redirect::action('ActivitiesController@show', array($activity->id));
60 58
             }
61 59
 
62 60
             /** If saving fails, send error message and old data */
63
-            else
64
-            {
61
+            else {
65 62
                 Session::flash('status', 'warning');
66 63
                 Session::flash('message', 'Error adding Activity. Please try again later.');
67 64
                 return Redirect::back()->withInput();
@@ -76,24 +73,25 @@ class ActivitiesController extends \BaseController {
76 73
         $instruments = Rubric::all();
77 74
         $courses = Course::where('user_id', Auth::user()->id)->get();
78 75
         $outcomes = Outcome::with('objectives')->get();
79
-//        var_dump($outcomes[0]->objectives);
76
+        //        var_dump($outcomes[0]->objectives);
80 77
         $objectives_by_outcome = Collection::make([]);
81
-        $outcomes->each(function($outcome) use (&$objectives_by_outcome) {
82
-//            var_dump($outcome->objectives);
78
+        $outcomes->each(function ($outcome) use (&$objectives_by_outcome) {
79
+            //            var_dump($outcome->objectives);
83 80
             $objectives_by_outcome->put($outcome->id, $outcome->objectives);
84
-//            var_dump($objectives);
81
+            //            var_dump($objectives);
85 82
         });
86 83
         $criteria_by_objective = Collection::make([]);
87
-        $objectives_by_outcome->each(function($objectives) use (&$criteria_by_objective) {
88
-            $objectives->each(function($objective) use (&$criteria_by_objective) {
84
+        $objectives_by_outcome->each(function ($objectives) use (&$criteria_by_objective) {
85
+            $objectives->each(function ($objective) use (&$criteria_by_objective) {
89 86
                 $criteria_by_objective->put($objective->id, $objective->criteria);
90 87
             });
91 88
         });
92 89
         $transforming_actions = [];
93 90
         $course = Course::find($course_id);
94
-//        var_dump($criteria_by_objective);
95
-//        return $objectives->toJson();
96
-        return View::make('local.managers.admins.new-activity-create',
91
+        //        var_dump($criteria_by_objective);
92
+        //        return $objectives->toJson();
93
+        return View::make(
94
+            'local.managers.admins.new-activity-create',
97 95
             compact(
98 96
                 'title',
99 97
                 'course',
@@ -116,7 +114,7 @@ class ActivitiesController extends \BaseController {
116 114
         $activity = Activity::find($id);
117 115
 
118 116
         // If activity does not exist, display 404
119
-        if(!$activity)
117
+        if (!$activity)
120 118
             App::abort('404');
121 119
 
122 120
         // Get activity's course
@@ -127,16 +125,14 @@ class ActivitiesController extends \BaseController {
127 125
             App::abort('403', 'Access Forbidden');
128 126
 
129 127
         // Get active semesters
130
-        $active_semesters= array();
128
+        $active_semesters = array();
131 129
         $active_semesters_collection = Semester::select('id')->where('is_visible', 1)->where('start', '<=', date('Y-m-d H:i:s'))->where('end', '>=', date('Y-m-d H:i:s'))->get();
132
-        foreach ($active_semesters_collection as $active_semester)
133
-        {
134
-            $active_semesters[]=$active_semester->id;
130
+        foreach ($active_semesters_collection as $active_semester) {
131
+            $active_semesters[] = $active_semester->id;
135 132
         }
136
-            // Added the function htmlspecialchars to activity name string because it was corrupting Jquery code while using quotes on page rendering. - Carlos R Caraballo 1/18/2019
137
-        $title = $course->code.$course->number.'-'.$course->section.': '.htmlspecialchars($activity->name, ENT_QUOTES).' <span class="small attention">('.$course->semester->code.')</span>';
138
-        //$outcomes = Outcome::orderBy('name', 'asc')->get();
139
-        $outcomes = Outcome::active();
133
+        // Added the function htmlspecialchars to activity name string because it was corrupting Jquery code while using quotes on page rendering. - Carlos R Caraballo 1/18/2019
134
+        $title = $course->code . $course->number . '-' . $course->section . ': ' . htmlspecialchars($activity->name, ENT_QUOTES) . ' <span class="small attention">(' . $course->semester->code . ')</span>';
135
+        $outcomes = Outcome::orderBy('name', 'asc')->get();
140 136
         $outcomes_achieved = json_decode($activity->outcomes_achieved, true);
141 137
         $outcomes_attempted = json_decode($activity->outcomes_attempted, true);
142 138
 
@@ -149,7 +145,7 @@ class ActivitiesController extends \BaseController {
149 145
         $activity = Activity::find($id);
150 146
 
151 147
         // If activity does not exist, display 404
152
-        if(!$activity)
148
+        if (!$activity)
153 149
             App::abort('404');
154 150
 
155 151
         // Get activity's course
@@ -167,12 +163,11 @@ class ActivitiesController extends \BaseController {
167 163
         $rubric_contents = json_decode($rubric->contents);
168 164
 
169 165
         // Get results
170
-        $assessments = DB::table('assessments')->join('students', 'assessments.student_id','=','students.id')->where('activity_id', '=', $activity->id)->orderBy('assessments.id', 'asc')->get();
166
+        $assessments = DB::table('assessments')->join('students', 'assessments.student_id', '=', 'students.id')->where('activity_id', '=', $activity->id)->orderBy('assessments.id', 'asc')->get();
171 167
 
172 168
         // Decode the scores (blade workaround)
173 169
         $scores_array = array();
174
-        foreach ($assessments as $index=>$assessment)
175
-        {
170
+        foreach ($assessments as $index => $assessment) {
176 171
             $scores_array[$assessment->id] = json_decode($assessment->scores, true);
177 172
         }
178 173
 
@@ -181,12 +176,9 @@ class ActivitiesController extends \BaseController {
181 176
 
182 177
     public function saveAssessment()
183 178
     {
184
-        try
185
-        {
186
-            $exception = DB::transaction(function()
187
-            {
188
-                DB::transaction(function()
189
-                {
179
+        try {
180
+            $exception = DB::transaction(function () {
181
+                DB::transaction(function () {
190 182
                     // Student assessment data
191 183
                     $student_data = json_decode(Input::get('student_scores'));
192 184
 
@@ -198,51 +190,42 @@ class ActivitiesController extends \BaseController {
198 190
                     $activity = Activity::find(Input::get('activity_id'));
199 191
 
200 192
                     // Create or update student scores
201
-                    if($activity->outcomes_attempted==NULL)
202
-                    {
193
+                    if ($activity->outcomes_attempted == NULL) {
203 194
                         // For each student, save her/his assessment in the db
204
-                        foreach ($student_data as $single_student_data)
205
-                        {
195
+                        foreach ($student_data as $single_student_data) {
206 196
                             // Find student by id
207 197
                             $student = Student::find($single_student_data->student_id);
208 198
 
209 199
                             $comments = trim($single_student_data->comments);
210
-                            if($comments=='')
211
-                            {
200
+                            if ($comments == '') {
212 201
                                 $comments = NULL;
213 202
                             }
214 203
 
215 204
                             // Add the assessment to the pivot table
216 205
                             $student->assessed_activities()->attach($activity->id, array(
217 206
                                 'scores' => json_encode($single_student_data->scores),
218
-                                'percentage'=>$single_student_data->percentage,
207
+                                'percentage' => $single_student_data->percentage,
219 208
                                 'comments' => $single_student_data->comments
220 209
                             ));
221 210
                         }
222
-                    }
223
-                    else
224
-                    {
211
+                    } else {
225 212
                         // For each student, save her/his assessment in the db
226
-                        foreach ($student_data as $single_student_data)
227
-                        {
213
+                        foreach ($student_data as $single_student_data) {
228 214
                             // Find student by id
229 215
                             $student = Student::find($single_student_data->student_id);
230 216
 
231 217
                             $comments = trim($single_student_data->comments);
232
-                            if($comments=='')
233
-                            {
218
+                            if ($comments == '') {
234 219
                                 $comments = NULL;
235 220
                             }
236 221
 
237 222
                             // Update the assessment in the pivot table
238 223
                             $student->assessed_activities()->updateExistingPivot($activity->id, array(
239 224
                                 'scores' => json_encode($single_student_data->scores),
240
-                                'percentage'=>$single_student_data->percentage,
225
+                                'percentage' => $single_student_data->percentage,
241 226
                                 'comments' => $single_student_data->comments
242 227
                             ));
243
-
244 228
                         }
245
-
246 229
                     }
247 230
 
248 231
 
@@ -256,43 +239,37 @@ class ActivitiesController extends \BaseController {
256 239
                     $course_outcomes_attempted = NULL;
257 240
                     $course_outcomes_achieved = NULL;
258 241
 
259
-                    if($course->outcomes_attempted==NULL)
260
-                    {
242
+                    if ($course->outcomes_attempted == NULL) {
261 243
                         $course_outcomes_attempted = array_fill(1, $outcomeCount, 0);
262 244
                         $course_outcomes_achieved = array_fill(1, $outcomeCount, 0);
263
-                    }
264
-                    else
265
-                    {
245
+                    } else {
266 246
                         // the second argument is necessary to convert it into an array
267 247
                         $course_outcomes_attempted = json_decode($course->outcomes_attempted, true);
268 248
                         $course_outcomes_achieved = json_decode($course->outcomes_achieved, true);
269 249
                     }
270 250
 
271 251
 
272
-                    foreach($criteria_achievement as $criterion_id=>$criterion_achieved)
273
-                    {
252
+                    foreach ($criteria_achievement as $criterion_id => $criterion_achieved) {
274 253
                         // Find corresponding learning outcome
275 254
                         $criterion = Criterion::withTrashed()->find($criterion_id);
276 255
                         $outcome = Outcome::find($criterion->outcome_id);
277 256
 
278 257
                         // If criterion is achieved (1), add 1 to all arrays
279
-                        if($criterion_achieved===1)
280
-                        {
281
-                            $outcomes_attempted[$outcome->id]+=1;
282
-                            $outcomes_achieved[$outcome->id]+=1;
283
-                            $course_outcomes_attempted[$outcome->id]+=1;
284
-                            $course_outcomes_achieved[$outcome->id]+=1;
258
+                        if ($criterion_achieved === 1) {
259
+                            $outcomes_attempted[$outcome->id] += 1;
260
+                            $outcomes_achieved[$outcome->id] += 1;
261
+                            $course_outcomes_attempted[$outcome->id] += 1;
262
+                            $course_outcomes_achieved[$outcome->id] += 1;
285 263
                         }
286 264
                         // Else if it's 0, only add to the attempted outcomes arrays
287
-                        elseif($criterion_achieved===0)
288
-                        {
289
-                            $outcomes_attempted[$outcome->id]+=1;
290
-                            $course_outcomes_attempted[$outcome->id]+=1;
265
+                        elseif ($criterion_achieved === 0) {
266
+                            $outcomes_attempted[$outcome->id] += 1;
267
+                            $course_outcomes_attempted[$outcome->id] += 1;
291 268
                         }
292 269
                     }
293 270
 
294 271
                     // If all values are 0, throw exception
295
-                    if(count(array_unique($outcomes_attempted))==1 && $outcomes_attempted[1]==0)
272
+                    if (count(array_unique($outcomes_attempted)) == 1 && $outcomes_attempted[1] == 0)
296 273
                         throw new Exception("Error Processing Request", 1);
297 274
 
298 275
 
@@ -305,18 +282,14 @@ class ActivitiesController extends \BaseController {
305 282
 
306 283
 
307 284
                     // Publish results if not a draft. That is, update the activity's course.
308
-                    if(Input::get('draft')==false)
309
-                    {
285
+                    if (Input::get('draft') == false) {
310 286
                         // Update course
311 287
                         $course->outcomes_achieved = json_encode($course_outcomes_achieved);
312 288
                         $course->outcomes_attempted = json_encode($course_outcomes_attempted);
313 289
                         $course->save();
314 290
 
315 291
                         $activity->draft = false;
316
-
317
-                    }
318
-                    else
319
-                    {
292
+                    } else {
320 293
                         // Set draft to true
321 294
                         $activity->draft = true;
322 295
                     }
@@ -334,18 +307,15 @@ class ActivitiesController extends \BaseController {
334 307
 
335 308
                     // Check if any assessed activities remain
336 309
                     $remainingAssessed = false;
337
-                    foreach ($activities as $activity1)
338
-                    {
339
-                        if($activity1->outcomes_attempted!=NULL)
340
-                        {
341
-                            $remainingAssessed =true;
310
+                    foreach ($activities as $activity1) {
311
+                        if ($activity1->outcomes_attempted != NULL) {
312
+                            $remainingAssessed = true;
342 313
                             break;
343 314
                         }
344 315
                     }
345 316
 
346 317
                     //If there are still evaluated activities in the course, recalculate course outcomes
347
-                    if(count($activities) && $remainingAssessed)
348
-                    {
318
+                    if (count($activities) && $remainingAssessed) {
349 319
                         $outcomeCount = Outcome::all()->count();
350 320
 
351 321
                         // Variables to hold recalculated outcomes for the course
@@ -353,29 +323,24 @@ class ActivitiesController extends \BaseController {
353 323
                         $course_outcomes_achieved = array_fill(1, $outcomeCount, 0);
354 324
 
355 325
                         // For each activity
356
-                        foreach ($activities as $activity2)
357
-                        {
326
+                        foreach ($activities as $activity2) {
358 327
                             // If activity has been assessed
359
-                            if($activity2->outcomes_attempted!=NULL)
360
-                            {
328
+                            if ($activity2->outcomes_attempted != NULL) {
361 329
                                 // Get the achieved criteria
362 330
                                 $criteria_achievement = json_decode($activity2->criteria_achieved, true);
363
-                                foreach($criteria_achievement as $criterion_id=>$criterion_achieved)
364
-                                {
331
+                                foreach ($criteria_achievement as $criterion_id => $criterion_achieved) {
365 332
                                     // Find corresponding learning outcome;
366 333
                                     $criterion = Criterion::withTrashed()->find($criterion_id);
367 334
                                     $outcome = Outcome::find($criterion->outcome_id);
368 335
 
369 336
                                     // If criterion is achieved (1), add 1 to both arrays
370
-                                    if($criterion_achieved === 1)
371
-                                    {
372
-                                        $course_outcomes_attempted[$outcome->id]+=1;
373
-                                        $course_outcomes_achieved[$outcome->id]+=1;
337
+                                    if ($criterion_achieved === 1) {
338
+                                        $course_outcomes_attempted[$outcome->id] += 1;
339
+                                        $course_outcomes_achieved[$outcome->id] += 1;
374 340
                                     }
375 341
                                     // Else, only add to the attempted outcomes arrays
376
-                                    elseif($criterion_achieved === 0)
377
-                                    {
378
-                                        $course_outcomes_attempted[$outcome->id]+=1;
342
+                                    elseif ($criterion_achieved === 0) {
343
+                                        $course_outcomes_attempted[$outcome->id] += 1;
379 344
                                     }
380 345
                                 }
381 346
                             }
@@ -383,54 +348,46 @@ class ActivitiesController extends \BaseController {
383 348
 
384 349
                         // Update course
385 350
                         DB::table('courses')
386
-                        ->where('id', $course->id)
387
-                        ->update(array(
388
-                            'outcomes_attempted'=> json_encode($course_outcomes_attempted),
389
-                            'outcomes_achieved'=> json_encode($course_outcomes_achieved),
390
-                            'updated_at' => date('Y-m-d H:i:s'))
391
-                        );
351
+                            ->where('id', $course->id)
352
+                            ->update(array(
353
+                                'outcomes_attempted' => json_encode($course_outcomes_attempted),
354
+                                'outcomes_achieved' => json_encode($course_outcomes_achieved),
355
+                                'updated_at' => date('Y-m-d H:i:s')
356
+                            ));
392 357
                     }
393 358
                     // Otherwise, set them all to NULL
394
-                    else
395
-                    {
359
+                    else {
396 360
                         DB::table('courses')
397
-                        ->where('id', $course->id)
398
-                        ->update(array(
399
-                            'outcomes_attempted'=> NULL,
400
-                            'outcomes_achieved'=> NULL,
401
-                            'updated_at' => date('Y-m-d H:i:s'))
402
-                        );
361
+                            ->where('id', $course->id)
362
+                            ->update(array(
363
+                                'outcomes_attempted' => NULL,
364
+                                'outcomes_achieved' => NULL,
365
+                                'updated_at' => date('Y-m-d H:i:s')
366
+                            ));
403 367
                     }
404
-
405 368
                 });
406 369
             });
407 370
 
408
-            if(is_null($exception))
409
-            {
371
+            if (is_null($exception)) {
410 372
                 Session::flash('status', 'success');
411 373
                 Session::flash('message', 'Assessment Saved. To add transforming actions click "Transforming Actions".');
412 374
                 return action('ActivitiesController@show', array(Input::get('activity_id')));
413 375
             }
414
-
415
-        }
416
-        catch(Exception $e)
417
-        {
418
-            Log::info('e:'.$e);
376
+        } catch (Exception $e) {
377
+            Log::info('e:' . $e);
378
+            echo $e->getMessage();
419 379
             Session::flash('status', 'danger');
420 380
             Session::flash('message', 'Error saving assessment. Try again later.');
421 381
 
422 382
             return action('ActivitiesController@show', array(Input::get('activity_id')));
423
-
424 383
         }
425 384
     }
426 385
 
427 386
     public function deleteAssessment()
428 387
     {
429 388
 
430
-        try
431
-        {
432
-            $exception = DB::transaction(function()
433
-            {
389
+        try {
390
+            $exception = DB::transaction(function () {
434 391
                 $activity = DB::table('activities')->where('id', Input::get('id'))->first();
435 392
 
436 393
                 $course = DB::table('courses')->where('id', $activity->course_id)->first();
@@ -441,14 +398,14 @@ class ActivitiesController extends \BaseController {
441 398
                     ->where('id', Input::get('id'))
442 399
                     ->update(array(
443 400
                         'draft' => 0,
444
-                        'outcomes_attempted'=> NULL,
445
-                        'outcomes_achieved'=> NULL,
446
-                        'criteria_achieved'=> NULL,
447
-                        'transforming_actions'=> NULL,
448
-                        'assessment_comments'=> NULL,
449
-                        'criteria_achieved_percentage'=> NULL,
450
-                        'updated_at' => date('Y-m-d H:i:s'))
451
-                    );
401
+                        'outcomes_attempted' => NULL,
402
+                        'outcomes_achieved' => NULL,
403
+                        'criteria_achieved' => NULL,
404
+                        'transforming_actions' => NULL,
405
+                        'assessment_comments' => NULL,
406
+                        'criteria_achieved_percentage' => NULL,
407
+                        'updated_at' => date('Y-m-d H:i:s')
408
+                    ));
452 409
 
453 410
                 // Delete students score
454 411
                 DB::table('assessments')->where('activity_id', $activity->id)->delete();
@@ -462,18 +419,15 @@ class ActivitiesController extends \BaseController {
462 419
 
463 420
                 // Check if any assessed activties remain
464 421
                 $remainingAssessed = false;
465
-                foreach ($activities as $activity)
466
-                {
467
-                    if($activity->outcomes_attempted!=NULL)
468
-                    {
469
-                        $remainingAssessed =true;
422
+                foreach ($activities as $activity) {
423
+                    if ($activity->outcomes_attempted != NULL) {
424
+                        $remainingAssessed = true;
470 425
                         break;
471 426
                     }
472 427
                 }
473 428
 
474 429
                 //If there are still evaluated activities in the course, recalculate course outcomes
475
-                if(count($activities) && $remainingAssessed)
476
-                {
430
+                if (count($activities) && $remainingAssessed) {
477 431
                     $outcomeCount = Outcome::all()->count();
478 432
 
479 433
                     // Variables to hold recalculated outcomes for the course
@@ -481,29 +435,24 @@ class ActivitiesController extends \BaseController {
481 435
                     $course_outcomes_achieved = array_fill(1, $outcomeCount, 0);
482 436
 
483 437
                     // For each activity
484
-                    foreach ($activities as $activity)
485
-                    {
438
+                    foreach ($activities as $activity) {
486 439
                         // If activity has been assessed
487
-                        if($activity->outcomes_attempted!=NULL)
488
-                        {
440
+                        if ($activity->outcomes_attempted != NULL) {
489 441
                             // Get the achieved criteria
490 442
                             $criteria_achievement = json_decode($activity->criteria_achieved, true);
491
-                            foreach($criteria_achievement as $criterion_id=>$criterion_achieved)
492
-                            {
443
+                            foreach ($criteria_achievement as $criterion_id => $criterion_achieved) {
493 444
                                 // Find corresponding learning outcome;
494 445
                                 $criterion = Criterion::withTrashed()->find($criterion_id);
495 446
                                 $outcome = Outcome::find($criterion->outcome_id);
496 447
 
497 448
                                 // If criterion is achieved (1), add 1 to both arrays
498
-                                if($criterion_achieved === 1)
499
-                                {
500
-                                    $course_outcomes_attempted[$outcome->id]+=1;
501
-                                    $course_outcomes_achieved[$outcome->id]+=1;
449
+                                if ($criterion_achieved === 1) {
450
+                                    $course_outcomes_attempted[$outcome->id] += 1;
451
+                                    $course_outcomes_achieved[$outcome->id] += 1;
502 452
                                 }
503 453
                                 // Else, only add to the attempted outcomes arrays
504
-                                elseif($criterion_achieved === 0)
505
-                                {
506
-                                    $course_outcomes_attempted[$outcome->id]+=1;
454
+                                elseif ($criterion_achieved === 0) {
455
+                                    $course_outcomes_attempted[$outcome->id] += 1;
507 456
                                 }
508 457
                             }
509 458
                         }
@@ -511,36 +460,31 @@ class ActivitiesController extends \BaseController {
511 460
 
512 461
                     // Update course
513 462
                     DB::table('courses')
514
-                    ->where('id', $course->id)
515
-                    ->update(array(
516
-                        'outcomes_attempted'=> json_encode($course_outcomes_attempted),
517
-                        'outcomes_achieved'=> json_encode($course_outcomes_achieved),
518
-                        'updated_at' => date('Y-m-d H:i:s'))
519
-                    );
463
+                        ->where('id', $course->id)
464
+                        ->update(array(
465
+                            'outcomes_attempted' => json_encode($course_outcomes_attempted),
466
+                            'outcomes_achieved' => json_encode($course_outcomes_achieved),
467
+                            'updated_at' => date('Y-m-d H:i:s')
468
+                        ));
520 469
                 }
521 470
                 // Otherwise, set them all to NULL
522
-                else
523
-                {
471
+                else {
524 472
                     DB::table('courses')
525
-                    ->where('id', $course->id)
526
-                    ->update(array(
527
-                        'outcomes_attempted'=> NULL,
528
-                        'outcomes_achieved'=> NULL,
529
-                        'updated_at' => date('Y-m-d H:i:s'))
530
-                    );
473
+                        ->where('id', $course->id)
474
+                        ->update(array(
475
+                            'outcomes_attempted' => NULL,
476
+                            'outcomes_achieved' => NULL,
477
+                            'updated_at' => date('Y-m-d H:i:s')
478
+                        ));
531 479
                 }
532 480
             });
533 481
 
534
-            if(is_null($exception))
535
-            {
482
+            if (is_null($exception)) {
536 483
                 Session::flash('status', 'success');
537 484
                 Session::flash('message', 'Assessment deleted.');
538 485
                 return Redirect::back();
539 486
             }
540
-
541
-        }
542
-        catch (Exception $e)
543
-        {
487
+        } catch (Exception $e) {
544 488
             Session::flash('status', 'danger');
545 489
             Session::flash('message', 'Error saving  assessment. Try again later.');
546 490
 
@@ -552,25 +496,21 @@ class ActivitiesController extends \BaseController {
552 496
     {
553 497
         $course = Activity::find($id)->course;
554 498
 
555
-        if(Activity::destroy($id))
556
-        {
499
+        if (Activity::destroy($id)) {
557 500
             // Recalculate course outcomes
558 501
             $activities = $course->activities;
559 502
 
560 503
             // Check if any assessed activties remain
561 504
             $remainingAssessed = false;
562
-            foreach ($course->activities as $activity)
563
-            {
564
-                if($activity->outcomes_attempted!=NULL)
565
-                {
566
-                    $remainingAssessed =true;
505
+            foreach ($course->activities as $activity) {
506
+                if ($activity->outcomes_attempted != NULL) {
507
+                    $remainingAssessed = true;
567 508
                     break;
568 509
                 }
569 510
             }
570 511
 
571 512
             //If there are still evaluated activities in the course, recalculate course outcomes
572
-            if(!$course->activities->isEmpty() && $remainingAssessed )
573
-            {
513
+            if (!$course->activities->isEmpty() && $remainingAssessed) {
574 514
                 $outcomeCount = Outcome::all()->count();
575 515
 
576 516
                 // Variables to hold recalculated outcomes for the course
@@ -578,60 +518,48 @@ class ActivitiesController extends \BaseController {
578 518
                 $course_outcomes_achieved = array_fill(1, $outcomeCount, 0);
579 519
 
580 520
                 // For each activity
581
-                foreach ($activities as $activity)
582
-                {
583
-                  // If activity has been assessed
584
-                  if($activity->outcomes_attempted!=NULL)
585
-                  {
586
-                    // Get the achieved criteria
587
-                    $criteria_achievement = json_decode($activity->criteria_achieved, true);
588
-                    foreach($criteria_achievement as $criterion_id=>$criterion_achieved)
589
-                    {
590
-                      // Find corresponding learning outcome;
591
-                      $criterion = Criterion::withTrashed()->find($criterion_id);
592
-                      $outcome = Outcome::find($criterion->outcome_id);
593
-
594
-                      // If criterion is achieved (1), add 1 to both arrays
595
-                      if($criterion_achieved === 1)
596
-                      {
597
-                        $course_outcomes_attempted[$outcome->id]+=1;
598
-                        $course_outcomes_achieved[$outcome->id]+=1;
599
-                      }
600
-                      // Else, only add to the attempted outcomes arrays
601
-                      elseif($criterion_achieved === 0)
602
-                      {
603
-                        $course_outcomes_attempted[$outcome->id]+=1;
604
-                      }
521
+                foreach ($activities as $activity) {
522
+                    // If activity has been assessed
523
+                    if ($activity->outcomes_attempted != NULL) {
524
+                        // Get the achieved criteria
525
+                        $criteria_achievement = json_decode($activity->criteria_achieved, true);
526
+                        foreach ($criteria_achievement as $criterion_id => $criterion_achieved) {
527
+                            // Find corresponding learning outcome;
528
+                            $criterion = Criterion::withTrashed()->find($criterion_id);
529
+                            $outcome = Outcome::find($criterion->outcome_id);
530
+
531
+                            // If criterion is achieved (1), add 1 to both arrays
532
+                            if ($criterion_achieved === 1) {
533
+                                $course_outcomes_attempted[$outcome->id] += 1;
534
+                                $course_outcomes_achieved[$outcome->id] += 1;
535
+                            }
536
+                            // Else, only add to the attempted outcomes arrays
537
+                            elseif ($criterion_achieved === 0) {
538
+                                $course_outcomes_attempted[$outcome->id] += 1;
539
+                            }
540
+                        }
605 541
                     }
606
-                  }
607 542
                 }
608 543
 
609 544
                 // Update course
610 545
                 $course->outcomes_achieved = json_encode($course_outcomes_achieved);
611 546
                 $course->outcomes_attempted = json_encode($course_outcomes_attempted);
612
-            }
613
-            else
614
-            {
547
+            } else {
615 548
                 $course->outcomes_achieved = NULL;
616 549
                 $course->outcomes_attempted = NULL;
617 550
             }
618 551
 
619
-            if($course->save())
620
-            {
552
+            if ($course->save()) {
621 553
                 Session::flash('status', 'success');
622 554
                 Session::flash('message', 'Activity deleted.');
623
-            }
624
-            else
625
-            {
555
+            } else {
626 556
                 Session::flash('status', 'danger');
627 557
                 Session::flash('message', 'Error deleting activity. Try again later.');
628 558
                 return Redirect::back();
629 559
             }
630 560
 
631 561
             return Redirect::action('CoursesController@show', array($course->id));
632
-        }
633
-        else
634
-        {
562
+        } else {
635 563
             Session::flash('status', 'danger');
636 564
             Session::flash('message', 'Error deleting activity. Try again later.');
637 565
             return Redirect::back();
@@ -640,12 +568,10 @@ class ActivitiesController extends \BaseController {
640 568
 
641 569
     public function update($id)
642 570
     {
643
-        try
644
-        {
571
+        try {
645 572
             $activity = Activity::find($id);
646 573
 
647
-            if(Input::has('update_activity_information'))
648
-            {
574
+            if (Input::has('update_activity_information')) {
649 575
                 /** Validation rules */
650 576
                 $validator = Validator::make(
651 577
                     array(
@@ -654,27 +580,25 @@ class ActivitiesController extends \BaseController {
654 580
                         'date' => Input::get('date'),
655 581
                     ),
656 582
                     array(
657
-                        'name' => 'required|unique:activities,course_id,'.$id,
583
+                        'name' => 'required|unique:activities,course_id,' . $id,
658 584
                         'description' => 'required|min:10',
659 585
                         'date' => 'required|dateFormat:Y-m-d'
660 586
                     ),
661 587
                     array(
662
-                        'date.dateFormat'=>'The date does not match the correct format: yyyy-mm-dd.'
588
+                        'date.dateFormat' => 'The date does not match the correct format: yyyy-mm-dd.'
663 589
                     )
664 590
                 );
665 591
 
666 592
                 /** If validation fails */
667
-                if ($validator->fails())
668
-                {
593
+                if ($validator->fails()) {
669 594
                     /** Prepare error message */
670 595
                     $message = 'Error(s) updating the Activity<ul>';
671 596
 
672
-                    foreach ($validator->messages()->all('<li>:message</li>') as $validationError)
673
-                    {
674
-                        $message.=$validationError;
597
+                    foreach ($validator->messages()->all('<li>:message</li>') as $validationError) {
598
+                        $message .= $validationError;
675 599
                     }
676 600
 
677
-                    $message.='</ul>';
601
+                    $message .= '</ul>';
678 602
 
679 603
                     /** Send error message and old data */
680 604
                     Session::flash('status', 'warning');
@@ -686,23 +610,17 @@ class ActivitiesController extends \BaseController {
686 610
                 $activity->name = Input::get('name');
687 611
                 $activity->description = Input::get('description');
688 612
                 $activity->date = Input::get('date');
689
-            }
690
-            elseif(Input::has('update_transforming_actions'))
691
-            {
692
-                if(trim(Input::get('transforming_actions')) !="")
613
+            } elseif (Input::has('update_transforming_actions')) {
614
+                if (trim(Input::get('transforming_actions')) != "")
693 615
                     $activity->transforming_actions = Input::get('transforming_actions');
694 616
                 else
695 617
                     $activity->transforming_actions = NULL;
696
-            }
697
-            elseif(Input::has('update_assessment_comments'))
698
-            {
699
-                if(trim(Input::get('assessment_comments')) !="")
618
+            } elseif (Input::has('update_assessment_comments')) {
619
+                if (trim(Input::get('assessment_comments')) != "")
700 620
                     $activity->assessment_comments = Input::get('assessment_comments');
701 621
                 else
702 622
                     $activity->assessment_comments = NULL;
703
-            }
704
-            else
705
-            {
623
+            } else {
706 624
                 Session::flash('status', 'danger');
707 625
                 Session::flash('message', 'Error updating Activity. Please try again later.');
708 626
                 return Redirect::action('ActivitiesController@show', array($activity->id));
@@ -714,15 +632,11 @@ class ActivitiesController extends \BaseController {
714 632
             Session::flash('status', 'success');
715 633
             Session::flash('message', 'Activity succesfully updated.');
716 634
             return Redirect::action('ActivitiesController@show', array($activity->id));
717
-
718
-        }
719
-        catch(Exception $e)
720
-        {
635
+        } catch (Exception $e) {
721 636
             Session::flash('status', 'warning');
722 637
             Session::flash('message', 'Error updating Activity. Please try again later.');
723 638
             return Redirect::action('ActivitiesController@show', array($activity->id));
724 639
         }
725
-
726 640
     }
727 641
 
728 642
     //TODO the code in the next 2 functions is the same as the assess function except for the view returned. try to refactor this to avoid copying code.
@@ -732,7 +646,7 @@ class ActivitiesController extends \BaseController {
732 646
         $activity = Activity::find($id);
733 647
 
734 648
         // If activity does not exist, display 404
735
-        if(!$activity)
649
+        if (!$activity)
736 650
             App::abort('404');
737 651
 
738 652
         // Get activity's course
@@ -756,8 +670,7 @@ class ActivitiesController extends \BaseController {
756 670
 
757 671
         // Decode the scores (blade workaround)
758 672
         $scores_array = array();
759
-        foreach ($assessments as $index=>$assessment)
760
-        {
673
+        foreach ($assessments as $index => $assessment) {
761 674
             $scores_array[$assessment->id] = json_decode($assessment->scores, true);
762 675
         }
763 676
 
@@ -769,7 +682,7 @@ class ActivitiesController extends \BaseController {
769 682
         $activity = Activity::find($id);
770 683
 
771 684
         // If activity does not exist, display 404
772
-        if(!$activity)
685
+        if (!$activity)
773 686
             App::abort('404');
774 687
 
775 688
         // Get activity's course
@@ -793,13 +706,10 @@ class ActivitiesController extends \BaseController {
793 706
 
794 707
         // Decode the scores (blade workaround)
795 708
         $scores_array = array();
796
-        foreach ($assessments as $index=>$assessment)
797
-        {
709
+        foreach ($assessments as $index => $assessment) {
798 710
             $scores_array[$assessment->id] = json_decode($assessment->scores, true);
799 711
         }
800 712
 
801 713
         return View::make('local.professors.print_assessment', compact('activity', 'title', 'students', 'course', 'rubric_contents', 'assessments', 'scores_array', 'rubric'));
802 714
     }
803
-
804
-
805 715
 }

+ 393
- 136
app/controllers/CriteriaController.php View File

@@ -1,47 +1,124 @@
1 1
 <?php
2 2
 
3
-class CriteriaController extends \BaseController {
3
+use Illuminate\Support\Facades\Input;
4
+
5
+class CriteriaController extends \BaseController
6
+{
4 7
 
5 8
     /**
6 9
      * Display a listing of the resource.
7 10
      *
11
+     *
8 12
      * @return Response
9 13
      */
14
+    public function editProgram()
15
+    {
16
+        $userProgram = Auth::user()['id'];
17
+
18
+        $userProgram = DB::select("select program_user.program_id from program_user where user_id = {$userProgram}");
19
+        Log::info($userProgram);
20
+        $title = "Criteria";
21
+        $outcomes = Outcome::orderBy('name', 'ASC')->lists('name', 'id');
22
+
23
+        $criteria = Criterion::withTrashed()->orderBy('name', 'ASC')->get();
24
+        $programs = Program::where("id", "=", $userProgram[0]->program_id)->get();
25
+        return View::make('local.managers.pCoords.criteria', compact('title', 'outcomes', 'schools', 'criteria', 'programs', 'objectives'));
26
+    }
27
+
28
+    public function editSchool()
29
+    {
30
+        $userSchool = Auth::user()['school_id'];
31
+        Log::info($userSchool);
32
+        $title = "Criteria";
33
+        $outcomes = Outcome::orderBy('name', 'ASC')->lists('name', 'id');
34
+
35
+        $schools = School::find($userSchool)->get();
36
+        $criteria = Criterion::withTrashed()->orderBy('name', 'ASC')->get();
37
+        $programs = Program::where("school_id", "=", $userSchool)->orderBy('name', 'ASC')->get();
38
+        $listOfId = array();
39
+        foreach ($programs as $program) {
40
+
41
+            $listOfId[] = $program->id;
42
+        }
43
+
44
+        $objectives = DB::table('objectives')->whereIn('program_id', $listOfId)->orderBy('text', 'ASC')->lists('text', 'id');
45
+
46
+
47
+
48
+
49
+
50
+        return View::make('local.managers.sCoords.criteria', compact('title', 'outcomes', 'schools', 'criteria', 'programs', 'objectives'));
51
+    }
52
+
53
+
10 54
     public function fetchCriterion()
11 55
     {
12 56
         return Criterion::find(Input::get('id'));
13 57
     }
58
+    public function fetchAllCriterion()
59
+    {
60
+        $program_id = Input::get('program_fetch');
61
+        $outcome_id = Input::get('outcome_fetch');
62
+        $json = array();
63
+        $json['criterion'] = DB::select("SELECT * FROM `new_criteria` where id in (select criterion_id from criterion_objective_outcome where outcome_id ={$outcome_id}) and id in(select criterion_id from program_criterion where program_id = {$program_id})");
64
+        return json_encode($json);
65
+    }
66
+    public function fetchObjectivesForSelect()
67
+    {
14 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);
72
+    }
15 73
     public function fetchCriterionWithTrashed()
16 74
     {
17
-        return Criterion::withTrashed()->find(Input::get('id'));
75
+
76
+        $json = array();
77
+        $json['criteria'] = DB::select(" select * from new_criteria where id = ?", array(Input::get('id')));
78
+        $json['outcomes'] = DB::select("select  DISTINCT outcomes.id, outcomes.name from outcomes , criterion_objective_outcome where criterion_objective_outcome.criterion_id = ? and outcomes.id = criterion_objective_outcome.outcome_id order by outcomes.id", array(Input::get('id')));
79
+        $json['objectives'] = DB::select("SELECT DISTINCT objectives.id, objectives.text FROM objectives, criterion_objective_outcome where criterion_objective_outcome.criterion_id = ? and criterion_objective_outcome.objective_id= objectives.id ", array(Input::get('id')));
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')));
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')));
82
+        $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')));
84
+
85
+        return json_encode($json);
18 86
     }
19 87
 
88
+    public function delete()
89
+    {
90
+        DB::delete("delete from new_criteria where id = ?", array(Input::get('id')));
91
+        $role = Auth::user()['role'];
92
+        switch ($role) {
93
+            case 1:
94
+                return Redirect::to('objective')->withInput();
95
+
96
+            case 2:
97
+                return Redirect::to('school-objective')->withInput();
20 98
 
99
+            case 3:
100
+                return Redirect::to('program-objective')->withInput();
101
+        }
102
+    }
21 103
     public function isCriterionUnique($input, $existing_criterion = NULL)
22 104
     {
23 105
         // dd($input);
24 106
         Log::info('isCriterionUnique');
25 107
 
26
-        if(Input::get('program_id')!=0)
108
+        if (Input::get('program_id') != 0)
27 109
             $program_id = $input['program_id'];
28 110
         else
29 111
             $program_id = NULL;
30 112
 
31
-        $saved_criterion = Criterion::
32
-            withTrashed()
113
+        $saved_criterion = Criterion::withTrashed()
33 114
             ->where('name', '=', $input['name'])
34 115
             ->where('outcome_id', '=', $input['outcome_id'])
35 116
             ->where('program_id', '=', $program_id)
36
-            // ->where('description12', '=', $input['description12'])
37
-            // ->where('description34', '=', $input['description34'])
38
-            // ->where('description56', '=', $input['description56'])
39
-            // ->where('description78', '=', $input['description78'])
40 117
             ->first();
41 118
 
42
-    
43 119
 
44
-        if($saved_criterion)
120
+
121
+        if ($saved_criterion)
45 122
             return false;
46 123
         else
47 124
             return true;
@@ -56,28 +133,40 @@ class CriteriaController extends \BaseController {
56 133
 
57 134
         $trimmed = trim(preg_replace('/\t+/', '', Input::get('subcriteria')));
58 135
 
59
-        Log::info('trimmed 1 -->'.$trimmed.'<--');
136
+        Log::info('trimmed 1 -->' . $trimmed . '<--');
60 137
 
61 138
 
62
-        if($trimmed ==''){
139
+        if ($trimmed == '') {
63 140
             $trimmed = NULL;
64
-        }
65
-        else{
141
+        } else {
66 142
             $trimmed = json_encode(preg_split('/\r\n/', $trimmed));
67 143
         }
68 144
 
69
-        Log::info('trimmed 2 -->'.$trimmed.'<--');
145
+        Log::info('trimmed 2 -->' . $trimmed . '<--');
70 146
 
71 147
 
72 148
         $clean_input['subcriteria'] = $trimmed;
73
-        $clean_input['outcome_id'] = trim(preg_replace('/\t+/', '', Input::get('outcome_id')));
74
-        $clean_input['program_id'] = trim(preg_replace('/\t+/', '', Input::get('program_id')));
75
-        $clean_input['description12'] = trim(preg_replace('/\t+/', '', Input::get('description12')));
76
-        $clean_input['description34'] = trim(preg_replace('/\t+/', '', Input::get('description34')));
77
-        $clean_input['description56'] = trim(preg_replace('/\t+/', '', Input::get('description56')));
78
-        $clean_input['description78'] = trim(preg_replace('/\t+/', '', Input::get('description78')));
149
+        $clean_input['outcome_id'] = Input::get('outcome');
150
+
151
+
152
+
153
+        $clean_input['objective_id'] = Input::get('objective');
154
+
155
+
156
+
157
+
158
+        $clean_input['program_id'] = Input::get('program_id');
159
+
79 160
         $clean_input['copyright'] = trim(preg_replace('/\t+/', '', Input::get('copyright')));
80 161
         $clean_input['notes'] = trim(preg_replace('/\t+/', '', Input::get('notes')));
162
+        $clean_input['maximum_score'] =  (int) Input::get('maximum_score');
163
+        $clean_input['scale_title'] = Input::get('title');
164
+        $clean_input['scale_description'] = Input::get('Scales');
165
+        $clean_input['min_score'] = Input::get('min');
166
+        $clean_input['max_score'] = Input::get('max');
167
+
168
+        $clean_input['number_of_scales'] = sizeof($clean_input['scale_title']);
169
+
81 170
 
82 171
         return $clean_input;
83 172
     }
@@ -90,30 +179,20 @@ class CriteriaController extends \BaseController {
90 179
                 'name' => $clean_input['name'],
91 180
                 'subcriteria' => $clean_input['subcriteria'],
92 181
                 'outcome_id' => $clean_input['outcome_id'],
93
-                'description12' => $clean_input['description12'],
94
-                'description34' => $clean_input['description34'],
95
-                'description56' => $clean_input['description56'],
96
-                'description78' => $clean_input['description78'],
97 182
                 'notes' => $clean_input['notes'],
98 183
                 'copyright' => $clean_input['copyright'],
184
+                'maximum_score' => $clean_input['maximum_score']
99 185
             ),
100 186
             array(
101 187
                 'name' => 'required|string',
102 188
                 'subcriteria' => 'string',
103
-                'outcome_id' => 'required|numeric|integer',
104
-                'description12' => 'required|string',
105
-                'description34' => 'required|string',
106
-                'description56' => 'required|string',
107
-                'description78' => 'required|string',
189
+                'outcome_id' => 'required|array',
190
+
108 191
                 'notes' => 'string',
109 192
                 'copyright' => 'string',
110
-            ),
111
-            array(
112
-                'description12.required' => 'The Beginning (1-2) field is required.',
113
-                'description34.required' => 'The In Progress (3-4) field is required.',
114
-                'description56.required' => 'The Satisfactory (5-6) field is required.',
115
-                'description78.required' => 'The Excellent (7-8) field is required.',
193
+                'maximum_score' => 'required|integer'
116 194
             )
195
+
117 196
         );
118 197
     }
119 198
 
@@ -130,115 +209,232 @@ class CriteriaController extends \BaseController {
130 209
         $validator = $this->makeValidator($clean_input);
131 210
 
132 211
         /** If validation fails */
133
-        if ($validator->fails())
134
-        {
212
+        if ($validator->fails()) {
135 213
             /** Prepare error message */
136 214
             $message = '<p>Error(s) creating a new Criterion:</p><ul>';
137 215
 
138
-            foreach ($validator->messages()->all('<li>:message</li>') as $validationError)
139
-            {
140
-                $message.=$validationError;
216
+            foreach ($validator->messages()->all('<li>:message</li>') as $validationError) {
217
+                $message .= $validationError;
141 218
             }
142 219
 
143
-            $message.='</ul>';
220
+            $message .= '</ul>';
144 221
 
145 222
             /** Send error message and old data */
146 223
             Session::flash('status', 'danger');
147 224
             Session::flash('message', $message);
148
-            return Redirect::to('criteria')->withInput();
149
-        }
150
-        else
151
-        {
225
+            $role = Auth::user()['role'];
226
+            switch ($role) {
227
+                case 1:
228
+                    return Redirect::to('objective')->withInput();
229
+
230
+                case 2:
231
+                    return Redirect::to('school-objective')->withInput();
232
+
233
+                case 3:
234
+                    return Redirect::to('program-objective')->withInput();
235
+            }
236
+        } else {
152 237
             // Check criterion uniqueness
153
-            if(!$this->isCriterionUnique($clean_input))
154
-            {
155
-                /** Send error message and old data */
238
+            /*if (!$this->isCriterionUnique($clean_input)) {
239
+                /** Send error message and old data
156 240
                 Session::flash('status', 'danger');
157 241
                 Session::flash('message', 'This criterion is a duplicate of an already saved criterion because its name and associated program are the same.');
158 242
                 return Redirect::to('criteria')->withInput();
159
-            }
243
+            }*/
160 244
 
161 245
             /** Instantiate new criterion */
162 246
             $criterion = new Criterion;
163
-            $criterion->name= $clean_input['name'];
247
+            $criterion->name = $clean_input['name'];
164 248
             $criterion->subcriteria = $clean_input['subcriteria'];
165
-            $criterion->outcome_id= $clean_input['outcome_id'];
166
-            $criterion->description12 = $clean_input['description12'];
167
-            $criterion->description34 = $clean_input['description34'];
168
-            $criterion->description56 = $clean_input['description56'];
169
-            $criterion->description78 = $clean_input['description78'];
170 249
 
171
-            if(Input::get('copyright'))
250
+
251
+            //gabriel añadió aqui
252
+
253
+            $criterion->number_of_scales = $clean_input['number_of_scales'];
254
+            $criterion->maximum_score = $clean_input['maximum_score'];
255
+
256
+            if (Input::get('copyright'))
172 257
                 $criterion->copyright = $clean_input['copyright'];
173 258
 
174
-            if(Input::get('notes'))
259
+            if (Input::get('notes'))
175 260
                 $criterion->notes = $clean_input['notes'];
176 261
 
177
-            // Set program
178
-            if(Input::get('program_id')!=0)
179
-                $criterion->program_id = $clean_input['program_id'];
180
-            else
181
-                $criterion->program_id = NULL;
182 262
 
183 263
 
184 264
             /** If criterion is saved, send success message */
185
-            if($criterion->save())
186
-            {
265
+            if ($criterion->save()) {
266
+
267
+                $criterionId = $criterion->id;
268
+                foreach ($clean_input['outcome_id'] as $outcome_id) {
269
+                    foreach ($clean_input['objective_id'] as $objective_id) {
270
+
271
+                        DB::insert("insert into `criterion_objective_outcome` (`objective_id`, `outcome_id`, `criterion_id`, `objective_outcome_id`) values ({$objective_id},{$outcome_id}, {$criterionId}, 0)");
272
+                    }
273
+                }
274
+
275
+                for ($i = 0; $i < sizeof($clean_input['scale_title']); $i++) {
276
+                    $scale = new Scale;
277
+                    $scale->title = $clean_input['scale_title'][$i];
278
+                    $scale->position = $i + 1;
279
+                    $scale->description = $clean_input['scale_description'][$i];
280
+                    $scale->min_score = $clean_input['min_score'][$i];
281
+                    $scale->max_score = $clean_input['max_score'][$i];
282
+
283
+                    if ($scale->save()) {
284
+                        DB::insert("insert into `criterion_scale` (`criterion_id`, `scale_id`) values({$criterionId},{$scale->id})");
285
+                    } else {
286
+                        Session::flash('status', 'danger');
287
+                        Session::flash('message', '<p>Error creating the Scales</p>');
288
+                        $role = Auth::user()['role'];
289
+                        switch ($role) {
290
+                            case 1:
291
+                                return Redirect::to('objective')->withInput();
292
+
293
+                            case 2:
294
+                                return Redirect::to('school-objective')->withInput();
295
+
296
+                            case 3:
297
+                                return Redirect::to('program-objective')->withInput();
298
+                        }
299
+                    }
300
+                }
301
+
302
+                foreach ($clean_input['program_id'] as $program_id) {
303
+                    DB::insert("insert into `program_criterion` (`criterion_id`, `program_id`) values({$criterionId},{$program_id})");
304
+                }
305
+
187 306
                 Session::flash('status', 'success');
188
-                Session::flash('message', 'Criterion created: "'.$criterion->name.'".');
189
-                return Redirect::to('criteria')->withInput(Input::only('outcome_id'));
307
+                Session::flash('message', 'Criterion created: "' . $criterion->name . '".');
308
+                $role = Auth::user()['role'];
309
+                switch ($role) {
310
+                    case 1:
311
+                        return Redirect::to('objective')->withInput();
312
+
313
+                    case 2:
314
+                        return Redirect::to('school-objective')->withInput();
315
+
316
+                    case 3:
317
+                        return Redirect::to('program-objective')->withInput();
318
+                }
190 319
             }
191 320
 
192 321
             /** If saving fails, send error message and old data */
193
-            else
194
-            {
322
+            else {
195 323
                 Session::flash('status', 'danger');
196 324
                 Session::flash('message', '<p>Error creating Criterion. Please try again later.</p>');
197
-                return Redirect::to('learning-outcomes-criteria')->withInput();
325
+                $role = Auth::user()['role'];
326
+                switch ($role) {
327
+                    case 1:
328
+                        return Redirect::to('objective')->withInput();
329
+
330
+                    case 2:
331
+                        return Redirect::to('school-objective')->withInput();
332
+
333
+                    case 3:
334
+                        return Redirect::to('program-objective')->withInput();
335
+                }
198 336
             }
199 337
         }
200 338
     }
201 339
 
340
+
341
+
202 342
     public function edit()
203 343
     {
204 344
         $title = "Criteria";
205
-        $outcomes = Outcome::orderBy('name', 'ASC')->get();
345
+        $outcomes = Outcome::orderBy('name', 'ASC')->lists('name', 'id');
346
+
206 347
         $schools = School::orderBy('name', 'ASC')->get();
207 348
         $criteria = Criterion::withTrashed()->orderBy('name', 'ASC')->get();
208 349
         $programs = Program::orderBy('name', 'ASC')->get();
350
+        $objectives = DB::table('objectives')->orderBy('text', 'ASC')->lists('text', 'id');
351
+
352
+
353
+
354
+
355
+
356
+        return View::make('local.managers.admins.criteria', compact('title', 'outcomes', 'schools', 'criteria', 'programs', 'objectives'));
357
+    }
358
+
359
+    private function cleanInputEdit()
360
+    {
361
+        $clean_input = array();
362
+
363
+        $clean_input['name'] = trim(preg_replace('/\t+/', '', Input::get('name')));
364
+
365
+
366
+        $trimmed = trim(preg_replace('/\t+/', '', Input::get('subcriteria')));
367
+
368
+        Log::info('trimmed 1 -->' . $trimmed . '<--');
369
+
209 370
 
210
-        return View::make('local.managers.admins.criteria', compact('title', 'outcomes', 'schools', 'criteria', 'programs'));
371
+        if ($trimmed == '') {
372
+            $trimmed = NULL;
373
+        } else {
374
+            $trimmed = json_encode(preg_split('/\r\n/', $trimmed));
375
+        }
376
+
377
+        Log::info('trimmed 2 -->' . $trimmed . '<--');
378
+
379
+
380
+        $clean_input['subcriteria'] = $trimmed;
381
+        $clean_input['outcome_id'] = Input::get('assoc_outcome');
382
+
383
+
384
+
385
+        $clean_input['objective_id'] = Input::get('assoc_objective');
386
+
387
+
388
+
389
+
390
+        $clean_input['program_id'] = Input::get('program_id');
391
+
392
+        $clean_input['copyright'] = trim(preg_replace('/\t+/', '', Input::get('copyright')));
393
+        $clean_input['notes'] = trim(preg_replace('/\t+/', '', Input::get('notes')));
394
+        $clean_input['maximum_score'] = (int) Input::get('assoc_maximum_score');
395
+        $clean_input['scale_title'] = Input::get('assoc_title');
396
+        $clean_input['scale_description'] = Input::get('assoc_scales');
397
+        $clean_input['number_of_scales'] = sizeof($clean_input['scale_title']);
398
+
399
+
400
+        return $clean_input;
211 401
     }
212 402
 
213 403
     public function update()
214 404
     {
215 405
         $criterion = Criterion::withTrashed()->find(Input::get('id'));
216 406
 
217
-        $clean_input = $this->cleanInput();
407
+        $clean_input = $this->cleanInputEdit();
218 408
 
219 409
         /** Validation rules */
220 410
         $validator = $this->makeValidator($clean_input);
221 411
 
222 412
         /** If validation fails */
223
-        if ($validator->fails())
224
-        {
413
+        if ($validator->fails()) {
225 414
             /** Prepare error message */
226 415
             $message = 'Error(s) updating the Criterion: <ul>';
227 416
 
228
-            foreach ($validator->messages()->all('<li>:message</li>') as $validationError)
229
-            {
230
-                $message.=$validationError;
417
+            foreach ($validator->messages()->all('<li>:message</li>') as $validationError) {
418
+                $message .= $validationError;
231 419
             }
232 420
 
233
-            $message.='</ul>';
421
+            $message .= '</ul>';
234 422
 
235 423
             /** Send error message and old data */
236 424
             Session::flash('status', 'danger');
237 425
             Session::flash('message', $message);
238
-            return Redirect::back()->withInput();
239
-        }
240
-        else
241
-        {
426
+            $role = Auth::user()['role'];
427
+            switch ($role) {
428
+                case 1:
429
+                    return Redirect::to('objective')->withInput();
430
+
431
+                case 2:
432
+                    return Redirect::to('school-objective')->withInput();
433
+
434
+                case 3:
435
+                    return Redirect::to('program-objective')->withInput();
436
+            }
437
+        } else {
242 438
 
243 439
             // // Check criterion uniqueness
244 440
             // if(!$this->isCriterionUnique($clean_input, $criterion))
@@ -250,50 +446,107 @@ class CriteriaController extends \BaseController {
250 446
             // }
251 447
 
252 448
             /** Set info */
253
-            $criterion->name= $clean_input['name'];
449
+            $criterion->name = $clean_input['name'];
254 450
             $criterion->subcriteria = $clean_input['subcriteria'];
255
-            $criterion->outcome_id= $clean_input['outcome_id'];
256
-            $criterion->description12 = $clean_input['description12'];
257
-            $criterion->description34 = $clean_input['description34'];
258
-            $criterion->description56 = $clean_input['description56'];
259
-            $criterion->description78 = $clean_input['description78'];
451
+
452
+
453
+
454
+            $criterion->number_of_scales = $clean_input['number_of_scales'];
455
+            $criterion->maximum_score = $clean_input['maximum_score'];
456
+
457
+
260 458
 
261 459
             // Set program
262
-            if(Input::get('program_id')!=0)
460
+            if (Input::get('program_id') != 0)
263 461
                 $criterion->program_id = Input::get('program_id');
264 462
             else
265 463
                 $criterion->program_id = NULL;
266 464
 
267 465
             // Set status
268
-            if(Input::get('status')==0)
466
+            if (Input::get('status') == 0)
269 467
                 $criterion->deleted_at = date('Y-m-d H:i:s');
270 468
             else
271 469
                 $criterion->deleted_at = NULL;
272 470
 
273
-            if(Input::get('copyright'))
471
+            if (Input::get('copyright'))
274 472
                 $criterion->copyright = $clean_input['copyright'];
275 473
             else
276
-                $criterion->copyright=NULL;
474
+                $criterion->copyright = NULL;
277 475
 
278
-            if(Input::get('notes'))
476
+            if (Input::get('notes'))
279 477
                 $criterion->notes = $clean_input['notes'];
280 478
             else
281
-                $criterion->notes=NULL;
479
+                $criterion->notes = NULL;
282 480
 
283 481
             /** If criterion is updated, send success message */
284
-            if($criterion->save())
285
-            {
482
+            if ($criterion->save()) {
483
+                $criterionId = $criterion->id;
484
+                DB::delete("delete from `criterion_objective_outcome` where `criterion_id` ={$criterionId}");
485
+
486
+                foreach ($clean_input['outcome_id'] as $outcome_id) {
487
+                    foreach ($clean_input['objective_id'] as $objective_id) {
488
+
489
+                        DB::insert("insert into `criterion_objective_outcome` (`objective_id`, `outcome_id`, `criterion_id`,`objective_outcome_id`) values ({$objective_id},{$outcome_id}, {$criterionId}, 0)");
490
+                    }
491
+                }
492
+                DB::delete("delete from `scales` where id in (select scale_id id from criterion_scale where criterion_id = {$criterionId})");
493
+
494
+                for ($i = 0; $i < sizeof($clean_input['scale_title']); $i++) {
495
+                    $scale = new Scale;
496
+                    $scale->title = $clean_input['scale_title'][$i];
497
+                    $scale->position = $i + 1;
498
+                    $scale->description = $clean_input['scale_description'][$i];
499
+                    if ($scale->save()) {
500
+                        DB::insert("insert into `criterion_scale` (`criterion_id`, `scale_id`) values({$criterionId},{$scale->id})");
501
+                    } else {
502
+                        Session::flash('status', 'danger');
503
+                        Session::flash('message', '<p>Error creating the Scales</p>');
504
+                        $role = Auth::user()['role'];
505
+                        switch ($role) {
506
+                            case 1:
507
+                                return Redirect::to('objective')->withInput();
508
+
509
+                            case 2:
510
+                                return Redirect::to('school-objective')->withInput();
511
+
512
+                            case 3:
513
+                                return Redirect::to('program-objective')->withInput();
514
+                        }
515
+                    }
516
+                }
517
+
518
+
519
+
286 520
                 Session::flash('status', 'success');
287
-                Session::flash('message', 'Updated criterion: "'.$criterion->name.'"');
288
-                return Redirect::back();
521
+                Session::flash('message', 'Updated criterion: "' . $criterion->name . '"');
522
+                $role = Auth::user()['role'];
523
+                switch ($role) {
524
+                    case 1:
525
+                        return Redirect::to('objective')->withInput();
526
+
527
+                    case 2:
528
+                        return Redirect::to('school-objective')->withInput();
529
+
530
+                    case 3:
531
+                        return Redirect::to('program-objective')->withInput();
532
+                }
289 533
             }
290 534
 
291 535
             /** If saving fails, send error message and old data */
292
-            else
293
-            {
536
+            else {
294 537
                 Session::flash('status', 'danger');
295 538
                 Session::flash('message', 'Error updating the Criterion. Please try again later.');
296
-                return Redirect::back()->withInput();
539
+                $role = Auth::user()['role'];
540
+                switch ($role) {
541
+                    case 1:
542
+                        return Redirect::to('objective')->withInput();
543
+
544
+                    case 2:
545
+                        return Redirect::to('school-objective')->withInput();
546
+
547
+                    case 3:
548
+                        return Redirect::to('program-objective')->withInput();
549
+                }
297 550
             }
298 551
         }
299 552
     }
@@ -359,70 +612,75 @@ class CriteriaController extends \BaseController {
359 612
     public function destroy()
360 613
     {
361 614
         $criterion = Criterion::withTrashed()->find(Input::get('id'));
362
-        if(!$criterion->trashed())
363
-        {
364
-            try
365
-            {
615
+        if (!$criterion->trashed()) {
616
+            try {
366 617
                 $criterion->delete();
367 618
                 Session::flash('status', 'success');
368
-                Session::flash('message', 'Deactivated criterion: "'.$criterion->name.'"');
369
-            }
370
-            catch (Exception $e)
371
-            {
619
+                Session::flash('message', 'Deactivated criterion: "' . $criterion->name . '"');
620
+            } catch (Exception $e) {
372 621
                 Session::flash('status', 'danger');
373
-                Session::flash('message', 'Error deactivating criterion."'.$criterion->name.'"');
622
+                Session::flash('message', 'Error deactivating criterion."' . $criterion->name . '"');
374 623
             }
375
-            return Redirect::back();
376
-        }
377
-        else
378
-        {
379
-            try
380
-            {
624
+            $role = Auth::user()['role'];
625
+            switch ($role) {
626
+                case 1:
627
+                    return Redirect::to('objective')->withInput();
628
+
629
+                case 2:
630
+                    return Redirect::to('school-objective')->withInput();
631
+
632
+                case 3:
633
+                    return Redirect::to('program-objective')->withInput();
634
+            }
635
+        } else {
636
+            try {
381 637
                 $criterion->restore();
382 638
                 Session::flash('status', 'success');
383
-                Session::flash('message', 'Reactivated criterion: "'.$criterion->name.'"');
384
-            }
385
-            catch (Exception $e)
386
-            {
639
+                Session::flash('message', 'Reactivated criterion: "' . $criterion->name . '"');
640
+            } catch (Exception $e) {
387 641
                 Session::flash('status', 'danger');
388
-                Session::flash('message', 'Error reactivating criterion: "'.$criterion->name.'".');
642
+                Session::flash('message', 'Error reactivating criterion: "' . $criterion->name . '".');
389 643
             }
390
-            return Redirect::back();
644
+            $role = Auth::user()['role'];
645
+            switch ($role) {
646
+                case 1:
647
+                    return Redirect::to('objective')->withInput();
648
+
649
+                case 2:
650
+                    return Redirect::to('school-objective')->withInput();
391 651
 
652
+                case 3:
653
+                    return Redirect::to('program-objective')->withInput();
654
+            }
392 655
         }
393 656
     }
394 657
 
395 658
     public function filterCriteria()
396 659
     {
397
-        switch (Input::get('filter'))
398
-        {
660
+        switch (Input::get('filter')) {
399 661
             case 'all':
400 662
                 return Criteria::all();
401 663
                 break;
402 664
 
403 665
             case 'school':
404 666
                 // If scoord
405
-                if(Auth::user()->role == '2')
406
-                {
667
+                if (Auth::user()->role == '2') {
407 668
 
408 669
                     // Fetch all the programs whose school is the user's
409 670
                     $program_ids = DB::table('programs')->where('school_id', Auth::user()->school_id)->lists('id');
410 671
 
411 672
                     // Return all criteria belonging to any of those programs
412
-                    return Criterion::
413
-                        whereIn('program_id', $program_ids)
673
+                    return Criterion::whereIn('program_id', $program_ids)
414 674
                         ->orderBy('name', 'ASC')
415 675
                         ->get();
416 676
                 }
417 677
 
418 678
                 // If pcoord
419
-                else
420
-                {
679
+                else {
421 680
                     // Fetch all the programs from the user's school;
422 681
                     $program_ids = DB::table('programs')->where('school_id', Auth::user()->programs[0]->school->id)->lists('id');
423 682
 
424
-                    return Criterion::
425
-                        whereIn('program_id', $program_ids)
683
+                    return Criterion::whereIn('program_id', $program_ids)
426 684
                         ->orderBy('name', 'ASC')
427 685
                         ->get();
428 686
                 }
@@ -430,8 +688,7 @@ class CriteriaController extends \BaseController {
430 688
                 break;
431 689
 
432 690
             case 'program':
433
-                return Criterion::
434
-                    whereIn('program_id', Auth::user()->programs->lists('id'))
691
+                return Criterion::whereIn('program_id', Auth::user()->programs->lists('id'))
435 692
                     ->orderBy('name', 'ASC')
436 693
                     ->get();
437 694
                 break;

+ 437
- 0
app/controllers/Objective2Controller.php View File

@@ -0,0 +1,437 @@
1
+<?php
2
+
3
+use Illuminate\Support\Facades\Auth;
4
+
5
+class Objective2Controller extends \BaseController
6
+{
7
+
8
+	/**
9
+	 * Display a listing of the resource.
10
+	 *
11
+	 * @return Response
12
+	 */
13
+
14
+	public function index()
15
+	{
16
+
17
+		$title = "Learning Outcomes and Criteria";
18
+		$outcomes = Outcome::orderBy('name', 'ASC')->get();
19
+		$schools = School::orderBy('name', 'ASC')->get();
20
+		$objectives = Objective::withTrashed()->orderBy('text', 'ASC')->get();
21
+
22
+		return View::make('global.view-learning-outcomes-criteria', compact('title', 'outcomes', 'schools', 'objectives'));
23
+	}
24
+
25
+
26
+
27
+	/**
28
+	 * Show the form for creating a new resource.
29
+	 *
30
+	 * @return Response
31
+	 */
32
+	public function isObjectiveUnique($input, $existing_Objective = NULL)
33
+	{
34
+
35
+		Log::info('isObjectiveUnique');
36
+
37
+		if (Input::get('program_id') != 0)
38
+			$program_id = $input['program_id'];
39
+		else
40
+			$program_id = NULL;
41
+
42
+		$saved_Objective = Objective::withTrashed()
43
+			->where('text', '=', $input['text'])
44
+			->where('outcome_id', '=', $input['outcome_id'])
45
+			->where('program_id', '=', $program_id)
46
+
47
+			->first();
48
+
49
+
50
+
51
+		if ($saved_Objective)
52
+			return false;
53
+		else
54
+			return true;
55
+	}
56
+
57
+
58
+	private function makeValidator($clean_input)
59
+	{
60
+		/** Validation rules */
61
+		return Validator::make(
62
+			array(
63
+				'text' => $clean_input['text'],
64
+
65
+				'outcome_id' => $clean_input['outcome_id'],
66
+				'program_id' => $clean_input['program_id']
67
+
68
+			),
69
+			array(
70
+				'text' => 'required|string',
71
+
72
+				'outcome_id' => 'required|array',
73
+				'program_id' => 'required|numeric|integer'
74
+
75
+			)
76
+
77
+		);
78
+	}
79
+
80
+
81
+	private function cleanInput()
82
+	{
83
+		$clean_input = array();
84
+
85
+		$clean_input['text'] = trim(preg_replace('/\t+/', '', Input::get('text')));
86
+
87
+
88
+		$clean_input['outcome_id'] = Input::get('outcome');
89
+		$counter = Input::get('counter') + 0;
90
+
91
+		for ($i = 0; $i < $counter; $i++) {
92
+			$clean_input['outcome_id'][$i] = trim(preg_replace('/\t+/', '', $clean_input['outcome_id'][$i]));
93
+		}
94
+
95
+		$clean_input['program_id'] = trim(preg_replace('/\t+/', '', Input::get('program_id')));
96
+
97
+
98
+		return $clean_input;
99
+	}
100
+
101
+	private function cleanAssocInput()
102
+	{
103
+		$clean_input = array();
104
+
105
+		$clean_input['text'] = trim(preg_replace('/\t+/', '', Input::get('text')));
106
+
107
+
108
+		$clean_input['outcome_id'] = Input::get('assoc_outcome');
109
+
110
+
111
+
112
+		$clean_input['program_id'] = trim(preg_replace('/\t+/', '', Input::get('program_id')));
113
+
114
+
115
+		return $clean_input;
116
+	}
117
+	public function fetchObjective()
118
+	{
119
+		return Objective::find(Input::get('id'));
120
+	}
121
+
122
+	public function fetchObjectiveWithTrashed()
123
+	{
124
+		return json_encode(DB::select('select o.id, o.program_id, o.text, outc.outcome_id outcome_id from objectives o, objective_outcome outc where o.id = ? and o.id = outc.objective_id', array(Input::get('id'))));
125
+	}
126
+	/**
127
+	 * Create a new Objective.
128
+	 *
129
+	 * @return Redirect Redirect back to form page
130
+	 */
131
+	public function create()
132
+	{
133
+
134
+		$clean_input = $this->cleanInput();
135
+
136
+		/** Validation rules */
137
+		$validator = $this->makeValidator($clean_input);
138
+
139
+		/** If validation fails */
140
+		if ($validator->fails()) {
141
+			/** Prepare error message */
142
+			$message = '<p>Error(s) creating a new Objective:</p><ul>';
143
+
144
+			foreach ($validator->messages()->all('<li>:message</li>') as $validationError) {
145
+				$message .= $validationError;
146
+			}
147
+
148
+			$message .= '</ul>';
149
+
150
+			/** Send error message and old data */
151
+			Session::flash('status', 'danger');
152
+			Session::flash('message', $message);
153
+			$role = Auth::user()['role'];
154
+			switch ($role) {
155
+				case 1:
156
+					return Redirect::to('objective')->withInput();
157
+
158
+				case 2:
159
+					return Redirect::to('school-objective')->withInput();
160
+
161
+				case 3:
162
+					return Redirect::to('program-objective')->withInput();
163
+			}
164
+		} else {
165
+			// Check Objective uniqueness
166
+			if (!$this->isObjectiveUnique($clean_input)) {
167
+				/** Send error message and old data */
168
+				Session::flash('status', 'danger');
169
+				Session::flash('message', "This objective is a duplicate of an already saved Objective because it's and associated program are the same.");
170
+				$role = Auth::user()['role'];
171
+				switch ($role) {
172
+					case 1:
173
+						return Redirect::to('objective')->withInput();
174
+
175
+					case 2:
176
+						return Redirect::to('school-objective')->withInput();
177
+
178
+					case 3:
179
+						return Redirect::to('program-objective')->withInput();
180
+				}
181
+			}
182
+
183
+			/** Instantiate new Objective */
184
+			$objective = new Objective;
185
+			$objective->text = $clean_input['text'];
186
+
187
+
188
+
189
+
190
+			// Set program
191
+			if (Input::get('program_id') != 0)
192
+				$objective->program_id = $clean_input['program_id'];
193
+			else
194
+				$objective->program_id = NULL;
195
+
196
+
197
+			/** If Objective is saved, send success message */
198
+			if ($objective->save()) {
199
+				$objectiveId = $objective->id;
200
+				foreach ($clean_input['outcome_id'] as $outcome_id) {
201
+					DB::insert("insert into `objective_outcome` (objective_id, outcome_id) values ({$objectiveId}, {$outcome_id})");
202
+
203
+					/*if (!($objectiveOutcome->save())) {
204
+						Session::flash('status', 'danger');
205
+						Session::flash('message', '<p>Error creating objective. Please try again later.</p>');
206
+						return Redirect::to('objective')->withInput();
207
+					}*/
208
+				}
209
+
210
+				Session::flash('status', 'success');
211
+				Session::flash('message', 'Objective created: "' . $objective->text . '".');
212
+				$role = Auth::user()['role'];
213
+				switch ($role) {
214
+					case 1:
215
+						return Redirect::to('objective')->withInput(Input::only('outcome_id'));
216
+
217
+					case 2:
218
+						return Redirect::to('school-objective')->withInput(Input::only('outcome_id'));
219
+
220
+					case 3:
221
+						return Redirect::to('program-objective')->withInput(Input::only('outcome_id'));
222
+				}
223
+			}
224
+
225
+			/** If saving fails, send error message and old data */
226
+			else {
227
+				Session::flash('status', 'danger');
228
+				Session::flash('message', '<p>Error creating objective. Please try again later.</p>');
229
+				$role = Auth::user()['role'];
230
+				switch ($role) {
231
+					case 1:
232
+						return Redirect::to('objective')->withInput();
233
+
234
+					case 2:
235
+						return Redirect::to('school-objective')->withInput();
236
+
237
+					case 3:
238
+						return Redirect::to('program-objective')->withInput();
239
+				}
240
+			}
241
+		}
242
+	}
243
+	/**
244
+	 * Store a newly created resource in storage.
245
+	 *
246
+	 * @return Response
247
+	 */
248
+	public function store()
249
+	{
250
+		//
251
+	}
252
+
253
+
254
+	/**
255
+	 * Display the specified resource.
256
+	 *
257
+	 * @param  int  $id
258
+	 * @return Response
259
+	 */
260
+	public function show($id)
261
+	{
262
+		//
263
+	}
264
+
265
+
266
+	/**
267
+	 * Show the form for editing the specified resource.
268
+	 *
269
+	 * @param  int  $id
270
+	 * @return Response
271
+	 */
272
+	public function edit()
273
+	{
274
+		$title = "Objective";
275
+		$outcomes = Outcome::orderBy('name', 'ASC')->lists('name', 'id');
276
+
277
+		$objectives = Objective::withTrashed()->orderBy('text', 'ASC')->get();
278
+		$programs = Program::orderBy('name', 'ASC')->get();
279
+
280
+		return View::make('local.managers.admins.objectives', compact('title', 'outcomes', 'objectives', 'programs'));
281
+	}
282
+
283
+	public function editProgram()
284
+	{
285
+		$userProgram = Auth::user()['id'];
286
+		Log::info(Auth::user());
287
+
288
+		$userProgram = DB::select("select program_user.program_id from program_user where user_id = {$userProgram}");
289
+
290
+		$title = "Objective";
291
+		$outcomes = Outcome::orderBy('name', 'ASC')->lists('name', 'id');
292
+
293
+		$objectives = Objective::withTrashed()->orderBy('text', 'ASC')->get();
294
+
295
+		$programs = Program::where("id", '=', $userProgram[0]->program_id)->get();
296
+
297
+
298
+
299
+
300
+		return View::make('local.managers.pCoords.objectives', compact('title', 'outcomes', 'objectives', 'programs'));
301
+	}
302
+
303
+	public function editSchool()
304
+	{
305
+		$userSchool = Auth::user()['school_id'];
306
+		Log::info($userSchool);
307
+		$title = "Objective";
308
+		$outcomes = Outcome::orderBy('name', 'ASC')->lists('name', 'id');
309
+
310
+		$objectives = Objective::withTrashed()->orderBy('text', 'ASC')->get();
311
+		$programs = Program::where("school_id", "=", $userSchool)->orderBy('name', 'ASC')->get();
312
+
313
+
314
+
315
+		return View::make('local.managers.sCoords.objectives', compact('title', 'outcomes', 'objectives', 'programs'));
316
+	}
317
+
318
+	/**
319
+	 * Update the specified resource in storage.
320
+	 *
321
+	 * @param  int  $id
322
+	 * @return Response
323
+	 */
324
+
325
+	public function update()
326
+
327
+	{
328
+
329
+		$Objective = Objective::withTrashed()->find(Input::get('id'));
330
+
331
+		$clean_input = $this->cleanAssocInput();
332
+
333
+		Log::info(print_r($clean_input, true));
334
+
335
+		/** Validation rules */
336
+		$validator = $this->makeValidator($clean_input);
337
+
338
+		/** If validation fails */
339
+		if ($validator->fails()) {
340
+			/** Prepare error message */
341
+			$message = 'Error(s) updating the Objective: <ul>';
342
+
343
+			foreach ($validator->messages()->all('<li>:message</li>') as $validationError) {
344
+				$message .= $validationError;
345
+			}
346
+
347
+			$message .= '</ul>';
348
+
349
+			/** Send error message and old data */
350
+			Session::flash('status', 'danger');
351
+			Session::flash('message', $message);
352
+			$role = Auth::user()['role'];
353
+			switch ($role) {
354
+				case 1:
355
+					return Redirect::to('objective')->withInput();
356
+
357
+				case 2:
358
+					return Redirect::to('school-objective')->withInput();
359
+
360
+				case 3:
361
+					return Redirect::to('program-objective')->withInput();
362
+			}
363
+		} else {
364
+
365
+
366
+
367
+			/** Set info */
368
+			$Objective->text = $clean_input['text'];
369
+
370
+
371
+
372
+			// Set program
373
+			if (Input::get('program_id') != 0)
374
+				$Objective->program_id = Input::get('program_id');
375
+			else
376
+				$Objective->program_id = NULL;
377
+
378
+			// Set status
379
+
380
+
381
+			/** If Objective is updated, send success message */
382
+			if ($Objective->save()) {
383
+
384
+				$objectiveId = $Objective->id;
385
+				DB::delete("delete from `objective_outcome` where objective_id ={$objectiveId}");
386
+
387
+				foreach ($clean_input['outcome_id'] as $outcome_id) {
388
+					DB::insert("insert into `objective_outcome` (objective_id, outcome_id) values ({$objectiveId}, {$outcome_id})");
389
+				}
390
+
391
+				Session::flash('status', 'success');
392
+				Session::flash('message', 'Updated Objective: "' . $Objective->text . '"');
393
+				$role = Auth::user()['role'];
394
+				switch ($role) {
395
+					case 1:
396
+						return Redirect::to('objective')->withInput();
397
+
398
+					case 2:
399
+						return Redirect::to('school-objective')->withInput();
400
+
401
+					case 3:
402
+						return Redirect::to('program-objective')->withInput();
403
+				}
404
+			}
405
+
406
+			/** If saving fails, send error message and old data */
407
+			else {
408
+				Session::flash('status', 'danger');
409
+				Session::flash('message', 'Error updating the Objective. Please try again later.');
410
+				$role = Auth::user()['role'];
411
+				switch ($role) {
412
+					case 1:
413
+						return Redirect::to('objective')->withInput();
414
+
415
+					case 2:
416
+						return Redirect::to('school-objective')->withInput();
417
+
418
+					case 3:
419
+						return Redirect::to('program-objective')->withInput();
420
+				}
421
+			}
422
+		}
423
+	}
424
+
425
+
426
+
427
+	/**
428
+	 * Remove the specified resource from storage.
429
+	 *
430
+	 * @param  int  $id
431
+	 * @return Response
432
+	 */
433
+	public function destroy($id)
434
+	{
435
+		//
436
+	}
437
+}

+ 86
- 0
app/controllers/Objective_OutcomeController.php View File

@@ -0,0 +1,86 @@
1
+<?php
2
+
3
+class Objective_OutcomeController extends \BaseController {
4
+
5
+	/**
6
+	 * Display a listing of the resource.
7
+	 *
8
+	 * @return Response
9
+	 */
10
+	public function index()
11
+	{
12
+		//
13
+	}
14
+
15
+
16
+	/**
17
+	 * Show the form for creating a new resource.
18
+	 *
19
+	 * @return Response
20
+	 */
21
+	public function create()
22
+	{
23
+		//
24
+	}
25
+
26
+
27
+	/**
28
+	 * Store a newly created resource in storage.
29
+	 *
30
+	 * @return Response
31
+	 */
32
+	public function store()
33
+	{
34
+		//
35
+	}
36
+
37
+
38
+	/**
39
+	 * Display the specified resource.
40
+	 *
41
+	 * @param  int  $id
42
+	 * @return Response
43
+	 */
44
+	public function show($id)
45
+	{
46
+		//
47
+	}
48
+
49
+
50
+	/**
51
+	 * Show the form for editing the specified resource.
52
+	 *
53
+	 * @param  int  $id
54
+	 * @return Response
55
+	 */
56
+	public function edit($id)
57
+	{
58
+		//
59
+	}
60
+
61
+
62
+	/**
63
+	 * Update the specified resource in storage.
64
+	 *
65
+	 * @param  int  $id
66
+	 * @return Response
67
+	 */
68
+	public function update($id)
69
+	{
70
+		//
71
+	}
72
+
73
+
74
+	/**
75
+	 * Remove the specified resource from storage.
76
+	 *
77
+	 * @param  int  $id
78
+	 * @return Response
79
+	 */
80
+	public function destroy($id)
81
+	{
82
+		//
83
+	}
84
+
85
+
86
+}

+ 49
- 75
app/controllers/RubricsController.php View File

@@ -1,6 +1,7 @@
1 1
 <?php
2 2
 
3
-class RubricsController extends \BaseController {
3
+class RubricsController extends \BaseController
4
+{
4 5
 
5 6
     /**
6 7
      * Show the form for creating a new rubric
@@ -15,20 +16,18 @@ class RubricsController extends \BaseController {
15 16
         if (!$activity)
16 17
             App::abort('404');
17 18
 
18
-        $title = 'Rubric for <em>'.$activity->name.'</em>';
19
+        $title = 'Rubric for <em>' . $activity->name . '</em>';
19 20
 
20 21
         // Select templates that belong to everyone or belong to the activity's course's school
21
-        $templates = Template::
22
-        where('is_visible', '=', 1)
23
-        ->where(function($query) use ($activity)
24
-        {
25
-            if(Auth::user()->role != 1){
26
-                $query
27
-                ->where('school_id', $activity->course->program->school->id)
28
-                ->orWhere('school_id', '=', NULL);
29
-            }
30
-        })
31
-        ->orderBy('name', 'ASC')->get();
22
+        $templates = Template::where('is_visible', '=', 1)
23
+            ->where(function ($query) use ($activity) {
24
+                if (Auth::user()->role != 1) {
25
+                    $query
26
+                        ->where('school_id', $activity->course->program->school->id)
27
+                        ->orWhere('school_id', '=', NULL);
28
+                }
29
+            })
30
+            ->orderBy('name', 'ASC')->get();
32 31
 
33 32
         $rubrics = Auth::user()->rubrics;
34 33
         $outcomes = Outcome::orderBy('name', 'ASC')->get();
@@ -48,10 +47,9 @@ class RubricsController extends \BaseController {
48 47
 
49 48
         DB::beginTransaction();
50 49
 
51
-        try
52
-        {
50
+        try {
53 51
             // Get rubric contents
54
-            $rubric_contents= json_decode(Input::get('contents'));
52
+            $rubric_contents = json_decode(Input::get('contents'));
55 53
 
56 54
             // Process rubric
57 55
             $rubric = new Rubric;
@@ -73,14 +71,12 @@ class RubricsController extends \BaseController {
73 71
             Session::flash('message', 'Rubric assigned.');
74 72
 
75 73
             return action('ActivitiesController@show', array($activity->id));
74
+        } catch (Exception $e) {
76 75
 
77
-
78
-        }
79
-        catch(Exception $e)
80
-        {
81 76
             DB::rollBack();
82
-            Session::flash('status', 'danger');
83
-            Session::flash('message', 'Error creating Rubric. Try again later.');
77
+            echo $e->getMessage();
78
+            //Session::flash('status', 'danger');
79
+            //Session::flash('message', 'Error creating Rubric. Try again later.');
84 80
         }
85 81
     }
86 82
 
@@ -111,17 +107,15 @@ class RubricsController extends \BaseController {
111 107
 
112 108
         try {
113 109
             // Get associated activity
114
-            $activity= Activity::where('rubric_id', '=', $rubric->id)->first();
110
+            $activity = Activity::where('rubric_id', '=', $rubric->id)->first();
115 111
 
116 112
             // If the associated activity has been assessed, delete the records
117
-            if($activity->outcomes_attempted!=NULL)
118
-            {
113
+            if ($activity->outcomes_attempted != NULL) {
119 114
                 DB::table('assessments')->where('activity_id', '=', $activity->id)->delete();
120
-                $activity->criteria_achieved_percentage= NULL;
121
-                $activity->criteria_achieved= NULL;
122
-                $activity->outcomes_achieved=NULL;
123
-                $activity->outcomes_attempted=NULL;
124
-
115
+                $activity->criteria_achieved_percentage = NULL;
116
+                $activity->criteria_achieved = NULL;
117
+                $activity->outcomes_achieved = NULL;
118
+                $activity->outcomes_attempted = NULL;
125 119
             }
126 120
 
127 121
             $rubric->save();
@@ -133,46 +127,38 @@ class RubricsController extends \BaseController {
133 127
 
134 128
             // Check if any assessed activities remain
135 129
             $remainingAssessed = false;
136
-            foreach ($course->activities as $activity)
137
-            {
138
-                if($activity->outcomes_attempted!=NULL)
139
-                {
140
-                    $remainingAssessed =true;
130
+            foreach ($course->activities as $activity) {
131
+                if ($activity->outcomes_attempted != NULL) {
132
+                    $remainingAssessed = true;
141 133
                     break;
142 134
                 }
143 135
             }
144 136
 
145 137
             //If there are still evaluated activities in the course, recalculate course outcomes
146
-            if(!$activities->isEmpty() && $remainingAssessed)
147
-            {
138
+            if (!$activities->isEmpty() && $remainingAssessed) {
148 139
                 // Variables to hold recalculated outcomes for the course
149 140
                 $course_outcomes_attempted = array_fill(1, Outcome::all()->count(), 0);
150 141
                 $course_outcomes_achieved = array_fill(1, Outcome::all()->count(), 0);
151 142
 
152 143
                 // For each activity
153
-                foreach ($activities as $activity)
154
-                {
144
+                foreach ($activities as $activity) {
155 145
                     // If activity has been assessed
156
-                    if($activity->outcomes_attempted!=NULL)
157
-                    {
146
+                    if ($activity->outcomes_attempted != NULL) {
158 147
                         // Get the achieved criteria
159 148
                         $criteria_achievement = json_decode($activity->criteria_achieved, true);
160
-                        foreach($criteria_achievement as $criterion_id=>$criterion_achieved)
161
-                        {
149
+                        foreach ($criteria_achievement as $criterion_id => $criterion_achieved) {
162 150
                             // Find corresponding learning outcome;
163 151
                             $criterion = Criterion::find($criterion_id);
164 152
                             $outcome = Outcome::find($criterion->outcome_id);
165 153
 
166 154
                             // If criterion is achieved (1), add 1 to both arrays
167
-                            if($criterion_achieved === 1)
168
-                            {
169
-                                $course_outcomes_attempted[$outcome->id]+=1;
170
-                                $course_outcomes_achieved[$outcome->id]+=1;
155
+                            if ($criterion_achieved === 1) {
156
+                                $course_outcomes_attempted[$outcome->id] += 1;
157
+                                $course_outcomes_achieved[$outcome->id] += 1;
171 158
                             }
172 159
                             // Else, only add to the attempted outcomes arrays
173
-                            elseif($criterion_achieved === 0)
174
-                            {
175
-                                $course_outcomes_attempted[$outcome->id]+=1;
160
+                            elseif ($criterion_achieved === 0) {
161
+                                $course_outcomes_attempted[$outcome->id] += 1;
176 162
                             }
177 163
                         }
178 164
                     }
@@ -181,14 +167,10 @@ class RubricsController extends \BaseController {
181 167
                 // Update course
182 168
                 $course->outcomes_achieved = json_encode($course_outcomes_achieved);
183 169
                 $course->outcomes_attempted = json_encode($course_outcomes_attempted);
184
-
185
-            }
186
-            else
187
-            {
170
+            } else {
188 171
                 // Update course
189 172
                 $course->outcomes_achieved = NULL;
190 173
                 $course->outcomes_attempted = NULL;
191
-
192 174
             }
193 175
 
194 176
             $course->save();
@@ -198,9 +180,7 @@ class RubricsController extends \BaseController {
198 180
             Session::flash('message', 'Rubric updated.');
199 181
 
200 182
             return action('ActivitiesController@show', array($activity->id));
201
-        }
202
-        catch (Exception $e)
203
-        {
183
+        } catch (Exception $e) {
204 184
             DB::rollBack();
205 185
             Session::flash('status', 'danger');
206 186
             Session::flash('message', 'Error: The rubric could not be updated. Try again later.');
@@ -216,13 +196,10 @@ class RubricsController extends \BaseController {
216 196
     {
217 197
         $rubric = Rubric::find(Input::get('id'));
218 198
 
219
-        if($rubric->delete())
220
-        {
199
+        if ($rubric->delete()) {
221 200
             Session::flash('status', 'success');
222 201
             Session::flash('message', 'Rubric deleted.');
223
-        }
224
-        else
225
-        {
202
+        } else {
226 203
             Session::flash('status', 'danger');
227 204
             Session::flash('message', 'Error: The rubric could not be deleted. Try again later.');
228 205
         }
@@ -243,10 +220,10 @@ class RubricsController extends \BaseController {
243 220
 
244 221
         // If activity does not belong to the requesting user, display 403
245 222
         if ($course->user_id != Auth::id())
246
-                App::abort('403', 'Access Forbidden');
223
+            App::abort('403', 'Access Forbidden');
247 224
 
248 225
         $rubric = Rubric::where('id', '=', $activity->rubric_id)->firstOrFail();
249
-        $title = $activity->name.': '.$rubric->name;
226
+        $title = $activity->name . ': ' . $rubric->name;
250 227
         return View::make('local.professors.viewrubric', compact('rubric', 'activity', 'title', 'course'));
251 228
     }
252 229
 
@@ -259,7 +236,7 @@ class RubricsController extends \BaseController {
259 236
     {
260 237
         // If user is a professor, display 403.
261 238
         if (Auth::user()->role == 4)
262
-                App::abort('403', 'Access Forbidden');
239
+            App::abort('403', 'Access Forbidden');
263 240
 
264 241
         $rubric = Rubric::where('id', '=', $rubric_id)->firstOrFail();
265 242
         $title = $rubric->name;
@@ -275,10 +252,10 @@ class RubricsController extends \BaseController {
275 252
 
276 253
         // If activity does not belong to the requesting user, display 403
277 254
         if ($course->user_id != Auth::id())
278
-                App::abort('403', 'Access Forbidden');
255
+            App::abort('403', 'Access Forbidden');
279 256
 
280 257
         $rubric = Rubric::where('id', '=', $activity->rubric_id)->firstOrFail();
281
-        $title = $activity->name.': '.$rubric->name;
258
+        $title = $activity->name . ': ' . $rubric->name;
282 259
         return View::make('local.professors.downloadrubric', compact('rubric', 'activity', 'title', 'course'));
283 260
     }
284 261
 
@@ -290,10 +267,10 @@ class RubricsController extends \BaseController {
290 267
 
291 268
         // If activity does not belong to the requesting user, display 403
292 269
         if ($course->user_id != Auth::id())
293
-                App::abort('403', 'Access Forbidden');
270
+            App::abort('403', 'Access Forbidden');
294 271
 
295 272
         $rubric = Rubric::where('id', '=', $activity->rubric_id)->firstOrFail();
296
-        $title = $activity->name.': '.$rubric->name;
273
+        $title = $activity->name . ': ' . $rubric->name;
297 274
         return View::make('local.professors.printrubric', compact('rubric', 'activity', 'title', 'course'));
298 275
     }
299 276
 
@@ -304,13 +281,10 @@ class RubricsController extends \BaseController {
304 281
 
305 282
         $rubric_contents = json_decode($rubric->contents);
306 283
 
307
-        foreach ($rubric_contents as $key => $criterion)
308
-        {
309
-            if($criterion->id == $criterion_id)
310
-            {
284
+        foreach ($rubric_contents as $key => $criterion) {
285
+            if ($criterion->id == $criterion_id) {
311 286
                 return json_encode($criterion);
312 287
             }
313 288
         }
314 289
     }
315
-
316 290
 }

+ 315
- 358
app/controllers/UsersController.php View File

@@ -1,6 +1,7 @@
1 1
 <?php
2 2
 
3
-class UsersController extends \BaseController {
3
+class UsersController extends \BaseController
4
+{
4 5
 
5 6
 	/**
6 7
 	 * Display a listing of the users.
@@ -9,10 +10,9 @@ class UsersController extends \BaseController {
9 10
 	 */
10 11
 	public function index()
11 12
 	{
12
-		$title="Users";
13
+		$title = "Users";
13 14
 
14
-		$users = User::
15
-			with('programs', 'school')
15
+		$users = User::with('programs', 'school')
16 16
 			->orderBy('surnames')
17 17
 			->orderBy('first_name')
18 18
 			->get();
@@ -32,6 +32,7 @@ class UsersController extends \BaseController {
32 32
 	public function edit()
33 33
 	{
34 34
 		$user = Auth::user();
35
+		Log::info($user);
35 36
 		$title = "Profile";
36 37
 		$schools = School::orderBy('name', 'asc')->get();
37 38
 		$programs = $user->programs;
@@ -45,140 +46,129 @@ class UsersController extends \BaseController {
45 46
 	 * @return Response
46 47
 	 */
47 48
 	public function store()
48
-    {
49
-    	$user = Auth::user();
50
-	    if(Input::get('submit_new_user') && Auth::user()->role==1)
51
-	    {
52
-
53
-	    	$first_name = strtoupper(Input::get('new_first_name'));
54
-	    	$surnames = strtoupper(Input::get('new_surnames'));
55
-	    	$email = strtolower(Input::get('new_email'));
56
-	    	$school_id = Input::get('new_school');
57
-
58
-	    	// Validation rules
59
-	        $validator = Validator::make(
60
-	            array(
61
-	                'first_name' => $first_name,
62
-	                'surnames' => $surnames,
63
-	                'email' => $email,
64
-	                'school_id' => $school_id,
65
-	            ),
66
-	            array(
67
-	                'first_name' => 'required',
68
-	                'surnames' => 'required',
69
-	                'email' => 'required|email',
70
-	                'school_id' => 'integer',
71
-	            )
72
-	        );
73
-
74
-	        /** If validation fails */
75
-	        if ($validator->fails())
76
-	        {
77
-	            /** Prepare error message */
78
-	            $message = 'Error(s) creating a user:<ul>';
79
-
80
-	            foreach ($validator->messages()->all('<li>:message</li>') as $validationError)
81
-	            {
82
-	                $message.=$validationError;
83
-	            }
84
-
85
-	            $message.='</ul>';
86
-
87
-	            /** Send error message and old data */
88
-	            Session::flash('status', 'danger');
89
-	            Session::flash('message', $message);
90
-	            return Redirect::back()->withInput();
91
-	        }
92
-
93
-
94
-	        DB::beginTransaction();
95
-	        try
96
-	        {
97
-                switch (Input::get('new_role'))
98
-                {
99
-                	case '1':
100
-
101
-                		User::create(array(
102
-                			'first_name' => $first_name,
103
-                			'surnames' => $surnames,
104
-                			'email'=> $email,
105
-                			'role'=> 1,
106
-                			'school_id'=> NULL,
107
-                			'has_access' => 1
108
-                		));
109
-                		break;
110
-
111
-                	case '2':
112
-                		User::create(array(
113
-                			'first_name' => $first_name,
114
-                			'surnames' => $surnames,
115
-                			'email'=> $email,
116
-                			'role'=> 2,
117
-                			'school_id'=> (int)Input::get('new_school'), // como que aqui
118
-                			'has_access' => 1
119
-                		));
120
-
121
-                		break;
122
-
123
-                	case '3':
124
-                		$user = User::create(array(
125
-                			'first_name' => $first_name,
126
-                			'surnames' => $surnames,
127
-                			'email'=> $email,
128
-                			'role'=> 3,
129
-                			'school_id'=> NULL,
130
-                			'has_access' => 1
131
-                		));
132
-
133
-                		// Attach new programs
134
-                		foreach (Input::get('programs') as $key => $program_id)
135
-                		{
136
-                			$user->programs()->attach($program_id);
137
-                		}
138
-
139
-                		$user->save();
140
-                		break;
141
-
142
-                	case '4':
143
-
144
-                		$user = User::create(array(
145
-                			'first_name' => $first_name,
146
-                			'surnames' => $surnames,
147
-                			'email'=> $email,
148
-                			'role'=> 4,
149
-                			'school_id'=> NULL,
150
-                			'has_access' => 1
151
-                		));
152
-
153
-                		// Attach new programs
154
-                		foreach (Input::get('new_programs') as $key => $program_id)
155
-                		{
156
-                			$user->programs()->attach($program_id);
157
-                		}
158
-                		$user->save();
159
-                		break;
160
-                }
161
-
162
-	            DB::commit();
163
-
164
-                Session::flash('status', 'success');
165
-                Session::flash('message', 'User created ('.date('m/d/y h:i:s A').')');
166
-                return Redirect::back();
167
-
168
-	        }
169
-	        catch(Exception $e)
170
-	        {
171
-	        	DB::rollBack();
172
-
173
-	            Session::flash('status', 'danger');
174
-	            Session::flash('message', 'Error creating. Try again later or contact the system administrator.');
175
-
176
-	            return Redirect::back();
177
-	        }
178
-	    }
179
-	    else
180
-	    	App::abort('404');
181
-    }
49
+	{
50
+		$user = Auth::user();
51
+		if (Input::get('submit_new_user') && Auth::user()->role == 1) {
52
+
53
+			$first_name = strtoupper(Input::get('new_first_name'));
54
+			$surnames = strtoupper(Input::get('new_surnames'));
55
+			$email = strtolower(Input::get('new_email'));
56
+			$school_id = Input::get('new_school');
57
+
58
+			// Validation rules
59
+			$validator = Validator::make(
60
+				array(
61
+					'first_name' => $first_name,
62
+					'surnames' => $surnames,
63
+					'email' => $email,
64
+					'school_id' => $school_id,
65
+				),
66
+				array(
67
+					'first_name' => 'required',
68
+					'surnames' => 'required',
69
+					'email' => 'required|email',
70
+					'school_id' => 'integer',
71
+				)
72
+			);
73
+
74
+			/** If validation fails */
75
+			if ($validator->fails()) {
76
+				/** Prepare error message */
77
+				$message = 'Error(s) creating a user:<ul>';
78
+
79
+				foreach ($validator->messages()->all('<li>:message</li>') as $validationError) {
80
+					$message .= $validationError;
81
+				}
82
+
83
+				$message .= '</ul>';
84
+
85
+				/** Send error message and old data */
86
+				Session::flash('status', 'danger');
87
+				Session::flash('message', $message);
88
+				return Redirect::back()->withInput();
89
+			}
90
+
91
+
92
+			DB::beginTransaction();
93
+			try {
94
+				switch (Input::get('new_role')) {
95
+					case '1':
96
+
97
+						User::create(array(
98
+							'first_name' => $first_name,
99
+							'surnames' => $surnames,
100
+							'email' => $email,
101
+							'role' => 1,
102
+							'school_id' => NULL,
103
+							'has_access' => 1
104
+						));
105
+						break;
106
+
107
+					case '2':
108
+						User::create(array(
109
+							'first_name' => $first_name,
110
+							'surnames' => $surnames,
111
+							'email' => $email,
112
+							'role' => 2,
113
+							'school_id' => (int)Input::get('new_school'), // como que aqui
114
+							'has_access' => 1
115
+						));
116
+
117
+						break;
118
+
119
+					case '3':
120
+						$user = User::create(array(
121
+							'first_name' => $first_name,
122
+							'surnames' => $surnames,
123
+							'email' => $email,
124
+							'role' => 3,
125
+							'school_id' => NULL,
126
+							'has_access' => 1
127
+						));
128
+
129
+						// Attach new programs
130
+						foreach (Input::get('programs') as $key => $program_id) {
131
+							$user->programs()->attach($program_id);
132
+						}
133
+
134
+						$user->save();
135
+						break;
136
+
137
+					case '4':
138
+
139
+						$user = User::create(array(
140
+							'first_name' => $first_name,
141
+							'surnames' => $surnames,
142
+							'email' => $email,
143
+							'role' => 4,
144
+							'school_id' => NULL,
145
+							'has_access' => 1
146
+						));
147
+
148
+						// Attach new programs
149
+						foreach (Input::get('new_programs') as $key => $program_id) {
150
+							$user->programs()->attach($program_id);
151
+						}
152
+						$user->save();
153
+						break;
154
+				}
155
+
156
+				DB::commit();
157
+
158
+				Session::flash('status', 'success');
159
+				Session::flash('message', 'User created (' . date('m/d/y h:i:s A') . ')');
160
+				return Redirect::back();
161
+			} catch (Exception $e) {
162
+				DB::rollBack();
163
+
164
+				Session::flash('status', 'danger');
165
+				Session::flash('message', 'Error creating. Try again later or contact the system administrator.');
166
+
167
+				return Redirect::back();
168
+			}
169
+		} else
170
+			App::abort('404');
171
+	}
182 172
 
183 173
 	/**
184 174
 	 * Update the user in storage.
@@ -187,230 +177,197 @@ class UsersController extends \BaseController {
187 177
 	 * @return Response
188 178
 	 */
189 179
 	public function update()
190
-    {
191
-    	$user = Auth::user();
192
-        if(Input::get('submit_contact_info'))
193
-    	{
194
-	        // Validation rules
195
-	        $validator = Validator::make(
196
-	            array(
197
-                    'office_phone' => Input::get('office_phone'),
198
-                    'office_extension' => Input::get('office_extension'),
199
-	                'cell_phone' => Input::get('cell_phone'),
200
-	            ),
201
-	            array(
202
-                    'office_phone' => 'string|max:20|required_with:office_extension',
203
-	                'office_extension' => 'digits_between:1,5|required_with:office_phone|unique:users,office_extension,'.$user->id,
204
-                    'cell_phone' => 'string|max:20'
205
-	            )
206
-	        );
207
-
208
-	        /** If validation fails */
209
-	        if ($validator->fails())
210
-	        {
211
-	            /** Prepare error message */
212
-	            $message = 'Error(s) updating your Contact nformation<ul>';
213
-
214
-	            foreach ($validator->messages()->all('<li>:message</li>') as $validationError)
215
-	            {
216
-	                $message.=$validationError;
217
-	            }
218
-
219
-	            $message.='</ul>';
220
-
221
-	            /** Send error message and old data */
222
-	            Session::flash('status', 'danger');
223
-	            Session::flash('message', $message);
224
-	            return Redirect::back()->withInput();
225
-	        }
226
-	        else
227
-	        {
228
-	            /** Set new contact info */
229
-	            if(Input::get('office_phone'))
230
-                {
231
-                    $user->office_phone = Input::get('office_phone');
232
-                    $user->office_extension = Input::get('office_extension');
233
-                }
234
-				else
235
-				{
180
+	{
181
+		$user = Auth::user();
182
+		if (Input::get('submit_contact_info')) {
183
+			// Validation rules
184
+			$validator = Validator::make(
185
+				array(
186
+					'office_phone' => Input::get('office_phone'),
187
+					'office_extension' => Input::get('office_extension'),
188
+					'cell_phone' => Input::get('cell_phone'),
189
+				),
190
+				array(
191
+					'office_phone' => 'string|max:20|required_with:office_extension',
192
+					'office_extension' => 'digits_between:1,5|required_with:office_phone|unique:users,office_extension,' . $user->id,
193
+					'cell_phone' => 'string|max:20'
194
+				)
195
+			);
196
+
197
+			/** If validation fails */
198
+			if ($validator->fails()) {
199
+				/** Prepare error message */
200
+				$message = 'Error(s) updating your Contact nformation<ul>';
201
+
202
+				foreach ($validator->messages()->all('<li>:message</li>') as $validationError) {
203
+					$message .= $validationError;
204
+				}
205
+
206
+				$message .= '</ul>';
207
+
208
+				/** Send error message and old data */
209
+				Session::flash('status', 'danger');
210
+				Session::flash('message', $message);
211
+				return Redirect::back()->withInput();
212
+			} else {
213
+				/** Set new contact info */
214
+				if (Input::get('office_phone')) {
215
+					$user->office_phone = Input::get('office_phone');
216
+					$user->office_extension = Input::get('office_extension');
217
+				} else {
236 218
 					$user->office_phone = NULL;
237
-                    $user->office_extension = NULL;
219
+					$user->office_extension = NULL;
220
+				}
221
+
222
+				if (Input::get('cell_phone')) {
223
+					$user->cell_phone = Input::get('cell_phone');
224
+				} else {
225
+					$user->cell_phone = NULL;
226
+				}
227
+
228
+				/** If alt email is updated, send success message */
229
+				if ($user->save()) {
230
+					Session::flash('status', 'success');
231
+					Session::flash('message', 'Contact Information updated.');
232
+					return Redirect::back();
238 233
 				}
239 234
 
240
-                if(Input::get('cell_phone'))
241
-                {
242
-                    $user->cell_phone = Input::get('cell_phone');
243
-                }
244
-				else
245
-				{
246
-                    $user->cell_phone = NULL;
235
+				/** If saving fails, send error message and old data */
236
+				else {
237
+					Session::flash('status', 'warning');
238
+					Session::flash('message', 'Error updating your Contact Information. Please try again later.');
239
+					return Redirect::back()->withInput();
247 240
 				}
241
+			}
242
+		} else if (Input::get('submit_roles') && Auth::user()->role == 1) {
243
+			try {
244
+				$exception = DB::transaction(function () {
245
+					$user = User::find(Input::get('id'));
246
+
247
+					switch (Input::get('role')) {
248
+						case '1':
249
+							$user->role = 1;
250
+							$user->school_id = NULL;
251
+
252
+							// Delete all programs associated to the user
253
+							$user->programs()->detach();
248 254
 
249
-	            /** If alt email is updated, send success message */
250
-	            if($user->save())
251
-	            {
252
-	                Session::flash('status', 'success');
253
-	                Session::flash('message', 'Contact Information updated.');
254
-	                return Redirect::back();
255
-	            }
256
-
257
-	            /** If saving fails, send error message and old data */
258
-	            else
259
-	            {
260
-	                Session::flash('status', 'warning');
261
-	                Session::flash('message', 'Error updating your Contact Information. Please try again later.');
262
-	                return Redirect::back()->withInput();
263
-	            }
264
-	        }
265
-	    }
266
-
267
-	    else if(Input::get('submit_roles') && Auth::user()->role==1)
268
-	    {
269
-	        try
270
-	        {
271
-	            $exception = DB::transaction(function()
272
-	            {
273
-                    $user = User::find(Input::get('id'));
274
-
275
-                    switch (Input::get('role')) {
276
-                    	case '1':
277
-                    		$user->role = 1;
278
-                    		$user->school_id = NULL;
279
-
280
-                    		// Delete all programs associated to the user
281
-                    		$user->programs()->detach();
282
-
283
-                    		$user->has_access = 1;
284
-
285
-                    		break;
286
-
287
-                    	case '2':
288
-                    		$user->role = 2;
289
-                    		$user->school_id = Input::get('school');
290
-
291
-                    		// Delete all programs associated to the user
292
-                    		$user->programs()->detach();
293
-
294
-
295
-                    		break;
296
-
297
-                    	case '3':
298
-                    		$user->role = 3;
299
-                    		$user->school_id = NULL;
300
-
301
-                    		// Delete all programs associated to the user
302
-                    		$user->programs()->detach();
303
-
304
-                    		// Attach new programs
305
-                    		foreach (Input::get('programs') as $key => $program_id)
306
-                    		{
307
-                    			$user->programs()->attach($program_id);
308
-                    		}
309
-                    		// $user->program_id = Input::get('program');
310
-
311
-                    		break;
312
-
313
-                    	case '4':
314
-                    		$user->role = 4;
315
-                    		$user->school_id = NULL;
316
-
317
-                    		// Delete all programs associated to the user
318
-                    		$user->programs()->detach();
319
-
320
-                    		// Attach new programs
321
-                    		foreach (Input::get('programs') as $key => $program_id)
322
-                    		{
323
-                    			$user->programs()->attach($program_id);
324
-                    		}
325
-                    		// $user->program_id = Input::get('program');
326
-
327
-                    		break;
328
-                    }
329
-
330
-                    $user->has_access = Input::get('has_access');
331
-                    $user->save();
332
-
333
-	            });
334
-
335
-	            if(is_null($exception))
336
-	            {
337
-	                Session::flash('status', 'success');
338
-	                Session::flash('message', 'User <b>'.User::find(Input::get('id'))->email.'</b> updated ('.date('m/d/y h:i:s A').'). To ensure proper access, click \'Update\' in the \'Access Level\' section at the bottom of the page.');
339
-	                return Redirect::back();
340
-	            }
341
-
342
-	        }
343
-	        catch(Exception $e)
344
-	        {
345
-	            Session::flash('status', 'danger');
346
-	            Session::flash('message', 'Error updating users. Try again later.');
347
-
348
-	            return Redirect::back();
349
-	        }
350
-	    }
351
-	    else
352
-	    	App::abort('403');
353
-    }
354
-
355
-    public function updateAccess()
356
-    {
357
-    	try
358
-        {
359
-            $exception = DB::transaction(function()
360
-            {
361
-                switch (Input::get('access_level')) {
362
-		    		case '1':
363
-		    			DB::table('users')
364
-			            ->whereIn('role', array(1))
365
-			            ->update(array('has_access' => 1));
366
-
367
-			            DB::table('users')
368
-			            ->whereIn('role', array(2, 3, 4))
369
-			            ->update(array('has_access' => 0));
370
-		    			break;
371
-
372
-		    		case '2':
373
-		    			DB::table('users')
374
-			            ->whereIn('role', array(1, 2))
375
-			            ->update(array('has_access' => 1));
376
-
377
-			            DB::table('users')
378
-			            ->whereIn('role', array(3, 4))
379
-			            ->update(array('has_access' => 0));
380
-		    			break;
381
-
382
-		    		case '3':
383
-		    			DB::table('users')
384
-			            ->whereIn('role', array(1, 2, 3))
385
-			            ->update(array('has_access' => 1));
386
-
387
-			            DB::table('users')
388
-			            ->whereIn('role', array(4))
389
-			            ->update(array('has_access' => 0));
390
-		    			break;
391
-
392
-		    		case '4':
393
-		    			DB::table('users')
394
-			            ->whereIn('role', array(1, 2, 3, 4))
395
-			            ->update(array('has_access' => 1));
396
-		    			break;
397
-		    	}
398
-            });
399
-
400
-            if(is_null($exception))
401
-            {
402
-                Session::flash('status', 'success');
403
-                Session::flash('message', 'Access level updated ('.date('m/d/y, h:i:s a').').');
404
-            }
405
-
406
-        }
407
-        catch(Exception $e)
408
-        {
409
-            Session::flash('status', 'danger');
410
-            Session::flash('message', 'Error updating access level. Try again later ('.date('m/d/y, h:i:s a').').');
411
-        }
412
-
413
-        return Redirect::back();
414
-    }
255
+							$user->has_access = 1;
415 256
 
257
+							break;
258
+
259
+						case '2':
260
+							$user->role = 2;
261
+							$user->school_id = Input::get('school');
262
+
263
+							// Delete all programs associated to the user
264
+							$user->programs()->detach();
265
+
266
+
267
+							break;
268
+
269
+						case '3':
270
+							$user->role = 3;
271
+							$user->school_id = NULL;
272
+
273
+							// Delete all programs associated to the user
274
+							$user->programs()->detach();
275
+
276
+							// Attach new programs
277
+							foreach (Input::get('programs') as $key => $program_id) {
278
+								$user->programs()->attach($program_id);
279
+							}
280
+							// $user->program_id = Input::get('program');
281
+
282
+							break;
283
+
284
+						case '4':
285
+							$user->role = 4;
286
+							$user->school_id = NULL;
287
+
288
+							// Delete all programs associated to the user
289
+							$user->programs()->detach();
290
+
291
+							// Attach new programs
292
+							foreach (Input::get('programs') as $key => $program_id) {
293
+								$user->programs()->attach($program_id);
294
+							}
295
+							// $user->program_id = Input::get('program');
296
+
297
+							break;
298
+					}
299
+
300
+					$user->has_access = Input::get('has_access');
301
+					$user->save();
302
+				});
303
+
304
+				if (is_null($exception)) {
305
+					Session::flash('status', 'success');
306
+					Session::flash('message', 'User <b>' . User::find(Input::get('id'))->email . '</b> updated (' . date('m/d/y h:i:s A') . '). To ensure proper access, click \'Update\' in the \'Access Level\' section at the bottom of the page.');
307
+					return Redirect::back();
308
+				}
309
+			} catch (Exception $e) {
310
+				Session::flash('status', 'danger');
311
+				Session::flash('message', 'Error updating users. Try again later.');
312
+
313
+				return Redirect::back();
314
+			}
315
+		} else
316
+			App::abort('403');
317
+	}
318
+
319
+	public function updateAccess()
320
+	{
321
+		try {
322
+			$exception = DB::transaction(function () {
323
+				switch (Input::get('access_level')) {
324
+					case '1':
325
+						DB::table('users')
326
+							->whereIn('role', array(1))
327
+							->update(array('has_access' => 1));
328
+
329
+						DB::table('users')
330
+							->whereIn('role', array(2, 3, 4))
331
+							->update(array('has_access' => 0));
332
+						break;
333
+
334
+					case '2':
335
+						DB::table('users')
336
+							->whereIn('role', array(1, 2))
337
+							->update(array('has_access' => 1));
338
+
339
+						DB::table('users')
340
+							->whereIn('role', array(3, 4))
341
+							->update(array('has_access' => 0));
342
+						break;
343
+
344
+					case '3':
345
+						DB::table('users')
346
+							->whereIn('role', array(1, 2, 3))
347
+							->update(array('has_access' => 1));
348
+
349
+						DB::table('users')
350
+							->whereIn('role', array(4))
351
+							->update(array('has_access' => 0));
352
+						break;
353
+
354
+					case '4':
355
+						DB::table('users')
356
+							->whereIn('role', array(1, 2, 3, 4))
357
+							->update(array('has_access' => 1));
358
+						break;
359
+				}
360
+			});
361
+
362
+			if (is_null($exception)) {
363
+				Session::flash('status', 'success');
364
+				Session::flash('message', 'Access level updated (' . date('m/d/y, h:i:s a') . ').');
365
+			}
366
+		} catch (Exception $e) {
367
+			Session::flash('status', 'danger');
368
+			Session::flash('message', 'Error updating access level. Try again later (' . date('m/d/y, h:i:s a') . ').');
369
+		}
370
+
371
+		return Redirect::back();
372
+	}
416 373
 }

+ 47
- 0
app/database/migrations/2020_10_04_142756_create_new_assessments_table.php View File

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

+ 52
- 0
app/database/migrations/2020_10_05_124915_create_activity_criterion_table.php View File

@@ -0,0 +1,52 @@
1
+<?php
2
+
3
+use Illuminate\Database\Schema\Blueprint;
4
+use Illuminate\Database\Migrations\Migration;
5
+
6
+class CreateActivityCriterionTable extends Migration {
7
+
8
+	/**
9
+	 * Run the migrations.
10
+	 *
11
+	 * @return void
12
+	 */
13
+	public function up()
14
+	{
15
+		Schema::create('activity_criterion', function(Blueprint $table)
16
+		{
17
+			$table->increments('id');
18
+			$table->integer('activity_id')->unsigned();
19
+			$table->integer('criterion_id')->unsigned();
20
+			$table
21
+				->foreign('activity_id')
22
+				->references('id')
23
+				->on('activities')
24
+				->onDelete('cascade')
25
+				->onUpdate('cascade');
26
+			$table
27
+				->foreign('criterion_id')
28
+				->references('id')
29
+				->on('criteria')
30
+				->onDelete('cascade')
31
+				->onUpdate('cascade');
32
+			$table->text('transformative_actions')->nullable();
33
+			$table->integer('expected_student_score')->nullable();
34
+			$table->decimal('expected_percentage_students_achieving', 5, 2)->nullable();
35
+			$table->decimal('percentage_students_who_achieved', 5, 2)->nullable();
36
+			$table->decimal('weight', 3, 2)->default(1.0);
37
+			$table->timestamps();
38
+		});
39
+	
40
+	}
41
+
42
+	/**
43
+	 * Reverse the migrations.
44
+	 *
45
+	 * @return void
46
+	 */
47
+	public function down()
48
+	{
49
+		Schema::drop('activity_criterion');
50
+	}
51
+
52
+}

+ 35
- 0
app/database/migrations/2020_10_05_130252_add_max_score_num_scales_new_criteria_table.php View File

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

+ 35
- 0
app/database/migrations/2020_10_05_142424_create_scales_table.php View File

@@ -0,0 +1,35 @@
1
+<?php
2
+
3
+use Illuminate\Database\Schema\Blueprint;
4
+use Illuminate\Database\Migrations\Migration;
5
+
6
+class CreateScalesTable extends Migration {
7
+
8
+	/**
9
+	 * Run the migrations.
10
+	 *
11
+	 * @return void
12
+	 */
13
+	public function up()
14
+	{
15
+		Schema::create('scales', function(Blueprint $table)
16
+		{
17
+			$table->increments('id');
18
+			$table->integer('position');
19
+			$table->string('title');
20
+			$table->string('description');
21
+			$table->timestamps();
22
+		});
23
+	}
24
+
25
+	/**
26
+	 * Reverse the migrations.
27
+	 *
28
+	 * @return void
29
+	 */
30
+	public function down()
31
+	{
32
+		Schema::drop('scales');
33
+	}
34
+
35
+}

+ 47
- 0
app/database/migrations/2020_10_05_142912_create_criterion_scale_table.php View File

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

+ 34
- 0
app/database/migrations/2020_10_05_232429_add_assessment_comments_to_activity_criterion.php View File

@@ -0,0 +1,34 @@
1
+<?php
2
+
3
+use Illuminate\Database\Schema\Blueprint;
4
+use Illuminate\Database\Migrations\Migration;
5
+
6
+class AddAssessmentCommentsToActivityCriterion extends Migration {
7
+
8
+	/**
9
+	 * Run the migrations.
10
+	 *
11
+	 * @return void
12
+	 */
13
+	public function up()
14
+	{
15
+		Schema::table('activity_criterion', function(Blueprint $table)
16
+		{
17
+			$table->text('assessment_comments')->after('transformative_actions')->nullable();
18
+		});
19
+	}
20
+
21
+	/**
22
+	 * Reverse the migrations.
23
+	 *
24
+	 * @return void
25
+	 */
26
+	public function down()
27
+	{
28
+		Schema::table('activity_criterion', function(Blueprint $table)
29
+		{
30
+			$table->drop('assessment_comments');
31
+		});
32
+	}
33
+
34
+}

+ 36
- 0
app/database/migrations/2020_10_09_131800_add_level_activation_date_to_outcomes.php View File

@@ -0,0 +1,36 @@
1
+<?php
2
+
3
+use Illuminate\Database\Schema\Blueprint;
4
+use Illuminate\Database\Migrations\Migration;
5
+
6
+class AddLevelActivationDateToOutcomes extends Migration {
7
+
8
+	/**
9
+	 * Run the migrations.
10
+	 *
11
+	 * @return void
12
+	 */
13
+	public function up()
14
+	{
15
+		Schema::table('outcomes', function(Blueprint $table)
16
+		{
17
+			$table->smallInteger('level');
18
+			$table->date('activation_date');
19
+		});
20
+	}
21
+
22
+	/**
23
+	 * Reverse the migrations.
24
+	 *
25
+	 * @return void
26
+	 */
27
+	public function down()
28
+	{
29
+		Schema::table('outcomes', function(Blueprint $table)
30
+		{
31
+			$table->drop('level')->default(1);
32
+			$table->drop('activation_date');
33
+		});
34
+	}
35
+
36
+}

+ 53
- 0
app/database/migrations/2020_10_16_190923_create_criterion_objective_outcome_table.php View File

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

+ 57
- 0
app/database/migrations/2020_10_18_145108_create_outcome_performance_table.php View File

@@ -0,0 +1,57 @@
1
+<?php
2
+
3
+use Illuminate\Database\Schema\Blueprint;
4
+use Illuminate\Database\Migrations\Migration;
5
+
6
+class CreateOutcomePerformanceTable extends Migration {
7
+
8
+	/**
9
+	 * Run the migrations.
10
+	 *
11
+	 * @return void
12
+	 */
13
+	public function up()
14
+	{
15
+		Schema::create('outcome_performance', function(Blueprint $table)
16
+		{
17
+			$table->increments('id');
18
+			$table->integer('criterion_id')->unsigned();
19
+			$table->integer('outcome_id')->unsigned();
20
+			$table->integer('semester_id')->unsigned();
21
+			$table->integer('students_attempted');
22
+			$table->integer('students_achieved');
23
+			$table->smallInteger('level');
24
+			$table
25
+				->foreign('criterion_id')
26
+				->references('id')
27
+				->on('criteria')
28
+				->onDelete('cascade')
29
+				->onUpdate('cascade');
30
+			$table
31
+				->foreign('outcome_id')
32
+				->references('id')
33
+				->on('outcomes')
34
+				->onDelete('cascade')
35
+				->onUpdate('cascade');
36
+			$table
37
+				->foreign('semester_id')
38
+				->references('id')
39
+				->on('semesters')
40
+				->onDelete('cascade')
41
+				->onUpdate('cascade');
42
+
43
+			$table->timestamps();
44
+		});
45
+	}
46
+
47
+	/**
48
+	 * Reverse the migrations.
49
+	 *
50
+	 * @return void
51
+	 */
52
+	public function down()
53
+	{
54
+		Schema::drop('outcome_performance');
55
+	}
56
+
57
+}

+ 30
- 0
app/database/migrations/2020_10_29_122332_MakeOutcomeNullable.php View File

@@ -0,0 +1,30 @@
1
+<?php
2
+
3
+use Illuminate\Database\Schema\Blueprint;
4
+use Illuminate\Database\Migrations\Migration;
5
+
6
+class MakeOutcomeNullable extends Migration
7
+{
8
+
9
+	/**
10
+	 * Run the migrations.
11
+	 *
12
+	 * @return void
13
+	 */
14
+	public function up()
15
+	{
16
+		Schema::table('objectives', function (Blueprint $table) {
17
+			$table->dropForeign('objectives_outcome_id_foreign');
18
+		});
19
+	}
20
+
21
+	/**
22
+	 * Reverse the migrations.
23
+	 *
24
+	 * @return void
25
+	 */
26
+	public function down()
27
+	{
28
+		//
29
+	}
30
+}

+ 30
- 0
app/database/migrations/2020_10_29_195413_MakeObjectiveNullable.php View File

@@ -0,0 +1,30 @@
1
+<?php
2
+
3
+use Illuminate\Database\Schema\Blueprint;
4
+use Illuminate\Database\Migrations\Migration;
5
+
6
+class MakeObjectiveNullable extends Migration
7
+{
8
+
9
+	/**
10
+	 * Run the migrations.
11
+	 *
12
+	 * @return void
13
+	 */
14
+	public function up()
15
+	{
16
+		Schema::table('new_criteria', function (Blueprint $table) {
17
+			$table->dropForeign('new_criteria_objective_id_foreign');
18
+		});
19
+	}
20
+
21
+	/**
22
+	 * Reverse the migrations.
23
+	 *
24
+	 * @return void
25
+	 */
26
+	public function down()
27
+	{
28
+		//
29
+	}
30
+}

+ 30
- 0
app/database/migrations/2020_10_29_224846_Make_criterion_objective_outcome_changeForeignKey.php View File

@@ -0,0 +1,30 @@
1
+<?php
2
+
3
+use Illuminate\Database\Schema\Blueprint;
4
+use Illuminate\Database\Migrations\Migration;
5
+
6
+class MakeCriterionObjectiveOutcomeChangeForeignKey extends Migration
7
+{
8
+
9
+	/**
10
+	 * Run the migrations.
11
+	 *
12
+	 * @return void
13
+	 */
14
+	public function up()
15
+	{
16
+		Schema::table('criterion_objective_outcome', function (Blueprint $table) {
17
+			$table->dropForeign('criterion_objective_outcome_criterion_id_foreign');
18
+			$table->foreign('criterion_id')->references('id')->on('new_criteria')->onDelete('cascade')->onUpdate('cascade');
19
+		});
20
+	}
21
+
22
+	/**
23
+	 * Reverse the migrations.
24
+	 *
25
+	 * @return void
26
+	 */
27
+	public function down()
28
+	{
29
+	}
30
+}

+ 35
- 0
app/database/migrations/2020_11_06_011242_changeCriteriaObjOutcome.php View File

@@ -0,0 +1,35 @@
1
+<?php
2
+
3
+use Illuminate\Database\Schema\Blueprint;
4
+use Illuminate\Database\Migrations\Migration;
5
+use Illuminate\Support\Facades\Schema;
6
+
7
+class ChangeCriteriaObjOutcome extends Migration
8
+{
9
+
10
+	/**
11
+	 * Run the migrations.
12
+	 *
13
+	 * @return void
14
+	 */
15
+	public function up()
16
+	{
17
+		Schema::table('criterion_objective_outcome', function (Blueprint $table) {
18
+			//$table->dropForeign('criterion_objective_outcome_objective_id_foreign');
19
+			//$table->dropForeign('criterion_objective_outcome_outcome_id_foreign');
20
+			//$table->integer('objective_outcome_id');
21
+			DB::statement("ALTER TABLE `criterion_objective_outcome` CHANGE COLUMN `objective_outcome_id` `objective_outcome_id` INT(10) UNSIGNED NOT NULL");
22
+			$table->foreign('objective_outcome_id')->references('id')->on('objective_outcome')->onDelete('cascade')->onUpdate('cascade');
23
+		});
24
+	}
25
+
26
+	/**
27
+	 * Reverse the migrations.
28
+	 *
29
+	 * @return void
30
+	 */
31
+	public function down()
32
+	{
33
+		//
34
+	}
35
+}

+ 35
- 0
app/database/migrations/2020_12_04_111708_dropDescriptionInCriteria.php View File

@@ -0,0 +1,35 @@
1
+<?php
2
+
3
+use Illuminate\Database\Schema\Blueprint;
4
+use Illuminate\Database\Migrations\Migration;
5
+
6
+class DropDescriptionInCriteria extends Migration
7
+{
8
+
9
+	/**
10
+	 * Run the migrations.
11
+	 *
12
+	 * @return void
13
+	 */
14
+	public function up()
15
+	{
16
+		Schema::table('new_criteria', function (Blueprint $table) {
17
+
18
+			$table->dropColumn('description12');
19
+			$table->dropColumn('description34');
20
+			$table->dropColumn('description56');
21
+			$table->dropColumn('description78');
22
+			$table->dropColumn('objective_id');
23
+		});
24
+	}
25
+
26
+	/**
27
+	 * Reverse the migrations.
28
+	 *
29
+	 * @return void
30
+	 */
31
+	public function down()
32
+	{
33
+		//
34
+	}
35
+}

+ 44
- 0
app/database/migrations/2020_12_10_175517_createProgramCriterion2.php View File

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

+ 34
- 0
app/database/migrations/2020_12_10_223135_addMinMaxInScales.php View File

@@ -0,0 +1,34 @@
1
+<?php
2
+
3
+use Illuminate\Database\Schema\Blueprint;
4
+use Illuminate\Database\Migrations\Migration;
5
+
6
+class AddMinMaxInScales extends Migration
7
+{
8
+
9
+	/**
10
+	 * Run the migrations.
11
+	 *
12
+	 * @return void
13
+	 */
14
+	public function up()
15
+	{
16
+		Schema::table('scales', function (Blueprint $table) {
17
+			$table->integer('min_score')->unsigned();
18
+			$table->integer('max_score')->unsigned();
19
+		});
20
+	}
21
+
22
+	/**
23
+	 * Reverse the migrations.
24
+	 *
25
+	 * @return void
26
+	 */
27
+	public function down()
28
+	{
29
+		Schema::table('scales', function (Blueprint $table) {
30
+			$table->dropColumn('min_score');
31
+			$table->dropColumn('max_score');
32
+		});
33
+	}
34
+}

+ 30
- 0
app/database/migrations/emails/feedback-email-copy.blade.php View File

@@ -0,0 +1,30 @@
1
+<!DOCTYPE html>
2
+<html lang="en-US">
3
+	<head>
4
+		<meta charset="utf-8">
5
+	</head>
6
+	<body style="width: 960px;">
7
+		<div>{{HTML::image('/images/olas-email-header.png', 'OLAS Header Image', array('class'=>'logo img-responsive'))}}</div>		
8
+		<div>
9
+			<h2 style="color: #E70033;">Copy of your feedback for OLAS (no-reply)</h2>
10
+			
11
+			<hr style="border: 0; height: 0; border-top: 1px solid rgba(0, 0, 0, 0.1); border-bottom: 1px solid rgba(255, 255, 255, 0.3);">
12
+			<h3>Type: </h3>
13
+			<p>{{ $type }}</p>
14
+
15
+			<h3>Email: </h3>
16
+			<p>{{ $email }}</p>
17
+
18
+			<h3>Comment: </h3>
19
+			<p>{{ $comment }}</p>
20
+			<hr style="border: 0; height: 0; border-top: 1px solid rgba(0, 0, 0, 0.1); border-bottom: 1px solid rgba(255, 255, 255, 0.3);">
21
+
22
+			<p>This is an automatic email message. Please do not reply, as the inbox is not monitored.</p>
23
+
24
+			<p>Regards,</p>
25
+			<p style="color: #E70033;"><strong>OLAS UPRRP Administration<strong></p><br/>
26
+			
27
+
28
+		</div>
29
+	</body>
30
+</html>

app/database/migrations/2018_08_28_140328_remove_outcome_id_from_objectives_table.php → app/database/unusedMigrations/2018_08_28_140328_remove_outcome_id_from_objectives_table.php View File

@@ -3,7 +3,8 @@
3 3
 use Illuminate\Database\Migrations\Migration;
4 4
 use Illuminate\Database\Schema\Blueprint;
5 5
 
6
-class RemoveOutcomeIdFromObjectivesTable extends Migration {
6
+class RemoveOutcomeIdFromObjectivesTable extends Migration
7
+{
7 8
 
8 9
 	/**
9 10
 	 * Run the migrations.
@@ -12,9 +13,8 @@ class RemoveOutcomeIdFromObjectivesTable extends Migration {
12 13
 	 */
13 14
 	public function up()
14 15
 	{
15
-		Schema::table('objectives', function(Blueprint $table)
16
-		{
17
-            $table->dropForeign('objectives_outcome_id_foreign');
16
+		Schema::table('objectives', function (Blueprint $table) {
17
+			$table->dropForeign('objectives_outcome_id_foreign');
18 18
 			$table->dropColumn('outcome_id');
19 19
 		});
20 20
 	}
@@ -27,12 +27,11 @@ class RemoveOutcomeIdFromObjectivesTable extends Migration {
27 27
 	 */
28 28
 	public function down()
29 29
 	{
30
-		Schema::table('objectives', function(Blueprint $table)
31
-		{
32
-            $table
33
-                ->integer('outcome_id')
34
-                ->after('id')
35
-                ->unsigned();
30
+		Schema::table('objectives', function (Blueprint $table) {
31
+			$table
32
+				->integer('outcome_id')
33
+				->after('id')
34
+				->unsigned();
36 35
 			$table
37 36
 				->foreign('outcome_id')
38 37
 				->references('id')
@@ -41,5 +40,4 @@ class RemoveOutcomeIdFromObjectivesTable extends Migration {
41 40
 				->onUpdate('cascade');
42 41
 		});
43 42
 	}
44
-
45 43
 }

app/database/migrations/2020_04_04_005817_add_outcome_id_to_objectives_table.php → app/database/unusedMigrations/2020_04_04_005817_add_outcome_id_to_objectives_table.php View File


+ 52
- 0
app/database/unusedMigrations/2020_10_05_124915_create_activity_criterion_table.php View File

@@ -0,0 +1,52 @@
1
+<?php
2
+
3
+use Illuminate\Database\Schema\Blueprint;
4
+use Illuminate\Database\Migrations\Migration;
5
+
6
+class CreateActivityCriterionTable extends Migration {
7
+
8
+	/**
9
+	 * Run the migrations.
10
+	 *
11
+	 * @return void
12
+	 */
13
+	public function up()
14
+	{
15
+		Schema::create('activity_criterion', function(Blueprint $table)
16
+		{
17
+			$table->increments('id');
18
+			$table->integer('activity_id')->unsigned();
19
+			$table->integer('criterion_id')->unsigned();
20
+			$table
21
+				->foreign('activity_id')
22
+				->references('id')
23
+				->on('activities')
24
+				->onDelete('cascade')
25
+				->onUpdate('cascade');
26
+			$table
27
+				->foreign('criterion_id')
28
+				->references('id')
29
+				->on('criteria')
30
+				->onDelete('cascade')
31
+				->onUpdate('cascade');
32
+			$table->text('transformative_actions')->nullable();
33
+			$table->integer('expected_student_score')->nullable();
34
+			$table->decimal('expected_percentage_students_achieving', 5, 2)->nullable();
35
+			$table->decimal('percentage_students_who_achieved', 5, 2)->nullable();
36
+			$table->decimal('weight', 3, 2)->default(1.0);
37
+			$table->timestamps();
38
+		});
39
+	
40
+	}
41
+
42
+	/**
43
+	 * Reverse the migrations.
44
+	 *
45
+	 * @return void
46
+	 */
47
+	public function down()
48
+	{
49
+		Schema::drop('activity_criterion');
50
+	}
51
+
52
+}

+ 35
- 0
app/database/unusedMigrations/2020_10_05_130252_add_max_score_num_scales_new_criteria_table.php View File

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

+ 35
- 0
app/database/unusedMigrations/2020_10_05_142424_create_scales_table.php View File

@@ -0,0 +1,35 @@
1
+<?php
2
+
3
+use Illuminate\Database\Schema\Blueprint;
4
+use Illuminate\Database\Migrations\Migration;
5
+
6
+class CreateScalesTable extends Migration {
7
+
8
+	/**
9
+	 * Run the migrations.
10
+	 *
11
+	 * @return void
12
+	 */
13
+	public function up()
14
+	{
15
+		Schema::create('scales', function(Blueprint $table)
16
+		{
17
+			$table->increments('id');
18
+			$table->integer('position');
19
+			$table->string('title');
20
+			$table->string('description');
21
+			$table->timestamps();
22
+		});
23
+	}
24
+
25
+	/**
26
+	 * Reverse the migrations.
27
+	 *
28
+	 * @return void
29
+	 */
30
+	public function down()
31
+	{
32
+		Schema::drop('scales');
33
+	}
34
+
35
+}

+ 47
- 0
app/database/unusedMigrations/2020_10_05_142912_create_criterion_scale_table.php View File

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

+ 34
- 0
app/database/unusedMigrations/2020_10_05_232429_add_assessment_comments_to_activity_criterion.php View File

@@ -0,0 +1,34 @@
1
+<?php
2
+
3
+use Illuminate\Database\Schema\Blueprint;
4
+use Illuminate\Database\Migrations\Migration;
5
+
6
+class AddAssessmentCommentsToActivityCriterion extends Migration {
7
+
8
+	/**
9
+	 * Run the migrations.
10
+	 *
11
+	 * @return void
12
+	 */
13
+	public function up()
14
+	{
15
+		Schema::table('activity_criterion', function(Blueprint $table)
16
+		{
17
+			$table->text('assessment_comments')->after('transformative_actions')->nullable();
18
+		});
19
+	}
20
+
21
+	/**
22
+	 * Reverse the migrations.
23
+	 *
24
+	 * @return void
25
+	 */
26
+	public function down()
27
+	{
28
+		Schema::table('activity_criterion', function(Blueprint $table)
29
+		{
30
+			$table->drop('assessment_comments');
31
+		});
32
+	}
33
+
34
+}

+ 36
- 0
app/database/unusedMigrations/2020_10_08_203557_create_new_criteria_table2.php View File

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

+ 33
- 0
app/database/unusedMigrations/2020_10_08_215013_drop_objective_id_new_criteria.php View File

@@ -0,0 +1,33 @@
1
+<?php
2
+
3
+use Illuminate\Database\Schema\Blueprint;
4
+use Illuminate\Database\Migrations\Migration;
5
+
6
+class DropObjectiveIdNewCriteria extends Migration
7
+{
8
+
9
+	/**
10
+	 * Run the migrations.
11
+	 *
12
+	 * @return void
13
+	 */
14
+	public function up()
15
+	{
16
+		Schema::table('new_criteria', function ($table) {
17
+			$table->integer('objective_id')->nullable();
18
+		});
19
+	}
20
+
21
+	/**
22
+	 * Reverse the migrations.
23
+	 *
24
+	 * @return void
25
+	 */
26
+	public function down()
27
+	{
28
+		Schema::table('new_criteria', function ($table) {
29
+
30
+			$table->dropColumn('objective_id');
31
+		});
32
+	}
33
+}

+ 34
- 0
app/database/unusedMigrations/2020_10_09_085334_add_activities_rubric_id.php View File

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

+ 35
- 0
app/database/unusedMigrations/2020_10_09_092810_drop_assessment_criteria.php View File

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

+ 35
- 0
app/database/unusedMigrations/2020_10_09_094503_add_criterion_to_assessment.php View File

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

+ 29
- 0
app/database/unusedMigrations/2020_10_09_095246_drop_foreign_assesment_criterion.php View File

@@ -0,0 +1,29 @@
1
+<?php
2
+
3
+use Illuminate\Database\Schema\Blueprint;
4
+use Illuminate\Database\Migrations\Migration;
5
+
6
+class DropForeignAssesmentCriterion extends Migration
7
+{
8
+
9
+	/**
10
+	 * Run the migrations.
11
+	 *
12
+	 * @return void
13
+	 */
14
+	public function up()
15
+	{
16
+		Schema::table('assessments', function ($table) {
17
+			$table->dropForeign('assessments_criterion_id_foreign');
18
+		});
19
+	}
20
+
21
+	/**
22
+	 * Reverse the migrations.
23
+	 *
24
+	 * @return void
25
+	 */
26
+	public function down()
27
+	{
28
+	}
29
+}

+ 36
- 0
app/database/unusedMigrations/2020_10_09_131800_add_level_activation_date_to_outcomes.php View File

@@ -0,0 +1,36 @@
1
+<?php
2
+
3
+use Illuminate\Database\Schema\Blueprint;
4
+use Illuminate\Database\Migrations\Migration;
5
+
6
+class AddLevelActivationDateToOutcomes extends Migration {
7
+
8
+	/**
9
+	 * Run the migrations.
10
+	 *
11
+	 * @return void
12
+	 */
13
+	public function up()
14
+	{
15
+		Schema::table('outcomes', function(Blueprint $table)
16
+		{
17
+			$table->smallInteger('level');
18
+			$table->date('activation_date');
19
+		});
20
+	}
21
+
22
+	/**
23
+	 * Reverse the migrations.
24
+	 *
25
+	 * @return void
26
+	 */
27
+	public function down()
28
+	{
29
+		Schema::table('outcomes', function(Blueprint $table)
30
+		{
31
+			$table->drop('level')->default(1);
32
+			$table->drop('activation_date');
33
+		});
34
+	}
35
+
36
+}

+ 28
- 53
app/filters.php View File

@@ -11,19 +11,16 @@
11 11
 |
12 12
 */
13 13
 
14
-App::before(function($request)
15
-{
16
-	Log::debug('START '.Request::getClientIp().': '.Request::method().' '.Request::path());
17
-
18
-	if( ! Request::secure())
19
-    {
20
-        return Redirect::secure(Request::path());
21
-    }
14
+App::before(function ($request) {
15
+	Log::debug('START ' . Request::getClientIp() . ': ' . Request::method() . ' ' . Request::path());
16
+
17
+	//if (!Request::secure()) {
18
+	//	return Redirect::secure(Request::path());
19
+	//}
22 20
 });
23 21
 
24 22
 
25
-App::after(function($request, $response)
26
-{
23
+App::after(function ($request, $response) {
27 24
 	//
28 25
 });
29 26
 
@@ -38,37 +35,28 @@ App::after(function($request, $response)
38 35
 |
39 36
 */
40 37
 
41
-Route::filter('auth', function()
42
-{
43
-	if (Auth::guest())
44
-	{
45
-		if (Request::ajax())
46
-		{
38
+Route::filter('auth', function () {
39
+	if (Auth::guest()) {
40
+		if (Request::ajax()) {
47 41
 			return Response::make('Unauthorized', 401);
48
-		}
49
-		else
50
-		{
42
+		} else {
51 43
 			return Redirect::guest('/');
52 44
 		}
53 45
 	}
54 46
 });
55 47
 
56 48
 
57
-Route::filter('auth.basic', function()
58
-{
49
+Route::filter('auth.basic', function () {
59 50
 	return Auth::basic();
60 51
 });
61 52
 
62
-Route::filter('has_access', function()
63
-{
64
-	if(!Auth::user()->has_access)
65
-	{
53
+Route::filter('has_access', function () {
54
+	if (!Auth::user()->has_access) {
66 55
 		Session::flash('status', 'info');
67 56
 		Session::flash('message', 'At this time, access to OLAS is limited to some users. Check back later or contact an administrator.');
68 57
 		Auth::logout();
69 58
 		return Redirect::action('AuthController@showLogin');
70 59
 	}
71
-
72 60
 });
73 61
 /*
74 62
 |--------------------------------------------------------------------------
@@ -81,10 +69,8 @@ Route::filter('has_access', function()
81 69
 |
82 70
 */
83 71
 
84
-Route::filter('guest', function()
85
-{
86
-	if (Auth::check())
87
-	{
72
+Route::filter('guest', function () {
73
+	if (Auth::check()) {
88 74
 		switch (Auth::user()->role) {
89 75
 			case 1:
90 76
 				return Redirect::to('administrator');
@@ -115,10 +101,8 @@ Route::filter('guest', function()
115 101
 |
116 102
 */
117 103
 
118
-Route::filter('admin', function()
119
-{
120
-	if (Auth::user()->role !=1)
121
-	{
104
+Route::filter('admin', function () {
105
+	if (Auth::user()->role != 1) {
122 106
 		switch (Auth::user()->role) {
123 107
 			case 2:
124 108
 				return Redirect::to('school-coordinator');
@@ -145,13 +129,10 @@ Route::filter('admin', function()
145 129
 |
146 130
 */
147 131
 
148
-Route::filter('scoord', function()
149
-{
132
+Route::filter('scoord', function () {
150 133
 
151
-	if (!(Auth::user()->role ==2 || Auth::user()->role ==1))
152
-	{
153
-		switch (Auth::user()->role)
154
-		{
134
+	if (!(Auth::user()->role == 2 || Auth::user()->role == 1)) {
135
+		switch (Auth::user()->role) {
155 136
 
156 137
 			case 3:
157 138
 				return Redirect::to('program-coordinator');
@@ -174,10 +155,8 @@ Route::filter('scoord', function()
174 155
 |
175 156
 */
176 157
 
177
-Route::filter('pcoord', function()
178
-{
179
-	if (!(Auth::user()->role ==3 || Auth::user()->role ==2 || Auth::user()->role ==1))
180
-	{
158
+Route::filter('pcoord', function () {
159
+	if (!(Auth::user()->role == 3 || Auth::user()->role == 2 || Auth::user()->role == 1)) {
181 160
 		return Redirect::to('professor');
182 161
 	}
183 162
 });
@@ -192,12 +171,10 @@ Route::filter('pcoord', function()
192 171
 |
193 172
 */
194 173
 
195
-Route::filter('prof', function()
196
-{
174
+Route::filter('prof', function () {
197 175
 	// If user has no courses then s/he is not a professor
198 176
 	// and must be redirected to her/his overview page
199
-	if (!count(Auth::user()->courses))
200
-	{
177
+	if (!count(Auth::user()->courses)) {
201 178
 		switch (Auth::user()->role) {
202 179
 			case 1:
203 180
 				return Redirect::to('administrator');
@@ -225,11 +202,9 @@ Route::filter('prof', function()
225 202
 |
226 203
 */
227 204
 
228
-Route::filter('csrf', function()
229
-{
205
+Route::filter('csrf', function () {
230 206
 	$token = Request::ajax() ? Request::header('X-CSRF-Token') : Input::get('_token');
231
-	if (Session::token() !== $token)
232
-	{
233
-	  throw new Illuminate\Session\TokenMismatchException;
207
+	if (Session::token() !== $token) {
208
+		throw new Illuminate\Session\TokenMismatchException;
234 209
 	}
235 210
 });

+ 29
- 26
app/models/Objective.php View File

@@ -1,43 +1,46 @@
1 1
 <?php
2 2
 
3
+use Illuminate\Database\Eloquent\SoftDeletingTrait;
4
+
3 5
 class Objective extends Eloquent
4 6
 {
7
+    use SoftDeletingTrait;
8
+    protected $fillable = array('text', 'outcome_id', 'program_id', 'active');
9
+    protected $table = 'objectives';
5 10
 
6
-  protected $fillable = array('text', 'outcome_id', 'program_id', 'active');
11
+    /**
12
+     * Return the program that the objective belongs to
13
+     *
14
+     * @return Illuminate\Database\Eloquent\Model
15
+     */
16
+    public function program()
17
+    {
18
+        return $this->belongsTo('Program');
19
+    }
7 20
 
8
-  /**
9
-   * Return the program that the objective belongs to
10
-   *
11
-   * @return Illuminate\Database\Eloquent\Model
12
-   */
13
-  public function program()
14
-  {
15
-  	return $this->belongsTo('Program');
16
-  }
21
+    /**
22
+     * Return the outcomes that the objective belongs to
23
+     *
24
+     * @return Illuminate\Database\Eloquent\Model
25
+     */
17 26
 
18
-  /**
19
-   * Return the outcomes that the objective belongs to
20
-   *
21
-   * @return Illuminate\Database\Eloquent\Model
22
-   */
23
-  public function outcomes()
24
-  {
25
-  	return $this->belongsToMany('Outcome', 'objective_outcome', 'objective_id', 'outcome_id');
26
-  }
27
+    public function outcomes()
28
+    {
29
+        return $this->belongsToMany('Outcome', 'objective_outcome', 'objective_id', 'outcome_id');
30
+    }
27 31
 
28
-  public function outcome()
29
-  {
30
-      return $this->belongsTo('Outcome');
31
-  }
32
+    public function outcome()
33
+    {
34
+        return $this->belongsTo('Outcome');
35
+    }
32 36
 
33 37
     /**
34 38
      * Return the program that the objective belongs to
35 39
      *
36 40
      * @return Illuminate\Database\Eloquent\Model
37 41
      */
38
-    public function criteria()
42
+    public function outcome_id()
39 43
     {
40
-        return $this->hasMany('Criterion');
44
+        return $this->hasMany('Objective_Outcome', 'objective_id');
41 45
     }
42
-
43 46
 }

+ 38
- 0
app/models/Objective_Outcome.php View File

@@ -0,0 +1,38 @@
1
+<?php
2
+
3
+use Illuminate\Database\Eloquent\SoftDeletingTrait;
4
+
5
+class Objective_Outcome extends Eloquent
6
+{
7
+    use SoftDeletingTrait;
8
+    protected $fillable = array('outcome_id', 'objective_id');
9
+    protected $table = 'objective_outcome';
10
+
11
+    /**
12
+     * Return the program that the objective belongs to
13
+     *
14
+     * @return Illuminate\Database\Eloquent\Model
15
+     */
16
+    public function outcome()
17
+    {
18
+        return $this->belongsTo('Outcome');
19
+    }
20
+
21
+    /**
22
+     * Return the outcomes that the objective belongs to
23
+     *
24
+     * @return Illuminate\Database\Eloquent\Model
25
+     */
26
+
27
+
28
+
29
+    /**
30
+     * Return the program that the objective belongs to
31
+     *
32
+     * @return Illuminate\Database\Eloquent\Model
33
+     */
34
+    public function objective()
35
+    {
36
+        return $this->belongsTo('Objective');
37
+    }
38
+}

+ 0
- 7
app/models/Outcome.php View File

@@ -24,11 +24,4 @@ class Outcome extends Eloquent
24 24
 	    return $this->hasMany('Objective');
25 25
 //		return $this->belongsToMany('Objective', 'objective_outcome');
26 26
 	}
27
-
28
-	public static function active()
29
-    {
30
-        //TODO: Check when semester doesnt exist or session is empty
31
-        $selected_semester = Semester::find(Session::get('semesters_ids')[0]);
32
-        return Outcome::withTrashed()->where('deactivation_date', '>=', $selected_semester->start)->orWhere('deactivation_date', null)->orderBy('name', 'ASC')->get();
33
-    }
34 27
 }

+ 17
- 0
app/models/Scale.php View File

@@ -0,0 +1,17 @@
1
+<?php
2
+
3
+use Illuminate\Database\Eloquent\SoftDeletingTrait;
4
+
5
+class Scale extends Eloquent
6
+{
7
+    use SoftDeletingTrait;
8
+    protected $dates = ['deleted_at'];
9
+
10
+    protected $table = 'scales';
11
+
12
+    public function outcomes()
13
+    {
14
+        //	  
15
+
16
+    }
17
+}

+ 13
- 12
app/models/User.php View File

@@ -7,7 +7,8 @@ use Illuminate\Auth\Reminders\RemindableInterface;
7 7
 
8 8
 use Zizaco\Entrust\HasRole;
9 9
 
10
-class User extends Eloquent implements UserInterface, RemindableInterface {
10
+class User extends Eloquent implements UserInterface, RemindableInterface
11
+{
11 12
 
12 13
 	use UserTrait, RemindableTrait, HasRole;
13 14
 
@@ -31,17 +32,17 @@ class User extends Eloquent implements UserInterface, RemindableInterface {
31 32
 	protected $fillable = array('ssn', 'first_name', 'surnames', 'email', 'role', 'school_id', 'has_access', 'cell_phone', 'office_phone', 'office_extension');
32 33
 
33 34
 	/**
34
-     * Searchable rules.
35
-     *
36
-     * @var array
37
-     */
38
-    protected $searchable = [
39
-        'columns' => [
40
-            'first_name' => 10,
41
-            'surnames' => 10,
42
-            'email' => 2,
43
-        ],
44
-    ];
35
+	 * Searchable rules.
36
+	 *
37
+	 * @var array
38
+	 */
39
+	protected $searchable = [
40
+		'columns' => [
41
+			'first_name' => 10,
42
+			'surnames' => 10,
43
+			'email' => 2,
44
+		],
45
+	];
45 46
 
46 47
 
47 48
 	public function program()

+ 125
- 118
app/routes.php View File

@@ -33,8 +33,7 @@ View::composer(array(
33 33
     'local.managers.admins._navigation',
34 34
     'local.managers.sCoords._navigation',
35 35
     'local.managers.pCoords._navigation',
36
-    ), function($view)
37
-{
36
+), function ($view) {
38 37
     // Get user's courses' numbers
39 38
     $courses = Auth::user()->courses;
40 39
 
@@ -54,10 +53,10 @@ View::composer(array(
54 53
     'local.managers.shared.program',
55 54
     'local.managers.shared.rubrics',
56 55
     'global.view-learning-outcomes-criteria',
57
-    'global.view-learning-outcomes-criteria'), function($view)
58
-    {
59
-        $view->with('role', Auth::user()->role);
60
-    });
56
+    'global.view-learning-outcomes-criteria'
57
+), function ($view) {
58
+    $view->with('role', Auth::user()->role);
59
+});
61 60
 
62 61
 
63 62
 /*
@@ -66,33 +65,29 @@ View::composer(array(
66 65
 
67 66
 /** Use modified guest filter to redirect logged in user */
68 67
 Route::get('/', array('before' => 'guest', 'uses' => 'AuthController@showLogin'));
69
-Route::post('/login', array('uses'=>'AuthController@login'));
68
+Route::post('/login', array('uses' => 'AuthController@login'));
70 69
 
71 70
 /**
72 71
  * Protected Routes
73 72
  */
74
-Route::group(array('before' => 'auth|has_access'), function()
75
-{
73
+Route::group(array('before' => 'auth|has_access'), function () {
76 74
 
77 75
     /**
78 76
      * Recalculate course outcomes
79 77
      *
80
-    */
78
+     */
81 79
 
82
-    Route::get('recalculateCourses', function()
83
-    {
80
+    Route::get('recalculateCourses', function () {
84 81
 
85 82
         DB::disableQueryLog();
86 83
 
87
-        if(Auth::user()->id!=58)
84
+        if (Auth::user()->id != 58)
88 85
             Redirect::action('AuthController@showLogin');
89 86
 
90
-        try
91
-        {
87
+        try {
92 88
             $courses = Course::all();
93 89
 
94
-            foreach ($courses as $course)
95
-            {
90
+            foreach ($courses as $course) {
96 91
                 echo $course->id;
97 92
                 // Recalculate course outcomes
98 93
                 $activities = Activity::where('course_id', $course->id)
@@ -102,8 +97,7 @@ Route::group(array('before' => 'auth|has_access'), function()
102 97
 
103 98
 
104 99
                 //If there are still evaluated activities in the course, recalculate course outcomes
105
-                if(!$activities->isEmpty())
106
-                {
100
+                if (!$activities->isEmpty()) {
107 101
                     $outcomeCount = Outcome::all()->count();
108 102
 
109 103
                     // Variables to hold recalculated outcomes for the course
@@ -111,104 +105,108 @@ Route::group(array('before' => 'auth|has_access'), function()
111 105
                     $course_outcomes_achieved = array_fill(1, $outcomeCount, 0);
112 106
 
113 107
                     // For each activity
114
-                    foreach ($activities as $activity2)
115
-                    {
108
+                    foreach ($activities as $activity2) {
116 109
                         // If activity has been assessed
117
-                        if($activity2->outcomes_attempted!=NULL)
118
-                        {
110
+                        if ($activity2->outcomes_attempted != NULL) {
119 111
                             echo '<ul>';
120 112
                             // Get the achieved criteria
121 113
                             $criteria_achievement = json_decode($activity2->criteria_achieved, true);
122
-                            foreach($criteria_achievement as $criterion_id=>$criterion_achieved)
123
-                            {
114
+                            foreach ($criteria_achievement as $criterion_id => $criterion_achieved) {
124 115
                                 // Find corresponding learning outcome;
125 116
                                 $criterion = Criterion::withTrashed()->where('id', $criterion_id)->first();
126 117
 
127
-                                print '<li>'.$criterion->id.'</li>';
118
+                                print '<li>' . $criterion->id . '</li>';
128 119
 
129 120
 
130 121
                                 $outcome = Outcome::find($criterion->outcome_id);
131 122
 
132 123
                                 // If criterion is achieved (1), add 1 to both arrays
133
-                                if($criterion_achieved === 1)
134
-                                {
135
-                                    $course_outcomes_attempted[$outcome->id]+=1;
136
-                                    $course_outcomes_achieved[$outcome->id]+=1;
124
+                                if ($criterion_achieved === 1) {
125
+                                    $course_outcomes_attempted[$outcome->id] += 1;
126
+                                    $course_outcomes_achieved[$outcome->id] += 1;
137 127
                                 }
138 128
                                 // Else, only add to the attempted outcomes arrays
139
-                                elseif($criterion_achieved === 0)
140
-                                {
141
-                                    $course_outcomes_attempted[$outcome->id]+=1;
129
+                                elseif ($criterion_achieved === 0) {
130
+                                    $course_outcomes_attempted[$outcome->id] += 1;
142 131
                                 }
143 132
                             }
144 133
 
145 134
                             echo '</ul>';
146
-
147 135
                         }
148 136
                     }
149 137
 
150 138
                     // Update course
151 139
                     DB::table('courses')
152
-                    ->where('id', $course->id)
153
-                    ->update(array(
154
-                        'outcomes_attempted'=> json_encode($course_outcomes_attempted),
155
-                        'outcomes_achieved'=> json_encode($course_outcomes_achieved),
156
-                        'updated_at' => date('Y-m-d H:i:s'))
157
-                    );
140
+                        ->where('id', $course->id)
141
+                        ->update(array(
142
+                            'outcomes_attempted' => json_encode($course_outcomes_attempted),
143
+                            'outcomes_achieved' => json_encode($course_outcomes_achieved),
144
+                            'updated_at' => date('Y-m-d H:i:s')
145
+                        ));
158 146
                 }
159 147
                 // Otherwise, set them all to NULL
160
-                else
161
-                {
148
+                else {
162 149
                     DB::table('courses')
163
-                    ->where('id', $course->id)
164
-                    ->update(array(
165
-                        'outcomes_attempted'=> NULL,
166
-                        'outcomes_achieved'=> NULL,
167
-                        'updated_at' => date('Y-m-d H:i:s'))
168
-                    );
150
+                        ->where('id', $course->id)
151
+                        ->update(array(
152
+                            'outcomes_attempted' => NULL,
153
+                            'outcomes_achieved' => NULL,
154
+                            'updated_at' => date('Y-m-d H:i:s')
155
+                        ));
169 156
                 }
170 157
             }
171 158
 
172 159
             return 'success';
173
-        }
174
-        catch(Exception $e)
175
-        {
176
-            return 'failure ('.$e->getLine().'): '.$e->getMessage();
160
+        } catch (Exception $e) {
161
+            return 'failure (' . $e->getLine() . '): ' . $e->getMessage();
177 162
         }
178 163
     });
179 164
 
180 165
     /**
181
-    * Shared Routes
182
-    */
166
+     * Shared Routes
167
+     */
183 168
 
184 169
     // Fetch all criteria associated to an outcome
185
-    Route::post( 'fetchCriteria', array(
170
+    Route::post('fetchCriteria', array(
186 171
         'as' => 'fetchCriteria',
187 172
         'uses' => 'OutcomesController@fetchCriteria'
188
-    ) );
173
+    ));
189 174
 
190 175
     // Fetch a criterion for a rubric
191
-    Route::post( 'fetchCriterion', array(
176
+    Route::post('fetchCriterion', array(
192 177
         'as' => 'fetchCriterion',
193 178
         'uses' => 'CriteriaController@fetchCriterion'
194
-    ) );
195
-
179
+    ));
180
+    // Fetch Criterions associated to programs
181
+    Route::post('fetchAllCriterion', array(
182
+        'as' => 'fetchAllCriterion',
183
+        'uses' => 'CriteriaController@fetchAllCriterion'
184
+    ));
185
+    Route::post('delete', array(
186
+        'as' => 'delete',
187
+        'uses' => 'CriteriaController@delete'
188
+    ));
196 189
     // Fetch a criterion for a rubric
197
-    Route::post( 'fetchCriterionWithTrashed', array(
190
+    Route::post('fetchCriterionWithTrashed', array(
198 191
         'as' => 'fetchCriterionWithTrashed',
199 192
         'uses' => 'CriteriaController@fetchCriterionWithTrashed'
200
-    ) );
193
+    ));
194
+    //Fetch objectives for criteria when outcome is chosen
195
+    Route::post('fetchObjectivesForSelect', array(
196
+        'as' => 'fetchObjectivesForSelect',
197
+        'uses' => 'CriteriaController@fetchObjectivesForSelect'
198
+    ));
201 199
 
202 200
     // Fetch a criterion for a rubric with custom content
203
-    Route::post( 'fetchRubricCriterion', array(
201
+    Route::post('fetchRubricCriterion', array(
204 202
         'as' => 'fetchRubricCriterion',
205 203
         'uses' => 'RubricsController@fetchRubricCriterion'
206
-    ) );
204
+    ));
207 205
 
208 206
     // Load a rubric template
209
-    Route::post('loadTemplate', array('uses'=>'TemplatesController@fetch'));
207
+    Route::post('loadTemplate', array('uses' => 'TemplatesController@fetch'));
210 208
 
211
-    Route::post('filterSemesters', array('uses'=>'SemestersController@filterSemesters'));
209
+    Route::post('filterSemesters', array('uses' => 'SemestersController@filterSemesters'));
212 210
 
213 211
 
214 212
     // Log out user
@@ -216,53 +214,55 @@ Route::group(array('before' => 'auth|has_access'), function()
216 214
 
217 215
     // Edit and update user profile
218 216
     Route::get('profile', 'UsersController@edit');
219
-    Route::post('profile/update', array('before' => 'csrf', 'uses'=>'UsersController@update'));
217
+    Route::post('profile/update', array('before' => 'csrf', 'uses' => 'UsersController@update'));
220 218
 
221 219
     // Allows users to give feeback
222
-    Route::post('feedback/send', array('before' => 'csrf', 'uses'=>'FeedbackController@send'));
223
-    Route::resource('feedback', 'FeedbackController',
224
-                array('only' => array('create')));
220
+    Route::post('feedback/send', array('before' => 'csrf', 'uses' => 'FeedbackController@send'));
221
+    Route::resource(
222
+        'feedback',
223
+        'FeedbackController',
224
+        array('only' => array('create'))
225
+    );
225 226
 
226 227
     // Show users all learning outcomes and criteria
227 228
     Route::get('learning-outcomes-criteria', 'CriteriaController@index');
228
-    Route::post('fetchOutcome', array('before' => 'csrf', 'uses'=>'OutcomesController@fetchOutcome'));
229
+    Route::post('fetchOutcome', array('before' => 'csrf', 'uses'=> 'OutcomesController@fetchOutcome'));
229 230
     // Show users all objectives and criteria
230 231
     Route::get('learning-objectives-criteria', 'CriteriaController@objectivesIndex');
231
-    Route::post('fetchObjectiveForCriteria', array('before' => 'csrf', 'uses'=>'ObjectivesController@fetchObjectiveForCriteria'));
232
+    Route::post('fetchObjectiveForCriteria', array('before' => 'csrf', 'uses'=> 'ObjectivesController@fetchObjectiveForCriteria'));
232 233
 
233 234
     // Show professor overview to users with courses
234 235
     Route::get('professor', 'ProfessorsController@overview');
235 236
 
236 237
     // Assessment reports for users' courses
237 238
     Route::get('my-assessment-reports', 'OutcomesController@professorAssessmentReports');
238
-    Route::post('objectives/fetch', array('before' => 'csrf', 'uses'=>'ObjectivesController@fetch'));
239
+    Route::post('objectives/fetch', array('before' => 'csrf', 'uses' => 'ObjectivesController@fetch'));
239 240
 
240 241
     /**
241 242
      * Administrator Routes
242 243
      */
243
-    Route::group( array('before' => 'admin'), function()
244
-    {
244
+    Route::group(array('before' => 'admin'), function () {
245 245
         Route::get('/administrator', 'AdministratorsController@overview');
246
-        Route::post( 'administrator/rubrics', array(
246
+        Route::post('administrator/rubrics', array(
247 247
             'as' => 'rubrics',
248 248
             'before' => 'csrf',
249 249
             'uses' => 'CriteriaController@fetch'
250
-        ) );
251
-        Route::post('createOutcome', array('before' => 'csrf', 'uses'=>'OutcomesController@create'));
252
-        Route::post('createCriterion', array('before' => 'csrf', 'uses'=>'CriteriaController@create'));
250
+        ));
251
+        Route::post('createOutcome', array('before' => 'csrf', 'uses' => 'OutcomesController@create'));
252
+        Route::post('createCriterion', array('before' => 'csrf', 'uses' => 'CriteriaController@create'));
253 253
 
254 254
         Route::get('learning-outcomes', 'OutcomesController@index');
255 255
         // TODO: Change later
256 256
         Route::get('new-learning-outcomes', 'OutcomesController@newIndex');
257 257
         Route::post('learning-outcomes/update', array('before' => 'csrf', 'uses' => 'OutcomesController@update'));
258 258
         Route::post('learning-outcomes/update', array('before' => 'csrf', 'uses' => 'OutcomesController@updateMore'));
259
-        Route::post('crtiteria/update', array('before' => 'csrf', 'uses'=>'CriteriaController@update'));
260
-        Route::delete('crtiteria/delete', array('before' => 'csrf', 'uses'=>'CriteriaController@destroy'));
259
+        Route::post('crtiteria/update', array('before' => 'csrf', 'uses'=> 'CriteriaController@update'));
260
+        Route::delete('crtiteria/delete', array('before' => 'csrf', 'uses'=> 'CriteriaController@destroy'));
261 261
 
262 262
         Route::get('administrator/users/{query?}', 'UsersController@index');
263 263
 
264
-        Route::post('administrator/updateAccess', array('before' => 'csrf', 'uses'=>'UsersController@updateAccess'));
265
-        Route::post('administrator/users/store', array('before' => 'csrf', 'uses'=>'UsersController@store'));
264
+        Route::post('administrator/updateAccess', array('before' => 'csrf', 'uses' => 'UsersController@updateAccess'));
265
+        Route::post('administrator/users/store', array('before' => 'csrf', 'uses' => 'UsersController@store'));
266 266
 
267 267
 
268 268
         Route::get('administrator/semesters', 'SemestersController@edit');
@@ -277,17 +277,15 @@ Route::group(array('before' => 'auth|has_access'), function()
277 277
         Route::get('template/{template}', 'TemplatesController@show');
278 278
 
279 279
         Route::get('courses/reassign', 'CoursesController@reassign');
280
-        Route::post('courses/update', array('before' => 'csrf', 'uses'=>'CoursesController@update'));
280
+        Route::post('courses/update', array('before' => 'csrf', 'uses' => 'CoursesController@update'));
281 281
 
282 282
         Route::get('activities/create', 'ActivitiesController@newCreate');
283
-
284 283
     });
285 284
 
286 285
     /**
287 286
      * School Coordinator Routes
288 287
      */
289
-    Route::group( array('before' => 'scoord'), function()
290
-    {
288
+    Route::group(array('before' => 'scoord'), function () {
291 289
         Route::get('school-coordinator', 'SchoolCoordinatorsController@overview');
292 290
         Route::get('school/{id}', 'SchoolsController@show');
293 291
         Route::get('program/{id}', 'ProgramsController@show');
@@ -300,28 +298,35 @@ Route::group(array('before' => 'auth|has_access'), function()
300 298
 
301 299
         // Assessment reports
302 300
         Route::get('school-assessment-report/{outcome_id}', 'OutcomesController@schoolAssessmentReport');
301
+
302
+        // Gabriel added this, so the school coordinator can add criterias and objectives
303
+        Route::get('school-objective', 'Objective2Controller@editSchool');
304
+        Route::get('school-criteria', 'CriteriaController@editSchool');
303 305
     });
304 306
 
307
+
305 308
     /**
306 309
      * Program Coordinator Routes
307 310
      */
308
-    Route::group( array('before' => 'pcoord'), function()
309
-    {
311
+    Route::group(array('before' => 'pcoord'), function () {
310 312
         Route::get('program-coordinator', 'ProgramCoordinatorsController@overview');
311 313
 
312 314
         Route::get('rubrics', 'TemplatesController@newTemplate');
313
-        Route::post('saveTemplate', array('before' => 'csrf', 'uses'=>'TemplatesController@create'));
314
-        Route::post('updateTemplate', array('before' => 'csrf', 'uses'=>'TemplatesController@update'));
315
-        Route::post('deleteTemplate', array('before' => 'csrf', 'uses'=>'TemplatesController@destroy'));
316
-        Route::get('criteria', 'CriteriaController@edit');
315
+        Route::post('saveTemplate', array('before' => 'csrf', 'uses' => 'TemplatesController@create'));
316
+        Route::post('updateTemplate', array('before' => 'csrf', 'uses' => 'TemplatesController@update'));
317
+        Route::post('deleteTemplate', array('before' => 'csrf', 'uses' => 'TemplatesController@destroy'));
317 318
         Route::get('course/{id}', 'CoursesController@showLimited');
318 319
         Route::get('rubrics/{template_id}/download', 'TemplatesController@download');
319
-        Route::post('program/fetch', array('before' => 'csrf', 'uses'=>'ProgramsController@fetch'));
320
+        Route::post('program/fetch', array('before' => 'csrf', 'uses' => 'ProgramsController@fetch'));
320 321
 
321
-        Route::get('printRubric/{id}', 'TemplatesController@printview' );
322
+        Route::get('printRubric/{id}', 'TemplatesController@printview');
322 323
         Route::get('rubric/{rubric_id}', 'RubricsController@show_limited');
323 324
         Route::get('grouped_course/{code}/{number}/{semester_code}', 'CoursesController@showGrouped');
324 325
 
326
+        //Criteria and objectives
327
+        Route::get('program-criteria', 'CriteriaController@editProgram');
328
+        Route::get('program-objective', 'Objective2Controller@editProgram');
329
+
325 330
         // Print program report
326 331
         Route::get('print_program/{id}', 'ProgramsController@print_program');
327 332
 
@@ -334,19 +339,25 @@ Route::group(array('before' => 'auth|has_access'), function()
334 339
 
335 340
         // Learning Objectives
336 341
         Route::get('program/{program}/objectives', 'ObjectivesController@index');
337
-        Route::post('updateObjective', array('before' => 'csrf', 'uses'=>'ObjectivesController@update'));
338
-        Route::post('program/{id}/createObjective', array('before' => 'csrf', 'uses'=>'ObjectivesController@create'));
339
-        Route::post('fetchObjective', array('before' => 'csrf', 'uses'=>'ObjectivesController@fetchObjective'));
340
-        Route::post('fetchObjectivesForCriteria', array('before' => 'csrf', 'uses'=>'ObjectivesController@fetchObjectivesForCriteria'));
341
-
342
-        // Five year plans
342
+        Route::post('updateObjective', array('before' => 'csrf', 'uses' => 'ObjectivesController@update'));
343
+        Route::post('program/{id}/createObjective', array('before' => 'csrf', 'uses' => 'ObjectivesController@create'));
344
+        Route::post('fetchObjective', array('before' => 'csrf', 'uses' => 'ObjectivesController@fetchObjective'));
345
+        Route::post('fetchObjectivesForCriteria', array('before' => 'csrf', 'uses' => 'ObjectivesController@fetchObjectivesForCriteria'));
346
+
347
+        //Objectives por Gabriel
348
+        Route::get('objective', 'Objective2Controller@edit');
349
+        Route::post('createObjective', array('before' => 'csrf', 'uses' => 'Objective2Controller@create'));
350
+        Route::post('updateObjective', array('before' => 'csrf', 'uses' => 'Objective2Controller@update'));
351
+        Route::post('fetchObjectiveWithTrashed', array('before' => 'csrf', 'uses' => 'Objective2Controller@fetchObjectiveWithTrashed'));
352
+
353
+        // Five year plans,
343 354
         Route::get('five-year-plans', 'FiveYearPlansController@index');
344 355
         Route::get('program/{program}/five-year-plans/create', 'FiveYearPlansController@create');
345 356
         Route::get('program/{program}/five-year-plans/{five_year_plan}', 'FiveYearPlansController@show');
346 357
         Route::get('program/{program}/five-year-plans/{five_year_plan}/edit', 'FiveYearPlansController@edit');
347 358
         Route::get('five-year-plans/{five_year_plan}/ms-word', 'FiveYearPlansController@msWord');
348
-        Route::post('five-year-plans/store', array('before' => 'csrf', 'uses'=>'FiveYearPlansController@store'));
349
-        Route::post('five-year-plans/update', array('before' => 'csrf', 'uses'=>'FiveYearPlansController@update'));
359
+        Route::post('five-year-plans/store', array('before' => 'csrf', 'uses' => 'FiveYearPlansController@store'));
360
+        Route::post('five-year-plans/update', array('before' => 'csrf', 'uses' => 'FiveYearPlansController@update'));
350 361
 
351 362
 
352 363
         // Annual plans
@@ -354,8 +365,8 @@ Route::group(array('before' => 'auth|has_access'), function()
354 365
         Route::get('program/{program}/annual-plans/create', 'AnnualPlansController@create');
355 366
         Route::get('program/{program}/annual-plans/{five_year_plan}', 'AnnualPlansController@show');
356 367
         Route::get('program/{program}/annual-plans/{five_year_plan}/edit', 'AnnualPlansController@edit');
357
-        Route::post('annual-plans/store', array('before' => 'csrf', 'uses'=>'AnnualPlansController@store'));
358
-        Route::post('annual-plans/update', array('before' => 'csrf', 'uses'=>'AnnualPlansController@update'));
368
+        Route::post('annual-plans/store', array('before' => 'csrf', 'uses' => 'AnnualPlansController@store'));
369
+        Route::post('annual-plans/update', array('before' => 'csrf', 'uses' => 'AnnualPlansController@update'));
359 370
 
360 371
         Route::get('learning-outcomes/show/{id}', 'OutcomesController@show');
361 372
         // TODO: Change route name
@@ -369,9 +380,8 @@ Route::group(array('before' => 'auth|has_access'), function()
369 380
     /**
370 381
      * Professor Routes
371 382
      */
372
-    Route::group(array('prefix' => 'professor', 'before'=>'prof'), function()
373
-    {
374
-        Route::post('program', array('before' => 'csrf', 'uses'=>'ProfessorsController@program'));
383
+    Route::group(array('prefix' => 'professor', 'before' => 'prof'), function () {
384
+        Route::post('program', array('before' => 'csrf', 'uses' => 'ProfessorsController@program'));
375 385
         Route::get('activities/{activity_id}/rubrics', 'RubricsController@newRubric');
376 386
         Route::get('activities/{activity_id}/rubric', 'RubricsController@show');
377 387
         Route::get('activities/{activity_id}/rubric/{rubric_id}/download', 'RubricsController@download');
@@ -379,23 +389,23 @@ Route::group(array('before' => 'auth|has_access'), function()
379 389
         Route::get('activities/{activity_id}/assess', 'ActivitiesController@assess');
380 390
         Route::get('activities/{activity_id}/view_assessment', 'ActivitiesController@viewAssessment');
381 391
         Route::get('activities/{activity_id}/print_assessment', 'ActivitiesController@printAssessment');
382
-        Route::post('activities/saveAssessment', array('before'=>'csrf', 'uses'=>'ActivitiesController@saveAssessment'));
383
-        Route::post('activities/deleteAssessment', array('before'=>'csrf', 'uses'=>'ActivitiesController@deleteAssessment'));
392
+        Route::post('activities/saveAssessment', array('before' => 'csrf', 'uses' => 'ActivitiesController@saveAssessment'));
393
+        Route::post('activities/deleteAssessment', array('before' => 'csrf', 'uses' => 'ActivitiesController@deleteAssessment'));
384 394
         Route::delete('activities/{activity_id}/delete', 'ActivitiesController@destroy');
385
-        Route::post('activities/{activity_id}/update', array('before' => 'csrf', 'uses'=>'ActivitiesController@update'));
395
+        Route::post('activities/{activity_id}/update', array('before' => 'csrf', 'uses' => 'ActivitiesController@update'));
386 396
         Route::get('courses/{id}', 'CoursesController@show');
387 397
         Route::get('courses/{semester}/{id}/students/{number}', 'StudentsController@show');
388 398
         Route::get('courses/{semester}/{id}/students/{number}/print_report', 'StudentsController@printStudentReport');
389 399
         Route::get('activities/{id}', 'ActivitiesController@show');
390
-        Route::post('activities/{id}', array('before' => 'csrf', 'uses'=>'ActivitiesController@create'));
400
+        Route::post('activities/{id}', array('before' => 'csrf', 'uses' => 'ActivitiesController@create'));
391 401
         Route::get('students', 'StudentsController@students');
392 402
         Route::get('program', 'ProfessorsController@program');
393 403
         Route::get('personal-information', 'ProfessorsController@personalInformation');
394 404
         Route::get('manual', 'ProfessorsController@manual');
395
-        Route::post('loadRubric', array('before' => 'csrf', 'uses'=>'RubricsController@fetch'));
396
-        Route::post('saveRubric', array('before' => 'csrf', 'uses'=>'RubricsController@create'));
397
-        Route::post('updateRubric', array('before' => 'csrf', 'uses'=>'RubricsController@update'));
398
-        Route::post('deleteRubric', array('before' => 'csrf', 'uses'=>'RubricsController@destroy'));
405
+        Route::post('loadRubric', array('before' => 'csrf', 'uses' => 'RubricsController@fetch'));
406
+        Route::post('saveRubric', array('before' => 'csrf', 'uses' => 'RubricsController@create'));
407
+        Route::post('updateRubric', array('before' => 'csrf', 'uses' => 'RubricsController@update'));
408
+        Route::post('deleteRubric', array('before' => 'csrf', 'uses' => 'RubricsController@destroy'));
399 409
         Route::get('learning-outcomes-criteria', 'CriteriaController@index');
400 410
         Route::get('learning-objectives-criteria', 'CriteriaController@objectivesIndex');
401 411
         Route::get('export_grades/{id}', 'CoursesController@exportGrades');
@@ -405,8 +415,5 @@ Route::group(array('before' => 'auth|has_access'), function()
405 415
         Route::get('professor-assessment-reports', 'OutcomesController@professorAssessmentReports');
406 416
 
407 417
         Route::get('general-studies-overview', 'ProfessorsController@generalStudiesOverview');
408
-
409
-
410 418
     });
411
-
412 419
 });

+ 20
- 18
app/views/local/managers/admins/_navigation.blade.php View File

@@ -8,6 +8,7 @@
8 8
         <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">Management<span class="caret"></span></a>
9 9
         <ul class="dropdown-menu" role="menu">
10 10
           <li>{{ HTML::linkAction('CoursesController@reassign', 'Courses') }}</li>
11
+          <li>{{ HTML::linkAction('Objective2Controller@edit', 'Objectives')}}</li>
11 12
           <li>{{ HTML::linkAction('CriteriaController@edit', 'Criteria') }}</li>
12 13
           <li>{{ HTML::linkAction('OutcomesController@index', 'Learning Outcomes') }}</li>
13 14
           <li>{{ HTML::linkAction('TemplatesController@newTemplate', 'Rubric Builder') }}</li>
@@ -29,7 +30,7 @@
29 30
         <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">Colleges and Schools<span class="caret"></span></a>
30 31
         <ul class="dropdown-menu" role="menu">
31 32
           @foreach ($schools as $school)
32
-            <li>{{ HTML::linkAction('SchoolsController@show', $school->name, array($school->id)) }}</li>
33
+          <li>{{ HTML::linkAction('SchoolsController@show', $school->name, array($school->id)) }}</li>
33 34
           @endforeach
34 35
         </ul>
35 36
       </li>
@@ -39,9 +40,9 @@
39 40
       <li class="dropdown">
40 41
         <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">Sections<span class="caret"></span></a>
41 42
         <ul class="dropdown-menu" role="menu">
42
-        @foreach ($courses as $course)
43
+          @foreach ($courses as $course)
43 44
           <li> {{ HTML::linkAction('CoursesController@show', $course->code.$course->number.'-'.$course->section.' ('.$course->semester->code.')', array('id'=>$course->id)) }}</li>
44
-        @endforeach
45
+          @endforeach
45 46
         </ul>
46 47
       </li>
47 48
       @endif
@@ -49,37 +50,38 @@
49 50
       <li class="dropdown">
50 51
         <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">Reports<span class="caret"></span></a>
51 52
         <ul class="dropdown-menu" role="menu">
52
-            <li>{{ HTML::linkAction('OutcomesController@managerAssessmentReports', 'Campus Reports') }}</li>
53
-            @if(count(Auth::user()->courses))
54
-              <li>{{ HTML::linkAction('OutcomesController@professorAssessmentReports', 'My Courses\' Reports') }}</li>
55
-            @endif
53
+          <li>{{ HTML::linkAction('OutcomesController@managerAssessmentReports', 'Campus Reports') }}</li>
54
+          @if(count(Auth::user()->courses))
55
+          <li>{{ HTML::linkAction('OutcomesController@professorAssessmentReports', 'My Courses\' Reports') }}</li>
56
+          @endif
56 57
         </ul>
57 58
       </li>
58 59
 
59 60
       <li class="dropdown">
60 61
         <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">Help<span class="caret"></span></a>
61 62
         <ul class="dropdown-menu" role="menu">
62
-            <li>{{ HTML::linkAction('FeedbackController@create', 'Feedback') }}</li>
63
-            <!-- <li><a href="{{ asset('files/OLAS-intro.pdf') }}">Introduction to OLAS</a></li> -->
64
-            <li><a href="{{ asset('files/intro-avaluo.pdf') }}">Introduction to Assessment</a></li>
65
-            <!-- <li><a href="{{ asset('files/OLAS-coords.pdf') }}">OLAS for Coordinators</a></li> -->
66
-            <li><a href="http://oeae.uprrp.edu/wp-content/uploads/2019/01/Brochure-de-OLAS-rev.-agosto-2018.pdf">Brochure</a></li>
63
+          <li>{{ HTML::linkAction('FeedbackController@create', 'Feedback') }}</li>
64
+          <!-- <li><a href="{{ asset('files/OLAS-intro.pdf') }}">Introduction to OLAS</a></li> -->
65
+          <li><a href="{{ asset('files/intro-avaluo.pdf') }}">Introduction to Assessment</a></li>
66
+          <!-- <li><a href="{{ asset('files/OLAS-coords.pdf') }}">OLAS for Coordinators</a></li> -->
67
+          <li><a href="http://oeae.uprrp.edu/wp-content/uploads/2019/01/Brochure-de-OLAS-rev.-agosto-2018.pdf">Brochure</a></li>
67 68
         </ul>
68 69
       </li>
69 70
       <li class="dropdown">
70 71
         <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">Account<span class="caret"></span></a>
71 72
         <ul class="dropdown-menu" role="menu">
72
-            <li>{{ HTML::linkAction('UsersController@edit', 'Profile') }}</li>
73
-            <li>{{ HTML::linkAction('AuthController@logout', 'Log out ('.Auth::user()->email.')') }}</li>
73
+          <li>{{ HTML::linkAction('UsersController@edit', 'Profile') }}</li>
74
+          <li>{{ HTML::linkAction('AuthController@logout', 'Log out ('.Auth::user()->email.')') }}</li>
74 75
         </ul>
75 76
       </li>
76 77
       <li class="dropdown">
77 78
         <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">NEW<span class="caret"></span></a>
78 79
         <ul class="dropdown-menu" role="menu">
79 80
           <li>{{ HTML::linkAction('OutcomesController@newIndex', 'New Index') }}</li>
80
-{{--          <li>{{ HTML::linkAction('AuthController@logout', 'Log out ('.Auth::user()->email.')') }}</li>--}}
81
-        </ul>
82
-      </li>
81
+          {{-- <li>{{ HTML::linkAction('AuthController@logout', 'Log out ('.Auth::user()->email.')') }}
82
+      </li>--}}
83
+    </ul>
84
+    </li>
83 85
     </ul>
84 86
   </div>
85
-</div>
87
+</div>

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


+ 420
- 0
app/views/local/managers/admins/objectives.blade.php View File

@@ -0,0 +1,420 @@
1
+@extends('layouts.master')
2
+
3
+@section('navigation')
4
+@include('local.managers.admins._navigation')
5
+@stop
6
+@section('main')
7
+
8
+<div class="row">
9
+    <div class="col-md-6">
10
+        <!-- Form to add a new objective -->
11
+        <div class="panel panel-default panel-button">
12
+            <div class="panel-heading">
13
+                Create
14
+            </div>
15
+            <div class="panel-body">
16
+                {{ Form::open(array('action' => 'Objective2Controller@create' )) }}
17
+                <div id='outcomeGroup'>
18
+                    <label> Associated Outcome</label>
19
+                    <div class="form-group col-md-11" id='outcomeForm'>
20
+
21
+
22
+                        {{ Form::select('outcome[0]', $outcomes, null, ['class'=>'form-control selectpicker', 'id' =>'outcome[0]']) }}
23
+
24
+                    </div>
25
+
26
+                </div>
27
+                <input type='hidden' name='counter' id='counter' value=1>
28
+                <button id='button-add-outcome' class='btn btn-md btn-secondary' onclick='addOutcomeTest()'>
29
+                    <span class='glyphicon glyphicon-plus'>
30
+
31
+                    </span>
32
+                    Add another Outcome
33
+                </button>
34
+
35
+                <!-- Associated Program -->
36
+
37
+
38
+                <div class="form-group">
39
+                    {{ Form::label('program_id', 'Associated Program') }}
40
+                    <select id="program_id" name="program_id" class="form-control selectpicker">
41
+                        <option value="0">All</option>
42
+                        @foreach ($programs as $program)
43
+                        <option value="{{ $program->id }}">{{ $program->name }} [{{ $program->school->name }}]</option>
44
+                        @endforeach
45
+                    </select>
46
+                </div>
47
+
48
+
49
+                <div class="form-group">
50
+                    {{ Form::label('text', 'Text') }}
51
+                    {{ Form::text('text', '', array('class' => 'form-control')) }}
52
+                </div>
53
+
54
+
55
+
56
+                {{ Form::submit('Create', array('class' => 'btn btn-primary btn-block')) }}
57
+                {{ Form::close() }}
58
+            </div>
59
+        </div>
60
+    </div>
61
+
62
+    <div class="col-md-6">
63
+        <div class="panel panel-default panel-button">
64
+            <div class="panel-heading">
65
+                Edit
66
+            </div>
67
+            <div class="panel-body">
68
+                {{ Form::open(array('action' => 'Objective2Controller@update')) }}
69
+
70
+                <div class="form-group">
71
+                    {{ Form::label('objective_id', 'Objectives') }}
72
+                    <select id="select-objective" name="id" class="form-control selectpicker">
73
+                        @foreach ($objectives as $objective)
74
+                        <option value="{{ $objective->id }}" data-subtext="
75
+                                        @if($objective->program)
76
+                                            &nbsp;&nbsp;&nbsp;[{{ $objective->program->name }}]
77
+                                        @endif
78
+                                        ">
79
+                            {{ $objective->text }}
80
+
81
+
82
+
83
+                        </option>
84
+                        @endforeach
85
+                    </select>
86
+                </div>
87
+
88
+                <!-- Associated Outcome -->
89
+
90
+                <div class="form-group">
91
+                    <div id='assocOutcomeGroup'>
92
+                        <label>Associated Outcome</label>
93
+
94
+                        {{ Form::select('assoc_outcome[]', $outcomes, null, ['class'=>'form-control selectpicker', 'id'=>'assoc_outcome0']) }}
95
+
96
+                    </div>
97
+                </div>
98
+                <button id='button-add-assoc-outcome' class='btn btn-md btn-secondary' onclick='addAssoc()'>
99
+                    <span class='glyphicon glyphicon-plus'>
100
+
101
+                    </span>
102
+                    Add another Outcome
103
+                </button>
104
+
105
+
106
+                <!-- Associated Program -->
107
+                <div class="form-group">
108
+                    {{ Form::label('program_id2', 'Associated Program') }}
109
+                    <select id="program_id2" name="program_id" class="form-control selectpicker">
110
+                        <option value="0">All</option>
111
+                        @foreach ($programs as $program)
112
+                        <option value="{{ $program->id }}">{{ $program->name }} [{{ $program->school->name }}]</option>
113
+                        @endforeach
114
+                    </select>
115
+                </div>
116
+
117
+                <!-- Status -->
118
+                <div class="form-group">
119
+                    {{ Form::label('status', 'Status') }}
120
+                    <span data-toggle="tooltip" data-placement="top" title="Use this option to deactivate or reactivate objectives. Inactive objective will stay in the system, but will not be available to use in new rubrics." class="glyphicon glyphicon-question-sign"></span>
121
+
122
+                    <select id="status" name="status" class="form-control">
123
+                        <option value="1">Active</option>
124
+                        <option value="0">Inactive</option>
125
+                    </select>
126
+                </div>
127
+
128
+                <div class="form-group">
129
+                    {{ Form::label('text', 'Text') }}
130
+                    {{ Form::text('text', Input::old('text'), array('class' => 'form-control', 'id'=>'objective-text')) }}
131
+                </div>
132
+                {{ Form::submit('Update', array('class' => 'btn btn-primary btn-block')) }}
133
+                {{ Form::close() }}
134
+            </div>
135
+
136
+
137
+
138
+
139
+        </div>
140
+    </div>
141
+</div>
142
+<script>
143
+    var outcomeHTML = document.getElementById('outcomeGroup').innerHTML;
144
+    var selectOptions = document.getElementById('outcome[0]').innerHTML;
145
+    var ran = false;
146
+
147
+    var counter = 1;
148
+    var counterAssoc = 1;
149
+    //Add Another Outcome
150
+
151
+    function changeOutcomeHtml() {
152
+        var outcomeHTML = document.getElementById('outcomeGroup').innerHTML;
153
+
154
+        outcomeHTML = outcomeHTML.replace('outcome[' + counter.toString() + ']', 'outcome[' + (counter + 1).toString() + ']');
155
+        counter += 1;
156
+        document.getElementById("outcomeGroup").innerHTML += outcomeHTML;
157
+
158
+
159
+
160
+
161
+        document.getElementById('button-add-outcome').onclick = addOutcome;
162
+    }
163
+
164
+    function addOutcome() {
165
+        outcomeHTML = outcomeHTML.replace('outcome[' + counter.toString() + ']', 'outcome[' + (counter + 1).toString() + ']');
166
+        counter += 1;
167
+
168
+        document.getElementById("outcomeGroup").innerHTML += outcomeHTML;
169
+    }
170
+
171
+    function addOutcomeTest() {
172
+        var $select = $('<select/>', {
173
+            'class': "selectpicker form-control",
174
+            'name': "outcome[" + counter.toString() + "]",
175
+            'data-live-search': 'true'
176
+
177
+        });
178
+        var $div = $('<div/>', {
179
+            'id': 'outcomeForm' + counter.toString(),
180
+            'class': 'form-group col-md-11'
181
+        });
182
+        var $divForButton = $('<div/>', {
183
+            'class': 'col-md-1',
184
+            'id': 'close' + counter.toString()
185
+
186
+        });
187
+        var $button = $('<button/>', {
188
+            'type': 'button',
189
+            'class': 'btn btn-primary',
190
+            'onclick': 'deleteLast()'
191
+        });
192
+        $button.append('X');
193
+        $divForButton.append($button);
194
+
195
+        $div.appendTo('#outcomeGroup')
196
+        $select.append(selectOptions);
197
+
198
+        $select.appendTo('#outcomeForm' + counter.toString()).selectpicker('refresh');
199
+        $divForButton.appendTo('#outcomeGroup');
200
+        counter += 1;
201
+        $('#counter').val(counter);
202
+
203
+    }
204
+
205
+    function deleteLast() {
206
+
207
+        div = document.getElementById('outcomeForm' + (counter - 1).toString());
208
+        div.remove();
209
+        button = document.getElementById('close' + (counter - 1).toString());
210
+        button.remove();
211
+        counter -= 1;
212
+        $('#counter').val(counter);
213
+    }
214
+
215
+    function fetchObjectiveForEditing() {
216
+        var id = $('#select-objective').find(':selected').val();
217
+
218
+        $.post(
219
+            "{{ URL::action('Objective2Controller@fetchObjectiveWithTrashed') }}", {
220
+                id: id
221
+            },
222
+            function(json) {
223
+
224
+                var text = json[0].text;
225
+
226
+
227
+
228
+                // Display info
229
+                $('#objective-text').val(text);
230
+
231
+
232
+                // Select associated outcome
233
+                var outcome_id = json[0].outcome_id;
234
+                $('#assoc_outcome0').val(outcome_id);
235
+                $('#assoc_outcome0').selectpicker('refresh');
236
+
237
+                var length = json.length;
238
+                if (ran == true) {
239
+                    for (var i = counterAssoc; i != 0; i--) {
240
+                        deleteLastAssoc(i);
241
+
242
+                    }
243
+                    counterAssoc = 1
244
+                }
245
+                for (var i = 1; i < length; i++) {
246
+                    var $select = $('<select />', {
247
+                        'class': "selectpicker form-control",
248
+                        'name': "assoc_outcome[]",
249
+                        'data-live-search': 'true',
250
+                        'id': 'assoc_outcome' + i.toString()
251
+
252
+                    });
253
+                    var $div = $('<div />', {
254
+                        'id': 'assocOutcomeForm' + i.toString(),
255
+                        'class': 'form-group col-md-11'
256
+                    });
257
+                    var $divForButton = $('<div />', {
258
+                        'class': 'col-md-1',
259
+                        'id': 'closeAssoc' + i.toString()
260
+
261
+                    });
262
+                    var $button = $('<button />', {
263
+                        'type': 'button',
264
+                        'class': 'btn btn-primary',
265
+                        'onclick': 'deleteLastAssoc()'
266
+                    });
267
+                    $button.append('X');
268
+                    $divForButton.append($button);
269
+
270
+                    $div.appendTo('#assocOutcomeGroup')
271
+                    $select.append(selectOptions);
272
+
273
+                    $select.appendTo('#assocOutcomeForm' + i.toString()).selectpicker('refresh');
274
+                    $divForButton.appendTo('#assocOutcomeGroup');
275
+
276
+                    $('#assoc_outcome' + i.toString()).val(json[i].outcome_id);
277
+                    $('#assoc_outcome' + i.toString()).selectpicker('refresh');
278
+
279
+                    counterAssoc = i;
280
+                    ran = true;
281
+
282
+                }
283
+
284
+                // Select associated program
285
+                if (json[0].program_id) {
286
+                    $('#program_id2').val(json[0].program_id);
287
+
288
+                } else {
289
+                    $('#program_id2').val(0);
290
+                }
291
+
292
+                $('#program_id2').selectpicker('refresh');
293
+
294
+
295
+                // Select status
296
+                if (json[0].deleted_at)
297
+                    $('#status').val(0);
298
+                else
299
+                    $('#status').val(1);
300
+            },
301
+            'json'
302
+        );
303
+    }
304
+
305
+    function deleteLastAssoc() {
306
+
307
+        div = document.getElementById('assocOutcomeForm' + (counterAssoc).toString());
308
+        div.remove();
309
+        button = document.getElementById('closeAssoc' + (counterAssoc).toString());
310
+        button.remove();
311
+        counterAssoc -= 1;
312
+
313
+    }
314
+
315
+    function addAssoc() {
316
+
317
+
318
+        var $select = $('<select />', {
319
+            'class': "selectpicker form-control",
320
+            'name': "assoc_outcome[]",
321
+            'data-live-search': 'true',
322
+            'id': 'assoc_outcome' + counterAssoc.toString()
323
+
324
+        });
325
+        var $div = $('<div />', {
326
+            'id': 'assocOutcomeForm' + counterAssoc.toString(),
327
+            'class': 'form-group col-md-11'
328
+        });
329
+        var $divForButton = $('<div />', {
330
+            'class': 'col-md-1',
331
+            'id': 'closeAssoc' + counterAssoc.toString()
332
+
333
+        });
334
+        var $button = $('<button />', {
335
+            'type': 'button',
336
+            'class': 'btn btn-primary',
337
+            'onclick': 'deleteLastAssoc()'
338
+        });
339
+        $button.append('X');
340
+        $divForButton.append($button);
341
+
342
+        $div.appendTo('#assocOutcomeGroup')
343
+        $select.append(selectOptions);
344
+
345
+        $select.appendTo('#assocOutcomeForm' + counterAssoc.toString()).selectpicker('refresh');
346
+        $divForButton.appendTo('#assocOutcomeGroup');
347
+
348
+
349
+        ran = true;
350
+        counterAssoc += 1;
351
+
352
+
353
+    }
354
+</script>
355
+@stop
356
+
357
+@section('javascript')
358
+
359
+// --------------------------------------------------------------------------
360
+// Page load
361
+// --------------------------------------------------------------------------
362
+
363
+// Hide accordion panel contents by default
364
+$('.panel-group .panel-body').hide();
365
+
366
+$('#outcome-display').parent().hide();
367
+
368
+fetchObjectiveForEditing();
369
+// setCriterionStatus();
370
+
371
+
372
+
373
+
374
+// --------------------------------------------------------------------------
375
+// Functions
376
+// --------------------------------------------------------------------------
377
+
378
+// Fetch criterion info for editing
379
+
380
+$('#button-add-outcome').on('click', function(e) {
381
+// Prevent the default action of the clicked item. In this case that is submit
382
+e.preventDefault();
383
+
384
+
385
+return false;
386
+});
387
+$('#button-add-assoc-outcome').on('click', function(e) {
388
+// Prevent the default action of the clicked item. In this case that is submit
389
+e.preventDefault();
390
+
391
+
392
+return false;
393
+});
394
+
395
+// --------------------------------------------------------------------------
396
+// Events
397
+// --------------------------------------------------------------------------
398
+
399
+// When panel heading is clicked, toggle it
400
+$('.panel-group .panel-heading').on('click', function()
401
+{
402
+$(this).next().stop().slideToggle();
403
+})
404
+
405
+
406
+// When list item is clicked, load corresponding info
407
+$('#select-objective').on('change', function()
408
+{
409
+fetchObjectiveForEditing();
410
+$('.selectpicker').selectpicker('refresh');
411
+});
412
+
413
+// When list item is clicked, load corresponding info
414
+$('.selectpicker').on('change', function()
415
+{
416
+//alert($(this).find(':selected').val());
417
+$('.selectpicker').selectpicker('refresh');
418
+});
419
+
420
+@stop

+ 16
- 15
app/views/local/managers/pCoords/_navigation.blade.php View File

@@ -6,8 +6,6 @@
6 6
     <ul class="nav navbar-nav navbar-right">
7 7
       <li>{{ HTML::linkAction('ProgramCoordinatorsController@overview', 'Overview') }}</li>
8 8
       <li>{{ HTML::linkAction('TemplatesController@newTemplate', 'Rubrics') }}</li>
9
-      {{-- la linea siguiente comentada es lo que habia originalmente. tanto la linea como este comentario se pueden borrar --}}
10
-      {{-- <li>{{ HTML::linkAction('CriteriaController@index', 'Learning Outcomes and Criteria') }}</li> --}}
11 9
       <li class="dropdown">
12 10
         <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">Learning and Criterias<span class="caret"></span></a>
13 11
         <ul class="dropdown-menu" role="menu">
@@ -15,14 +13,17 @@
15 13
           <li>{{ HTML::linkAction('CriteriaController@objectivesIndex', 'Objectives and Criteria') }}</li>
16 14
         </ul>
17 15
       </li>
16
+      <li>{{ HTML::linkAction('Objective2Controller@editProgram', 'Objectives')}}</li>
17
+      <li>{{ HTML::linkAction('CriteriaController@editProgram', 'Criteria') }}</li>
18
+
18 19
       @if(count(Auth::user()->courses))
19 20
       <li> {{ HTML::linkAction('ProfessorsController@overview', 'My Courses', NULL) }}</li>
20 21
       <li class="dropdown">
21 22
         <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">Sections<span class="caret"></span></a>
22 23
         <ul class="dropdown-menu" role="menu">
23
-        @foreach ($courses as $course)
24
+          @foreach ($courses as $course)
24 25
           <li> {{ HTML::linkAction('CoursesController@show', $course->code.$course->number.'-'.$course->section.' ('.$course->semester->code.')', array('id'=>$course->id)) }}</li>
25
-        @endforeach
26
+          @endforeach
26 27
         </ul>
27 28
       </li>
28 29
       @endif
@@ -30,28 +31,28 @@
30 31
       <li class="dropdown">
31 32
         <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">Reports<span class="caret"></span></a>
32 33
         <ul class="dropdown-menu" role="menu">
33
-            <li>{{ HTML::linkAction('OutcomesController@managerAssessmentReports', 'Program Reports') }}</li>
34
-            @if(count(Auth::user()->courses))
35
-              <li>{{ HTML::linkAction('OutcomesController@professorAssessmentReports', 'My Courses\' Reports') }}</li>
36
-            @endif
34
+          <li>{{ HTML::linkAction('OutcomesController@managerAssessmentReports', 'Program Reports') }}</li>
35
+          @if(count(Auth::user()->courses))
36
+          <li>{{ HTML::linkAction('OutcomesController@professorAssessmentReports', 'My Courses\' Reports') }}</li>
37
+          @endif
37 38
         </ul>
38 39
       </li>
39 40
 
40 41
       <li class="dropdown">
41 42
         <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">Help<span class="caret"></span></a>
42 43
         <ul class="dropdown-menu" role="menu">
43
-            <li>{{ HTML::linkAction('FeedbackController@create', 'Feedback') }}</li>
44
-            <!-- <li><a href="{{ asset('files/OLAS-intro.pdf') }}">Introduction to OLAS</a></li> -->
45
-            <li><a href="{{ asset('files/intro-avaluo.pdf') }}">Introduction to Assessment</a></li>
46
-            <!-- <li><a href="{{ asset('files/OLAS-coords.pdf') }}">OLAS for Coordinators</a></li> -->
47
-            <li><a href="http://oeae.uprrp.edu/wp-content/uploads/2019/01/Brochure-de-OLAS-rev.-agosto-2018.pdf">Brochure</a></li>
44
+          <li>{{ HTML::linkAction('FeedbackController@create', 'Feedback') }}</li>
45
+          <!-- <li><a href="{{ asset('files/OLAS-intro.pdf') }}">Introduction to OLAS</a></li> -->
46
+          <li><a href="{{ asset('files/intro-avaluo.pdf') }}">Introduction to Assessment</a></li>
47
+          <!-- <li><a href="{{ asset('files/OLAS-coords.pdf') }}">OLAS for Coordinators</a></li> -->
48
+          <li><a href="http://oeae.uprrp.edu/wp-content/uploads/2019/01/Brochure-de-OLAS-rev.-agosto-2018.pdf">Brochure</a></li>
48 49
         </ul>
49 50
       </li>
50 51
       <li class="dropdown">
51 52
         <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">Account<span class="caret"></span></a>
52 53
         <ul class="dropdown-menu" role="menu">
53
-            <li>{{ HTML::linkAction('UsersController@edit', 'Profile') }}</li>
54
-            <li>{{ HTML::linkAction('AuthController@logout', 'Log out ('.Auth::user()->email.')') }}</li>
54
+          <li>{{ HTML::linkAction('UsersController@edit', 'Profile') }}</li>
55
+          <li>{{ HTML::linkAction('AuthController@logout', 'Log out ('.Auth::user()->email.')') }}</li>
55 56
         </ul>
56 57
       </li>
57 58
     </ul>

+ 1023
- 0
app/views/local/managers/pCoords/criteria.blade.php
File diff suppressed because it is too large
View File


+ 419
- 0
app/views/local/managers/pCoords/objectives.blade.php View File

@@ -0,0 +1,419 @@
1
+@extends('layouts.master')
2
+
3
+@section('navigation')
4
+@include('local.managers.pCoords._navigation')
5
+@stop
6
+@section('main')
7
+
8
+<div class="row">
9
+    <div class="col-md-6">
10
+        <!-- Form to add a new objective -->
11
+        <div class="panel panel-default panel-button">
12
+            <div class="panel-heading">
13
+                Create
14
+            </div>
15
+            <div class="panel-body">
16
+                {{ Form::open(array('action' => 'Objective2Controller@create' )) }}
17
+                <div id='outcomeGroup'>
18
+                    <label> Associated Outcome</label>
19
+                    <div class="form-group col-md-11" id='outcomeForm'>
20
+
21
+
22
+                        {{ Form::select('outcome[0]', $outcomes, null, ['class'=>'form-control selectpicker', 'id' =>'outcome[0]']) }}
23
+
24
+                    </div>
25
+
26
+                </div>
27
+                <input type='hidden' name='counter' id='counter' value=1>
28
+                <button id='button-add-outcome' class='btn btn-md btn-secondary' onclick='addOutcomeTest()'>
29
+                    <span class='glyphicon glyphicon-plus'>
30
+
31
+                    </span>
32
+                    Add another Outcome
33
+                </button>
34
+
35
+                <!-- Associated Program -->
36
+
37
+
38
+                <div class="form-group">
39
+                    {{ Form::label('program_id', 'Associated Program') }}
40
+                    <select id="program_id" name="program_id" class="form-control selectpicker">
41
+
42
+                        <option value="{{ $programs[0]->id }}">{{ $programs[0]->name }} [{{ $programs[0]->school->name }}]</option>
43
+
44
+                    </select>
45
+                </div>
46
+
47
+
48
+                <div class="form-group">
49
+                    {{ Form::label('text', 'Text') }}
50
+                    {{ Form::text('text', '', array('class' => 'form-control')) }}
51
+                </div>
52
+
53
+
54
+
55
+                {{ Form::submit('Create', array('class' => 'btn btn-primary btn-block')) }}
56
+                {{ Form::close() }}
57
+            </div>
58
+        </div>
59
+    </div>
60
+
61
+    <div class="col-md-6">
62
+        <div class="panel panel-default panel-button">
63
+            <div class="panel-heading">
64
+                Edit
65
+            </div>
66
+            <div class="panel-body">
67
+                {{ Form::open(array('action' => 'Objective2Controller@update')) }}
68
+
69
+                <div class="form-group">
70
+                    {{ Form::label('objective_id', 'Objectives') }}
71
+                    <select id="select-objective" name="id" class="form-control selectpicker">
72
+                        @foreach ($objectives as $objective)
73
+                        <option value="{{ $objective->id }}" data-subtext="
74
+                                        @if($objective->program)
75
+                                            &nbsp;&nbsp;&nbsp;[{{ $objective->program->name }}]
76
+                                        @endif
77
+                                        ">
78
+                            {{ $objective->text }}
79
+
80
+
81
+
82
+                        </option>
83
+                        @endforeach
84
+                    </select>
85
+                </div>
86
+
87
+                <!-- Associated Outcome -->
88
+
89
+                <div class="form-group">
90
+                    <div id='assocOutcomeGroup'>
91
+                        <label>Associated Outcome</label>
92
+
93
+                        {{ Form::select('assoc_outcome[]', $outcomes, null, ['class'=>'form-control selectpicker', 'id'=>'assoc_outcome0']) }}
94
+
95
+                    </div>
96
+                </div>
97
+                <button id='button-add-assoc-outcome' class='btn btn-md btn-secondary' onclick='addAssoc()'>
98
+                    <span class='glyphicon glyphicon-plus'>
99
+
100
+                    </span>
101
+                    Add another Outcome
102
+                </button>
103
+
104
+
105
+                <!-- Associated Program -->
106
+                <div class="form-group">
107
+                    {{ Form::label('program_id2', 'Associated Program') }}
108
+                    <select id="program_id2" name="program_id" class="form-control selectpicker">
109
+
110
+
111
+                        <option value="{{ $programs[0]->id }}">{{ $programs[0]->name }} [{{ $programs[0]->school->name }}]</option>
112
+
113
+                    </select>
114
+                </div>
115
+
116
+                <!-- Status -->
117
+                <div class="form-group">
118
+                    {{ Form::label('status', 'Status') }}
119
+                    <span data-toggle="tooltip" data-placement="top" title="Use this option to deactivate or reactivate objectives. Inactive objective will stay in the system, but will not be available to use in new rubrics." class="glyphicon glyphicon-question-sign"></span>
120
+
121
+                    <select id="status" name="status" class="form-control">
122
+                        <option value="1">Active</option>
123
+                        <option value="0">Inactive</option>
124
+                    </select>
125
+                </div>
126
+
127
+                <div class="form-group">
128
+                    {{ Form::label('text', 'Text') }}
129
+                    {{ Form::text('text', Input::old('text'), array('class' => 'form-control', 'id'=>'objective-text')) }}
130
+                </div>
131
+                {{ Form::submit('Update', array('class' => 'btn btn-primary btn-block')) }}
132
+                {{ Form::close() }}
133
+            </div>
134
+
135
+
136
+
137
+
138
+        </div>
139
+    </div>
140
+</div>
141
+<script>
142
+    var outcomeHTML = document.getElementById('outcomeGroup').innerHTML;
143
+    var selectOptions = document.getElementById('outcome[0]').innerHTML;
144
+    var ran = false;
145
+
146
+    var counter = 1;
147
+    var counterAssoc = 1;
148
+    //Add Another Outcome
149
+
150
+    function changeOutcomeHtml() {
151
+        var outcomeHTML = document.getElementById('outcomeGroup').innerHTML;
152
+
153
+        outcomeHTML = outcomeHTML.replace('outcome[' + counter.toString() + ']', 'outcome[' + (counter + 1).toString() + ']');
154
+        counter += 1;
155
+        document.getElementById("outcomeGroup").innerHTML += outcomeHTML;
156
+
157
+
158
+
159
+
160
+        document.getElementById('button-add-outcome').onclick = addOutcome;
161
+    }
162
+
163
+    function addOutcome() {
164
+        outcomeHTML = outcomeHTML.replace('outcome[' + counter.toString() + ']', 'outcome[' + (counter + 1).toString() + ']');
165
+        counter += 1;
166
+
167
+        document.getElementById("outcomeGroup").innerHTML += outcomeHTML;
168
+    }
169
+
170
+    function addOutcomeTest() {
171
+        var $select = $('<select/>', {
172
+            'class': "selectpicker form-control",
173
+            'name': "outcome[" + counter.toString() + "]",
174
+            'data-live-search': 'true'
175
+
176
+        });
177
+        var $div = $('<div/>', {
178
+            'id': 'outcomeForm' + counter.toString(),
179
+            'class': 'form-group col-md-11'
180
+        });
181
+        var $divForButton = $('<div/>', {
182
+            'class': 'col-md-1',
183
+            'id': 'close' + counter.toString()
184
+
185
+        });
186
+        var $button = $('<button/>', {
187
+            'type': 'button',
188
+            'class': 'btn btn-primary',
189
+            'onclick': 'deleteLast()'
190
+        });
191
+        $button.append('X');
192
+        $divForButton.append($button);
193
+
194
+        $div.appendTo('#outcomeGroup')
195
+        $select.append(selectOptions);
196
+
197
+        $select.appendTo('#outcomeForm' + counter.toString()).selectpicker('refresh');
198
+        $divForButton.appendTo('#outcomeGroup');
199
+        counter += 1;
200
+        $('#counter').val(counter);
201
+
202
+    }
203
+
204
+    function deleteLast() {
205
+
206
+        div = document.getElementById('outcomeForm' + (counter - 1).toString());
207
+        div.remove();
208
+        button = document.getElementById('close' + (counter - 1).toString());
209
+        button.remove();
210
+        counter -= 1;
211
+        $('#counter').val(counter);
212
+    }
213
+
214
+    function fetchObjectiveForEditing() {
215
+        var id = $('#select-objective').find(':selected').val();
216
+
217
+        $.post(
218
+            "{{ URL::action('Objective2Controller@fetchObjectiveWithTrashed') }}", {
219
+                id: id
220
+            },
221
+            function(json) {
222
+
223
+                var text = json[0].text;
224
+
225
+
226
+
227
+                // Display info
228
+                $('#objective-text').val(text);
229
+
230
+
231
+                // Select associated outcome
232
+                var outcome_id = json[0].outcome_id;
233
+                $('#assoc_outcome0').val(outcome_id);
234
+                $('#assoc_outcome0').selectpicker('refresh');
235
+
236
+                var length = json.length;
237
+                if (ran == true) {
238
+                    for (var i = counterAssoc; i != 0; i--) {
239
+                        deleteLastAssoc(i);
240
+
241
+                    }
242
+                    counterAssoc = 1
243
+                }
244
+                for (var i = 1; i < length; i++) {
245
+                    var $select = $('<select />', {
246
+                        'class': "selectpicker form-control",
247
+                        'name': "assoc_outcome[]",
248
+                        'data-live-search': 'true',
249
+                        'id': 'assoc_outcome' + i.toString()
250
+
251
+                    });
252
+                    var $div = $('<div />', {
253
+                        'id': 'assocOutcomeForm' + i.toString(),
254
+                        'class': 'form-group col-md-11'
255
+                    });
256
+                    var $divForButton = $('<div />', {
257
+                        'class': 'col-md-1',
258
+                        'id': 'closeAssoc' + i.toString()
259
+
260
+                    });
261
+                    var $button = $('<button />', {
262
+                        'type': 'button',
263
+                        'class': 'btn btn-primary',
264
+                        'onclick': 'deleteLastAssoc()'
265
+                    });
266
+                    $button.append('X');
267
+                    $divForButton.append($button);
268
+
269
+                    $div.appendTo('#assocOutcomeGroup')
270
+                    $select.append(selectOptions);
271
+
272
+                    $select.appendTo('#assocOutcomeForm' + i.toString()).selectpicker('refresh');
273
+                    $divForButton.appendTo('#assocOutcomeGroup');
274
+
275
+                    $('#assoc_outcome' + i.toString()).val(json[i].outcome_id);
276
+                    $('#assoc_outcome' + i.toString()).selectpicker('refresh');
277
+
278
+                    counterAssoc = i;
279
+                    ran = true;
280
+
281
+                }
282
+
283
+                // Select associated program
284
+                if (json[0].program_id) {
285
+                    $('#program_id2').val(json[0].program_id);
286
+
287
+                } else {
288
+                    $('#program_id2').val(0);
289
+                }
290
+
291
+                $('#program_id2').selectpicker('refresh');
292
+
293
+
294
+                // Select status
295
+                if (json[0].deleted_at)
296
+                    $('#status').val(0);
297
+                else
298
+                    $('#status').val(1);
299
+            },
300
+            'json'
301
+        );
302
+    }
303
+
304
+    function deleteLastAssoc() {
305
+
306
+        div = document.getElementById('assocOutcomeForm' + (counterAssoc).toString());
307
+        div.remove();
308
+        button = document.getElementById('closeAssoc' + (counterAssoc).toString());
309
+        button.remove();
310
+        counterAssoc -= 1;
311
+
312
+    }
313
+
314
+    function addAssoc() {
315
+
316
+
317
+        var $select = $('<select />', {
318
+            'class': "selectpicker form-control",
319
+            'name': "assoc_outcome[]",
320
+            'data-live-search': 'true',
321
+            'id': 'assoc_outcome' + counterAssoc.toString()
322
+
323
+        });
324
+        var $div = $('<div />', {
325
+            'id': 'assocOutcomeForm' + counterAssoc.toString(),
326
+            'class': 'form-group col-md-11'
327
+        });
328
+        var $divForButton = $('<div />', {
329
+            'class': 'col-md-1',
330
+            'id': 'closeAssoc' + counterAssoc.toString()
331
+
332
+        });
333
+        var $button = $('<button />', {
334
+            'type': 'button',
335
+            'class': 'btn btn-primary',
336
+            'onclick': 'deleteLastAssoc()'
337
+        });
338
+        $button.append('X');
339
+        $divForButton.append($button);
340
+
341
+        $div.appendTo('#assocOutcomeGroup')
342
+        $select.append(selectOptions);
343
+
344
+        $select.appendTo('#assocOutcomeForm' + counterAssoc.toString()).selectpicker('refresh');
345
+        $divForButton.appendTo('#assocOutcomeGroup');
346
+
347
+
348
+        ran = true;
349
+        counterAssoc += 1;
350
+
351
+
352
+    }
353
+</script>
354
+@stop
355
+
356
+@section('javascript')
357
+
358
+// --------------------------------------------------------------------------
359
+// Page load
360
+// --------------------------------------------------------------------------
361
+
362
+// Hide accordion panel contents by default
363
+$('.panel-group .panel-body').hide();
364
+
365
+$('#outcome-display').parent().hide();
366
+
367
+fetchObjectiveForEditing();
368
+// setCriterionStatus();
369
+
370
+
371
+
372
+
373
+// --------------------------------------------------------------------------
374
+// Functions
375
+// --------------------------------------------------------------------------
376
+
377
+// Fetch criterion info for editing
378
+
379
+$('#button-add-outcome').on('click', function(e) {
380
+// Prevent the default action of the clicked item. In this case that is submit
381
+e.preventDefault();
382
+
383
+
384
+return false;
385
+});
386
+$('#button-add-assoc-outcome').on('click', function(e) {
387
+// Prevent the default action of the clicked item. In this case that is submit
388
+e.preventDefault();
389
+
390
+
391
+return false;
392
+});
393
+
394
+// --------------------------------------------------------------------------
395
+// Events
396
+// --------------------------------------------------------------------------
397
+
398
+// When panel heading is clicked, toggle it
399
+$('.panel-group .panel-heading').on('click', function()
400
+{
401
+$(this).next().stop().slideToggle();
402
+})
403
+
404
+
405
+// When list item is clicked, load corresponding info
406
+$('#select-objective').on('change', function()
407
+{
408
+fetchObjectiveForEditing();
409
+$('.selectpicker').selectpicker('refresh');
410
+});
411
+
412
+// When list item is clicked, load corresponding info
413
+$('.selectpicker').on('change', function()
414
+{
415
+//alert($(this).find(':selected').val());
416
+$('.selectpicker').selectpicker('refresh');
417
+});
418
+
419
+@stop

+ 15
- 15
app/views/local/managers/sCoords/_navigation.blade.php View File

@@ -6,8 +6,6 @@
6 6
     <ul class="nav navbar-nav navbar-right">
7 7
       <li>{{ HTML::linkAction('SchoolCoordinatorsController@overview', 'Overview') }}</li>
8 8
       <li>{{ HTML::linkAction('TemplatesController@newTemplate', 'Rubrics') }}</li>
9
-      {{-- la linea siguiente comentada es lo que habia originalmente. tanto la linea como este comentario se pueden borrar --}}
10
-      {{-- <li>{{ HTML::linkAction('CriteriaController@index', 'Learning Outcomes and Criteria') }}</li> --}}
11 9
       <li class="dropdown">
12 10
         <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">Learning and Criterias<span class="caret"></span></a>
13 11
         <ul class="dropdown-menu" role="menu">
@@ -15,14 +13,16 @@
15 13
           <li>{{ HTML::linkAction('CriteriaController@objectivesIndex', 'Objectives and Criteria') }}</li>
16 14
         </ul>
17 15
       </li>
16
+      <li>{{ HTML::linkAction('Objective2Controller@editSchool', 'Objectives')}}</li>
17
+      <li>{{ HTML::linkAction('CriteriaController@editSchool', 'Criteria') }}</li>
18 18
       @if(count(Auth::user()->courses))
19 19
       <li> {{ HTML::linkAction('ProfessorsController@overview', 'My Courses', NULL) }}</li>
20 20
       <li class="dropdown">
21 21
         <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">Sections<span class="caret"></span></a>
22 22
         <ul class="dropdown-menu" role="menu">
23
-        @foreach ($courses as $course)
23
+          @foreach ($courses as $course)
24 24
           <li> {{ HTML::linkAction('CoursesController@show', $course->code.$course->number.'-'.$course->section.' ('.$course->semester->code.')', array('id'=>$course->id)) }}</li>
25
-        @endforeach
25
+          @endforeach
26 26
         </ul>
27 27
       </li>
28 28
       @endif
@@ -30,28 +30,28 @@
30 30
       <li class="dropdown">
31 31
         <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">Reports<span class="caret"></span></a>
32 32
         <ul class="dropdown-menu" role="menu">
33
-            <li>{{ HTML::linkAction('OutcomesController@managerAssessmentReports', 'School Reports') }}</li>
34
-            @if(count(Auth::user()->courses))
35
-              <li>{{ HTML::linkAction('OutcomesController@professorAssessmentReports', 'My Courses\' Reports') }}</li>
36
-            @endif
33
+          <li>{{ HTML::linkAction('OutcomesController@managerAssessmentReports', 'School Reports') }}</li>
34
+          @if(count(Auth::user()->courses))
35
+          <li>{{ HTML::linkAction('OutcomesController@professorAssessmentReports', 'My Courses\' Reports') }}</li>
36
+          @endif
37 37
         </ul>
38 38
       </li>
39 39
 
40 40
       <li class="dropdown">
41 41
         <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">Help<span class="caret"></span></a>
42 42
         <ul class="dropdown-menu" role="menu">
43
-            <li>{{ HTML::linkAction('FeedbackController@create', 'Feedback') }}</li>
44
-            <!-- <li><a href="{{ asset('files/OLAS-intro.pdf') }}">Introduction to OLAS</a></li> -->
45
-            <li><a href="{{ asset('files/intro-avaluo.pdf') }}">Introduction to Assessment</a></li>
46
-            <!-- <li><a href="{{ asset('files/OLAS-coords.pdf') }}">OLAS for Coordinators</a></li> -->
47
-            <li><a href="http://oeae.uprrp.edu/wp-content/uploads/2019/01/Brochure-de-OLAS-rev.-agosto-2018.pdf">Brochure</a></li>
43
+          <li>{{ HTML::linkAction('FeedbackController@create', 'Feedback') }}</li>
44
+          <!-- <li><a href="{{ asset('files/OLAS-intro.pdf') }}">Introduction to OLAS</a></li> -->
45
+          <li><a href="{{ asset('files/intro-avaluo.pdf') }}">Introduction to Assessment</a></li>
46
+          <!-- <li><a href="{{ asset('files/OLAS-coords.pdf') }}">OLAS for Coordinators</a></li> -->
47
+          <li><a href="http://oeae.uprrp.edu/wp-content/uploads/2019/01/Brochure-de-OLAS-rev.-agosto-2018.pdf">Brochure</a></li>
48 48
         </ul>
49 49
       </li>
50 50
       <li class="dropdown">
51 51
         <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">Account<span class="caret"></span></a>
52 52
         <ul class="dropdown-menu" role="menu">
53
-            <li>{{ HTML::linkAction('UsersController@edit', 'Profile') }}</li>
54
-            <li>{{ HTML::linkAction('AuthController@logout', 'Log out ('.Auth::user()->email.')') }}</li>
53
+          <li>{{ HTML::linkAction('UsersController@edit', 'Profile') }}</li>
54
+          <li>{{ HTML::linkAction('AuthController@logout', 'Log out ('.Auth::user()->email.')') }}</li>
55 55
         </ul>
56 56
       </li>
57 57
     </ul>

+ 1029
- 0
app/views/local/managers/sCoords/criteria.blade.php
File diff suppressed because it is too large
View File


+ 420
- 0
app/views/local/managers/sCoords/objectives.blade.php View File

@@ -0,0 +1,420 @@
1
+@extends('layouts.master')
2
+
3
+@section('navigation')
4
+@include('local.managers.sCoords._navigation')
5
+@stop
6
+@section('main')
7
+
8
+<div class="row">
9
+    <div class="col-md-6">
10
+        <!-- Form to add a new objective -->
11
+        <div class="panel panel-default panel-button">
12
+            <div class="panel-heading">
13
+                Create
14
+            </div>
15
+            <div class="panel-body">
16
+                {{ Form::open(array('action' => 'Objective2Controller@create' )) }}
17
+                <div id='outcomeGroup'>
18
+                    <label> Associated Outcome</label>
19
+                    <div class="form-group col-md-11" id='outcomeForm'>
20
+
21
+
22
+                        {{ Form::select('outcome[0]', $outcomes, null, ['class'=>'form-control selectpicker', 'id' =>'outcome[0]']) }}
23
+
24
+                    </div>
25
+
26
+                </div>
27
+                <input type='hidden' name='counter' id='counter' value=1>
28
+                <button id='button-add-outcome' class='btn btn-md btn-secondary' onclick='addOutcomeTest()'>
29
+                    <span class='glyphicon glyphicon-plus'>
30
+
31
+                    </span>
32
+                    Add another Outcome
33
+                </button>
34
+
35
+                <!-- Associated Program -->
36
+
37
+
38
+                <div class="form-group">
39
+                    {{ Form::label('program_id', 'Associated Program') }}
40
+                    <select id="program_id" name="program_id" class="form-control selectpicker">
41
+                        <option value="0">All</option>
42
+                        @foreach ($programs as $program)
43
+                        <option value="{{ $program->id }}">{{ $program->name }} [{{ $program->school->name }}]</option>
44
+                        @endforeach
45
+                    </select>
46
+                </div>
47
+
48
+
49
+                <div class="form-group">
50
+                    {{ Form::label('text', 'Text') }}
51
+                    {{ Form::text('text', '', array('class' => 'form-control')) }}
52
+                </div>
53
+
54
+
55
+
56
+                {{ Form::submit('Create', array('class' => 'btn btn-primary btn-block')) }}
57
+                {{ Form::close() }}
58
+            </div>
59
+        </div>
60
+    </div>
61
+
62
+    <div class="col-md-6">
63
+        <div class="panel panel-default panel-button">
64
+            <div class="panel-heading">
65
+                Edit
66
+            </div>
67
+            <div class="panel-body">
68
+                {{ Form::open(array('action' => 'Objective2Controller@update')) }}
69
+
70
+                <div class="form-group">
71
+                    {{ Form::label('objective_id', 'Objectives') }}
72
+                    <select id="select-objective" name="id" class="form-control selectpicker">
73
+                        @foreach ($objectives as $objective)
74
+                        <option value="{{ $objective->id }}" data-subtext="
75
+                                        @if($objective->program)
76
+                                            &nbsp;&nbsp;&nbsp;[{{ $objective->program->name }}]
77
+                                        @endif
78
+                                        ">
79
+                            {{ $objective->text }}
80
+
81
+
82
+
83
+                        </option>
84
+                        @endforeach
85
+                    </select>
86
+                </div>
87
+
88
+                <!-- Associated Outcome -->
89
+
90
+                <div class="form-group">
91
+                    <div id='assocOutcomeGroup'>
92
+                        <label>Associated Outcome</label>
93
+
94
+                        {{ Form::select('assoc_outcome[]', $outcomes, null, ['class'=>'form-control selectpicker', 'id'=>'assoc_outcome0']) }}
95
+
96
+                    </div>
97
+                </div>
98
+                <button id='button-add-assoc-outcome' class='btn btn-md btn-secondary' onclick='addAssoc()'>
99
+                    <span class='glyphicon glyphicon-plus'>
100
+
101
+                    </span>
102
+                    Add another Outcome
103
+                </button>
104
+
105
+
106
+                <!-- Associated Program -->
107
+                <div class="form-group">
108
+                    {{ Form::label('program_id2', 'Associated Program') }}
109
+                    <select id="program_id2" name="program_id" class="form-control selectpicker">
110
+                        <option value="0">All</option>
111
+                        @foreach ($programs as $program)
112
+                        <option value="{{ $program->id }}">{{ $program->name }} [{{ $program->school->name }}]</option>
113
+                        @endforeach
114
+                    </select>
115
+                </div>
116
+
117
+                <!-- Status -->
118
+                <div class="form-group">
119
+                    {{ Form::label('status', 'Status') }}
120
+                    <span data-toggle="tooltip" data-placement="top" title="Use this option to deactivate or reactivate objectives. Inactive objective will stay in the system, but will not be available to use in new rubrics." class="glyphicon glyphicon-question-sign"></span>
121
+
122
+                    <select id="status" name="status" class="form-control">
123
+                        <option value="1">Active</option>
124
+                        <option value="0">Inactive</option>
125
+                    </select>
126
+                </div>
127
+
128
+                <div class="form-group">
129
+                    {{ Form::label('text', 'Text') }}
130
+                    {{ Form::text('text', Input::old('text'), array('class' => 'form-control', 'id'=>'objective-text')) }}
131
+                </div>
132
+                {{ Form::submit('Update', array('class' => 'btn btn-primary btn-block')) }}
133
+                {{ Form::close() }}
134
+            </div>
135
+
136
+
137
+
138
+
139
+        </div>
140
+    </div>
141
+</div>
142
+<script>
143
+    var outcomeHTML = document.getElementById('outcomeGroup').innerHTML;
144
+    var selectOptions = document.getElementById('outcome[0]').innerHTML;
145
+    var ran = false;
146
+
147
+    var counter = 1;
148
+    var counterAssoc = 1;
149
+    //Add Another Outcome
150
+
151
+    function changeOutcomeHtml() {
152
+        var outcomeHTML = document.getElementById('outcomeGroup').innerHTML;
153
+
154
+        outcomeHTML = outcomeHTML.replace('outcome[' + counter.toString() + ']', 'outcome[' + (counter + 1).toString() + ']');
155
+        counter += 1;
156
+        document.getElementById("outcomeGroup").innerHTML += outcomeHTML;
157
+
158
+
159
+
160
+
161
+        document.getElementById('button-add-outcome').onclick = addOutcome;
162
+    }
163
+
164
+    function addOutcome() {
165
+        outcomeHTML = outcomeHTML.replace('outcome[' + counter.toString() + ']', 'outcome[' + (counter + 1).toString() + ']');
166
+        counter += 1;
167
+
168
+        document.getElementById("outcomeGroup").innerHTML += outcomeHTML;
169
+    }
170
+
171
+    function addOutcomeTest() {
172
+        var $select = $('<select/>', {
173
+            'class': "selectpicker form-control",
174
+            'name': "outcome[" + counter.toString() + "]",
175
+            'data-live-search': 'true'
176
+
177
+        });
178
+        var $div = $('<div/>', {
179
+            'id': 'outcomeForm' + counter.toString(),
180
+            'class': 'form-group col-md-11'
181
+        });
182
+        var $divForButton = $('<div/>', {
183
+            'class': 'col-md-1',
184
+            'id': 'close' + counter.toString()
185
+
186
+        });
187
+        var $button = $('<button/>', {
188
+            'type': 'button',
189
+            'class': 'btn btn-primary',
190
+            'onclick': 'deleteLast()'
191
+        });
192
+        $button.append('X');
193
+        $divForButton.append($button);
194
+
195
+        $div.appendTo('#outcomeGroup')
196
+        $select.append(selectOptions);
197
+
198
+        $select.appendTo('#outcomeForm' + counter.toString()).selectpicker('refresh');
199
+        $divForButton.appendTo('#outcomeGroup');
200
+        counter += 1;
201
+        $('#counter').val(counter);
202
+
203
+    }
204
+
205
+    function deleteLast() {
206
+
207
+        div = document.getElementById('outcomeForm' + (counter - 1).toString());
208
+        div.remove();
209
+        button = document.getElementById('close' + (counter - 1).toString());
210
+        button.remove();
211
+        counter -= 1;
212
+        $('#counter').val(counter);
213
+    }
214
+
215
+    function fetchObjectiveForEditing() {
216
+        var id = $('#select-objective').find(':selected').val();
217
+
218
+        $.post(
219
+            "{{ URL::action('Objective2Controller@fetchObjectiveWithTrashed') }}", {
220
+                id: id
221
+            },
222
+            function(json) {
223
+
224
+                var text = json[0].text;
225
+
226
+
227
+
228
+                // Display info
229
+                $('#objective-text').val(text);
230
+
231
+
232
+                // Select associated outcome
233
+                var outcome_id = json[0].outcome_id;
234
+                $('#assoc_outcome0').val(outcome_id);
235
+                $('#assoc_outcome0').selectpicker('refresh');
236
+
237
+                var length = json.length;
238
+                if (ran == true) {
239
+                    for (var i = counterAssoc; i != 0; i--) {
240
+                        deleteLastAssoc(i);
241
+
242
+                    }
243
+                    counterAssoc = 1
244
+                }
245
+                for (var i = 1; i < length; i++) {
246
+                    var $select = $('<select />', {
247
+                        'class': "selectpicker form-control",
248
+                        'name': "assoc_outcome[]",
249
+                        'data-live-search': 'true',
250
+                        'id': 'assoc_outcome' + i.toString()
251
+
252
+                    });
253
+                    var $div = $('<div />', {
254
+                        'id': 'assocOutcomeForm' + i.toString(),
255
+                        'class': 'form-group col-md-11'
256
+                    });
257
+                    var $divForButton = $('<div />', {
258
+                        'class': 'col-md-1',
259
+                        'id': 'closeAssoc' + i.toString()
260
+
261
+                    });
262
+                    var $button = $('<button />', {
263
+                        'type': 'button',
264
+                        'class': 'btn btn-primary',
265
+                        'onclick': 'deleteLastAssoc()'
266
+                    });
267
+                    $button.append('X');
268
+                    $divForButton.append($button);
269
+
270
+                    $div.appendTo('#assocOutcomeGroup')
271
+                    $select.append(selectOptions);
272
+
273
+                    $select.appendTo('#assocOutcomeForm' + i.toString()).selectpicker('refresh');
274
+                    $divForButton.appendTo('#assocOutcomeGroup');
275
+
276
+                    $('#assoc_outcome' + i.toString()).val(json[i].outcome_id);
277
+                    $('#assoc_outcome' + i.toString()).selectpicker('refresh');
278
+
279
+                    counterAssoc = i;
280
+                    ran = true;
281
+
282
+                }
283
+
284
+                // Select associated program
285
+                if (json[0].program_id) {
286
+                    $('#program_id2').val(json[0].program_id);
287
+
288
+                } else {
289
+                    $('#program_id2').val(0);
290
+                }
291
+
292
+                $('#program_id2').selectpicker('refresh');
293
+
294
+
295
+                // Select status
296
+                if (json[0].deleted_at)
297
+                    $('#status').val(0);
298
+                else
299
+                    $('#status').val(1);
300
+            },
301
+            'json'
302
+        );
303
+    }
304
+
305
+    function deleteLastAssoc() {
306
+
307
+        div = document.getElementById('assocOutcomeForm' + (counterAssoc).toString());
308
+        div.remove();
309
+        button = document.getElementById('closeAssoc' + (counterAssoc).toString());
310
+        button.remove();
311
+        counterAssoc -= 1;
312
+
313
+    }
314
+
315
+    function addAssoc() {
316
+
317
+
318
+        var $select = $('<select />', {
319
+            'class': "selectpicker form-control",
320
+            'name': "assoc_outcome[]",
321
+            'data-live-search': 'true',
322
+            'id': 'assoc_outcome' + counterAssoc.toString()
323
+
324
+        });
325
+        var $div = $('<div />', {
326
+            'id': 'assocOutcomeForm' + counterAssoc.toString(),
327
+            'class': 'form-group col-md-11'
328
+        });
329
+        var $divForButton = $('<div />', {
330
+            'class': 'col-md-1',
331
+            'id': 'closeAssoc' + counterAssoc.toString()
332
+
333
+        });
334
+        var $button = $('<button />', {
335
+            'type': 'button',
336
+            'class': 'btn btn-primary',
337
+            'onclick': 'deleteLastAssoc()'
338
+        });
339
+        $button.append('X');
340
+        $divForButton.append($button);
341
+
342
+        $div.appendTo('#assocOutcomeGroup')
343
+        $select.append(selectOptions);
344
+
345
+        $select.appendTo('#assocOutcomeForm' + counterAssoc.toString()).selectpicker('refresh');
346
+        $divForButton.appendTo('#assocOutcomeGroup');
347
+
348
+
349
+        ran = true;
350
+        counterAssoc += 1;
351
+
352
+
353
+    }
354
+</script>
355
+@stop
356
+
357
+@section('javascript')
358
+
359
+// --------------------------------------------------------------------------
360
+// Page load
361
+// --------------------------------------------------------------------------
362
+
363
+// Hide accordion panel contents by default
364
+$('.panel-group .panel-body').hide();
365
+
366
+$('#outcome-display').parent().hide();
367
+
368
+fetchObjectiveForEditing();
369
+// setCriterionStatus();
370
+
371
+
372
+
373
+
374
+// --------------------------------------------------------------------------
375
+// Functions
376
+// --------------------------------------------------------------------------
377
+
378
+// Fetch criterion info for editing
379
+
380
+$('#button-add-outcome').on('click', function(e) {
381
+// Prevent the default action of the clicked item. In this case that is submit
382
+e.preventDefault();
383
+
384
+
385
+return false;
386
+});
387
+$('#button-add-assoc-outcome').on('click', function(e) {
388
+// Prevent the default action of the clicked item. In this case that is submit
389
+e.preventDefault();
390
+
391
+
392
+return false;
393
+});
394
+
395
+// --------------------------------------------------------------------------
396
+// Events
397
+// --------------------------------------------------------------------------
398
+
399
+// When panel heading is clicked, toggle it
400
+$('.panel-group .panel-heading').on('click', function()
401
+{
402
+$(this).next().stop().slideToggle();
403
+})
404
+
405
+
406
+// When list item is clicked, load corresponding info
407
+$('#select-objective').on('change', function()
408
+{
409
+fetchObjectiveForEditing();
410
+$('.selectpicker').selectpicker('refresh');
411
+});
412
+
413
+// When list item is clicked, load corresponding info
414
+$('.selectpicker').on('change', function()
415
+{
416
+//alert($(this).find(':selected').val());
417
+$('.selectpicker').selectpicker('refresh');
418
+});
419
+
420
+@stop

+ 1
- 1
bootstrap/start.php View File

@@ -26,7 +26,7 @@ $app = new Illuminate\Foundation\Application;
26 26
 
27 27
 $env = $app->detectEnvironment(array(
28 28
 
29
-	'local' => array(gethostname(), 'ubuntu', 'RPV20111.rrp.campus', 'homestead'),
29
+	'local' => array(gethostname(), 'RPV20111.rrp.campus', 'homestead'),
30 30
     'production' => array('*.com', '*.edu', '*.org'),
31 31
 
32 32
 ));

+ 1
- 0
public/.htaccess View File

@@ -12,4 +12,5 @@
12 12
     RewriteCond %{REQUEST_FILENAME} !-d
13 13
     RewriteCond %{REQUEST_FILENAME} !-f
14 14
     RewriteRule ^ index.php [L]
15
+
15 16
 </IfModule>