app/Http/Controllers/quizattempt.php
/**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
Store a newly created resource in storage.
Store a newly created resource in storage .
public function store(Request $request)
    {
        $q=question::all();
        $a=answer::all();
        $n=count($q);
        $x=0;
        for($i=0; $i<$n; $i++)
        {   
            $c=($a[$i]->ans);
            if(in_array($c,$request->get('ans')) )
	        {
		        $x=$x+1;
	        }
        }
        $r=new result();
        $r->s_name=session('sname')->name;
        $r->result=$x;
        $r->save();  
        return view('mark',compact('r','q','a'));
    }
public function store ( Request $ request ) { $ q = question :: all ( ) ; $ a = answer :: all ( ) ; $ n = count ( $ q ) ; $ x = 0 ; for ( $ i = 0 ; $ i < $ n ; $ i ++ ) { $ c = ( $ a [ $ i ] -> ans ) ; if ( in_array ( $ c , $ request -> get ( 'ans' ) ) ) { $ x = $ x + 1 ; } } $ r = new result ( ) ; $ r -> s_name = session ( 'sname' ) -> name ; $ r -> result = $ x ; $ r -> save ( ) ; return view ( 'mark' , compact ( 'r' , 'q' , 'a' ) ) ; }
Store a newly created resource in storage.
Store a newly created resource in storage .
//$s=student::find($id); // echo $c; //echo "<br>"; //print_r( $request->get('ans')); //echo in_array($c,$request->get('ans')); //echo $x; //instead of somu current student's name who is attending the quiz. //return view('correct',compact('question')); 