123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117 |
- <?php
-
- class FillNewAssessmentActivityCriterion extends Seeder
- {
-
- public function run()
- {
-
- // DB::enableQueryLog();
- $activities = DB::table('activities')
- ->join('rubric_activity', 'activities.id', '=', 'rubric_activity.activity_id')
- ->join('rubrics', 'rubrics.id', '=', 'rubric_activity.rubric_id')
- ->join('rubric_criterion', 'rubrics.id', '=', 'rubric_criterion.rubric_id')
- ->select('activities.*', 'rubrics.expected_percentage', 'rubrics.expected_points', 'rubric_criterion.criterion_id')
- ->orderBy('activities.id')
- ->orderBy('rubric_criterion.criterion_id')
- ->get();
- // DB::enableQueryLog();
- // dd(DB::getQueryLog());
- // exit();
- $activity_antes = -1;
- foreach ($activities as $activity) {
- $activity_id = $activity->id;
- $expected_percentage_students_achieving = $activity->expected_percentage;
- $transformative_actions = $activity->transforming_actions;
- $assessment_comments = $activity->assessment_comments;
- $expected_student_score = $activity->expected_points;
- $criterion_id = $activity->criterion_id;
- // $datos=json_decode($activity->criteria_achieved, true);
- // $i=0;
- // foreach($datos as $criterion_id=>$score)
- // {
- $existe_ya = DB::table('activity_criterion')->where('activity_id', $activity_id)->where('criterion_id', $criterion_id)->first();
- if (empty($existe_ya)) {
- if ($activity_antes == $activity_id) {
- DB::table('activity_criterion')->insert(
- array(
- "activity_id" => $activity_id,
- "criterion_id" => $criterion_id,
- "expected_percentage_students_achieving" => $expected_percentage_students_achieving,
- "expected_student_score" => $expected_student_score
- )
- );
- } else {
- $activity_antes = $activity_id;
- DB::table('activity_criterion')->insert(
- array(
- "activity_id" => $activity_id,
- "criterion_id" => $criterion_id,
- "expected_percentage_students_achieving" => $expected_percentage_students_achieving,
- "expected_student_score" => $expected_student_score,
- "transformative_actions" => $transformative_actions,
- "assessment_comments" => $assessment_comments
- )
- );
- }
- print $activity_id . ':' . $criterion_id;
- print "\n";
- }
- // $i++;
- // }
- }
-
- // exit();
- $assessments = DB::table('assessments')->get();
- $i = 0;
- foreach ($assessments as $assessment) {
- // var_dump($assessment);exit();
- $student_id = $assessment->student_id;
- $activity_id = $assessment->activity_id;
- $datos = json_decode($assessment->scores, true);
- // $criterion=(array)DB::table('activity_criterion')->where('activity_id', $activity_id)->first();
- // var_dump($rubric);exit();
- // $criterion_id=$criterion["criterion_id"];
- // print_r($datos);
- // print"\n";
- // print $rubric->id;print"\t";
- foreach ($datos as $criterion_id => $score) {
- // print $dato["id"];print"\n";
- // var_dump($criterion);
- $activity_criterion = DB::table('activity_criterion')->where('criterion_id', $criterion_id)->where('activity_id', $activity_id)->first();
- if (empty($activity_criterion)) {
- // var_dump($criterion_id);
- var_dump($assessment);
- // $activities=DB::table('activities')->where('id', $activity_id)->first();
- // $rubric_criterion=DB::table('rubric_criterion')->where('criterion_id', $criterion_id)->first();
- // var_dump($activities);
- // var_dump($rubric_criterion);
- // exit();
- $activity_criterion_id = DB::table('activity_criterion')->insertGetId(
- array(
- "activity_id" => $activity_id,
- "criterion_id" => $criterion_id,
- "transformative_actions" => $transformative_actions,
- "assessment_comments" => $assessment_comments
- )
- );
- } else $activity_criterion_id = $activity_criterion->id;
- $existe_ya = DB::table('assessments')->where('student_id', $student_id)->where('activity_criterion_id', $activity_criterion_id)->first();
- if (empty($existe_ya)) {
- DB::table('assessments')->insert(array("student_id" => $student_id, "activity_criterion_id" => $activity_criterion_id, 'score' => $score));
- print ".";
- }
- }
- // print $activity_id.':'.$criterion_id;print"\n";
-
- $i++;
- }
-
-
- // $course = Rubric::where('code', $code)->where('number', $number)->where('section', $section)->where('semester_id', $semester_id)->first();
-
-
-
-
- }
- }
|