diff --git a/app/controllers/homework_commons_controller.rb b/app/controllers/homework_commons_controller.rb index 8696b802a..ac3b84871 100644 --- a/app/controllers/homework_commons_controller.rb +++ b/app/controllers/homework_commons_controller.rb @@ -368,6 +368,7 @@ class HomeworkCommonsController < ApplicationController ActiveRecord::Base.transaction do begin @homework = HomeworkCommon.new(homework_params) + @homework.reference_answer = params[:reference_answer].to_s.strip @homework.homework_type = @homework_type @homework.user_id = current_user.id @homework.course_id = @course.id @@ -417,6 +418,7 @@ class HomeworkCommonsController < ApplicationController ActiveRecord::Base.transaction do begin @homework.update_attributes!(homework_params) + @homework.reference_answer = params[:reference_answer].to_s.strip if @homework.homework_type == "group" homework_detail_group = @homework.homework_detail_group @@ -1404,8 +1406,8 @@ class HomeworkCommonsController < ApplicationController end def homework_params - tip_exception("name参数不能为空") if params[:name].blank? - tip_exception("description参数不能为空") if params[:description].blank? + tip_exception("标题不能为空") if params[:name].blank? + tip_exception("内容不能为空") if params[:description].blank? params.require(:homework_common).permit(:name, :description, :reference_answer) end diff --git a/app/controllers/main_controller.rb b/app/controllers/main_controller.rb index bccc76c81..158329197 100644 --- a/app/controllers/main_controller.rb +++ b/app/controllers/main_controller.rb @@ -19,6 +19,13 @@ class MainController < ApplicationController uid_logger("main start is #{cookies[:_educoder_session]}") end - render file: 'public/react/build/index.html', :layout => false + + + if params[:path] && params[:path]&.include?("educoderh5") && params[:path].split("/").first == "educoderh5" + render file: 'public/h5build/index.html', :layout => false + else + render file: 'public/react/build/index.html', :layout => false + end + end end \ No newline at end of file diff --git a/app/controllers/shixuns_controller.rb b/app/controllers/shixuns_controller.rb index d3744fb6e..c40010be2 100644 --- a/app/controllers/shixuns_controller.rb +++ b/app/controllers/shixuns_controller.rb @@ -25,7 +25,7 @@ class ShixunsController < ApplicationController before_action :special_allowed, only: [:send_to_course, :search_user_courses] before_action :shixun_marker, only: [:new, :create] - before_action :validate_wachat_support, only: [:shixun_exec] + #before_action :validate_wachat_support, only: [:shixun_exec] skip_before_action :check_sign, only: [:download_file] ## 获取课程列表 @@ -1186,11 +1186,11 @@ private md5.hexdigest end - def validate_wachat_support - - if (params[:wechat].present? && !@shixun.is_wechat_support?) - tip_exception(-5, "..") - end - end + # def validate_wachat_support + # + # if (params[:wechat].present? && !@shixun.is_wechat_support?) + # tip_exception(-5, "..") + # end + # end end diff --git a/app/controllers/weapps/challenges_controller.rb b/app/controllers/weapps/challenges_controller.rb new file mode 100644 index 000000000..e6ba35731 --- /dev/null +++ b/app/controllers/weapps/challenges_controller.rb @@ -0,0 +1,23 @@ +class Weapps::ChallengesController < Weapps::BaseController + before_action :require_login + before_action :set_challenge + + def is_play + # 关卡有展示效果 || 选择题 || jupyter实训 || vnc || 隐藏代码窗口 || html+css实训 + play = @challenge.show_type != -1 || @challenge.st == 1 || @shixun.is_jupyter? || @shixun.vnc || + @shixun.hide_code? || (@shixun.small_mirror_name & ["Css", "Html", "Web"]).present? + if play + normal_status(-5, "该关卡暂不支持小程序") + else + render_ok + end + end + + + private + def set_challenge + @challenge = Challenge.find_by!(id: params[:id]) + @shixun = @challenge.shixun + end + +end diff --git a/app/controllers/weapps/sessions_controller.rb b/app/controllers/weapps/sessions_controller.rb index 732d0a686..2dbab7aa7 100644 --- a/app/controllers/weapps/sessions_controller.rb +++ b/app/controllers/weapps/sessions_controller.rb @@ -17,7 +17,13 @@ class Weapps::SessionsController < Weapps::BaseController # session[:wechat_user_extra].delete(:nickName) # 绑定微信号 - OpenUsers::Wechat.create!(user: user, uid: session_unionid) if user.wechat_open_user.blank? + # open_user = OpenUsers::Wechat.find_by(uid: session_unionid) + # if open_user.present? && open_user.user_id.nil? + # open_user.update!(user_id: user.id) + # els + if user.wechat_open_user.blank? + OpenUsers::Wechat.create!(user: user, uid: session_unionid) + end successful_authentication(user) end diff --git a/app/controllers/weapps/unbind_accounts_controller.rb b/app/controllers/weapps/unbind_accounts_controller.rb new file mode 100644 index 000000000..53c8d8478 --- /dev/null +++ b/app/controllers/weapps/unbind_accounts_controller.rb @@ -0,0 +1,16 @@ +class Weapps::UnbindAccountsController < Weapps::BaseController + before_action :require_login + + def show + @user = current_user + end + + def destroy + open_user = OpenUsers::Wechat.find_by!(user_id: current_user.id) + session[:unionid] = open_user.uid + open_user.destroy! + UserAction.create(action_id: current_user.id, action_type: "UnbindWechat", user_id: current_user.id, :ip => request.remote_ip) + logout_user + render_ok + end +end \ No newline at end of file diff --git a/app/helpers/homework_commons_helper.rb b/app/helpers/homework_commons_helper.rb index f962288eb..3061a6e80 100644 --- a/app/helpers/homework_commons_helper.rb +++ b/app/helpers/homework_commons_helper.rb @@ -171,10 +171,10 @@ module HomeworkCommonsHelper {status: status, time: time} end - # 作品数统计:type: 1 已提交 0 未提交 + # 作品数统计:type: 1 已提交 0 未提交 2 所有 def studentwork_count homework_common, type, member student_works = homework_common.teacher_works(member) - type == 1 ? student_works.where("work_status != 0").size : student_works.where(work_status: 0).size + type == 2 ? student_works.size : (type == 1 ? student_works.where("work_status != 0").size : student_works.where(work_status: 0).size) end # 上次查重的时间 diff --git a/app/helpers/weapps/courses_helper.rb b/app/helpers/weapps/courses_helper.rb index 32de8f253..580536ec6 100644 --- a/app/helpers/weapps/courses_helper.rb +++ b/app/helpers/weapps/courses_helper.rb @@ -1,15 +1,16 @@ module Weapps::CoursesHelper require 'chinese_pinyin' - def teacher_list teachers + def teacher_list teachers, user_course_identity data = [] teachers.each do |teacher| if teacher.user.present? teacher_user = teacher.user name = teacher_user.real_name role = teacher.role == "CREATOR" ? "管理员" : teacher.role == "PROFESSOR" ? "教师" : "助教" + member_roles = user_course_identity < Course::ASSISTANT_PROFESSOR ? teacher_user.course_role(teacher.course) : [] item = {name: name, course_member_id: teacher.id, login: teacher_user.login, user_id: teacher.user_id, role: role, - school: teacher_user.school_name, image_url: url_to_avatar(teacher_user)} + school: teacher_user.school_name, image_url: url_to_avatar(teacher_user), member_roles: member_roles} pinyin = Pinyin.t(name.strip, splitter: '') first_char = pinyin[0] letter = first_letter first_char @@ -28,15 +29,16 @@ module Weapps::CoursesHelper end - def student_list students, excellent + def student_list students, excellent, user_course_identity data = [] students.each do |student| if student.user.present? student_user = student.user name = student_user.real_name phone = excellent ? "" : student_user.hidden_phone + member_roles = user_course_identity < Course::ASSISTANT_PROFESSOR ? student_user.course_role(student.course) : [] item = {name: name, course_member_id: student.id, login: student_user.login, user_id: student.user_id, - student_id: student_user.student_id, image_url: url_to_avatar(student_user), phone: phone} + student_id: student_user.student_id, image_url: url_to_avatar(student_user), phone: phone, member_roles: member_roles} pinyin = Pinyin.t(name.strip, splitter: '') first_char = pinyin[0] letter = first_letter first_char diff --git a/app/models/homework_common.rb b/app/models/homework_common.rb index 8f084befd..de245517d 100644 --- a/app/models/homework_common.rb +++ b/app/models/homework_common.rb @@ -35,7 +35,7 @@ class HomeworkCommon < ApplicationRecord # 学生的查重情况 has_many :homework_review_results, :dependent => :destroy - validates :name, length: { maximum: 60, too_long: "不能超过60个字符" } + validates :name, presence: true, length: { maximum: 60, too_long: "不能超过60个字符" } validates :description, length: { maximum: 15000, too_long: "不能超过15000个字符" } validates :explanation, length: { maximum: 5000, too_long: "不能超过5000个字符" } validates :reference_answer, length: { maximum: 15000, too_long: "不能超过15000个字符" } diff --git a/app/models/mirror_repository.rb b/app/models/mirror_repository.rb index 96a92e5e7..315813e51 100644 --- a/app/models/mirror_repository.rb +++ b/app/models/mirror_repository.rb @@ -8,6 +8,7 @@ class MirrorRepository < ApplicationRecord scope :published_mirror, -> { where(status: [1,2,3,5]) } scope :published_main_mirror, -> { published_mirror.where(main_type: 1) } scope :published_small_mirror, -> { published_mirror.where(main_type: 0) } + scope :small_mirror, -> { where(main_type: 0) } def deletable? status != 1 && !shixun_mirror_repositories.exists? diff --git a/app/models/shixun.rb b/app/models/shixun.rb index 30c27ba94..c3c5cec78 100644 --- a/app/models/shixun.rb +++ b/app/models/shixun.rb @@ -171,7 +171,8 @@ class Shixun < ApplicationRecord # 实训对应的镜像小类别名(已选) def small_mirror_name - mirror_repositories.published_small_mirror.map(&:type_name) + names = mirror_repositories.small_mirror.map(&:type_name) + names.blank? ? [] : names end def small_mirror_id diff --git a/app/views/homework_commons/index.json.jbuilder b/app/views/homework_commons/index.json.jbuilder index a508659e8..6b34eb220 100644 --- a/app/views/homework_commons/index.json.jbuilder +++ b/app/views/homework_commons/index.json.jbuilder @@ -27,21 +27,20 @@ json.homeworks @homework_commons.each do |homework| unless curr_status[:status].include?("未发布") json.commit_count studentwork_count homework, 1, @member json.uncommit_count studentwork_count homework, 0, @member + json.all_count studentwork_count homework, 2, @member end - if @user_course_identity < Course::STUDENT - if homework.homework_type == "practice" - json.shixun_identifier homework.shixuns.take.try(:identifier) - json.shixun_status homework.shixuns.take.try(:status).to_i - end - elsif @user_course_identity == Course::STUDENT + if homework.homework_type == "practice" + json.shixun_identifier homework.shixuns.take.try(:identifier) + json.shixun_status homework.shixuns.take.try(:status).to_i + end + if @user_course_identity == Course::STUDENT if homework.homework_type == "practice" shixun = homework.shixuns.take # json.challenge_count homework.shixuns.first.try(:challenges_count).to_i current_myshixun = homework.user_work(@user.id).try(:myshixun) myshixun = current_myshixun ? current_myshixun : shixun.myshixuns.find_by(user_id: @user.id) # json.game_count current_myshixun ? current_myshixun.exec_count : 0 - json.shixun_status shixun.try(:status).to_i json.task_operation task_operation_url(myshixun, shixun) else work = homework.user_work(@user.id) diff --git a/app/views/weapps/courses/students.json.jbuilder b/app/views/weapps/courses/students.json.jbuilder index 40928a1b1..8c51393f0 100644 --- a/app/views/weapps/courses/students.json.jbuilder +++ b/app/views/weapps/courses/students.json.jbuilder @@ -1,4 +1,4 @@ -json.students student_list @students, @course.excellent +json.students student_list @students, @course.excellent, @user_course_identity json.students_count @students_count if @course_group json.course_group do diff --git a/app/views/weapps/courses/teachers.json.jbuilder b/app/views/weapps/courses/teachers.json.jbuilder index 424fd296a..684c12517 100644 --- a/app/views/weapps/courses/teachers.json.jbuilder +++ b/app/views/weapps/courses/teachers.json.jbuilder @@ -1,3 +1,3 @@ -json.teacher_list teacher_list(@teacher_list) +json.teacher_list teacher_list(@teacher_list, @user_course_identity) json.teacher_list_size @teacher_list_size json.apply_size @applications_size \ No newline at end of file diff --git a/app/views/weapps/unbind_accounts/show.json.jbuilder b/app/views/weapps/unbind_accounts/show.json.jbuilder new file mode 100644 index 000000000..c4223a021 --- /dev/null +++ b/app/views/weapps/unbind_accounts/show.json.jbuilder @@ -0,0 +1 @@ +json.user_account @user.phone.present? ? @user.phone : (@user.mail.present? ? @user.mail : @user.login) diff --git a/config/routes.rb b/config/routes.rb index 971c1859f..9eef49bfc 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1019,6 +1019,7 @@ Rails.application.routes.draw do resource :code_session, only: [:create] resource :verify, only: [:create] resource :check_account, only: [:create] + resource :unbind_accounts, only: [:show, :destroy] resources :searchs, only: [:index] resources :course_stickies, only: [:create] do @@ -1027,6 +1028,9 @@ Rails.application.routes.draw do resources :shixun_lists, only: [:index] resources :subjects, path: :paths, only: [:index, :create, :update, :edit, :show] + resources :challenges do + get :is_play, on: :member + end resources :courses, only: [:create, :update, :edit, :show] do member do diff --git a/public/compatibility.html b/public/compatibility.html index 963ff4035..be53c744f 100644 --- a/public/compatibility.html +++ b/public/compatibility.html @@ -5,9 +5,9 @@
EduCoder支持所有第三方直播平台,特别推荐:
@@ -37,9 +37,9 @@ class Live extends Component{ (简明手册)