codenamecrud/codenamecrud

View on GitHub
app/views/courses/show.html.slim

Summary

Maintainability
Test Coverage
.container
  .col-sm-8.col-sm-offset-2.col-lg-8.col-lg-offset-2.text-center
    h1 = @course.title
    - if user_signed_in? && @course.is_active?
      h3.text-muted = "Завершено #{number_to_percentage(current_user.completed_lessons(@course).to_i,  precision: 0)}"

    .course-description
      p.text-muted= @course.description

  .col-sm-8.col-sm-offset-2.col-lg-8.col-lg-offset-2
    - @course.sections.order_by_position.each do |section|
        h2 id=("section-#{section.slug}") = section.title
        .section-description
          .col-xs-12
            p.text-muted = section.description
              ul.lessons-list
                - section.lessons.order_by_position.each.with_index(1) do |lesson, index|
                  li.row
                    = link_to [@course, lesson], class: 'link-to-lesson' do
                      h2.text-muted
                        ' Шаг #{index}:
                        span class=(lesson.is_project? ? 'text-danger' : 'text-primary') = lesson.title
                      .col-xs-12.lesson-description
                        = lesson.description

            ul.lessons-list
              - section.lessons.order_by_position.each.with_index(1) do |lesson, index|
                li.row
                  .toggle-check id=(dom_id(lesson))
                    - if user_signed_in? && current_user.lessons.include?(lesson)
                      i.glyphicon.glyphicon-check

                  = link_to [@course, lesson], class: 'link-to-lesson' do
                    h2.text-muted
                      ' Шаг #{index}:
                      span class=(lesson.is_project? ? 'text-danger' : 'text-primary') = lesson.title
                    .col-xs-12.lesson-description
                      = lesson.description

- title @course.title