From f39279b84d44eba41f79e70d58f606fe07d2db1e Mon Sep 17 00:00:00 2001 From: omochiumaiumai Date: Tue, 12 Mar 2024 17:59:08 +0900 Subject: [PATCH 1/7] =?UTF-8?q?html=E3=81=A8js=E3=81=A7=E3=81=AE=E5=AE=9F?= =?UTF-8?q?=E8=A3=85=E3=81=AB=E5=A4=89=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../courses/practices_controller.rb | 2 ++ app/javascript/courses-practices.js | 22 +++++--------- .../practices/_courses_practice.html.slim | 24 +++++++++++++++ .../practices/_courses_practices.html.slim | 30 +++++++++++++++++++ .../practices/_practice_user_icon.html.slim | 4 +++ app/views/courses/practices/index.html.slim | 2 +- 6 files changed, 69 insertions(+), 15 deletions(-) create mode 100644 app/views/courses/practices/_courses_practice.html.slim create mode 100644 app/views/courses/practices/_courses_practices.html.slim create mode 100644 app/views/courses/practices/_practice_user_icon.html.slim diff --git a/app/controllers/courses/practices_controller.rb b/app/controllers/courses/practices_controller.rb index 4a00f3978cb..f3ac2768de1 100644 --- a/app/controllers/courses/practices_controller.rb +++ b/app/controllers/courses/practices_controller.rb @@ -3,5 +3,7 @@ class Courses::PracticesController < ApplicationController def index @course = Course.find(params[:course_id]) + @categories = Course.find(@course.id).categories.order(:created_at) + @learnings = current_user.learnings end end diff --git a/app/javascript/courses-practices.js b/app/javascript/courses-practices.js index 57e1a61e4c9..888d90b2dca 100644 --- a/app/javascript/courses-practices.js +++ b/app/javascript/courses-practices.js @@ -1,17 +1,11 @@ -import Vue from 'vue' -import CoursesPractices from 'courses-practices.vue' - document.addEventListener('DOMContentLoaded', () => { - const selector = '#js-courses-practices' - const practices = document.querySelector(selector) - if (practices) { - const courseId = practices.getAttribute('course-id') - const currentUser = window.currentUser - new Vue({ - render: (h) => - h(CoursesPractices, { - props: { courseId: courseId, currentUser: currentUser } - }) - }).$mount(selector) + function scrollToCategory() { + const count = location.href.search('#') + const hash = location.href.slice(count + 1) + const element = document.getElementById(hash) + if (element) { + element.scrollIntoView() + } } + scrollToCategory() }) diff --git a/app/views/courses/practices/_courses_practice.html.slim b/app/views/courses/practices/_courses_practice.html.slim new file mode 100644 index 00000000000..8fa753aaf4e --- /dev/null +++ b/app/views/courses/practices/_courses_practice.html.slim @@ -0,0 +1,24 @@ +.category-practices-item + a.category-practices-item__anchor :id="practice_#{practice.id}" + header.category-practices-item__header + .category-practices-item__title + a.category-practices-item__title-link href=practice_path(practice.id) + - if practice.include_must_read_books? + span.a-badge.is-danger.is-xs 要書籍 + span.category-practices-item__title-link-label = practice.title + - learning = learnings.find { |l| l.practice_id == practice.id } + - learning_status = learning ? learning.status : 'unstarted' + a.practice-status.category-practices-item__status( + class="is-#{learning_status}", + href="#{practice_path(practice.id)}#learning-Status") + = t("activerecord.enums.learning.status.#{learning_status}") + + .category-practices-item__learning-time.is-only-mentor + - learning_minute_statistic = practice.learning_minute_statistic + | 所要時間の目安: #{learning_minute_statistic.median} + | (平均: #{learning_minute_statistic.average}) + - if practice.started_students.present? + .a-user-icons + .a-user-icons__items + - practice.started_students.each do |started_student| + == render 'practice_user_icon', started_student: started_student diff --git a/app/views/courses/practices/_courses_practices.html.slim b/app/views/courses/practices/_courses_practices.html.slim new file mode 100644 index 00000000000..d7b8734d480 --- /dev/null +++ b/app/views/courses/practices/_courses_practices.html.slim @@ -0,0 +1,30 @@ +.page-body__inner + .page-body__columns + .page-body__column.is-main + - categories.each do |category| + - if category.practices.present? + .categories-item.practices(id="category-#{category.id}") + header.categories-item__header + h2.categories-item__title + = category.name + - if category.practices.size == current_user.completed_practices_size_by_category[category.id] + span.stamp.is-circle.is-solved 修了 + .categories-item__description + - if current_user.mentor + .categories-item__edit.is-only-mentor + a.categories-item__edit-link href=edit_mentor_category_path(category.id, course_id: course_id) + i.fa-solid.fa-pen + .a-long-text.is-md + = category.description + .categories-item__body.a-card + .category-practices + - category.practices.each do |practice| + == render 'courses_practice', practice: practice, learnings: learnings + .page-body__column.is-sub + nav.page-nav + ul.page-nav__items + - categories.each do |category| + - if category.practices.present? + li.page-nav__item + a.page-nav__item-link href="practices#category-#{category.id}" + span.page-nav__item-link-inner = category.name diff --git a/app/views/courses/practices/_practice_user_icon.html.slim b/app/views/courses/practices/_practice_user_icon.html.slim new file mode 100644 index 00000000000..884432f9681 --- /dev/null +++ b/app/views/courses/practices/_practice_user_icon.html.slim @@ -0,0 +1,4 @@ +.a-user-icons__item + a.a-user-icons__item-link(href="#{user_path(started_student)}") + span.a-user-role(class="a-user-role is-#{started_student.primary_role}") + = image_tag started_student.avatar_url, title: started_student.icon_title, class: 'a-user-icons__item-icon a-user-icon' diff --git a/app/views/courses/practices/index.html.slim b/app/views/courses/practices/index.html.slim index ea676b28893..8e52c990fa0 100644 --- a/app/views/courses/practices/index.html.slim +++ b/app/views/courses/practices/index.html.slim @@ -38,4 +38,4 @@ header.page-header = render 'courses/tabs' .page-body.js-users-visibility .container.is-xl - #js-courses-practices(course-id="#{@course.id}") + = render 'courses_practices', course_id: @course.id, categories: @categories, learnings: @learnings From 161f9f7942620dc562e162055c164ef295ab9a5b Mon Sep 17 00:00:00 2001 From: omochiumaiumai Date: Tue, 12 Mar 2024 17:59:20 +0900 Subject: [PATCH 2/7] =?UTF-8?q?vue=E3=82=92=E5=89=8A=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/javascript/courses-practices.vue | 117 -------------------------- app/javascript/practice-user-icon.vue | 21 ----- 2 files changed, 138 deletions(-) delete mode 100644 app/javascript/courses-practices.vue delete mode 100644 app/javascript/practice-user-icon.vue diff --git a/app/javascript/courses-practices.vue b/app/javascript/courses-practices.vue deleted file mode 100644 index 90a15a83483..00000000000 --- a/app/javascript/courses-practices.vue +++ /dev/null @@ -1,117 +0,0 @@ - - - diff --git a/app/javascript/practice-user-icon.vue b/app/javascript/practice-user-icon.vue deleted file mode 100644 index 9d5d7195b63..00000000000 --- a/app/javascript/practice-user-icon.vue +++ /dev/null @@ -1,21 +0,0 @@ - - - From 25321ccef2387635c0971bcaedcc23dfb2ba4bf2 Mon Sep 17 00:00:00 2001 From: omochiumaiumai Date: Wed, 13 Mar 2024 22:31:53 +0900 Subject: [PATCH 3/7] =?UTF-8?q?=E5=A4=96=E3=82=8C=E3=81=A6=E3=81=84?= =?UTF-8?q?=E3=82=8BCSS=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/courses/practices/_courses_practices.html.slim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/courses/practices/_courses_practices.html.slim b/app/views/courses/practices/_courses_practices.html.slim index d7b8734d480..d2da2277e72 100644 --- a/app/views/courses/practices/_courses_practices.html.slim +++ b/app/views/courses/practices/_courses_practices.html.slim @@ -21,7 +21,7 @@ - category.practices.each do |practice| == render 'courses_practice', practice: practice, learnings: learnings .page-body__column.is-sub - nav.page-nav + nav.page-nav.a-card ul.page-nav__items - categories.each do |category| - if category.practices.present? From ceac1c781eb4b4e96d6f22668f8b415990a61dcd Mon Sep 17 00:00:00 2001 From: omochiumaiumai Date: Fri, 15 Mar 2024 15:45:28 +0900 Subject: [PATCH 4/7] =?UTF-8?q?courses-practice.vue=E3=82=92=E5=89=8A?= =?UTF-8?q?=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/javascript/courses-practice.vue | 79 ----------------------------- 1 file changed, 79 deletions(-) delete mode 100644 app/javascript/courses-practice.vue diff --git a/app/javascript/courses-practice.vue b/app/javascript/courses-practice.vue deleted file mode 100644 index 9e2d7f2531b..00000000000 --- a/app/javascript/courses-practice.vue +++ /dev/null @@ -1,79 +0,0 @@ - - - From a5ec69e7a44cdca49f75ede4735f7c89ec6c608d Mon Sep 17 00:00:00 2001 From: omochiumaiumai Date: Mon, 18 Mar 2024 19:34:25 +0900 Subject: [PATCH 5/7] =?UTF-8?q?=E6=89=80=E8=A6=81=E6=99=82=E9=96=93?= =?UTF-8?q?=E3=81=AE=E7=9B=AE=E5=AE=89=E3=81=AE=E5=87=A6=E7=90=86=E3=82=92?= =?UTF-8?q?=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/practice.rb | 10 ++++++++++ .../courses/practices/_courses_practice.html.slim | 7 ++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/app/models/practice.rb b/app/models/practice.rb index 04a8b332767..65fc205d464 100644 --- a/app/models/practice.rb +++ b/app/models/practice.rb @@ -184,4 +184,14 @@ def total_learning_minute(report) def average_minute_per_practice(minute, size) minute / size end + + def convert_to_hour_minute(time) + hour = time / 60 + minute = (time % 60).round + if minute.zero? + "#{hour}時間" + else + "#{hour}時間#{minute}分" + end + end end diff --git a/app/views/courses/practices/_courses_practice.html.slim b/app/views/courses/practices/_courses_practice.html.slim index 8fa753aaf4e..822ecb89208 100644 --- a/app/views/courses/practices/_courses_practice.html.slim +++ b/app/views/courses/practices/_courses_practice.html.slim @@ -14,9 +14,10 @@ = t("activerecord.enums.learning.status.#{learning_status}") .category-practices-item__learning-time.is-only-mentor - - learning_minute_statistic = practice.learning_minute_statistic - | 所要時間の目安: #{learning_minute_statistic.median} - | (平均: #{learning_minute_statistic.average}) + - unless practice.learning_minute_statistic.nil? + - time = practice.learning_minute_statistic + | 所要時間の目安: #{convert_to_hour_minute(time.median)} + | (平均: #{convert_to_hour_minute(time.average)}) - if practice.started_students.present? .a-user-icons .a-user-icons__items From 69a0b2af28c23712aadd135f902d849f2d1bfd30 Mon Sep 17 00:00:00 2001 From: omochiumaiumai Date: Fri, 22 Mar 2024 22:13:58 +0900 Subject: [PATCH 6/7] =?UTF-8?q?=E6=8A=BD=E8=B1=A1=E7=9A=84=E3=81=AA?= =?UTF-8?q?=E5=A4=89=E6=95=B0=E5=90=8D=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/practice.rb | 12 ++++++------ .../courses/practices/_courses_practice.html.slim | 6 +++--- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/app/models/practice.rb b/app/models/practice.rb index 65fc205d464..a216313382c 100644 --- a/app/models/practice.rb +++ b/app/models/practice.rb @@ -185,13 +185,13 @@ def average_minute_per_practice(minute, size) minute / size end - def convert_to_hour_minute(time) - hour = time / 60 - minute = (time % 60).round - if minute.zero? - "#{hour}時間" + def convert_to_hour_minute(learning_minute_statistic) + converted_hour = learning_minute_statistic / 60 + converted_minute = (learning_minute_statistic % 60).round + if converted_minute.zero? + "#{converted_hour}時間" else - "#{hour}時間#{minute}分" + "#{converted_hour}時間#{converted_minute}分" end end end diff --git a/app/views/courses/practices/_courses_practice.html.slim b/app/views/courses/practices/_courses_practice.html.slim index 822ecb89208..88fc99d6919 100644 --- a/app/views/courses/practices/_courses_practice.html.slim +++ b/app/views/courses/practices/_courses_practice.html.slim @@ -15,9 +15,9 @@ .category-practices-item__learning-time.is-only-mentor - unless practice.learning_minute_statistic.nil? - - time = practice.learning_minute_statistic - | 所要時間の目安: #{convert_to_hour_minute(time.median)} - | (平均: #{convert_to_hour_minute(time.average)}) + - learning_minute_statistic = practice.learning_minute_statistic + | 所要時間の目安: #{convert_to_hour_minute(learning_minute_statistic.median)} + | (平均: #{convert_to_hour_minute(learning_minute_statistic.average)}) - if practice.started_students.present? .a-user-icons .a-user-icons__items From 92fb52d9cc49305bbbe447d7c0d1bf4c9c9d3b63 Mon Sep 17 00:00:00 2001 From: omochiumaiumai Date: Fri, 26 Apr 2024 01:05:20 +0900 Subject: [PATCH 7/7] =?UTF-8?q?`@course`=E3=82=92=E5=88=A9=E7=94=A8?= =?UTF-8?q?=E3=81=97=E3=81=A6`@categories`=E3=82=92=E5=8F=96=E5=BE=97?= =?UTF-8?q?=E3=81=99=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/courses/practices_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/courses/practices_controller.rb b/app/controllers/courses/practices_controller.rb index f3ac2768de1..6ca92fadcb9 100644 --- a/app/controllers/courses/practices_controller.rb +++ b/app/controllers/courses/practices_controller.rb @@ -3,7 +3,7 @@ class Courses::PracticesController < ApplicationController def index @course = Course.find(params[:course_id]) - @categories = Course.find(@course.id).categories.order(:created_at) + @categories = @course.categories.order(:created_at) @learnings = current_user.learnings end end