0

I am working on a time based quiz project with PHP and MySQL and storing results as in below table.

Table: score

sid |Question_ID|answer |is_correct|User_ID|score|score_calculated|time_taken
1   |10         |Manager|Y         |  1    |200  |  0             |3.2
2   |10         |Emp    |N         |  2    |200  |  0             |2.4
3   |10         |Manager|Y         |  3    |200  |  0             |6.5
4   |10         |Other  |N         |  4    |200  |  0             |8.3
5   |11         |Yellow |N         |  1    |300  |  0             |2.3
5   |11         |green  |N         |  2    |300  |  0             |5.8
6   |11         |Red    |Y         |  3    |300  |  0             |6.4
7   |11         |Red    |Y         |  4    |300  |  0             |9.1

Score column contain the mark for each question

Score calculations based on:

  • Correct answer used minimum time = 100%
  • Correct answer used 2nd minimum time = 75%
  • Correct answer used 3rd minimum time = 50%
  • Other correct answers = 25%
  • Other incorrect answers = 0

The above calculated values need to be updated on ** 'score_calculated' ** field. Can anyone please suggest a query or method to solve the scoring process?

4

2 回答 2

1

解决您的问题的最佳方法是 MysqlTrigger。在每次提交答案时(插入后),您都可以调用触发器。

于 2013-07-05T07:47:03.660 回答
0

Ranking通过记录解决了问题time_taken。稍后我将使用查询编辑它...

于 2013-07-08T07:54:37.567 回答