Gabriel Santiago Plaza hace 4 años
padre
commit
76cc344e47

+ 0
- 14
READMEPLEASE.txt Ver fichero

@@ -1,14 +0,0 @@
1
-NO CORRAN LOS MIGRATIONS QUE TIENEN. hay algunos migrations que los hice y creé otros migrations para cancelar esos por ignorancia. Ahora
2
-
3
-
4
-1. Añadí un objectiveController que se llama Objective2Controller. Las rutas
5
-	que tienen ese controller se tienen que añadir dentro del routes.php
6
-
7
-2. Añadí un objectives.blade.php para editar objective
8
-3. Edité criteria.blade.php
9
-4. Edité criteriaController.php
10
-5. No creé modelos que funcionan, preferí utilizar DB::select()
11
-
12
-6. edité criteria donde esta la tabla, apunta a new_criteria en vez de criteria
13
-7. Los outcomes, apuntan a outcomes, no a new_outcomes, descubrí eso el martes 11/17 y no me deja añadir a new_outcomes
14
-8. CUALQUIERO DUDA contactarme gabriel.santiago21@upr.edu  787-969-0474

+ 249
- 77
app/controllers/CriteriaController.php Ver fichero

@@ -11,16 +11,62 @@ class CriteriaController extends \BaseController
11 11
      * 
12 12
      * @return Response
13 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
+
14 54
     public function fetchCriterion()
15 55
     {
16 56
         return Criterion::find(Input::get('id'));
17 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
+    }
18 66
     public function fetchObjectivesForSelect()
19 67
     {
20
-        //$alloutcome = Input::get('outcome');
21
-        //$array = array();
22
-        //foreach ($alloutcome as $outcome) {
23
-        $outcome = DB::select("select objectives.id, objectives.text from objectives, objective_outcome where objective_outcome.outcome_id =? and objective_outcome.objective_id = objectives.id and objectives.active=1", array(Input::get('id')));
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')));
24 70
         //
25 71
         return json_encode($outcome);
26 72
     }
@@ -29,22 +75,31 @@ class CriteriaController extends \BaseController
29 75
 
30 76
         $json = array();
31 77
         $json['criteria'] = DB::select(" select * from new_criteria where id = ?", array(Input::get('id')));
32
-        $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", array(Input::get('id')));
33
-        $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')));
34
-        $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 = ? 
35
-        and outcomes.id = criterion_objective_outcome.outcome_id) and objectives.id = objective_outcome.objective_id ORDER BY outcome_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')));
36 84
 
37
-
38
-        //foreach ($objectivesAll as $objective) {
39
-
40
-        //   $objectivesArray = (array) $objective;
41
-        ///    Log::info("Logging an array: " . print_r($objectivesArray, true));
42
-        ///    $json['objectives_outcome'][strval($objectivesArray['outcome_id'])] = array('id' => $objectivesArray['id'], 'text' => $objectivesArray['text'], 'outcome_id');
43
-        //}
44 85
         return json_encode($json);
45 86
     }
46 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();
47 95
 
96
+            case 2:
97
+                return Redirect::to('school-objective')->withInput();
98
+
99
+            case 3:
100
+                return Redirect::to('program-objective')->withInput();
101
+        }
102
+    }
48 103
     public function isCriterionUnique($input, $existing_criterion = NULL)
49 104
     {
50 105
         // dd($input);
@@ -59,10 +114,6 @@ class CriteriaController extends \BaseController
59 114
             ->where('name', '=', $input['name'])
60 115
             ->where('outcome_id', '=', $input['outcome_id'])
61 116
             ->where('program_id', '=', $program_id)
62
-            // ->where('description12', '=', $input['description12'])
63
-            // ->where('description34', '=', $input['description34'])
64
-            // ->where('description56', '=', $input['description56'])
65
-            // ->where('description78', '=', $input['description78'])
66 117
             ->first();
67 118
 
68 119
 
@@ -104,15 +155,17 @@ class CriteriaController extends \BaseController
104 155
 
105 156
 
106 157
 
107
-        $clean_input['program_id'] = trim(preg_replace('/\t+/', '', Input::get('program_id')));
108
-        $clean_input['description12'] = trim(preg_replace('/\t+/', '', Input::get('description12')));
109
-        $clean_input['description34'] = trim(preg_replace('/\t+/', '', Input::get('description34')));
110
-        $clean_input['description56'] = trim(preg_replace('/\t+/', '', Input::get('description56')));
111
-        $clean_input['description78'] = trim(preg_replace('/\t+/', '', Input::get('description78')));
158
+        $clean_input['program_id'] = Input::get('program_id');
159
+
112 160
         $clean_input['copyright'] = trim(preg_replace('/\t+/', '', Input::get('copyright')));
113 161
         $clean_input['notes'] = trim(preg_replace('/\t+/', '', Input::get('notes')));
114
-        $clean_input['maximum_score'] = 8;
115
-        $clean_input['number_of_scales'] = 4;
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']);
116 169
 
117 170
 
118 171
         return $clean_input;
@@ -126,30 +179,20 @@ class CriteriaController extends \BaseController
126 179
                 'name' => $clean_input['name'],
127 180
                 'subcriteria' => $clean_input['subcriteria'],
128 181
                 'outcome_id' => $clean_input['outcome_id'],
129
-                'description12' => $clean_input['description12'],
130
-                'description34' => $clean_input['description34'],
131
-                'description56' => $clean_input['description56'],
132
-                'description78' => $clean_input['description78'],
133 182
                 'notes' => $clean_input['notes'],
134 183
                 'copyright' => $clean_input['copyright'],
184
+                'maximum_score' => $clean_input['maximum_score']
135 185
             ),
136 186
             array(
137 187
                 'name' => 'required|string',
138 188
                 'subcriteria' => 'string',
139 189
                 'outcome_id' => 'required|array',
140
-                'description12' => 'required|string',
141
-                'description34' => 'required|string',
142
-                'description56' => 'required|string',
143
-                'description78' => 'required|string',
190
+
144 191
                 'notes' => 'string',
145 192
                 'copyright' => 'string',
146
-            ),
147
-            array(
148
-                'description12.required' => 'The Beginning (1-2) field is required.',
149
-                'description34.required' => 'The In Progress (3-4) field is required.',
150
-                'description56.required' => 'The Satisfactory (5-6) field is required.',
151
-                'description78.required' => 'The Excellent (7-8) field is required.',
193
+                'maximum_score' => 'required|integer'
152 194
             )
195
+
153 196
         );
154 197
     }
155 198
 
@@ -179,7 +222,17 @@ class CriteriaController extends \BaseController
179 222
             /** Send error message and old data */
180 223
             Session::flash('status', 'danger');
181 224
             Session::flash('message', $message);
182
-            return Redirect::to('criteria')->withInput();
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
+            }
183 236
         } else {
184 237
             // Check criterion uniqueness
185 238
             /*if (!$this->isCriterionUnique($clean_input)) {
@@ -194,12 +247,11 @@ class CriteriaController extends \BaseController
194 247
             $criterion->name = $clean_input['name'];
195 248
             $criterion->subcriteria = $clean_input['subcriteria'];
196 249
 
197
-            $criterion->description12 = $clean_input['description12'];
198
-            $criterion->description34 = $clean_input['description34'];
199
-            $criterion->description56 = $clean_input['description56'];
200
-            $criterion->description78 = $clean_input['description78'];
250
+
201 251
             //gabriel añadió aqui
202
-            $criterion->objective_id = 1; //$clean_input['objective_id'];
252
+
253
+            $criterion->number_of_scales = $clean_input['number_of_scales'];
254
+            $criterion->maximum_score = $clean_input['maximum_score'];
203 255
 
204 256
             if (Input::get('copyright'))
205 257
                 $criterion->copyright = $clean_input['copyright'];
@@ -207,11 +259,6 @@ class CriteriaController extends \BaseController
207 259
             if (Input::get('notes'))
208 260
                 $criterion->notes = $clean_input['notes'];
209 261
 
210
-            // Set program
211
-            if (Input::get('program_id') != 0)
212
-                $criterion->program_id = $clean_input['program_id'];
213
-            else
214
-                $criterion->program_id = NULL;
215 262
 
216 263
 
217 264
             /** If criterion is saved, send success message */
@@ -220,30 +267,78 @@ class CriteriaController extends \BaseController
220 267
                 $criterionId = $criterion->id;
221 268
                 foreach ($clean_input['outcome_id'] as $outcome_id) {
222 269
                     foreach ($clean_input['objective_id'] as $objective_id) {
223
-                        //try{
270
+
224 271
                         DB::insert("insert into `criterion_objective_outcome` (`objective_id`, `outcome_id`, `criterion_id`, `objective_outcome_id`) values ({$objective_id},{$outcome_id}, {$criterionId}, 0)");
225
-                        // }
226
-                        //catch{
227
-                        //Session::flash('status', 'danger');
228
-                        //Session::flash('message', '<p>Error creating objective. Please try again later.</p>');
229
-                        //return Redirect::to('objective')->withInput();
230
-                        //}
231 272
                     }
232 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
+
233 306
                 Session::flash('status', 'success');
234 307
                 Session::flash('message', 'Criterion created: "' . $criterion->name . '".');
235
-                return Redirect::to('criteria')->withInput(Input::only('outcome_id'));
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
+                }
236 319
             }
237 320
 
238 321
             /** If saving fails, send error message and old data */
239 322
             else {
240 323
                 Session::flash('status', 'danger');
241 324
                 Session::flash('message', '<p>Error creating Criterion. Please try again later.</p>');
242
-                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
+                }
243 336
             }
244 337
         }
245 338
     }
246 339
 
340
+
341
+
247 342
     public function edit()
248 343
     {
249 344
         $title = "Criteria";
@@ -257,6 +352,7 @@ class CriteriaController extends \BaseController
257 352
 
258 353
 
259 354
 
355
+
260 356
         return View::make('local.managers.admins.criteria', compact('title', 'outcomes', 'schools', 'criteria', 'programs', 'objectives'));
261 357
     }
262 358
 
@@ -291,15 +387,14 @@ class CriteriaController extends \BaseController
291 387
 
292 388
 
293 389
 
294
-        $clean_input['program_id'] = trim(preg_replace('/\t+/', '', Input::get('program_id')));
295
-        $clean_input['description12'] = trim(preg_replace('/\t+/', '', Input::get('description12')));
296
-        $clean_input['description34'] = trim(preg_replace('/\t+/', '', Input::get('description34')));
297
-        $clean_input['description56'] = trim(preg_replace('/\t+/', '', Input::get('description56')));
298
-        $clean_input['description78'] = trim(preg_replace('/\t+/', '', Input::get('description78')));
390
+        $clean_input['program_id'] = Input::get('program_id');
391
+
299 392
         $clean_input['copyright'] = trim(preg_replace('/\t+/', '', Input::get('copyright')));
300 393
         $clean_input['notes'] = trim(preg_replace('/\t+/', '', Input::get('notes')));
301
-        $clean_input['maximum_score'] = 8;
302
-        $clean_input['number_of_scales'] = 4;
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']);
303 398
 
304 399
 
305 400
         return $clean_input;
@@ -328,7 +423,17 @@ class CriteriaController extends \BaseController
328 423
             /** Send error message and old data */
329 424
             Session::flash('status', 'danger');
330 425
             Session::flash('message', $message);
331
-            return Redirect::back()->withInput();
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
+            }
332 437
         } else {
333 438
 
334 439
             // // Check criterion uniqueness
@@ -343,11 +448,11 @@ class CriteriaController extends \BaseController
343 448
             /** Set info */
344 449
             $criterion->name = $clean_input['name'];
345 450
             $criterion->subcriteria = $clean_input['subcriteria'];
346
-            //$criterion->outcome_id = $clean_input['outcome_id'];
347
-            $criterion->description12 = $clean_input['description12'];
348
-            $criterion->description34 = $clean_input['description34'];
349
-            $criterion->description56 = $clean_input['description56'];
350
-            $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'];
351 456
 
352 457
 
353 458
 
@@ -384,17 +489,64 @@ class CriteriaController extends \BaseController
384 489
                         DB::insert("insert into `criterion_objective_outcome` (`objective_id`, `outcome_id`, `criterion_id`,`objective_outcome_id`) values ({$objective_id},{$outcome_id}, {$criterionId}, 0)");
385 490
                     }
386 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
+
387 519
 
388 520
                 Session::flash('status', 'success');
389 521
                 Session::flash('message', 'Updated criterion: "' . $criterion->name . '"');
390
-                return Redirect::back();
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
+                }
391 533
             }
392 534
 
393 535
             /** If saving fails, send error message and old data */
394 536
             else {
395 537
                 Session::flash('status', 'danger');
396 538
                 Session::flash('message', 'Error updating the Criterion. Please try again later.');
397
-                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
+                }
398 550
             }
399 551
         }
400 552
     }
@@ -421,7 +573,17 @@ class CriteriaController extends \BaseController
421 573
                 Session::flash('status', 'danger');
422 574
                 Session::flash('message', 'Error deactivating criterion."' . $criterion->name . '"');
423 575
             }
424
-            return Redirect::back();
576
+            $role = Auth::user()['role'];
577
+            switch ($role) {
578
+                case 1:
579
+                    return Redirect::to('objective')->withInput();
580
+
581
+                case 2:
582
+                    return Redirect::to('school-objective')->withInput();
583
+
584
+                case 3:
585
+                    return Redirect::to('program-objective')->withInput();
586
+            }
425 587
         } else {
426 588
             try {
427 589
                 $criterion->restore();
@@ -431,7 +593,17 @@ class CriteriaController extends \BaseController
431 593
                 Session::flash('status', 'danger');
432 594
                 Session::flash('message', 'Error reactivating criterion: "' . $criterion->name . '".');
433 595
             }
434
-            return Redirect::back();
596
+            $role = Auth::user()['role'];
597
+            switch ($role) {
598
+                case 1:
599
+                    return Redirect::to('objective')->withInput();
600
+
601
+                case 2:
602
+                    return Redirect::to('school-objective')->withInput();
603
+
604
+                case 3:
605
+                    return Redirect::to('program-objective')->withInput();
606
+            }
435 607
         }
436 608
     }
437 609
 

+ 119
- 13
app/controllers/Objective2Controller.php Ver fichero

@@ -1,5 +1,7 @@
1 1
 <?php
2 2
 
3
+use Illuminate\Support\Facades\Auth;
4
+
3 5
 class Objective2Controller extends \BaseController
4 6
 {
5 7
 
@@ -104,11 +106,8 @@ class Objective2Controller extends \BaseController
104 106
 
105 107
 
106 108
 		$clean_input['outcome_id'] = Input::get('assoc_outcome');
107
-		$counter = Input::get('counter') + 0;
108 109
 
109
-		for ($i = 0; $i < $counter; $i++) {
110
-			$clean_input['outcome_id'][$i] = trim(preg_replace('/\t+/', '', $clean_input['outcome_id'][$i]));
111
-		}
110
+
112 111
 
113 112
 		$clean_input['program_id'] = trim(preg_replace('/\t+/', '', Input::get('program_id')));
114 113
 
@@ -151,14 +150,34 @@ class Objective2Controller extends \BaseController
151 150
 			/** Send error message and old data */
152 151
 			Session::flash('status', 'danger');
153 152
 			Session::flash('message', $message);
154
-			return Redirect::to('objective')->withInput();
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
+			}
155 164
 		} else {
156 165
 			// Check Objective uniqueness
157 166
 			if (!$this->isObjectiveUnique($clean_input)) {
158 167
 				/** Send error message and old data */
159 168
 				Session::flash('status', 'danger');
160 169
 				Session::flash('message', "This objective is a duplicate of an already saved Objective because it's and associated program are the same.");
161
-				return Redirect::to('objective')->withInput();
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
+				}
162 181
 			}
163 182
 
164 183
 			/** Instantiate new Objective */
@@ -190,14 +209,34 @@ class Objective2Controller extends \BaseController
190 209
 
191 210
 				Session::flash('status', 'success');
192 211
 				Session::flash('message', 'Objective created: "' . $objective->text . '".');
193
-				return Redirect::to('objective')->withInput(Input::only('outcome_id'));
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
+				}
194 223
 			}
195 224
 
196 225
 			/** If saving fails, send error message and old data */
197 226
 			else {
198 227
 				Session::flash('status', 'danger');
199 228
 				Session::flash('message', '<p>Error creating objective. Please try again later.</p>');
200
-				return Redirect::to('objective')->withInput();
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
+				}
201 240
 			}
202 241
 		}
203 242
 	}
@@ -241,9 +280,41 @@ class Objective2Controller extends \BaseController
241 280
 		return View::make('local.managers.admins.objectives', compact('title', 'outcomes', 'objectives', 'programs'));
242 281
 	}
243 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
+
244 297
 
245 298
 
246 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
+
247 318
 	/**
248 319
 	 * Update the specified resource in storage.
249 320
 	 *
@@ -252,11 +323,15 @@ class Objective2Controller extends \BaseController
252 323
 	 */
253 324
 
254 325
 	public function update()
326
+
255 327
 	{
328
+
256 329
 		$Objective = Objective::withTrashed()->find(Input::get('id'));
257 330
 
258 331
 		$clean_input = $this->cleanAssocInput();
259 332
 
333
+		Log::info(print_r($clean_input, true));
334
+
260 335
 		/** Validation rules */
261 336
 		$validator = $this->makeValidator($clean_input);
262 337
 
@@ -274,7 +349,17 @@ class Objective2Controller extends \BaseController
274 349
 			/** Send error message and old data */
275 350
 			Session::flash('status', 'danger');
276 351
 			Session::flash('message', $message);
277
-			return Redirect::back()->withInput();
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
+			}
278 363
 		} else {
279 364
 
280 365
 
@@ -301,9 +386,20 @@ class Objective2Controller extends \BaseController
301 386
 
302 387
 				foreach ($clean_input['outcome_id'] as $outcome_id) {
303 388
 					DB::insert("insert into `objective_outcome` (objective_id, outcome_id) values ({$objectiveId}, {$outcome_id})");
304
-					Session::flash('status', 'success');
305
-					Session::flash('message', 'Updated Objective: "' . $Objective->text . '"');
306
-					return Redirect::back();
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();
307 403
 				}
308 404
 			}
309 405
 
@@ -311,7 +407,17 @@ class Objective2Controller extends \BaseController
311 407
 			else {
312 408
 				Session::flash('status', 'danger');
313 409
 				Session::flash('message', 'Error updating the Objective. Please try again later.');
314
-				return Redirect::back()->withInput();
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
+				}
315 421
 			}
316 422
 		}
317 423
 	}

+ 315
- 358
app/controllers/UsersController.php Ver fichero

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

+ 0
- 31
app/database/migrations/2020_11_11_201214_dropForeignObjOut.php Ver fichero

@@ -1,31 +0,0 @@
1
-<?php
2
-
3
-use Illuminate\Database\Schema\Blueprint;
4
-use Illuminate\Database\Migrations\Migration;
5
-
6
-class DropForeignObjOut 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_objective_outcome_id_foreign');
18
-			$table->foreign('outcome_id')->references('id')->on('outcomes')->onDelete('cascade')->onUpdate('cascade');
19
-		});
20
-	}
21
-
22
-	/**
23
-	 * Reverse the migrations.
24
-	 *
25
-	 * @return void
26
-	 */
27
-	public function down()
28
-	{
29
-		//
30
-	}
31
-}

+ 35
- 0
app/database/migrations/2020_12_04_111708_dropDescriptionInCriteria.php Ver fichero

@@ -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 Ver fichero

@@ -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 Ver fichero

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

+ 17
- 0
app/models/Scale.php Ver fichero

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

+ 18
- 2
app/routes.php Ver fichero

@@ -177,7 +177,15 @@ Route::group(array('before' => 'auth|has_access'), function () {
177 177
         'as' => 'fetchCriterion',
178 178
         'uses' => 'CriteriaController@fetchCriterion'
179 179
     ));
180
-
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
+    ));
181 189
     // Fetch a criterion for a rubric
182 190
     Route::post('fetchCriterionWithTrashed', array(
183 191
         'as' => 'fetchCriterionWithTrashed',
@@ -285,8 +293,13 @@ Route::group(array('before' => 'auth|has_access'), function () {
285 293
 
286 294
         // Assessment reports
287 295
         Route::get('school-assessment-report/{outcome_id}', 'OutcomesController@schoolAssessmentReport');
296
+
297
+        // Gabriel added this, so the school coordinator can add criterias and objectives
298
+        Route::get('school-objective', 'Objective2Controller@editSchool');
299
+        Route::get('school-criteria', 'CriteriaController@editSchool');
288 300
     });
289 301
 
302
+
290 303
     /**
291 304
      * Program Coordinator Routes
292 305
      */
@@ -297,7 +310,6 @@ Route::group(array('before' => 'auth|has_access'), function () {
297 310
         Route::post('saveTemplate', array('before' => 'csrf', 'uses' => 'TemplatesController@create'));
298 311
         Route::post('updateTemplate', array('before' => 'csrf', 'uses' => 'TemplatesController@update'));
299 312
         Route::post('deleteTemplate', array('before' => 'csrf', 'uses' => 'TemplatesController@destroy'));
300
-        Route::get('criteria', 'CriteriaController@edit');
301 313
         Route::get('course/{id}', 'CoursesController@showLimited');
302 314
         Route::get('rubrics/{template_id}/download', 'TemplatesController@download');
303 315
         Route::post('program/fetch', array('before' => 'csrf', 'uses' => 'ProgramsController@fetch'));
@@ -306,6 +318,10 @@ Route::group(array('before' => 'auth|has_access'), function () {
306 318
         Route::get('rubric/{rubric_id}', 'RubricsController@show_limited');
307 319
         Route::get('grouped_course/{code}/{number}/{semester_code}', 'CoursesController@showGrouped');
308 320
 
321
+        //Criteria and objectives
322
+        Route::get('program-criteria', 'CriteriaController@editProgram');
323
+        Route::get('program-objective', 'Objective2Controller@editProgram');
324
+
309 325
         // Print program report
310 326
         Route::get('print_program/{id}', 'ProgramsController@print_program');
311 327
 

+ 1
- 1
app/views/local/managers/admins/_navigation.blade.php Ver fichero

@@ -8,7 +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')}}
11
+          <li>{{ HTML::linkAction('Objective2Controller@edit', 'Objectives')}}</li>
12 12
           <li>{{ HTML::linkAction('CriteriaController@edit', 'Criteria') }}</li>
13 13
           <li>{{ HTML::linkAction('OutcomesController@index', 'Learning Outcomes') }}</li>
14 14
           <li>{{ HTML::linkAction('TemplatesController@newTemplate', 'Rubric Builder') }}</li>

+ 346
- 74
app/views/local/managers/admins/criteria.blade.php Ver fichero

@@ -47,13 +47,15 @@
47 47
 
48 48
                 <!-- Associated Program -->
49 49
                 <div class="form-group">
50
-                    {{ Form::label('program_id', 'Associated Program') }}
51
-                    <select id="program_id" name="program_id" class="form-control selectpicker">
52
-                        <option value="0">All</option>
53
-                        @foreach ($programs as $program)
54
-                        <option value="{{ $program->id }}">{{ $program->name }} [{{ $program->school->name }}]</option>
55
-                        @endforeach
56
-                    </select>
50
+                    {{ Form::label('program_id', 'Associated Program') }}<br>
51
+                    <br>
52
+
53
+                    @foreach ($programs as $program)
54
+
55
+                    <input type="checkbox" id="{{ $program->name }}" name="program_id[]" value="{{$program->id}}">
56
+                    <label for="{{ $program->name }}"> {{ $program->name }} [{{ $program->school->name }}]</label><br>
57
+                    @endforeach
58
+
57 59
                 </div>
58 60
 
59 61
                 <div class="form-group">
@@ -66,27 +68,21 @@
66 68
                     <p class="help-block"><strong>Manually add</strong> bullets or numbering.</p>
67 69
                     {{ Form::textarea('subcriteria', '', array('class' => 'form-control', 'rows'=>3, 'aria-labelledby'=>'subcriteria')) }}
68 70
                 </div>
69
-
70 71
                 <div class="form-group">
71
-                    {{ Form::label('description12', 'Beginning (1-2)') }}
72
-                    {{ Form::textarea('description12', '', array('class' => 'form-control', 'rows'=>2, 'aria-labelledby'=>'description12')) }}
72
+                    {{ Form::label('maximum_score', 'Maximum Score') }}
73
+                    {{ Form::text('maximum_score', '1', array('class' => 'form-control', 'id'=>'maximum_score', 'oninput'=>'addOptions("Num_scale", "maximum_score", "Scales")')) }}
73 74
                 </div>
74
-
75 75
                 <div class="form-group">
76
-                    {{ Form::label('description34', 'In Progress (3-4)') }}
77
-                    {{ Form::textarea('description34', '', array('class' => 'form-control', 'rows'=>2, 'aria-labelledby'=>'description34')) }}
78
-                </div>
76
+                    {{ Form::label('scales', 'Number of Scales') }}
77
+                    <select id="Num_scale" name="scales" class="form-control selectpicker" onchange='numberOfScales("Num_scale", "Scales")'>
79 78
 
80
-                <div class="form-group">
81
-                    {{ Form::label('description56', 'Satisfactory (5-6)') }}
82
-                    {{ Form::textarea('description56', '', array('class' => 'form-control', 'rows'=>2, 'aria-labelledby'=>'description56')) }}
79
+                    </select>
83 80
                 </div>
81
+                <div id='Scales' data-value="0">
84 82
 
85
-                <div class="form-group">
86
-                    {{ Form::label('description78', 'Excellent (7-8)') }}
87
-                    {{ Form::textarea('description78', '', array('class' => 'form-control', 'rows'=>2, 'aria-labelledby'=>'description78')) }}
88 83
                 </div>
89 84
 
85
+
90 86
                 <div class="form-group">
91 87
                     {{ Form::label('copyright', 'Copyright') }}
92 88
                     {{ Form::textarea('copyright', '', array('class' => 'form-control', 'rows'=>2, 'placeholder'=>'(optional)', 'aria-labelledby'=>'copyright')) }}
@@ -111,6 +107,21 @@
111 107
             <div class="panel-body">
112 108
                 {{ Form::open(array('action' => 'CriteriaController@update')) }}
113 109
 
110
+
111
+                <div class="form-group">
112
+                    {{ Form::label('program_id2', 'Associated Program')}}
113
+                    <select id='select-program' class="form-control selectpicker" onchange='fetchAllCriterion("select-program", "assoc_outcomes_fetch")'>
114
+                        @foreach ($programs as $program)
115
+                        <option value='{{$program->id}}' data-subtext="{{$program->code}}">{{$program->name}}</option>
116
+                        @endforeach
117
+                    </select>
118
+                </div>
119
+                <div class="form-group">
120
+                    <label>Associated Outcome</label>
121
+                    {{ Form::select('assoc_outcome_fetch', $outcomes, null, ['class'=>'form-control selectpicker', 'id'=>'assoc_outcomes_fetch', 'onchange'=>'fetchAllCriterion("select-program", "assoc_outcomes_fetch")']) }}
122
+
123
+                </div>
124
+
114 125
                 <div class="form-group">
115 126
                     {{ Form::label('criterion_id', 'Criterion') }}
116 127
                     <select id="select-criterion" name="id" class="form-control selectpicker" onchange='fetchCriterionForEditing()'>
@@ -161,13 +172,13 @@
161 172
 
162 173
                 <!-- Associated Program -->
163 174
                 <div class="form-group">
164
-                    {{ Form::label('program_id2', 'Associated Program') }}
165
-                    <select id="program_id2" name="program_id" class="form-control selectpicker">
166
-                        <option value="0">All</option>
167
-                        @foreach ($programs as $program)
168
-                        <option value="{{ $program->id }}">{{ $program->name }} [{{ $program->school->name }}]</option>
169
-                        @endforeach
170
-                    </select>
175
+
176
+                    {{ Form::label('program_id2', 'Associated Program') }}<br><br>
177
+                    @foreach ($programs as $program)
178
+
179
+                    <input type="checkbox" id="assoc_program_id_{{ $program->id }}" name="program_id[]" value="{{$program->id}}">
180
+                    <label for="assoc_program_id_{{ $program->id }}"> {{ $program->name }} <sub>[{{ $program->school->name }}]</sub></label><br>
181
+                    @endforeach
171 182
                 </div>
172 183
 
173 184
 
@@ -182,6 +193,8 @@
182 193
                     </select>
183 194
                 </div>
184 195
 
196
+
197
+
185 198
                 <div class="form-group">
186 199
                     {{ Form::label('name', 'Name') }}
187 200
                     {{ Form::text('name', Input::old('name'), array('class' => 'form-control', 'id'=>'criterion_name')) }}
@@ -194,25 +207,22 @@
194 207
                 </div>
195 208
 
196 209
                 <div class="form-group">
197
-                    {{ Form::label('description12', 'Beginning (1-2)') }}
198
-                    {{ Form::textarea('description12', Input::old('description12'), array('class' => 'form-control', 'rows'=>2, 'id'=>'criterion_description12')) }}
210
+                    {{ Form::label('assoc_maximum_score', 'Maximum Score') }}
211
+                    {{ Form::text('assoc_maximum_score', '', array('class' => 'form-control', 'id'=>'assoc_maximum_score', 'oninput'=>'addOptions("Num_assoc_scale", "assoc_maximum_score", "Assoc_Scales")')) }}
199 212
                 </div>
200 213
 
201
-                <div class="form-group">
202
-                    {{ Form::label('description34', 'In Progress (3-4)') }}
203
-                    {{ Form::textarea('description34', Input::old('description34'), array('class' => 'form-control', 'rows'=>2, 'id'=>'criterion_description34')) }}
204
-                </div>
205 214
 
206 215
                 <div class="form-group">
207
-                    {{ Form::label('description56', 'Satisfactory (5-6)') }}
208
-                    {{ Form::textarea('description56', Input::old('description56'), array('class' => 'form-control', 'rows'=>2, 'id'=>'criterion_description56')) }}
216
+                    {{ Form::label('scales', 'Number of Scales') }}
217
+                    <select id="Num_assoc_scale" class="form-control selectpicker" onchange='numberOfAssoc("Num_assoc_scale", "Assoc_Scales")'>
218
+
219
+                    </select>
209 220
                 </div>
221
+                <div id='Assoc_Scales' data-value="0">
210 222
 
211
-                <div class="form-group">
212
-                    {{ Form::label('description78', 'Excellent (7-8)') }}
213
-                    {{ Form::textarea('description78', Input::old('description78'), array('class' => 'form-control', 'rows'=>2, 'id'=>'criterion_description78')) }}
214 223
                 </div>
215 224
 
225
+
216 226
                 <div class="form-group">
217 227
                     {{ Form::label('copyright', 'Copyright Information') }}
218 228
                     {{ Form::textarea('copyright', Input::old('copyright'), array('class' => 'form-control', 'rows'=>2, 'id'=>'criterion_copyright', 'placeholder'=>'(optional)')) }}
@@ -222,9 +232,13 @@
222 232
                     {{ Form::label('notes', 'Additional Notes') }}
223 233
                     {{ Form::textarea('notes', Input::old('notes'), array('class' => 'form-control', 'rows'=>2, 'id'=>'criterion_notes', 'placeholder'=>'(optional)')) }}
224 234
                 </div>
235
+                <div id='delete'>
225 236
 
237
+                </div>
226 238
                 {{ Form::submit('Update', array('class' => 'btn btn-primary btn-block')) }}
227 239
                 {{ Form::close() }}
240
+
241
+
228 242
             </div>
229 243
         </div>
230 244
     </div>
@@ -235,10 +249,142 @@
235 249
     var counter = 1;
236 250
     var counterObj = 1;
237 251
     var outcomeString = 'OutcomeGroup_';
252
+    $(document).ready(function() {
253
+        addOptions('Num_scale', 'maximum_score', 'Scales');
254
+        numberOfScales('Num_scale', 'Scales');
255
+    });
256
+
257
+
258
+    function numberOfAssoc(string, Scales) {
259
+        var maximum = $('#assoc_maximum_score').val();
260
+        var amountOfScale = parseInt($('#' + string).val());
261
+        var dataValue = parseInt($('#' + Scales).attr('data-value'));
262
+        //add
263
+        if (dataValue < amountOfScale) {
264
+
265
+            fullDiv = '';
266
+
267
+            for (var i = dataValue; i < amountOfScale; i++) {
268
+                div = '<div id="assoc_eval' + i.toString() + Scales + '">' +
269
+                    '<div class ="form-row">' +
270
+                    '<label for="header' + (i).toString() + '">Evaluación ' + (i + 1).toString() + '</label><br><br>' +
271
+                    '<input type="hidden"  id="header' + i.toString() + '">' +
272
+                    '<div class="form-group col-md-8" >' +
273
+                    '<label for="title' + i.toString() + '">Nombre de Evaluación ' + (i + 1).toString() + '</label>' +
274
+                    '<input class="form-control" name="assoc_title[]" type="text"  id="title' + i.toString() + '" placeholder ="Nombre de evaluacion" ></div>' +
275
+                    '<div class ="form-group col-md-2">' +
276
+                    '<label for="min' + i.toString() + '">Mínimo </label>' +
277
+                    '<input class="form-control" type="number" id="assoc_min' + i.toString() + '" min="1" max = "' + maximum + '" oninput ="changedMin(' + "'assoc_min" + i.toString() + "', '" + i.toString() + "', 'Assoc_Scales' " + ')" name = "assoc_min[]"></div>' +
278
+                    '<div class ="form-group col-md-2">' +
279
+                    '<label for="max' + i.toString() + '">Máximo </label>' +
280
+                    '<input class="form-control" type="number" id="assoc_max' + i.toString() + '" min="1" max = "' + maximum + '" oninput ="changedMax(' + "'assoc_max" + i.toString() + "', '" + i.toString() + "', 'Assoc_Scales' " + ')" name = "assoc_max[]"></div></div>' +
281
+                    '<div class ="form-group">' +
282
+                    '<label for ="descripcion' + i.toString() + '">Descripción de evaluación</label>' +
283
+                    '<textarea class="form-control" rows="2" aria-labelledby="descripcion' + i.toString() + '" name="assoc_scales[]" cols="50" ></textarea></div></div>';
284
+                fullDiv += div;
285
+
286
+
287
+            }
288
+
289
+            $('#' + Scales).append(fullDiv);
290
+            $('#' + Scales).attr('data-value', amountOfScale);
291
+        } else {
292
+            for (var i = dataValue; i > amountOfScale; i--) {
293
+                $('#assoc_eval' + (i - 1).toString()).remove();
294
+            }
295
+        }
296
+        $('#' + Scales).attr('data-value', amountOfScale);
238 297
 
298
+    }
239 299
 
240
-    //Add outcome Button
300
+    function addOptions(select, max, scaleDiv) {
301
+        var maxscore = parseInt($('#' + max).val())
302
+        options = '';
303
+        for (var i = 1; i <= maxscore; i++) {
304
+            options += '<option value="' + i.toString() + '">' + i.toString() + '</option>';
305
+
306
+        }
307
+
308
+        var previousvalue = parseInt($('#' + select).val());
309
+        $('#' + select).html(options);
310
+        $('#' + select).val(previousvalue);
311
+        $('#' + select).selectpicker('refresh');
312
+
313
+        var attribute = parseInt($('#' + scaleDiv).attr('data-value'));
314
+
315
+        for (var i = 0; i < attribute; i++) {
316
+            $('#max' + i.toString()).attr('max', maxscore);
317
+            $('#min' + i.toString()).attr('max', maxscore);
318
+        }
319
+
320
+    }
321
+
322
+
323
+
324
+    function numberOfScales(string, Scales) {
325
+        var maximum = $('#maximum_score').val();
326
+        var amountOfScale = parseInt($('#' + string).val());
327
+        var dataValue = parseInt($('#' + Scales).attr('data-value'));
328
+        //add
329
+        if (dataValue < amountOfScale) {
330
+
331
+            fullDiv = '';
332
+
333
+            for (var i = dataValue; i < amountOfScale; i++) {
334
+                div = '<div id="eval' + i.toString() + Scales + '">' +
335
+                    '<div class ="form-row">' +
336
+                    '<label for="header' + (i).toString() + '">Evaluación ' + (i + 1).toString() + '</label><br><br>' +
337
+                    '<input type="hidden"  id="header' + i.toString() + '">' +
338
+                    '<div class="form-group col-md-8" >' +
339
+                    '<label for="title' + i.toString() + '">Nombre de Evaluación ' + (i + 1).toString() + '</label>' +
340
+                    '<input class="form-control" name="title[]" type="text"  id="title' + i.toString() + '" placeholder ="Nombre de evaluacion" ></div>' +
341
+                    '<div class ="form-group col-md-2">' +
342
+                    '<label for="min' + i.toString() + '">Mínimo </label>' +
343
+                    '<input class="form-control" type="number" id="min' + i.toString() + '" min="1" max = "' + maximum + '" oninput ="changedMin(' + "'min" + i.toString() + "', '" + i.toString() + "', 'Scales' " + ')" name = "min[]"></div>' +
344
+                    '<div class ="form-group col-md-2">' +
345
+                    '<label for="max' + i.toString() + '">Máximo </label>' +
346
+                    '<input class="form-control" type="number" id="max' + i.toString() + '" min="1" max = "' + maximum + '" oninput ="changedMax(' + "'max" + i.toString() + "', '" + i.toString() + "', 'Scales' " + ')" name = "max[]"></div></div>' +
347
+                    '<div class ="form-group">' +
348
+                    '<label for ="descripcion' + i.toString() + '">Descripción de evaluación</label>' +
349
+                    '<textarea class="form-control" rows="2" aria-labelledby="descripcion' + i.toString() + '" name="' + Scales + '[]" cols="50" ></textarea></div></div>';
350
+                fullDiv += div;
351
+            }
352
+
353
+            $('#' + Scales).append(fullDiv);
354
+
355
+        } else {
356
+            for (var i = dataValue; i > amountOfScale; i--) {
357
+                $('#eval' + (i - 1).toString() + Scales).remove();
358
+            }
359
+        }
360
+        $('#' + Scales).attr('data-value', amountOfScale);
361
+
362
+    }
363
+
364
+    function changedMin(min, index, scaleDiv) {
365
+        var maximum = parseInt($('#' + min).val()) + 1;
366
+        var maxScaleScore = parseInt($('#' + scaleDiv).attr('data-value'));
367
+
368
+        for (var i = parseInt(index); i < maxScaleScore; i++) {
369
+            $('#max' + i).attr('min', maximum);
370
+
371
+        }
372
+
373
+    }
374
+
375
+    function changedMax(max, index, scaleDiv) {
376
+        var maximum = parseInt($('#' + max).val()) + 1;
377
+        var maxScaleScore = parseInt($('#' + scaleDiv).attr('data-value'));
241 378
 
379
+        for (var i = parseInt(index) + 1; i < maxScaleScore; i++) {
380
+            $('#min' + i).attr('min', maximum)
381
+
382
+        }
383
+
384
+
385
+    }
386
+
387
+    //Add outcome Button
242 388
     function addOutcomeTest() {
243 389
         var $select = $('<select/>', {
244 390
             'class': "selectpicker form-control",
@@ -281,6 +427,7 @@
281 427
     }
282 428
 
283 429
 
430
+
284 431
     //Delete Outcome and OptGroup associated
285 432
 
286 433
     function deleteLast(outcomeForm, outcomeOptGroup, closeButton, objective) {
@@ -490,7 +637,7 @@
490 637
             },
491 638
             function(varArray) {
492 639
 
493
-                var optionName = '<optgroup id="' + outcomeString + (counter - 1).toString() + '"label="' + outcomeString + (counter).toString() + '"';
640
+                var optionName = '<optgroup id="' + outcomeString + (counter - 1).toString() + '"label="' + varArray[0].name + '"';
494 641
                 for (var i = 0; i < varArray.length; i++) {
495 642
                     var option = '<option value ="' + varArray[i].id.toString() + '">' + varArray[i].text + '</option>'
496 643
                     optionName += (option)
@@ -521,8 +668,45 @@
521 668
 
522 669
     //after post
523 670
 
524
-
671
+    fetchAllCriterion("select-program", "assoc_outcomes_fetch");
525 672
     //For editing criterion
673
+    function fetchAllCriterion(program, outcome) {
674
+        var program_id_fetch = $('#' + program).find(':selected').val();
675
+        var outcome_fetch = $('#' + outcome).find(':selected').val();
676
+        $.post(
677
+            "{{URL::action('CriteriaController@fetchAllCriterion')}}", {
678
+                program_fetch: program_id_fetch,
679
+                outcome_fetch: outcome_fetch
680
+            },
681
+            function(json) {
682
+                json_length = (json.criterion.length);
683
+                fullHTML = '';
684
+                for (var i = 0; i < json_length; i++) {
685
+                    fullHTML += '<option value="' + json.criterion[i].id + '">' + json.criterion[i].name + '</option>';
686
+                }
687
+                $('#select-criterion').html(fullHTML);
688
+                $('#select-criterion').selectpicker('refresh');
689
+                fetchCriterionForEditing()
690
+
691
+            },
692
+            'json'
693
+        );
694
+    }
695
+
696
+    function deleteCriterion() {
697
+        var id = $('#select-criterion').find(':selected').val()
698
+
699
+        $.post(
700
+            "{{ URL::action('CriteriaController@delete')}}", {
701
+                id: id
702
+            },
703
+            function() {
704
+                window.location.reload(true)
705
+            }
706
+        )
707
+    }
708
+
709
+
526 710
     function fetchCriterionForEditing() {
527 711
         var id = $('#select-criterion').find(':selected').val();
528 712
 
@@ -531,30 +715,47 @@
531 715
                 id: id
532 716
             },
533 717
             function(json) {
534
-                var name = json.criteria[0].name;
535 718
 
719
+                if (!(json.activity_criterion.length)) {
720
+
721
+                    var button = "<button type='button' class ='btn btn-primary btn-block' onclick ='deleteCriterion()'>Delete Criterion</button><br><br>"
722
+                    $('#delete').html(button)
723
+
724
+                }
725
+
726
+                if (!(json.criteria.length)) {
727
+                    name = ' ';
728
+                    var subcriteria = '';
729
+                    copyright = null;
730
+                    notes = null;
731
+                    $('#status').val(0);
732
+                    maximum = 1;
733
+                    $('#assoc_maximum_score').val(1);
734
+
735
+
736
+                } else {
737
+                    var name = json.criteria[0].name;
738
+                    if (json.criteria[0].subcriteria) {
739
+                        subcriteria = JSON.parse(json.criteria[0].subcriteria).join('\n');
740
+                    }
741
+                    var copyright = json.criteria[0].copyright;
742
+                    var notes = json.criteria[0].notes;
743
+
744
+                    // Display info
745
+                    $('#criterion_name').val(name);
746
+                    $('#criterion_subcriteria').text(subcriteria);
747
+                    if (json.criteria[0].deleted_at)
748
+                        $('#status').val(0);
749
+                    else
750
+                        $('#status').val(1);
751
+                    $('#assoc_maximum_score').val(json.criteria[0].maximum_score);
752
+                    var maximum = json.criteria[0].maximum_score;
753
+
754
+                    // If copyright or notes aren't empty, load them
536 755
 
537
-                var subcriteria = '';
538
-                if (json.criteria[0].subcriteria) {
539
-                    subcriteria = JSON.parse(json.criteria[0].subcriteria).join('\n');
540 756
                 }
541 757
 
542
-                var description12 = json.criteria[0].description12;
543
-                var description34 = json.criteria[0].description34;
544
-                var description56 = json.criteria[0].description56;
545
-                var description78 = json.criteria[0].description78;
546
-                var copyright = json.criteria[0].copyright;
547
-                var notes = json.criteria[0].notes;
548
-
549
-                // Display info
550
-                $('#criterion_name').val(name);
551
-                $('#criterion_subcriteria').text(subcriteria);
552
-                $('#criterion_description12').text(description12);
553
-                $('#criterion_description34').text(description34);
554
-                $('#criterion_description56').text(description56);
555
-                $('#criterion_description78').text(description78);
556
-
557
-                // If copyright or notes aren't empty, load them
758
+
558 759
                 if (copyright) {
559 760
                     $('#criterion_copyright').text(copyright);
560 761
                 } else {
@@ -565,6 +766,12 @@
565 766
                 } else {
566 767
                     $('#criterion_notes').text('');
567 768
                 }
769
+
770
+
771
+
772
+
773
+
774
+
568 775
                 // Select associated outcome
569 776
                 try {
570 777
                     for (var i = assocOutcomeCounter - 1; i > 0; i--) {
@@ -574,9 +781,13 @@
574 781
                     var Notran = true;
575 782
                 }
576 783
 
577
-
578
-                $('#assoc_outcome_0').val(json.outcomes[0].id);
579
-                $('#assoc_outcome_0').selectpicker('refresh');
784
+                if (json.outcomes.length) {
785
+                    $('#assoc_outcome_0').val(json.outcomes[0].id);
786
+                    $('#assoc_outcome_0').selectpicker('refresh');
787
+                } else {
788
+                    $('#assoc_outcome_0').val($('#assoc_outcomes_fetch').find(':selected').val());
789
+                    $('#assoc_outcome_0').selectpicker('refresh');
790
+                }
580 791
 
581 792
 
582 793
 
@@ -607,7 +818,7 @@
607 818
                 var i = 0;
608 819
                 for (var j = 0; j < json.outcomes.length; j++) {
609 820
                     assocOutcomeCounter += 1;
610
-                    var optionName = '<optgroup id="' + 'Associated_Outcome' + (assocOutcomeCounter - 1).toString() + '"label="' + 'Associated Outcome' + (assocOutcomeCounter).toString() + '"';
821
+                    var optionName = '<optgroup id="' + 'Associated_Outcome' + (assocOutcomeCounter - 1).toString() + '"label="' + json.outcomes[j].name + '"';
611 822
                     for (; i < json.objectives_outcome.length; i++) {
612 823
                         if (json.objectives_outcome[i].outcome_id != json.outcomes[j].id) break;
613 824
 
@@ -640,6 +851,10 @@
640 851
                     $('#assoc_objective_0').val(json.objectives[0].id);
641 852
                     $('#assoc_objective_0').selectpicker('refresh');
642 853
                 } catch (err) {
854
+                    if (!json.objectives.length) {
855
+                        $('#assoc_objective_0').val(0);
856
+                        $('#assoc_objective_0').selectpicker('refresh');
857
+                    }
643 858
                     var thereIsNoObjective = true;
644 859
                 }
645 860
 
@@ -656,21 +871,78 @@
656 871
 
657 872
 
658 873
                 // Select associated program
659
-                if (json.criteria[0].program_id) {
660
-                    $('#program_id2').val(json.criteria[0].program_id);
874
+                var program_length = json.program.length;
875
+                $('input[type=checkbox]').prop('checked', false);
876
+
877
+                for (var i = 0; i < program_length; i++) {
878
+                    $('#assoc_program_id_' + json.program[i].program_id).prop("checked", true);
879
+                }
880
+
661 881
 
882
+                // Select status
883
+
884
+
885
+                scaleLength = json.scales.length;
886
+                fullDiv = '';
887
+                if (!scaleLength) {
888
+                    div = '<div id="assoc_eval 0"">' +
889
+                        '<div class ="form-row">' +
890
+                        '<label for="header0">Evaluación 1</label><br><br>' +
891
+                        '<input type="hidden"  id="header0">' +
892
+                        '<div class="form-group col-md-8" >' +
893
+                        '<label for="title0">Nombre de Evaluación 1</label>' +
894
+                        '<input class="form-control" name="assoc_title[]" value =" "type="text"  id="title0" placeholder ="Nombre de evaluacion" ></div>' +
895
+                        '<div class ="form-group col-md-2">' +
896
+                        '<label for="min0">Mínimo </label>' +
897
+                        '<input class="form-control" type="number" id="assoc_min0" min="1" max = "1" value =" " name = "assoc_min[]"></div>' +
898
+                        '<div class ="form-group col-md-2">' +
899
+                        '<label for="max">Máximo </label>' +
900
+                        '<input class="form-control" type="number" id="assoc_max" min="1" max = "" value =" " name = "assoc_max[]"></div></div>' +
901
+                        '<div class ="form-group">' +
902
+                        '<label for ="descripcion">Descripción de evaluación</label>' +
903
+                        '<textarea class="form-control" rows="2" aria-labelledby="descripcion" name="assoc_scales[]" cols="50" ></textarea></div></div>';
904
+                    fullDiv += div;
662 905
                 } else {
663
-                    $('#program_id2').val(0);
906
+                    var dataValue = parseInt($('#Assoc_Scales').attr('data-value'));
907
+                    $('#assoc_maximum_score').val(json.criteria[0].maximum_score);
908
+                    var maximum = json.criteria[0].maximum_score;
909
+
910
+
911
+                    $('#Assoc_Scales').html(' ');
912
+                    for (var i = 0; i < scaleLength; i++) {
913
+
914
+                        div = '<div id="assoc_eval' + i.toString() + '">' +
915
+                            '<div class ="form-row">' +
916
+                            '<label for="header' + (i).toString() + '">Evaluación ' + (i + 1).toString() + '</label><br><br>' +
917
+                            '<input type="hidden"  id="header' + i.toString() + '">' +
918
+                            '<div class="form-group col-md-8" >' +
919
+                            '<label for="title' + i.toString() + '">Nombre de Evaluación ' + (i + 1).toString() + '</label>' +
920
+                            '<input class="form-control" name="assoc_title[]" value ="' + json.scales[i].title + '"type="text"  id="title' + i.toString() + '" placeholder ="Nombre de evaluacion" ></div>' +
921
+                            '<div class ="form-group col-md-2">' +
922
+                            '<label for="min' + i.toString() + '">Mínimo </label>' +
923
+                            '<input class="form-control" type="number" id="assoc_min' + i.toString() + '" min="1" max = "' + maximum + '" value ="' + json.scales[i].min_score + '"oninput ="changedMin(' + "'assoc_min" + i.toString() + "', '" + i.toString() + "', 'Assoc_Scales' " + ')" name = "assoc_min[]"></div>' +
924
+                            '<div class ="form-group col-md-2">' +
925
+                            '<label for="max' + i.toString() + '">Máximo </label>' +
926
+                            '<input class="form-control" type="number" id="assoc_max' + i.toString() + '" min="1" max = "' + maximum + '" value ="' + json.scales[i].max_score + '"oninput ="changedMax(' + "'assoc_max" + i.toString() + "', '" + i.toString() + "', 'Assoc_Scales' " + ')" name = "assoc_max[]"></div></div>' +
927
+                            '<div class ="form-group">' +
928
+                            '<label for ="descripcion' + i.toString() + '">Descripción de evaluación</label>' +
929
+                            '<textarea class="form-control" rows="2" aria-labelledby="descripcion' + i.toString() + '" name="assoc_scales[]" cols="50" >' + json.scales[i].description + '</textarea></div></div>';
930
+                        fullDiv += div;
931
+
932
+                    }
664 933
                 }
665 934
 
666
-                $('#program_id2').selectpicker('refresh');
935
+                addOptions('Num_assoc_scale', 'assoc_maximum_score');
936
+
937
+                $('#Assoc_Scales').append(fullDiv);
938
+                $('#Assoc_Scales').attr('data-value', scaleLength);
939
+                $('#Num_assoc_scale').val(scaleLength);
940
+                $('#Num_assoc_scale').selectpicker('refresh')
941
+
942
+
943
+
667 944
 
668 945
 
669
-                // Select status
670
-                if (json.criteria[0].deleted_at)
671
-                    $('#status').val(0);
672
-                else
673
-                    $('#status').val(1);
674 946
             },
675 947
             'json'
676 948
         );

+ 5
- 5
app/views/local/managers/admins/objectives.blade.php Ver fichero

@@ -91,7 +91,7 @@
91 91
                     <div id='assocOutcomeGroup'>
92 92
                         <label>Associated Outcome</label>
93 93
 
94
-                        {{ Form::select('assoc_outcome[0]', $outcomes, null, ['class'=>'form-control selectpicker', 'id'=>'assoc_outcome0']) }}
94
+                        {{ Form::select('assoc_outcome[]', $outcomes, null, ['class'=>'form-control selectpicker', 'id'=>'assoc_outcome0']) }}
95 95
 
96 96
                     </div>
97 97
                 </div>
@@ -245,7 +245,7 @@
245 245
                 for (var i = 1; i < length; i++) {
246 246
                     var $select = $('<select />', {
247 247
                         'class': "selectpicker form-control",
248
-                        'name': "assoc_outcome[" + i.toString() + "]",
248
+                        'name': "assoc_outcome[]",
249 249
                         'data-live-search': 'true',
250 250
                         'id': 'assoc_outcome' + i.toString()
251 251
 
@@ -314,10 +314,10 @@
314 314
 
315 315
     function addAssoc() {
316 316
 
317
-        counterAssoc += 1;
317
+
318 318
         var $select = $('<select />', {
319 319
             'class': "selectpicker form-control",
320
-            'name': "assoc_outcome[" + counterAssoc.toString() + "]",
320
+            'name': "assoc_outcome[]",
321 321
             'data-live-search': 'true',
322 322
             'id': 'assoc_outcome' + counterAssoc.toString()
323 323
 
@@ -347,7 +347,7 @@
347 347
 
348 348
 
349 349
         ran = true;
350
-
350
+        counterAssoc += 1;
351 351
 
352 352
 
353 353
     }

+ 16
- 14
app/views/local/managers/pCoords/_navigation.blade.php Ver fichero

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

+ 1023
- 0
app/views/local/managers/pCoords/criteria.blade.php
La diferencia del archivo ha sido suprimido porque es demasiado grande
Ver fichero


+ 419
- 0
app/views/local/managers/pCoords/objectives.blade.php Ver fichero

@@ -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

+ 16
- 14
app/views/local/managers/sCoords/_navigation.blade.php Ver fichero

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

+ 1029
- 0
app/views/local/managers/sCoords/criteria.blade.php
La diferencia del archivo ha sido suprimido porque es demasiado grande
Ver fichero


+ 420
- 0
app/views/local/managers/sCoords/objectives.blade.php Ver fichero

@@ -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