Merge branch 'educoder' into develop

dev_haigong
huang 6 years ago
commit cc061a04ea

@ -1,4 +1,4 @@
source 'http://gems.ruby-china.com'
source 'https://gems.ruby-china.com'
unless RUBY_PLATFORM =~ /w32/
# unix-like only

@ -1132,7 +1132,7 @@ class AccountController < ApplicationController
reward_grade(@user, @user.id, 'Phone', 500)
else
@user.update_attributes!(:mail => params[:value])
Gitlab.client.edit_user_email(@user.gid, :email => @user.mail) if @user.gid
# Gitlab.client.edit_user_email(@user.gid, :email => @user.mail) if @user.gid
reward_grade(@user, @user.id, 'Mail', 500)
end
end

@ -465,7 +465,7 @@ class ChallengesController < ApplicationController
render_404
return
else
if (@shixun.status == 0 && !User.current.manager_of_shixun?(@shixun))
if (@shixun.status == 0 && !User.current.manager_of_shixun?(@shixun)) || @shixun.status == -1
render_403
return
end

@ -1190,9 +1190,16 @@ class CoursesController < ApplicationController
@all_members = searchmember_by_name(student_homework_score(0, 0, 10,"desc"), q)
end
@homeworks = @course.homework_commons.where("publish_time <= '#{Time.now}'").order("publish_time asc")
@exercises = @course.exercises.where("publish_time <= '#{Time.now}'").order("publish_time asc")
@tasks = @course.graduation_tasks.where("publish_time <= '#{Time.now}'").order("publish_time asc")
@homeworks = @course.homework_commons.where("publish_time <= '#{Time.now}'").order("publish_time asc, created_at asc")
@exercises = @course.exercises.where("publish_time <= '#{Time.now}'").order("publish_time asc, created_at asc")
@tasks = @course.graduation_tasks.where("publish_time <= '#{Time.now}'").order("publish_time asc, created_at asc")
@homeworks.where(:homework_type => 4).each do |homework|
items = homework.student_works.where("work_status != 0")
if items.count == 0 && homework.publish_time < Time.now && !@course.is_end
update_shixun_work_status homework
end
end
respond_to do |format|
format.xls {
@ -2390,8 +2397,8 @@ class CoursesController < ApplicationController
sheet1[4,3] = "学号"
sheet1[4,4] = "分班"
current_col = 4
for i in 0 ... homeworks.where(:homework_type => 4).count
sheet1[4,current_col+=1] = "实训作业第"+(i+1).to_s+""
homeworks.where(:homework_type => 4).each do |homework|
sheet1[4,current_col+=1] = "#{homework.name}"
end
for i in 0 ... homeworks.where(:homework_type => 1).count
sheet1[4,current_col+=1] = "普通作业第"+(i+1).to_s+""
@ -2425,63 +2432,63 @@ class CoursesController < ApplicationController
sheet1[count_row,column+=1] = member.course_group_id == 0 ? "暂无" : member.course_group.name
# current_col = 5
shixun_score = 0
homeworks.where(:homework_type => 4).each do |homework|
homeworks.where(:homework_type => 4).includes(:student_works).each do |homework|
student_works = homework.student_works.where("user_id = #{member.user.id}")
if student_works.empty?
sheet1[count_row,column+=1] = 0
else
work_score = student_works.first.work_score.nil? ? 0 : student_works.first.work_score
sheet1[count_row,column+=1] = work_score < 0 ? 0 : work_score.round(2)
shixun_score += work_score < 0 ? 0 : work_score.round(2)
sheet1[count_row,column+=1] = work_score < 0 ? 0 : work_score.round(1)
shixun_score += work_score < 0 ? 0 : work_score.round(1)
end
# current_col += 1
end
common_score = 0
homeworks.where(:homework_type => 1).each do |homework|
homeworks.where(:homework_type => 1).includes(:student_works).each do |homework|
student_works = homework.student_works.where("user_id = #{member.user.id}")
if student_works.empty?
sheet1[count_row,column+=1] = 0
else
work_score = student_works.first.work_score.nil? ? 0 : student_works.first.work_score
sheet1[count_row,column+=1] = work_score < 0 ? 0 : work_score.round(2)
common_score += work_score < 0 ? 0 : work_score.round(2)
sheet1[count_row,column+=1] = work_score < 0 ? 0 : work_score.round(1)
common_score += work_score < 0 ? 0 : work_score.round(1)
end
# current_col += 1
end
group_score = 0
homeworks.where(:homework_type => 3).each do |homework|
homeworks.where(:homework_type => 3).includes(:student_works).each do |homework|
student_works = homework.student_works.where("user_id = #{member.user.id}")
if student_works.empty?
sheet1[count_row,column+=1] = 0
else
work_score = student_works.first.work_score.nil? ? 0 : student_works.first.work_score
sheet1[count_row,column+=1] = work_score < 0 ? 0 : work_score.round(2)
group_score += work_score < 0 ? 0 : work_score.round(2)
sheet1[count_row,column+=1] = work_score < 0 ? 0 : work_score.round(1)
group_score += work_score < 0 ? 0 : work_score.round(1)
end
# current_col += 1
end
exercise_score = 0
exercises.each do |exercise|
exercises.includes(:exercise_users).each do |exercise|
exercise_user = exercise.exercise_users.where("user_id = #{member.user.id}")
if exercise_user.empty?
sheet1[count_row,column+=1] = 0
else
work_score = exercise_user.first.score.nil? ? 0 : exercise_user.first.score
sheet1[count_row,column+=1] = work_score < 0 ? 0 : work_score.round(2)
exercise_score += work_score < 0 ? 0 : work_score.round(2)
sheet1[count_row,column+=1] = work_score < 0 ? 0 : work_score.round(1)
exercise_score += work_score < 0 ? 0 : work_score.round(1)
end
# current_col += 1
end
graduation_score = 0
tasks.each do |task|
tasks.includes(:graduation_works).each do |task|
graduation_works = task.graduation_works.where("user_id = #{member.user.id}")
if graduation_works.empty?
sheet1[count_row,column+=1] = 0
else
work_score = graduation_works.first.work_score.nil? ? 0 : graduation_works.first.work_score
sheet1[count_row,column+=1] = work_score < 0 ? 0 : work_score.round(2)
graduation_score += work_score < 0 ? 0 : work_score.round(2)
sheet1[count_row,column+=1] = work_score < 0 ? 0 : work_score.round(1)
graduation_score += work_score < 0 ? 0 : work_score.round(1)
end
# current_col += 1
end
@ -2494,7 +2501,7 @@ class CoursesController < ApplicationController
if tasks.count > 0
sheet1[count_row,column+=1] = graduation_score
end
sheet1[count_row,column+=1] = sum.round(2)
sheet1[count_row,column+=1] = sum.round(1)
count_row += 1
end
@ -2550,8 +2557,8 @@ class CoursesController < ApplicationController
count_row += 1
end
homeworks.where(:homework_type => 4).each_with_index do |home, i|
sheet = book.create_worksheet :name => "实训作业第#{i+1}"
homeworks.where(:homework_type => 4).includes(:student_works).each_with_index do |home, i|
sheet = book.create_worksheet :name => "#{home.name}"
sheet[0,0] = "课程编号"
sheet[0,1] = course.id
sheet[1,0] = "课程名称"
@ -2567,6 +2574,10 @@ class CoursesController < ApplicationController
sheet.row(4).concat([l(:excel_rank),l(:excel_user_name),l(:excel_nickname),l(:excel_student_id),l(:excel_homework_des),l(:excel_l_penalty),l(:excel_f_score),l(:excel_commit_time)])
count_row = 5
items = home.student_works.where("work_status != 0").order("work_score desc")
if items.count == 0 && home.publish_time < Time.now && !course.is_end
update_shixun_work_status home
items = StudentWork.where("work_status != 0 and homework_common_id = #{home.id}").order("work_score desc")
end
items.each_with_index do |stu, j|
sheet[count_row,0]= j + 1
sheet[count_row,1] = stu.user.show_real_name
@ -2574,13 +2585,13 @@ class CoursesController < ApplicationController
sheet[count_row,3] = stu.user.user_extensions.student_id
sheet[count_row,4] = strip_html stu.description
sheet[count_row,5] = stu.late_penalty
sheet[count_row,6] = stu.work_score.nil? ? l(:label_without_score) : stu.work_score.round(2)
sheet[count_row,6] = stu.work_score.nil? ? l(:label_without_score) : stu.work_score.round(1)
sheet[count_row,7] = format_time(stu.commit_time)
count_row += 1
end
end
homeworks.where(:homework_type => 1).each_with_index do |home, i|
homeworks.where(:homework_type => 1).includes(:student_works).each_with_index do |home, i|
sheet = book.create_worksheet :name => "普通作业第#{i+1}"
sheet[0,0] = "课程编号"
sheet[0,1] = course.id
@ -2609,17 +2620,17 @@ class CoursesController < ApplicationController
sheet[count_row,2] = stu.user.login
sheet[count_row,3] = stu.user.user_extensions.student_id
sheet[count_row,4] = strip_html stu.description
sheet[count_row,5] = stu.teacher_score.nil? ? l(:label_without_score) : stu.teacher_score.round(2)
sheet[count_row,6] = stu.teaching_asistant_score.nil? ? l(:label_without_score) : stu.teaching_asistant_score.round(2)
sheet[count_row,5] = stu.teacher_score.nil? ? l(:label_without_score) : stu.teacher_score.round(1)
sheet[count_row,6] = stu.teaching_asistant_score.nil? ? l(:label_without_score) : stu.teaching_asistant_score.round(1)
if home.anonymous_comment ==0
sheet[count_row,7] = stu.student_score.nil? ? l(:label_without_score) : stu.student_score.round(2)
sheet[count_row,7] = stu.student_score.nil? ? l(:label_without_score) : stu.student_score.round(1)
sheet[count_row,8] = (home.teacher_priority == 1 && !stu.teacher_score.nil?) ? 0 : stu.absence_penalty
sheet[count_row,9] = (home.teacher_priority == 1 && !stu.teacher_score.nil?) ? 0 : stu.late_penalty
sheet[count_row,10] = stu.work_score.nil? ? l(:label_without_score) : stu.work_score.round(2)
sheet[count_row,10] = stu.work_score.nil? ? l(:label_without_score) : stu.work_score.round(1)
sheet[count_row,11] = format_time(stu.commit_time)
else
sheet[count_row,7] = (home.teacher_priority == 1 && !stu.teacher_score.nil?) ? 0 : stu.late_penalty
sheet[count_row,8] = stu.work_score.nil? ? l(:label_without_score) : stu.work_score.round(2)
sheet[count_row,8] = stu.work_score.nil? ? l(:label_without_score) : stu.work_score.round(1)
sheet[count_row,9] = format_time(stu.commit_time)
end
count_row += 1
@ -2627,7 +2638,7 @@ class CoursesController < ApplicationController
end
homeworks.where(:homework_type => 3).each_with_index do |home, i|
homeworks.where(:homework_type => 3).includes(:student_works).each_with_index do |home, i|
sheet = book.create_worksheet :name => "分组作业第#{i+1}"
sheet[0,0] = "课程编号"
sheet[0,1] = course.id
@ -2658,17 +2669,17 @@ class CoursesController < ApplicationController
sheet[count_row,3] = stu.user.user_extensions.student_id
sheet[count_row,4] = get_group_member_names home.student_works.where(:group_id => stu.group_id).pluck(:user_id)
sheet[count_row,5] = strip_html stu.description
sheet[count_row,6] = stu.teacher_score.nil? ? l(:label_without_score) : stu.teacher_score.round(2)
sheet[count_row,7] = stu.teaching_asistant_score.nil? ? l(:label_without_score) : stu.teaching_asistant_score.round(2)
sheet[count_row,6] = stu.teacher_score.nil? ? l(:label_without_score) : stu.teacher_score.round(1)
sheet[count_row,7] = stu.teaching_asistant_score.nil? ? l(:label_without_score) : stu.teaching_asistant_score.round(1)
if home.anonymous_comment ==0
sheet[count_row,8] = stu.student_score.nil? ? l(:label_without_score) : stu.student_score.round(2)
sheet[count_row,8] = stu.student_score.nil? ? l(:label_without_score) : stu.student_score.round(1)
sheet[count_row,9] = (home.teacher_priority == 1 && !stu.teacher_score.nil?) ? 0 : stu.absence_penalty
sheet[count_row,10] = (home.teacher_priority == 1 && !stu.teacher_score.nil?) ? 0 : stu.late_penalty
sheet[count_row,11] = stu.work_score.nil? ? l(:label_without_score) : stu.work_score.round(2)
sheet[count_row,11] = stu.work_score.nil? ? l(:label_without_score) : stu.work_score.round(1)
sheet[count_row,12] = format_time(stu.commit_time)
else
sheet[count_row,8] = (home.teacher_priority == 1 && !stu.teacher_score.nil?) ? 0 : stu.late_penalty
sheet[count_row,9] = stu.work_score.nil? ? l(:label_without_score) : stu.work_score.round(2)
sheet[count_row,9] = stu.work_score.nil? ? l(:label_without_score) : stu.work_score.round(1)
sheet[count_row,10] = format_time(stu.commit_time)
end
count_row += 1
@ -2700,7 +2711,7 @@ class CoursesController < ApplicationController
sheet[count_row,3] = stu.user.user_extensions.student_id
sheet[count_row,4] = stu.objective_score == -1 ? "0.0" : format("%.1f",stu.objective_score)
sheet[count_row,5] = stu.subjective_score == -1 ? "0.0" : format("%.1f",stu.subjective_score)
sheet[count_row,6] = stu.score.nil? ? '--' : stu.score.round(2)
sheet[count_row,6] = stu.score.nil? ? '--' : stu.score.round(1)
sheet[count_row,7] = stu.commit_status == 0 ? l(:excel_no_answer) : format_time(stu.start_at)
count_row += 1
end
@ -2741,12 +2752,12 @@ class CoursesController < ApplicationController
sheet[count_row,column+=1] = get_group_member_names task.graduation_works.where(:group_id => stu.group_id).pluck(:user_id)
end
sheet[count_row,column+=1] = strip_html stu.description
sheet[count_row,column+=1] = stu.teacher_score.nil? ? l(:label_without_score) : stu.teacher_score.round(2)
sheet[count_row,column+=1] = stu.teacher_score.nil? ? l(:label_without_score) : stu.teacher_score.round(1)
if task.cross_comment
sheet[count_row,column+=1] = stu.cross_score.nil? ? l(:label_without_score) : stu.cross_score.round(2)
sheet[count_row,column+=1] = stu.cross_score.nil? ? l(:label_without_score) : stu.cross_score.round(1)
end
sheet[count_row,column+=1] = stu.late_penalty
sheet[count_row,column+=1] = stu.work_score.nil? ? l(:label_without_score) : stu.work_score.round(2)
sheet[count_row,column+=1] = stu.work_score.nil? ? l(:label_without_score) : stu.work_score.round(1)
sheet[count_row,column+=1] = format_time(stu.commit_time)
count_row += 1
end

@ -104,6 +104,8 @@ class EcloudController < ApplicationController
des_services = params['services'].select{|s| s['opttype'] == 1}
if des_services.present?
des_services.each do |ds|
logger.info("666666#{ecloud.try(:id)}, 55555555#{ds['code']}")
esd = EcloudService.where(ecloud_id: ecloud.try(:id), code: ds['code']).first
esd.update_attributes!(opttype: ds['opttype'], begintime: ds['begintime'], endtime: ds['endtime'])
end
@ -143,10 +145,10 @@ class EcloudController < ApplicationController
# end
render :json => {result: true, errmsg: ""}
rescue Exception => e
logger.error(e.message)
render :json => {code: 500, msg: "#{e.message}"}
raise ActiveRecord::Rollback
# rescue Exception => e
# logger.error(e.message)
# render :json => {code: 500, msg: "#{e.message}"}
# raise ActiveRecord::Rollback
end
end
end

@ -18,7 +18,7 @@ class EcsController < ApplicationController
@major_count = @major_schools.count
if @major_count == 0
if !@is_school_manager && @major_count == 0
render_403
else
if params[:search].present?

@ -158,7 +158,7 @@ class ManagementsController < ApplicationController
@sub_type = 8
@g = Gitlab.client
if params[:search]
myshixun_id = Game.where(:identifier => params[:search]).pluck(:myshixun_id)
myshixun_id = Game.where("identifier = #{params[:search]} or id = #{params[:search]}").pluck(:myshixun_id)
@myshixuns = Myshixun.where(:id => myshixun_id).includes(:shixun)
else
@myshixuns = Myshixun.where("0=0").includes(:shixun)
@ -812,7 +812,7 @@ class ManagementsController < ApplicationController
format.xls{
shixun_ids = @all_discusses.pluck(:dis_id).uniq
filename = "#{Time.now.strftime("%Y%m%d")}-实训反馈.xls"
send_data(shixun_feedback_xls(shixun_ids), :type => 'application/octet-stream', :filename => filename_for_content_disposition(filename))
send_data(shixun_feedback_xls(shixun_ids), :type => "text/excel;charset=utf-8; header=present", :filename => filename_for_content_disposition(filename))
}
end
end
@ -1368,6 +1368,7 @@ end
after_dep = Department.where(:school_id => params[:school_id], :name => department.name).first
if after_dep
UserExtensions.where(:school_id => params[:applied_id], :department_id => department.id).update_all(:department_id => after_dep.id)
department.apply_add_departments.destroy_all
department.destroy
else
department.apply_add_departments.update_all(:school_id => params[:school_id])

@ -1,10 +1,10 @@
# encoding: utf-8
class MyshixunsController < ApplicationController
layout 'base_myshixun'
skip_before_filter :verify_authenticity_token, :only => [:training_task_status, :close_webssh]
before_filter :require_login, :except => [:training_task_status, :close_webssh]
skip_before_filter :verify_authenticity_token, :only => [:training_task_status, :close_webssh, :code_runinng_message]
before_filter :require_login, :except => [:training_task_status, :close_webssh, :code_runinng_message]
before_filter :check_authentication, :except => [:training_task_status, :close_webssh, :mul_test_home, :mul_test_user,
:mul_test_myshixun, :mul_test_shixun, :mul_test_start]
:mul_test_myshixun, :mul_test_shixun, :mul_test_start, :code_runinng_message]
before_filter :find_myshixun, :only => [:show, :myshixun_reset, :open_webssh, :sync_reset_time, :destroy, :search_file_list, :vnc]
DCODES = %W(2 3 4 5 6 7 8 9 a b c f e f g h i j k l m n o p q r s t u v w x y z)
@ -435,6 +435,39 @@ class MyshixunsController < ApplicationController
end
# 代码运行中的信息接口
def code_runinng_message
begin
logger.info("######################params: #{params}")
jsonTestDetails = JSON.parse(params[:jsonTestDetails])
game_id = jsonTestDetails['buildID']
message = jsonTestDetails['textMsg']
logger.info("##################code_runinng_message:#{jsonTestDetails}")
logger.info("##################buildID: #{game_id}")
logger.info("##################textMsg: #{message}")
if game_id.present? && message.present?
game = Game.find game_id
msg = game.run_code_message
# 只有评测中的game才会创建和更新代码评测中的信息
logger.info("##################game: #{game.status}")
logger.info("##################retry_status: #{game.retry_status}")
if game.status == 1 || game.status == 2 && game.retry_status == 1
if msg.blank?
RunCodeMessage.create!(:game_id => game_id, :status => 1, :message => message)
else
msg.update_attributes(:status => (msg.status + 1), :message => message)
end
else
# 评测完成,初始化评测信息的状态
msg.update_attributes(:status => 0, :message => nil) if msg.present?
end
render :json => {:data => "success"}
end
rescue Exception => e
render :json => {:data => "failed, exception_message: #{e}"}
end
end
# taskId 即返回的game id
# 返回结果params [:stauts] 0 表示成功,其它则失败
# msg 错误信息
@ -540,7 +573,7 @@ class MyshixunsController < ApplicationController
logger.info("training_task_status start#4**#{game_id}**** #{Time.now.strftime("%Y-%m-%d %H:%M:%S.%L")}")
render :json => {:data => "success"}
rescue Exception => e
render :json => {:data => "failed"}
render :json => {:data => "failed, errer_message:#{e}"}
logger.error("training_task_status error: #{e}")
raise ActiveRecord::Rollback
end

@ -1115,8 +1115,8 @@ class ShixunsController < ApplicationController
g.delete_project(@shixun.gpid) if @shixun.try(:gpid).present?
apply_record = ApplyAction.where(:container_id => @shixun.id, :container_type => "ApplyShixun")
apply_record.delete_all if apply_record
HomeworkCommonsShixuns.where(:shixun_id => @shixun).delete_all # 关联删报错,后续解决
@shixun.destroy
#HomeworkCommonsShixuns.where(:shixun_id => @shixun).delete_all # 关联删报错,后续解决
@shixun.update_attribute(:status, -1)
respond_to do |format|
if params[:come_from] == "admin"
format.html{ redirect_to shixuns_managements_path }
@ -1163,11 +1163,16 @@ class ShixunsController < ApplicationController
end
def get_script_contents
mirrir_script = MirrorScript.find(params[:script_id])
script = mirrir_script.try(:script)
description = mirrir_script.try(:description)
script = modify_shixun_script @shixun, script
render :json => {contents: script, description: description}
if params[:script_id].to_i == -1
render :json => {contents: "", description: ""}
else
mirrir_script = MirrorScript.find(params[:script_id])
script = mirrir_script.try(:script)
description = mirrir_script.try(:description)
script = modify_shixun_script @shixun, script
render :json => {contents: script, description: description}
end
end
def get_common_script
@ -1210,7 +1215,7 @@ class ShixunsController < ApplicationController
# Find shixun of id params[:id]
def find_shixun
@shixun = Shixun.find_by_identifier(params[:id])
render_404 if @shixun.nil?
render_404 if @shixun.nil? || @shixun.status == -1
rescue ActiveRecord::RecordNotFound
render_404
end
@ -1357,4 +1362,8 @@ class ShixunsController < ApplicationController
def validation_email
render_403 if User.current.mail.blank?
end
def validate_shixun
end
end

@ -54,7 +54,7 @@ class UsersController < ApplicationController
accept_api_auth :index, :show, :create, :update, :destroy, :tag_save, :tag_saveEx
#william
before_filter :require_login, :only => [:tag_save, :tag_saveEx]
before_filter :require_login, :only => [:tag_save, :tag_saveEx, :search_user_course, :search_user_project]
#before_filter :refresh_changests, :only =>[:user_activities,:user_courses,:user_projects,:user_newfeedback]
#visitor

@ -6521,6 +6521,67 @@ def visible_task_count course, is_teacher
task_count
end
def update_shixun_work_status homework
shixun = homework.shixuns.first
student_works = homework.student_works.where(:work_status => 0)
homework_challenge_settings = homework.homework_challenge_settings
challeng_ids = homework_challenge_settings.map(&:challenge_id)
# 取已发布的作品
if homework.unified_setting
student_works = student_works
else
setting = homework.homework_group_settings.where("publish_time < '#{Time.now}'")
if setting.blank?
student_works = student_works.where("0=1")
else
users = homework.course.members.where(:course_group_id => setting.map(&:course_group_id))
student_works = student_works.where(:user_id => users.map(&:user_id))
end
end
# 已发布作品且状态为未提交的作品 如果有开启过实训则更新状态
myshixuns = Myshixun.where(:shixun_id => shixun.id, :user_id => student_works.map(&:user_id))
myshixuns.each do |myshixun|
work = student_works.where(:user_id => myshixun.user_id).first
member = Member.find_by_sql("select course_group_id from members where course_id = #{homework.course_id} and user_id = #{work.user_id}").first
setting_time = homework_group_setting homework, member.try(:course_group_id)
games = myshixun.games.where(:challenge_id => challeng_ids)
myshixun_endtime = games.select{|game| game.status == 2}.size == games.size ? games.map(&:end_time).max : nil
compelete_status = 0
if myshixun_endtime.present? && myshixun_endtime < setting_time.end_time
if myshixun_endtime < setting_time.publish_time
compelete_status = 2
else
compelete_status = 1
end
end
if setting_time.end_time > Time.now
work.update_attributes(:work_status => 1, :late_penalty => 0, :commit_time => myshixun.updated_at, :update_time => myshixun.updated_at, :myshixun_id => myshixun.id, :compelete_status => compelete_status)
else
work.update_attributes(:work_status => ((myshixun.is_complete? && (myshixun.done_time < setting_time.end_time)) ? 1 : 2), :late_penalty => (myshixun.is_complete? && (myshixun.done_time < setting_time.end_time) ? 0 : homework.late_penalty), :commit_time => myshixun.updated_at, :update_time => myshixun.updated_at, :myshixun_id => myshixun.id, :compelete_status => compelete_status)
end
set_shixun_final_score work, homework.homework_detail_manual.answer_open_evaluation, homework_challenge_settings
end
# 更新所有学生的效率分
update_student_eff_score HomeworkCommon.where(:id => homework.id).first
=begin
student_works.each do |work|
if work.work_status == 0
myshixun = Myshixun.where(:shixun_id => shixun.id, :user_id => work.user_id).first
if myshixun
member = Member.find_by_sql("select course_group_id from members where course_id = #{homework.course_id} and user_id = #{User.current.id}").first
setting_time = homework_group_setting homework, member.try(:course_group_id)
if setting_time.end_time > Time.now
work.update_attributes(:work_status => 1, :late_penalty => 0, :commit_time => myshixun.updated_at, :update_time => myshixun.updated_at, :myshixun_id => myshixun.id)
else
work.update_attributes(:work_status => ((myshixun.is_complete? && (myshixun.done_time < setting_time.end_time)) ? 1 : 2), :late_penalty => (myshixun.is_complete? && (myshixun.done_time < setting_time.end_time) ? 0 : homework.late_penalty), :commit_time => myshixun.updated_at, :update_time => myshixun.updated_at, :myshixun_id => myshixun.id)
end
end
end
set_shixun_final_score work, homework.homework_detail_manual.answer_open_evaluation, homework_challenge_settings
end
=end
end
#成绩计算
def set_final_score homework,student_work
if homework && homework.homework_detail_manual && !student_work.ultimate_score

@ -3,67 +3,6 @@ include UserScoreHelper
module StudentWorkHelper
def update_shixun_work_status homework
shixun = homework.homework_commons_shixuns.shixun
student_works = homework.student_works.where(:work_status => 0)
homework_challenge_settings = homework.homework_challenge_settings
challeng_ids = homework_challenge_settings.map(&:challenge_id)
# 取已发布的作品
if homework.unified_setting
student_works = student_works
else
setting = homework.homework_group_settings.where("publish_time < '#{Time.now}'")
if setting.blank?
student_works = student_works.where("0=1")
else
users = homework.course.members.where(:course_group_id => setting.map(&:course_group_id))
student_works = student_works.where(:user_id => users.map(&:user_id))
end
end
# 已发布作品且状态为未提交的作品 如果有开启过实训则更新状态
myshixuns = Myshixun.where(:shixun_id => shixun.id, :user_id => student_works.map(&:user_id))
myshixuns.each do |myshixun|
work = student_works.where(:user_id => myshixun.user_id).first
member = Member.find_by_sql("select course_group_id from members where course_id = #{homework.course_id} and user_id = #{work.user_id}").first
setting_time = homework_group_setting homework, member.try(:course_group_id)
games = myshixun.games.where(:challenge_id => challeng_ids)
myshixun_endtime = games.select{|game| game.status == 2}.size == games.size ? games.map(&:end_time).max : nil
compelete_status = 0
if myshixun_endtime.present? && myshixun_endtime < setting_time.end_time
if myshixun_endtime < setting_time.publish_time
compelete_status = 2
else
compelete_status = 1
end
end
if setting_time.end_time > Time.now
work.update_attributes(:work_status => 1, :late_penalty => 0, :commit_time => myshixun.updated_at, :update_time => myshixun.updated_at, :myshixun_id => myshixun.id, :compelete_status => compelete_status)
else
work.update_attributes(:work_status => ((myshixun.is_complete? && (myshixun.done_time < setting_time.end_time)) ? 1 : 2), :late_penalty => (myshixun.is_complete? && (myshixun.done_time < setting_time.end_time) ? 0 : homework.late_penalty), :commit_time => myshixun.updated_at, :update_time => myshixun.updated_at, :myshixun_id => myshixun.id, :compelete_status => compelete_status)
end
set_shixun_final_score work, homework.homework_detail_manual.answer_open_evaluation, homework_challenge_settings
end
# 更新所有学生的效率分
update_student_eff_score HomeworkCommon.where(:id => homework.id).first
=begin
student_works.each do |work|
if work.work_status == 0
myshixun = Myshixun.where(:shixun_id => shixun.id, :user_id => work.user_id).first
if myshixun
member = Member.find_by_sql("select course_group_id from members where course_id = #{homework.course_id} and user_id = #{User.current.id}").first
setting_time = homework_group_setting homework, member.try(:course_group_id)
if setting_time.end_time > Time.now
work.update_attributes(:work_status => 1, :late_penalty => 0, :commit_time => myshixun.updated_at, :update_time => myshixun.updated_at, :myshixun_id => myshixun.id)
else
work.update_attributes(:work_status => ((myshixun.is_complete? && (myshixun.done_time < setting_time.end_time)) ? 1 : 2), :late_penalty => (myshixun.is_complete? && (myshixun.done_time < setting_time.end_time) ? 0 : homework.late_penalty), :commit_time => myshixun.updated_at, :update_time => myshixun.updated_at, :myshixun_id => myshixun.id)
end
end
end
set_shixun_final_score work, homework.homework_detail_manual.answer_open_evaluation, homework_challenge_settings
end
=end
end
#获取当前用户的项目列表
def user_projects_option
projects = User.current.projects.visible

@ -6,32 +6,36 @@ module SubjectsHelper
end
# 实训路径详情列表,右侧状态显示栏
def shixun_show_in_subject subject_status, shixun_status
content = if subject_status < 2
case shixun_status
when 0, 1
'<span class="fr color-grey-c">暂未公开</span>'
when 2
'<span class="fr color-grey-9">已发布</span>'
when 3
'<span class="fr color-grey-9">已关闭</span>'
else
""
end
else
if shixun_status != 2
case shixun_status
when 0, 1
'<span class="fr color-grey-c">暂未公开</span>'
when 3
'<span class="fr color-grey-9">已关闭</span>'
else
""
end
else
""
end
end
def shixun_show_in_subject subject_status, shixun_status, shixun_hidden
content = if shixun_hidden
'<span class="fr color-grey-c">暂未公开</span>'
else
if subject_status < 2
case shixun_status
when 0, 1
'<span class="fr color-grey-c">暂未公开</span>'
when 2
'<span class="fr color-grey-9">已发布</span>'
when 3
'<span class="fr color-grey-9">已关闭</span>'
else
""
end
else
if shixun_status != 2
case shixun_status
when 0, 1
'<span class="fr color-grey-c">暂未公开</span>'
when 3
'<span class="fr color-grey-9">已关闭</span>'
else
""
end
else
""
end
end
end
return content.html_safe
end
@ -39,7 +43,7 @@ module SubjectsHelper
def start_shixun_in_subject subject, shixun, myshixun
is_modify = ShixunModify.where(:myshixun_id => myshixun.try(:id), :shixun_id => shixun.try(:id), :status => 1).first
content_before = ''
content = if shixun.status == 2 || User.current.manager_of_shixun?(shixun)
content = if (shixun.status == 2 && !shixun.hidden) || User.current.manager_of_shixun?(shixun)
content_before = "<a href=\"#{shixun_path(shixun)}\" class=\"mr30 color-blue_4C shixun_detail pointer fl none\" target=\"_blank\">查看详情</a>"
if User.current.try(:mail).blank?
%Q{<a class="btn_auto user_bluebg_btn fl none" onclick="sure_box_redirect_without_newtab_btn('#{security_settings_path}', '开启实训,请先绑定邮箱','绑定邮箱');" id = "shixun_operation">开始实战</a>}

@ -4,7 +4,7 @@ class Department < ActiveRecord::Base
# apply_add_departments 不能关联删除 tidings表有关联
has_many :apply_add_departments
has_many :tidings, as: :container, dependent: :destroy
attr_accessible :name, :school_id, :is_auth, :identifier, :is_delete
attr_accessible :name, :school_id, :is_auth, :identifier, :is_delete, :host_count
scope :is_active, lambda{where(:is_delete => false)}
scope :is_delete, lambda{where(:is_delete => true)}

@ -13,6 +13,7 @@ class Game < ActiveRecord::Base
has_many :challenge_samples
has_many :game_codes, :dependent => :destroy
has_many :evaluate_records, :dependent => :destroy
has_one :run_code_message, :dependent => :destroy
include ApplicationHelper
scope :min, lambda { select([:id, :status, :myshixun_id, :user_id, :final_score, :challenge_id, :identifier,

@ -0,0 +1,5 @@
class RunCodeMessage < ActiveRecord::Base
# attr_accessible :title, :body
belongs_to :game
end

@ -73,7 +73,7 @@ class Shixun < ActiveRecord::Base
end
def fork_identifier
self.fork_from.nil? ? "--" : Shixun.find(self.fork_from).try(:identifier)
self.fork_from.nil? ? "--" : Shixun.where(id: self.fork_from).first.try(:identifier)
end
def get_fork

@ -151,6 +151,9 @@ class GamesService
result = test_set.attributes.count > 4 ? test_set.try(:result) : nil
#actual_output = Base64.encode64(actual_output)
compile_success = (actual_output.blank? || actual_output.downcase.match(/error/).present?) ? 0 : 1
compile_success == 0 ? "编译失败,请在测试结果中查看具体的错误信息" : compile_success
public_result = {:is_public => (test_set.is_public ? 1 : 0), :result => result,
:actual_output => actual_output, :compile_success => compile_success}
# 测试集公开的话才返回input结果
@ -498,7 +501,9 @@ class GamesService
# 更新评测次数
game.update_column(:evaluate_count, (game.evaluate_count.to_i + 1))
# 清空代码评测信息
msg = game.run_code_message
msg.update_attributes(:status => 0, :message => nil) if msg.present?
# 更新时间是为了TPM端显示的更新退出实训及访问实训的时候会更新
myshixun.update_column(:updated_at, Time.now)
@ -793,7 +798,10 @@ class GamesService
# 如果没有超时并且正在评测中
# 判断评测中的状态有两种1、如果之前没有通关的只需判断status为1即可如果通过关则判断game的resubmit_identifier是否更新
if (params[:time_out] == "false") && ((params[:resubmit].blank? && game.status==1) || (params[:resubmit].present? && (params[:resubmit] != resubmit_identifier)))
return
# 代码评测的信息
running_code_status = game.run_code_message.try(:status)
running_code_message = game.run_code_message.try(:message)
return {:running_code_status => running_code_status, :running_code_message => running_code_message}
end
Rails.logger.info("##### resubmit_identifier is #{resubmit_identifier}")
@ -886,8 +894,10 @@ class GamesService
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}
return {:grade => grade, :gold => score, :experience => experience, :status => game_status, :had_done => had_done, :position => game_challenge.position,
:port => port, :power => power, :record => record, :mirror_name => mirror_name, :picture => picture, :web_route => web_route, :latest_output => latest_output,
return {:grade => grade, :gold => score, :experience => experience, :status => game_status, :had_done => had_done,
:position => game_challenge.position, :port => port, :power => power, :record => record,
:mirror_name => mirror_name, :picture => picture, :web_route => web_route, :latest_output => latest_output,
:star => game.star, :next_game => next_game, :prev_game => prev_game}.merge(output_hash)
end

@ -125,9 +125,21 @@ class ShixunsService
praise_count = d.praise_tread.where(:praise_or_tread => 1).count
user_praise= d.praise_tread.select{|pt| pt.user_id == current_user.id}.length > 0 ? true : false
# 实训TPM的管理员可以看到隐藏的评论
parents = {:id => d.id, :content => d.content, :time => time_from_now(d.created_at), :position => d.position, :user_id => d.user.try(:id), :reward => d.reward,
:image_url => url_to_avatar(d.user), :username => d.username, :user_login => d.user.try(:login), :shixun_id => dis.id, :hidden => d.hidden,
:manager => current_user.manager_of_shixun?(dis, current_user), :praise_count => praise_count, :user_praise => user_praise, :admin => current_user.admin?}
manager = current_user.manager_of_shixun?(dis, current_user)
game_url =
if manager
position = d.position.nil? ? 1 : d.position
game_identifier = Game.find_by_sql("SELECT g.identifier FROM games g JOIN challenges c on g.challenge_id = c.id
WHERE c.shixun_id = #{dis.id} AND c.position = #{position} AND g.user_id = #{d.user_id}").first.try(:identifier)
"/tasks/#{game_identifier}"
else
""
end
parents = {:id => d.id, :content => d.content, :time => time_from_now(d.created_at), :position => d.position,
:user_id => d.user.try(:id), :reward => d.reward, :image_url => url_to_avatar(d.user),
:username => d.username, :user_login => d.user.try(:login), :shixun_id => dis.id, :hidden => d.hidden,
:manager => manager, :praise_count => praise_count, game_url: game_url,
:user_praise => user_praise, :admin => current_user.admin?}
# 现在没有二级回复所以查询的时候直接从root_id取
children = Discuss.where(:root_id => d.id).includes(:user).reorder("created_at asc")

@ -10,13 +10,12 @@
<%= heads_for_theme %>
<%= call_hook :view_layouts_base_html_head %>
<%= stylesheet_link_tag 'jquery/jquery-ui-1.9.2', 'css/edu-common','educoder/edu-main','educoder/edu-all', 'css/edu-public', 'css/font-awesome', 'css/edu-class', 'css/magic-check'%>
<%#= javascript_heads %>
<%= javascript_include_tag "edu/application",'educoder/edu_application'%>
<%= javascript_heads %>
<%= javascript_include_tag "edu/application", 'educoder/edu_application'%>
</head>
<body onload="prettyPrint();" style="height: 100%; background: #fff;">
<body style="height: 100%; background: #fff;">
<div class="newContainer" style="width: 1000px;"> <!-- 页面全部内容 -->
<div class="clearfix" style="width: 1000px;"> <!-- 主题部分 -->
<%= render_flash_messages %>
<%= yield %>
<div class="cl"></div>
</div>

@ -36,6 +36,14 @@
</div>
</div>
<% end %>
<div class="mt20 mb20" style="text-align:center;">
<div class="pages_user_show" style="width:auto; display:inline-block;">
<ul id="homework_pository_ref_pages">
<%= pagination_links_full @authorizations_pages, @authorizations_count, :per_page_links => false, :remote => true, :flag => true, :is_new => true %>
</ul>
<div class="cl"></div>
</div>
</div>
<% else %>
<%= render :partial => "welcome/no_data" %>
<% end %>

@ -27,6 +27,15 @@
</div>
<% end %>
<div class="mt20 mb20" style="text-align:center;">
<div class="pages_user_show" style="width:auto; display:inline-block;">
<ul id="homework_pository_ref_pages">
<%= pagination_links_full @authorizations_pages, @authorizations_count, :per_page_links => false, :remote => true, :flag => true, :is_new => true %>
</ul>
<div class="cl"></div>
</div>
</div>
<!--<div style="text-align:center;">-->
<!--<div class="pages_right_min" style="width:auto; display:inline-block;">-->
<!--<ul id="homework_pository_ref_pages">-->

@ -38,7 +38,7 @@
<td><%= user.try(:authentication_status) %></td>
<td><%= user.try(:professional_status) %></td>
<td ><span class="edu-txt-w140 task-hide2" title="<%= user.try(:user_extensions).try(:school).try(:name) %>"><%= user.try(:user_extensions).try(:school).try(:name).blank? ? "--" : user.try(:user_extensions).try(:school) %></span></td>
<td ><span class="edu-txt-w140 task-hide2"><%= user.try(:user_extensions).department ? user.try(:user_extensions).try(:department).try(:name).to_s : '--' %></span></td>
<td ><span class="edu-txt-w140 task-hide2"><%= user.try(:user_extensions).try(:department) ? user.try(:user_extensions).try(:department).try(:name).to_s : '--' %></span></td>
<td><%= user.last_login_on.blank? ? "--" : (format_time user.last_login_on) %></td>
<td><%= identity_authentication_status(user) %></td>
<td class="homepage_teacher">

@ -5,167 +5,163 @@
SearchByName_poll();
}
}
$(function () {
});
</script>
<div class="edu-class-container edu-position">
<p class="mb10 font-14">
<%= link_to @course.name, course_path(@course),:class => "color-grey-9" %> &gt; <%= link_to "问卷列表", poll_index_path(:course_id => @course.id),:class => "color-grey-9" %> &gt;
#<%= get_poll_index(@poll, @course, @is_teacher) + 1 %>
</p>
<div class="edu-con-top user_bg_shadow bor-grey-e clearfix mb20">
<p class="ml15 fl color-grey3">
<% unless @poll.is_public %>
<i id="poll_public_icon_<%= @poll.id %>" class="fa fa-lock color-grey-c fl mt8 mr15 font-18"></i>
<% end %>
<span><%= @poll.polls_name %></span>
<p class="mb10 font-14">
<%= link_to @course.name, course_path(@course),:class => "color-grey-9" %> &gt; <%= link_to "问卷列表", poll_index_path(:course_id => @course.id),:class => "color-grey-9" %> &gt;
#<%= get_poll_index(@poll, @course, @is_teacher) + 1 %>
</p>
<%= link_to "返回", poll_index_path(:course_id => @course.id), :class => "fr font-12 mr15 mt3 color-grey" %>
</div>
<div class="edu-tab clearfix mb20">
<div class="edu-con-top user_bg_shadow bor-grey-e clearfix mb20">
<p class="ml15 fl color-grey3">
<% unless @poll.is_public %>
<i id="poll_public_icon_<%= @poll.id %>" class="fa fa-lock color-grey-c fl mt8 mr15 font-18"></i>
<% end %>
<span><%= @poll.polls_name %></span>
</p>
<%= link_to "返回", poll_index_path(:course_id => @course.id), :class => "fr font-12 mr15 mt3 color-grey" %>
</div>
<div class="clearfix mb20">
<ul id="edu-tab-nav" class="border-bottom-orange">
<li id="edu-tab-nav-1" class="new-tab-nav background-orange" onclick="HoverLi(1);">
<a href="javascript:void(0);" class="tab_type">答题列表</a>
</li>
<% if @is_teacher || (@poll.show_result == 1 && @poll.polls_status == 3) %>
<li id="edu-tab-nav-2" class="new-tab-nav" onclick="HoverLi(2);">
<a href="javascript:void(0);" class="tab_type">统计结果</a>
</li>
<li id="edu-tab-nav-2" class="new-tab-nav" onclick="HoverLi(2);">
<a href="javascript:void(0);" class="tab_type">统计结果</a>
</li>
<% end %>
<% if @is_teacher %>
<li id="edu-tab-nav-3" class="new-tab-nav" onclick="HoverLi(3);">
<a href="javascript:void(0);" class="tab_type">问卷内容</a>
</li>
<li id="edu-tab-nav-4" class="new-tab-nav" onclick="HoverLi(4);">
<a href="javascript:void(0);" class="tab_type">设置</a>
</li>
<% if @poll.polls_status > 1 %>
<%= link_to "导出统计", export_poll_poll_path(@poll, :course_id => @course.id, :format => 'xls'), :id => "export_poll_work", :class => "fr white-btn orange-btn mt10 ml15" %>
<% end %>
<% if @poll.polls_status < 3 %>
<%= link_to "编辑问卷", edit_poll_path(@poll, :course_id => @course.id), :class => "fr white-btn orange-btn mt10 ml15" %>
<% end %>
<% if @poll.polls_status == 1 || @poll.poll_group_settings.where("publish_time is null or publish_time > '#{Time.now}'").count > 0 %>
<%= link_to '立即发布', publish_notice_poll_path(@poll), :remote => true, :class => "white-btn orange-btn fr ml15 mt10" %>
<% end %>
<% if (@poll.polls_status == 2 && @poll.end_time > Time.now) || @poll.poll_group_settings.where("publish_time < '#{Time.now}' and end_time > '#{Time.now}'").count > 0 %>
<%= link_to '立即截止', end_notice_poll_path(@poll), :remote => true, :class => "white-btn orange-btn fr ml15 mt10" %>
<% end %>
<% if @poll.polls_status == 2 %>
<a href="javascript:void(0)" class="white-btn orange-btn fr ml15 mt10" onclick="cancel_publish('<%= cancel_publish_poll_path(@poll) %>')">撤销发布</a>
<% end %>
<li id="edu-tab-nav-3" class="new-tab-nav" onclick="HoverLi(3);">
<a href="javascript:void(0);" class="tab_type">问卷内容</a>
</li>
<li id="edu-tab-nav-4" class="new-tab-nav" onclick="HoverLi(4);">
<a href="javascript:void(0);" class="tab_type">设置</a>
</li>
<% if @poll.polls_status > 1 %>
<%= link_to "导出统计", export_poll_poll_path(@poll, :course_id => @course.id, :format => 'xls'), :id => "export_poll_work", :class => "fr white-btn orange-btn mt10 ml15" %>
<% end %>
<% if @poll.polls_status < 3 %>
<%= link_to "编辑问卷", edit_poll_path(@poll, :course_id => @course.id), :class => "fr white-btn orange-btn mt10 ml15" %>
<% end %>
<% if @poll.polls_status == 1 || @poll.poll_group_settings.where("publish_time is null or publish_time > '#{Time.now}'").count > 0 %>
<%= link_to '立即发布', publish_notice_poll_path(@poll), :remote => true, :class => "white-btn orange-btn fr ml15 mt10" %>
<% end %>
<% if (@poll.polls_status == 2 && @poll.end_time > Time.now) || @poll.poll_group_settings.where("publish_time < '#{Time.now}' and end_time > '#{Time.now}'").count > 0 %>
<%= link_to '立即截止', end_notice_poll_path(@poll), :remote => true, :class => "white-btn orange-btn fr ml15 mt10" %>
<% end %>
<% if @poll.polls_status == 2 %>
<a href="javascript:void(0)" class="white-btn orange-btn fr ml15 mt10" onclick="cancel_publish('<%= cancel_publish_poll_path(@poll) %>')">撤销发布</a>
<% end %>
<% else %>
<li id="edu-tab-nav-4" class="new-tab-nav" onclick="HoverLi(4);">
<a href="javascript:void(0);" class="tab_type">查看设置</a>
</li>
<% if User.current.member_of_course?(@poll.course) %>
<p class="fr">
<% poll_user = @poll.poll_users.where(:user_id => User.current).first %>
<% member = @poll.course.members.where(:user_id => User.current.id).first %>
<% setting_time = poll_group_setting @poll, member.try(:course_group) %>
<% if poll_user %>
<% if poll_user.commit_status > 0 %>
<%= link_to '查看答题', poll_path(@poll, :user_id => User.current.id), :class => "white-btn orange-btn fr mt10 mr15" %>
<% elsif setting_time.publish_time < Time.now && setting_time.end_time > Time.now %>
<%= link_to (poll_user.start_at.nil? ? "开始答题" : "继续答题"), poll_path(@poll, :user_id => User.current.id), :class => "white-btn orange-btn fr mt10 mr15" %>
<% end %>
<% elsif setting_time.publish_time < Time.now && setting_time.end_time > Time.now %>
<%= link_to "开始答题", poll_path(@poll, :user_id => User.current.id), :class => "white-btn orange-btn fr mt10 mr15" %>
<% end %>
</p>
<% end %>
<li id="edu-tab-nav-4" class="new-tab-nav" onclick="HoverLi(4);">
<a href="javascript:void(0);" class="tab_type">查看设置</a>
</li>
<% if User.current.member_of_course?(@poll.course) %>
<p class="fr">
<% poll_user = @poll.poll_users.where(:user_id => User.current).first %>
<% member = @poll.course.members.where(:user_id => User.current.id).first %>
<% setting_time = poll_group_setting @poll, member.try(:course_group) %>
<% if poll_user %>
<% if poll_user.commit_status > 0 %>
<%= link_to '查看答题', poll_path(@poll, :user_id => User.current.id), :class => "white-btn orange-btn fr mt10 mr15" %>
<% elsif setting_time.publish_time < Time.now && setting_time.end_time > Time.now %>
<%= link_to (poll_user.start_at.nil? ? "开始答题" : "继续答题"), poll_path(@poll, :user_id => User.current.id), :class => "white-btn orange-btn fr mt10 mr15" %>
<% end %>
<% elsif setting_time.publish_time < Time.now && setting_time.end_time > Time.now %>
<%= link_to "开始答题", poll_path(@poll, :user_id => User.current.id), :class => "white-btn orange-btn fr mt10 mr15" %>
<% end %>
</p>
<% end %>
<% end %>
</ul>
<div id="edu-tab-con-1">
<div id="edu-tab-con-1" class="edu-back-white">
<div id="list_count" class="user_bg_shadow bor-grey-e padding15">
<!--老师显示部分-->
<% if @is_teacher %>
<form id="poll_user_search_form">
<li class="clearfix mb5">
<!--样式edu-filter-btn-yellow等根据状态显示-->
<% poll_curr_status = poll_curr_time @poll %>
<% if poll_curr_status[:status] != "" %>
<span class="edu-filter-btn <%= homework_status_color poll_curr_status[:status] %> fl "><%= poll_curr_status[:status] %></span>
<% end %>
<% if @poll.try(:polls_status) == 1 && @poll.publish_time %>
<span class="color-grey fr font-12">将于&nbsp;<span class="color-orange font-12"><%= format_time(@poll.publish_time).to_s %></span>&nbsp;发布</span>
<% else %>
<span class="fr font-12 <%= @poll.try(:polls_status) == 3 ? 'color-grey' : 'color-orange' %>"><%= poll_curr_status[:time] %></span>
<% end %>
</li>
<input id="poll_id" type="hidden" value="<%= @poll.id %>">
<ul class="work_search_ul clearfix">
<form id="poll_user_search_form">
<li class="clearfix mb5">
<span class="fl mr10 color-grey">答题状态:</span>
<span class="fl mr25">
<a href="javascript:void(0);" id="poll_status_no_limit" class="<%= @status.blank? ? 'check_on' : '' %> pl5 pr5">不限</a>
</span>
<input id="work_status_1" class="magic-checkbox fl" type="checkbox" value="0" name="poll_status[]" <%= !@status.blank? && @status.include?('0') ? 'checked' : '' %>>
<label for="work_status_1" class="fl mr25">未提交(<%= un_commit_num @poll %>)</label>
<input id="work_status_2" class="magic-checkbox fl" type="checkbox" value="1" name="poll_status[]" <%= !@status.blank? && @status.include?('1') ? 'checked' : '' %>>
<label for="work_status_2" class="fl mr25">按时提交(<%= has_commit_num @poll %>)</label>
<!--样式edu-filter-btn-yellow等根据状态显示-->
<% poll_curr_status = poll_curr_time @poll %>
<% if poll_curr_status[:status] != "" %>
<span class="edu-filter-btn <%= homework_status_color poll_curr_status[:status] %> fl "><%= poll_curr_status[:status] %></span>
<% end %>
<% if @poll.try(:polls_status) == 1 && @poll.publish_time %>
<span class="color-grey fr font-12">将于&nbsp;<span class="color-orange font-12"><%= format_time(@poll.publish_time).to_s %></span>&nbsp;发布</span>
<% else %>
<span class="fr font-12 <%= @poll.try(:polls_status) == 3 ? 'color-grey' : 'color-orange' %>"><%= poll_curr_status[:time] %></span>
<% end %>
</li>
<li class="clearfix mb5">
<span class="fl mr10 color-grey">分班情况:</span>
<span class="fl mr25">
<a href="javascript:void(0);" id="poll_group_no_limit" class="<%= @group.blank? ? 'check_on' : '' %> pl5 pr5">不限</a>
</span>
<div class="fl mb5" style="max-width: 83%">
<% if @group_teacher %>
<% groups = @course.course_groups.where(:id => @member.teacher_course_groups.pluck(:course_group_id)) %>
<% else %>
<% groups = @course.course_groups %>
<% end %>
<% groups.each do |group| %>
<input id="group_<%= group.id %>" class="magic-checkbox fl" type="checkbox" value="<%= group.id %>" name="poll_group[]" <%= !@group.blank? && @group.include?(group.id) ? 'checked' : '' %>>
<label for="group_<%= group.id %>" class="fl mr25"><%= group.name %>(<%= group.members.count %>)</label>
<% end %>
<% if !@group_teacher %>
<input id="group_0" class="magic-checkbox fl" type="checkbox" value="0" name="poll_group[]">
<label for="group_0" class="fl mr25">未分班(<%= @no_group_count %>)</label>
<% end %>
<input id="poll_id" type="hidden" value="<%= @poll.id %>">
<ul class="work_search_ul clearfix">
<li class="clearfix mb5">
<span class="fl mr10 color-grey">答题状态:</span>
<span class="fl mr25">
<a href="javascript:void(0);" id="poll_status_no_limit" class="<%= @status.blank? ? 'check_on' : '' %> pl5 pr5">不限</a>
</span>
<input id="work_status_1" class="magic-checkbox fl" type="checkbox" value="0" name="poll_status[]" <%= !@status.blank? && @status.include?('0') ? 'checked' : '' %> />
<label for="work_status_1" class="fl mr25">未提交(<%= un_commit_num @poll %>)</label>
<input id="work_status_2" class="magic-checkbox fl" type="checkbox" value="1" name="poll_status[]" <%= !@status.blank? && @status.include?('1') ? 'checked' : '' %> />
<label for="work_status_2" class="fl mr25">按时提交(<%= has_commit_num @poll %>)</label>
</li>
<li class="clearfix mb5">
<span class="fl mr10 color-grey">分班情况:</span>
<span class="fl mr25">
<a href="javascript:void(0);" id="poll_group_no_limit" class="<%= @group.blank? ? 'check_on' : '' %> pl5 pr5">不限</a>
</span>
<div class="fl mb5" style="max-width: 83%">
<% if @group_teacher %>
<% groups = @course.course_groups.where(:id => @member.teacher_course_groups.pluck(:course_group_id)) %>
<% else %>
<% groups = @course.course_groups %>
<% end %>
<% groups.each do |group| %>
<input id="group_<%= group.id %>" class="magic-checkbox fl" type="checkbox" value="<%= group.id %>" name="poll_group[]" <%= !@group.blank? && @group.include?(group.id) ? 'checked' : '' %> />
<label for="group_<%= group.id %>" class="fl mr25"><%= group.name %>(<%= group.members.count %>)</label>
<% end %>
<% if !@group_teacher %>
<input id="group_0" class="magic-checkbox fl" type="checkbox" value="0" name="poll_group[]">
<label for="group_0" class="fl mr25">未分班(<%= @no_group_count %>)</label>
<% end %>
</div>
</li>
</ul>
<li class="clearfix mt5 mb10">
<div class="edu-find fr mr20 with20 pr">
<div class="edu-find-input">
<input type="text" class="with100 panel-box-sizing" maxlength="20" placeholder="姓名、学号关键字检索" value="<%= @name %>" id="student_user_name" />
<!--<i class="fa fa-close mr5 color-grey edu-close" onclick="colse_searchbox();"></i>-->
<span class="edu-close" onclick="clear_searchbox();" data-tip-down="关闭">×</span>
</div>
<a href="javascript:void(0);" onclick="SearchByName_poll();" class="edu-open font-16 color-grey"><i class="fa fa-search"></i></a>
</div>
</li>
</ul>
<li class="clearfix mt5 mb10">
<div class="edu-find fr mr20 with20 pr">
<div class="edu-find-input">
<input type="text" class="with100 panel-box-sizing" maxlength="20" placeholder="姓名、学号关键字检索" value="<%= @name %>" id="student_user_name">
<!--<i class="fa fa-close mr5 color-grey edu-close" onclick="colse_searchbox();"></i>-->
<span class="edu-close" onclick="clear_searchbox();" data-tip-down="关闭">×</span>
</div>
<a href="javascript:void(0);" onclick="SearchByName_poll();" class="edu-open font-16 color-grey"><i class="fa fa-search"></i></a>
</div>
</li>
</form>
</form>
<% elsif User.current.member_of_course?(@poll.course) %>
<!--学生显示部分-->
<div class="clearfix mb10">
<p class="fl">
<% poll_user = @poll.poll_users.where(:user_id => User.current).first %>
<% if poll_user %>
<% if poll_user.commit_status > 0 %>
<span class="edu-filter-btn edu-filter-btn-orange">你已提交</span>
<% else %>
<span class="edu-filter-btn edu-filter-btn-orange">你未提交</span>
<!--学生显示部分-->
<div class="clearfix mb10">
<p class="fl">
<% poll_user = @poll.poll_users.where(:user_id => User.current).first %>
<% if poll_user %>
<% if poll_user.commit_status > 0 %>
<span class="edu-filter-btn edu-filter-btn-orange">你已提交</span>
<% else %>
<span class="edu-filter-btn edu-filter-btn-orange">你未提交</span>
<% end %>
<% end %>
<% end %>
</p>
</p>
<p class="fr font-12 mt8">
<span class="fr color-grey ml10"><%= @has_commit_count %>人已交)</span>
<% if @poll.polls_status == 2 && @poll.end_time > Time.now %>
<% end_time = @poll.end_time.to_time.to_i %>
<span class="fr color-grey">答题剩余时间:<span class="color-orange03"><%= (end_time - Time.now.to_i) / (24 * 60 * 60) %></span>天<span class="color-orange03"><%= ((end_time - Time.now.to_i) % (24 * 60 * 60)) / (60 * 60) %></span>小时<span class="color-orange03"><%= (((end_time - Time.now.to_i) % (24 * 60 * 60)) % (60 * 60)) / 60 %></span>分</span>
<% elsif @poll.polls_status == 3 %>
<span class="color-orange ml30">提交已截止</span>
<% end %>
</p>
</div>
<p class="fr font-12 mt8">
<span class="fr color-grey ml10"><%= @has_commit_count %>人已交)</span>
<% if @poll.polls_status == 2 && @poll.end_time > Time.now %>
<% end_time = @poll.end_time.to_time.to_i %>
<span class="fr color-grey">答题剩余时间:<span class="color-orange03"><%= (end_time - Time.now.to_i) / (24 * 60 * 60) %></span>天<span class="color-orange03"><%= ((end_time - Time.now.to_i) % (24 * 60 * 60)) / (60 * 60) %></span>小时<span class="color-orange03"><%= (((end_time - Time.now.to_i) % (24 * 60 * 60)) % (60 * 60)) / 60 %></span>分</span>
<% elsif @poll.polls_status == 3 %>
<span class="color-orange ml30">提交已截止</span>
<% end %>
</p>
</div>
<% end %>
<div id="poll_student_work_list">
@ -196,71 +192,71 @@
<div class="clearfix">
<% @poll.poll_questions.includes(:poll_answers).each_with_index do |poll_question, i| %>
<div class="question_item_con font-14 user_bg_shadow bor-grey-e mb20 pt15">
<div class="clearfix pl15 pr15">
<p class="fl font-15" id="mao<%= poll_question.question_number %>">
<% if poll_question.try(:is_necessary) == 1 %>
<span class="color-orange03">*</span>
<% end %>
第<%= poll_question.question_number %>
题:<span class="color-orange03">[<%= poll_question.question_type_name %>]</span>
<% if poll_question.question_type == 2 && (poll_question.min_choices != 0 || poll_question.max_choices != 0) %>
<span class="ml10">可选 <%= poll_question.min_choices %> - <%= poll_question.max_choices %> 项</span>
<% end %>
</p>
</div>
<div class="pl15 pr15 justify upload_img table_maxWidth break_word"><%= poll_question.question_title.html_safe %></div>
<% case poll_question.question_type %>
<% when 1 %>
<div class="pl15 pr15 mb15">
<% poll_answers = poll_question.poll_answers %>
<% poll_answers.each_with_index do |poll_answer, index| %>
<li class="clearfix">
<% if poll_answer.answer_text != '' %>
<input class="magic-radio fl mt5 magic-checkbox_show" id="poll_<%= poll_answer.id %>_poll_answer_id" type="radio">
<label class="fl color-grey3" for="poll_<%= poll_answer.id %>_poll_answer_id"><%= poll_answer.answer_text %></label>
<% else %>
<span class="fl mr5">
<input class="ml-3 mr5 magic-radio" id="sx_<%= poll_answer.id %>" name="<%= poll_question %>" value="" type="radio">
<label for="sx_<%= poll_answer.id %>">其它</label>
</span>
<input type="text" readonly class="fl other_input with90 mt3"/>
<% end %>
</li>
<% end %>
<div class="question_item_con font-14 user_bg_shadow bor-grey-e mb20 pt15">
<div class="clearfix pl15 pr15">
<p class="fl font-15" id="mao<%= poll_question.question_number %>">
<% if poll_question.try(:is_necessary) == 1 %>
<span class="color-orange03">*</span>
<% end %>
第<%= poll_question.question_number %>
题:<span class="color-orange03">[<%= poll_question.question_type_name %>]</span>
<% if poll_question.question_type == 2 && (poll_question.min_choices != 0 || poll_question.max_choices != 0) %>
<span class="ml10">可选 <%= poll_question.min_choices %> - <%= poll_question.max_choices %> 项</span>
<% end %>
</p>
</div>
<% when 2 %>
<div class="pl15 pr15 mb15">
<% poll_answers = poll_question.poll_answers %>
<% poll_answers.each_with_index do |poll_answer, index| %>
<li class="clearfix">
<% if poll_answer.answer_text != '' %>
<input class="magic-checkbox fl mt5 magic-checkbox_show" id="poll_<%= poll_answer.id %>_poll_answer_id" type="checkbox">
<label class="fl color-grey3" for="poll_<%= poll_answer.id %>_poll_answer_id"><%= poll_answer.answer_text %></label>
<% else %>
<span class="fl mr5">
<input class="ml-3 mr5 magic-checkbox" id="sx_<%= poll_answer.id %>" name="<%= poll_question %>" value="" type="checkbox">
<label for="sx_<%= poll_answer.id %>">其它</label>
</span>
<input type="text" readonly class="fl other_input with90 mt3"/>
<div class="pl15 pr15 justify upload_img table_maxWidth break_word"><%= poll_question.question_title.html_safe %></div>
<% case poll_question.question_type %>
<% when 1 %>
<div class="pl15 pr15 mb15">
<% poll_answers = poll_question.poll_answers %>
<% poll_answers.each_with_index do |poll_answer, index| %>
<li class="clearfix">
<% if poll_answer.answer_text != '' %>
<input class="magic-radio fl mt5 magic-checkbox_show" id="poll_<%= poll_answer.id %>_poll_answer_id" type="radio">
<label class="fl color-grey3" for="poll_<%= poll_answer.id %>_poll_answer_id"><%= poll_answer.answer_text %></label>
<% else %>
<span class="fl mr5">
<input class="ml-3 mr5 magic-radio" id="sx_<%= poll_answer.id %>" name="<%= poll_question %>" value="" type="radio">
<label for="sx_<%= poll_answer.id %>">其它</label>
</span>
<input type="text" readonly class="fl other_input with90 mt3"/>
<% end %>
</li>
<% end %>
</li>
<% end %>
</div>
<% when 3 %>
<div class="pl15 pr15 mb15">
<textarea class="task-height-150 with100 pl15" style="box-sizing: border-box" placeholder="在此填入答案" disabled></textarea>
</div>
<% end %>
</div>
</div>
<% when 2 %>
<div class="pl15 pr15 mb15">
<% poll_answers = poll_question.poll_answers %>
<% poll_answers.each_with_index do |poll_answer, index| %>
<li class="clearfix">
<% if poll_answer.answer_text != '' %>
<input class="magic-checkbox fl mt5 magic-checkbox_show" id="poll_<%= poll_answer.id %>_poll_answer_id" type="checkbox"/>
<label class="fl color-grey3" for="poll_<%= poll_answer.id %>_poll_answer_id"><%= poll_answer.answer_text %></label>
<% else %>
<span class="fl mr5">
<input class="ml-3 mr5 magic-checkbox" id="sx_<%= poll_answer.id %>" name="<%= poll_question %>" value="" type="checkbox"/>
<label for="sx_<%= poll_answer.id %>">其它</label>
</span>
<input type="text" readonly class="fl other_input with90 mt3"/>
<% end %>
</li>
<% end %>
</div>
<% when 3 %>
<div class="pl15 pr15 mb15">
<textarea class="task-height-150 with100 pl15" style="box-sizing: border-box" placeholder="在此填入答案" disabled></textarea>
</div>
<% end %>
</div>
<% end %>
</div>
</div>
</div>
<div id="edu-tab-con-4" class="user_bg_shadow bor-grey-e undis">
<%= render :partial => "poll_setting" %>
<div id="edu-tab-con-4" class="user_bg_shadow bor-grey-e undis edu-back-white">
<%= render :partial => "poll_setting" %>
</div>
</div>
</div>
</div>
<script>
$(function () {

@ -85,8 +85,9 @@
<div class="clearfix">
<div class="with15 pr fl" <%= @power ? "select-for" : "" %>>
<input type="hidden" name="mirror_script" id="shixun_scenario" value="<%= @shixun.script_tag.try(:id) %>">
<input type="text" id="shixun_scenario_name" class="task-height-40 task-form-100 panel-box-sizing pr20 color-grey3 font-14" readonly placeholder="请选择脚本" value="<%= @shixun.script_tag.try(:script_type) %>"/>
<input type="text" id="shixun_scenario_name" class="task-height-40 task-form-100 panel-box-sizing pr20 color-grey3 font-14" readonly placeholder="请选择脚本" value="<%= @shixun.script_tag.try(:script_type) ? @shixun.script_tag.try(:script_type) : "无" %>"/>
<div class="down-select bor-grey-e user_bg_shadow" id="shixun_scenario_option">
<p data-shixun-value="-1" title="无">无</p>
<% @shixun.standrad_script.each do |script| %>
<p data-shixun-value="<%= script.id %>" title="<%= script.script_type %>"><%= script.script_type %></p>
<% end %>

@ -93,7 +93,7 @@
<%#= render :partial => "student_work/echart_of_shixun_skills" %>
</div>
</div>-->
<% if true %>
<% unless params[:pdf] %>
<div class="bor-grey-e mt20">
<p class="pt10 pb10 pl15 pr15 clearfix bor-bottom-greyE">
<span class="fl font-bd">图形统计</span>

@ -61,7 +61,7 @@
<span class="paragraph_name <%= shixun.status < 2 && !is_shixun_manager ? "color-grey-c" : "color-grey3" %>"><span class="subject_stage_shixun_index"><%= s_index + 1 %></span>-<%= index + 1 %>&nbsp;&nbsp;<%= shixun.name %></span>
</li>
<li class="fr status_li">
<%= shixun_show_in_subject @subject.status, shixun.status %>
<%= shixun_show_in_subject @subject.status, shixun.status, shixun.hidden %>
<%= start_shixun_in_subject @subject, shixun, myshixun %>
</li>
</div>

@ -86,6 +86,7 @@
<% end %>
</p>
<% if User.current.logged? %>
<div class="homepagePostSetting" style="right: 4px;top: 5px;display: block">
<ul>
<li class="edu-position edu-position-hidebox">
@ -105,6 +106,8 @@
</li>
</ul>
</div>
<% end %>
</div>
</div>
<% end %>

@ -464,6 +464,7 @@ RedmineApp::Application.routes.draw do ## oauth相关
get 'sigle_mul_test'
get 'sigle_update_myshixun'
match 'training_task_status', :via => [:get, :post]
match 'code_runinng_message', :via => [:get, :post]
end
resources :games, :path => "stages" do
member do

@ -0,0 +1,10 @@
class CreateRunCodeMessages < ActiveRecord::Migration
def change
create_table :run_code_messages do |t|
t.integer :status
t.string :message
t.references :game
t.timestamps
end
end
end

@ -0,0 +1,14 @@
class MigrateHomeworkCommonEndTimes < ActiveRecord::Migration
def up
homework_commons = HomeworkCommon.where("id < 21549")
homework_commons.find_each do |homework|
sql = "update homework_commons set end_time = (select max(end_time) from
homework_seconds where id = #{homework.id}) where id = #{homework.id}"
ActiveRecord::Base.connection.execute(sql)
end
end
def down
end
end

@ -0,0 +1,13 @@
class MigrateHomeworkCommonEndTime2 < ActiveRecord::Migration
def up
homework_commons = HomeworkCommon.where("id >= 21549")
homework_commons.each do |homework|
if homework.publish_time.nil?
homework.update_column('end_time', nil)
end
end
end
def down
end
end

@ -0,0 +1,11 @@
class ModifyForkFromForShixuns < ActiveRecord::Migration
def up
shixuns = Shixun.where(:fork_from => 1933)
shixuns.each do |shixun|
shixun.update_attribute(:fork_from, nil)
end
end
def down
end
end

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save