diff --git a/Gemfile b/Gemfile index 11029470..7909cb17 100644 --- a/Gemfile +++ b/Gemfile @@ -63,8 +63,8 @@ gem 'elasticsearch-rails' gem 'oauth2' # xlsx -#gem 'axlsx', '3.0.0.pre' -#gem 'axlsx_rails', '0.3.0' +gem 'axlsx', '3.0.0.pre' +gem 'axlsx_rails', '0.3.0' #Ruby 2.2+ has removed test/unit from the core library. if RUBY_VERSION>='2.2' diff --git a/app/api/mobile/api.rb b/app/api/mobile/api.rb index eefedb5b..69bd4d44 100644 --- a/app/api/mobile/api.rb +++ b/app/api/mobile/api.rb @@ -34,9 +34,9 @@ module Mobile version 'v1', using: :path format :json content_type :json, "application/json;charset=UTF-8" - # use ActionDispatch::Session::CookieStore - + use ActionDispatch::Session::CookieStore + require 'digest' use Mobile::Middleware::ErrorHandler helpers do @@ -53,6 +53,16 @@ module Mobile error!('401 Unauthorized', 401) if params[:private_token] != "hriEn3UwXfJs3PmyXnSG" end + def cnmooc_access_key! + ## 签名 + accessKeyId = 'LTAISM4HFWpQHh3g'.freeze + accessKeySecret = '9NMU8ushmFu8SN1EKHOhvo9jmv1qp0'.freeze + sign = Digest::MD5.hexdigest("AccessKeyId=#{accessKeyId}AccessKeySecret=#{accessKeySecret}").upcase + if params[:sign] != sign + error!('401 Unauthorized', 401) + end + end + # 有一些接口没登录也能查看数据 def career_authenticate! pass = request.path.include?("introduction") || request.path.include?("get_published_careers")|| request.path.include?("get_current_user") @@ -99,6 +109,12 @@ module Mobile return uw.user if uw end + third_party_user_id = session[:third_party_user_id] + if third_party_user_id + c_user = UserSource.find_by_id(session[:third_party_user_id]) + return c_user.user if c_user + end + token = ApiKey.where(access_token: params[:token]).first if token && !token.expired? return User.find(token.user_id) @@ -160,6 +176,7 @@ module Mobile mount Apis::Careers mount Apis::Assets mount Apis::Ecloud + mount Apis::Cnmooc diff --git a/app/api/mobile/apis/cnmooc.rb b/app/api/mobile/apis/cnmooc.rb new file mode 100644 index 00000000..d67a390d --- /dev/null +++ b/app/api/mobile/apis/cnmooc.rb @@ -0,0 +1,75 @@ +# encoding=utf-8 +# 好大学接口数据 +module Mobile + module Apis + class Cnmooc < Grape::API + before {cnmooc_access_key!} + content_type :json, 'application/json;charset=UTF-8' + + resources :cnmoocs do + desc '获取实训数据' + get "get_resources_data" do + CnmoocsService.new.get_resources_data params + end + + desc "实训搜索功能" + params do + requires :name, type: String, desc: "搜索名称" + end + get 'search_resources' do + CnmoocsService.new.search_resources params + end + + desc " 查找用户" + params do + requires :userName, type: String, desc: "好大学用户名" + end + get 'find_user' do + CnmoocsService.new.find_user params + end + + desc "创建用户" + params do + requires :userName, type: String, desc: "好大学用户名" + end + post "create_user" do + CnmoocsService.new.create_user params + end + + desc "获取资源访问地址" + params do + requires :userId, type: Integer, desc: "用户ID" + requires :resouceId, type: String, desc: "资源唯一标示" + requires :accessType, type: Integer, desc: "资源类型" + end + get "source_url" do + if session[:third_party_user_id].blank? + user = User.find(params[:userId]) + session[:third_party_user_id] = user.user_source.id + end + + CnmoocsService.new.source_url(params) + end + + desc "远程登录" + params do + requires :mail, type: String, desc: "邮箱地址" + requires :password, type: String, desc: "密码" + end + get "login_educoder" do + CnmoocsService.new.login_educoder params + end + + desc "资源学习情况查询" + params do + requires :userId, type: Integer, desc: "用户ID" + requires :resouceId, type: String, desc: "资源唯一标示" + end + get 'get_students_data' do + CnmoocsService.new.get_students_data params + end + + end + end + end +end \ No newline at end of file diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 435c71fc..42dd6e1e 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -207,6 +207,9 @@ class ApplicationController < ActionController::Base elsif session[:wechat_openid] uw = UserWechat.find_by_openid(session[:wechat_openid]) user = uw.user if uw + elsif session[:third_party_user_id] + c_user = UserSource.find_by_id(session[:third_party_user_id]) + user = c_user.user if c_user end end if user.nil? && Setting.rest_api_enabled? && accept_api_auth? diff --git a/app/controllers/exercise_bank_controller.rb b/app/controllers/exercise_bank_controller.rb index e4fa6727..6b8090dd 100644 --- a/app/controllers/exercise_bank_controller.rb +++ b/app/controllers/exercise_bank_controller.rb @@ -104,6 +104,7 @@ class ExerciseBankController < ApplicationController :question_type => params[:question_type] || 1, :question_number => @exercise.exercise_bank_questions.count + 1, :question_score => params[:question_score], + :shixun_name => params[:question_type] == '5' ? params[:shixun_name] : nil, :shixun_id => params[:shixun], :max_choices => params[:max_choices].to_i || 0, :min_choices => params[:min_choices].to_i || 0 @@ -271,6 +272,7 @@ class ExerciseBankController < ApplicationController end end if @exercise_question.question_type == 5 + @exercise_question.shixun_name = params[:shixun_name].strip if !params[:shixun_name].blank? question_score = 0 @exercise_question.exercise_bank_shixun_challenges.each_with_index do |challenge, index| challenge.question_score = params[:question_score][index] diff --git a/app/controllers/exercise_controller.rb b/app/controllers/exercise_controller.rb index 23024a78..ee5705fb 100644 --- a/app/controllers/exercise_controller.rb +++ b/app/controllers/exercise_controller.rb @@ -372,6 +372,7 @@ class ExerciseController < ApplicationController :question_type => params[:question_type] || 1, :question_number => @exercise.exercise_questions.count + 1, :question_score => params[:question_type] == '5' ? 0 : params[:question_score], + :shixun_name => params[:question_type] == '5' ? params[:shixun_name] : nil, :shixun_id => params[:shixun] } @exercise_questions = @exercise.exercise_questions.new option @@ -512,6 +513,7 @@ class ExerciseController < ApplicationController end end if @exercise_question.question_type == 5 + @exercise_question.shixun_name = params[:shixun_name].strip if !params[:shixun_name].blank? question_score = 0 @exercise_question.exercise_shixun_challenges.each_with_index do |challenge, index| challenge.question_score = params[:question_score][index] @@ -1508,7 +1510,8 @@ class ExerciseController < ApplicationController :question_type => q[:question_type] || 1, :question_number => q[:question_number], :question_score => q[:question_score], - :shixun_id => q[:shixun_id] + :shixun_id => q[:shixun_id], + :shixun_name => q[:shixun_name] } exercise_bank_question = exercise_bank.exercise_bank_questions.new option diff --git a/app/controllers/managements_controller.rb b/app/controllers/managements_controller.rb index 202f90b3..eb3c37c9 100644 --- a/app/controllers/managements_controller.rb +++ b/app/controllers/managements_controller.rb @@ -4185,7 +4185,7 @@ end sheet1 = book.create_worksheet :name => "users" blue = Spreadsheet::Format.new :color => :blue, :weight => :bold, :size => 10 sheet1.row(0).default_format = blue - sheet1.row(0).concat(["用户姓名","性别","职业","职称","地区"," 单位","子单位","注册时间","最后登录时间","授权"]) + sheet1.row(0).concat(["用户姓名","性别","职业","职称","地区"," 单位","子单位","注册时间","最后登录时间","授权", "邮箱"]) count_row = 1 users.each do |user| sheet1[count_row,0] = user.try(:show_real_name) @@ -4198,6 +4198,7 @@ end sheet1[count_row,7] = format_time user.created_on sheet1[count_row,8] = format_time user.last_login_on sheet1[count_row,9] = user.trial_authorization + sheet1[count_row,10] = user.mail count_row += 1 end book.write xls_report @@ -4295,7 +4296,7 @@ end count_row = 1 shixuns = Shixun.where(:id => shixun_ids).includes(discusses: [:user]) sheet1.row(0).concat(["序号", "实训ID", "实训名称", "实训作者", "作者单位", "评论数", "评论内容", "关卡", "评论者", "评论者职业", - "评论者单位", "评论时间", "社区导师是否已回复"]) + "评论者单位", "评论时间", "社区导师是否已回复", "我的账号回复内容", "回复时间"]) shixuns.each_with_index do |shixun, i| discusses = shixun.discusses.where("user_id != ?", 1) if beginTime.present? @@ -4313,6 +4314,7 @@ end discusses.each_with_index do |discuss, j| user = discuss.user content = discuss.content.gsub(//, "【图片评论】").gsub(/!\[\].+\)/, "【图片评论】") + myself_discuss = discuss.children.where(user_id: User.current.id).last sheet1[count_row, 6] = strip_html content sheet1[count_row, 7] = "第#{discuss.position}关" sheet1[count_row, 8] = user.show_real_name @@ -4320,6 +4322,8 @@ end sheet1[count_row, 10] = user.school_name sheet1[count_row, 11] = format_time discuss.created_at sheet1[count_row, 12] = discuss.children.pluck(:user_id).include?(1) ? "是" : "否" + sheet1[count_row, 13] = myself_discuss.try(:content) + sheet1[count_row, 14] = myself_discuss ? (format_time myself_discuss.created_at) : "" count_row += 1 end #count_row += 1 diff --git a/app/controllers/question_banks_controller.rb b/app/controllers/question_banks_controller.rb index 96f6db3b..cffecba1 100644 --- a/app/controllers/question_banks_controller.rb +++ b/app/controllers/question_banks_controller.rb @@ -117,7 +117,7 @@ class QuestionBanksController < ApplicationController else @courses = User.current.courses.where("is_delete = 0 and is_end = 0").select{ |course| User.current.has_teacher_role(course)} end - @homework_ids = params[:check_homework_bank] || params[:bank_id].split(" ") + @homework_ids = params[:check_homework_bank] || params[:bank_id].split(" ") unless params[:is_observe] @search = params[:search] respond_to do |format| format.js diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 35449aad..34fa1a8d 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -7034,7 +7034,8 @@ def quote_exercise_bank exercise, course :question_type => q[:question_type] || 1, :question_number => q[:question_number], :question_score => q[:question_score], - :shixun_id => q[:shixun_id] + :shixun_id => q[:shixun_id], + :shixun_name => q[:shixun_name] } exercise_question = new_exercise.exercise_questions.new option diff --git a/app/models/cnmooc_user.rb b/app/models/cnmooc_user.rb new file mode 100644 index 00000000..e834c768 --- /dev/null +++ b/app/models/cnmooc_user.rb @@ -0,0 +1,8 @@ +class CnmoocUser < UserSource + + private + + def email_prefix + 'cnmooc_' + end +end diff --git a/app/models/user.rb b/app/models/user.rb index 752ea113..3e89e4f2 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -269,6 +269,8 @@ class User < Principal has_many :article_homepages, :dependent => :destroy has_many :competition_lists, :dependent => :destroy + has_one :user_source + ## end # default_scope -> { includes(:user_extensions, :user_score) } diff --git a/app/models/user_source.rb b/app/models/user_source.rb new file mode 100644 index 00000000..d8fb350d --- /dev/null +++ b/app/models/user_source.rb @@ -0,0 +1,21 @@ +class UserSource < ActiveRecord::Base + belongs_to :user + + def generate_email + email = rand_email + while User.exists?(mail: email) do + email = rand_email + end + email + end + + private + + def rand_email + email_prefix + Random.rand.to_s[2..8] + '@educoder.com' + end + + def email_prefix + '' + end +end diff --git a/app/services/cnmoocs_service.rb b/app/services/cnmoocs_service.rb new file mode 100644 index 00000000..9ec02bfd --- /dev/null +++ b/app/services/cnmoocs_service.rb @@ -0,0 +1,162 @@ +class CnmoocsService + include ApplicationHelper + include GamesHelper + + def get_resources_data params + page = params[:pageNo].to_i + limit = params[:pageSize] || 16 + offset = page * limit.to_i + resouces = [] + if params[:level].to_s == "1" + subjects = Subject.find_by_sql("SELECT subjects.id, subjects.name, subjects.status, COUNT(myshixuns.id) AS myshixun_member_count + FROM myshixuns, stage_shixuns, subjects WHERE myshixuns.shixun_id = stage_shixuns.shixun_id + AND stage_shixuns.subject_id = subjects.id AND `subjects`.`hidden` = 0 AND `subjects`.`status` = 2 + GROUP BY subjects.id ORDER BY myshixun_member_count DESC limit #{offset},#{limit}") + + subjects.each do |subject| + resouces << {resouceId: subject.id, parentId: nil, resouceName: subject.name, accessType: 0, nodeType: 0, + resouceType: 2} + end + totalCount = Subject.where(:status => 2, :hidden => 0).count + count = subjects.count + elsif params[:level].to_s == "2" + return {error: -1, messages: "请求二级及其更高目录时,parentId不能为空"} if params[:parentId].blank? + stages = Stage.where(:subject_id => params[:parentId]).offset(offset).limit(limit) + stages.each do |stage| + resouces << {resouceId: stage.id, parentId: params[:parentId], resouceName: stage.name, accessType: 0, nodeType: 0, + resouceType: 2} + end + totalCount = Stage.where(:subject_id => params[:parentId]).count + count = stages.count + elsif params[:level].to_s == "3" + return {error: -1, messages: "请求二级及其更高目录时,parentId不能为空"} if params[:parentId].blank? + shixun_ids = StageShixun.where(:stage_id => params[:parentId]).pluck(:shixun_id) + shixuns = Shixun.where(:id => shixun_ids).offset(offset).limit(limit) + shixuns.each do |shixun| + resouces << {resouceId: shixun.id, parentId: params[:parentId], resouceName: shixun.name, accessType: 2, + nodeType: 1, resouceType: 1} + end + totalCount = Shixun.where(:id => shixun_ids).count + count = shixuns.count + end + pageCount = ((totalCount / limit.to_f) == (totalCount / limit)) ? (totalCount / limit) : ((totalCount / limit) + 1) + {error: 0, messages: "请求成功", + page: {count: count, totalCount: totalCount, pageNo: page, pageSize: limit, pageCount: pageCount}, + data: {resouces: resouces} } + end + + def search_resources params + page = params[:pageNo].to_i + limit = params[:pageSize] || 16 + offset = page * limit.to_i + shixuns = Shixun.select([:id, :identifier, :name, :myshixuns_count, :averge_star, :challenges_count, :trainee]). + where(status: 2, hidden: 0).where("name like ?", "%#{params[:name]}%") + shixun_count = shixuns.count + pageCount = ((shixun_count / limit.to_f) == (shixun_count / limit)) ? (shixun_count / limit) : ((shixun_count / limit) + 1) + shixuns = shixuns.order("myshixuns_count desc").offset(offset).limit(limit) + shixun_list = shixun_data shixuns + {error: 0, messages: "请求成功", + page: {count: shixuns.count, totalCount: shixun_count, pageNo: page, pageSize: limit, pageCount: pageCount}, + data: shixun_list } + end + + def find_user params + c_user = CnmoocUser.find_by_uuid(params[:userName]) + if c_user + {error: 0, messages: "找到用户", data: { userId: c_user.user_id } } + else + {error: -1, messages: "找不到用户"} + end + end + + def create_user(params) + c_user = CnmoocUser.find_by_uuid(params[:userName]) + + if c_user.present? + return { error: -1, messages: '用户已存在' } + end + c_user = CnmoocUser.new(uuid: params[:userName], name: params[:name]) + + mail = params[:email] || c_user.generate_email + name = params[:name] || "好大学_#{params[:userName]}" + login = generate_login('m') + Rails.logger.info("#######mail: #{mail}, #{name}, #{login}") + create_params = { + lastname: name, + mail: mail, + mail_notification: mail, + password: OauthController::DEFAULT_PASSWORD, + certification: 1 + } + user = User.new(create_params) + # login 有问题,只能这样赋值 + user.login = login + ActiveRecord::Base.transaction do + user.save! + + UserExtensions.create!(user_id: user.id, school_id: School.first.id, identity: 4, gender: 0) + + c_user.user_id = user.id + c_user.save! + end + + { error: 0, messages: "创建成功", data: { userId: user.id } } + end + + def login_educoder params + user, last_login_on = User.try_to_login(params[:mail], params[:password]) + if user + self.logged_user = user + {error: 0, messages: "登录成功"} + else + {error: -1, messages: "登录失败,请检查邮箱和密码是否正确"} + end + + end + + def source_url(params) + shixun = Shixun.find_by_identifier(params[:resouceId]) + if shixun.blank? + return { error: -1, messages: '资源不存在' } + end + + { error: 0, messages: '成功', accessUrl: "#{Redmine::Configuration['educoder_domain']}/shixuns/#{shixun.identifier}" } + end + + def get_students_data params + shixun = Shixun.find_by_id params[:resouceId] + return {error: -1, messages: "资源id不对,请使用资源的id查找"} if shixun.blank? + myshixun = shixun.myshixuns.where(:user_id => params[:userId]).includes(:games).first + if myshixun.present? + score = myshixun.total_score + time = 0 + myshixun.games.each do |game| + time += game.consumes_time_int + end + {error: 0, messages: '成功', data: {time: time, score: score * 10}} + else + {error: -1, messages: '用户还未开始学习此资源'} + end + + end + + + private + def shixun_data shixuns + shixun_list = [] + shixuns.includes(:tag_repertoires).each do |shixun| + tag_name = shixun.tag_repertoires.first.try(:name) + level = %W(初级 中级 高级 顶级)[shixun.trainee - 1] + shixun_list << {identifier: shixun.identifier, name: shixun.name, students_count: shixun.myshixuns_count, + challenges_count: shixun.challenges_count, score_info: shixun.averge_star, level: level} + + end + {resouces: shixun_list} + end + + # 为新创建的用户随机生成以m为前缀的用户名,m表示该用户是用邮箱注册 + def generate_login(login_pre) + us = UsersService.new + us.generate_user_login(login_pre) + end +end \ No newline at end of file diff --git a/app/views/exercise/_edit_shixun.html.erb b/app/views/exercise/_edit_shixun.html.erb index b7caa087..ef96f3b7 100644 --- a/app/views/exercise/_edit_shixun.html.erb +++ b/app/views/exercise/_edit_shixun.html.erb @@ -1,7 +1,10 @@ <%= form_for("",:url => update_exercise_question_exercise_index_path(:exercise_question => exercise_question.id),:html => {:id => "update_exercise_question_#{exercise_question.id}"}) do |f|%>

实训题

-

<%= exercise_question.shixun.name %>

+

+ + +

  • diff --git a/app/views/exercise/_exercise_form.html.erb b/app/views/exercise/_exercise_form.html.erb index 677e7014..bee149fd 100644 --- a/app/views/exercise/_exercise_form.html.erb +++ b/app/views/exercise/_exercise_form.html.erb @@ -106,11 +106,15 @@ //修改标题时确定按钮 function edit_poll_question(doc,id,quest_type) { + var name = $.trim($("#poll_questions_name_" + id).val()); var title = $.trim($("#poll_questions_title_" + id).val()); var score = $.trim($("#poll_question_score_"+ id).val()); var standard_ans = $.trim($("#exercise_choice_" + id).val()); + if(name===""){ + notice_box("题目标题不能为空"); + } if(title.length == 0 || score.length == 0){ - notice_box("题目标题/分数不能为空"); + notice_box("要求/分数不能为空"); }else if(!/^[1-9][0-9]*$/.test(score)) { notice_box("分数必须是非零开头的数字"); }else if(quest_type !=3 && quest_type !=4 && standard_ans.length == 0) { diff --git a/app/views/exercise/_exercise_student.html.erb b/app/views/exercise/_exercise_student.html.erb index add9d655..ec47f1c0 100644 --- a/app/views/exercise/_exercise_student.html.erb +++ b/app/views/exercise/_exercise_student.html.erb @@ -162,7 +162,7 @@ <% end %>
  • <% if exercise_question.question_type == 5 %> -

    <%= exercise_question.shixun.name %>

    +

    <%= exercise_question.shixun_name %>

    <% end %>
    <%= exercise_question.question_title.html_safe %>
    <% case exercise_question.question_type %> diff --git a/app/views/exercise/_exercise_student_result.html.erb b/app/views/exercise/_exercise_student_result.html.erb index 0dd656be..6d48573f 100644 --- a/app/views/exercise/_exercise_student_result.html.erb +++ b/app/views/exercise/_exercise_student_result.html.erb @@ -140,7 +140,7 @@ <% end %> <% if exercise_question.question_type == 5 %> -

    <%= exercise_question.shixun.name %>

    +

    <%= exercise_question.shixun_name %>

    <% end %>
    <%= exercise_question.question_title.html_safe %>
    <% case exercise_question.question_type %> diff --git a/app/views/exercise/_new_shixun.html.erb b/app/views/exercise/_new_shixun.html.erb index 1cff068f..6ce2cd68 100644 --- a/app/views/exercise/_new_shixun.html.erb +++ b/app/views/exercise/_new_shixun.html.erb @@ -8,7 +8,10 @@ -

    <%= @shixun.name %>

    +

    + + +

  • diff --git a/app/views/exercise/_show_shixun.html.erb b/app/views/exercise/_show_shixun.html.erb index 92feef9d..75f460ec 100644 --- a/app/views/exercise/_show_shixun.html.erb +++ b/app/views/exercise/_show_shixun.html.erb @@ -16,7 +16,7 @@

    <% end %> -

    <%= exercise_question.shixun.name %>

    +

    <%= exercise_question.shixun_name %>

    <%= exercise_question.question_title.html_safe %>
    <% exercise_question.exercise_shixun_challenges.each_with_index do |exercise_challenge,index| %> diff --git a/app/views/exercise/student_exercise_list.html.erb b/app/views/exercise/student_exercise_list.html.erb index 3632b4d7..b8335515 100644 --- a/app/views/exercise/student_exercise_list.html.erb +++ b/app/views/exercise/student_exercise_list.html.erb @@ -256,7 +256,7 @@ <% end %>
    <% if exercise_question.question_type == 5 %> -

    <%= exercise_question.shixun.name %>

    +

    <%= exercise_question.shixun_name %>

    <% end %>
    <%= exercise_question.question_title.html_safe %> diff --git a/app/views/exercise_bank/_edit_shixun.html.erb b/app/views/exercise_bank/_edit_shixun.html.erb index 41383767..7aa84e9f 100644 --- a/app/views/exercise_bank/_edit_shixun.html.erb +++ b/app/views/exercise_bank/_edit_shixun.html.erb @@ -1,7 +1,10 @@ <%= form_for("",:url => update_exercise_question_exercise_bank_index_path(:exercise_question => exercise_question.id),:html => {:id => "update_exercise_question_#{exercise_question.id}"}) do |f|%>

    实训题

    -

    <%= exercise_question.shixun.name %>

    +

    + + +

  • diff --git a/app/views/exercise_bank/_new_shixun.html.erb b/app/views/exercise_bank/_new_shixun.html.erb index 36af84ad..140ee9b2 100644 --- a/app/views/exercise_bank/_new_shixun.html.erb +++ b/app/views/exercise_bank/_new_shixun.html.erb @@ -8,7 +8,10 @@ -

    <%= @shixun.name %>

    +

    + + +

  • diff --git a/app/views/exercise_bank/_show_shixun.html.erb b/app/views/exercise_bank/_show_shixun.html.erb index cf2a9b2b..e426fd0e 100644 --- a/app/views/exercise_bank/_show_shixun.html.erb +++ b/app/views/exercise_bank/_show_shixun.html.erb @@ -14,7 +14,7 @@

    -

    <%= exercise_question.shixun.name %>

    +

    <%= exercise_question.shixun_name %>

    <%= exercise_question.question_title.html_safe %>
    <% exercise_question.exercise_bank_shixun_challenges.each_with_index do |exercise_challenge,index| %> diff --git a/app/views/exercise_bank/show.html.erb b/app/views/exercise_bank/show.html.erb index 0fb5e2ca..14712a92 100644 --- a/app/views/exercise_bank/show.html.erb +++ b/app/views/exercise_bank/show.html.erb @@ -80,7 +80,7 @@ <% end %>
    <% if exercise_question.question_type == 5 %> -

    <%= exercise_question.shixun.name %>

    +

    <%= exercise_question.shixun_name %>

    <% end %>
    <%= exercise_question.question_title.html_safe %>
    <% case exercise_question.question_type %> diff --git a/app/views/homework_bank/_send_homework_bank.html.erb b/app/views/homework_bank/_send_homework_bank.html.erb index 3127aecd..6b935521 100644 --- a/app/views/homework_bank/_send_homework_bank.html.erb +++ b/app/views/homework_bank/_send_homework_bank.html.erb @@ -31,4 +31,17 @@ - \ No newline at end of file + + + \ No newline at end of file diff --git a/app/views/managements/evaluate_simple.html.erb b/app/views/managements/evaluate_simple.html.erb index a278395c..6d05aedf 100644 --- a/app/views/managements/evaluate_simple.html.erb +++ b/app/views/managements/evaluate_simple.html.erb @@ -14,8 +14,9 @@ 回传时间 前端轮询 结果存储 - 创建时间 - 唯一表示 + 创建时间 + 最大执行时间 + 唯一标识 实训名称 @@ -35,7 +36,8 @@ <%= record.front_js %> <%= record.test_cases %> <%= format_time record.created_at %> - <%= record.identifier %> + <%= record.shixun.try(:exec_time) %> + <%= record.shixun.try(:identifier) %> <%= link_to record.shixun.try(:name), task_path(record.game), :target => "_blank", :title => "#{record.shixun.try(:name)}" %> <% end %> diff --git a/db/migrate/20190528075558_create_user_sources.rb b/db/migrate/20190528075558_create_user_sources.rb new file mode 100644 index 00000000..03f6c12a --- /dev/null +++ b/db/migrate/20190528075558_create_user_sources.rb @@ -0,0 +1,15 @@ +class CreateUserSources < ActiveRecord::Migration + def change + create_table :user_sources do |t| + t.string :type + t.integer :user_id + t.string :uuid + t.string :name + + t.timestamps + end + + add_index :user_sources, [:type, :uuid], unique: true + add_index :user_sources, :user_id + end +end diff --git a/db/migrate/20190529014121_add_shixun_name_to_ex_question.rb b/db/migrate/20190529014121_add_shixun_name_to_ex_question.rb new file mode 100644 index 00000000..8aa02878 --- /dev/null +++ b/db/migrate/20190529014121_add_shixun_name_to_ex_question.rb @@ -0,0 +1,14 @@ +class AddShixunNameToExQuestion < ActiveRecord::Migration + def change + add_column :exercise_questions, :shixun_name, :string + add_column :exercise_bank_questions, :shixun_name, :string + + ExerciseQuestion.where(question_type: 5).each do |question| + question.update_column("shixun_name", question.shixun.try(:name)) + end + + ExerciseBankQuestion.where(question_type: 5).each do |question| + question.update_column("shixun_name", question.shixun.try(:name)) + end + end +end diff --git a/public/javascripts/edu/base_edu.js b/public/javascripts/edu/base_edu.js index 8167249c..1963d1cb 100644 --- a/public/javascripts/edu/base_edu.js +++ b/public/javascripts/edu/base_edu.js @@ -1361,16 +1361,6 @@ function choose_course_to_send_hb(){ } } -function search_hw_course(url){ - $.ajax({ - url: url, - type: 'post', - data: {search: $("#hb_search_course_input").val(), is_observe: true}, - success: function(data){ - } - }); -} - function submit_send_hb_to_course(){ if($("input[name='course_id']:checked").length >= 1){ $("#search_course_notice_h").html("").hide(); diff --git a/public/javascripts/edu/course.js b/public/javascripts/edu/course.js index 330dbea7..98163bda 100644 --- a/public/javascripts/edu/course.js +++ b/public/javascripts/edu/course.js @@ -1103,6 +1103,15 @@ function add_ex_question(doc,quest_type) var title = $.trim($("#poll_questions_title").val()); var score = $.trim($("#question_score").val()); var standard_ans = $.trim($("#exercise_choice_" + quest_type).val()); + + if (quest_type == 5) { + var name = $.trim($("#poll_questions_name").val()); + if(name===""){ + notice_box("题目标题不能为空"); + result = false; + } + } + if(title.length == 0){ if(quest_type != 5){ notice_box("题目标题不能为空"); @@ -1414,6 +1423,13 @@ function edit_poll_question(doc,id,quest_type) { var title = $.trim($("#poll_questions_title_" + id).val()); var score = $.trim($("#poll_question_score_" + id).val()); var standard_ans = $.trim($("#exercise_choice_" + id).val()); + if (quest_type == 5) { + var name = $.trim($("#poll_questions_name_" + id).val()); + if(name===""){ + notice_box("题目标题不能为空"); + result = false; + } + } if (title.length == 0) { if (quest_type != 5) { notice_box("题目标题不能为空");