Procházet zdrojové kódy

Antes de buscar criterios

Gabriel Santiago Plaza před 3 roky
rodič
revize
94f41117d6

+ 5
- 2
app/controllers/ActivitiesController.php Zobrazit soubor

@@ -195,13 +195,16 @@ class ActivitiesController extends \BaseController
195 195
         // Get results
196 196
         $activity_criterion_ids = DB::table('activity_criterion')->where("activity_id", '=', $activity->id)->lists('id');
197 197
         Log::info($activity_criterion_ids);
198
-        $assessments = DB::table('assessments')->join('students', 'assessments.student_id', '=', 'students.id')->whereIn('activity_criterion_id', $activity_criterion_ids)->orderBy('assessments.id', 'asc')->get();
198
+        $assessments = DB::table('assessments')
199
+            ->join('students', 'assessments.student_id', '=', 'students.id')
200
+            ->whereIn('activity_criterion_id', $activity_criterion_ids)
201
+            ->orderBy('assessments.id', 'asc')->get();
199 202
         Log::info($assessments);
200 203
         // Decode the scores (blade workaround)
201 204
         $scores_array = array();
202 205
 
203 206
         foreach ($assessments as $index => $assessment) {
204
-            $scores_array[$assessment->student_id][$index] = $assessment->score;
207
+            $scores_array[$assessment->student_id][] = $assessment->score;
205 208
             $scores_array[$assessment->student_id]['comments'] = DB::table('activity_student')->where('student_id', '=', $assessment->student_id)
206 209
                 ->where("activity_id", '=', $activity->id)
207 210
                 ->select('comments')->first()->comments;

+ 31
- 13
app/controllers/OutcomesController.php Zobrazit soubor

@@ -567,15 +567,15 @@ class OutcomesController extends \BaseController
567 567
             $level = $level->levels;
568 568
 
569 569
             // buscar todos los criterios con el level y ponerlos en un array
570
-//             $outcome_criterias = DB::table('criterion_objective_outcome')
571
-//                 ->join('new_criteria', 'new_criteria.id', '=', 'criterion_objective_outcome.criterion_id')
572
-//                 ->join('objectives', 'objectives.id', '=', 'criterion_objective_outcome.objective_id')
573
-//                 ->where('criterion_objective_outcome.outcome_id', $id)
574
-//                 ->where('new_criteria.number_of_scales', $level)
575
-//                 ->whereNull('new_criteria.deleted_at')
576
-//                 ->select('new_criteria.id', 'new_criteria.name')
577
-//                 ->orderBy('new_criteria.name', 'asc')
578
-//                 ->get();
570
+            //             $outcome_criterias = DB::table('criterion_objective_outcome')
571
+            //                 ->join('new_criteria', 'new_criteria.id', '=', 'criterion_objective_outcome.criterion_id')
572
+            //                 ->join('objectives', 'objectives.id', '=', 'criterion_objective_outcome.objective_id')
573
+            //                 ->where('criterion_objective_outcome.outcome_id', $id)
574
+            //                 ->where('new_criteria.number_of_scales', $level)
575
+            //                 ->whereNull('new_criteria.deleted_at')
576
+            //                 ->select('new_criteria.id', 'new_criteria.name')
577
+            //                 ->orderBy('new_criteria.name', 'asc')
578
+            //                 ->get();
579 579
             $outcome_criterias = DB::table('criterion_objective_outcome')
580 580
                 ->join('criteria', 'criteria.id', '=', 'criterion_objective_outcome.criterion_id')
581 581
                 ->join('objectives', 'objectives.id', '=', 'criterion_objective_outcome.objective_id')
@@ -779,14 +779,32 @@ class OutcomesController extends \BaseController
779 779
         if (!$outcome)
780 780
             App::abort('404');
781 781
         $title = "My Courses' Assessment Report: " . $outcome->name;
782
+        $activity_criterion = DB::table('assessments')->lists('activity_criterion_id');
783
+        $courses = DB::table("courses")
784
+            ->join('activities', 'activities.course_id', '=', 'courses.id')
785
+            ->join('activity_criterion', 'activity_criterion.activity_id', '=', 'activities.id')
786
+            ->whereIn('activity_criterion.id', $activity_criterion)
787
+            ->where('courses.user_id', '=', Auth::user()->id)
788
+            ->where('activities.draft', '=', 0)
789
+            ->whereIn('courses.semester_id', Session::get('semesters_ids'))
790
+            ->groupBy(array('code', 'number'))
791
+            ->get();
792
+        /*$courses = Course::has('activites')
793
+            ->join('activity_criterion', 'activity_criterion.activity_id', '=', 'activities.id')
794
+            ->where('user_id', Auth::user()->id)
795
+            ->where('activities.draft', '=', 0)
796
+            ->whereIn('semester_id', Semester::get('semester_ids'))
797
+            ->whereIn('activity_criterion.id', $activity_criterion)
798
+            ->groupBy(array('code', 'number'))
799
+            ->get();*/
782 800
 
783
-
784
-        $courses = Course::where('user_id', Auth::user()->id)
801
+        /*$courses = Course::where('user_id', Auth::user()->id)
785 802
             ->has('activities')
786
-            ->whereNotNull('outcomes_attempted')
803
+            //->whereNotNull('outcomes_attempted')
787 804
             ->whereIn('semester_id', Session::get('semesters_ids'))
788 805
             ->groupBy(array('code', 'number'))
789
-            ->get();
806
+            ->get();*/
807
+
790 808
 
791 809
         return View::make('local.professors.assessment_report', compact('title', 'outcome', 'courses'));
792 810
     }

+ 35
- 0
app/database/migrations/2021_07_06_075249_fix_activities.php Zobrazit soubor

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

+ 42
- 0
app/database/migrations/2021_07_06_075356_criterion_scale.php Zobrazit soubor

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

+ 124
- 4
app/models/Activity.php Zobrazit soubor

@@ -23,22 +23,142 @@ class Activity extends Eloquent
23 23
   {
24 24
     return $this->belongsToMany('Student', 'assessments')->withPivot('scores', 'percentage')->withTimestamps();
25 25
   }
26
+  public function amount_of_assessed_students()
27
+  {
28
+
29
+    $activity_criterion = DB::table('activity_criterion')->where('activity_id', '=', $this->id)->lists('id');
30
+    $amount_of_students = DB::table('assessments')->whereIn('activity_criterion_id', $activity_criterion)->lists('student_id');
26 31
 
32
+    return count($amount_of_students);
33
+  }
27 34
   // cap_array
28
-  public function getCapArrayAttribute($value)
35
+  public function getCapArrayAttribute()
29 36
   {
30
-    return json_decode($this->criteria_achieved_percentage, true);
37
+    $criteria_achieved_percentage = [];
38
+
39
+
40
+    $criterias = DB::table('criteria')
41
+      ->join('activity_criterion', 'activity_criterion.criterion_id', '=', 'criteria.id')
42
+      ->where('activity_criterion.activity_id', '=', $this->id)
43
+      ->select(
44
+        'activity_criterion.id as id',
45
+        'activity_criterion.criterion_id as criterion_id',
46
+        'activity_criterion.activity_id as activity_id'
47
+      )
48
+      ->addSelect('criteria.name', 'criteria.subcriteria')
49
+      ->get();
50
+    Log::info($criterias);
51
+    Log::info($this->rubric);
52
+    Log::info("this is rubric");
53
+    foreach ($criterias as $index => $single_crit) {
54
+
55
+
56
+      $single_crit->outcome_id = json_encode(DB::table('criterion_objective_outcome')
57
+        ->where('criterion_id', '=', $single_crit->criterion_id)
58
+        ->lists('outcome_id'));
59
+      Log::info(json_decode($single_crit->outcome_id));
60
+      $amount_of_students = count(DB::table('assessments')
61
+        ->where("activity_criterion_id", '=', $single_crit->id)
62
+        ->lists('student_id'));
63
+      Log::info($amount_of_students);
64
+      Log::info($single_crit->id);
65
+      Log::info('lmaoOOOO');
66
+
67
+      $student_pass = DB::table('assessments')
68
+        ->where("activity_criterion_id", '=', $single_crit->id)
69
+        ->where('score', '>=', $this->rubric[0]->expected_points)
70
+        ->lists('student_id');
71
+      Log::info($student_pass);
72
+      $amount_of_students_passed = count(DB::table('assessments')
73
+        ->where("activity_criterion_id", '=', $single_crit->id)
74
+        ->where('score', '>=', $this->rubric[0]->expected_points)
75
+        ->lists('student_id'));
76
+      Log::info($amount_of_students_passed);
77
+      Log::info('es aqui');
78
+      $single_crit->score_percentage = ($amount_of_students_passed / $amount_of_students) * 100;
79
+      $criteria_achieved_percentage[$single_crit->criterion_id] = $single_crit;
80
+      Log::info("?");
81
+    }
82
+    return $criteria_achieved_percentage;
31 83
   }
32 84
 
33 85
   // o_ach_array
34 86
   public function getOAchArrayAttribute($value)
35 87
   {
36
-    return json_decode($this->outcomes_achieved, true);
88
+    $outcomes_achieved = [];
89
+    $all_criterion = DB::table('activity_criterion')
90
+      ->where('activity_criterion.activity_id', '=', $this->id)
91
+      ->get();
92
+
93
+    $attempted_criteria = 0;
94
+    $passed_criteria = 0;
95
+
96
+    $all_outcomes = DB::table('outcomes')->get();
97
+
98
+
99
+    foreach ($all_criterion as $index => $activity_crit) {
100
+
101
+      $amount_of_outcomes_attempted = DB::table('criterion_objective_outcome')
102
+        ->join('outcomes', 'outcomes.id', '=', 'criterion_objective_outcome.outcome_id')
103
+        ->where('criterion_id', '=', $activity_crit->criterion_id)
104
+        ->select('criterion_objective_outcome.outcome_id')
105
+        ->distinct()
106
+        ->orderBy('criterion_objective_outcome.outcome_id')
107
+        ->select('outcomes.id', 'outcomes.expected_outcome')
108
+        ->get();
109
+      $passed_criteria = count(DB::table('assessments')
110
+        ->where('activity_criterion_id', '=', $activity_crit->id)
111
+        ->where('score', '>=', $this->rubric[0]->expected_points)
112
+        ->lists('student_id'));
113
+      $attempted_criteria = count(DB::table('assessments')
114
+        ->where('activity_criterion_id', '=', $activity_crit->id)
115
+        ->lists('student_id'));
116
+      Log::info("For activity_crit " . ($activity_crit->id));
117
+      $percent_for_criteria = ($passed_criteria / $attempted_criteria) * 100;
118
+      Log::info('Percent calculated' . $percent_for_criteria);
119
+
120
+
121
+      $percent_for_criteria = ($passed_criteria / $attempted_criteria) * 100;
122
+
123
+      foreach ($amount_of_outcomes_attempted as $index2 => $outcome) {
124
+
125
+        if ($percent_for_criteria >= $this->rubric[0]->expected_percentage) {
126
+          if (array_key_exists($outcome->id, $outcomes_achieved)) $outcomes_achieved[$outcome->id] += 1;
127
+          else $outcomes_achieved[$outcome->id] = 1;
128
+        }
129
+      }
130
+    }
131
+
132
+    return $outcomes_achieved;
37 133
   }
38 134
 
39 135
   // o_att_array
40 136
   public function getOAttArrayAttribute($value)
41 137
   {
42
-    return json_decode($this->outcomes_attempted, true);
138
+
139
+
140
+    $outcomes_attempted = [];
141
+
142
+    $all_criterion = DB::table('activity_criterion')
143
+      ->where('activity_criterion.activity_id', '=', $this->id)
144
+      ->lists('criterion_id');
145
+
146
+    foreach ($all_criterion as $index => $criterion_id) {
147
+
148
+      $amount_of_outcomes = DB::table('criterion_objective_outcome')
149
+        ->where('criterion_id', '=', $criterion_id)
150
+        ->select('criterion_objective_outcome.outcome_id')
151
+        ->distinct()
152
+        ->orderBy('criterion_objective_outcome.outcome_id')
153
+        ->lists('outcome_id');
154
+
155
+      foreach ($amount_of_outcomes as $index2 => $outcome_id) {
156
+        if (array_key_exists($outcome_id, $outcomes_attempted)) $outcomes_attempted[$outcome_id] += 1;
157
+        else $outcomes_attempted[$outcome_id] = 1;
158
+      }
159
+    }
160
+
161
+    //return json_decode($this->outcomes_attempted, true);
162
+    return $outcomes_attempted;
43 163
   }
44 164
 }

+ 7
- 1
app/models/Course.php Zobrazit soubor

@@ -63,10 +63,16 @@ class Course extends Eloquent
63 63
     $criteria = DB::table('criteria')
64 64
       ->join('activity_criterion', 'activity_criterion.criterion_id', '=', 'criteria.id')
65 65
       ->join('activities', 'activity_criterion.activity_id', '=', 'activities.id')
66
+      ->join('rubric_activity', 'rubric_activity.activity_id', '=', 'activities.id')
67
+      ->join('rubric', 'rubric.id', '=', 'rubric_activity.rubric_id')
66 68
       ->join('courses', 'activities.course_id', '=', 'courses.id')
67 69
       ->join('criterion_objective_outcome', 'criterion_objective_outcome.criterion_id', '=', 'criteria.id')
68 70
       ->where('courses.id', '=', $this->id)
69
-      ->select('criteria.id', 'expected_percentage_students_achieving', 'activity_criterion.activity_id')
71
+      ->select(
72
+        'criteria.id',
73
+        'rubric.expected_percentage as expected_percentage_students_achieving'/*'expected_percentage_students_achieving',*/,
74
+        'activity_criterion.activity_id'
75
+      )
70 76
       ->distinct()
71 77
       ->get();
72 78
 

+ 35
- 21
app/views/local/professors/assessment_report.blade.php Zobrazit soubor

@@ -45,23 +45,30 @@
45 45
                         <!-- If grouped course has activities that evaluate the outcome -->
46 46
 
47 47
                         <?php
48
+
49
+
48 50
                             $sections_evaluating = Course::has('activities')
49
-                            ->whereNotNull('outcomes_attempted')
50
-                            ->whereRaw('outcomes_attempted not like \'%"'.$outcome->id.'":0%\'')
51
-                            ->with(array('activities'=>function($query) use(&$outcome){
52
-                                $query->whereNotNull('outcomes_attempted');
53
-                                $query->whereRaw('outcomes_attempted not like \'%"'.$outcome->id.'":0%\'');} ))
51
+                            
52
+                            //->whereNotNull('outcomes_attempted')
53
+                            //->whereRaw('outcomes_attempted not like \'%"'.$outcome->id.'":0%\'')
54
+                            //->with(array('activities'=>function($query) use(&$outcome){
55
+                            //    $query->whereNotNull('outcomes_attempted');
56
+                            //    $query->whereRaw('outcomes_attempted not like \'%"'.$outcome->id.'":0%\'');} ))
54 57
                             ->where('code', $course->code)->where('number',$course->number)
55 58
                             ->whereIn('semester_id', Session::get('semesters_ids'))
56 59
                             ->get();
60
+                            
61
+                            $semester_code = DB::table('semesters')->where('id', '=', $course->semester_id)->first();
62
+                            $program = DB::table('programs')->where('id', $course->program_id)->first();
63
+                            
57 64
                         ?>
58 65
 
59 66
                         @if(count($sections_evaluating))
60 67
                             <tr>
61 68
                                 <td>
62
-                                    {{ $course->code}}-{{ $course->number }} ({{ $course->semester->code }})
69
+                                    {{ $course->code}}-{{ $course->number }} ({{ $semester_code->code }})
63 70
                                 </td>
64
-                                <td>{{ $course->program->name }}</td>
71
+                                <td>{{ $program->name }}</td>
65 72
                                 <td>
66 73
                                 <!-- For each section -->
67 74
                                 @foreach($sections_evaluating as $index3 => $section)
@@ -69,29 +76,34 @@
69 76
 
70 77
                                     <!-- For each activity in the section -->
71 78
                                     @foreach($section->activities as $index4 => $activity)
72
-
79
+<?php Log::info($section); Log::info($section->activities) ;
80
+Log::info($activity->o_att_array);
81
+Log::info("this is the cap_array for ". $activity->name);
82
+Log::info($activity->cap_array);
83
+Log::info('aqui papi');?>
73 84
                                         <!-- If activity has a rubric and the rubric has the outcome being evaluated -->
74
-                                        @if(array_key_exists($outcome->id, (array)$activity->o_att_array) && $activity->o_att_array[$outcome->id] >=1)
85
+                                        @if(array_key_exists($outcome->id, (array)$activity->o_att_array))
75 86
                                             <h5>Measure {{ $index4 + 1 }}</h5>
76
-                                            <p>A rubric was used in the {{ $section->code }}-{{ $section->number }} ({{ $section->name }}) course ({{ date('M Y', strtotime($course->updated_at))}}) to assess students’ <u>{{ strtolower($outcome->name) }}</u> in the activity: "<strong>{{ $activity->name }}</strong>". At the time of assessment there were {{ $activity->assessed_students()->count() }} students in the section.</p>
77
-                                            <p>The expected performance level was that <strong>{{ $activity->rubric->expected_percentage }}%</strong> of students participating in the activity would score <strong>{{ $activity->rubric->expected_points }} points</strong>  or more in the 1-8 point scale used.</p>
87
+                                            <p>A rubric was used in the {{ $section->code }}-{{ $section->number }} ({{ $section->name }}) course ({{ date('M Y', strtotime($course->updated_at))}}) to assess students’ <u>{{ strtolower($outcome->name) }}</u> in the activity: "<strong>{{ $activity->name }}</strong>". At the time of assessment there were {{ $activity->amount_of_assessed_students() }} students in the section.</p>
88
+                                            <p>The expected performance level was that <strong>{{ $activity->rubric[0]->expected_percentage }}%</strong> of students participating in the activity would score <strong>{{ $activity->rubric[0]->expected_points }} points</strong>  or more in the 1-{{$activity->rubric[0]->max_score}} point scale used.</p>
78 89
                                             <p>The results for each criterion were as follows:</p>
79 90
 
80 91
                                             <table class="table table-condensed table-bordered datatable">
81
-                                                @foreach((array)$activity->cap_array as $index5 => $cap)
82
-                                                    <?php
83
-                                                        $criterion = Criterion::find($index5);
84
-                                                    ?>
85 92
 
86
-                                                    @if($criterion['outcome_id'] == $outcome->id && $cap >= $activity->rubric->expected_percentage )
93
+                                                @foreach($activity->cap_array as $criterion_id => $criterion)
94
+                                                    
95
+                                                        
96
+                                                    
97
+
98
+                                                    @if(in_array($outcome->id, json_decode($criterion->outcome_id))  /*== $outcome->id*/ && $criterion->score_percentage >= $activity->rubric[0]->expected_percentage )
87 99
                                                         <tr>
88
-                                                            <td>{{ $criterion['name'] }}</td>
89
-                                                            <td class="col-md-1 success">{{ $cap }}%</td>
100
+                                                            <td>{{ $criterion->name }}</td>
101
+                                                            <td class="col-md-1 success">{{ $criterion->score_percentage }}%</td>
90 102
                                                         </tr>
91
-                                                    @elseif($criterion['outcome_id'] == $outcome->id && $cap < $activity->rubric->expected_percentage )
103
+                                                    @elseif(in_array($outcome->id, json_decode($criterion->outcome_id)) && $criterion->score_percentage < $activity->rubric[0]->expected_percentage )
92 104
                                                         <tr>
93
-                                                            <td>{{ $criterion['name'] }}</td>
94
-                                                            <td class="col-md-1 danger">{{ $cap }}%</td>
105
+                                                            <td>{{ $criterion->name }}</td>
106
+                                                            <td class="col-md-1 danger">{{ $criterion->score_percentage }}%</td>
95 107
                                                         </tr>
96 108
                                                     @endif
97 109
                                                 @endforeach
@@ -105,6 +117,8 @@
105 117
                                             <?php
106 118
                                                 $o_att_array = $activity->o_att_array;
107 119
                                                 $o_ach_array = $activity->o_ach_array;
120
+                                                Log::info($o_att_array);
121
+                                                Log::info($o_ach_array);
108 122
                                                 $percentage = ($o_ach_array[$outcome->id]/$o_att_array[$outcome->id])*100;
109 123
                                             ?>
110 124
                                             @if($percentage >= 100)