You are here

function CourseObjectQuiz::getTakeUrl in Course 8.2

Same name and namespace in other branches
  1. 8.3 modules/course_quiz/src/Plugin/course/CourseObject/CourseObjectQuiz.php \Drupal\course_quiz\Plugin\course\CourseObject\CourseObjectQuiz::getTakeUrl()
  2. 3.x modules/course_quiz/src/Plugin/course/CourseObject/CourseObjectQuiz.php \Drupal\course_quiz\Plugin\course\CourseObject\CourseObjectQuiz::getTakeUrl()

The take URL of the quiz is /take.

Overrides CourseObject::getTakeUrl

File

modules/course_quiz/src/Plugin/course/CourseObject/CourseObjectQuiz.php, line 57

Class

CourseObjectQuiz
Plugin annotation @CourseObject( id = "quiz", label = "Quiz", handlers = { "fulfillment" = "\Drupal\course_quiz\Plugin\course\CourseObject\CourseObjectQuizFulfillment" } )

Namespace

Drupal\course_quiz\Plugin\course\CourseObject

Code

function getTakeUrl() {
  if ($this
    ->getOption('quiz_goto') == "view") {
    return \Drupal\Core\Url::fromRoute('entity.quiz.take', [
      'quiz' => $this
        ->getInstanceId(),
    ]);
  }
  else {
    return \Drupal\Core\Url::fromRoute('entity.quiz.canonical', [
      'quiz' => $this
        ->getInstanceId(),
    ]);
  }
}