Commit 9a484300 authored by Devin Zuczek's avatar Devin Zuczek Committed by Devin Zuczek
Browse files

Issue #2001772 by djdevin, deggertsen: UI Update: "Take Course" should change...

Issue #2001772 by djdevin, deggertsen: UI Update: "Take Course" should change to "Review Course" after user enrolled
parent eac8318f
Loading
Loading
Loading
Loading
+0 −13
Original line number Diff line number Diff line
@@ -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.
+1 −0
Original line number Diff line number Diff line
@@ -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'),
      ];
    }

+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>
+5 −0
Original line number Diff line number Diff line
@@ -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');
@@ -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'));
  }

}