説明なし

Objective.php 2.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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', '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->students = Course::getStudentReportForOutcome($course_code);
  43. Log::info(array($course_code));
  44. $course_code->criteria = Course::getCriteriaPlanReport($course_code);
  45. }
  46. return $course_codes;
  47. }
  48. public function outcomes()
  49. {
  50. return $this->belongsToMany('Outcome', 'objective_outcome', 'objective_id', 'outcome_id');
  51. }
  52. public function outcome()
  53. {
  54. return $this->belongsTo('Outcome');
  55. }
  56. /**
  57. * Return the program that the objective belongs to
  58. *
  59. * @return Illuminate\Database\Eloquent\Model
  60. */
  61. public function outcome_id()
  62. {
  63. return $this->hasMany('Objective_Outcome', 'objective_id');
  64. }
  65. }