Added validation for options, change a bit of layout and added some html5 validation

This commit is contained in:
mwalbeck 2016-10-24 13:38:02 +02:00
commit aa6e5653e1
19 changed files with 78 additions and 136 deletions

View file

@ -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();
}