normalize-logging

This commit is contained in:
xiaomlove
2021-04-26 20:37:17 +08:00
parent 58c6aa58e8
commit 63a2c71cb6
18 changed files with 225 additions and 109 deletions

View File

@@ -20,6 +20,8 @@ class DB
}
const ELOQUENT_CONNECTION_NAME = 'default';
public function setDriver(DBInterface $driver)
{
$this->driver = $driver;

View File

@@ -11,33 +11,29 @@ class Exam
{
global $lang_functions;
$examRep = new ExamRepository();
$userExams = $examRep->listUserExamProgress($uid);
if ($userExams->isEmpty()) {
$userExam = $examRep->getUserExamProgress($uid);
if (empty($userExam)) {
return '';
}
$htmlArr = [];
foreach ($userExams as $userExam) {
$exam = $userExam->exam;
$row = [];
$row[] = sprintf('%s%s', $lang_functions['exam_name'], $exam->name);
$row[] = sprintf('%s%s ~ %s', $lang_functions['exam_time_range'], $exam->begin, $exam->end);
foreach ($exam->indexes as $key => $index) {
if (isset($index['checked']) && $index['checked']) {
$requireValue = $index['require_value'];
$currentValue = $userExam->progress_value[$index['index']] ?? 0;
$unit = ExamModel::$indexes[$index['index']]['unit'] ?? '';
$row[] = sprintf(
'%s%s, Require%s %s, Current%s %s, Result%s',
$lang_functions['exam_index'] . ($key + 1),
ExamModel::$indexes[$index['index']]['name'] ?? '',
$requireValue, $unit,
$currentValue, $unit,
$currentValue >= $requireValue ? 'Done!' : 'Not done!'
);
}
$exam = $userExam->exam;
$row = [];
$row[] = sprintf('%s%s', $lang_functions['exam_name'], $exam->name);
$row[] = sprintf('%s%s ~ %s', $lang_functions['exam_time_range'], $exam->begin, $exam->end);
foreach ($exam->indexes as $key => $index) {
if (isset($index['checked']) && $index['checked']) {
$requireValue = $index['require_value'];
$currentValue = $userExam->progress[$index['index']] ?? 0;
$unit = ExamModel::$indexes[$index['index']]['unit'] ?? '';
$row[] = sprintf(
'%s%s, %s%s %s, %s%s %s, %s%s',
$lang_functions['exam_index'] . ($key + 1), ExamModel::$indexes[$index['index']]['name'] ?? '',
$lang_functions['exam_require'], $requireValue, $unit,
$lang_functions['exam_progress_current'], $currentValue, $unit,
$lang_functions['exam_progress_result'],
$currentValue >= $requireValue ? $lang_functions['exam_progress_result_pass_yes'] : $lang_functions['exam_progress_result_pass_no']
);
}
$htmlArr[] = implode("\n", $row);
}
return nl2br(implode("\n\n", $htmlArr));
return nl2br(implode("\n", $row));
}
}