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 - - - + + + diff --git a/public/react/public/css/edu-all.css b/public/react/public/css/edu-all.css index e505c0ddc..5700120c8 100644 --- a/public/react/public/css/edu-all.css +++ b/public/react/public/css/edu-all.css @@ -15,7 +15,7 @@ text-align: center; height: 60px; box-sizing: border-box; - min-width: 785px; + min-width: 780px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; diff --git a/public/react/src/App.js b/public/react/src/App.js index 96a4f91b0..d445d1d35 100644 --- a/public/react/src/App.js +++ b/public/react/src/App.js @@ -828,7 +828,7 @@ class App extends Component { render={ (props) => () }/> - () } diff --git a/public/react/src/AppConfig.js b/public/react/src/AppConfig.js index a3c081285..4667ebbde 100644 --- a/public/react/src/AppConfig.js +++ b/public/react/src/AppConfig.js @@ -46,7 +46,7 @@ if (isDev) { // 老师 //debugType="teacher"; // 学生 -//debugType="student"; +debugType="student"; diff --git a/public/react/src/modules/courses/Video/Live.js b/public/react/src/modules/courses/Video/Live.js index 5a808633f..d869922fb 100644 --- a/public/react/src/modules/courses/Video/Live.js +++ b/public/react/src/modules/courses/Video/Live.js @@ -10,10 +10,10 @@ import tencent from './images/tencent.png'; import WeiBaiTong from './images/WeiBaiTong.png'; import douyu from './images/douyu.jpg'; class Live extends Component{ - + render(){ const { liveData , lives , successFunc , pageSize , changePage , page } = this.props; - + return(

EduCoder支持所有第三方直播平台,特别推荐:

@@ -37,9 +37,9 @@ class Live extends Component{ (简明手册)
  • - - - +
    + +
    (简明手册)
  • @@ -51,11 +51,11 @@ class Live extends Component{ { lives.map((item,key)=>{ return( - successFunc()} > ) @@ -74,7 +74,7 @@ class Live extends Component{ //
    // //
    - } + }
    ) } diff --git a/public/react/src/modules/courses/shixunHomework/ShixunhomeWorkItem.js b/public/react/src/modules/courses/shixunHomework/ShixunhomeWorkItem.js index 5c12fe3b9..c8639e6eb 100644 --- a/public/react/src/modules/courses/shixunHomework/ShixunhomeWorkItem.js +++ b/public/react/src/modules/courses/shixunHomework/ShixunhomeWorkItem.js @@ -128,7 +128,7 @@ class ShixunhomeWorkItem extends Component{ stopPro = (event) => { event.stopPropagation() } - + editname = (name,id,event) => { this.setState({ ModalsRenametype:true, @@ -373,8 +373,8 @@ class ShixunhomeWorkItem extends Component{ {this.props.isAdmin?this.stopPro(event)} className={discussMessage&&discussMessage.shixun_status>1?this.props.isAdminOrCreator()?" newhomepagePostSettingname fr":" homepagePostSettingbox fr":" newwidthSettin fr"} style={{"right":"-2px","top":"6px","display":"block"}}> - {discussMessage&&discussMessage.shixun_status>1?实训详情: - 实训详情 + {discussMessage&&discussMessage.shixun_status>1?进入学习: + 进入学习 } @@ -387,27 +387,19 @@ class ShixunhomeWorkItem extends Component{ {this.props.isStudent===true?this.props.course_identity===5?discussMessage&&discussMessage.shixun_status>1? discussMessage.time_status<5? - {startbtn===false? - (discussMessage.task_operation[0] == '继续挑战' || discussMessage.task_operation[0] == '查看实战' ? - - {discussMessage.task_operation[0]} - - : - this.taskoperationId(discussMessage.task_operation[1])}> - {discussMessage.task_operation[0]} - ):开启中} + 进入学习 :"":"":"":"" } - { this.props.isAdmin?this.hrefjumpskip("/courses/"+this.props.match.params.coursesId+"/"+this.state.shixuntypes+"/"+discussMessage.homework_id+"/list?tab=0")} className="btn colorblue font-16 fontweight400 mr20 fr">作品详情:""} + { this.props.isAdmin?this.hrefjumpskip("/courses/"+this.props.match.params.coursesId+"/"+this.state.shixuntypes+"/"+discussMessage.homework_id+"/list?tab=0")} className="btn colorblue font-16 fontweight400 mr20 fr">作品列表:""} { - this.props.isStudent? this.hrefjumpskip("/courses/"+this.props.match.params.coursesId+"/"+this.state.shixuntypes+"/"+discussMessage.homework_id+"/list?tab=0")} className="btn colorblue font-16 fontweight400 mr20 fr mt2">作品详情:"" + this.props.isStudent? this.hrefjumpskip("/courses/"+this.props.match.params.coursesId+"/"+this.state.shixuntypes+"/"+discussMessage.homework_id+"/list?tab=0")} className="btn colorblue font-16 fontweight400 mr20 fr mt2">作品列表:"" } { this.props.isNotMember===true? this.props.discussMessage.private_icon===true?"" - :this.hrefjumpskip("/courses/"+this.props.match.params.coursesId+"/"+this.state.shixuntypes+"/"+discussMessage.homework_id+"/list?tab=0")} className="btn colorblue font-16 fontweight400 mr20 fr">作品详情:"" + :this.hrefjumpskip("/courses/"+this.props.match.params.coursesId+"/"+this.state.shixuntypes+"/"+discussMessage.homework_id+"/list?tab=0")} className="btn colorblue font-16 fontweight400 mr20 fr">作品列表:"" } @@ -440,9 +432,9 @@ class ShixunhomeWorkItem extends Component{ {
    所属目录:{discussMessage.upper_category_name}
    } } - - - + + + {/* { discussMessage.replies_count != 0 && {discussMessage.replies_count} 回复 } { discussMessage.praise_num != 0 && {discussMessage.praise_num} 点赞 } diff --git a/public/react/src/modules/paths/statics/index.js b/public/react/src/modules/paths/statics/index.js index b10809f99..849311c12 100644 --- a/public/react/src/modules/paths/statics/index.js +++ b/public/react/src/modules/paths/statics/index.js @@ -4,7 +4,7 @@ * @Github: * @Date: 2020-01-10 09:33:45 * @LastEditors : tangjiang - * @LastEditTime : 2020-01-14 17:01:32 + * @LastEditTime : 2020-02-14 17:51:48 */ import './index.scss'; import React, { useEffect } from 'react'; @@ -166,36 +166,46 @@ const App = (props) => { { title: '姓名', dataIndex: 'username', - align: 'center' + align: 'center', + width: 200 }, { title: '通关实训数', dataIndex: 'passed_myshixun_count', align: 'center', + with: 170, + render: (val) => val + '', sorter: (a, b) => a.passed_myshixun_count - b.passed_myshixun_count }, { title: '完成关卡', dataIndex: 'passed_games_count', align: 'center', + with: 170, + render: (val) => val + '', sorter: (a, b) => a.passed_games_count - b.passed_games_count }, { title: '代码行', dataIndex: 'code_line_count', align: 'center', + with: 170, + render: (val) => val + '', sorter: (a, b) => a.code_line_count - b.code_line_count }, { title: '评测次数', dataIndex: 'evaluate_count', align: 'center', + with: 170, + render: (val) => val + '', sorter: (a, b) => a.evaluate_count - b.evaluate_count }, { title: '所用时间', dataIndex: 'cost_time', align: 'center', + // with: 180, render: (text) => (text && moment(text).format('HH:mm:ss')) || '-', sorter: (a, b) => a.cost_time - b.cost_time } diff --git a/public/react/src/modules/tpm/TPMIndexHOC.js b/public/react/src/modules/tpm/TPMIndexHOC.js index 02cc82f92..00123045b 100644 --- a/public/react/src/modules/tpm/TPMIndexHOC.js +++ b/public/react/src/modules/tpm/TPMIndexHOC.js @@ -35,14 +35,14 @@ if (!window['indexHOCLoaded']) { // $('head').append($('') // .attr('href', `${_url_origin}/stylesheets/educoder/antd.min.css?1525440977`)); $('head').append($('') - .attr('href', `${_url_origin}/stylesheets/css/edu-common.css?1`)); + .attr('href', `${_url_origin}/stylesheets/css/edu-common.css?3`)); $('head').append($('') - .attr('href', `${_url_origin}/stylesheets/educoder/edu-main.css?1`)); + .attr('href', `${_url_origin}/stylesheets/educoder/edu-main.css?3`)); // index.html有加载 $('head').append($('') - .attr('href', `${_url_origin}/stylesheets/educoder/edu-all.css?1`)); + .attr('href', `${_url_origin}/stylesheets/educoder/edu-all.css?3`)); // $('head').append($('') diff --git a/public/stylesheets/educoder/edu-all.css b/public/stylesheets/educoder/edu-all.css index 72c9dde8f..368ae3738 100644 --- a/public/stylesheets/educoder/edu-all.css +++ b/public/stylesheets/educoder/edu-all.css @@ -15,7 +15,7 @@ text-align: center; height: 60px; box-sizing: border-box; - min-width: 785px; + min-width: 780px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;