如何在php中计算在线考试系统的总分 [英] How to calculate the total marks for online Examination system in php

查看:100
本文介绍了如何在php中计算在线考试系统的总分的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发简单的在线考试系统.在添加问题管理员时,输入该问题的正确分数和负面分数.但是我的问题是如何获得每个问题和满分的正确和否定分数.我无法获得结果.下面的代码正在提交测试 submittest.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 submittest.php

<?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";


?>

此处显示问题代码的方式

<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>

此处是我如何将数据发送到上述代码Submit-test.php

$('.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

推荐答案

您可以使用会话.在提交正确答案时,请使用session ++和对于错误使用的会话-如果您想同时显示错误和正确答案,则可以使用两个会话,一个代表错误,另一个代表正确.提交正确答案时,请使用right_session ++;对于错误回答,请使用rong_sesssion ++.

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++.

这篇关于如何在php中计算在线考试系统的总分的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆