【问题标题】:How to protect a stopwatch during a test assessment? [closed]如何在测试评估期间保护秒表? [关闭]
【发布时间】:2011-11-13 16:43:51
【问题描述】:

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

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

但我不知道这是否是一个好方法,我是否走在好的路上。

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

【问题讨论】:

    标签: php oop pdo stopwatch


    【解决方案1】:

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

    当他们提交测试时,您会检查相同的内容。

    您必须为学生提供一个唯一的 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
       }
    }
    

    【讨论】:

      猜你喜欢
      • 2013-05-12
      • 1970-01-01
      • 1970-01-01
      • 2019-06-08
      • 2016-05-23
      • 2011-07-05
      • 1970-01-01
      • 1970-01-01
      • 2021-03-13
      相关资源
      最近更新 更多