private function DDLinesResponse::getDragDropResults in Quiz 8.4
Get a list of the labels, tagged correct, false, or no answer
1 call to DDLinesResponse::getDragDropResults()
- DDLinesResponse::score in question_types/
quiz_ddlines/ lib/ Drupal/ quiz_ddlines/ DDLinesResponse.php - Calculate the score for the response.
File
- question_types/
quiz_ddlines/ lib/ Drupal/ quiz_ddlines/ DDLinesResponse.php, line 259
Class
- DDLinesResponse
- Extension of QuizQuestionResponse
Namespace
Drupal\quiz_ddlinesCode
private function getDragDropResults() {
$results = array();
// Iterate through the correct answers, and check
// the users answer:
foreach (json_decode($this->question->ddlines_elements)->elements as $element) {
$source_id = $element->label->id;
if (isset($this->user_answers[$source_id])) {
$results[$element->label->id] = $this->user_answers[$source_id] == $element->hotspot->id ? AnswerStatus::CORRECT : AnswerStatus::WRONG;
}
else {
$results[$element->label->id] = AnswerStatus::NO_ANSWER;
}
}
return $results;
}