説明なし

Criterion.php 4.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. <?php
  2. use Illuminate\Database\Eloquent\SoftDeletingTrait;
  3. class Criterion extends Eloquent
  4. {
  5. use SoftDeletingTrait;
  6. protected $dates = ['deleted_at'];
  7. // protected $table = 'new_criteria';
  8. protected $table = 'criteria';
  9. public function outcomes()
  10. {
  11. // return $this->belongs('Objective')->belongs('Outcome');
  12. // TODO: Changes here
  13. // return $this->belongs('Outcome');
  14. return $this->hasManyThrough('Outcome', 'Objective');
  15. }
  16. public function objectives()
  17. {
  18. return $this->belongsToMany('Objective');
  19. }
  20. public function rubrics()
  21. {
  22. // return $this->belongsToMany('Rubric', 'new_criterion_rubric');
  23. return $this->belongsToMany('Rubric', 'criterion_rubric');
  24. }
  25. /**
  26. * Return the program that the criterion belongs to
  27. *
  28. * @return Illuminate\Database\Eloquent\Model
  29. */
  30. public function program()
  31. {
  32. return $this->belongsTo('Program');
  33. }
  34. // public function activities()
  35. // {
  36. // return $this->hasManyThrough('Activity','activity_criterion');
  37. // }
  38. //
  39. public function subcriteria()
  40. {
  41. return json_decode($this->subcriteria);
  42. }
  43. public static function students_attempted($criterion_id, $activity_id)
  44. {
  45. $students_attempted = 0;
  46. // var_dump($criterion_id);
  47. // var_dump($semester);
  48. // exit();
  49. $activities_criterions = DB::table('activity_criterion')
  50. ->join('activities', 'activity_criterion.activity_id', '=', 'activities.id')
  51. ->join('courses', 'activities.course_id', '=', 'courses.id')
  52. ->where('activities.id', '=', $activity_id)
  53. ->where('activity_criterion.criterion_id', '=', $criterion_id)
  54. ->select('activity_criterion.id')
  55. ->distinct()
  56. ->get();
  57. foreach($activities_criterions as $activity_criterion)
  58. {
  59. // $students_attempted+=DB::table('new_assessments')
  60. // ->join('activity_criterion', 'new_assessments.activity_criterion_id', '=', 'activity_criterion.id')
  61. // ->where('activity_criterion.id',$activity_criterion->id)
  62. // ->count();
  63. $students_attempted+=DB::table('assessments')
  64. ->join('activity_criterion', 'assessments.activity_criterion_id', '=', 'activity_criterion.id')
  65. ->where('activity_criterion.id',$activity_criterion->id)
  66. ->count();
  67. }
  68. return $students_attempted;
  69. }
  70. public static function students_achieved($criterion_id, $activity_id)
  71. {
  72. $students_achieved=0;
  73. // $activities_criterions=DB::table('activity_criterion')
  74. // ->join('activities', 'activity_criterion.activity_id', '=', 'activities.id')
  75. // ->join('courses', 'activities.course_id', '=', 'courses.id')
  76. // ->where('activities.id','=',$activity_id)
  77. // ->where('activity_criterion.criterion_id','=',$criterion_id)
  78. // ->select('activity_criterion.id','expected_student_score')
  79. // ->distinct()
  80. // ->get();
  81. $activities_criterions=DB::table('activity_criterion')
  82. ->join('activities', 'activity_criterion.activity_id', '=', 'activities.id')
  83. ->join('courses', 'activities.course_id', '=', 'courses.id')
  84. ->join('rubric_activity', 'rubric_activity.activity_id', '=', 'activities.id')
  85. ->join('rubrics', 'rubric_activity.rubric_id', '=', 'rubrics.id')
  86. ->where('activities.id','=',$activity_id)
  87. ->where('activity_criterion.criterion_id','=',$criterion_id)
  88. ->select('activity_criterion.id','expected_points')
  89. ->distinct()
  90. ->get();
  91. foreach($activities_criterions as $activity_criterion)
  92. {
  93. // $expected_student_score=DB::table('new_criteria')->where('id',$criterion_id)->select('expected_student_score')->get();
  94. // $students_achieved+=DB::table('new_assessments')
  95. // ->join('activity_criterion', 'new_assessments.activity_criterion_id', '=', 'activity_criterion.id')
  96. // ->where('activity_criterion.id',$activity_criterion->id)
  97. // ->where('new_assessments.score','>=',$activity_criterion->expected_student_score)
  98. // ->count();
  99. $students_achieved+=DB::table('assessments')
  100. ->join('activity_criterion', 'assessments.activity_criterion_id', '=', 'activity_criterion.id')
  101. ->where('activity_criterion.id',$activity_criterion->id)
  102. ->where('assessments.score','>=',$activity_criterion->expected_points)
  103. ->count();
  104. }
  105. return $students_achieved;
  106. }
  107. }