Нет описания

2021_10_18_125837_student_outcome_assess_view.php 1.0KB

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php
  2. use Illuminate\Database\Schema\Blueprint;
  3. use Illuminate\Database\Migrations\Migration;
  4. class StudentOutcomeAssessView extends Migration {
  5. /**
  6. * Run the migrations.
  7. *
  8. * @return void
  9. */
  10. public function up()
  11. {
  12. //
  13. DB::statement("
  14. CREATE VIEW `student_outcome_assess`
  15. AS SELECT
  16. `eval`.`student_id` AS `student_id`,
  17. `eval`.`semester_id` AS `semester_id`,
  18. `eval`.`outcome_id` AS `outcome_id`,sum(`eval`.`total_evaluated`) AS `total_evaluated`,sum(coalesce(`ach`.`total_achieved`,0)) AS `total_achieved`
  19. FROM (`student_criteria_evaluated` `eval` left join `student_criteria_achieved` `ach` on(((`eval`.`student_id` = `ach`.`student_id`) and (`eval`.`semester_id` = `ach`.`semester_id`) and (`eval`.`criterion_id` = `ach`.`criterion_id`) and (`eval`.`outcome_id` = `ach`.`outcome_id`)))) group by `eval`.`student_id`,`eval`.`semester_id`,`eval`.`outcome_id`;
  20. ");
  21. }
  22. /**
  23. * Reverse the migrations.
  24. *
  25. * @return void
  26. */
  27. public function down()
  28. {
  29. //
  30. DB::statement('DROP VIEW IF EXISTS student_outcome_assess');
  31. }
  32. }