12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- <?php
-
- class FillNewCriterionRubric extends Seeder {
-
- public function run()
- {
- $rubrics=DB::table('rubrics')->get();
- $i=0;
- foreach ($rubrics as $rubric)
- {
- $datos=json_decode($rubric->contents, true);
- // print_r($datos);
- // print"\n";
- // print $rubric->id;print"\t";
- // if($rubric->id==29){var_dump($datos);}
- foreach($datos as $dato)
- {
- if($rubric->id==29){print $dato["id"];print"Entrando\n";}
- $new_criterion=(array)DB::table('criteria')->where('id', $dato["id"])->first();
- // var_dump($new_criterion);
- $program_id=(array)DB::table('courses')
- ->join('activities', 'courses.id', '=', 'activities.course_id')
- ->join('new_rubric_activity', 'new_rubric_activity.activity_id', '=', 'activities.id')
- ->select('courses.program_id')
- ->where('new_rubric_activity.rubric_id',$rubric->id)
- ->first();
- if(empty($program_id))$program_id['program_id']=1;
- // else var_dump($program_id);
-
- // var_dump($program_id);
- // var_dump($new_criterion);
- if(!empty($new_criterion))
- {
- $existe=(array)DB::table('objectives')->where('id', $new_criterion["id"])->first();
- $objective_id=$new_criterion["id"];
- if(empty($existe))
- {
- $existe4=(array)DB::table('objectives')->where('program_id', $program_id['program_id'])->where('text', $new_criterion["name"])->first();
- // print_r($existe4);print"\n";
- if(!empty($existe4))
- {
- // DB::table('objectives')->insert(array("id"=> $new_criterion["id"],"program_id"=>$program_id['program_id'],"text"=>$new_criterion["name"],'outcome_id'=>$new_criterion['outcome_id']));
- $objective_id=$existe4["id"];
- }
- else
- {
- print "A crear entrada en objectives: $objective_id";
- // var_dump(array("id"=> $objective_id,"program_id"=>$program_id['program_id'],"text"=>$new_criterion["name"],'outcome_id'=>$new_criterion['outcome_id']));
- DB::table('objectives')->insert(array("id"=> $objective_id,"program_id"=>$program_id['program_id'],"text"=>$new_criterion["name"],'outcome_id'=>$new_criterion['outcome_id']));
- }
- }
- else
- {
- $existe4=(array)DB::table('objectives')->where('program_id', $program_id['program_id'])->where('text', $new_criterion["name"])->first();
- // print_r($existe4);print"\n";
- if(empty($existe4))
- {
- $objective_id=DB::table('objectives')->insertGetId(array("program_id"=>$program_id['program_id'],"text"=>$new_criterion["name"],'outcome_id'=>$new_criterion['outcome_id']));
- }
-
- }
- $new_criterion["objective_id"]=$objective_id;
- unset($new_criterion['outcome_id']);
- // var_dump($new_criterion);
- $existe2=(array)DB::table('new_criteria')->where('id', $new_criterion["id"])->first();
- if(empty($existe2))
- {
- DB::table('new_criteria')->insert($new_criterion);
- }
- $existe3=(array)DB::table('new_criterion_rubric')->where('criterion_id', $new_criterion["id"])->where('rubric_id', $rubric->id)->first();
- if(empty($existe3))
- {
- DB::table('new_criterion_rubric')->insert(
- array('criterion_id' => $dato["id"], 'rubric_id' => $rubric->id)
- );
- }
- }
- // if($i)exit();
-
- }
- // if($rubric->id==29){exit();}
- $i++;
- }
-
-
- // $course = Rubric::where('code', $code)->where('number', $number)->where('section', $section)->where('semester_id', $semester_id)->first();
-
-
-
-
- }
-
-
- }
|