closedquestion-8.x-3.x-dev/src/Question/CqQuestionInterface.php
src/Question/CqQuestionInterface.php
<?php
namespace Drupal\closedquestion\Question;
/**
* Interface CqQuestionInterface.
*
* Interface containing the set of functions external modules can expect from a
* question.
*
* @package Drupal\closedquestion\Question
*/
interface CqQuestionInterface {
/**
* Check if the user answered the quetsion correctly.
*
* @return bool
* TRUE if the current answer of the user is the correct answer, FALSE
* otherwise.
*/
public function isCorrect();
/**
* Gets tries before correct answer.
*
* Get the number of tries the user needed to find the correct answer,
* or 0 if the user has not found the correct answer yet.
*
* @return int
* The number of tries needed to find the correct answer.
*/
public function onceCorrect();
/**
* Gets the number of incorrect answers the user has given.
*
* This can be larger than the number returned by onceCorrect, if the user,
* after finding the correct answer, tries more incorrect answers just
* to see the feedback.
*
* @return int
* The number of incorrect answers given.
*/
public function getTries();
/**
* Resets the answer and tries counts of the question.
*/
public function reset();
/**
* Adds a listener to the question.
*
* @param CqListenerQuestionInterface $listener
* The listener to add.
*/
public function addListener(CqListenerQuestionInterface $listener);
/**
* Returns the UserAnswer of this question.
*
* @return object
* cqUserAnswer object.
*/
public function getUserAnswer();
/**
* Returns the node of this question.
*
* @return \Drupal\closedquestion\Entity\ClosedQuestionInterface
* Closed question entity.
*/
public function getClosedQuestion();
}
