public function analyseStudentPerformance($studentId) { $student = User::find($studentId); $studentTeachingSection = TeachingSection::where('users_id', '=', $studentId)->first(); // dd($studentTeachingSection); $studentSection = Section::find($studentTeachingSection->sections_id); $studentArray = array(); $studentArray['name'] = $student->name; $studentArray['realname'] = $student->realname; $studentArray['grade'] = $studentSection->grade; $studentArray['order'] = $studentSection->order; // a table show all exminations the student has token // show the different table of different subjects. $allTranscripts = Transcript::where('users_id', '=', $studentId)->get(); // dd($allTranscripts); $studentExaminations = array(); $i = 0; foreach ($allTranscripts as $transcript) { /*对该成绩单的学生的每次考试的语文,数学,英语三科的排名*/ $studentExaminations[$i]['chineseRanking'] = Transcript::getStudentSubjectRanking($transcript, 1); $studentExaminations[$i]['mathRanking'] = Transcript::getStudentSubjectRanking($transcript, 2); $studentExaminations[$i]['englishRanking'] = Transcript::getStudentSubjectRanking($transcript, 3); $examination = Examination::find($transcript->examinations_id); $studentExaminations[$i]['examination_name'] = $examination->name; $studentExaminations[$i]['examination_semester'] = $examination->semester; $studentExaminations[$i]['examination_date'] = $examination->date; $studentExaminations[$i]['total'] = $transcript->total; $studentExaminations[$i]['rank'] = $transcript->rank; $subjects = Subject::where('transcripts_id', '=', $transcript->id)->get(); foreach ($subjects as $subject) { $subjectType = $subject->type; if ($subjectType == 1) { $studentExaminations[$i]['chinese'] = $subject->score; } elseif ($subjectType == 2) { $studentExaminations[$i]['math'] = $subject->score; } elseif ($subjectType == 3) { $studentExaminations[$i]['english'] = $subject->score; } elseif ($subjectType == 4) { $studentExaminations[$i]['physics'] = $subject->score; } elseif ($subjectType == 5) { $studentExaminations[$i]['biology'] = $subject->score; } elseif ($subjectType == 6) { $studentExaminations[$i]['chemistry'] = $subject->score; } elseif ($subjectType == 7) { $studentExaminations[$i]['history'] = $subject->score; } elseif ($subjectType == 8) { $studentExaminations[$i]['politics'] = $subject->score; } else { $studentExaminations[$i]['geography'] = $subject->score; } } $i++; } //dd($studentExaminations); return view('scores.analyseStudentPerformance', compact('studentArray', 'studentExaminations')); }
public function getStudentsAllInfoEachSection($examinations_id, $sections_id) { // get all students in the section $studentsIds = User::getStudentBySection($sections_id); // // //get all above students transcripts in the examinations. // $transcripts = DB::table('transcripts')->where('examination_id', '=', $examinations_id) // ->whereIn('users_id', '=', $studentsId)->get(); // DB::table('transcripts') // ->join('users', 'transcripts.users_id', '=', 'users.id') // ->join('examinations', 'transcripts.examinations_id', '=', 'examinations.id') // ->get(); // $students = DB::table('users')->whereIn('id', '=', $studentsIds)->get(); $section = Section::find($sections_id); $examination = Examination::find($examinations_id); $examinationArray = array(); $examinationArray['name'] = $examination->name; if ($examination->semester == 1) { $examinationArray['semester'] = '第一学期'; } elseif ($examination->semester == 2) { $examinationArray['semester'] = '第二学期'; } elseif ($examination->semester == 3) { $examinationArray['semester'] = '小学期'; } else { $examinationArray['semester'] = '其他'; } if ($examination->type == 1) { $examinationArray['type'] = '期末考试'; } elseif ($examination->type == 2) { $examinationArray['type'] = '期中考试'; } elseif ($examination->type == 3) { $examinationArray['type'] = '月考'; } else { $examinationArray['type'] = '普通考试'; } $examinationArray['date'] = $examination->date; $arrayStudentScores = array(); $i = 0; // 这个班级的最大总分 $maxTotalScore = Transcript::getMaxTotalScores($studentsIds); // dd($maxTotalScore); foreach ($studentsIds as $studentsId) { $student = User::findOrFail($studentsId); $arrayStudentScores[$i]['student_id'] = $student->id; $arrayStudentScores[$i]['student_name'] = $student->realname; $arrayStudentScores[$i]['student_realName'] = $student->realname; $transcript = Transcript::where('users_id', '=', $student->id)->where('examinations_id', '=', $examinations_id)->first(); // dd($transcript); $arrayStudentScores[$i]['total'] = $transcript->total; $subjects = Subject::where('transcripts_id', '=', $transcript->id)->get(); foreach ($subjects as $subject) { $subjectType = $subject->type; if ($subjectType == 1) { $arrayStudentScores[$i]['chinese'] = $subject->score; } elseif ($subjectType == 2) { $arrayStudentScores[$i]['math'] = $subject->score; } elseif ($subjectType == 3) { $arrayStudentScores[$i]['english'] = $subject->score; } elseif ($subjectType == 4) { $arrayStudentScores[$i]['physics'] = $subject->score; } elseif ($subjectType == 5) { $arrayStudentScores[$i]['biology'] = $subject->score; } elseif ($subjectType == 6) { $arrayStudentScores[$i]['chemistry'] = $subject->score; } elseif ($subjectType == 7) { $arrayStudentScores[$i]['history'] = $subject->score; } elseif ($subjectType == 8) { $arrayStudentScores[$i]['politics'] = $subject->score; } else { $arrayStudentScores[$i]['geography'] = $subject->score; } } // 得到与最高分的分差 $arrayStudentScores[$i]['pointDifference'] = $maxTotalScore - $transcript->total; $transcript = Transcript::where('users_id', '=', $studentsId)->where('examinations_id', '=', $examinations_id)->first(); $arrayStudentScores[$i]['ranking'] = $transcript->rank; $i++; } // dd($arrayStudentScores); // 使用ranking进行排序 /* * 下面是对该班成绩的分析*/ // 该班级的该次考试的总和各科平均分 $examAverages = array(); $examAverages['totalAve'] = 0; $examAverages['chineseAve'] = 0; $examAverages['mathAve'] = 0; $examAverages['englishAve'] = 0; $examAverages['physicsAve'] = 0; $examAverages['biologyAve'] = 0; $examAverages['chemistryAve'] = 0; $examAverages['historyAve'] = 0; $examAverages['politicsAve'] = 0; $examAverages['geographyAve'] = 0; $count = 0; // 该次考试各科成绩中第一名,最后一名,平均分,中位数分析比较 $bestStudent = $arrayStudentScores[0]; $worstStudent = $arrayStudentScores[0]; $middleStudent = $arrayStudentScores[0]; $length = sizeof($arrayStudentScores); $halfLength = round($length / 2); // dd($halfLength); foreach ($arrayStudentScores as $studentExamScores) { $examAverages['totalAve'] += $studentExamScores['total']; $examAverages['chineseAve'] += $studentExamScores['chinese']; $examAverages['mathAve'] += $studentExamScores['math']; $examAverages['englishAve'] += $studentExamScores['english']; $examAverages['physicsAve'] += $studentExamScores['physics']; $examAverages['biologyAve'] += $studentExamScores['biology']; $examAverages['chemistryAve'] += $studentExamScores['chemistry']; $examAverages['historyAve'] += $studentExamScores['history']; $examAverages['politicsAve'] += $studentExamScores['politics']; $examAverages['geographyAve'] += $studentExamScores['geography']; $count++; //the best performance student if ($studentExamScores['ranking'] < $bestStudent['ranking']) { $bestStudent = $studentExamScores; } // the worst performance student if ($studentExamScores['ranking'] > $worstStudent['ranking']) { $worstStudent = $studentExamScores; } if ($studentExamScores['ranking'] == $halfLength) { $middleStudent = $studentExamScores; } } $examAverages['totalAve'] /= $count; $examAverages['chineseAve'] /= $count; $examAverages['mathAve'] /= $count; $examAverages['englishAve'] /= $count; $examAverages['physicsAve'] /= $count; $examAverages['biologyAve'] /= $count; $examAverages['chemistryAve'] /= $count; $examAverages['historyAve'] /= $count; $examAverages['politicsAve'] /= $count; $examAverages['geographyAve'] /= $count; // end该班级的该次考试的总和各科平均分 // 该次考试各科成绩中第一名,最后一名,平均分,中位数分析比较 // the best student // the worst student // the middle student // end该次考试各科成绩中第一名,最后一名,平均分,中位数分析比较 return view('scores.analyseSectionPerformance', compact('examinationArray', 'arrayStudentScores', 'section', 'examAverages', 'bestStudent', 'worstStudent', 'middleStudent')); }
public function forecastStudentFuturePerformance($studentId) { $student = User::find($studentId); // 这部分工作和CheckStudentController的中 analyseStudentPerformance 方法是一样, code取自该方法 $studentTeachingSection = TeachingSection::where('users_id', '=', $studentId)->first(); // dd($studentTeachingSection); $studentSection = Section::find($studentTeachingSection->sections_id); $studentArray = array(); $studentArray['name'] = $student->name; $studentArray['realname'] = $student->realname; $studentArray['grade'] = $studentSection->grade; $studentArray['order'] = $studentSection->order; $allTranscripts = Transcript::where('users_id', '=', $studentId)->get(); // 该学生的全部考试考试的所有各种平均分 $studentAllPreExamsAve = array(); $studentAllPreExamsAve['totalAve'] = 0; $studentAllPreExamsAve['rankingAve'] = 0; $studentAllPreExamsAve['chineseAve'] = 0; $studentAllPreExamsAve['mathAve'] = 0; $studentAllPreExamsAve['englishAve'] = 0; $studentAllPreExamsAve['physicsAve'] = 0; $studentAllPreExamsAve['biologyAve'] = 0; $studentAllPreExamsAve['chemistryAve'] = 0; $studentAllPreExamsAve['historyAve'] = 0; $studentAllPreExamsAve['geographyAve'] = 0; $studentAllPreExamsAve['politicsAve'] = 0; $count = 0; $previousTotalAndRankingArray = []; foreach ($allTranscripts as $transcript) { $examination = Examination::find($transcript->examinations_id); $tampTotalAndRankingArray = [floatval($transcript->total), floatval($transcript->rank), 1]; $previousTotalAndRankingArray[$count] = $tampTotalAndRankingArray; /* $previousTotalAndRankingArray[$count]['total'] = $transcript->total; $previousTotalAndRankingArray[$count]['rank'] = $transcript->rank; $previousTotalAndRankingArray[$count]['ballSize'] = 10;*/ $studentAllPreExamsAve['totalAve'] += $transcript->total; $studentAllPreExamsAve['rankingAve'] += $transcript->rank; $subjects = Subject::where('transcripts_id', '=', $transcript->id)->get(); foreach ($subjects as $subject) { $subjectType = $subject->type; if ($subjectType == 1) { $studentAllPreExamsAve['chineseAve'] += $subject->score; } elseif ($subjectType == 2) { $studentAllPreExamsAve['mathAve'] += $subject->score; } elseif ($subjectType == 3) { $studentAllPreExamsAve['englishAve'] += $subject->score; } elseif ($subjectType == 4) { $studentAllPreExamsAve['physicsAve'] += $subject->score; } elseif ($subjectType == 5) { $studentAllPreExamsAve['biologyAve'] += $subject->score; } elseif ($subjectType == 6) { $studentAllPreExamsAve['chemistryAve'] += $subject->score; } elseif ($subjectType == 7) { $studentAllPreExamsAve['historyAve'] += $subject->score; } elseif ($subjectType == 8) { $studentAllPreExamsAve['politicsAve'] += $subject->score; } else { $studentAllPreExamsAve['geographyAve'] += $subject->score; } } $count++; } $studentAllPreExamsAve['totalAve'] /= $count; $studentAllPreExamsAve['rankingAve'] = round($studentAllPreExamsAve['rankingAve'] / $count); $studentAllPreExamsAve['chineseAve'] /= $count; $studentAllPreExamsAve['mathAve'] /= $count; $studentAllPreExamsAve['englishAve'] /= $count; $studentAllPreExamsAve['physicsAve'] /= $count; $studentAllPreExamsAve['biologyAve'] /= $count; $studentAllPreExamsAve['chemistryAve'] /= $count; $studentAllPreExamsAve['historyAve'] /= $count; $studentAllPreExamsAve['politicsAve'] /= $count; $studentAllPreExamsAve['geographyAve'] /= $count; $studentAllPreExamsAveData = [$studentAllPreExamsAve['chineseAve'], $studentAllPreExamsAve['mathAve'], $studentAllPreExamsAve['englishAve'], $studentAllPreExamsAve['physicsAve'], $studentAllPreExamsAve['biologyAve'], $studentAllPreExamsAve['chemistryAve'], $studentAllPreExamsAve['historyAve'], $studentAllPreExamsAve['politicsAve'], $studentAllPreExamsAve['geographyAve']]; // end该学生的全部考试考试的所有各种平均分 // 对下次考试的预测 $forecastNextExam = array(); // 调用测试算法,对下次考试预测 $forecastNextExam['total'] = 862; $forecastNextExam['ranking'] = 1; $forecastNextExam['chinese'] = 108; $forecastNextExam['math'] = 117; $forecastNextExam['english'] = 77; $forecastNextExam['physics'] = 74; $forecastNextExam['biology'] = 80; $forecastNextExam['chemistry'] = 78; $forecastNextExam['history'] = 71; $forecastNextExam['politics'] = 82; $forecastNextExam['geography'] = 78; $forecastNextExamData = [$forecastNextExam['chinese'], $forecastNextExam['math'], $forecastNextExam['english'], $forecastNextExam['physics'], $forecastNextExam['biology'], $forecastNextExam['chemistry'], $forecastNextExam['history'], $forecastNextExam['politics'], $forecastNextExam['geography']]; // dd($studentArray); // dd($studentAllPreExamsAve); // dd($forecastNextExam); // 对之前所有考试的总分和排名, 平均排名和 未来排名 $averageTotalAndRankingArray = [[$studentAllPreExamsAve['totalAve'], $studentAllPreExamsAve['rankingAve'], 1]]; $forecastTotalAndRankingArray = [[$forecastNextExam['total'], $forecastNextExam['ranking'], 1]]; // dd($previousTotalAndRankingArray); // dd($averageTotalAndRankingArray); // dd($forecastTotalAndRankingArray); return view('forecast.forecastStudentsFuturePerformance', compact('studentArray', 'studentAllPreExamsAveData', 'forecastNextExamData', 'previousTotalAndRankingArray', 'averageTotalAndRankingArray', 'forecastTotalAndRankingArray')); }
public function createNewTest(Request $request) { $user = Auth::User(); //get all information of a new Test. //返回一个成功的信息回去 $name = $request->input('name'); $semester = $request->input('semester'); $type = $request->input('type'); $date = $request->input('date'); $schools_id = 1; $newExamination = new Examination(); $newExamination->name = $name; $newExamination->semester = $semester; $newExamination->type = $type; $newExamination->date = $date; $newExamination->description = $request->input('description'); $newExamination->schools_id = $schools_id; $newExamination->save(); //将这个新的考试信息存储到session中 // $request->session()->put('newExamination', $newExamination); $checkedIds = $request->input('add'); $sections = DB::table('sections')->whereIn('id', $checkedIds)->get(); $allStudentsAllSections = []; $i = 0; //已经创建了一个新的examination,也已经知道有多少个班级会被记录,因此可以为每个班级的每个学生创建此次考试的transcription. foreach ($sections as $section) { $allStudentsAllSections[$i]['sectionGrade'] = $section->grade; $allStudentsAllSections[$i]['sectionOrder'] = $section->order; $allStudentIdsEachSection = User::getStudentBySection($section->id); $allStudentsEachSection = DB::table('users')->whereIn('id', $allStudentIdsEachSection)->get(); $allStudentsAllSections[$i]['students'] = $allStudentsEachSection; $i++; } //在examinationsInfos表中将sectionId, examinationsId, 和当前users_id生成一新的数据. foreach ($sections as $section) { $examinationsInfos = new Examinationsinfo(); $examinationsInfos->users_id = $user->id; $examinationsInfos->examinations_id = $newExamination->id; $examinationsInfos->sections_id = $section->id; $examinationsInfos->save(); } // Session::put('url.intended', URL::previous()); // Session::put('url.intended', URL::previous()); // using the Facade // session()->put('url.intended', URL::previous()); // using the L5 helper // dd($allStudentsAllSections); /*Session::flash('backUrl', Request::fullUrl());*/ // 在这里将"sections","allStudentsAllSections","newExamination"都放到session中, //以便在教师填写填写完学生的考试成绩时, 在取出, 返回到allSectionsEachTest.blade.php页面 Session::put('newExamination', $newExamination); Session::put('allStudentsAllSections', $allStudentsAllSections); // $data = Session::all(); // dd($data); return view('scores.allSectionsEachTest', compact('user', 'sections', 'allStudentsAllSections', 'newExamination')); /* foreach($checkedIds as $checkedId){ $teachingSections = TeachingSection::where('sections_id', '=', $checkedId)->get(); $studentsIds = DB::table('teaching_sections')->where('sections_id', '=', $checkedId)->lists('users_id'); $students = DB::table('users')->where('role', '=', '1')->whereIn('id', $studentsIds)->get(); $section = Section::find($checkedId); return view('scores.logStudentsTestResult', compact('students', 'section', 'newExamination'));*/ // foreach ($teachingSections as $teachingSection) { //// 这里得到的是一个collection of users // $students = User::where('id', '=', $teachingSection->users_id) // ->where('role', '=', '1')->get(); // $section = Section::find($teachingSection->sections_id); // //// return view('scores.logStudentsTestResult', compact('students', 'section', 'newExamination')); // // } }
public function destroyAll($id) { // $Examinations = Examination::where('POrecord_id', '=', $id)->get()->all(); $POrecord = $Examinations[0]->POrecord; foreach ($Examinations as $Examination) { $Examination->delete(); } $POrecord->status = 'Sequencing'; $POrecord->save(); return \Redirect::to('research/ngs/projects/show/' . $POrecord->project->id)->with('message', 'You have no Examination record!'); }