123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155 |
- <?php
-
- use Illuminate\Database\Eloquent\SoftDeletingTrait;
-
- class Criterion extends Eloquent
- {
- use SoftDeletingTrait;
- protected $dates = ['deleted_at'];
-
-
- protected $table = 'criteria';
-
- public static function outcomes($criterion_id)
- {
-
-
-
- $outcomes = DB::table('criterion_objective_outcome')
- ->join('outcomes', 'outcomes.id', '=', 'criterion_objective_outcome.outcome_id')
- ->where('criterion_id', $criterion_id)
- ->select('outcomes.*')
- ->distinct()
- ->get();
- return $outcomes;
-
- }
-
-
-
- public function getObjectivesAttribute()
- {
- return $this->belongsToMany('Objective', 'criterion_objective_outcome');
- }
-
- public function rubrics()
- {
-
- return $this->belongsToMany('Rubric', 'rubric_criterion');
- }
-
-
-
-
-
-
-
- public function programs()
- {
- return $this->belongsToMany('Program', 'program_criterion');
- }
-
-
-
-
-
-
-
-
-
- public function program()
- {
- return $this->belongsTo('Program');
- }
-
-
-
-
-
-
- public function subcriteria()
- {
- return json_decode($this->subcriteria);
- }
-
- public static function students_attempted($criterion_id, $activity_id)
- {
- $students_attempted = 0;
-
-
-
- $activities_criterions = DB::table('activity_criterion')
- ->join('activities', 'activity_criterion.activity_id', '=', 'activities.id')
- ->join('courses', 'activities.course_id', '=', 'courses.id')
- ->where('activities.id', '=', $activity_id)
- ->where('activity_criterion.criterion_id', '=', $criterion_id)
- ->select('activity_criterion.id')
- ->distinct()
- ->get();
-
- foreach ($activities_criterions as $activity_criterion) {
-
-
-
-
-
-
- $students_attempted += DB::table('assessments')
- ->join('activity_criterion', 'assessments.activity_criterion_id', '=', 'activity_criterion.id')
- ->where('activity_criterion.id', $activity_criterion->id)
- ->whereNotNull('score')
- ->count();
- }
- return $students_attempted;
- }
-
- public static function students_achieved($criterion_id, $activity_id)
- {
- $students_achieved = 0;
-
-
-
-
-
-
-
-
-
- $activities_criterions = DB::table('activity_criterion')
- ->join('activities', 'activity_criterion.activity_id', '=', 'activities.id')
- ->join('courses', 'activities.course_id', '=', 'courses.id')
- ->join('rubric_activity', 'rubric_activity.activity_id', '=', 'activities.id')
- ->join('rubrics', 'rubric_activity.rubric_id', '=', 'rubrics.id')
- ->where('activities.id', '=', $activity_id)
- ->where('activity_criterion.criterion_id', '=', $criterion_id)
- ->select('activity_criterion.id', 'expected_points')
- ->distinct()
- ->get();
-
- foreach ($activities_criterions as $activity_criterion) {
-
-
-
-
-
-
-
-
- $students_achieved += DB::table('assessments')
- ->join('activity_criterion', 'assessments.activity_criterion_id', '=', 'activity_criterion.id')
- ->whereNotNull('score')
- ->where('activity_criterion.id', $activity_criterion->id)
- ->where('assessments.score', '>=', $activity_criterion->expected_points)
- ->count();
- }
- return $students_achieved;
- }
- }
|