public function recordstudentEachSectionEachTest($studentId, $newExaminationId)
 {
     /*        $teachingSections = TeachingSection::where('sections_id', '=', $sectionId)->get();
     
             $studentsIdsIncludingTeachers = DB::table('teaching_sections')->where('sections_id', '=', $sectionId)->lists('users_id');
             $students = DB::table('users')->where('role', '=', '1')->whereIn('id', $studentsIdsIncludingTeachers)->get();
             $studentsIds = DB::table('users')->where('role', '=', '1')->whereIn('id', $studentsIdsIncludingTeachers)->lists('id');*/
     //        dd($students);
     //        dd($sectionId);
     //        dd($newExaminationId);
     //generating a transcript table for each student in this examination.
     $newTranscript = new Transcript();
     $newTranscript->examinations_id = $newExaminationId;
     $newTranscript->users_id = $studentId;
     $newTranscript->save();
     $student = User::findOrFail($studentId);
     $teachingSection = TeachingSection::getTeachingsectionByStudent($student);
     $section = Section::findOrFail($teachingSection->sections_id);
     $school = School::findOrFail($section->schools_id);
     $studentArray = array();
     $studentArray['name'] = $student->name;
     $studentArray['realname'] = $student->realname;
     $studentArray['sectionGrade'] = $section->grade;
     $studentArray['sectionOrder'] = $section->order;
     $studentArray['schoolName'] = $school->name;
     //        $students = DB::table('users')->where('role', '=', '1')->whereIn('id', $studentsIds)->paginate(10);
     //        $wholeSectionTranscripts = DB::table('transcripts')->where('examinations_id', '=', $newExaminationId)->whereIn('users_id', $studentsIds)->paginate(10);
     /*       if (Session::has('backUrl')) {
                 Session::keep('backUrl');
             }*/
     return view('scores.logStudentsTestResult', compact('newTranscript', 'studentArray'));
 }
 public function importStudentOwnSections(Request $request)
 {
     $studentSectionId = $request->input('addStudentSections');
     $user = Auth::user();
     //        在teachingSection表中查找是否已经有这个学生,如果有就把原来信息改写,如果没有就插入一条记录
     $studentTeachingSection = TeachingSection::getTeachingsectionByStudent($user);
     if ($studentTeachingSection === null) {
         //means it doesn't exist in teachingSection table.
         //we need to update it.
         $newStudentTeachingSection = new TeachingSection();
         $newStudentTeachingSection->users_id = $user->id;
         $newStudentTeachingSection->sections_id = $studentSectionId;
         $section = Section::find($studentSectionId);
         $section->total += 1;
         $section->save();
         $newStudentTeachingSection->save();
     } else {
         //it already exists in teachingSection, we just update the latest section.
         $studentTeachingSection->sections_id = $studentSectionId;
         $studentTeachingSection->save();
     }
     flash()->overlay('同学你好,已经成功修改了你的学习班级信息', '成功');
     return redirect('/dashboard');
 }