$stclass = $request->get('stclass');
$myclass = Stclass::find($request->get('stclass'))->name;
$studentId = $request->get('studentId');
$studentname = Student::find($request->get('studentId'))->surname;
$session= $request->get('sessionnow');
$term = $request->get('term');
$myids = Stclass::find($stclass)->students;
// $dodo = DB::table('results')
// -> where('studentClass', $stclass)->where('session', $session)->where('term', $term)
// ->selectRaw('results.studentId')->distinct()->get();
$resultpercent = DB::table('results')
-> where('studentClass', $stclass)->where('session', $session)->where('term', $term)->where('studentId', $studentId)
->selectRaw("SUM((results.exam + (results.test1 + results.test2)/2)/2)/(COUNT(results.subject)) as overallpercent")->get();
$dodo = DB::table('results')
-> where('studentClass', $stclass)->where('session', $session)->where('term', $term)
->selectRaw('results.studentId')->get();
$results = DB::table('results')
->where('studentClass', $stclass)->where('session', $session)->where('term', $term)->where('studentId', $studentId)
->selectRaw('results.*, (results.test1 + results.test2)/2 as cav, (results.exam + (results.test1 + results.test2)/2)/2 as totalmark')->get();
return view('admin.results.studentresultsheet', compact('results', 'myclass', 'studentname','resultpercent', 'countsubjects'));