在测试评估过程中如何保护秒表?

发布于 2024-12-03 18:00:40 字数 310 浏览 2 评论 0原文

我想知道如何设置秒表并防止他作弊。 我打算使用

  • date()
  • $_SERVER['DATE_GMT']
  • $_SERVER['DATE_LOCAL']

但我不知道是否这是一个很好的方法,如果我进展顺利的话。

当时间结束时,测试评估必须防止修改(测试结束),我想检查 $end_test = $end_planned 是否为 $start_test + 60min

I want to know how i can set up a stopwatch and prevent him agaist cheat.
I was going to use

  • date()
  • $_SERVER['DATE_GMT']
  • $_SERVER['DATE_LOCAL']

But I don't know if it is a good method and if I am on good way.

The test assessment must be portected against modification (endof test) when the time is over, and I want to check if $end_test = $end_planned which is $start_test + 60min.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

会傲 2024-12-10 18:00:40

您可以将它们的开始时间存储在数据库或外部文件中。然后,当他们重新加载测试时,您需要获取他们开始测试的时间、当前时间,并计算他们是否还有时间。

当他们提交测试时,你会检查同样的事情。

您必须为学生提供一个唯一的 PIN 码供其使用,以便在存储它时可以再次查找。

像这样的东西可能会起作用。

当他们加载页面时,要求他们提供唯一的 PIN:

$test_duration = 30; // minutes
$test_duration *= 60; // turning into sections for later use

// check if results from a PIN lookup are empty
if($pin_from_db == "") { // there no pin in the database. Student didn't start yet
   $sql = "INSERT INTO example_student_table(student_id, start_time) VALUES ($student_id, " . date('U') . ")";
   $start = date('U');
} else { // there was a PIN in the Database
   $start = (int)$time_from_db;
}

// check if they still have time left
if($start < (date('U') + $start)) {
   // let them do the test
} else {
   // dont let them continue the test
}

您的表单将如下所示

<form action="processor.php" method="post">
   // what ever other questions you need answered put here
   <input type="hidden" name="end_time" value="<?php echo $start + $test_duration" />
</form>

然后,当他们提交页面时,您的“processor.php”可以检查他们是否在指定的时间内完成了操作

if(isset($_POST)) {
   $allotment = $_POST['end_time'];
   $now       = date('U');
   if($now <= $allotment) {
      // they finished in time
   } else {
      // they didn't finish in time
   }
}

You could store the time they start at in a database or external file. Then when they reload the test you would need get the time they started the test, the current time, and calculate if they still have time.

When they submit the test you would check the same thing.

You would have to give students a unique PIN to use so when you store it, it can be looked up again.

Something like this might work.

When they load the page ask them for their unique PIN:

$test_duration = 30; // minutes
$test_duration *= 60; // turning into sections for later use

// check if results from a PIN lookup are empty
if($pin_from_db == "") { // there no pin in the database. Student didn't start yet
   $sql = "INSERT INTO example_student_table(student_id, start_time) VALUES ($student_id, " . date('U') . ")";
   $start = date('U');
} else { // there was a PIN in the Database
   $start = (int)$time_from_db;
}

// check if they still have time left
if($start < (date('U') + $start)) {
   // let them do the test
} else {
   // dont let them continue the test
}

Your form would look something like this

<form action="processor.php" method="post">
   // what ever other questions you need answered put here
   <input type="hidden" name="end_time" value="<?php echo $start + $test_duration" />
</form>

Then when they submit the page your 'processor.php' could check to see if they did it in the allotted time

if(isset($_POST)) {
   $allotment = $_POST['end_time'];
   $now       = date('U');
   if($now <= $allotment) {
      // they finished in time
   } else {
      // they didn't finish in time
   }
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文