gpt4 book ai didi

php - 阿里测验没有零结果

转载 作者:行者123 更新时间:2023-11-29 22:29:42 24 4
gpt4 key购买 nike

我有 Ari Quiz 的代码:

$query = sprintf('UPDATE #__ariquizstatisticsinfo SET Status = %1$s,EndDate = %2$s,MaxScore = %3$f,UserScore = %4$f,UserScorePercent = %7$f, Passed = %5$d, ElapsedTime = UNIX_TIMESTAMP(%2$s) - UNIX_TIMESTAMP(StartDate) + UsedTime WHERE StatisticsInfoId = %6$d',
$db->Quote(ARIQUIZ_USERQUIZ_STATUS_COMPLETE),
$db->Quote($finishedDate),
$finishedInfo['MaxScore'],
$finishedInfo['UserScore'],
$finishedInfo['Passed'],
$statisticsInfoId,
$finishedInfo['MaxScore'] > 0 ? min(round(100 * $finishedInfo['UserScore'] / $finishedInfo['MaxScore'], 2), 100.00) : 0.00

);

但是当没有正确回答问题时,我不需要在 mysql 数据库中写入 0 个结果。我对此进行了修改:

    if ($finishedInfo['UserScore'] == 0.00) 
{
$resultes = 1.00;
}
else
{
$resultes = $f;
}
$query = sprintf('UPDATE #__ariquizstatisticsinfo SET Status = %1$s,EndDate = %2$s,MaxScore = %3$f,UserScore = %4$resultes,UserScorePercent = %7$f, Passed = %5$d, ElapsedTime = UNIX_TIMESTAMP(%2$s) - UNIX_TIMESTAMP(StartDate) + UsedTime WHERE StatisticsInfoId = %6$d',
$db->Quote(ARIQUIZ_USERQUIZ_STATUS_COMPLETE),
$db->Quote($finishedDate),
$finishedInfo['MaxScore'],
$finishedInfo['UserScore'],
$finishedInfo['Passed'],
$statisticsInfoId,
$finishedInfo['MaxScore'] > 0 ? min(round(100 * $finishedInfo['UserScore'] / $finishedInfo['MaxScore'], 2), 100.00) : 0.00
);

但是当我完成测试时出现错误:

500 - AriQuizModelUserQuiz::markQuizAsFinished() : The following SQL query can not be executed 'UPDATE #__ariquizstatisticsinfo SET Status = 'Finished',EndDate = '2015-04-28 07:41:06',MaxScore = 2.700000,UserScore = esultes,UserScorePercent = 0.000000, Passed = 0, ElapsedTime = UNIX_TIMESTAMP('2015-04-28 07:41:06') - UNIX_TIMESTAMP(StartDate) + UsedTime WHERE StatisticsInfoId = 134'. Details: Unknown column 'esultes' in 'field list' SQL=UPDATE joomla_ariquizstatisticsinfo SET Status = 'Finished',EndDate = '2015-04-28 07:41:06',MaxScore = 2.700000,UserScore = esultes,UserScorePercent = 0.000000, Passed = 0, ElapsedTime = UNIX_TIMESTAMP('2015-04-28 07:41:06') - UNIX_TIMESTAMP(StartDate) + UsedTime WHERE StatisticsInfoId = 134

提前致谢!

<小时/>

返回更新:我尝试了这段代码:

   $finaluserscore = '%4$f';
if ($finaluserscore == 0.00)
{
$finaluserscore = 1.00;
} else {
$finaluserscore = '%4$f';
}
$query = sprintf('UPDATE #__ariquizstatisticsinfo SET Status = %1$s,EndDate = %2$s,MaxScore = %3$f,UserScore = ' . $finaluserscore . ',UserScorePercent = %7$f, Passed = %5$d, ElapsedTime = UNIX_TIMESTAMP(%2$s) - UNIX_TIMESTAMP(StartDate) + UsedTime WHERE StatisticsInfoId = %6$d',
$db->Quote(ARIQUIZ_USERQUIZ_STATUS_COMPLETE),
$db->Quote($finishedDate),
$finishedInfo['MaxScore'],
$finishedInfo['UserScore'],
$finishedInfo['Passed'],
$statisticsInfoId,
$finishedInfo['MaxScore'] > 0 ? min(round(100 * $finishedInfo['UserScore'] / $finishedInfo['MaxScore'], 2), 100.00) : 0.00
);

但我不明白为什么如果我得到的结果是 0.00,这会让我得到 1.00,而如果我得到的结果超过 0.00,那么结果还是一样。

最佳答案

我认为你漏掉了一个逗号

UserScore = %4$resultes

可能

UserScore = %4$,resultes

关于php - 阿里测验没有零结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29913386/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com