mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-03 14:10:57 +08:00
exam add backgrond color
This commit is contained in:
@@ -104,6 +104,10 @@ class ExamResource extends Resource
|
||||
->inline()
|
||||
->required()
|
||||
->columnSpan(['sm' => 2]),
|
||||
Forms\Components\TextInput::make('background_color')
|
||||
->required()
|
||||
->label(__('exam.background_color'))
|
||||
->columnSpan(['sm' => 2]),
|
||||
Forms\Components\TextInput::make('priority')
|
||||
->columnSpan(['sm' => 2])
|
||||
->integer()
|
||||
|
||||
@@ -11,7 +11,7 @@ class Exam extends NexusModel
|
||||
{
|
||||
protected $fillable = [
|
||||
'name', 'description', 'begin', 'end', 'duration', 'status', 'is_discovered', 'filters', 'indexes', 'priority',
|
||||
'recurring', 'type', 'success_reward_bonus', 'fail_deduct_bonus', 'max_user_count'
|
||||
'recurring', 'type', 'success_reward_bonus', 'fail_deduct_bonus', 'max_user_count', 'background_color',
|
||||
];
|
||||
|
||||
public $timestamps = true;
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('exams', function (Blueprint $table) {
|
||||
$table->string("background_color")->default("blue");
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('exams', function (Blueprint $table) {
|
||||
$table->dropColumn("background_color");
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -2899,9 +2899,9 @@ if ($msgalert)
|
||||
|
||||
//show the exam info
|
||||
$exam = new \Nexus\Exam\Exam();
|
||||
$examHtml = $exam->render($CURUSER['id']);
|
||||
if (!empty($examHtml)) {
|
||||
msgalert("messages.php", $examHtml, "blue");
|
||||
$currentExam = $exam->getCurrent($CURUSER['id']);
|
||||
if (!empty($currentExam['html'])) {
|
||||
msgalert("messages.php", $currentExam['html'], $currentExam['exam']->background_color ?? 'blue');
|
||||
}
|
||||
}
|
||||
if ($offlinemsg)
|
||||
|
||||
@@ -7,12 +7,12 @@ use App\Repositories\ExamRepository;
|
||||
|
||||
class Exam
|
||||
{
|
||||
public function render($uid)
|
||||
public function getCurrent($uid): array
|
||||
{
|
||||
$examRep = new ExamRepository();
|
||||
$userExam = $examRep->getUserExamProgress($uid, ExamUser::STATUS_NORMAL);
|
||||
if (empty($userExam)) {
|
||||
return '';
|
||||
return ['exam' => null, 'html' => ''];
|
||||
}
|
||||
/** @var \App\Models\Exam $exam */
|
||||
$exam = $userExam->exam;
|
||||
@@ -34,6 +34,7 @@ class Exam
|
||||
if ($exam->description) {
|
||||
$row[] = "\n" . $exam->description;
|
||||
}
|
||||
return nl2br(implode("\n", $row));
|
||||
$html = nl2br(implode("\n", $row));
|
||||
return compact('exam', 'html');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,4 +68,5 @@ return [
|
||||
'reach_max_user_count' => 'The number of claimed users has reached its maximum',
|
||||
'claimed_user_count' => 'Claimed',
|
||||
'max_user_count' => 'Max claim user count(0 means unlimited)',
|
||||
'background_color' => 'Info box background color',
|
||||
];
|
||||
|
||||
@@ -70,4 +70,5 @@ return [
|
||||
'reach_max_user_count' => '认领人数已达上限',
|
||||
'claimed_user_count' => '认领人数',
|
||||
'max_user_count' => '最多认领人数(0表示无限制)',
|
||||
'background_color' => '信息框背景色',
|
||||
];
|
||||
|
||||
@@ -68,4 +68,5 @@ return [
|
||||
'reach_max_user_count' => '認領人數已達上限',
|
||||
'claimed_user_count' => '認領人數',
|
||||
'max_user_count' => '最多認領人數(0表示無限製)',
|
||||
'background_color' => '信息框背景色',
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user