How to calculate the total marks for online Examination system in php


I am developing simple online Examination system. while adding Questions Admin enter the Correct score and Negative score for that question. But my problem is how to get the correct and negative score of each question and total marks.I am unable to get the results. Here below code is submitting test <strong>submittest.php</strong>

<?php require_once("db.php"); session_start(); $tot=0; $correct=0; $wrong=0; $ques=''; $answered=0; $wrong_answered=0; $resgiterno=$_POST['registerno']; //$id= $_SESSION['id']; foreach($_POST as $key=>$value) { $id=substr($key,7); $tot++; $answer=implode(",",$value); //if(dbSelect("questions","*","correct_option='$answer' and id='$id'","")) if($score_sql=mysql_query("select * from questions where correct_option='$answer' and id='$id'")) { $score=mysql_fetch_array($score_sql); $correct=$correct+$score['correct_score']; $wrong=$wrong+$score['negative_score']; //echo $val; $ques.=$id.","; } } $total_marks=$correct-$wrong; //echo "total score is $total_marks"; echo "Congratulations you have Completed the Exam"; ?>

<strong>Here how Displaying Questions Code</strong>

<div class="que_box_left"><div class="d1"><div class="option">a)</div><input name="answer_<?php echo $question['id']?>[]" type="checkbox" value="option_a" class="mar_ri" /></div> <div class="d2"><?php echo $question['option_a'] ?></div></div> <div class="que_box_left"><div class="d1"><div class="option">b)</div><input name="answer_<?php echo $question['id']?>[]" type="checkbox" value="option_b" class="mar_ri" /></div> <div class="d2"><?php echo $question['option_b']?></div></div> <div class="clear"></div> <div class="que_box_left"><div class="d1"><div class="option">c)</div><input name="answer_<?php echo $question['id']?>[]" type="checkbox" value="option_c" class="mar_ri" /></div> <div class="d2"><?php echo $question['option_c']?></div></div> <div class="que_box_left"><div class="d1"><div class="option">d)</div><input name="answer_<?php echo $question['id']?>[]" type="checkbox" value="option_d" class="mar_ri" /></div> <div class="d2"><?php echo $question['option_d']?> </div>

<strong>here how i send the data to above code submit-test.php</strong>

$('.form_test_submit').live("click",function(){ $.post("submit-test.php?testname="+testname,$('.form_test').serialize(),function(data){ alert(data); if(data=='Congratulations you have Completed the Exam') window.location.assign("results.php"); /* else window.location.assign("level.php?sid=<?php echo $student['sid'] ?>&eid=<?php echo $eid ?>&subid=<?php echo $subid ?>"); */ }); return false; });

By that code i am unable to get the Exact Results. please Help me. Thanks In advance


You can use session. On submission of true answer use session++ and for wrong use session-- and if you want to show both wrong and right answer you can use two sessions one for wrong and other is for right. On submission of true answer use right_session++ and for wrong ans use wrong_sesssion++.


  • Demystify Windbd memory usage labels: “Private Working Set” is large while memory is marked as Regio
  • multiple views navigation in UIPopovercontroller
  • Datalake analytic join
  • save a function in localstorage
  • How to test for the end of a pointer array?
  • Populate single dropdown from two tables
  • python: extract float from a python list of string( AUD 31.99)
  • How to connect to Ethereum URLs created using AWS blockchain template
  • What is the difference between scala classes, scripts and worksheets in Intellij-idea?
  • How do I get the Suggested Sentence in a string as output in LanguageTool?
  • Clueless about this error: wrong sign in 'by' argument
  • How to setText in a textArea from an ArrayList?
  • jQuery Plugin (DataTables) only loads properly on page refresh
  • Unsupported operand types [closed]
  • SUM datatable column with compute but NO filter
  • How to retrieve values stored in JSON array in MySQL query itself?
  • Giving uploaded images a unique name for mysqli
  • What is supported by broadcasting in tensorflow? How dimensions matches determined?
  • Performing way to limit double accuracy
  • std::string::substr throws std::out_of_range but the arguments are in limit
  • C++ how to get substring after get position of its index
  • Extract All Possible Paths from Expression-Tree and evaluate them to hold TRUE
  • XSLT foreach repeating nodes to flat
  • List images(01.png) and descriptions(01.txt) from directory
  • D3 nodes and links from JSON with nested arrays of children
  • ilmerge with a PFX file
  • Why value captured by reference in lambda is broken? [duplicate]
  • RestKit - RKRequestDelegate does not exist
  • How to delete a row from a dynamic generate table using jquery?
  • json Serialization in asp
  • Rails 2: use form_for to build a form covering multiple objects of the same class
  • WPF Applying a trigger on binding failure
  • Why joiner is not used after Sequence generator or Update statergy
  • How to stop GridView from loading again when I press back button?
  • Recursive/Hierarchical Query Using Postgres
  • Observable and ngFor in Angular 2
  • How to Embed XSL into XML
  • UserPrincipal.Current returns apppool on IIS
  • Conditional In-Line CSS for IE and Others?
  • To Get the radio button value in ruby on rails