You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
80 lines
1.5 KiB
80 lines
1.5 KiB
5 years ago
|
<?php
|
||
|
|
||
|
//问题类
|
||
|
class Question implements JsonSerializable
|
||
|
{
|
||
|
private $question_id;
|
||
|
private $question_title;
|
||
|
private $answer = array();
|
||
|
private $right_answer;
|
||
|
|
||
|
/**
|
||
|
* Question constructor.
|
||
|
* @param $question_id
|
||
|
* @param $question_title
|
||
|
*/
|
||
|
public function __construct($question_id, $question_title)
|
||
|
{
|
||
|
$this->question_id = $question_id;
|
||
|
$this->question_title = $question_title;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* @return mixed
|
||
|
*/
|
||
|
public function getQuestionId()
|
||
|
{
|
||
|
return $this->question_id;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* @return mixed
|
||
|
*/
|
||
|
public function getQuestionTitle()
|
||
|
{
|
||
|
return $this->question_title;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* @param mixed $question_id
|
||
|
*/
|
||
|
public function setQuestionId($question_id): void
|
||
|
{
|
||
|
$this->question_id = $question_id;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* @param mixed $question_title
|
||
|
*/
|
||
|
public function setQuestionTitle($question_title): void
|
||
|
{
|
||
|
$this->question_title = $question_title;
|
||
|
}
|
||
|
|
||
|
public function jsonSerialize()
|
||
|
{
|
||
|
$data = [];
|
||
|
foreach ($this as $key => $val) {
|
||
|
if ($val !== null) $data[$key] = $val;
|
||
|
}
|
||
|
return $data;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* @param array $answer
|
||
|
*/
|
||
|
public function setAnswer(array $answer): void
|
||
|
{
|
||
|
$this->answer = $answer;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* @param mixed $right_answer
|
||
|
*/
|
||
|
public function setRightAnswer($right_answer): void
|
||
|
{
|
||
|
$this->right_answer = $right_answer;
|
||
|
}
|
||
|
|
||
|
|
||
|
}
|