exam progress update when get

This commit is contained in:
xiaomlove
2021-06-14 01:54:19 +08:00
parent 0c11ceaaa2
commit 67d68e73f7
4 changed files with 23 additions and 12 deletions

View File

@@ -23,16 +23,16 @@ class Attendance
public function attend($initial = 10, $step = 5, $maximum = 2000, $continous = array())
{
if($this->check(true)) return false;
$res = sql_query(sprintf('SELECT DATEDIFF(%s, `added`) AS diff, `days`, `total_days`, `total_points` FROM `attendance` WHERE `uid` = %u ORDER BY `id` DESC LIMIT 1', sqlesc($this->curdate), $this->userid)) or sqlerr(__FILE__,__LINE__);
$res = sql_query(sprintf('SELECT DATEDIFF(%s, `added`) AS diff, `days`, `total_days` FROM `attendance` WHERE `uid` = %u ORDER BY `id` DESC LIMIT 1', sqlesc($this->curdate), $this->userid)) or sqlerr(__FILE__,__LINE__);
$doUpdate = mysql_num_rows($res);
if ($doUpdate) {
$row = mysql_fetch_row($res);
do_log("uid: {$this->userid}, row: " . json_encode($row));
} else {
$row = [0, 0, 0, 0];
$row = [0, 0, 0];
}
$points = min($initial + $step * $row['total_attend_times'], $maximum);
list($datediff, $days, $totalDays, $totalPoints) = $row;
list($datediff, $days, $totalDays) = $row;
$cdays = $datediff == 1 ? ++$days : 1;
if($cdays > 1){
krsort($continous);