From c0f38b84c2a455f95eb4f3605f233e0f883b264a Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Wed, 18 Mar 2020 20:25:53 +0800 Subject: [PATCH 1/6] =?UTF-8?q?=E8=8E=B7=E5=8F=96=E4=B8=8B=E4=B8=80?= =?UTF-8?q?=E4=B8=AA=E5=BE=85=E8=AF=84=E9=98=85=E7=9A=84=E5=AD=A6=E7=94=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/application_controller.rb | 2 +- app/controllers/homework_commons_controller.rb | 11 ++++++++++- .../homework_commons/get_next_work.json.jbuilder | 2 ++ config/routes.rb | 1 + 4 files changed, 14 insertions(+), 2 deletions(-) create mode 100644 app/views/homework_commons/get_next_work.json.jbuilder diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 15e795bdb..ccf52049c 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -330,7 +330,7 @@ class ApplicationController < ActionController::Base end if !User.current.logged? && Rails.env.development? - User.current = User.find 1 + User.current = User.find 8825 end diff --git a/app/controllers/homework_commons_controller.rb b/app/controllers/homework_commons_controller.rb index f64688deb..98be8c699 100644 --- a/app/controllers/homework_commons_controller.rb +++ b/app/controllers/homework_commons_controller.rb @@ -11,7 +11,7 @@ class HomeworkCommonsController < ApplicationController before_action :find_homework, only: [:edit, :show, :update, :group_list, :homework_code_repeat, :code_review_results, :code_review_detail, :show_comment, :settings, :works_list, :update_settings, :reference_answer, :publish_groups, :end_groups, :alter_name, :update_explanation, - :update_score, :update_student_score, :batch_comment] + :update_score, :update_student_score, :batch_comment, :get_next_work] before_action :user_course_identity before_action :homework_publish, only: [:show, :works_list, :code_review_results, :show_comment, :settings, :reference_answer, :update_student_score] @@ -287,6 +287,15 @@ class HomeworkCommonsController < ApplicationController end end + def get_next_work + member = @course.course_member(current_user.id) + student_works = @homework.teacher_works(member).where.not(id: @homework.student_works_scores.where(reviewer_role: [1, 2])) + if params[:work_id] + student_works = student_works.where.not(id: params[:work_id]) + end + @work = student_works.where("work_status > 0").take + end + def update_score tip_exception("作业还未发布,暂不能计算成绩") if @homework.publish_time.nil? || @homework.publish_time > Time.now @homework.update_homework_work_score diff --git a/app/views/homework_commons/get_next_work.json.jbuilder b/app/views/homework_commons/get_next_work.json.jbuilder new file mode 100644 index 000000000..e03b18970 --- /dev/null +++ b/app/views/homework_commons/get_next_work.json.jbuilder @@ -0,0 +1,2 @@ +json.work_id @work&.id +json.user_name @work&.user&.real_name \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index 047141ea8..da07c8d89 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -597,6 +597,7 @@ Rails.application.routes.draw do get :update_score get :update_student_score post :batch_comment + get :get_next_work end collection do From 48b9fa519726163f6ca93252a64a18c354506e55 Mon Sep 17 00:00:00 2001 From: harry Date: Wed, 18 Mar 2020 20:28:34 +0800 Subject: [PATCH 2/6] video-player add point --- .../react/src/modules/courses/Video/video-play/index.jsx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/public/react/src/modules/courses/Video/video-play/index.jsx b/public/react/src/modules/courses/Video/video-play/index.jsx index e33439dcf..b3d20fd8e 100644 --- a/public/react/src/modules/courses/Video/video-play/index.jsx +++ b/public/react/src/modules/courses/Video/video-play/index.jsx @@ -44,7 +44,9 @@ export default ({ src, videoId, logWatchHistory, courseId = null }) => { let pos = []//播放时间点集 const log = useCallback((callback, isEnd = false) => { - let params = {} + let params = { + point: el.currentTime.currentTime + } if (logId) { params['log_id'] = logId params['watch_duration'] = getTotalEffectTime(pos) //当前观看视频时长,拖放进度条,重复的视频片段观看时,不会把重复的时长累积进来,最大时长是视频的总时长 @@ -137,7 +139,7 @@ export default ({ src, videoId, logWatchHistory, courseId = null }) => { log() } } - }else { + } else { lastUpdatedTime = newTime } } @@ -177,7 +179,7 @@ export default ({ src, videoId, logWatchHistory, courseId = null }) => { el.current.removeEventListener('seeking', onSeeking) el.current.removeEventListener('seeked', onSeeked) el.current.removeEventListener('timeupdate', onTimeupdate) - if(el.current.playing) { + if (el.current.playing) { log() } } From eb6cee3e615491fcf3f8274b421f38c6d583c445 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Wed, 18 Mar 2020 20:31:34 +0800 Subject: [PATCH 3/6] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E8=80=81=E5=B8=88?= =?UTF-8?q?=E5=90=8D=E7=A7=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/courses_controller.rb | 2 +- app/controllers/weapps/courses_controller.rb | 1 + app/controllers/weapps/homes_controller.rb | 2 +- app/views/courses/index.json.jbuilder | 1 - app/views/weapps/courses/show.json.jbuilder | 3 ++- app/views/weapps/homes/show.json.jbuilder | 1 + 6 files changed, 6 insertions(+), 4 deletions(-) diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index 48f644a14..46ac514b4 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -99,7 +99,7 @@ class CoursesController < ApplicationController limit = params[:limit] || 16 @courses = @courses.page(page).per(limit) - @courses = @courses.preload(:school, :none_hidden_course_modules, :teacher_users, teacher: :user_extension) + @courses = @courses.preload(:school, :none_hidden_course_modules, teacher: :user_extension) end def course_videos diff --git a/app/controllers/weapps/courses_controller.rb b/app/controllers/weapps/courses_controller.rb index 2a375a7fb..1dec62201 100644 --- a/app/controllers/weapps/courses_controller.rb +++ b/app/controllers/weapps/courses_controller.rb @@ -76,6 +76,7 @@ class Weapps::CoursesController < Weapps::BaseController def show @course = current_course @current_user = current_user + @teacher_users = @course.teacher_users.where.not(user_id: @course.tea_id).map(&:real_name)[0..2] end def shixun_homework_category diff --git a/app/controllers/weapps/homes_controller.rb b/app/controllers/weapps/homes_controller.rb index e53923fa8..3e94354a2 100644 --- a/app/controllers/weapps/homes_controller.rb +++ b/app/controllers/weapps/homes_controller.rb @@ -19,7 +19,7 @@ class Weapps::HomesController < Weapps::BaseController @courses = @courses.where(id: current_laboratory.all_courses) @course_count = @courses.count order_str = "course_members.sticky=1 desc, course_members.sticky_time desc, courses.created_at desc" - @courses = paginate(@courses.order(order_str).includes(:teacher, :school)) + @courses = paginate(@courses.order(order_str).includes(:teacher_users, :teacher, :school)) @user = current_user end end \ No newline at end of file diff --git a/app/views/courses/index.json.jbuilder b/app/views/courses/index.json.jbuilder index a8b70c435..f9bceebb8 100644 --- a/app/views/courses/index.json.jbuilder +++ b/app/views/courses/index.json.jbuilder @@ -13,6 +13,5 @@ json.courses @courses do |course| json.is_end course.is_end json.first_category_url module_url(course.none_hidden_course_modules.first, course) json.excellent course.excellent - json.teacher_users course.teacher_users.select{|u| u.id != course.tea_id }.map(&:real_name)[0..2] # 取前3名老师 end json.courses_count @courses_count diff --git a/app/views/weapps/courses/show.json.jbuilder b/app/views/weapps/courses/show.json.jbuilder index c22b24426..cf58315b4 100644 --- a/app/views/weapps/courses/show.json.jbuilder +++ b/app/views/weapps/courses/show.json.jbuilder @@ -1,4 +1,5 @@ json.(@course, :id, :name, :course_members_count, :credit, :invite_code_halt) json.teachers_count @course.teachers.count json.students_count @course.students.count -json.course_identity @current_user.course_identity(@course) \ No newline at end of file +json.course_identity @current_user.course_identity(@course) +json.teacher_users @teacher_users \ No newline at end of file diff --git a/app/views/weapps/homes/show.json.jbuilder b/app/views/weapps/homes/show.json.jbuilder index f307d64fe..5d0e35e05 100644 --- a/app/views/weapps/homes/show.json.jbuilder +++ b/app/views/weapps/homes/show.json.jbuilder @@ -26,5 +26,6 @@ json.courses @courses.each do |course| course_member = @category == "study" ? course.students.where(user_id: @user.id).first : course.teachers.where(user_id: @user.id).first json.sticky course_member.sticky json.course_identity current_user.course_identity(course) + json.teacher_users course.teacher_users.select{|u| u.id != course.tea_id }.map(&:real_name)[0..2] # 取前3名老师 end From c24e5cf774c823a1c91865c291b0846166e1e0f5 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Wed, 18 Mar 2020 20:38:55 +0800 Subject: [PATCH 4/6] =?UTF-8?q?=E5=8D=8F=E4=BD=9C=E8=80=81=E5=B8=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/application_controller.rb | 2 +- app/controllers/weapps/courses_controller.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index ccf52049c..15e795bdb 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -330,7 +330,7 @@ class ApplicationController < ActionController::Base end if !User.current.logged? && Rails.env.development? - User.current = User.find 8825 + User.current = User.find 1 end diff --git a/app/controllers/weapps/courses_controller.rb b/app/controllers/weapps/courses_controller.rb index 1dec62201..3a1b22cc4 100644 --- a/app/controllers/weapps/courses_controller.rb +++ b/app/controllers/weapps/courses_controller.rb @@ -76,7 +76,7 @@ class Weapps::CoursesController < Weapps::BaseController def show @course = current_course @current_user = current_user - @teacher_users = @course.teacher_users.where.not(user_id: @course.tea_id).map(&:real_name)[0..2] + @teacher_users = @course.teacher_users.where.not(id: @course.tea_id).map(&:real_name)[0..2] end def shixun_homework_category From 7a28b31a468914174a50123f178f53283cb4be56 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Wed, 18 Mar 2020 20:47:26 +0800 Subject: [PATCH 5/6] =?UTF-8?q?=E5=AD=A6=E7=94=9F=E9=87=8D=E5=81=9A?= =?UTF-8?q?=E7=9A=84=E6=9D=83=E9=99=90=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/myshixuns_controller.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/controllers/myshixuns_controller.rb b/app/controllers/myshixuns_controller.rb index a96a2a79f..8713bebf3 100644 --- a/app/controllers/myshixuns_controller.rb +++ b/app/controllers/myshixuns_controller.rb @@ -18,7 +18,8 @@ class MyshixunsController < ApplicationController # 强制重置实训 # 前段需要按照操作过程提示 def reset_my_game - unless (current_user.admin? || current_user.id == @myshixun.user_id) + course = Course.find_by(id: params[:course_id]) + unless (current_user.admin_or_business? || current_user.id == @myshixun.user_id) || (course.present? && current_user.course_identity(course) < Course::STUDENT) tip_exception("403", "") end begin From f56574a926c594d3b0fb86925d5de606152773f9 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Wed, 18 Mar 2020 20:48:37 +0800 Subject: [PATCH 6/6] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/student_works/shixun_work_report.json.jbuilder | 1 + 1 file changed, 1 insertion(+) diff --git a/app/views/student_works/shixun_work_report.json.jbuilder b/app/views/student_works/shixun_work_report.json.jbuilder index d8ab98a3f..c6596d1ee 100644 --- a/app/views/student_works/shixun_work_report.json.jbuilder +++ b/app/views/student_works/shixun_work_report.json.jbuilder @@ -1,4 +1,5 @@ json.homework_common_id @homework.id +json.course_id @homework.course_id json.category @homework.category_info json.course_name @course.name json.work_id @work.id