PaperQuestion.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. namespace App\Models;
  3. use Illuminate\Database\Eloquent\Model;
  4. class PaperQuestion extends Model
  5. {
  6. protected $table = 'paper_questions';
  7. protected $primaryKey = 'id';
  8. public $incrementing = false;
  9. protected $keyType = 'string';
  10. public $timestamps = false;
  11. protected $fillable = [
  12. 'id',
  13. 'paper_id',
  14. 'question_bank_id',
  15. 'knowledge_point',
  16. 'question_type', // choice-选择题, fill-填空题, answer-解答题
  17. 'difficulty',
  18. 'score',
  19. 'estimated_time',
  20. 'question_number',
  21. 'student_answer',
  22. 'is_correct',
  23. 'score_obtained',
  24. ];
  25. protected $casts = [
  26. 'question_bank_id' => 'integer',
  27. 'difficulty' => 'float',
  28. 'score' => 'float',
  29. 'estimated_time' => 'integer',
  30. 'question_number' => 'integer',
  31. 'is_correct' => 'boolean',
  32. 'score_obtained' => 'float',
  33. 'question_type' => 'string',
  34. ];
  35. /**
  36. * 获取所属试卷
  37. */
  38. public function paper()
  39. {
  40. return $this->belongsTo(Paper::class, 'paper_id', 'paper_id');
  41. }
  42. }