Brak opisu

Objective.php 2.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. /**
  9. * Return the program that the objective belongs to
  10. *
  11. * @return Illuminate\Database\Eloquent\Model
  12. */
  13. public function program()
  14. {
  15. return $this->belongsTo('Program');
  16. }
  17. /**
  18. * Return the outcomes that the objective belongs to
  19. *
  20. * @return Illuminate\Database\Eloquent\Model
  21. */
  22. //Must have typ_semester_objective_id, program_id,semester_id to work
  23. //funciona con Outcome::getObjectivesReport
  24. //Es como la imagen suelta por el app llamada, tabla_estudiantes.jpg
  25. //
  26. public static function getPlanReport($objective)
  27. {
  28. $course_codes = DB::table('typ_semester_courses')
  29. ->join('courses', 'courses.id', '=', 'typ_semester_courses.course_id')
  30. ->where('typ_semester_objective_id', $objective->typ_semester_objective_id)
  31. ->where('courses.program_id', $objective->program_id)
  32. ->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")
  33. ->get();
  34. Log::info($course_codes);
  35. //$course_codes['studentPerOutcome'] = array();
  36. foreach ($course_codes as $course_code) {
  37. $course_code->transforming_actions = DB::table('annual_plan_transformative')
  38. ->join('transformative_actions', 'transformative_actions.id', '=', 'annual_plan_transformative.trans_id')
  39. ->where('typ_semester_course_id', $course_code->typ_semester_course_id)
  40. ->select('transformative_actions.*')
  41. ->get();
  42. $course_code->future_typ_course_id = Course::getFutureTypSemesterCourses($course_code->typ_semester_course_id, $course_code->program_id);
  43. $course_code->students = Course::getStudentReportForOutcome($course_code);
  44. //Log::info(array($course_code));
  45. $course_code->criteria = Course::getCriteriaPlanReport($course_code);
  46. }
  47. return $course_codes;
  48. }
  49. public function outcomes()
  50. {
  51. return $this->belongsToMany('Outcome', 'objective_outcome', 'objective_id', 'outcome_id');
  52. }
  53. public function outcome()
  54. {
  55. return $this->belongsTo('Outcome');
  56. }
  57. /**
  58. * Return the program that the objective belongs to
  59. *
  60. * @return Illuminate\Database\Eloquent\Model
  61. */
  62. public function outcome_id()
  63. {
  64. return $this->hasMany('Objective_Outcome', 'objective_id');
  65. }
  66. }