fix attendance

This commit is contained in:
xiaomlove
2021-06-14 02:12:21 +08:00
parent 67d68e73f7
commit c63005fbf7
2 changed files with 5 additions and 4 deletions

View File

@@ -584,13 +584,13 @@ class ExamRepository extends BaseRepository
try {
$updateResult = $this->updateProgress($examUser);
if ($updateResult) {
do_log("$logPrefix, [UPDATE_SUCCESS_RETURN_DIRECTLY]");
do_log("$logPrefix, [UPDATE_PROGRESS_SUCCESS_RETURN_DIRECTLY]");
return $updateResult;
} else {
do_log("$logPrefix, [UPDATE_SUCCESS_FAIL]");
do_log("$logPrefix, [UPDATE_PROGRESS_FAIL]");
}
} catch (\Exception $exception) {
do_log("$logPrefix, [UPDATE_SUCCESS_FAIL]: " . $exception->getMessage(), 'error');
do_log("$logPrefix, [UPDATE_PROGRESS_FAIL]: " . $exception->getMessage(), 'error');
}
$exam = $examUser->exam;
$progress = $examUser->progress;

View File

@@ -22,6 +22,7 @@ class Attendance
public function attend($initial = 10, $step = 5, $maximum = 2000, $continous = array())
{
do_log(json_encode(func_get_args()));
if($this->check(true)) return false;
$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);
@@ -31,8 +32,8 @@ class Attendance
} else {
$row = [0, 0, 0];
}
$points = min($initial + $step * $row['total_attend_times'], $maximum);
list($datediff, $days, $totalDays) = $row;
$points = min($initial + $step * $totalDays, $maximum);
$cdays = $datediff == 1 ? ++$days : 1;
if($cdays > 1){
krsort($continous);