Browse Source

Cambios a todo menos Criteria Objective_outcome

parent
commit
8eccda4d85

+ 109
- 61
app/controllers/CriteriaController.php View File

@@ -156,14 +156,20 @@ class CriteriaController extends \BaseController
156 156
         else
157 157
             $program_id = NULL;
158 158
 
159
-        $saved_criterion = Criterion::withTrashed()
159
+        $saved_criterion = DB::table('criteria')
160
+            ->join('program_criterion', 'program_criterion.criterion_id', '=', 'criteria.id')
161
+            ->join('criterion_objective_outcome', 'criterion_objective_outcome.criterion_id', '=', 'criteria.id')
162
+            ->whereIn('program_id', $input['program_id'])
163
+            ->whereIn('objective_id', $input['objective_id'])
164
+            ->whereIn('outcome_id', $input['outcome_id'])
160 165
             ->where('name', '=', $input['name'])
161
-            ->where('outcome_id', '=', $input['outcome_id'])
162
-            ->where('program_id', '=', $program_id)
166
+            ->where('subcriteria', '=', $input['subcriteria'])
163 167
             ->first();
164 168
 
165 169
 
166 170
 
171
+
172
+
167 173
         if ($saved_criterion)
168 174
             return false;
169 175
         else
@@ -227,16 +233,19 @@ class CriteriaController extends \BaseController
227 233
                 'outcome_id' => $clean_input['outcome_id'],
228 234
                 'notes' => $clean_input['notes'],
229 235
                 'copyright' => $clean_input['copyright'],
230
-                'maximum_score' => $clean_input['maximum_score']
236
+                'maximum_score' => $clean_input['maximum_score'],
237
+                'scales' => $clean_input['scale_description'],
238
+                'objective_id' => $clean_input['objective_id']
231 239
             ),
232 240
             array(
233 241
                 'name' => 'required|string',
234 242
                 'subcriteria' => 'string',
235 243
                 'outcome_id' => 'required|array',
236
-
244
+                'scales' => 'required|array',
237 245
                 'notes' => 'string',
238 246
                 'copyright' => 'string',
239
-                'maximum_score' => 'required|integer'
247
+                'maximum_score' => 'required|integer',
248
+                'objective_id' => 'required|array'
240 249
             )
241 250
 
242 251
         );
@@ -281,12 +290,23 @@ class CriteriaController extends \BaseController
281 290
             }
282 291
         } else {
283 292
             // Check criterion uniqueness
284
-            /*if (!$this->isCriterionUnique($clean_input)) {
285
-                /** Send error message and old data
293
+            if (!$this->isCriterionUnique($clean_input)) {
294
+                /** Send error message and old data*/
286 295
                 Session::flash('status', 'danger');
287 296
                 Session::flash('message', 'This criterion is a duplicate of an already saved criterion because its name and associated program are the same.');
288
-                return Redirect::to('criteria')->withInput();
289
-            }*/
297
+
298
+                $role = Auth::user()['role'];
299
+                switch ($role) {
300
+                    case 1:
301
+                        return Redirect::to('criteria')->withInput();
302
+
303
+                    case 2:
304
+                        return Redirect::to('school-criteria')->withInput();
305
+
306
+                    case 3:
307
+                        return Redirect::to('program-criteria')->withInput();
308
+                }
309
+            }
290 310
 
291 311
             /** Instantiate new criterion */
292 312
             $criterion = new Criterion;
@@ -296,8 +316,8 @@ class CriteriaController extends \BaseController
296 316
 
297 317
             //gabriel añadió aqui
298 318
 
299
-            //$criterion->number_of_scales = $clean_input['number_of_scales'];
300
-            //$criterion->maximum_score = $clean_input['maximum_score'];
319
+            $criterion->num_scales = $clean_input['number_of_scales'];
320
+            $criterion->max_score = $clean_input['maximum_score'];
301 321
 
302 322
             if (Input::get('copyright'))
303 323
                 $criterion->copyright = $clean_input['copyright'];
@@ -319,27 +339,34 @@ class CriteriaController extends \BaseController
319 339
                 }
320 340
 
321 341
                 for ($i = 0; $i < sizeof($clean_input['scale_description']); $i++) {
322
-                    $scale = new Scale;
323 342
 
324
-                    $position = $i;
325
-                    $scale->description = $clean_input['scale_description'][$i];
343
+                    $existing_scale = DB::table('scales')->where('description', $clean_input['scale_description'][$i])
344
+                        ->first();
345
+                    if ($existing_scale) {
346
+                        DB::insert("insert_into `criterion_scale` (`criterion_id`, `scale_id`, `position`) values({$criterionId},{$existing_scale->id},{$i})");
347
+                    } else {
348
+                        $scale = new Scale;
326 349
 
350
+                        $position = $i;
351
+                        $scale->description = $clean_input['scale_description'][$i];
327 352
 
328
-                    if ($scale->save()) {
329
-                        DB::insert("insert into `criterion_scale` (`criterion_id`, `scale_id`, `position`) values({$criterionId},{$scale->id}, {$position})");
330
-                    } else {
331
-                        Session::flash('status', 'danger');
332
-                        Session::flash('message', '<p>Error creating the Scales</p>');
333
-                        $role = Auth::user()['role'];
334
-                        switch ($role) {
335
-                            case 1:
336
-                                return Redirect::to('criteria')->withInput();
337
-
338
-                            case 2:
339
-                                return Redirect::to('school-criteria')->withInput();
340
-
341
-                            case 3:
342
-                                return Redirect::to('program-criteria')->withInput();
353
+
354
+                        if ($scale->save()) {
355
+                            DB::insert("insert into `criterion_scale` (`criterion_id`, `scale_id`, `position`) values({$criterionId},{$scale->id}, {$position})");
356
+                        } else {
357
+                            Session::flash('status', 'danger');
358
+                            Session::flash('message', '<p>Error creating the Scales</p>');
359
+                            $role = Auth::user()['role'];
360
+                            switch ($role) {
361
+                                case 1:
362
+                                    return Redirect::to('criteria')->withInput();
363
+
364
+                                case 2:
365
+                                    return Redirect::to('school-criteria')->withInput();
366
+
367
+                                case 3:
368
+                                    return Redirect::to('program-criteria')->withInput();
369
+                            }
343 370
                         }
344 371
                     }
345 372
                 }
@@ -436,10 +463,10 @@ class CriteriaController extends \BaseController
436 463
 
437 464
         $clean_input['copyright'] = trim(preg_replace('/\t+/', '', Input::get('copyright')));
438 465
         $clean_input['notes'] = trim(preg_replace('/\t+/', '', Input::get('notes')));
439
-        /* $clean_input['maximum_score'] = (int) Input::get('assoc_maximum_score');
440
-        $clean_input['scale_title'] = Input::get('assoc_title');
466
+        $clean_input['maximum_score'] = (int) Input::get('assoc_maximum_score');
467
+        //$clean_input['scale_title'] = Input::get('assoc_title');
441 468
         $clean_input['scale_description'] = Input::get('assoc_scales');
442
-        $clean_input['number_of_scales'] = sizeof($clean_input['scale_title']);*/
469
+        $clean_input['number_of_scales'] = sizeof($clean_input['scale_description']);
443 470
 
444 471
 
445 472
         return $clean_input;
@@ -482,19 +509,29 @@ class CriteriaController extends \BaseController
482 509
         } else {
483 510
 
484 511
             // // Check criterion uniqueness
485
-            // if(!$this->isCriterionUnique($clean_input, $criterion))
486
-            // {
487
-            //     /** Send error message and old data */
488
-            //     Session::flash('status', 'danger');
489
-            //     Session::flash('message', 'This criterion is a duplicate of an already saved criterion because its name, assoaciated school or program, and progress indicators are the same.');
490
-            //     return Redirect::to('criteria')->withInput();
491
-            // }
512
+            if (!$this->isCriterionUnique($clean_input, $criterion)) {
513
+                /** Send error message and old data */
514
+                Session::flash('status', 'danger');
515
+                Session::flash('message', 'This criterion is a duplicate of an already saved criterion because its name, assoaciated school or program, and progress indicators are the same.');
516
+                $role = Auth::user()['role'];
517
+                switch ($role) {
518
+                    case 1:
519
+                        return Redirect::to('objective')->withInput();
520
+
521
+                    case 2:
522
+                        return Redirect::to('school-objective')->withInput();
523
+
524
+                    case 3:
525
+                        return Redirect::to('program-objective')->withInput();
526
+                }
527
+            }
492 528
 
493 529
             /** Set info */
494 530
             $criterion->name = $clean_input['name'];
495 531
             $criterion->subcriteria = $clean_input['subcriteria'];
496 532
 
497
-
533
+            $criterion->num_scales = $clean_input['number_of_scales'];
534
+            $criterion->max_score = $clean_input['maximum_score'];
498 535
 
499 536
 
500 537
 
@@ -535,31 +572,42 @@ class CriteriaController extends \BaseController
535 572
                         DB::insert("insert into `criterion_objective_outcome` (`objective_id`, `outcome_id`, `criterion_id`) values ({$objective_id},{$outcome_id}, {$criterionId})");
536 573
                     }
537 574
                 }
575
+
538 576
                 /*DB::delete("delete from `scales` where id in (select scale_id id from criterion_scale where criterion_id = {$criterionId})");
577
+*/
578
+                DB::delete("delete from criterion_scale where criterion_id = {$criterionId}");
579
+                for ($i = 0; $i < sizeof($clean_input['scale_description']); $i++) {
539 580
 
540
-                for ($i = 0; $i < sizeof($clean_input['scale_title']); $i++) {
541
-                    $scale = new Scale;
542
-                    $scale->title = $clean_input['scale_title'][$i];
543
-                    $scale->position = $i + 1;
544
-                    $scale->description = $clean_input['scale_description'][$i];
545
-                    if ($scale->save()) {
546
-                        DB::insert("insert into `criterion_scale` (`criterion_id`, `scale_id`) values({$criterionId},{$scale->id})");
581
+                    $existing_scale = DB::table('scales')->where('description', $clean_input['scale_description'][$i])
582
+                        ->first();
583
+                    if ($existing_scale) {
584
+                        DB::insert("insert_into `criterion_scale` (`criterion_id`, `scale_id`, `position`) values({$criterionId},{$existing_scale->id},{$i})");
547 585
                     } else {
548
-                        Session::flash('status', 'danger');
549
-                        Session::flash('message', '<p>Error creating the Scales</p>');
550
-                        $role = Auth::user()['role'];
551
-                        switch ($role) {
552
-                            case 1:
553
-                                return Redirect::to('objective')->withInput();
554
-
555
-                            case 2:
556
-                                return Redirect::to('school-objective')->withInput();
557
-
558
-                            case 3:
559
-                                return Redirect::to('program-objective')->withInput();
586
+                        $scale = new Scale;
587
+
588
+                        $position = $i;
589
+                        $scale->description = $clean_input['scale_description'][$i];
590
+
591
+
592
+                        if ($scale->save()) {
593
+                            DB::insert("insert into `criterion_scale` (`criterion_id`, `scale_id`, `position`) values({$criterionId},{$scale->id}, {$position})");
594
+                        } else {
595
+                            Session::flash('status', 'danger');
596
+                            Session::flash('message', '<p>Error creating the Scales</p>');
597
+                            $role = Auth::user()['role'];
598
+                            switch ($role) {
599
+                                case 1:
600
+                                    return Redirect::to('criteria')->withInput();
601
+
602
+                                case 2:
603
+                                    return Redirect::to('school-criteria')->withInput();
604
+
605
+                                case 3:
606
+                                    return Redirect::to('program-criteria')->withInput();
607
+                            }
560 608
                         }
561 609
                     }
562
-                }*/
610
+                }
563 611
                 foreach ($clean_input['program_id'] as $program_id) {
564 612
                     DB::insert("insert into `program_criterion` (`criterion_id`, `program_id`) values({$criterionId},{$program_id})");
565 613
                 }

+ 33
- 0
app/database/migrations/2021_07_08_093000_add_max_num_to_criteria.php View File

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

+ 32
- 0
app/database/migrations/2021_07_09_150656_edit_template_criterion.php View File

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

+ 32
- 0
app/database/migrations/2021_07_09_150819_edit_rubric_criterion.php View File

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

+ 59
- 1
app/models/Activity.php View File

@@ -31,6 +31,35 @@ class Activity extends Eloquent
31 31
 
32 32
     return count($amount_of_students);
33 33
   }
34
+
35
+  public function criteria_achieved()
36
+  {
37
+
38
+    $activity_criterion = DB::table('activity_criterion')
39
+      ->where('activity_id', '=', $this->id)
40
+      ->get();
41
+    $criteria_achieved = [];
42
+    foreach ($activity_criterion as $index => $single_ac) {
43
+
44
+      $assessments_passed = count(DB::table('assessments')
45
+        ->where('score', '>=', $this->rubric[0]->expected_points)
46
+        ->where('activity_criterion_id', '=', $single_ac->id)
47
+        ->lists('student_id'));
48
+      $assessments_attempted = count(DB::table('assessments')
49
+        ->where('activity_criterion_id', '=', $single_ac->id)
50
+        ->lists('student_id'));
51
+
52
+      if ((($assessments_passed / $assessments_attempted) * 100) >= $this->rubric[0]->expected_percentage) {
53
+        $criteria_achieved[$single_ac->criterion_id] = 1;
54
+      } else {
55
+        $criteria_achieved[$single_ac->criterion_id] = 0;
56
+      }
57
+    }
58
+    return  $criteria_achieved;
59
+  }
60
+
61
+
62
+
34 63
   // cap_array
35 64
   public function getCapArrayAttribute()
36 65
   {
@@ -85,6 +114,7 @@ class Activity extends Eloquent
85 114
   // o_ach_array
86 115
   public function getOAchArrayAttribute($value)
87 116
   {
117
+    /*
88 118
     $outcomes_achieved = [];
89 119
     $all_criterion = DB::table('activity_criterion')
90 120
       ->where('activity_criterion.activity_id', '=', $this->id)
@@ -129,11 +159,39 @@ class Activity extends Eloquent
129 159
       }
130 160
     }
131 161
 
162
+    return $outcomes_achieved;*/
163
+
164
+    $outcomes_achieved = [];
165
+
166
+    $criteria_achieved = $this->criteria_achieved();
167
+
168
+
169
+    $all_outcomes = DB::table('outcomes')->lists('id');
170
+
171
+    foreach ($all_outcomes as $outcome_id) {
172
+      $outcomes_achieved[$outcome_id] = 0;
173
+    }
174
+
175
+    foreach ($criteria_achieved as $criterion_id => $passed) {
176
+
177
+      if ($passed == 1) {
178
+        $outcomes_related = DB::table('criterion_objective_outcome')
179
+          ->where("criterion_id", '=', $criterion_id)
180
+          ->select('outcome_id')
181
+          ->distinct()
182
+          ->lists('outcome_id');
183
+
184
+        foreach ($outcomes_related as $index => $outcome_id) {
185
+
186
+          $outcomes_achieved[$outcome_id] += 1;
187
+        }
188
+      }
189
+    }
132 190
     return $outcomes_achieved;
133 191
   }
134 192
 
135 193
   // o_att_array
136
-  public function getOAttArrayAttribute($value)
194
+  public function getOAttArrayAttribute()
137 195
   {
138 196
 
139 197
 

+ 37
- 12
app/views/local/managers/pCoords/criteria.blade.php View File

@@ -284,37 +284,62 @@
284 284
         $('#' + select).html(options);
285 285
         $('#' + select).val(previousvalue);
286 286
         $('#' + select).selectpicker('refresh');
287
+        $('#'+select).trigger('change');
287 288
     }
288 289
 
289 290
     function numberOfAssoc(string, Scales) {
290 291
         var maximum = $('#assoc_maximum_score').val();
291 292
         var amountOfScale = parseInt($('#' + string).val());
292 293
         var dataValue = parseInt($('#' + Scales).attr('data-value'));
294
+        var division = maximum/amountOfScale;
293 295
         //add
294
-        if (dataValue < amountOfScale) {
296
+        
295 297
 
296 298
             fullDiv = '';
297
-
299
+        if(division ==1){
298 300
             for (var i = dataValue; i < amountOfScale; i++) {
299 301
                 div = '<div id="assoc_eval' + i.toString() + Scales + '">' +
300 302
                     '<div class ="form-group">' +
301
-                    '<label for ="descripcion' + i.toString() + '">Descripción de evaluación</label>' +
302
-                    '<textarea class="form-control" rows="2" aria-labelledby="descripcion' + i.toString() + '" name="assoc_scales[]" cols="50" ></textarea></div></div>';
303
+                    '<label for ="assoc_descripcion' + i.toString() + '">Scale Description ('+(i+1)+')</label>' +
304
+                    '<textarea class="form-control" rows="2" aria-labelledby="assoc_descripcion' + i.toString() + '" name="assoc_scales[]" cols="50" ></textarea></div></div>';
303 305
                 fullDiv += div;
304 306
 
305 307
 
306 308
             }
309
+        }
310
+        else if(division == maximum){
311
+            div = '<div id="assoc_eval' +0 + Scales + '">' +
312
+                    '<div class ="form-group">' +
313
+                    '<label for ="assoc_descripcion' + 0 + '">Scale Description ('+1+' - '+maximum+') </label>' +
314
+                    '<textarea class="form-control" rows="2" aria-labelledby="assoc_descripcion' + 0 + '" name="assoc_scales[]" cols="50" ></textarea></div></div>';
315
+                fullDiv += div;
316
+        }
317
+        else{
318
+            for (var i = 0; i < amountOfScale; i++) {
307 319
 
308
-            $('#' + Scales).append(fullDiv);
309
-            $('#' + Scales).attr('data-value', amountOfScale);
310
-        } else {
311
-            for (var i = dataValue; i > amountOfScale; i--) {
312
-                $('#assoc_eval' + (i - 1).toString()).remove();
313
-            }
320
+            div = '<div id="assoc_eval' + i.toString() + Scales + '">' +
321
+                    '<div class ="form-group">' +
322
+                    '<label for ="assoc_descripcion' + i.toString() + '">Scale Description ('+(1+(i*division))+' - '+((1+i)*division)+')</label>' +
323
+                    '<textarea class="form-control" rows="2" aria-labelledby="assoc_descripcion' + i.toString() + '" name="assoc_scales[]" cols="50" ></textarea></div></div>';
324
+                fullDiv += div;
325
+        }
314 326
         }
315
-        $('#' + Scales).attr('data-value', amountOfScale);
316 327
 
317
-    }
328
+            $('#' + Scales).html(fullDiv);
329
+            $('#' + Scales).attr('data-value', amountOfScale);
330
+        } 
331
+    
332
+        
333
+
334
+        
335
+        
336
+        //add
337
+    
338
+
339
+
340
+
341
+
342
+
318 343
    
319 344
     function numberOfScales(string, Scales) {
320 345
         var maximum = parseInt($('#maximum_score').val());

+ 1
- 0
app/views/local/professors/assessment_report.blade.php View File

@@ -119,6 +119,7 @@ Log::info('aqui papi');?>
119 119
                                                 $o_ach_array = $activity->o_ach_array;
120 120
                                                 Log::info($o_att_array);
121 121
                                                 Log::info($o_ach_array);
122
+                                                Log::info('los outcomes');
122 123
                                                 $percentage = ($o_ach_array[$outcome->id]/$o_att_array[$outcome->id])*100;
123 124
                                             ?>
124 125
                                             @if($percentage >= 100)