Loading course.module +0 −13 Original line number Diff line number Diff line Loading @@ -131,19 +131,6 @@ function course_editing_start($course) { } } /** * Menu title handler for the Take course tab. * * @return string * "Review course" or "Take course", depending on the current user's * completion status. */ function course_take_title($node) { global $user; $report = course_enrollment_load($node, $user); return ($user->uid > 1 && isset($report->complete) && $report->complete) ? t('Review course') : t('Take course'); } /** * Menu access callback to determins if the take course button should display * on the course node. Loading src/View/CourseViewBuilder.php +1 −0 Original line number Diff line number Diff line Loading @@ -36,6 +36,7 @@ class CourseViewBuilder extends EntityViewBuilder { $build['course'] = [ '#theme' => 'course_take_course_button', '#course' => $course, '#title' => $enrollment && $enrollment->isComplete() ? t('Review course') : t('Take course'), ]; } Loading templates/course-take-course-button.html.twig +1 −1 Original line number Diff line number Diff line <div class="course-take-course-link-wrapper"> <a {{ create_attribute({'class': ['course-take-course-link', 'button']}) }} href="{{ path('course.take', {'course': course.id}) }}"> {{ 'Take course'|t }} {{ title }} </a> </div> tests/src/Functional/CourseWorkflowTest.php +5 −0 Original line number Diff line number Diff line Loading @@ -43,6 +43,8 @@ class CourseWorkflowTest extends CourseTestBase { $this->assertResponse(200, 'Can see completion page'); $this->assertSession()->responseContains('This course is not complete.'); $this->drupalGet("course/{$course->id()}"); $this->assertSession()->linkExistsExact(t('Take course')); $this->drupalGet("course/{$course->id()}/take"); $this->assertLink('Course object 1'); $this->assertNoLink('Course object 2'); Loading Loading @@ -71,6 +73,9 @@ class CourseWorkflowTest extends CourseTestBase { $this->assertLink('Complete'); $this->clickLink('Complete'); $this->assertSession()->responseContains('You have completed the course.'); $this->drupalGet("course/{$course->id()}"); $this->assertSession()->linkExistsExact(t('Review course')); } } Loading
course.module +0 −13 Original line number Diff line number Diff line Loading @@ -131,19 +131,6 @@ function course_editing_start($course) { } } /** * Menu title handler for the Take course tab. * * @return string * "Review course" or "Take course", depending on the current user's * completion status. */ function course_take_title($node) { global $user; $report = course_enrollment_load($node, $user); return ($user->uid > 1 && isset($report->complete) && $report->complete) ? t('Review course') : t('Take course'); } /** * Menu access callback to determins if the take course button should display * on the course node. Loading
src/View/CourseViewBuilder.php +1 −0 Original line number Diff line number Diff line Loading @@ -36,6 +36,7 @@ class CourseViewBuilder extends EntityViewBuilder { $build['course'] = [ '#theme' => 'course_take_course_button', '#course' => $course, '#title' => $enrollment && $enrollment->isComplete() ? t('Review course') : t('Take course'), ]; } Loading
templates/course-take-course-button.html.twig +1 −1 Original line number Diff line number Diff line <div class="course-take-course-link-wrapper"> <a {{ create_attribute({'class': ['course-take-course-link', 'button']}) }} href="{{ path('course.take', {'course': course.id}) }}"> {{ 'Take course'|t }} {{ title }} </a> </div>
tests/src/Functional/CourseWorkflowTest.php +5 −0 Original line number Diff line number Diff line Loading @@ -43,6 +43,8 @@ class CourseWorkflowTest extends CourseTestBase { $this->assertResponse(200, 'Can see completion page'); $this->assertSession()->responseContains('This course is not complete.'); $this->drupalGet("course/{$course->id()}"); $this->assertSession()->linkExistsExact(t('Take course')); $this->drupalGet("course/{$course->id()}/take"); $this->assertLink('Course object 1'); $this->assertNoLink('Course object 2'); Loading Loading @@ -71,6 +73,9 @@ class CourseWorkflowTest extends CourseTestBase { $this->assertLink('Complete'); $this->clickLink('Complete'); $this->assertSession()->responseContains('You have completed the course.'); $this->drupalGet("course/{$course->id()}"); $this->assertSession()->linkExistsExact(t('Review course')); } }