Keine Beschreibung

FillNewAssessmentActivityCriterion.php 4.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. <?php
  2. class FillNewAssessmentActivityCriterion extends Seeder
  3. {
  4. public function run()
  5. {
  6. // DB::enableQueryLog();
  7. $activities = DB::table('activities')
  8. ->join('rubric_activity', 'activities.id', '=', 'rubric_activity.activity_id')
  9. ->join('rubrics', 'rubrics.id', '=', 'rubric_activity.rubric_id')
  10. ->join('rubric_criterion', 'rubrics.id', '=', 'rubric_criterion.rubric_id')
  11. ->select('activities.*', 'rubrics.expected_percentage', 'rubrics.expected_points', 'rubric_criterion.criterion_id')
  12. ->orderBy('activities.id')
  13. ->orderBy('rubric_criterion.criterion_id')
  14. ->get();
  15. // DB::enableQueryLog();
  16. // dd(DB::getQueryLog());
  17. // exit();
  18. $activity_antes = -1;
  19. foreach ($activities as $activity) {
  20. $activity_id = $activity->id;
  21. $expected_percentage_students_achieving = $activity->expected_percentage;
  22. $transformative_actions = $activity->transforming_actions;
  23. $assessment_comments = $activity->assessment_comments;
  24. $expected_student_score = $activity->expected_points;
  25. $criterion_id = $activity->criterion_id;
  26. // $datos=json_decode($activity->criteria_achieved, true);
  27. // $i=0;
  28. // foreach($datos as $criterion_id=>$score)
  29. // {
  30. $existe_ya = DB::table('activity_criterion')->where('activity_id', $activity_id)->where('criterion_id', $criterion_id)->first();
  31. if (empty($existe_ya)) {
  32. if ($activity_antes == $activity_id) {
  33. DB::table('activity_criterion')->insert(
  34. array(
  35. "activity_id" => $activity_id,
  36. "criterion_id" => $criterion_id,
  37. "expected_percentage_students_achieving" => $expected_percentage_students_achieving,
  38. "expected_student_score" => $expected_student_score
  39. )
  40. );
  41. } else {
  42. $activity_antes = $activity_id;
  43. DB::table('activity_criterion')->insert(
  44. array(
  45. "activity_id" => $activity_id,
  46. "criterion_id" => $criterion_id,
  47. "expected_percentage_students_achieving" => $expected_percentage_students_achieving,
  48. "expected_student_score" => $expected_student_score,
  49. "transformative_actions" => $transformative_actions,
  50. "assessment_comments" => $assessment_comments
  51. )
  52. );
  53. }
  54. print $activity_id . ':' . $criterion_id;
  55. print "\n";
  56. }
  57. // $i++;
  58. // }
  59. }
  60. // exit();
  61. $assessments = DB::table('assessments')->get();
  62. $i = 0;
  63. foreach ($assessments as $assessment) {
  64. // var_dump($assessment);exit();
  65. $student_id = $assessment->student_id;
  66. $activity_id = $assessment->activity_id;
  67. $datos = json_decode($assessment->scores, true);
  68. // $criterion=(array)DB::table('activity_criterion')->where('activity_id', $activity_id)->first();
  69. // var_dump($rubric);exit();
  70. // $criterion_id=$criterion["criterion_id"];
  71. // print_r($datos);
  72. // print"\n";
  73. // print $rubric->id;print"\t";
  74. foreach ($datos as $criterion_id => $score) {
  75. // print $dato["id"];print"\n";
  76. // var_dump($criterion);
  77. $activity_criterion = DB::table('activity_criterion')->where('criterion_id', $criterion_id)->where('activity_id', $activity_id)->first();
  78. if (empty($activity_criterion)) {
  79. // var_dump($criterion_id);
  80. var_dump($assessment);
  81. // $activities=DB::table('activities')->where('id', $activity_id)->first();
  82. // $rubric_criterion=DB::table('rubric_criterion')->where('criterion_id', $criterion_id)->first();
  83. // var_dump($activities);
  84. // var_dump($rubric_criterion);
  85. // exit();
  86. $activity_criterion_id = DB::table('activity_criterion')->insertGetId(
  87. array(
  88. "activity_id" => $activity_id,
  89. "criterion_id" => $criterion_id,
  90. "transformative_actions" => $transformative_actions,
  91. "assessment_comments" => $assessment_comments
  92. )
  93. );
  94. } else $activity_criterion_id = $activity_criterion->id;
  95. $existe_ya = DB::table('assessments')->where('student_id', $student_id)->where('activity_criterion_id', $activity_criterion_id)->first();
  96. if (empty($existe_ya)) {
  97. DB::table('assessments')->insert(array("student_id" => $student_id, "activity_criterion_id" => $activity_criterion_id, 'score' => $score));
  98. print ".";
  99. }
  100. }
  101. // print $activity_id.':'.$criterion_id;print"\n";
  102. $i++;
  103. }
  104. // $course = Rubric::where('code', $code)->where('number', $number)->where('section', $section)->where('semester_id', $semester_id)->first();
  105. }
  106. }