diff --git a/app/controllers/accounts_controller.rb b/app/controllers/accounts_controller.rb index 2524c53d8..e62dcf6ed 100644 --- a/app/controllers/accounts_controller.rb +++ b/app/controllers/accounts_controller.rb @@ -38,7 +38,7 @@ class AccountsController < ApplicationController return normal_status(-2, "验证码已失效") if !verifi_code&.effective? end - code = generate_identifier User, 8 + code = generate_identifier User, 8, pre login = pre + code @user = User.new(admin: false, login: login, mail: email, phone: phone, type: "User") @user.password = params[:password] diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index ec3ea326c..5ba0db363 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -396,10 +396,10 @@ class ApplicationController < ActionController::Base end # 随机生成字符 - def generate_identifier(container, num) + def generate_identifier(container, num, pre='') code = DCODES.sample(num).join if container == User - while container.exists?(login: code) do + while container.exists?(login: pre+code) do code = DCODES.sample(num).join end else diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index 8a532a9ad..5c3f2e743 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -12,7 +12,7 @@ class CoursesController < ApplicationController end before_action :require_login, except: [:index, :show, :students, :teachers, :board_list, :mine, :all_course_groups, - :left_banner, :top_banner] + :left_banner, :top_banner, :informs, :online_learning] before_action :check_account, only: [:new, :create, :apply_to_join_course, :join_excellent_course] before_action :check_auth, except: [:index, :show, :students, :teachers, :board_list, :mine, :all_course_groups, :left_banner, :top_banner, :apply_to_join_course, :exit_course] @@ -26,18 +26,22 @@ class CoursesController < ApplicationController :base_info, :get_historical_courses, :create_group_by_importing_file, :attahcment_category_list,:export_member_scores_excel, :duplicate_course, :switch_to_teacher, :switch_to_assistant, :switch_to_student, :exit_course, - :informs, :update_informs, :join_excellent_course, :online_learning] + :informs, :update_informs, :join_excellent_course, :online_learning, + :update_task_position, :tasks_list] before_action :teacher_allowed, only: [:update, :destroy, :settings, :search_teacher_candidate, :transfer_to_course_group, :delete_from_course, :search_users, :add_students_by_search, :get_historical_courses, :add_teacher_popup, :add_teacher] before_action :admin_allowed, only: [:set_invite_code_halt, :set_public_or_private, :change_course_admin, - :set_course_group, :create_group_by_importing_file, :update_informs] + :set_course_group, :create_group_by_importing_file, :update_informs, + :update_task_position, :tasks_list] before_action :teacher_or_admin_allowed, only: [:graduation_group_list, :create_graduation_group, :join_graduation_group, :change_course_teacher, :export_member_scores_excel, :course_group_list, :teacher_application_review, :apply_teachers, :delete_course_teacher] before_action :validate_course_name, only: [:create, :update] before_action :find_board, only: :board_list before_action :validate_page_size, only: :mine + before_action :course_tasks, only: [:tasks_list, :update_task_position] + before_action :find_container, only: [:update_task_position] if RUBY_PLATFORM =~ /linux/ require 'simple_xlsx_reader' @@ -100,7 +104,12 @@ class CoursesController < ApplicationController # GET /courses/new def new @course = Course.new - normal_status("成功") + unless params[:subject_id].blank? + subject = Subject.find_by(id: params[:subject_id], excellent: 1) + render :json => {status: 0, course_name: "#{subject&.name}第#{subject&.courses&.count.to_i + 1}期"} + else + normal_status("成功") + end end # Get /courses/:id/settings @@ -152,7 +161,7 @@ class CoursesController < ApplicationController end rescue => e uid_logger_error(e.message) - tip_exception("课堂创建失败!") + tip_exception(e.message) raise ActiveRecord::Rollback end end @@ -685,12 +694,12 @@ class CoursesController < ApplicationController if order == 1 # REDO:Extension - @students = @students.includes(user: :user_extension).order("user_extensions.student_id") + @students = @students.includes(user: :user_extension).order("user_extensions.student_id, course_members.id") elsif order == 2 - @students = @students.includes(:course_group).order("course_groups.position") + @students = @students.includes(:course_group).order("course_groups.position, course_members.id") else # REDO:Extension - @students = @students.includes(user: :user_extension).order("user_extensions.student_id") + @students = @students.includes(user: :user_extension).order("user_extensions.student_id, course_members.id") end if course_group_id.present? @@ -918,10 +927,10 @@ class CoursesController < ApplicationController return normal_status(-1, "课堂已结束,无法加入") if course.is_end # 实名认证和职业认证的身份判断 - return normal_status(-1, "该课堂要求成员完成实名和职业认证") if course.authentication && - course.professional_certification && (!current_user.authentication || !current_user.professional_certification) - return normal_status(-1, "该课堂要求成员完成实名认证") if course.authentication && !current_user.authentication - return normal_status(-1, "该课堂要求成员完成职业认证") if course.professional_certification && !current_user.professional_certification + return normal_status(-2, "该课堂要求成员完成实名和职业认证") if course.authentication && + course.professional_certification && (!current_user.authentication && !current_user.professional_certification) + return normal_status(-2, "该课堂要求成员完成实名认证") if course.authentication && !current_user.authentication + return normal_status(-2, "该课堂要求成员完成职业认证") if course.professional_certification && !current_user.professional_certification # 身份验证 if params[:professor].blank? && params[:assistant_professor].blank? && params[:student].blank? @@ -1117,6 +1126,44 @@ class CoursesController < ApplicationController render_ok(count: count, courses: courses.select(:id, :name).as_json) end + def tasks_list + case params[:container_type] + when 'shixun_homework' + @tasks = @course.practice_homeworks + when 'common_homework' + @tasks = @course.normal_homeworks + when 'group_homework' + @tasks = @course.group_homeworks + when 'exercise' + @tasks = @course.exercises + when 'poll' + @tasks = @course.polls + when 'graduation_topic' + @tasks = @course.graduation_topics + when 'graduation_task' + @tasks = @course.graduation_tasks + when 'attachment' + @tasks = @course.attachments + else + tip_exception("请指定任务类型") + end + end + + def update_task_position + tip_exception("缺少position参数") if params[:position].blank? + unless params[:position].to_i == @task.position + if params[:position].to_i < @task.position + @tasks.where("position < #{@task.position} and position >= ?", params[:position]).update_all("position = position + 1") + else + @tasks.where("position > #{@task.position} and position <= ?", params[:position]).update_all("position = position - 1") + end + @task.update_attributes(position: params[:position]) + normal_status(0, "移动成功") + else + normal_status(-1, "位置没有变化") + end + end + private # Use callbacks to share common setup or constraints between actions. @@ -1177,6 +1224,48 @@ class CoursesController < ApplicationController end end + def course_tasks + case params[:container_type] + when 'shixun_homework' + @tasks = @course.practice_homeworks + when 'common_homework' + @tasks = @course.normal_homeworks + when 'group_homework' + @tasks = @course.group_homeworks + when 'exercise' + @tasks = @course.exercises + when 'poll' + @tasks = @course.polls + when 'graduation_topic' + @tasks = @course.graduation_topics + when 'graduation_task' + @tasks = @course.graduation_tasks + when 'attachment' + @tasks = @course.attachments + else + tip_exception("请指定任务类型") + end + end + + def find_container + case params[:container_type] + when 'shixun_homework', 'common_homework', 'group_homework' + @task = HomeworkCommon.find_by(id: params[:container_id]) + when 'exercise' + @task = Exercise.find_by(id: params[:container_id]) + when 'poll' + @task = Poll.find_by(id: params[:container_id]) + when 'graduation_topic' + @task = GraduationTopic.find_by(id: params[:container_id]) + when 'graduation_task' + @task = GraduationTask.find_by(id: params[:container_id]) + when 'attachment' + @task = Attachment.find_by(id: params[:container_id]) + else + tip_exception("container_type参数有误") + end + end + def student_act_score group_id, search sql_select = %Q{SELECT cm.*,( SELECT SUM(student_works.work_score) diff --git a/app/controllers/exercise_questions_controller.rb b/app/controllers/exercise_questions_controller.rb index 52915a8ba..75ada699d 100644 --- a/app/controllers/exercise_questions_controller.rb +++ b/app/controllers/exercise_questions_controller.rb @@ -348,7 +348,7 @@ class ExerciseQuestionsController < ApplicationController #当试卷已发布时(试卷的总状态),当标准答案修改时,如有已提交的学生,需重新计算分数. - if @exercise.exercise_status == Exercise::PUBLISHED + if @exercise.exercise_status >= Exercise::PUBLISHED ex_users_committed = @exercise.exercise_users.exercise_user_committed if ex_users_committed.size > 0 ex_users_committed.each do |ex_user| diff --git a/app/controllers/homework_commons_controller.rb b/app/controllers/homework_commons_controller.rb index 5d1733983..eb3576f24 100644 --- a/app/controllers/homework_commons_controller.rb +++ b/app/controllers/homework_commons_controller.rb @@ -37,8 +37,6 @@ class HomeworkCommonsController < ApplicationController @category = @main_category.course_second_categories.find_by(id: params[:category]) tip_exception("子目录id有误") if !@category.present? @homework_commons = @homework_commons.where(course_second_category_id: params[:category]) - elsif @homework_type == 4 - @homework_commons = @homework_commons end @all_count = @homework_commons.size diff --git a/app/controllers/shixuns_controller.rb b/app/controllers/shixuns_controller.rb index c9b56bb98..bfd386e1c 100644 --- a/app/controllers/shixuns_controller.rb +++ b/app/controllers/shixuns_controller.rb @@ -563,15 +563,15 @@ class ShixunsController < ApplicationController end # 如果该实训是金课中的实训,则将当前用户加入到当期开课的课堂 - # if StageShixun.exists?(shixun_id: @shixun.id, subject_id: Subject.where(excellent: 1)) - # subject = Subject.where(excellent: 1, id: StageShixun.where(shixun_id: @shixun.id).pluck(:subject_id)).take - # course = subject.courses.where("start_date is not null and start_date <= '#{Date.today}' and end_date is not null and end_date >= '#{Date.today}'").take - # if course.present? && !CourseMember.exists?(course_id: course.id, user_id: current_user.id) - # # 为了不影响后续操作,用create而不是create! - # CourseMember.create(course_id: course.id, user_id: current_user.id, role: 4) - # CourseAddStudentCreateWorksJob.perform_later(course.id, [current_user.id]) - # end - # end + if StageShixun.exists?(shixun_id: @shixun.id, subject_id: Subject.where(excellent: 1)) + subject = Subject.find_by(id: StageShixun.where(shixun_id: @shixun.id).pluck(:subject_id), excellent: 1) + course = subject.courses.where("start_date is not null and start_date <= '#{Date.today}' and end_date is not null and end_date >= '#{Date.today}'").take + if course.present? && !CourseMember.exists?(course_id: course.id, user_id: current_user.id) + # 为了不影响后续操作,用create而不是create! + CourseMember.create(course_id: course.id, user_id: current_user.id, role: 4) + CourseAddStudentCreateWorksJob.perform_later(course.id, [current_user.id]) + end + end ActiveRecord::Base.transaction do begin diff --git a/app/controllers/subjects_controller.rb b/app/controllers/subjects_controller.rb index 156b34f25..6c5481787 100644 --- a/app/controllers/subjects_controller.rb +++ b/app/controllers/subjects_controller.rb @@ -1,447 +1,447 @@ -class SubjectsController < ApplicationController - before_action :require_login, :check_auth, except: [:index, :show, :right_banner] - # before_action :check_auth, except: [:index] - before_action :check_account, except: [:index, :show] - before_action :find_subject, except: [:index, :create, :new, :append_to_stage] - before_action :allowed, only: [:update, :edit, :destroy, :publish, :cancel_publish, :cancel_has_publish, - :search_members, :add_subject_members, :statistics, :shixun_report, :school_report, - :up_member_position, :down_member_position] - - include ApplicationHelper - include SubjectsHelper - - def index - @tech_system = Repertoire.where(nil).order("updated_at desc") - select = params[:select] # 路径导航类型 - reorder = params[:order] || "publish_time" - search = params[:search] - - ## 分页参数 - page = params[:page] || 1 - limit = params[:limit] || 16 - offset = (page.to_i-1) * limit - - # 最热排序 - if reorder == "myshixun_count" - if select - @subjects = Subject.find_by_sql("SELECT subjects.id, subjects.user_id, subjects.name, subjects.stages_count, subjects.repertoire_id, subjects.status, - subjects.shixuns_count, subjects.excellent, sum(shixuns.myshixuns_count) AS myshixun_member_count FROM subjects join stage_shixuns - on stage_shixuns.subject_id = subjects.id join shixuns on shixuns.id = stage_shixuns.shixun_id where - subjects.hidden = 0 AND subjects.status = 2 AND subjects.name like '%#{search}%' - AND subjects.repertoire_id = #{select} GROUP BY subjects.id ORDER BY myshixun_member_count DESC") - else - @subjects = Subject.find_by_sql("SELECT subjects.id, subjects.user_id, subjects.name, subjects.stages_count, subjects.repertoire_id, subjects.status, - subjects.shixuns_count, subjects.excellent, sum(shixuns.myshixuns_count) AS myshixun_member_count FROM subjects join stage_shixuns - on stage_shixuns.subject_id = subjects.id join shixuns on shixuns.id = stage_shixuns.shixun_id where - subjects.hidden = 0 AND subjects.status = 2 AND subjects.name like '%#{search}%' - GROUP BY subjects.id ORDER BY myshixun_member_count DESC") - end - else - # 我的路径 - if reorder == "mine" - tip_exception(401, "..") unless current_user.logged? - - mine_subject_id = StageShixun.find_by_sql("select DISTINCT(subject_id) from stage_shixuns where shixun_id in - (select distinct(shixun_id) from myshixuns where user_id=#{current_user.id})").map(&:subject_id) - manage_subject_id = SubjectMember.where(user_id: current_user.id).pluck(:subject_id) - total_subject_id = (mine_subject_id + manage_subject_id).uniq - @subjects = Subject.where(id: total_subject_id) - elsif reorder == "publish_time" - @subjects = Subject.unhidden - else - @subjects = Subject.visible.unhidden - end - - # 类型 - if select - @subjects = @subjects.where(repertoire_id: select) - end - - if search.present? - @subjects = @subjects.where("name like ?", "%#{search}%") - end - - # 排序 - order_str = reorder == "publish_time" ? "status = 2 desc, publish_time asc" : "updated_at desc" - @subjects = @subjects.reorder(order_str) - end - - @total_count = @subjects.size - - if reorder != "myshixun_count" - @subjects = @subjects.page(page).per(limit).includes(:shixuns, :repertoire) - else - @subjects = @subjects[offset, limit] - subject_ids = @subjects.pluck(:id) - order_ids = subject_ids.size > 0 ? subject_ids.join(',') : -1 - @subjects = Subject.where(id: subject_ids).order("field(id,#{order_ids})").includes(:shixuns, :repertoire) - end - end - - def show - @user = current_user - @is_creator = current_user.creator_of_subject?(@subject) - @is_manager = @user.manager_of_subject?(@subject) - # 合作团队 - @shixuns = @subject.shixuns.published.pluck(:id) - @courses = @subject.courses if @subject.excellent - @members = @subject.subject_members.includes(:user) - - shixuns = @subject.shixuns.published.pluck(:id) - challenge_ids = Challenge.where(shixun_id: shixuns).pluck(:id) - # 实训路径中的所有实训标签 - @tags = ChallengeTag.where(challenge_id: challenge_ids).pluck(:name).uniq - # 用户获取的实训标签 - # @user_tags = @subject.shixuns.map(&:user_tags_name).flatten.uniq - @user_tags = user_shixun_tags challenge_ids, @user.id - @my_subject_progress = @subject.my_subject_progress - # 访问数变更 - @subject.increment!(:visits) - end - - def right_banner - @user = current_user - # 合作团队 - @members = @subject.subject_members.includes(:user) - shixuns = @subject.shixuns.published.pluck(:id) - challenge_ids = Challenge.where(shixun_id: shixuns).pluck(:id) - # 实训路径中的所有实训标签 - @tags = ChallengeTag.where(challenge_id: challenge_ids).pluck(:name).uniq - # 用户获取的实训标签 - # @user_tags = @subject.shixuns.map(&:user_tags_name).flatten.uniq - @user_tags = user_shixun_tags challenge_ids, @user.id - @my_subject_progress = @subject.my_subject_progress - end - - def new - normal_status("") - end - - def create - ActiveRecord::Base.transaction do - begin - @subject = Subject.new(subject_params) - @subject.user_id = current_user.id - @subject.save! - @subject.subject_members.create!(role: 1, user_id: current_user.id) - rescue Exception => e - uid_logger_error(e.message) - tip_exception("实训路径创建失败") - raise ActiveRecord::Rollback - end - end - end - - def edit - end - - def update - begin - @subject.update_attributes(subject_params) - rescue Exception => e - uid_logger_error(e.message) - tip_exception("实训路径更新失败") - raise ActiveRecord::Rollback - end - end - - def destroy - ActiveRecord::Base.transaction do - begin - ApplyAction.where(container_type: "ApplySubject", container_id: @subject.id).destroy_all - @subject.destroy - rescue Exception => e - uid_logger_error(e.message) - tip_exception("实训路径删除失败") - raise ActiveRecord::Rollback - end - end - end - - def choose_subject_shixun - @search = params[:search].strip if params[:search] - @type = params[:type] - # 超级管理员用户显示所有未隐藏的实训、非管理员显示合作团队用户的实训(对本单位公开且未隐藏) - if current_user.admin? - @shixuns = Shixun.select([:id, :name, :status, :myshixuns_count, :identifier, :averge_star]).where(hidden: 0) - else - none_shixun_ids = ShixunSchool.where("school_id != #{current_user.user_extension.try(:school_id).to_i}").pluck(:shixun_id) - @shixuns = Shixun.select([:id, :name, :status, :myshixuns_count, :identifier, :averge_star]).where.not(id: none_shixun_ids).where(hidden: 0) - end - - # 实训课程的所有标签 - tag_ids = @shixuns.joins(:shixun_tag_repertoires).pluck(:tag_repertoire_id).uniq - @tags = TagRepertoire.select([:id, :name]).where(id: tag_ids) - - unless params[:search].blank? - @shixuns = @shixuns.joins(:user).where("shixuns.name like ? or concat(users.lastname, users.firstname) like ?", - "%#{@search}%", "%#{@search}%").distinct - end - - unless @type.nil? || @type == "" || @type == "all" - shixun_ids = ShixunTagRepertoire.where(tag_repertoire_id: @type).pluck(:shixun_id).uniq - @shixuns = @shixuns.where(id: shixun_ids) - end - - @shixuns = @shixuns.reorder("created_at desc") - @shixuns_count = @shixuns.size - - ## 分页参数 - page = params[:page] || 1 - @shixuns = @shixuns.page(page).per(10) - - @shixuns = @shixuns.includes(:myshixuns) - end - - def append_to_stage - @shixuns = Shixun.where(id: params[:shixun_id]).order("id desc") - end - - def choose_course - course_ids = Course.find_by_sql("SELECT c.id FROM courses c, course_members m - WHERE m.course_id = c.id AND m.role in (1,2,3) - AND m.user_id=#{current_user.id} AND c.is_delete = 0 AND c.is_end = 0").map(&:id) - @courses = Course.where(id: course_ids) - @none_shixun_ids = ShixunSchool.where("school_id != #{current_user.user_extension.try(:school_id).to_i}").pluck(:shixun_id) - end - - def send_to_course - @course = Course.find_by!(id: params[:course_id]) - stages = @subject.stages.where(id: @subject.stage_shixuns.where(shixun_id: params[:shixun_ids]).pluck(:stage_id)) - - course_module = @course.course_modules.where(module_type: "shixun_homework").first - - ActiveRecord::Base.transaction do - begin - # 将实训课程下的所有已发布实训按顺序发送到课堂,同时创建与章节同名的实训作业目录 - stages.each do |stage| - category = CourseSecondCategory.where(name: stage.name, course_id: @course.id, category_type: "shixun_homework").first || - CourseSecondCategory.create!(name: stage.name, course_id: @course.id, category_type: "shixun_homework", - course_module_id: course_module.id, position: course_module.course_second_categories.count + 1) - - stage.shixuns.where(id: params[:shixun_ids], status: 2).each do |shixun| - homework = HomeworksService.new.create_homework shixun, @course, category, current_user - end - end - rescue Exception => e - uid_logger(e.message) - tip_exception(e.message) - raise ActiveRecord::Rollback - end - end - end - - def publish - apply = ApplyAction.where(container_type: "ApplySubject", container_id: @subject.id).order("created_at desc").first - if apply && apply.status == 0 - @status = 0 - else - @subject.update_attributes(status: 1) - ApplyAction.create(container_type: "ApplySubject", container_id: @subject.id, user_id: current_user.id, status: 0) - begin - status = Educoder::Sms.send(mobile: '18711011226', send_type:'publish_subject' , name: '管理员') - rescue => e - uid_logger_error("发送验证码出错: #{e}") - end - @status = 1 - end - end - - def cancel_publish - begin - apply = ApplyAction.where(container_type: "ApplySubject", container_id: @subject.id).order("created_at desc").first - if apply && apply.status == 0 - apply.update_attributes(status: 3) - apply.tidings.destroy_all - end - @subject.update_attributes(status: 0) - rescue => e - uid_logger_error(e.message) - tip_exception("撤销申请失败") - raise ActiveRecord::Rollback - end - end - - def cancel_has_publish - begin - @subject.update_attributes(:status => 0) - rescue => e - uid_logger_error(e.message) - tip_exception("撤销发布失败") - raise ActiveRecord::Rollback - end - end - - def search_members - tip_exception("搜索内容不能为空") unless params[:search] - page = params[:page] || 1 - member_ids = @subject.subject_members.map(&:user_id).join(',') - condition = "%#{params[:search].strip}%".gsub(" ","") - @users = User.where("id not in (?) and status = 1 and LOWER(concat(lastname, firstname, login, mail)) LIKE ?", member_ids, "#{condition}") - - @users = @users.page(page).per(10) - @users = @users.includes(:user_extension) - end - - def add_subject_members - # tip_exception(403, "没权限操作") if !current_user.admin? - tip_exception("user_ids 不能为空!") if params[:user_ids].blank? - memberships = params[:user_ids] - memberships.each do |member| - if SubjectMember.where(user_id: member, subject_id: @subject.id).count == 0 - user = User.find_by!(id: member) - SubjectMember.create!(user_id: member, subject_id: @subject.id, role: 2, position: @subject.subject_members.size + 1) if user.present? - end - end - end - - # 删除实训 - # DELETE: /api/subejcts/:id/delete_member - def delete_member - tip_exception(403, "没权限操作") unless current_user.manager_of_subject?(@subject) - tip_exception('用户id不能为空') if params[:user_id].blank? - user = @subject.subject_members.where(:user_id => params[:user_id], :role => 2).first - tip_exception("管理员用户不允许删除,或用户不存在") if user.blank? - ActiveRecord::Base.transaction do - begin - @subject.subject_members.where("position > #{user.position}").update_all("position = position - 1") - user.destroy - rescue Exception => e - uid_logger_error(e.message) - tip_exception(e.message) - raise ActiveRecord::Rollback - end - end - end - - # 合作者上移 - def up_member_position - tip_exception('用户id不能为空') if params[:user_id].blank? - ActiveRecord::Base.transaction do - begin - member = @subject.subject_members.where(user_id: params[:user_id]).first - # position为1时不能再往上移 - tip_exception('不能再上移了') if member.position == 1 - - up_member = @subject.subject_members.where(position: member.position - 1).first - up_member.update_attribute(:position, member.position) - member.update_attribute(:position, member.position - 1) - rescue Exception => e - uid_logger_error(e.message) - tip_exception(e.message) - raise ActiveRecord::Rollback - end - end - end - - # 合作者下移 - def down_member_position - tip_exception('用户id不能为空') if params[:user_id].blank? - ActiveRecord::Base.transaction do - begin - member = @subject.subject_members.where(user_id: params[:user_id]).first - - # position已经是最大值时不能再往下移 - tip_exception('不能再下移了') if member.position == @subject.subject_members.size - - down_member = @subject.subject_members.where(:position => member.position + 1).first - down_member.update_attribute(:position, member.position) - member.update_attribute(:position, member.position + 1) - rescue Exception => e - uid_logger_error(e.message) - tip_exception(e.message) - raise ActiveRecord::Rollback - end - end - end - - def statistics - @learn_count = @subject.member_count - shixun_ids = @subject.stage_shixuns.pluck(:shixun_id) - # 受用课堂(已经发布的实训(在此路径中的实训)作业的个数) - homework_common_id = HomeworkCommonsShixun.where(shixun_id: shixun_ids).pluck(:homework_common_id).uniq - homework_common_id = homework_common_id.blank? ? -1 : homework_common_id.join(",") - - courses = Course.find_by_sql("select c.id, c.school_id from courses c right join homework_commons hc on c.id = hc.course_id where c.is_delete = 0 - and c.school_id is not null and hc.publish_time < '#{Time.now}' and hc.id in (#{(homework_common_id)})") - course_ids = courses.pluck(:id).uniq - @course_count = course_ids.length - # 受用院校 - school_ids = courses.pluck(:school_id).uniq - @schools_count = school_ids.length - - # 采用课堂情况 - @schools = School.select([:id, :name]).where(id: school_ids) - @schools = - @schools.map do |s| - school_courses = Course.where(id: course_ids, school_id: s.id) - course_count = school_courses.count - student_count = StudentsForCourse.where(course_id: school_courses.pluck(:id)).count - homework_count = HomeworkCommon.find_by_sql("select count(*) cnt from homework_commons hc join courses c on hc.course_id = c.id - where c.school_id = #{s.id} and hc.id in(#{homework_common_id})").first.try(:cnt) - s.attributes.dup.merge({name: s.name, course_count: course_count, student_count: student_count,homework_count: homework_count}) - end - @schools = @schools.sort{|x,y| y['homework_count'] <=> x['homework_count']} - @school_total_count = @schools.size - - page = params[:page] || 1 - @schools = @schools[(page.to_i-1)*10, 10] - - # TODO: 这个可以异步加载,让页面刷新完成后再加载图形数据 - # 章节使用情况 - @stage_user_info = [] - @sum = 0 #总数 - @subject.stages.includes(:stage_shixuns).each do |stage| - shixun_ids = stage.stage_shixuns.pluck(:shixun_id) - if shixun_ids.present? - homework_common_id = HomeworkCommonsShixun.where(shixun_id: shixun_ids).pluck(:homework_common_id).uniq - if homework_common_id.present? - publish_homework = HomeworkDetailManual.where("homework_common_id in(?) and comment_status > 0", homework_common_id.join(",")).pluck(:homework_common_id) - use_count = publish_homework.present? ? HomeworkCommon.find_by_sql("select count(*) cnt from homework_commons hc join courses c on hc.course_id = c.id - where hc.id in(#{publish_homework.join(",")}) and c.school_id is not null").first.try(:cnt) : 0 - @sum += use_count - else - @sum += 0 - use_count = 0 - end - @stage_user_info << use_count - else - @sum += 0 - @stage_user_info << 0 - end - end - end - - def shixun_report - - end - - def school_report - @schools = School.find_by_sql("select count(ms.id) ue_count, s.id, s.name school_name from user_extensions ue, - myshixuns ms, schools s where ue.user_id = ms.user_id and ms.shixun_id in (select shixun_id from - stage_shixuns where subject_id = '#{@subject.id}') and s.id = ue.school_id group by ue.school_id - order by ue_count desc limit 10") - end - - private - def subject_params - tip_exception("实训路径名称不能为空") if params[:name].blank? - tip_exception("实训路径简介不能为空") if params[:description].blank? - tip_exception("实训路径学习须知不能为空") if params[:learning_notes].blank? - params.require(:subject).permit(:name, :description, :learning_notes) - end - - def find_subject - @subject = Subject.find_by!(id: params[:id]) - - unless @subject.status == 2 || current_user.manager_of_subject?(@subject) - tip_exception("403", "") - end - end - - def allowed - unless current_user.manager_of_subject?(@subject) - tip_exception("403", "") - end - end -end +class SubjectsController < ApplicationController + before_action :require_login, :check_auth, except: [:index, :show, :right_banner] + # before_action :check_auth, except: [:index] + before_action :check_account, except: [:index, :show, :right_banner] + before_action :find_subject, except: [:index, :create, :new, :append_to_stage] + before_action :allowed, only: [:update, :edit, :destroy, :publish, :cancel_publish, :cancel_has_publish, + :search_members, :add_subject_members, :statistics, :shixun_report, :school_report, + :up_member_position, :down_member_position] + + include ApplicationHelper + include SubjectsHelper + + def index + @tech_system = Repertoire.where(nil).order("updated_at desc") + select = params[:select] # 路径导航类型 + reorder = params[:order] || "publish_time" + search = params[:search] + + ## 分页参数 + page = params[:page] || 1 + limit = params[:limit] || 16 + offset = (page.to_i-1) * limit + + # 最热排序 + if reorder == "myshixun_count" + if select + @subjects = Subject.find_by_sql("SELECT subjects.id, subjects.user_id, subjects.name, subjects.stages_count, subjects.repertoire_id, subjects.status, + subjects.shixuns_count, subjects.excellent, sum(shixuns.myshixuns_count) AS myshixun_member_count FROM subjects join stage_shixuns + on stage_shixuns.subject_id = subjects.id join shixuns on shixuns.id = stage_shixuns.shixun_id where + subjects.hidden = 0 AND subjects.status = 2 AND subjects.name like '%#{search}%' + AND subjects.repertoire_id = #{select} GROUP BY subjects.id ORDER BY myshixun_member_count DESC") + else + @subjects = Subject.find_by_sql("SELECT subjects.id, subjects.user_id, subjects.name, subjects.stages_count, subjects.repertoire_id, subjects.status, + subjects.shixuns_count, subjects.excellent, sum(shixuns.myshixuns_count) AS myshixun_member_count FROM subjects join stage_shixuns + on stage_shixuns.subject_id = subjects.id join shixuns on shixuns.id = stage_shixuns.shixun_id where + subjects.hidden = 0 AND subjects.status = 2 AND subjects.name like '%#{search}%' + GROUP BY subjects.id ORDER BY myshixun_member_count DESC") + end + else + # 我的路径 + if reorder == "mine" + tip_exception(401, "..") unless current_user.logged? + + mine_subject_id = StageShixun.find_by_sql("select DISTINCT(subject_id) from stage_shixuns where shixun_id in + (select distinct(shixun_id) from myshixuns where user_id=#{current_user.id})").map(&:subject_id) + manage_subject_id = SubjectMember.where(user_id: current_user.id).pluck(:subject_id) + total_subject_id = (mine_subject_id + manage_subject_id).uniq + @subjects = Subject.where(id: total_subject_id) + elsif reorder == "publish_time" + @subjects = Subject.unhidden + else + @subjects = Subject.visible.unhidden + end + + # 类型 + if select + @subjects = @subjects.where(repertoire_id: select) + end + + if search.present? + @subjects = @subjects.where("name like ?", "%#{search}%") + end + + # 排序 + order_str = reorder == "publish_time" ? "status = 2 desc, publish_time asc" : "updated_at desc" + @subjects = @subjects.reorder(order_str) + end + + @total_count = @subjects.size + + if reorder != "myshixun_count" + @subjects = @subjects.page(page).per(limit).includes(:shixuns, :repertoire) + else + @subjects = @subjects[offset, limit] + subject_ids = @subjects.pluck(:id) + order_ids = subject_ids.size > 0 ? subject_ids.join(',') : -1 + @subjects = Subject.where(id: subject_ids).order("field(id,#{order_ids})").includes(:shixuns, :repertoire) + end + end + + def show + @user = current_user + @is_creator = current_user.creator_of_subject?(@subject) + @is_manager = @user.manager_of_subject?(@subject) + # 合作团队 + @shixuns = @subject.shixuns.published.pluck(:id) + @courses = @subject.courses if @subject.excellent + @members = @subject.subject_members.includes(:user) + + shixuns = @subject.shixuns.published.pluck(:id) + challenge_ids = Challenge.where(shixun_id: shixuns).pluck(:id) + # 实训路径中的所有实训标签 + @tags = ChallengeTag.where(challenge_id: challenge_ids).pluck(:name).uniq + # 用户获取的实训标签 + # @user_tags = @subject.shixuns.map(&:user_tags_name).flatten.uniq + @user_tags = user_shixun_tags challenge_ids, @user.id + @my_subject_progress = @subject.my_subject_progress + # 访问数变更 + @subject.increment!(:visits) + end + + def right_banner + @user = current_user + # 合作团队 + @members = @subject.subject_members.includes(:user) + shixuns = @subject.shixuns.published.pluck(:id) + challenge_ids = Challenge.where(shixun_id: shixuns).pluck(:id) + # 实训路径中的所有实训标签 + @tags = ChallengeTag.where(challenge_id: challenge_ids).pluck(:name).uniq + # 用户获取的实训标签 + # @user_tags = @subject.shixuns.map(&:user_tags_name).flatten.uniq + @user_tags = user_shixun_tags challenge_ids, @user.id + @my_subject_progress = @subject.my_subject_progress + end + + def new + normal_status("") + end + + def create + ActiveRecord::Base.transaction do + begin + @subject = Subject.new(subject_params) + @subject.user_id = current_user.id + @subject.save! + @subject.subject_members.create!(role: 1, user_id: current_user.id) + rescue Exception => e + uid_logger_error(e.message) + tip_exception("实训路径创建失败") + raise ActiveRecord::Rollback + end + end + end + + def edit + end + + def update + begin + @subject.update_attributes(subject_params) + rescue Exception => e + uid_logger_error(e.message) + tip_exception("实训路径更新失败") + raise ActiveRecord::Rollback + end + end + + def destroy + ActiveRecord::Base.transaction do + begin + ApplyAction.where(container_type: "ApplySubject", container_id: @subject.id).destroy_all + @subject.destroy + rescue Exception => e + uid_logger_error(e.message) + tip_exception("实训路径删除失败") + raise ActiveRecord::Rollback + end + end + end + + def choose_subject_shixun + @search = params[:search].strip if params[:search] + @type = params[:type] + # 超级管理员用户显示所有未隐藏的实训、非管理员显示合作团队用户的实训(对本单位公开且未隐藏) + if current_user.admin? + @shixuns = Shixun.select([:id, :name, :status, :myshixuns_count, :identifier, :averge_star]).where(hidden: 0) + else + none_shixun_ids = ShixunSchool.where("school_id != #{current_user.user_extension.try(:school_id).to_i}").pluck(:shixun_id) + @shixuns = Shixun.select([:id, :name, :status, :myshixuns_count, :identifier, :averge_star]).where.not(id: none_shixun_ids).where(hidden: 0) + end + + # 实训课程的所有标签 + tag_ids = @shixuns.joins(:shixun_tag_repertoires).pluck(:tag_repertoire_id).uniq + @tags = TagRepertoire.select([:id, :name]).where(id: tag_ids) + + unless params[:search].blank? + @shixuns = @shixuns.joins(:user).where("shixuns.name like ? or concat(users.lastname, users.firstname) like ?", + "%#{@search}%", "%#{@search}%").distinct + end + + unless @type.nil? || @type == "" || @type == "all" + shixun_ids = ShixunTagRepertoire.where(tag_repertoire_id: @type).pluck(:shixun_id).uniq + @shixuns = @shixuns.where(id: shixun_ids) + end + + @shixuns = @shixuns.reorder("created_at desc") + @shixuns_count = @shixuns.size + + ## 分页参数 + page = params[:page] || 1 + @shixuns = @shixuns.page(page).per(10) + + @shixuns = @shixuns.includes(:myshixuns) + end + + def append_to_stage + @shixuns = Shixun.where(id: params[:shixun_id]).order("id desc") + end + + def choose_course + course_ids = Course.find_by_sql("SELECT c.id FROM courses c, course_members m + WHERE m.course_id = c.id AND m.role in (1,2,3) + AND m.user_id=#{current_user.id} AND c.is_delete = 0 AND c.is_end = 0").map(&:id) + @courses = Course.where(id: course_ids) + @none_shixun_ids = ShixunSchool.where("school_id != #{current_user.user_extension.try(:school_id).to_i}").pluck(:shixun_id) + end + + def send_to_course + @course = Course.find_by!(id: params[:course_id]) + stages = @subject.stages.where(id: @subject.stage_shixuns.where(shixun_id: params[:shixun_ids]).pluck(:stage_id)) + + course_module = @course.course_modules.where(module_type: "shixun_homework").first + + ActiveRecord::Base.transaction do + begin + # 将实训课程下的所有已发布实训按顺序发送到课堂,同时创建与章节同名的实训作业目录 + stages.each do |stage| + category = CourseSecondCategory.where(name: stage.name, course_id: @course.id, category_type: "shixun_homework").first || + CourseSecondCategory.create!(name: stage.name, course_id: @course.id, category_type: "shixun_homework", + course_module_id: course_module.id, position: course_module.course_second_categories.count + 1) + + stage.shixuns.where(id: params[:shixun_ids], status: 2).each do |shixun| + homework = HomeworksService.new.create_homework shixun, @course, category, current_user + end + end + rescue Exception => e + uid_logger(e.message) + tip_exception(e.message) + raise ActiveRecord::Rollback + end + end + end + + def publish + apply = ApplyAction.where(container_type: "ApplySubject", container_id: @subject.id).order("created_at desc").first + if apply && apply.status == 0 + @status = 0 + else + @subject.update_attributes(status: 1) + ApplyAction.create(container_type: "ApplySubject", container_id: @subject.id, user_id: current_user.id, status: 0) + begin + status = Educoder::Sms.send(mobile: '18711011226', send_type:'publish_subject' , name: '管理员') + rescue => e + uid_logger_error("发送验证码出错: #{e}") + end + @status = 1 + end + end + + def cancel_publish + begin + apply = ApplyAction.where(container_type: "ApplySubject", container_id: @subject.id).order("created_at desc").first + if apply && apply.status == 0 + apply.update_attributes(status: 3) + apply.tidings.destroy_all + end + @subject.update_attributes(status: 0) + rescue => e + uid_logger_error(e.message) + tip_exception("撤销申请失败") + raise ActiveRecord::Rollback + end + end + + def cancel_has_publish + begin + @subject.update_attributes(:status => 0) + rescue => e + uid_logger_error(e.message) + tip_exception("撤销发布失败") + raise ActiveRecord::Rollback + end + end + + def search_members + tip_exception("搜索内容不能为空") unless params[:search] + page = params[:page] || 1 + member_ids = @subject.subject_members.map(&:user_id).join(',') + condition = "%#{params[:search].strip}%".gsub(" ","") + @users = User.where("id not in (?) and status = 1 and LOWER(concat(lastname, firstname, login, mail)) LIKE ?", member_ids, "#{condition}") + + @users = @users.page(page).per(10) + @users = @users.includes(:user_extension) + end + + def add_subject_members + # tip_exception(403, "没权限操作") if !current_user.admin? + tip_exception("user_ids 不能为空!") if params[:user_ids].blank? + memberships = params[:user_ids] + memberships.each do |member| + if SubjectMember.where(user_id: member, subject_id: @subject.id).count == 0 + user = User.find_by!(id: member) + SubjectMember.create!(user_id: member, subject_id: @subject.id, role: 2, position: @subject.subject_members.size + 1) if user.present? + end + end + end + + # 删除实训 + # DELETE: /api/subejcts/:id/delete_member + def delete_member + tip_exception(403, "没权限操作") unless current_user.manager_of_subject?(@subject) + tip_exception('用户id不能为空') if params[:user_id].blank? + user = @subject.subject_members.where(:user_id => params[:user_id], :role => 2).first + tip_exception("管理员用户不允许删除,或用户不存在") if user.blank? + ActiveRecord::Base.transaction do + begin + @subject.subject_members.where("position > #{user.position}").update_all("position = position - 1") + user.destroy + rescue Exception => e + uid_logger_error(e.message) + tip_exception(e.message) + raise ActiveRecord::Rollback + end + end + end + + # 合作者上移 + def up_member_position + tip_exception('用户id不能为空') if params[:user_id].blank? + ActiveRecord::Base.transaction do + begin + member = @subject.subject_members.where(user_id: params[:user_id]).first + # position为1时不能再往上移 + tip_exception('不能再上移了') if member.position == 1 + + up_member = @subject.subject_members.where(position: member.position - 1).first + up_member.update_attribute(:position, member.position) + member.update_attribute(:position, member.position - 1) + rescue Exception => e + uid_logger_error(e.message) + tip_exception(e.message) + raise ActiveRecord::Rollback + end + end + end + + # 合作者下移 + def down_member_position + tip_exception('用户id不能为空') if params[:user_id].blank? + ActiveRecord::Base.transaction do + begin + member = @subject.subject_members.where(user_id: params[:user_id]).first + + # position已经是最大值时不能再往下移 + tip_exception('不能再下移了') if member.position == @subject.subject_members.size + + down_member = @subject.subject_members.where(:position => member.position + 1).first + down_member.update_attribute(:position, member.position) + member.update_attribute(:position, member.position + 1) + rescue Exception => e + uid_logger_error(e.message) + tip_exception(e.message) + raise ActiveRecord::Rollback + end + end + end + + def statistics + @learn_count = @subject.member_count + shixun_ids = @subject.stage_shixuns.pluck(:shixun_id) + # 受用课堂(已经发布的实训(在此路径中的实训)作业的个数) + homework_common_id = HomeworkCommonsShixun.where(shixun_id: shixun_ids).pluck(:homework_common_id).uniq + homework_common_id = homework_common_id.blank? ? -1 : homework_common_id.join(",") + + courses = Course.find_by_sql("select c.id, c.school_id from courses c right join homework_commons hc on c.id = hc.course_id where c.is_delete = 0 + and c.school_id is not null and hc.publish_time < '#{Time.now}' and hc.id in (#{(homework_common_id)})") + course_ids = courses.pluck(:id).uniq + @course_count = course_ids.length + # 受用院校 + school_ids = courses.pluck(:school_id).uniq + @schools_count = school_ids.length + + # 采用课堂情况 + @schools = School.select([:id, :name]).where(id: school_ids) + @schools = + @schools.map do |s| + school_courses = Course.where(id: course_ids, school_id: s.id) + course_count = school_courses.count + student_count = StudentsForCourse.where(course_id: school_courses.pluck(:id)).count + homework_count = HomeworkCommon.find_by_sql("select count(*) cnt from homework_commons hc join courses c on hc.course_id = c.id + where c.school_id = #{s.id} and hc.id in(#{homework_common_id})").first.try(:cnt) + s.attributes.dup.merge({name: s.name, course_count: course_count, student_count: student_count,homework_count: homework_count}) + end + @schools = @schools.sort{|x,y| y['homework_count'] <=> x['homework_count']} + @school_total_count = @schools.size + + page = params[:page] || 1 + @schools = @schools[(page.to_i-1)*10, 10] + + # TODO: 这个可以异步加载,让页面刷新完成后再加载图形数据 + # 章节使用情况 + @stage_user_info = [] + @sum = 0 #总数 + @subject.stages.includes(:stage_shixuns).each do |stage| + shixun_ids = stage.stage_shixuns.pluck(:shixun_id) + if shixun_ids.present? + homework_common_id = HomeworkCommonsShixun.where(shixun_id: shixun_ids).pluck(:homework_common_id).uniq + if homework_common_id.present? + publish_homework = HomeworkDetailManual.where("homework_common_id in(?) and comment_status > 0", homework_common_id.join(",")).pluck(:homework_common_id) + use_count = publish_homework.present? ? HomeworkCommon.find_by_sql("select count(*) cnt from homework_commons hc join courses c on hc.course_id = c.id + where hc.id in(#{publish_homework.join(",")}) and c.school_id is not null").first.try(:cnt) : 0 + @sum += use_count + else + @sum += 0 + use_count = 0 + end + @stage_user_info << use_count + else + @sum += 0 + @stage_user_info << 0 + end + end + end + + def shixun_report + + end + + def school_report + @schools = School.find_by_sql("select count(ms.id) ue_count, s.id, s.name school_name from user_extensions ue, + myshixuns ms, schools s where ue.user_id = ms.user_id and ms.shixun_id in (select shixun_id from + stage_shixuns where subject_id = '#{@subject.id}') and s.id = ue.school_id group by ue.school_id + order by ue_count desc limit 10") + end + + private + def subject_params + tip_exception("实训路径名称不能为空") if params[:name].blank? + tip_exception("实训路径简介不能为空") if params[:description].blank? + tip_exception("实训路径学习须知不能为空") if params[:learning_notes].blank? + params.require(:subject).permit(:name, :description, :learning_notes) + end + + def find_subject + @subject = Subject.find_by!(id: params[:id]) + + unless @subject.status == 2 || current_user.manager_of_subject?(@subject) + tip_exception("403", "") + end + end + + def allowed + unless current_user.manager_of_subject?(@subject) + tip_exception("403", "") + end + end +end diff --git a/app/helpers/exercises_helper.rb b/app/helpers/exercises_helper.rb index ace9e062e..baf594a42 100644 --- a/app/helpers/exercises_helper.rb +++ b/app/helpers/exercises_helper.rb @@ -403,6 +403,12 @@ module ExercisesHelper end user_answer_content = answer_choice_array.sort standard_answer = q.exercise_standard_answers.pluck(:exercise_choice_id).sort #该问题的标准答案,可能有多个 + + #TODO: 旧版多选题的标准答案是放在一个里面的,新版又做成了一个题有多个标准答案(exercise_choice_id存放的是标准答案的位置..) + if q.question_type == 1 && standard_answer.size == 1 + standard_answer = standard_answer.first.to_s.split("").map(&:to_i) + end + if user_answer_content == standard_answer #答案一致,多选或单选才给分,答案不对不给分 if standard_answer.size > 0 q_score_1 = q.question_score diff --git a/app/models/course.rb b/app/models/course.rb index b7bea6ec0..baed1efe6 100644 --- a/app/models/course.rb +++ b/app/models/course.rb @@ -32,7 +32,12 @@ class Course < ApplicationRecord has_many :teacher_course_members, -> { teachers_and_admin }, class_name: 'CourseMember' has_many :teacher_users, through: :teacher_course_members, source: :user has_many :course_messages, dependent: :destroy + has_many :homework_commons, dependent: :destroy + has_many :normal_homeworks, -> { normals }, class_name: 'HomeworkCommon' + has_many :group_homeworks, -> { groups }, class_name: 'HomeworkCommon' + has_many :practice_homeworks, -> { practices }, class_name: 'HomeworkCommon' + has_many :homework_group_settings has_many :graduation_works, dependent: :destroy diff --git a/app/models/homework_common.rb b/app/models/homework_common.rb index f198a7143..332aff045 100644 --- a/app/models/homework_common.rb +++ b/app/models/homework_common.rb @@ -12,6 +12,7 @@ class HomeworkCommon < ApplicationRecord belongs_to :course, counter_cache: true belongs_to :homework_bank, optional: true + belongs_to :user has_many :homework_challenge_settings, dependent: :destroy has_one :homework_commons_shixun, dependent: :destroy @@ -48,6 +49,9 @@ class HomeworkCommon < ApplicationRecord scope :search_homework_type, lambda {|num| where(homework_type:num)} scope :unified_setting, -> {where("unified_setting = ? ", 1)} + scope :normals, -> {where(homework_type: %i[normal]).order("position desc")} + scope :groups, -> {where(homework_type: %i[group]).order("position desc")} + scope :practices, -> {where(homework_type: %i[practice]).order("position desc")} # 是否显示参考答案 def view_answer identity, user_id diff --git a/app/models/subject.rb b/app/models/subject.rb index 113460375..b8d6eef8b 100644 --- a/app/models/subject.rb +++ b/app/models/subject.rb @@ -19,9 +19,9 @@ class Subject < ApplicationRecord has_many :stages, -> { order("stages.position ASC") }, dependent: :destroy # 开放课堂 - has_many :courses, -> { order("courses.id ASC") } + has_many :courses, -> { where("is_delete = 0").order("courses.id ASC") } - validates :name, length: { maximum: 40 } + validates :name, length: { maximum: 60 } validates :description, length: { maximum: 5000 } validates :learning_notes, length: { maximum: 500 } diff --git a/app/services/homeworks_service.rb b/app/services/homeworks_service.rb index ab149403d..a21614efc 100644 --- a/app/services/homeworks_service.rb +++ b/app/services/homeworks_service.rb @@ -328,7 +328,14 @@ class HomeworksService work.late_penalty = work.work_status == 2 ? homework.late_penalty : 0 work.commit_time = myshixun.created_at > setting_time.publish_time ? setting_time.publish_time : myshixun.created_at work.myshixun_id = myshixun.id - work.update_time = myshixun.updated_at + work.update_time = if myshixun_endtime.present? && myshixun_endtime <= homework_end_or_late_time + myshixun_endtime + elsif myshixun.updated_at > homework_end_or_late_time + last_pass_time = games.select{|game| game.status == 2 && game.end_time < homework_end_or_late_time}.map(&:end_time).max + last_pass_time.present? ? last_pass_time : myshixun.created_at + else + myshixun.updated_at + end work.final_score = final_score score = work.final_score + work.eff_score - work.late_penalty diff --git a/app/views/courses/tasks_list.json.jbuilder b/app/views/courses/tasks_list.json.jbuilder new file mode 100644 index 000000000..29de925a6 --- /dev/null +++ b/app/views/courses/tasks_list.json.jbuilder @@ -0,0 +1,7 @@ +json.tasks @tasks.each do |task| + json.user_name task.user.real_name + json.task_id task.id + json.task_name task.name + json.category task.course_second_category&.name + json.position task.position +end \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index 4e7b19687..80c4d4237 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -352,6 +352,8 @@ Rails.application.routes.draw do post 'update_informs' get 'online_learning' post 'join_excellent_course' + get 'tasks_list' + post 'update_task_position' end collection do diff --git a/db/migrate/20190820021047_migrate_course_task_position.rb b/db/migrate/20190820021047_migrate_course_task_position.rb new file mode 100644 index 000000000..cf1b633bd --- /dev/null +++ b/db/migrate/20190820021047_migrate_course_task_position.rb @@ -0,0 +1,13 @@ +class MigrateCourseTaskPosition < ActiveRecord::Migration[5.2] + def change + add_column :homework_commons, :position, :integer, :default => 0 + + Course.find_each do |course| + puts course.id + course.practice_homeworks.order("IF(ISNULL(homework_commons.publish_time),0,1), homework_commons.publish_time DESC, + homework_commons.created_at DESC").reverse.each_with_index do |homework, index| + homework.update_columns(position: index + 1) + end + end + end +end diff --git a/db/migrate/20190820102040_change_exercise_1930_position.rb b/db/migrate/20190820102040_change_exercise_1930_position.rb new file mode 100644 index 000000000..acf99b9e5 --- /dev/null +++ b/db/migrate/20190820102040_change_exercise_1930_position.rb @@ -0,0 +1,29 @@ +class ChangeExercise1930Position < ActiveRecord::Migration[5.2] + def change + exs = Exercise.all.includes(:exercise_questions) + exs.each do |ex| + ex_questions = ex&.exercise_questions&.select(:id,:question_number,:exercise_id)&.order("question_number ASC") #试卷的位置迁移 + if ex_questions.present? + ex_questions.each_with_index do |q,index| + puts index + q_num = index + 1 + if q.question_number.to_i != q_num + q.update_attributes(question_number: q_num) + end + end + end + + ex_q_bank = ex&.exercise_bank&.exercise_bank_questions&.select(:id,:question_number,:exercise_bank_id,:shixun_id)&.order("question_number ASC") #试卷的习题库位置迁移 + if ex_q_bank.present? + ex_q_bank.each_with_index do |q,index| + puts index + q_num_1 = index + 1 + if q.question_number.to_i != q_num_1 + q.update_attributes(question_number: q_num_1) + end + end + end + end + + end +end diff --git a/lib/tasks/excellent_course_exercise.rake b/lib/tasks/excellent_course_exercise.rake index d337fbd73..0d8875806 100644 --- a/lib/tasks/excellent_course_exercise.rake +++ b/lib/tasks/excellent_course_exercise.rake @@ -103,6 +103,13 @@ namespace :excellent_course_exercise do end user_answer_content = answer_choice_array.sort standard_answer = q.exercise_standard_answers.pluck(:exercise_choice_id).sort #该问题的标准答案,可能有多个 + + #TODO: 旧版多选题的标准答案是放在一个里面的,新版又做成了一个题有多个标准答案(exercise_choice_id存放的是标准答案的位置..) + + if q.question_type == 1 && standard_answer.size == 1 + standard_answer = standard_answer.first.to_s.split("").map(&:to_i) + end + if user_answer_content == standard_answer #答案一致,多选或单选才给分,答案不对不给分 if standard_answer.size > 0 q_score_1 = q.question_score diff --git a/lib/tasks/user.rake b/lib/tasks/user.rake index 7e2cd2c57..144876009 100644 --- a/lib/tasks/user.rake +++ b/lib/tasks/user.rake @@ -43,12 +43,18 @@ namespace :sync do is_test: true } user = User.create!(edit_params) - puts "aa" + user.password = "edu12345678" + user.save! UserExtension.create!(user_id: user.id, school_id: 117) puts i end end + task :password => :environment do + + end + + # 随机生成字符 def generate_identifier(container, num) code = DCODES.sample(num).join diff --git a/public/react/public/css/edu-all.css b/public/react/public/css/edu-all.css index 3b96cbf7f..97b5d753a 100644 --- a/public/react/public/css/edu-all.css +++ b/public/react/public/css/edu-all.css @@ -112,10 +112,26 @@ em.vertical-line{display: inline-block;width: 2px;background: #999;height: 10px} .smallSquare:nth-child(3n+0){margin-right: 0px;} .partimg{height: 180px;width: 100%;border-radius: 6px 6px 0px 0px;} /*块状列表上面的绿色标签*/ -.tag-green{position: absolute;left: 0px;top:20px;} -.tag-green .tag-name{display: block;width: auto;background-image: url("/images/educoder/tag1.png");background-size: 100% 100%;padding: 0px 8px;color: #fff;float: left;} -.tag-orange{position: absolute;right: 0px;top:20px;} -.tag-orange .tag-name{display: block;width: auto;background-color:#FF6800;background-size: 100% 100%;padding: 0px 8px;color: #fff;float: left;} +.tag-green{ + position: absolute; + left: 10px; + bottom: 90px;} +.tag-green .tag-name{display: block;width: auto; + /*background-image: url("/images/educoder/tag1.png");*/ + background: #000000; + border: 1px solid #fff; + border-radius: 3px; + font-size: 14px; + opacity: 0.56; + background-size: 100% 100%;padding: 0px 8px;color: #fff;float: left;} +.tag-orange{position: absolute;right: 0px;top:12px;} +.tag-orange .tag-name{display: block;width: auto;background-color:#FF6800; + background-size: 100% 100%;padding: 0px 8px;color: #fff;float: left; + height: 28px; + line-height: 28px; + border-top-left-radius: 4px; + border-bottom-left-radius: 4px; +} /*发送至弹框里的下拉框*/ .downSelectOption{position: relative;height: 35px;} .downSelectOption .showOption{background-color: #F4F4F4;border: 1px solid #EAEAEA;width: 100%;padding: 5px 40px 5px 5px;outline: none;height: 100%;box-sizing: border-box;} @@ -3423,4 +3439,8 @@ a.singlepublishtwo{ .detail_for_paragraph p{ white-space: pre-wrap; +} + +.ant-tooltip{ + max-width: 100% !important; } \ No newline at end of file diff --git a/public/react/scripts/build.js b/public/react/scripts/build.js index c18479299..b2bac24ec 100644 --- a/public/react/scripts/build.js +++ b/public/react/scripts/build.js @@ -198,6 +198,8 @@ function generateNewIndexJsp() { var result = data.replace('/js/js_min_all.js', `${cdnHost}/react/build/js/js_min_all.js?v=${newVersion}`) // .replace('/js/js_min_all_2.js', `${cdnHost}/react/build/js/js_min_all_2.js?v=${newVersion}`) + // ${cdnHost} 加了cdn后,这个文件里的字体文件加载会有跨域的报错 ../fonts/fontawesome-webfont.eot + // TODO tpi 评测结果关闭也使用了fontawesome .replace('/css/css_min_all.css', `${cdnHost}/react/build/css/css_min_all.css?v=${newVersion}`) .replace('/css/iconfont.css', `${cdnHost}/react/build/css/iconfont.css?v=${newVersion}`) .replace(/\/js\/create_kindeditor.js/g, `${cdnHost}/react/build/js/create_kindeditor.js?v=${newVersion}`) diff --git a/public/react/src/App.js b/public/react/src/App.js index 5b57428c3..9621fdc18 100644 --- a/public/react/src/App.js +++ b/public/react/src/App.js @@ -306,7 +306,7 @@ class App extends Component { - {/**/} + diff --git a/public/react/src/index.css b/public/react/src/index.css index 7c46797a8..ee89ffc11 100644 --- a/public/react/src/index.css +++ b/public/react/src/index.css @@ -37,4 +37,4 @@ body { .MuiModal-root-15{ z-index: 1000 !important; -} \ No newline at end of file +} diff --git a/public/react/src/modules/courses/Index.js b/public/react/src/modules/courses/Index.js index 1430b8c5d..01117b4f8 100644 --- a/public/react/src/modules/courses/Index.js +++ b/public/react/src/modules/courses/Index.js @@ -828,7 +828,7 @@ class CoursesIndex extends Component{ {/*新建精品课堂*/} {/*coursesId 课堂id */} {/*id 是否是私有或者公有*/} - () } diff --git a/public/react/src/modules/courses/busyWork/CommonWorkAnswer.js b/public/react/src/modules/courses/busyWork/CommonWorkAnswer.js index d7614459c..ccaa3c04b 100644 --- a/public/react/src/modules/courses/busyWork/CommonWorkAnswer.js +++ b/public/react/src/modules/courses/busyWork/CommonWorkAnswer.js @@ -56,7 +56,11 @@ class CommonWorkAnswer extends Component{ } componentDidMount() { this.fetchData() + try { + this.props.triggerRef(this); + }catch (e) { + } on('commonwork_fetch_all', this.fetchAllListener) } componentWillUnmount() { diff --git a/public/react/src/modules/courses/busyWork/CommonWorkDetailIndex.js b/public/react/src/modules/courses/busyWork/CommonWorkDetailIndex.js index 4d82f4182..8c77aaab2 100644 --- a/public/react/src/modules/courses/busyWork/CommonWorkDetailIndex.js +++ b/public/react/src/modules/courses/busyWork/CommonWorkDetailIndex.js @@ -17,7 +17,7 @@ import PublishRightnow from './PublishRightnow' import '../css/Courses.css' import CBreadcrumb from '../common/CBreadcrumb' import DownloadMessageysl from "../../modals/DownloadMessageysl"; - +import ConnectProject from './ConnectProject' import { Spin } from 'antd' //引入对应跳转的组件 @@ -158,6 +158,30 @@ class CommonWorkDetailIndex extends Component{ } bindRef = ref => { this.child = ref }; + // 关联项目 + openConnectionProject = (work) => { + this.refs['connectProject'].openConnectionProject(work) + } + connectSuccess = () => { + this.child.fetchData && this.child.fetchData() + } + + cancelConnectionProject = (work) => { + let workId=this.props.match.params.workId; + let courseId=this.props.match.params.coursesId; + + const url = `/homework_commons/${work.homework_id}/student_works/cancel_relate_project.json` + axios.get(url).then((response)=> { + if (response.data.status == 0) { + this.child.fetchData && this.child.fetchData() + + this.props.showNotification('取消关联成功') + } + }).catch((error)=>{ + console.log(error) + }) + } + // 关联项目 END render() { let {course_name, homework_name, homework_status, noTab @@ -180,7 +204,8 @@ class CommonWorkDetailIndex extends Component{ const childModuleName = this.state.moduleName const commonHandler = { - initWorkDetailCommonState: this.initWorkDetailCommonState + initWorkDetailCommonState: this.initWorkDetailCommonState, + triggerRef: this.bindRef } const isAdmin = this.props.isAdmin() @@ -191,7 +216,7 @@ class CommonWorkDetailIndex extends Component{ let params = {} if (isListModule) { // TODO - if(this.child!=undefined) { + if(this.child && this.child._getRequestParams) { params = this.child._getRequestParams() !== undefined ? this.child._getRequestParams() : {}; } } @@ -341,6 +366,20 @@ class CommonWorkDetailIndex extends Component{ {/*项目在线质量检测*/} {isAdmin && this.props.toEditPage(this.props.match.params, workId)}>编辑作业} + { // + work_statuses && work_statuses.indexOf('关联项目') != -1 && + + + this.openConnectionProject({ homework_id: workId })}>关联项目 + this.props.toCreateProject()}>创建项目 + + } + + { // + work_statuses && work_statuses.indexOf('取消关联') != -1 && + this.cancelConnectionProject( {homework_id: workId} )}>取消关联 + } + {work_statuses && work_statuses.indexOf('提交作品') != -1 && { this.props.toWorkPostPage(this.props.match.params)}} >提交作品} diff --git a/public/react/src/modules/courses/busyWork/CommonWorkList.js b/public/react/src/modules/courses/busyWork/CommonWorkList.js index 10bbca9f3..528aa1d9e 100644 --- a/public/react/src/modules/courses/busyWork/CommonWorkList.js +++ b/public/react/src/modules/courses/busyWork/CommonWorkList.js @@ -38,10 +38,10 @@ function renderScore(score, content) { function getScoreTip(score, dom) { return score == '--' ? '未评分' : score == '**' ? '未公开' : dom } -function buildColumns(that, student_works) { +function buildColumns(that, student_works, studentData) { let gotWorkGroup = false; let gotProjectInfo = false; - if (student_works) { + if (student_works && student_works.length) { student_works.forEach(item => { if (item.work_group) { gotWorkGroup = true @@ -50,6 +50,13 @@ function buildColumns(that, student_works) { gotProjectInfo = true; } }) + } else if (studentData && studentData[0]) { + if (studentData[0].work_group) { + gotWorkGroup = true + } + if (studentData[0].project_info) { + gotProjectInfo = true; + } } let courseId= that.props.match.params.coursesId; let workId= that.props.match.params.workId; @@ -431,6 +438,9 @@ class CommonWorkList extends Component{ group_id:arg_course_group, } } + fetchData = () => { + this.fetchList() + } fetchList = () => { let workId=this.props.match.params.workId; let courseId=this.props.match.params.coursesId; @@ -542,7 +552,7 @@ class CommonWorkList extends Component{ late_penalty, absence_penalty, appeal_penalty ,end_immediately ,publish_immediately - , homework_id, visible + , homework_id, visible, work_group, project_info } =this.state; @@ -566,7 +576,6 @@ class CommonWorkList extends Component{ return { label: `${item.name}(${item.count})`, value: item.id } }) - const columns = buildColumns(this, student_works) const isAdmin = this.props.isAdmin() const isStudent = this.props.isStudent() @@ -579,9 +588,11 @@ class CommonWorkList extends Component{ }else{ StudentData=isStudent ? [{ id, user_name, user_login, student_id, group_name, work_status, update_time, teacher_score, teaching_asistant_score, student_score, ultimate_score, work_score, student_comment_count, appeal_all_count, appeal_deal_count, - late_penalty, absence_penalty, appeal_penalty, - work_group: '', isMine: true }] : [] + late_penalty, absence_penalty, appeal_penalty, project_info, + work_group, isMine: true }] : [] } + const columns = buildColumns(this, student_works, StudentData) + let params = this._getRequestParams() let exportUrl = `/api/homework_commons/${workId}/works_list.zip?${queryString.stringify(params)}`; const exportResultUrl = `/api/homework_commons/${workId}/works_list.xlsx`; diff --git a/public/react/src/modules/courses/busyWork/CommonWorkQuestion.js b/public/react/src/modules/courses/busyWork/CommonWorkQuestion.js index 49f1e5158..f400cd9a2 100644 --- a/public/react/src/modules/courses/busyWork/CommonWorkQuestion.js +++ b/public/react/src/modules/courses/busyWork/CommonWorkQuestion.js @@ -55,7 +55,11 @@ class CommonWorkQuestion extends Component{ } componentDidMount() { this.fetchData() - + try { + this.props.triggerRef(this); + }catch (e) { + + } on('commonwork_fetch_all', this.fetchAllListener) } componentWillUnmount() { diff --git a/public/react/src/modules/courses/busyWork/CommonWorkSetting.js b/public/react/src/modules/courses/busyWork/CommonWorkSetting.js index aeda66ae1..4683e4e88 100644 --- a/public/react/src/modules/courses/busyWork/CommonWorkSetting.js +++ b/public/react/src/modules/courses/busyWork/CommonWorkSetting.js @@ -77,7 +77,7 @@ class CommonWorkSetting extends Component{ } } - getsettings=()=>{ + fetchData=()=>{ let workId=this.props.match.params.workId; const isAdmin = this.props.isAdmin() const url = `/homework_commons/${workId}/settings.json` @@ -160,14 +160,19 @@ class CommonWorkSetting extends Component{ componentDidMount(){ - this.getsettings(); + this.fetchData(); + try { + this.props.triggerRef(this); + }catch (e) { + + } on('commonwork_fetch_all', this.fetchAllListener) } componentWillUnmount() { off('commonwork_fetch_all', this.fetchAllListener) } fetchAllListener = () => { - this.getsettings() + this.fetchData() } @@ -477,7 +482,7 @@ class CommonWorkSetting extends Component{ // checkBoxValues:[], // checkAllValue:false // }) - // this.getsettings(); + // this.fetchData(); // } // }).catch((error)=>{ @@ -988,11 +993,11 @@ class CommonWorkSetting extends Component{ Saves={Saves} course_groups={course_groups} /> */} - - - + this.setHistoryFun("/courses/"+this.props.match.params.coursesId+"/teachers")}> 教师 {coursedata.teacher_count} - + this.setHistoryFun("/courses/"+this.props.match.params.coursesId+"/students")}> 学生 {coursedata.student_count} {coursedata.credit===null?"": diff --git a/public/react/src/modules/courses/coursesDetail/CoursesLeftNav.js b/public/react/src/modules/courses/coursesDetail/CoursesLeftNav.js index 16c71f942..d3b68ac32 100644 --- a/public/react/src/modules/courses/coursesDetail/CoursesLeftNav.js +++ b/public/react/src/modules/courses/coursesDetail/CoursesLeftNav.js @@ -880,8 +880,10 @@ class Coursesleftnav extends Component{ return(
-
  • this.showsandians(e,key,item.category_url,1)} className={this.props.mainurl===item.category_url&&key===this.props.indexs?"liactive":"clearfix active"} onMouseLeave={(e)=>this.hidesandian(e,key)} onMouseEnter={(e)=>this.showsandian(e,key)}> - this.showsandians(e,key,item.category_url,1)} className={ item.second_category===undefined?"fl ml20 pd0":item.second_category.length===0?"fl ml20 pd0":this.state.sandiantypes===key?"fl ml20 pd0 ebebeb":"fl ml20 pd0"}> + +
  • this.showsandians(e,key,item.category_url,1)} className={this.props.mainurl===item.category_url&&key===this.props.indexs?"liactive":"clearfix active"} onMouseLeave={(e)=>this.hidesandian(e,key)} onMouseEnter={(e)=>this.showsandian(e,key)}> + + this.showsandians(e,key,item.category_url,1)} className={ item.second_category===undefined?"fl ml20 pd0":item.second_category.length===0?"fl ml20 pd0":this.state.sandiantypes===key?"fl ml20 pd0 ebebeb":"fl ml20 pd0"}> { item.type==="announcement"?: item.type==="online_learning"?: @@ -912,7 +914,8 @@ class Coursesleftnav extends Component{ :""} -
  • + + {/*下拉列表*/} @@ -950,14 +953,15 @@ class Coursesleftnav extends Component{ > {/*"/courses/"+this.props.match.params.coursesId+"/"+item.type+"/"+iem.category_type+"/"+iem.category_id*/} +
  • this.selectnavids(e,key,iem.category_id,item.type+"child",iem.second_category_url,key)} onMouseLeave={(e)=>this.twosandianhide(e,index,item.type)} onMouseEnter={(e)=>this.twosandianshow(e,index,item.type)} key={index} ref={provided.innerRef} {...provided.draggableProps} {...provided.dragHandleProps} - title={iem.category_name.length<10?"":iem.category_name} - > + > + {iem.category_name} {iem.category_count===0?"":iem.category_count} @@ -971,6 +975,7 @@ class Coursesleftnav extends Component{ {provided.placeholder} +
  • @@ -993,31 +998,35 @@ class Coursesleftnav extends Component{ return(
    {/**/} - -
  • this.setnavid(e,key,item.id,item.type,item.category_url)} onMouseEnter={(e)=>this.showsandian(e,key)} - title={item.name.length<7?"":item.name} - > - - { - item.type==="announcement"?: - item.type==="online_learning"?: - item.type==="shixun_homework"?: - item.type==="common_homework"?: - item.type==="group_homework"?: - item.type==="graduation"?: - item.type==="exercise"?: - item.type==="poll"?: - item.type==="attachment"?: - item.type==="board"?: - item.type==="course_group"?:"" - } - - this.selectnavid(e,key,item.id,item.type,item.category_url)}>{item.name} - {item.task_count===0?"":item.task_count} - - -
  • + + +
  • this.setnavid(e,key,item.id,item.type,item.category_url)} onMouseEnter={(e)=>this.showsandian(e,key)} + + > + + + { + item.type==="announcement"?: + item.type==="online_learning"?: + item.type==="shixun_homework"?: + item.type==="common_homework"?: + item.type==="group_homework"?: + item.type==="graduation"?: + item.type==="exercise"?: + item.type==="poll"?: + item.type==="attachment"?: + item.type==="board"?: + item.type==="course_group"?:"" + } + + this.selectnavid(e,key,item.id,item.type,item.category_url)}>{item.name} + {item.task_count===0?"":item.task_count} + + + +
  • + {/*
    */} @@ -1035,8 +1044,9 @@ class Coursesleftnav extends Component{ } } return( - -
  • + +
  • + this.selectnavids(e,key,iem.category_id,item.type+"child",iem.second_category_url,key)} > {/*{iem.category_name}*/} @@ -1044,6 +1054,7 @@ class Coursesleftnav extends Component{ {iem.category_count===0?"":iem.category_count} +
  • ) diff --git a/public/react/src/modules/courses/coursesPublic/SelectSetting.js b/public/react/src/modules/courses/coursesPublic/SelectSetting.js index b453d0075..2870c5d12 100644 --- a/public/react/src/modules/courses/coursesPublic/SelectSetting.js +++ b/public/react/src/modules/courses/coursesPublic/SelectSetting.js @@ -461,11 +461,7 @@ class Selectsetting extends Component{ - -
    - - +
  • {datalist&&datalist.title} @@ -632,7 +633,7 @@ class Selectsetting extends Component{ {this.state.newfileListtypes===true?

    请先上传资源

    :""} -

    +

    -

    - - 勾选后所有用户可见,否则仅课堂成员可见 - -
    + {/*
    */} + {/**/} + {/*勾选后所有用户可见,否则仅课堂成员可见*/} + {/**/} + {/*
    */} {/*{this.props.has_course_groups&&this.props.has_course_groups===true?:""}*/} - {/*{this.state.course_groupss&&this.state.course_groupss.length>0?*/} - {/*统一设置(选中则所有分班使用相同的发布设置,否则各个单独设置)*/} - {/*:""}*/} + {this.state.course_groupss&&this.state.course_groupss.length>0? + 统一设置(选中则所有分班使用相同的发布设置,否则各个单独设置) + :""} -
    - 勾选后所有用户可见,否则仅课堂成员可见 - + {/*
    */} + {/*勾选后所有用户可见,否则仅课堂成员可见*/} + {/**/} - {/*{this.state.course_groups_count&&this.state.course_groups_count>0?*/} - {/*统一设置(选中则所有分班使用相同的发布设置,否则各个单独设置)*/} - {/*:""}*/} + {this.state.course_groups_count&&this.state.course_groups_count>0? + 统一设置(选中则所有分班使用相同的发布设置,否则各个单独设置) + :""} + + + {this.props.courses===undefined?"":detailInfoList.is_creator===true?this.state.courseslist.map((item,key)=>{ + return( + + + + + + )}):"" + } + + - {this.state.MenuItemskey}次开课 + 第{this.state.MenuItemskey}次开课
  • @@ -495,24 +510,24 @@ class DetailTop extends Component{ {item.course_status.status===0?
    即将开课
    :""} {item.course_status.status===1?
    {item.course_status.time}
    :""} {item.course_status.status===2? - detailInfoList.is_creator===true?
    已结束
    :item.course_identity<6? + detailInfoList.is_creator===true||detailInfoList.allow_add_member===true?
    已结束
    :item.course_identity<6?
    已结束
    :"":""} {item.course_status.status===0? - detailInfoList.is_creator===true? + detailInfoList.is_creator===true||detailInfoList.allow_add_member===true? 进入课堂 :item.course_identity<6?
    报名成功
    :this.JoinnowCourse(item.course_id)}>立即报名:""} {item.course_status.status===1? - detailInfoList.is_creator===true?this.JoinnowCourse(item.course_id)}> + detailInfoList.is_creator===true||detailInfoList.allow_add_member===true?this.JoinnowCourse(item.course_id)}> 进入课堂 :item.course_identity<6? 立即学习 :this.JoinnowCourse(item.course_id)}>立即加入:""} {item.course_status.status===2? - detailInfoList.is_creator===true? + detailInfoList.is_creator===true||detailInfoList.allow_add_member===true? 进入课堂 :item.course_identity<6? 进入课堂 diff --git a/public/react/src/modules/paths/PathDetail/OpenCourse.js b/public/react/src/modules/paths/PathDetail/OpenCourse.js index bd9b309fd..ccc11185e 100644 --- a/public/react/src/modules/paths/PathDetail/OpenCourse.js +++ b/public/react/src/modules/paths/PathDetail/OpenCourse.js @@ -26,9 +26,9 @@ class OpenCourse extends Component { console.log(this.props.match.params.pathId) if(value===0){ - window.open(`/courses/${this.props.match.params.pathId}/newgold/0 `); + window.open(`/courses/news/${this.props.match.params.pathId}/newgold/0 `); }else{ - window.open(`/courses/${this.props.match.params.pathId}/newgold/1`); + window.open(`/courses/news/${this.props.match.params.pathId}/newgold/1`); } this.props.OpenCourseCancel(); } @@ -68,10 +68,11 @@ class OpenCourse extends Component {

    - + 开放课堂:所有用户可以随时访问 - + + 私有课堂:仅报名参与的课堂成员可以访问 diff --git a/public/react/src/modules/paths/PathDetail/PathDetailIndex.js b/public/react/src/modules/paths/PathDetail/PathDetailIndex.js index d64763980..edac5ca01 100644 --- a/public/react/src/modules/paths/PathDetail/PathDetailIndex.js +++ b/public/react/src/modules/paths/PathDetail/PathDetailIndex.js @@ -461,7 +461,7 @@ class PathDetailIndex extends Component{

    -
    15&&clickdetailInfoListtype===false?"newsubscript mb9 color-grey-9 fr":"newsubscript mb9 color-grey-9 none"} +
    20&&clickdetailInfoListtype===false?"newsubscript mb9 color-grey-9 fr":"newsubscript mb9 color-grey-9 none"} onClick={()=>this.clickNewsubscript(0)} >...
    @@ -542,7 +542,7 @@ class PathDetailIndex extends Component{ { detailInfoList===undefined?"":detailInfoList.allow_add_member===true?
    {key!=0?:""} - {key+1!= members&&members.length?:""} + {key+1== members.length?"":}
    :"" } diff --git a/public/react/src/modules/tpm/TPMIndexHOC.js b/public/react/src/modules/tpm/TPMIndexHOC.js index 1a6c38639..6149687bc 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?9`)); + .attr('href', `${_url_origin}/stylesheets/css/edu-common.css?1`)); $('head').append($('') - .attr('href', `${_url_origin}/stylesheets/educoder/edu-main.css?9`)); + .attr('href', `${_url_origin}/stylesheets/educoder/edu-main.css?1`)); // index.html有加载 $('head').append($('') - .attr('href', `${_url_origin}/stylesheets/educoder/edu-all.css?9`)); + .attr('href', `${_url_origin}/stylesheets/educoder/edu-all.css?1`)); // $('head').append($('') diff --git a/public/react/src/modules/user/usersInfo/InfosPackage.js b/public/react/src/modules/user/usersInfo/InfosPackage.js index aca31a7b5..4b2c655c3 100644 --- a/public/react/src/modules/user/usersInfo/InfosPackage.js +++ b/public/react/src/modules/user/usersInfo/InfosPackage.js @@ -234,15 +234,15 @@ class InfosPackage extends Component{
    - + {item.visit_count}人浏览
    - + {moment(item.deadline_at).format("YYYY-MM-DD HH:mm")}竞标截止
    - + {item.bidding_users_count}人竞标
    diff --git a/public/react/src/modules/user/usersInfo/video/VideoUploadList.js b/public/react/src/modules/user/usersInfo/video/VideoUploadList.js index aff9e8496..f3d6b4f7a 100644 --- a/public/react/src/modules/user/usersInfo/video/VideoUploadList.js +++ b/public/react/src/modules/user/usersInfo/video/VideoUploadList.js @@ -435,7 +435,7 @@ function VideoUploadList (props) {
    {/* windows video/* 不管用 TODO */}
    ) diff --git a/public/stylesheets/educoder/edu-all.css b/public/stylesheets/educoder/edu-all.css index d55fd3906..bc6af002c 100644 --- a/public/stylesheets/educoder/edu-all.css +++ b/public/stylesheets/educoder/edu-all.css @@ -114,10 +114,26 @@ em.vertical-line{display: inline-block;width: 2px;background: #999;height: 10px} .smallSquare:nth-child(3n+0){margin-right: 0px;} .partimg{height: 180px;width: 100%;border-radius: 6px 6px 0px 0px;} /*块状列表上面的绿色标签*/ -.tag-green{position: absolute;left: 0px;top:20px;} -.tag-green .tag-name{display: block;width: auto;background-image: url("/images/educoder/tag1.png");background-size: 100% 100%;padding: 0px 8px;color: #fff;float: left;} -.tag-orange{position: absolute;right: 0px;top:20px;} -.tag-orange .tag-name{display: block;width: auto;background-color:#FF6800;background-size: 100% 100%;padding: 0px 8px;color: #fff;float: left;} +.tag-green{ + position: absolute; + left: 10px; + bottom: 90px;} +.tag-green .tag-name{display: block;width: auto; + /*background-image: url("/images/educoder/tag1.png");*/ + background: #000000; + border: 1px solid #fff; + border-radius: 3px; + font-size: 14px; + opacity: 0.56; + background-size: 100% 100%;padding: 0px 8px;color: #fff;float: left;} +.tag-orange{position: absolute;right: 0px;top:12px;} +.tag-orange .tag-name{display: block;width: auto;background-color:#FF6800; + background-size: 100% 100%;padding: 0px 8px;color: #fff;float: left; + height: 28px; + line-height: 28px; + border-top-left-radius: 4px; + border-bottom-left-radius: 4px; +} /*发送至弹框里的下拉框*/ .downSelectOption{position: relative;height: 35px;} .downSelectOption .showOption{background-color: #F4F4F4;border: 1px solid #EAEAEA;width: 100%;padding: 5px 40px 5px 5px;outline: none;height: 100%;box-sizing: border-box;} @@ -3714,9 +3730,13 @@ a.singlepublishtwo{ } .shaiContent li.shaiItem:hover i.iconfont{ - color: #4CACFF!important + color: #4CACFF !important; } .detail_for_paragraph p{ white-space: pre-wrap; +} + +.ant-tooltip{ + max-width: 100% !important; } \ No newline at end of file