pre_develop
hjm 6 years ago
commit ec83c30929

@ -63,8 +63,8 @@ gem 'elasticsearch-rails'
gem 'oauth2' gem 'oauth2'
# xlsx # xlsx
#gem 'axlsx', '3.0.0.pre' gem 'axlsx', '3.0.0.pre'
#gem 'axlsx_rails', '0.3.0' gem 'axlsx_rails', '0.3.0'
#Ruby 2.2+ has removed test/unit from the core library. #Ruby 2.2+ has removed test/unit from the core library.
if RUBY_VERSION>='2.2' if RUBY_VERSION>='2.2'

@ -34,9 +34,9 @@ module Mobile
version 'v1', using: :path version 'v1', using: :path
format :json format :json
content_type :json, "application/json;charset=UTF-8" content_type :json, "application/json;charset=UTF-8"
# use ActionDispatch::Session::CookieStore use ActionDispatch::Session::CookieStore
require 'digest'
use Mobile::Middleware::ErrorHandler use Mobile::Middleware::ErrorHandler
helpers do helpers do
@ -53,6 +53,16 @@ module Mobile
error!('401 Unauthorized', 401) if params[:private_token] != "hriEn3UwXfJs3PmyXnSG" error!('401 Unauthorized', 401) if params[:private_token] != "hriEn3UwXfJs3PmyXnSG"
end 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! def career_authenticate!
pass = request.path.include?("introduction") || request.path.include?("get_published_careers")|| request.path.include?("get_current_user") 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 return uw.user if uw
end 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 token = ApiKey.where(access_token: params[:token]).first
if token && !token.expired? if token && !token.expired?
return User.find(token.user_id) return User.find(token.user_id)
@ -160,6 +176,7 @@ module Mobile
mount Apis::Careers mount Apis::Careers
mount Apis::Assets mount Apis::Assets
mount Apis::Ecloud mount Apis::Ecloud
mount Apis::Cnmooc

@ -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

@ -207,6 +207,9 @@ class ApplicationController < ActionController::Base
elsif session[:wechat_openid] elsif session[:wechat_openid]
uw = UserWechat.find_by_openid(session[:wechat_openid]) uw = UserWechat.find_by_openid(session[:wechat_openid])
user = uw.user if uw 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
end end
if user.nil? && Setting.rest_api_enabled? && accept_api_auth? if user.nil? && Setting.rest_api_enabled? && accept_api_auth?

@ -104,6 +104,7 @@ class ExerciseBankController < ApplicationController
:question_type => params[:question_type] || 1, :question_type => params[:question_type] || 1,
:question_number => @exercise.exercise_bank_questions.count + 1, :question_number => @exercise.exercise_bank_questions.count + 1,
:question_score => params[:question_score], :question_score => params[:question_score],
:shixun_name => params[:question_type] == '5' ? params[:shixun_name] : nil,
:shixun_id => params[:shixun], :shixun_id => params[:shixun],
:max_choices => params[:max_choices].to_i || 0, :max_choices => params[:max_choices].to_i || 0,
:min_choices => params[:min_choices].to_i || 0 :min_choices => params[:min_choices].to_i || 0
@ -271,6 +272,7 @@ class ExerciseBankController < ApplicationController
end end
end end
if @exercise_question.question_type == 5 if @exercise_question.question_type == 5
@exercise_question.shixun_name = params[:shixun_name].strip if !params[:shixun_name].blank?
question_score = 0 question_score = 0
@exercise_question.exercise_bank_shixun_challenges.each_with_index do |challenge, index| @exercise_question.exercise_bank_shixun_challenges.each_with_index do |challenge, index|
challenge.question_score = params[:question_score][index] challenge.question_score = params[:question_score][index]

@ -372,6 +372,7 @@ class ExerciseController < ApplicationController
:question_type => params[:question_type] || 1, :question_type => params[:question_type] || 1,
:question_number => @exercise.exercise_questions.count + 1, :question_number => @exercise.exercise_questions.count + 1,
:question_score => params[:question_type] == '5' ? 0 : params[:question_score], :question_score => params[:question_type] == '5' ? 0 : params[:question_score],
:shixun_name => params[:question_type] == '5' ? params[:shixun_name] : nil,
:shixun_id => params[:shixun] :shixun_id => params[:shixun]
} }
@exercise_questions = @exercise.exercise_questions.new option @exercise_questions = @exercise.exercise_questions.new option
@ -512,6 +513,7 @@ class ExerciseController < ApplicationController
end end
end end
if @exercise_question.question_type == 5 if @exercise_question.question_type == 5
@exercise_question.shixun_name = params[:shixun_name].strip if !params[:shixun_name].blank?
question_score = 0 question_score = 0
@exercise_question.exercise_shixun_challenges.each_with_index do |challenge, index| @exercise_question.exercise_shixun_challenges.each_with_index do |challenge, index|
challenge.question_score = params[:question_score][index] challenge.question_score = params[:question_score][index]
@ -1508,7 +1510,8 @@ class ExerciseController < ApplicationController
:question_type => q[:question_type] || 1, :question_type => q[:question_type] || 1,
:question_number => q[:question_number], :question_number => q[:question_number],
:question_score => q[:question_score], :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 exercise_bank_question = exercise_bank.exercise_bank_questions.new option

@ -12,11 +12,12 @@ class HomeworkCommonController < ApplicationController
before_filter :find_homework, :only => [:edit,:update,:alert_anonymous_comment,:start_anonymous_comment,:stop_anonymous_comment,:destroy,:start_evaluation_set, before_filter :find_homework, :only => [:edit,:update,:alert_anonymous_comment,:start_anonymous_comment,:stop_anonymous_comment,:destroy,:start_evaluation_set,
:set_evaluation_attr,:score_rule_set,:alert_forbidden_anonymous_comment,:alert_open_student_works,:open_student_works, :set_evaluation_attr,:score_rule_set,:alert_forbidden_anonymous_comment,:alert_open_student_works,:open_student_works,
:set_score_open,:alert_score_open_modal,:add_to_homework_bank,:publish_notice,:publish_homework,:end_notice,:end_homework, :set_score_open,:alert_score_open_modal,:add_to_homework_bank,:publish_notice,:publish_homework,:end_notice,:end_homework,
:setting,:set_public,:homework_setting,:update_explanation,:cancel_publish, :homework_code_repeat, :review_detail,:move_to_category] :setting,:set_public,:homework_setting,:update_explanation,:cancel_publish, :homework_code_repeat, :review_detail,:move_to_category,
:rename_modal, :rename_homework]
before_filter :teacher_of_course, :only => [:new, :create, :edit, :update, :destroy, :start_anonymous_comment, :stop_anonymous_comment, :alert_anonymous_comment, before_filter :teacher_of_course, :only => [:new, :create, :edit, :update, :destroy, :start_anonymous_comment, :stop_anonymous_comment, :alert_anonymous_comment,
:start_evaluation_set,:set_evaluation_attr,:score_rule_set,:alert_forbidden_anonymous_comment,:alert_open_student_works, :start_evaluation_set,:set_evaluation_attr,:score_rule_set,:alert_forbidden_anonymous_comment,:alert_open_student_works,
:open_student_works,:add_to_homework_bank,:publish_notice,:end_notice,:publish_homework,:end_homework,:update_explanation, :open_student_works,:add_to_homework_bank,:publish_notice,:end_notice,:publish_homework,:end_homework,:update_explanation,
:cancel_publish, :move_to_category,:homework_setting] :cancel_publish, :move_to_category,:homework_setting, :rename_homework, :rename_modal]
# before_filter :member_of_course, :only => [:index,:setting] # before_filter :member_of_course, :only => [:index,:setting]
@ -275,6 +276,19 @@ class HomeworkCommonController < ApplicationController
@groups = paginateHelper @groups, 5 @groups = paginateHelper @groups, 5
end end
def rename_modal
end
def rename_homework
if params[:name].blank?
@notice = true
else
@homework.update_attributes(:name => params[:name].strip)
redirect_to homework_common_index_path(:course => @course.id, :homework_type => @homework.homework_type)
end
end
def setting def setting
@is_new = params[:is_new].to_i if params[:is_new] @is_new = params[:is_new].to_i if params[:is_new]
@is_empty = @homework.publish_time.nil? @is_empty = @homework.publish_time.nil?

@ -853,7 +853,7 @@ class ManagementsController < ApplicationController
def evaluate_simple def evaluate_simple
page = params[:page] page = params[:page]
@recodes = EvaluateRecord.where("created_at > ?", Time.now - 1.days).reorder("consume_time desc") @recodes = EvaluateRecord.where("created_at > ?", Time.now - 10000.days).reorder("consume_time desc")
@recodes_count = @recodes.size @recodes_count = @recodes.size
@record_pages = Paginator.new @recodes_count, 20, page || 1 @record_pages = Paginator.new @recodes_count, 20, page || 1
@offset ||= @record_pages.offset @offset ||= @record_pages.offset
@ -2023,7 +2023,7 @@ end
# @schools = School.where(:id =>user_exs.map(&:school_id)) # @schools = School.where(:id =>user_exs.map(&:school_id))
# end # end
@search = params[:search] # 搜索字 @search = params[:search] # 搜索字
@keyword = params[:keyword].blank? ? "u_name" : params[:keyword] # 根据姓名/课程名搜索 @keyword = params[:keyword].blank? ? "c_name" : params[:keyword] # 根据姓名/课程名搜索
@status = params[:status] @status = params[:status]
@school_id = params[:school_id] @school_id = params[:school_id]
@ -2044,11 +2044,13 @@ end
if params[:status] && params[:status]!='' if params[:status] && params[:status]!=''
@courses = @courses.where(:is_end => @status.to_i) @courses = @courses.where(:is_end => @status.to_i)
end end
if "u_name" == @keyword if "c_name" == @keyword
@courses = @courses.where("name like ?", "%#{@search}%")
elsif "u_name" == @keyword
if @search.blank? if @search.blank?
@courses = @courses @courses = @courses
else else
user_id = User.where("concat(lastname, firstname) like '%#{@search}%'") # user_id = User.where("concat(lastname, firstname) like '%#{@search}%'")
@courses = @courses.joins("join users u on courses.tea_id = u.id").where("concat(u.lastname, u.firstname) like '%#{@search}%'") @courses = @courses.joins("join users u on courses.tea_id = u.id").where("concat(u.lastname, u.firstname) like '%#{@search}%'")
end end
elsif "dep_name" == @keyword elsif "dep_name" == @keyword
@ -4183,7 +4185,7 @@ end
sheet1 = book.create_worksheet :name => "users" sheet1 = book.create_worksheet :name => "users"
blue = Spreadsheet::Format.new :color => :blue, :weight => :bold, :size => 10 blue = Spreadsheet::Format.new :color => :blue, :weight => :bold, :size => 10
sheet1.row(0).default_format = blue sheet1.row(0).default_format = blue
sheet1.row(0).concat(["用户姓名","性别","职业","职称","地区"," 单位","子单位","注册时间","最后登录时间","授权"]) sheet1.row(0).concat(["用户姓名","性别","职业","职称","地区"," 单位","子单位","注册时间","最后登录时间","授权", "邮箱"])
count_row = 1 count_row = 1
users.each do |user| users.each do |user|
sheet1[count_row,0] = user.try(:show_real_name) sheet1[count_row,0] = user.try(:show_real_name)
@ -4196,6 +4198,7 @@ end
sheet1[count_row,7] = format_time user.created_on sheet1[count_row,7] = format_time user.created_on
sheet1[count_row,8] = format_time user.last_login_on sheet1[count_row,8] = format_time user.last_login_on
sheet1[count_row,9] = user.trial_authorization sheet1[count_row,9] = user.trial_authorization
sheet1[count_row,10] = user.mail
count_row += 1 count_row += 1
end end
book.write xls_report book.write xls_report
@ -4293,7 +4296,7 @@ end
count_row = 1 count_row = 1
shixuns = Shixun.where(:id => shixun_ids).includes(discusses: [:user]) shixuns = Shixun.where(:id => shixun_ids).includes(discusses: [:user])
sheet1.row(0).concat(["序号", "实训ID", "实训名称", "实训作者", "作者单位", "评论数", "评论内容", "关卡", "评论者", "评论者职业", sheet1.row(0).concat(["序号", "实训ID", "实训名称", "实训作者", "作者单位", "评论数", "评论内容", "关卡", "评论者", "评论者职业",
"评论者单位", "评论时间", "社区导师是否已回复"]) "评论者单位", "评论时间", "社区导师是否已回复", "我的账号回复内容", "回复时间"])
shixuns.each_with_index do |shixun, i| shixuns.each_with_index do |shixun, i|
discusses = shixun.discusses.where("user_id != ?", 1) discusses = shixun.discusses.where("user_id != ?", 1)
if beginTime.present? if beginTime.present?
@ -4311,6 +4314,7 @@ end
discusses.each_with_index do |discuss, j| discusses.each_with_index do |discuss, j|
user = discuss.user user = discuss.user
content = discuss.content.gsub(/<img.*\/>/, "【图片评论】").gsub(/!\[\].+\)/, "【图片评论】") content = discuss.content.gsub(/<img.*\/>/, "【图片评论】").gsub(/!\[\].+\)/, "【图片评论】")
myself_discuss = discuss.children.where(user_id: User.current.id).last
sheet1[count_row, 6] = strip_html content sheet1[count_row, 6] = strip_html content
sheet1[count_row, 7] = "#{discuss.position}" sheet1[count_row, 7] = "#{discuss.position}"
sheet1[count_row, 8] = user.show_real_name sheet1[count_row, 8] = user.show_real_name
@ -4318,6 +4322,8 @@ end
sheet1[count_row, 10] = user.school_name sheet1[count_row, 10] = user.school_name
sheet1[count_row, 11] = format_time discuss.created_at sheet1[count_row, 11] = format_time discuss.created_at
sheet1[count_row, 12] = discuss.children.pluck(:user_id).include?(1) ? "" : "" 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 count_row += 1
end end
#count_row += 1 #count_row += 1

@ -117,7 +117,7 @@ class QuestionBanksController < ApplicationController
else else
@courses = User.current.courses.where("is_delete = 0 and is_end = 0").select{ |course| User.current.has_teacher_role(course)} @courses = User.current.courses.where("is_delete = 0 and is_end = 0").select{ |course| User.current.has_teacher_role(course)}
end 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] @search = params[:search]
respond_to do |format| respond_to do |format|
format.js format.js

@ -850,7 +850,7 @@ class ShixunsController < ApplicationController
begin begin
raise "请先绑定邮箱" if User.current.mail.blank? raise "请先绑定邮箱" if User.current.mail.blank?
new_shixun = Shixun.new new_shixun = Shixun.new
new_shixun.attributes = @shixun.attributes.dup.except("id","user_id","visits","gpid","status", "identifier", "homepage_show","git_url") new_shixun.attributes = @shixun.attributes.dup.except("id","user_id","visits","gpid","status", "identifier", "homepage_show","git_url", "propaedeutics")
new_shixun.user_id = User.current.id new_shixun.user_id = User.current.id
new_shixun.identifier = generate_identifier new_shixun.identifier = generate_identifier
new_shixun.status = 0 new_shixun.status = 0

@ -584,16 +584,16 @@ class StudentWorkController < ApplicationController
@stundet_works = @stundet_works.where(:work_status => @status) @stundet_works = @stundet_works.where(:work_status => @status)
end end
@stundet_works = search_work_member @stundet_works, @name
if @stundet_works.size != 0 if @stundet_works.size != 0
if @order == "student_id" if @order == "student_id"
@stundet_works = @stundet_works.includes(:user => {:user_extensions => []}).order("user_extensions.student_id #{@b_sort}") @stundet_works = @stundet_works.joins(:user => {:user_extensions => []}).order("user_extensions.student_id #{@b_sort}")
else else
@stundet_works = @stundet_works.order("#{@order} #{@b_sort}") @stundet_works = @stundet_works.order("#{@order} #{@b_sort}")
end end
end end
@stundet_works = search_work_member @stundet_works, @name
@score = @b_sort == "desc" ? "asc" : "desc" @score = @b_sort == "desc" ? "asc" : "desc"
# @is_focus = params[:is_focus] ? params[:is_focus].to_i : 0 # @is_focus = params[:is_focus] ? params[:is_focus].to_i : 0
# 消息传过来的ID # 消息传过来的ID
@ -615,6 +615,7 @@ class StudentWorkController < ApplicationController
_index _index
@stundet_works = paginateHelper @stundet_works, @limit @stundet_works = paginateHelper @stundet_works, @limit
@members = @course.members.select([:user_id, :course_group_id])
if @stundet_works.size != 0 if @stundet_works.size != 0
@stundet_works = if @homework.homework_type == 1 @stundet_works = if @homework.homework_type == 1
@stundet_works.includes(:student_works_scores, [user: :user_extensions]) @stundet_works.includes(:student_works_scores, [user: :user_extensions])
@ -623,7 +624,6 @@ class StudentWorkController < ApplicationController
elsif @homework.homework_type == 4 elsif @homework.homework_type == 4
@stundet_works.includes(:student_works_scores, [myshixun: :games], [user: :user_extensions]) @stundet_works.includes(:student_works_scores, [myshixun: :games], [user: :user_extensions])
end end
@members = @course.members.where(user_id: @stundet_works.pluck(:user_id)).select([:user_id, :course_group_id])
end end
respond_to do |format| respond_to do |format|
format.js format.js
@ -647,7 +647,7 @@ class StudentWorkController < ApplicationController
uid: "#{work.user.user_extensions.student_id}", uid: "#{work.user.user_extensions.student_id}",
downloadUrl: '' downloadUrl: ''
} }
attachment = work.attachments.first attachment = work.attachments.last
if attachment if attachment
o[:downloadUrl] = "https://#{Setting.host_name}/"+download_named_attachment_path(attachment.id, attachment.filename) o[:downloadUrl] = "https://#{Setting.host_name}/"+download_named_attachment_path(attachment.id, attachment.filename)
end end

@ -7034,7 +7034,8 @@ def quote_exercise_bank exercise, course
:question_type => q[:question_type] || 1, :question_type => q[:question_type] || 1,
:question_number => q[:question_number], :question_number => q[:question_number],
:question_score => q[:question_score], :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 exercise_question = new_exercise.exercise_questions.new option

@ -0,0 +1,8 @@
class CnmoocUser < UserSource
private
def email_prefix
'cnmooc_'
end
end

@ -269,6 +269,8 @@ class User < Principal
has_many :article_homepages, :dependent => :destroy has_many :article_homepages, :dependent => :destroy
has_many :competition_lists, :dependent => :destroy has_many :competition_lists, :dependent => :destroy
has_one :user_source
## end ## end
# default_scope -> { includes(:user_extensions, :user_score) } # default_scope -> { includes(:user_extensions, :user_score) }

@ -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

@ -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

@ -224,7 +224,8 @@
to_relate.attributes = relate.attributes.except('id', 'ec_course_achievement_method_id', 'ec_course_target_id', to_relate.attributes = relate.attributes.except('id', 'ec_course_achievement_method_id', 'ec_course_target_id',
'ec_course_evaluation_subitem_id', 'created_at', 'updated_at') 'ec_course_evaluation_subitem_id', 'created_at', 'updated_at')
to_relate.ec_course_target_id = course_target_map[relate.ec_course_target_id] to_relate.ec_course_target_id = course_target_map[relate.ec_course_target_id]
to_relate.ec_course_evaluation_subitem_id = course_target_map[relate.ec_course_evaluation_subitem_id] # 可能不存在,所以为 -1
to_relate.ec_course_evaluation_subitem_id = course_evaluation_subitem_map[relate.ec_course_evaluation_subitem_id] || -1
to_relate.save! to_relate.save!
achievement_evaluation_relates_map[relate.id] = to_relate.id achievement_evaluation_relates_map[relate.id] = to_relate.id

@ -371,7 +371,8 @@ class GamesService
end end
if content != last_content if content != last_content
content_modified = 1 content_modified = 1
code_file = @g.edit_file(@myshixun.gpid, current_user.login, :content => content, :file_path => path, :branch_name => "master", :commit_message => "auto commit") code_file = @g.edit_file(@myshixun.gpid, current_user.login, :content => content, :file_path => path, :branch_name => "master",
:commit_message => (params[:evaluate] == 1 ? "commit by author" : "auto commit" ))
end end
# REDO是否有读写分离的问题 # REDO是否有读写分离的问题
if record.present? if record.present?
@ -801,6 +802,7 @@ class GamesService
# 轮询获取状态 # 轮询获取状态
# resubmit是在file_update中生成的从game_build中传入的 # resubmit是在file_update中生成的从game_build中传入的
def game_status params, current_user def game_status params, current_user
Rails.logger.info("sec_key is #{params[:sec_key]}**1")
game = Game.find_by_identifier(params[:identifier]) game = Game.find_by_identifier(params[:identifier])
resubmit_identifier = game.resubmit_identifier resubmit_identifier = game.resubmit_identifier
# 如果没有超时并且正在评测中 # 如果没有超时并且正在评测中
@ -812,6 +814,7 @@ class GamesService
return {:running_code_status => running_code_status, :running_code_message => running_code_message} return {:running_code_status => running_code_status, :running_code_message => running_code_message}
end end
Rails.logger.info("sec_key is #{params[:sec_key]}**2")
Rails.logger.info("##### resubmit_identifier is #{resubmit_identifier}") Rails.logger.info("##### resubmit_identifier is #{resubmit_identifier}")
port = params[:port] port = params[:port]
score = 0 score = 0
@ -838,6 +841,7 @@ class GamesService
end end
end end
Rails.logger.info("sec_key is #{params[:sec_key]}**3")
# 实训的最大评测次数,这个值是为了优化查询,每次只取最新的最新一次评测的结果集 # 实训的最大评测次数,这个值是为了优化查询,每次只取最新的最新一次评测的结果集
max_query_index = game.query_index - 1 max_query_index = game.query_index - 1
# 区分评测过未评测过,未评测过按需求取数据 # 区分评测过未评测过,未评测过按需求取数据
@ -854,7 +858,7 @@ class GamesService
# 能进入到此处肯定是已经返回了结果也就是说outputs中肯定有了数据 # 能进入到此处肯定是已经返回了结果也就是说outputs中肯定有了数据
Rails.logger.info("sec_key is #{params[:sec_key]}**4")
test_sets_count = qurey_test_sets.size test_sets_count = qurey_test_sets.size
# had_test = Output.where(:game_id => game.id, :query_index => max_query_index) # had_test = Output.where(:game_id => game.id, :query_index => max_query_index)
# had_test_count = had_test.count # had_test_count = had_test.count
@ -881,6 +885,7 @@ class GamesService
web_route = game_challenge.try(:web_route) web_route = game_challenge.try(:web_route)
mirror_name = shixun.mirror_name mirror_name = shixun.mirror_name
Rails.logger.info("sec_key is #{params[:sec_key]}**5")
# 轮询结束,更新评测耗时 # 轮询结束,更新评测耗时
e_record = EvaluateRecord.where(:identifier => params[:sec_key]).first e_record = EvaluateRecord.where(:identifier => params[:sec_key]).first
if game_status == 0 || game_status == 2 if game_status == 0 || game_status == 2
@ -898,12 +903,14 @@ class GamesService
# 实训制作者当前拥有的金币 # 实训制作者当前拥有的金币
grade = User.where(:id => game.user_id).pluck(:grade).first grade = User.where(:id => game.user_id).pluck(:grade).first
Rails.logger.info("sec_key is #{params[:sec_key]}**6")
# 高性能取上一关、下一关 # 高性能取上一关、下一关
prev_game = Game.prev_identifier(shixun.id, game.myshixun_id, game_challenge.position) prev_game = Game.prev_identifier(shixun.id, game.myshixun_id, game_challenge.position)
next_game = Game.next_game(shixun.id, game.myshixun_id, game_challenge.position).try(:identifier) next_game = Game.next_game(shixun.id, game.myshixun_id, game_challenge.position).try(:identifier)
output_hash = {:test_sets => test_sets, :had_test_count => test_sets_count, :test_sets_count => test_sets_count, :had_passed_testsests_error_count => had_passed_testsests_error_count} output_hash = {:test_sets => test_sets, :had_test_count => test_sets_count, :test_sets_count => test_sets_count, :had_passed_testsests_error_count => had_passed_testsests_error_count}
Rails.logger.info("sec_key is #{params[:sec_key]}**7")
return {:grade => grade, :gold => score, :experience => experience, :status => game_status, :had_done => had_done, return {:grade => grade, :gold => score, :experience => experience, :status => game_status, :had_done => had_done,
:position => game_challenge.position, :port => port, :power => power, :record => record, :position => game_challenge.position, :port => port, :power => power, :record => record,
:mirror_name => mirror_name, :picture => picture, :web_route => web_route, :latest_output => latest_output, :mirror_name => mirror_name, :picture => picture, :web_route => web_route, :latest_output => latest_output,

@ -1 +1 @@
<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no"><meta name="theme-color" content="#000000"><meta name="renderer" content="webkit"/><meta name="force-rendering" content="webkit"/><meta http-equiv="X-UA-Compatible" content="IE=edge"/><link rel="manifest" href="/manifest.json"><link rel="shortcut icon" href="/favicon.ico"><title>Educoder</title><script type="text/javascript">window.__isR=!0</script><link rel="stylesheet" href="/react/build/css/css_min_all.css"><link rel="stylesheet" href="/assets/iconfont/iconfont.css"><link href="/react/build/./static/css/main.ce4a97cd.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="md_div" style="display:none"></div><div id="root" class="page -layout-v -fit"></div><div id="picture_display" style="display:none"></div><script type="text/javascript" src="/react/build/js/js_min_all.js"></script><script type="text/javascript" src="/assets/kindeditor/kindeditor.js"></script><script type="text/javascript" src="/react/build/js/create_kindeditor.js"></script><script type="text/javascript" src="/javascripts/educoder/edu_application.js"></script><script type="text/javascript" src="/react/build/./static/js/main.8545f40f.js"></script></body></html> <!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no"><meta name="theme-color" content="#000000"><meta name="renderer" content="webkit"/><meta name="force-rendering" content="webkit"/><meta http-equiv="X-UA-Compatible" content="IE=edge"/><link rel="manifest" href="/manifest.json"><link rel="shortcut icon" href="/favicon.ico"><title>Educoder</title><script type="text/javascript">window.__isR=!0</script><link rel="stylesheet" href="/react/build/css/css_min_all.css"><link rel="stylesheet" href="/assets/iconfont/iconfont.css"><link href="/react/build/./static/css/main.0568ccaf.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="md_div" style="display:none"></div><div id="root" class="page -layout-v -fit"></div><div id="picture_display" style="display:none"></div><script type="text/javascript" src="/react/build/js/js_min_all.js"></script><script type="text/javascript" src="/assets/kindeditor/kindeditor.js"></script><script type="text/javascript" src="/react/build/js/create_kindeditor.js"></script><script type="text/javascript" src="/javascripts/educoder/edu_application.js"></script><script type="text/javascript" src="/react/build/./static/js/main.dfa4489a.js"></script></body></html>

@ -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|%> <%= form_for("",:url => update_exercise_question_exercise_index_path(:exercise_question => exercise_question.id),:html => {:id => "update_exercise_question_#{exercise_question.id}"}) do |f|%>
<div class="user_bg_shadow bor-grey-e pl15 pr30 mb20 fillin_Temp" id="poll_answers_<%= exercise_question.id %>"> <div class="user_bg_shadow bor-grey-e pl15 pr30 mb20 fillin_Temp" id="poll_answers_<%= exercise_question.id %>">
<p class="fl mt15 font-16 mb10">实训题</p> <p class="fl mt15 font-16 mb10">实训题</p>
<p class="clearfix mb10" style="margin-left: 78px;"><%= exercise_question.shixun.name %></p> <p class="clearfix mb10">
<label class="panel-form-label fl"><span class="mr10">标题</span></label>
<textarea class="panel-form-width2-690 fl panel-box-sizing" maxlength="100" name='shixun_name' id="poll_questions_name_<%=exercise_question.id %>" placeholder="请输入实训标题"><%= exercise_question.shixun_name %></textarea>
</p>
<li class="clearfix pr mb20"> <li class="clearfix pr mb20">
<input name="question_type" value="5" type="hidden"> <input name="question_type" value="5" type="hidden">
<label class="panel-form-label fl"><span class="mr10">要求</span></label> <label class="panel-form-label fl"><span class="mr10">要求</span></label>

@ -106,11 +106,15 @@
//修改标题时确定按钮 //修改标题时确定按钮
function edit_poll_question(doc,id,quest_type) 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 title = $.trim($("#poll_questions_title_" + id).val());
var score = $.trim($("#poll_question_score_"+ id).val()); var score = $.trim($("#poll_question_score_"+ id).val());
var standard_ans = $.trim($("#exercise_choice_" + id).val()); var standard_ans = $.trim($("#exercise_choice_" + id).val());
if(name===""){
notice_box("题目标题不能为空");
}
if(title.length == 0 || score.length == 0){ if(title.length == 0 || score.length == 0){
notice_box("题目标题/分数不能为空"); notice_box("要求/分数不能为空");
}else if(!/^[1-9][0-9]*$/.test(score)) { }else if(!/^[1-9][0-9]*$/.test(score)) {
notice_box("分数必须是非零开头的数字"); notice_box("分数必须是非零开头的数字");
}else if(quest_type !=3 && quest_type !=4 && standard_ans.length == 0) { }else if(quest_type !=3 && quest_type !=4 && standard_ans.length == 0) {

@ -162,7 +162,7 @@
<% end %> <% end %>
</div> </div>
<% if exercise_question.question_type == 5 %> <% if exercise_question.question_type == 5 %>
<p class="pl15 pr15 mb10"><%= exercise_question.shixun.name %></p> <p class="pl15 pr15 mb10"><%= exercise_question.shixun_name %></p>
<% end %> <% end %>
<div class="pl15 pr15 justify upload_img table_maxWidth break_word"><%= exercise_question.question_title.html_safe %></div> <div class="pl15 pr15 justify upload_img table_maxWidth break_word"><%= exercise_question.question_title.html_safe %></div>
<% case exercise_question.question_type %> <% case exercise_question.question_type %>

@ -140,7 +140,7 @@
<% end %> <% end %>
</div> </div>
<% if exercise_question.question_type == 5 %> <% if exercise_question.question_type == 5 %>
<p class="pl15 pr15 mb10"><%= exercise_question.shixun.name %></p> <p class="pl15 pr15 mb10"><%= exercise_question.shixun_name %></p>
<% end %> <% end %>
<div class="pl15 pr15 justify upload_img table_maxWidth break_word"><%= exercise_question.question_title.html_safe %></div> <div class="pl15 pr15 justify upload_img table_maxWidth break_word"><%= exercise_question.question_title.html_safe %></div>
<% case exercise_question.question_type %> <% case exercise_question.question_type %>

@ -8,7 +8,10 @@
<input name="question_type" value="5" type="hidden"> <input name="question_type" value="5" type="hidden">
<input name="shixun" value="<%= @shixun.id %>" type="hidden"> <input name="shixun" value="<%= @shixun.id %>" type="hidden">
<input name="quest_id" id="quest_id" value="0" type="hidden"> <input name="quest_id" id="quest_id" value="0" type="hidden">
<p class="clearfix mb10" style="margin-left: 78px;"><%= @shixun.name %></p> <p class="clearfix mb10">
<label class="panel-form-label fl"><span class="mr10">标题</span></label>
<textarea class="panel-form-width2-690 fl panel-box-sizing" maxlength="100" name='shixun_name' id="poll_questions_name" placeholder="请输入实训标题"><%= @shixun.name %></textarea>
</p>
<li class="clearfix pr mb20"> <li class="clearfix pr mb20">
<label class="panel-form-label fl"><span class="mr10">要求</span></label> <label class="panel-form-label fl"><span class="mr10">要求</span></label>
<textarea id="poll_questions_title" name="question_title" class="panel-form-width2-690 fl panel-box-sizing undis"></textarea> <textarea id="poll_questions_title" name="question_title" class="panel-form-width2-690 fl panel-box-sizing undis"></textarea>

@ -16,7 +16,7 @@
</p> </p>
<% end %> <% end %>
</div> </div>
<p class="pl15 pr15 mb10"><%= exercise_question.shixun.name %></p> <p class="pl15 pr15 mb10"><%= exercise_question.shixun_name %></p>
<div class="pl15 pr15 justify upload_img table_maxWidth break_word"><%= exercise_question.question_title.html_safe %></div> <div class="pl15 pr15 justify upload_img table_maxWidth break_word"><%= exercise_question.question_title.html_safe %></div>
<div class="pl15 pr15 pt10 pb10 bor-top-greyE"> <div class="pl15 pr15 pt10 pb10 bor-top-greyE">
<% exercise_question.exercise_shixun_challenges.each_with_index do |exercise_challenge,index| %> <% exercise_question.exercise_shixun_challenges.each_with_index do |exercise_challenge,index| %>

@ -256,7 +256,7 @@
<% end %> <% end %>
</div> </div>
<% if exercise_question.question_type == 5 %> <% if exercise_question.question_type == 5 %>
<p class="pl15 pr15 mb10"><%= exercise_question.shixun.name %></p> <p class="pl15 pr15 mb10"><%= exercise_question.shixun_name %></p>
<% end %> <% end %>
<div class="pl15 pr15 justify upload_img table_maxWidth break_word"> <div class="pl15 pr15 justify upload_img table_maxWidth break_word">
<%= exercise_question.question_title.html_safe %> <%= exercise_question.question_title.html_safe %>

@ -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|%> <%= 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|%>
<div class="user_bg_shadow bor-grey-e pl15 pr30 mb20 fillin_Temp" id="poll_answers_<%= exercise_question.id %>"> <div class="user_bg_shadow bor-grey-e pl15 pr30 mb20 fillin_Temp" id="poll_answers_<%= exercise_question.id %>">
<p class="fl mt15 font-16 mb10">实训题</p> <p class="fl mt15 font-16 mb10">实训题</p>
<p class="clearfix mb10" style="margin-left: 78px;"><%= exercise_question.shixun.name %></p> <p class="clearfix mb10">
<label class="panel-form-label fl"><span class="mr10">标题</span></label>
<textarea class="panel-form-width2-690 fl panel-box-sizing" maxlength="100" name='shixun_name' id="poll_questions_name_<%=exercise_question.id %>" placeholder="请输入实训标题"><%= exercise_question.shixun_name %></textarea>
</p>
<li class="clearfix pr mb20"> <li class="clearfix pr mb20">
<input name="question_type" value="5" type="hidden"> <input name="question_type" value="5" type="hidden">
<label class="panel-form-label fl"><span class="mr10">要求</span></label> <label class="panel-form-label fl"><span class="mr10">要求</span></label>

@ -8,7 +8,10 @@
<input name="question_type" value="5" type="hidden"> <input name="question_type" value="5" type="hidden">
<input name="shixun" value="<%= @shixun.id %>" type="hidden"> <input name="shixun" value="<%= @shixun.id %>" type="hidden">
<input name="quest_id" id="quest_id" value="0" type="hidden"> <input name="quest_id" id="quest_id" value="0" type="hidden">
<p class="clearfix mb10" style="margin-left: 78px;"><%= @shixun.name %></p> <p class="clearfix mb10">
<label class="panel-form-label fl"><span class="mr10">标题</span></label>
<textarea class="panel-form-width2-690 fl panel-box-sizing" maxlength="100" name='shixun_name' id="poll_questions_name" placeholder="请输入实训标题"><%= @shixun.name %></textarea>
</p>
<li class="clearfix pr mb20"> <li class="clearfix pr mb20">
<label class="panel-form-label fl"><span class="mr10">要求</span></label> <label class="panel-form-label fl"><span class="mr10">要求</span></label>
<textarea id="poll_questions_title" name="question_title" class="panel-form-width2-690 fl panel-box-sizing undis"></textarea> <textarea id="poll_questions_title" name="question_title" class="panel-form-width2-690 fl panel-box-sizing undis"></textarea>

@ -14,7 +14,7 @@
<a href="javascript:void(0)" onclick="exQuestionEdit(<%= exercise_question.id%>, <%= exercise_question.question_type %>);"><i data-tip-down="编辑" class="fa fa-pencil color-orange05"></i></a> <a href="javascript:void(0)" onclick="exQuestionEdit(<%= exercise_question.id%>, <%= exercise_question.question_type %>);"><i data-tip-down="编辑" class="fa fa-pencil color-orange05"></i></a>
</p> </p>
</div> </div>
<p class="pl15 pr15 mb10"><%= exercise_question.shixun.name %></p> <p class="pl15 pr15 mb10"><%= exercise_question.shixun_name %></p>
<div class="pl15 pr15 justify upload_img table_maxWidth break_word"><%= exercise_question.question_title.html_safe %></div> <div class="pl15 pr15 justify upload_img table_maxWidth break_word"><%= exercise_question.question_title.html_safe %></div>
<div class="pl15 pr15 pt10 pb10 bor-top-greyE"> <div class="pl15 pr15 pt10 pb10 bor-top-greyE">
<% exercise_question.exercise_bank_shixun_challenges.each_with_index do |exercise_challenge,index| %> <% exercise_question.exercise_bank_shixun_challenges.each_with_index do |exercise_challenge,index| %>

@ -80,7 +80,7 @@
<% end %> <% end %>
</div> </div>
<% if exercise_question.question_type == 5 %> <% if exercise_question.question_type == 5 %>
<p class="pl15 pr15 mb10"><%= exercise_question.shixun.name %></p> <p class="pl15 pr15 mb10"><%= exercise_question.shixun_name %></p>
<% end %> <% end %>
<div class="pl15 pr15 justify upload_img table_maxWidth break_word"><%= exercise_question.question_title.html_safe %></div> <div class="pl15 pr15 justify upload_img table_maxWidth break_word"><%= exercise_question.question_title.html_safe %></div>
<% case exercise_question.question_type %> <% case exercise_question.question_type %>

@ -31,4 +31,17 @@
</div> </div>
</div> </div>
</div> </div>
</div> </div>
<script>
function search_hw_course(url){
$.ajax({
url: url,
type: 'post',
data: {search: $("#hb_search_course_input").val(), is_observe: true},
success: function(data){
}
});
}
</script>

@ -11,7 +11,8 @@
<div class="fl task-form-100 clearfix" style="box-sizing: border-box; padding-left: 15px;"> <div class="fl task-form-100 clearfix" style="box-sizing: border-box; padding-left: 15px;">
<span class="fl mr10 mt3 color-grey3"># <%= get_hw_index(homework_common, @is_teacher, @homework_type) + 1 %></span> <span class="fl mr10 mt3 color-grey3"># <%= get_hw_index(homework_common, @is_teacher, @homework_type) + 1 %></span>
<% homework_curr_status = homework_curr_time(homework_common) %> <% homework_curr_status = homework_curr_time(homework_common) %>
<%= link_to homework_common.name.to_s, student_work_index_path(:homework => homework_common.id,:host=> Setting.host_course), :class => "edu-class-inner-list fl color-grey-3"%> <%= link_to homework_common.name.to_s, student_work_index_path(:homework => homework_common.id,:host=> Setting.host_course),
:id => "homework_name_#{homework_common.id}", :class => "edu-class-inner-list fl color-grey-3"%>
<% unless homework_common.is_public %> <% unless homework_common.is_public %>
<i id="homework_public_<%= homework_common.id %>" class="fa fa-lock color-grey-c fl mt8 ml15 font-18"></i> <i id="homework_public_<%= homework_common.id %>" class="fa fa-lock color-grey-c fl mt8 ml15 font-18"></i>
<% end %> <% end %>
@ -144,6 +145,9 @@
<li> <li>
<%= link_to "设置", student_work_index_path(:homework => homework_common.id, :tab => 4) %> <%= link_to "设置", student_work_index_path(:homework => homework_common.id, :tab => 4) %>
</li> </li>
<li>
<%= link_to "重命名", rename_modal_homework_common_path(homework_common), :remote => true %>
</li>
<% if homework_common.homework_detail_manual.try(:comment_status) == 0 %> <% if homework_common.homework_detail_manual.try(:comment_status) == 0 %>
<li> <li>
<%= link_to '立即发布', publish_notice_homework_common_path(homework_common), :remote => true %> <%= link_to '立即发布', publish_notice_homework_common_path(homework_common), :remote => true %>

@ -0,0 +1,30 @@
<div class="task-popup" style="width:460px;">
<div class=" task-popup-title clearfix task-popup-bggrey">
重命名
</div>
<div class="task_popup_con">
<%= form_for "", :url => rename_homework_homework_common_path(@homework), :remote => true, :html => {:id => "rename_shixun_homework_form"} do |f| %>
<div class="df pl20 pr20 mb20 mt10">
<span class="fl pt3">作业名称:</span>
<div class="flex1">
<input type="text" class="input-100-35 greyInput" maxlength="20" value="<%= @homework.name %>" name="name" id="rename_homework_name" placeholder="请输入作业名称"/>
<p class="lineh-20" style="height: 20px;"><span class="color-orange-tip none" id="printNotice">请输入作业名称</span></p>
</div>
</div>
<% end %>
<li class="clearfix mt10 edu-txt-center">
<a href="javascript:void(0);" class="task-btn mr20" onclick="hideModal()">取消</a>
<a href="javascript:void(0);" class="task-btn task-btn-orange" onclick="surePutIn();">确定</a>
</li>
</div>
</div>
<script>
function surePutIn(){
if($("#rename_homework_name").val() == "") {
$("#printNotice").removeClass("none");
} else {
$("#rename_shixun_homework_form").submit();
hideModal();
}
}
</script>

@ -0,0 +1,5 @@
<% if @notice %>
notice_box("作业名称不能为空");
<% else %>
$("#homework_name_<%= @homework.id %>").html(<%= @homework.name %>);
<% end %>

@ -0,0 +1,2 @@
var html = '<%= escape_javascript(render :partial => "homework_common/rename_shixun_homework") %>';
pop_box_new(html, 460, 227);

@ -14,6 +14,7 @@
</div> </div>
<select class="task-form-15 task-height-30 fl" style="margin:0px 0px 0px 25px;width: 11%" name="keyword" id="condition_status"> <select class="task-form-15 task-height-30 fl" style="margin:0px 0px 0px 25px;width: 11%" name="keyword" id="condition_status">
<option value="c_name">课堂名称搜索</option>
<option value="u_name">创建者姓名搜索</option> <option value="u_name">创建者姓名搜索</option>
<option value="dep_name">创建者单位搜索</option> <option value="dep_name">创建者单位搜索</option>
</select> </select>

@ -1,54 +1,30 @@
<% if false %>
<style>
.manage_ol ol li{list-style-type: disc;}
</style>
<div class="task-popup" style="width:400px;">
<div class=" task-popup-title clearfix task-popup-bggrey">
<h3 class="fl ">耗时详情</h3>
<a href="javascript:void(0)" id="closeIcon" style="top: -48px;right: -20px;z-index: 100000;"><i class="iconfont icon-shanchudiao"></i></a>
</div>
<div class="task_popup_con manage_ol">
<ol class="pl30">
<li>总耗时:<%= @consume_time %></li>
<li>作品更新:<%= @student_work %></li>
<li>文件更新:<%= @file_update %></li>
<li>中间层总耗时:<%= @brige %></li>
<li class="ml15">pull代码<%= @git_pull %></li>
<li class="ml15">pod启动<%= @create_pod %></li>
<li class="ml15">pod执行<%= @pod_execute %></li>
<li>中间层回传:<%= @return_back %>--中间层出结果传Educoder</li>
<li>前端轮询:<%= @front_js %>--局部数据查询Js轮询</li>
<li>回调结果存储:<%= @test_cases %></li>
</ol>
</div>
</div>
<% end %>
<% if @recodes.present? %> <% if @recodes.present? %>
<div class="edu-con-bg01 mt15" id="evaluate_records_list"> <div class="edu-con-bg01 mt15" id="evaluate_records_list">
<table class="edu-pop-table edu-txt-center" cellpadding="0" cellspacing="0" style="table-layout: fixed"> <table class="edu-pop-table edu-txt-center" cellpadding="0" cellspacing="0" style="table-layout: fixed">
<thead> <thead>
<tr> <tr>
<th width="5%">序号</th> <th width="5%">ID</th>
<th width="10%">总耗时<i class="fa fa-long-arrow-down color-light-green ml5" ></i></th> <th width="5%">总耗时<i class="fa fa-long-arrow-down color-light-green ml5" ></i></th>
<th width="5%">作品更新</th> <th width="5%">作品更新</th>
<th width="5%">文件更新</th> <th width="5%">文件更新</th>
<th width="10%">中间层总耗时</th> <th width="10%">中间层总耗时</th>
<th width="5%">pull代码</th> <th width="5%">pull代码</th>
<th width="5%">pod启动</th> <th width="5%">pod启动</th>
<th width="5%">pod执行</th> <th width="5%">pod执行</th>
<th width="10%">中间层回传</th> <th width="5%">回传时间</th>
<th width="5%">前端轮询</th> <th width="5%">前端轮询</th>
<th width="10%">回调结果存储</th> <th width="5%">结果存储</th>
<th width="15%">创建时间</th> <th width="10%">创建时间</th>
<th width="15%">实训名称</th> <th width="5%">最大执行时间</th>
<th width="8%">唯一标识</th>
<th width="17%">实训名称</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<% @recodes.each_with_index do |record, index| %> <% @recodes.each do |record| %>
<tr> <tr>
<td><%= index %></td> <td><%= record.id %></td>
<td><%= record.consume_time %></td> <td><%= record.consume_time %></td>
<td><%= record.student_work %></td> <td><%= record.student_work %></td>
<td><%= record.file_update %></td> <td><%= record.file_update %></td>
@ -60,6 +36,8 @@
<td><%= record.front_js %></td> <td><%= record.front_js %></td>
<td><%= record.test_cases %></td> <td><%= record.test_cases %></td>
<td><%= format_time record.created_at %></td> <td><%= format_time record.created_at %></td>
<td><%= record.shixun.try(:exec_time) %></td>
<td><%= record.shixun.try(:identifier) %></td>
<td><%= link_to record.shixun.try(:name), task_path(record.game), :target => "_blank", :title => "#{record.shixun.try(:name)}" %></td> <td><%= link_to record.shixun.try(:name), task_path(record.game), :target => "_blank", :title => "#{record.shixun.try(:name)}" %></td>
</tr> </tr>
<% end %> <% end %>

@ -1,3 +1,4 @@
<div class="edu-back-white mb10"> <div class="edu-back-white mb10">
<div class="pt30 pl20 pr20 pb40 bor-bottom-greyE clearfix"> <div class="pt30 pl20 pr20 pb40 bor-bottom-greyE clearfix">
<span class="fl font-16">配置</span> <span class="fl font-16">配置</span>

@ -199,14 +199,11 @@
<a href="javascript:void(0);" id="status_no_limit" class="<%= @status.blank? ? 'check_on' : '' %> pl10 pr10">不限</a> <a href="javascript:void(0);" id="status_no_limit" class="<%= @status.blank? ? 'check_on' : '' %> pl10 pr10">不限</a>
</span> </span>
<input id="work_status_1" class="magic-checkbox fl" type="checkbox" value="0" name="status[]" <%= !@status.blank? && @status.include?('0') ? 'checked' : '' %>> <input id="work_status_1" class="magic-checkbox fl" type="checkbox" value="0" name="status[]" <%= !@status.blank? && @status.include?('0') ? 'checked' : '' %>>
<label for="work_status_1" class="fl mr25">未提交(<%= @all_student_works.where(:work_status => 0).count %> <label for="work_status_1" class="fl mr25">未提交(<%= @all_student_works.where(:work_status => 0).count %>)</label>
)</label>
<input id="work_status_2" class="magic-checkbox fl" type="checkbox" value="1" name="status[]" <%= !@status.blank? && @status.include?('1') ? 'checked' : '' %>> <input id="work_status_2" class="magic-checkbox fl" type="checkbox" value="1" name="status[]" <%= !@status.blank? && @status.include?('1') ? 'checked' : '' %>>
<label for="work_status_2" class="fl mr25">按时提交(<%= student_works.where(:work_status => 1).count %> <label for="work_status_2" class="fl mr25">按时提交(<%= student_works.where(:work_status => 1).count %>)</label>
)</label>
<input id="work_status_3" class="magic-checkbox fl" type="checkbox" value="2" name="status[]" <%= !@status.blank? && @status.include?('2') ? 'checked' : '' %>> <input id="work_status_3" class="magic-checkbox fl" type="checkbox" value="2" name="status[]" <%= !@status.blank? && @status.include?('2') ? 'checked' : '' %>>
<label for="work_status_3" class="fl mr25">延时提交(<%= student_works.where(:work_status => 2).count %> <label for="work_status_3" class="fl mr25">延时提交(<%= student_works.where(:work_status => 2).count %>)</label>
)</label>
</li> </li>
<li class="clearfix"> <li class="clearfix">

@ -1103,6 +1103,8 @@ RedmineApp::Application.routes.draw do ## oauth相关
match 'move_to_category', :via => [:get,:post] match 'move_to_category', :via => [:get,:post]
match 'homework_code_repeat', :via => [:get,:post] match 'homework_code_repeat', :via => [:get,:post]
get 'review_detail' get 'review_detail'
post 'rename_homework'
get 'rename_modal'
end end
collection do collection do

@ -0,0 +1,8 @@
class ModifyExecTimeForShixun < ActiveRecord::Migration
def up
change_column(:shixuns, :exec_time, :integer, :default => 20)
end
def down
end
end

@ -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

@ -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

@ -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(){ function submit_send_hb_to_course(){
if($("input[name='course_id']:checked").length >= 1){ if($("input[name='course_id']:checked").length >= 1){
$("#search_course_notice_h").html("").hide(); $("#search_course_notice_h").html("").hide();

@ -1103,6 +1103,15 @@ function add_ex_question(doc,quest_type)
var title = $.trim($("#poll_questions_title").val()); var title = $.trim($("#poll_questions_title").val());
var score = $.trim($("#question_score").val()); var score = $.trim($("#question_score").val());
var standard_ans = $.trim($("#exercise_choice_" + quest_type).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(title.length == 0){
if(quest_type != 5){ if(quest_type != 5){
notice_box("题目标题不能为空"); notice_box("题目标题不能为空");
@ -1414,6 +1423,13 @@ function edit_poll_question(doc,id,quest_type) {
var title = $.trim($("#poll_questions_title_" + id).val()); var title = $.trim($("#poll_questions_title_" + id).val());
var score = $.trim($("#poll_question_score_" + id).val()); var score = $.trim($("#poll_question_score_" + id).val());
var standard_ans = $.trim($("#exercise_choice_" + 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 (title.length == 0) {
if (quest_type != 5) { if (quest_type != 5) {
notice_box("题目标题不能为空"); notice_box("题目标题不能为空");

@ -323,7 +323,7 @@ class ecStudentList extends Component {
schooldata={schooldata} schooldata={schooldata}
ecpath={this.state.ecComponentState} ecpath={this.state.ecComponentState}
/> />
<div className="clearfix padding20-30 bor-bottom-greyE mb10 mt10 edu-back-white"> <div className="clearfix padding20-30 bor-bottom-greyE mb10 edu-back-white">
<span className="fl font-18 courseSystem ">学生列表</span> <span className="fl font-18 courseSystem ">学生列表</span>
<a className="fr font-15 courseSystem" onClick={this.windowsgoblack}>返回</a> <a className="fr font-15 courseSystem" onClick={this.windowsgoblack}>返回</a>
</div> </div>

@ -22,6 +22,8 @@
} }
#traningNav>li>.ecTitles { #traningNav>li>.ecTitles {
line-height: 16px !important; line-height: 16px !important;
height: 18px!important;
width: 18px!important;
} }
#traningNav>li>.ecTitlefont:hover{ #traningNav>li>.ecTitlefont:hover{

@ -74,7 +74,7 @@ em.vertical-line{display: inline-block;width: 2px;background: #999;height: 10px}
.moreitem{position: absolute;right: 5px;top:35px;height: 15px;color:#656565} .moreitem{position: absolute;right: 5px;top:35px;height: 15px;color:#656565}
/*块状列表*/ /*块状列表*/
.square-list{width: 100%;box-sizing: border-box;margin-top:20px} .square-list{width: 100%;box-sizing: border-box;margin-top:20px}
.square-Item{position: relative;width:280px;margin-right: 26px;margin-bottom: 26px;float: left;border-radius: 6px;background-color:#fff;box-shadow: 0px 0px 12px rgba(0,0,0,0.1); height: 301px;} .square-Item{position: relative;width:280px;margin-right: 26px;margin-bottom: 26px;float: left;border-radius: 6px;background-color:#fff;box-shadow: 0px 0px 12px rgba(0,0,0,0.1); min-height: 301px;}
.square-Item:hover{bottom: 3px; box-shadow: 0px 0px 12px rgba(0,0,0,0.3);} .square-Item:hover{bottom: 3px; box-shadow: 0px 0px 12px rgba(0,0,0,0.3);}
.square-Item:hover .closeSquare{display: block} .square-Item:hover .closeSquare{display: block}
.square-Item:nth-child(4n+0){margin-right: 0px;} .square-Item:nth-child(4n+0){margin-right: 0px;}

Loading…
Cancel
Save