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