Geen omschrijving

FillNewAssessmentActivityCriterion.php 4.3KB

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