Added validation for options, change a bit of layout and added some html5 validation
This commit is contained in:
parent
71c79d3b2a
commit
aa6e5653e1
19 changed files with 78 additions and 136 deletions
app
|
@ -17,24 +17,24 @@ class Option extends Model
|
|||
return true;
|
||||
}
|
||||
|
||||
public function addOption($question, $request, $nr)
|
||||
public function addOption($question, $optionData)
|
||||
{
|
||||
$this->option = $request->get("option{$nr}");
|
||||
if ($request->get("correct_answer{$nr}") == null) {
|
||||
$this->correct_answer = 0;
|
||||
$this->option = $optionData["option"];
|
||||
if (array_key_exists("correct_answer", $optionData)) {
|
||||
$this->correct_answer = 1;
|
||||
} else {
|
||||
$this->correct_answer = $request->get("correct_answer{$nr}");
|
||||
$this->correct_answer = 0;
|
||||
}
|
||||
$question->options()->save($this);
|
||||
}
|
||||
|
||||
public function updateOption($request, $nr)
|
||||
public function updateOption($optionData)
|
||||
{
|
||||
$this->option = $request->get("option{$nr}");
|
||||
if ($request->get("correct_answer{$nr}") == null) {
|
||||
$this->correct_answer = 0;
|
||||
$this->option = $optionData["option"];
|
||||
if (array_key_exists("correct_answer", $optionData)) {
|
||||
$this->correct_answer = 1;
|
||||
} else {
|
||||
$this->correct_answer = $request->get("correct_answer{$nr}");
|
||||
$this->correct_answer = 0;
|
||||
}
|
||||
$this->update();
|
||||
}
|
||||
|
|
Reference in a new issue