| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- <?php
- namespace App\Models;
- use Illuminate\Database\Eloquent\Model;
- class PaperQuestion extends Model
- {
- protected $table = 'paper_questions';
- protected $primaryKey = 'id';
- public $incrementing = false;
- protected $keyType = 'string';
- public $timestamps = false;
-
- protected $fillable = [
- 'id',
- 'paper_id',
- 'question_bank_id',
- 'knowledge_point',
- 'question_type', // choice-选择题, fill-填空题, answer-解答题
- 'difficulty',
- 'score',
- 'estimated_time',
- 'question_number',
- 'student_answer',
- 'is_correct',
- 'score_obtained',
- ];
-
- protected $casts = [
- 'question_bank_id' => 'integer',
- 'difficulty' => 'float',
- 'score' => 'float',
- 'estimated_time' => 'integer',
- 'question_number' => 'integer',
- 'is_correct' => 'boolean',
- 'score_obtained' => 'float',
- 'question_type' => 'string',
- ];
-
- /**
- * 获取所属试卷
- */
- public function paper()
- {
- return $this->belongsTo(Paper::class, 'paper_id', 'paper_id');
- }
- /**
- * 获取对应的题库题目
- */
- public function questionBank()
- {
- return $this->belongsTo(\App\Models\Question::class, 'question_bank_id', 'id');
- }
- }
|