Няма описание

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. <?php
  2. use Illuminate\Database\Eloquent\SoftDeletingTrait;
  3. class Objective extends Eloquent
  4. {
  5. use SoftDeletingTrait;
  6. protected $fillable = array('text', 'outcome_id', 'active');
  7. protected $table = 'objectives';
  8. protected $appends = array("grouped_annual_course");
  9. /**
  10. * Return the program that the objective belongs to
  11. *
  12. * @return Illuminate\Database\Eloquent\Model
  13. */
  14. public function program()
  15. {
  16. return $this->belongsTo('Program');
  17. }
  18. //paired_outcome
  19. public function getPairedOutcomeAttribute()
  20. {
  21. return Outcome::join('typ_semester_outcome', 'typ_semester_outcome.outcome_id', '=', 'outcomes.id')
  22. ->join('typ_semester_objectives', 'typ_semester_objectives.typ_semester_outcome_id', '=', 'typ_semester_outcome.id')
  23. ->where('typ_semester_objectives.id', $this->typ_semester_objective_id)
  24. ->select('typ_semester_outcome.id as typ_semester_outcome_id', 'outcomes.*')
  25. ->first();
  26. }
  27. public function getGroupedAnnualCourseAttribute()
  28. {
  29. if (isset($this->typ_semester_objective_id)) {
  30. /*$course_codes = DB::table('typ_semester_courses')
  31. ->join('courses', 'courses.id', '=', 'typ_semester_courses.course_id')
  32. ->where('typ_semester_objective_id', $this->typ_semester_objective_id)
  33. ->where('courses.program_id', $this->program_id)
  34. ->select('courses.code', 'courses.number', 'courses.id as course_id', 'typ_semester_courses.id as typ_semester_course_id', DB::raw("'{$this->semester_id}' as semester_id"), "courses.program_id")
  35. ->get();*/
  36. return Course::join('typ_semester_courses', 'courses.id', '=', 'typ_semester_courses.course_id')
  37. ->where('typ_semester_objective_id', $this->typ_semester_objective_id)
  38. ->where('courses.program_id', $this->program_id)
  39. ->select('courses.*', 'typ_semester_courses.id as typ_semester_course_id', DB::raw("'{$this->semester_id}' as semester_id"), "courses.program_id")
  40. ->get();
  41. // $course_code_id = $course_codes->lists('course_id');
  42. //$course_code_typ = $course_codes->lists('typ_semester_course_id');
  43. /*
  44. $courses = []; //Course::whereIn("id", $course_code_id)->get();
  45. foreach ($course_codes as $i => $code) {
  46. $c = Course::where('id', $code->course_id)->first();
  47. $c->setAttribute('typ_semester_course_id', $code->typ_semester_course_id); //$course_code_typ[$i]);
  48. /*$c->setAttribute(
  49. 'transforming_actions',
  50. DB::table('annual_plan_transformative')
  51. ->join('transformative_actions', 'transformative_actions.id', '=', 'annual_plan_transformative.trans_id')
  52. ->where('typ_semester_course_id', $c->typ_semester_course_id)
  53. ->select('transformative_actions.*')
  54. ->get()
  55. );
  56. //$c->setAttribute("future_typ_course_id", $this->()); //Course::getFutureTypSemesterCourses($c->typ_semester_course_id, $c->program_id));
  57. $c->setAttribute("students", Course::getStudentReportForOutcome($c));
  58. //$c->setAttribute("criteria", Course::getCriteriaPlanReport($c));
  59. $courses[] = $c;
  60. }
  61. return $courses;
  62. */
  63. }
  64. return null;
  65. }
  66. /**
  67. * Return the outcomes that the objective belongs to
  68. *
  69. * @return Illuminate\Database\Eloquent\Model
  70. */
  71. //Must have typ_semester_objective_id, program_id,semester_id to work
  72. //funciona con Outcome::getObjectivesReport
  73. //Es como la imagen suelta por el app llamada, tabla_estudiantes.jpg
  74. //
  75. public static function getPlanReport($objective)
  76. {
  77. $course_codes = DB::table('typ_semester_courses')
  78. ->join('courses', 'courses.id', '=', 'typ_semester_courses.course_id')
  79. ->where('typ_semester_objective_id', $objective->typ_semester_objective_id)
  80. ->where('courses.program_id', $objective->program_id)
  81. ->select('courses.code', 'courses.number', 'courses.id as course_id', 'typ_semester_courses.id as typ_semester_course_id', DB::raw("'{$objective->semester_id}' as semester_id"), "courses.program_id")
  82. ->get();
  83. Log::info($course_codes);
  84. //$course_codes['studentPerOutcome'] = array();
  85. foreach ($course_codes as $course_code) {
  86. $course_code->transforming_actions = DB::table('annual_plan_transformative')
  87. ->join('transformative_actions', 'transformative_actions.id', '=', 'annual_plan_transformative.trans_id')
  88. ->where('typ_semester_course_id', $course_code->typ_semester_course_id)
  89. ->select('transformative_actions.*')
  90. ->get();
  91. $course_code->future_typ_course_id = Course::getFutureTypSemesterCourses($course_code->typ_semester_course_id, $course_code->program_id);
  92. $course_code->students = Course::getStudentReportForOutcome($course_code);
  93. //Log::info(array($course_code));
  94. $course_code->criteria = Course::getCriteriaPlanReport($course_code);
  95. }
  96. return $course_codes;
  97. }
  98. public function outcomes()
  99. {
  100. return $this->belongsToMany('Outcome', 'objective_outcome', 'objective_id', 'outcome_id');
  101. }
  102. public function outcome()
  103. {
  104. return $this->belongsTo('Outcome');
  105. }
  106. /**
  107. * Return the program that the objective belongs to
  108. *
  109. * @return Illuminate\Database\Eloquent\Model
  110. */
  111. public function outcome_id()
  112. {
  113. return $this->hasMany('Objective_Outcome', 'objective_id');
  114. }
  115. }