Açıklama Yok

Objective.php 6.1KB

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