diff --git a/app/assets/javascripts/debates.js.coffee b/app/assets/javascripts/debates.js.coffee
new file mode 100644
index 000000000..761567942
--- /dev/null
+++ b/app/assets/javascripts/debates.js.coffee
@@ -0,0 +1,3 @@
+# Place all the behaviors and hooks related to the matching controller here.
+# All this logic will automatically be available in application.js.
+# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
diff --git a/app/assets/stylesheets/debates.css.scss b/app/assets/stylesheets/debates.css.scss
new file mode 100644
index 000000000..6c45b3be9
--- /dev/null
+++ b/app/assets/stylesheets/debates.css.scss
@@ -0,0 +1,3 @@
+// Place all the styles related to the debates controller here.
+// They will automatically be included in application.css.
+// You can use Sass (SCSS) here: http://sass-lang.com/
diff --git a/app/controllers/account_controller.rb b/app/controllers/account_controller.rb
index f14c0ccc7..f31ff8eb5 100644
--- a/app/controllers/account_controller.rb
+++ b/app/controllers/account_controller.rb
@@ -586,7 +586,8 @@ class AccountController < ApplicationController
def apply_trail
apply_action = ApplyAction.where(:user_id => User.current.id, :container_type => "TrialAuthorization", :status => 0).first
- if User.current.user_extensions.identity == 1 && !User.current.user_extensions.student_id.nil? && User.current.user_extensions.student_id != "" && !User.current.user_extensions.school.nil? && [1579, 2438, 1587, 117].include?(User.current.user_extensions.school_id)
+ school_ids = School.where(:auto_users_trial => 1).map(&:id)
+ if User.current.user_extensions.identity == 1 && !User.current.user_extensions.student_id.nil? && User.current.user_extensions.student_id != "" && !User.current.user_extensions.school.nil? && school_ids.include?(User.current.user_extensions.school_id)
User.current.update_attributes(:certification => 1)
@tip = "申请成功,我们将在一分钟内完成审核"
if apply_action.blank?
diff --git a/app/controllers/challenges_controller.rb b/app/controllers/challenges_controller.rb
index aef0170ff..375596075 100644
--- a/app/controllers/challenges_controller.rb
+++ b/app/controllers/challenges_controller.rb
@@ -132,6 +132,8 @@ class ChallengesController < ApplicationController
end
end
@index = params[:position].to_i - 1
+ # 发起重置请求
+ shixun_modify_status_without_publish(@shixun, 1)
respond_to do |format|
format.js
end
@@ -157,6 +159,8 @@ class ChallengesController < ApplicationController
answer = params[:choice][:answer][index] == "0" ? false : true
ChallengeQuestion.create(:option_name => test, :challenge_choose_id => @challenge_choose.id, :position => index, :right_key => answer)
end
+ # 发起重置请求
+ shixun_modify_status_without_publish(@shixun, 1)
@challenge_choose.challenge_tags.delete_all unless @challenge_choose.challenge_tags.blank?
unless params[:knowledge].blank?
params[:knowledge][:input].each do |input|
@@ -197,7 +201,8 @@ class ChallengesController < ApplicationController
def destroy_challenge_choose
@challenge_choose = ChallengeChoose.where(:id => params[:choose_id]).first
@challenge_choose.destroy
-
+ # 发起重置请求
+ shixun_modify_status_without_publish(@shixun, 1)
redirect_to edit_shixun_challenge_path(@challenge, :shixun_id => @shixun)
end
@@ -255,7 +260,7 @@ class ChallengesController < ApplicationController
end
end
# 向jenkins端发送请求,构建公共测试用例
- add_shixun_modify_status(@shixun, 1)
+ shixun_modify_status_publish(@shixun, 1)
elsif params[:tab].to_i == 5
@challenge_tags.delete_all unless @challenge_tags.blank?
unless params[:knowledge].blank?
diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb
index 887b24d06..9eef2c48f 100644
--- a/app/controllers/courses_controller.rb
+++ b/app/controllers/courses_controller.rb
@@ -36,8 +36,9 @@ class CoursesController < ApplicationController
before_filter :require_login, :only => [:join, :unjoin]
#before_filter :allow_join, :only => [:join]
require 'bundler/setup'
- require 'simple_xlsx_reader'
-
+ if RUBY_PLATFORM =~ /linux/
+ require 'simple_xlsx_reader'
+ end
# params[:search] 搜索课程的名称
# params[:select] "join" "create" "all" 参与的 创建的 所有的课程
#
@@ -103,6 +104,17 @@ class CoursesController < ApplicationController
@import_attachments = Attachment.where(:container_id => @course.id, :container_type => "ImportStudent")
end
+ def shixun_statistics
+ @homeworks = @course.homework_commons.where("homework_type = 4").order("created_at asc")
+ filename="#{format_date(Time.now)}_#{@course.teacher.show_real_name.to_s}_#{@course.name}_实训数据报告";
+
+ respond_to do |format|
+ format.xls {
+ send_data(shixun_xls(@homeworks,@course), :type => 'application/octet-stream', :filename => filename_for_content_disposition("#{filename}.xls"))
+ }
+ end
+ end
+
# REDO:性能需要优化,这块是管理员后台任务,不影响用户使用
def sync_students
school_id = User.find(@course.tea_id).try(:user_extensions).try(:school_id)
@@ -1988,6 +2000,87 @@ class CoursesController < ApplicationController
@results = paginateHelper @results, @limit
end
+ def shixun_xls homeworks, course
+ xls_report = StringIO.new
+ book = Spreadsheet::Workbook.new
+ blue = Spreadsheet::Format.new :color => :blue, :weight => :bold, :size => 10
+ black = Spreadsheet::Format.new :color => :black, :weight => :bold, :size => 10
+ current_row = 0
+ homeworks.each_with_index do |homework, i|
+ sheet = book.create_worksheet :name => "第#{i+1}次作业"
+ sheet.row(0).default_format = blue
+ sheet[0,0] = "课堂编号"
+ sheet[0,1] = "主讲老师"
+ sheet[0,2] = "课堂名称"
+ sheet[0,3] = "作业编号"
+ sheet[0,4] = "作业/实训名称"
+ sheet[0,5] = "关卡"
+ sheet[0,6] = "学生id"
+ sheet[0,7] = "学生姓名"
+ sheet[0,8] = "经验值"
+ sheet[0,9] = "金币"
+ sheet[0,10] = "评测历史"
+ sheet[0,11] = "评测时间"
+ sheet[0,12] = "评测结果"
+ sheet[1,0] = course.id
+ sheet[1,1] = course.teacher.show_real_name
+ sheet[1,2] = course.name
+ sheet[1,3] = "# #{i + 1}"
+ sheet[1,4] = homework.name
+ current_row = 1
+ shixun = homework.homework_commons_shixuns.shixun if homework.homework_commons_shixuns
+ if shixun
+ shixun.challenges.each_with_index do |challenge, j|
+ sheet[current_row,5] = "第#{j+1}关"
+ games = Game.where(:challenge_id => challenge.id, :user_id => homework.student_works.where("work_status != 0").map(&:user_id))
+ count_exp_score = 0
+ count_gold_score = 0
+ count_test = 0
+ count_time = 0
+ if games.count > 0
+ games.each do |game|
+ user = game.user
+ sheet[current_row,6] = user.login
+ sheet[current_row,7] = user.show_real_name
+ sheet[current_row,8] = game.final_score ? "+#{game.final_score.to_s} 经验值" : "--"
+ count_exp_score = count_exp_score + (game.final_score ? game.final_score.to_i : 0)
+ sheet[current_row,9] = game.final_score ? (game.answer_open? ? "#{-challenge.score.to_i} 金币" : "+#{game.final_score.to_i} 金币") : "--"
+ count_gold_score = count_gold_score + (game.final_score ? (game.answer_open? ? -challenge.score.to_i : game.final_score.to_i) : 0)
+
+ count = game.outputs.count
+ if count > 0
+ outputs = game.outputs.where(:test_set_position => 1).order("created_at asc")
+ outputs.each_with_index do |output, k|
+ count_test = count_test + 1
+ sheet[current_row,10] = "第#{k+1}次评测"
+ sheet[current_row,11] = k == 0 ? game_spend_time((output.created_at - game.created_at).to_i) : game_spend_time((output.created_at - outputs[k-1].created_at).to_i)
+ count_time = count_time + (k == 0 ? (output.created_at - game.created_at).to_i : (output.created_at - outputs[k-1].created_at).to_i)
+ sheet[current_row,12] = game.outputs.where(:query_index => output.query_index).select{|ou| ou.result == false}.count > 0 ? "失败" : "成功"
+ current_row = current_row + 1
+ end
+ else
+ current_row = current_row + 1
+ end
+ end
+ else
+ current_row = current_row + 1
+ end
+
+ sheet[current_row,6] = "合计"
+ sheet[current_row,7] = games.count.to_s + "人"
+ sheet[current_row,8] = count_exp_score >= 0 ? "+#{count_exp_score} 经验值" : "-#{count_exp_score} 经验值"
+ sheet[current_row,9] = count_gold_score >= 0 ? "+#{count_gold_score} 金币" : "-#{count_gold_score} 金币"
+ sheet[current_row,10] = "共#{count_test}次评测"
+ sheet[current_row,11] = game_spend_time((count_time == 0 ? 0 : (count_time / count_test)).to_i)+"/次"
+ sheet.row(current_row).default_format = black
+ current_row = current_row + 1
+ end
+ end
+ end
+ book.write xls_report
+ xls_report.string
+ end
+
def member_to_xls homeworks, course, members,groups
xls_report = StringIO.new
book = Spreadsheet::Workbook.new
diff --git a/app/controllers/debates_controller.rb b/app/controllers/debates_controller.rb
new file mode 100644
index 000000000..5e442e4bb
--- /dev/null
+++ b/app/controllers/debates_controller.rb
@@ -0,0 +1,2 @@
+class DebatesController < ApplicationController
+end
diff --git a/app/controllers/forums_controller.rb b/app/controllers/forums_controller.rb
index ed646354c..337f951aa 100644
--- a/app/controllers/forums_controller.rb
+++ b/app/controllers/forums_controller.rb
@@ -119,8 +119,10 @@ class ForumsController < ApplicationController
end
def index
- order = ""
+ order = "sticky desc, created_at desc"
@order_str = ""
+ @user = User.current
+=begin
if(params[:reorder_complex])
order = "replies_count #{params[:reorder_complex]}, #{Memo.table_name}.created_at #{params[:reorder_complex]}"
@order_str = "reorder_complex="+params[:reorder_complex]
@@ -134,6 +136,7 @@ class ForumsController < ApplicationController
order = "#{Memo.table_name}.updated_at desc"
@order_str = "reorder_time=desc"
end
+=end
@memo = Memo.new(:forum => @forum)
@memos = Memo.where("parent_id is null")
@topic_count = @memos.count
@@ -148,10 +151,13 @@ class ForumsController < ApplicationController
@my_forums_count = Memo.where("author_id =? and parent_id is null", User.current.id).count
@my_memos_count = Memo.where("author_id =? and parent_id is not null", User.current.id).count
@errors = params[:errors]
+ memos_id = Memo.where("author_id =?", User.current.id).map(&:id)
+ @memos_praise_count = PraiseTread.where(:praise_tread_object_id => memos_id, :praise_tread_object_type => "Memo").count
+
respond_to do |format|
format.js
format.html {
- render :layout => 'base_new_forum'
+ render :layout => 'base_edu'
}# show.html.erb
format.json { render json: @forum }
end
@@ -181,13 +187,10 @@ class ForumsController < ApplicationController
end
@memo = Memo.new(:forum => @forum)
@topic_count = @forum.topics.count
- @topic_pages = Paginator.new @topic_count, per_page_option, params['page']
- @memos = @forum.topics.includes(:last_reply).
- limit(@topic_pages.per_page).
- offset(@topic_pages.offset).
- reorder(order).
- preload(:author, {:last_reply => :author}).
- all
+ @limit = 20
+ @is_remote = true
+ @topic_pages = Paginator.new @topic_count, @limit, params['page'] || 1
+ @memos = paginateHelper @forum.topics.includes(:last_reply).reorder(order).preload(:author, {:last_reply => :author}), @limit
@my_topic_count = Memo.where("forum_id = #{@memo.forum_id} and parent_id is null").count
@my_replies_count = Memo.where("forum_id = #{@memo.forum_id} and parent_id is not null").count
@errors = params[:errors]
diff --git a/app/controllers/games_controller.rb b/app/controllers/games_controller.rb
index 69194f1f8..438c6f8ee 100644
--- a/app/controllers/games_controller.rb
+++ b/app/controllers/games_controller.rb
@@ -4,13 +4,72 @@ class GamesController < ApplicationController
skip_before_filter :verify_authenticity_token, :only => [:file_update]
before_filter :find_myshixun, :only => [:index]
before_filter :find_game, :only => [:show, :game_build, :entry,:next_step, :prev_step,:outputs_show, :file_edit, :file_update, :get_waiting_time,
- :game_status, :change_status, :answer, :minus_score, :refresh_game_list, :reset_original_code, :reset_new_code, :evaluating_choice]
+ :game_status, :change_status, :answer, :minus_score, :refresh_game_list, :reset_original_code, :reset_new_code, :evaluating_choice, :sync_codes]
before_filter :find_repository, :only => [:show, :entry, :file_edit, :file_update, :reset_original_code, :reset_new_code, :html_show]
before_filter :allowd_manager
before_filter :allowd_view, :only => [:show]
before_filter :find__shixun_language, :only => [:show, :entry]
include ApplicationHelper
+ require 'open3'
+ # 同步更新最新代码
+ # 同步完成后,需要更新myshixun的commit_id为实训的commit最新值
+ # --------------------------
+ # 新思路,有冲突则则重置,没有冲突直接pull
+ # --------------------------
+ def sync_codes
+ g = Gitlab.client
+ myshixun_user_login = User.where(:id => @myshixun.user_id).first.try(:login)
+ myshixun_rep_identifier = Repository.where(:myshixun_id => @myshixun.id, :type => "Repository::Gitlab").first.try(:identifier)
+ gitlab_address = Redmine::Configuration['gitlab_address']
+ gitlab_myshixun_url = git_myshixun_url(@myshixun, @myshixun.try(:user_id))
+ shixun = @myshixun.shixun
+ gitlab_shixun_url = git_shixun_url(shixun, (shixun.try(:fork_from).blank? ? "educoder" : "eduforge"))
+ if RUBY_PLATFORM =~ /w32/
+ path = "c:/test/"
+ else
+ path = "/home/pdl/myshixun_shell"
+ end
+ script = "cd #{path}
+ git clone #{gitlab_address.to_s+'/'+myshixun_user_login+'/'+ myshixun_rep_identifier}.git
+ cd #{myshixun_rep_identifier}/
+ git remote set-url origin https://#{shixun.fork_from.blank? ? "educoder" : "eduforge"}:xinhu1ji2qu3@testbdgit.trustie.net/#{myshixun_user_login}/#{myshixun_rep_identifier}.git
+ git remote add remote_origin #{gitlab_shixun_url}
+ #git pull
+ git pull remote_origin master
+ if [ $? -eq 0 ];then
+ echo -e 'git pull succssed'
+ else
+ git reset --hard #{@myshixun.commit_id}
+ git pull remote_origin master
+ if [ $? -eq 0 ];then
+ echo -e 'git reset and pull succssed'
+ else
+ echo -e 'git reset and pull failed'
+ fi
+ fi
+ git push -f origin master
+ if [ $? -eq 0 ];then
+ echo -e 'git push succssed'
+ cd ../
+ rm -rf #{myshixun_rep_identifier}/
+ else
+ echo -e 'git push failed'
+ fi"
+ aFile =File.new(File.join("#{path}","#{@myshixun.identifier}.sh"), "w+")
+ if aFile
+ aFile.syswrite(script)
+ else
+ logger.error "Unable to open file!"
+ end
+ system("sh #{path}/#{@myshixun.identifier}.sh")
+ # stdin, stdout, stderr = Open3.popen3("sh #{path}/#{@myshixun.identifier}.sh")
+ shixun_new_commit = g.commits(@myshixun.shixun.try(:gpid)).first.try(:id)
+ @myshixun.update_column(:commit_id, shixun_new_commit)
+ sleep(2) # g
+ render :json => {:status => 200}
+ end
+
def index
@games = @myshixun.games.includes(:challenge)
@games_count = @games.count
@@ -28,7 +87,7 @@ class GamesController < ApplicationController
# git_repository_url @myshixun, "Myshixun"
# @st 0 实践任务 1 多选任务 2 单选任务
def show
- # 展示全部实训
+ # 展示全部实训
@is_subject = params[:is_subject]
if @game.status == 1
# 放置页面ajax数据还没获取就关闭
@@ -39,6 +98,9 @@ class GamesController < ApplicationController
@game_challenge = @game.challenge
@challenges = Challenge.where(:shixun_id => @myshixun.shixun_id)
@shixun = @myshixun.shixun
+ # 判断tpm是否修改了
+ @tpm_modified = tpm_is_modified(@myshixun, @shixun.try(:gpid))
+ # end
@praise_count = PraiseTread.where(:praise_tread_object_id => @game_challenge.id, :praise_tread_object_type => "Challenge").count
@tread_count = PraiseTread.where(:praise_tread_object_id => @game_challenge.id, :praise_tread_object_type => "ChallengeTread").count
# @games_count = @games.count
@@ -166,7 +228,7 @@ class GamesController < ApplicationController
raise("实训云平台繁忙(繁忙等级:94)")
end
render :json => {:result => "success", :onRun => res['onRun'], :waitNum => res['waitNum'], :waitingTime => res['waitingTime'], :resubmit => resubmit }
- #render :json => {:result => "success", :onRun => 0, :waitNum => 12, :waitingTime => 1234 }
+ #render :json => {:result => "success", :onRun => 0, :waitNum => 12, :waitingTime => 1234 }
rescue Exception => e
render :json => {:result => "failed"}
end
@@ -316,9 +378,9 @@ class GamesController < ApplicationController
answer_right = []
@game_challenge.challenge_chooses.each_with_index do |choose, index|
correct = (params[:answer][index] == choose.standard_answer) ? true : false
- if choose.current_choose_outputs.blank?
- ChooseOutputs.create(:challenge_choose_id => choose.id, :user_id => User.current.id, :answer => params[:answer][index], :correct => correct)
- end
+ #choose.current_choose_outputs.delete if choose.current_choose_outputs.present?
+ #ChooseOutputs.create(:challenge_choose_id => choose.id, :user_id => User.current.id, :answer => params[:answer][index], :correct => correct)
+ Output.create(:game_id => @game.id, :test_set_position => choose.position, :actual_output => params[:answer][index], :result => correct, :query_index => @game.query_index)
if @shixun.status > 1 && !@game.answer_open
if correct
score += choose.score
@@ -332,14 +394,15 @@ class GamesController < ApplicationController
end
answer_right << correct
end
- @game.update_attributes(:status => 2, :end_time => Time.now)
@had_done = @game.had_done
- reward_grade(@game.user, @game.id, 'Game', score)
- reward_experience(@game.user, @game.id, 'Game', score)
- @game.update_attribute(:final_score, score)
-
+ if @right
+ @game.update_attributes(:status => 2, :end_time => Time.now)
+ reward_grade(@game.user, @game.id, 'Game', score)
+ reward_experience(@game.user, @game.id, 'Game', score)
+ @game.update_attribute(:final_score, score)
+ end
respond_to do |format|
- format.js{redirect_to myshixun_game_path(@game, :myshixun_id => @myshixun, :choose => 1)}
+ format.js{redirect_to myshixun_game_path(@game, :myshixun_id => @myshixun, :choose => @right)}
end
end
@@ -407,7 +470,7 @@ class GamesController < ApplicationController
if(params[:choose] == "true")
challenge.challenge_chooses.each_with_index do |choose, index|
@answer += "第"+ ((index + 1).to_s) +"题:
"
- @answer += choose.answer
+ @answer += (choose.answer.blank? ? choose.standard_answer : choose.answer)
@answer += "
"
end
else
@@ -434,11 +497,17 @@ class GamesController < ApplicationController
user = User.current
challenge_score = @game_challenge.score.to_i
reward_grade(user, @game.id, 'Answer', -challenge_score)
- @answer = @game_challenge.answer
- @game.update_column(:answer_open, true)
- respond_to do |format|
- format.js
+ @answer = ""
+ if @game.challenge.st == 0
+ @answer = @game_challenge.answer
+ else
+ @game_challenge.challenge_chooses.each_with_index do |choose, index|
+ @answer += "第"+ ((index + 1).to_s) +"题:
"
+ @answer += (choose.answer.blank? ? choose.standard_answer : choose.answer)
+ @answer += "
"
+ end
end
+ @game.update_column(:answer_open, true)
end
def refresh_game_list
diff --git a/app/controllers/managements_controller.rb b/app/controllers/managements_controller.rb
index 32010e53f..ca8c7f1a3 100644
--- a/app/controllers/managements_controller.rb
+++ b/app/controllers/managements_controller.rb
@@ -7,6 +7,80 @@ class ManagementsController < ApplicationController
include UsersHelper
include ApplicationHelper
+ #用户修改
+ def account
+ @user = User.find(params[:user_id])
+ ue = @user.user_extensions
+ # @trail_authentication = ApplyAction.where(:user_id => @user.id, :container_type => "TrialAuthorization").order("created_at desc").first
+ # @authentication = @user.authentication
+ # if @user.nickname.nil? || @user.lastname.nil? || ue.try(:identity).nil? || ue.try(:location).nil? || ue.try(:location).nil?
+ # @require_auth = true
+ # else
+ # if User.current.certification != 1 && (@trail_authentication.blank? || (@trail_authentication.status == 2 && (@trail_authentication.updated_at.to_i + 5*60) < Time.now.to_i))
+ # @require_trail_auth = true
+ # end
+ # end
+ # @s_message = AppliedMessage.where(:status => 3, :user_id => User.current.id, :viewed => 0, :applied_type => 'ApplyAddSchools').first
+ # @d_message = AppliedMessage.where(:status => 3, :user_id => User.current.id, :viewed => 0, :applied_type => 'ApplyAddDepartment').first
+
+ # AppliedMessage.where(:status => 3, :user_id => User.current.id, :viewed => 0, :applied_type => 'ApplyAddSchools').update_all(:viewed => true)
+ # AppliedMessage.where(:status => 3, :user_id => User.current.id, :viewed => 0, :applied_type => 'ApplyAddDepartment').update_all(:viewed => true)
+
+ lg = @user.login
+ @pref = @user.pref
+ diskfile = disk_filename('User', @user.id)
+ diskfile1 = diskfile + 'temp'
+ begin
+ if request.post?
+ @user.nickname = params[:nickname]
+ @user.lastname = params[:lastname]
+ @user.firstname = ""
+ @user.show_realname = params[:show_realname] ? 0 : 1
+ @user.pref.attributes = params[:pref]
+ @user.mail = params[:mail]
+ @user.phone = params[:phone]
+ @user.password = params[:new_password]
+ @user.pref[:no_self_notified] = (params[:no_self_notified] == '1')
+ @se = @user.extensions
+ @se.school_id = params[:occupation]
+ @se.department_id = params[:department_id]
+ @se.gender = params[:sex]
+ @se.location = params[:province] if params[:province]
+ @se.location_city = params[:city] if params[:city]
+ @se.identity = params[:identity].to_i if params[:identity]
+ if @se.identity == 0
+ @se.technical_title = params[:te_technical_title] if params[:te_technical_title]
+ @se.student_id = nil
+ elsif @se.identity == 1
+ @se.student_id = params[:no] if params[:no]
+ @se.technical_title = nil
+ elsif @se.identity == 2
+ @se.technical_title = params[:pro_technical_title] if params[:pro_technical_title]
+ @se.student_id = nil
+ end
+ @se.brief_introduction = params[:brief_introduction]
+
+ if @user.save && @se.save
+ reward_grade(@user, @user.id, 'Account', 500)
+ # 头像保存
+ FileUtils.mv diskfile1, diskfile, force: true if File.exist? diskfile1
+ @user.pref.save
+ @user.notified_project_ids = (@user.mail_notification == 'selected' ? params[:notified_project_ids] : [])
+ set_language_if_valid @user.language
+ flash[:notice] = l(:notice_account_updated)
+ return
+ else
+ @user.login = lg
+ end
+
+ end
+ # 不管前面是否有异常,如果文件已存在就删除
+ ensure
+ File.delete(diskfile1) if File.exist?(diskfile1)
+ end
+ @setting_type = 1
+ end
+
# 镜像管理
def mirror_repository
@menu_type = 3
@@ -482,14 +556,26 @@ end
def save_school
uploaded_io = params[:logo]
sl = School.create(:name => params[:schoolname],:province => params[:province],:city => params[:city],:address => params[:address])
- # sl = School.create(:name => params[:school],:province => params[:schollProvince],:city => params[:schoolCity],:address => params[:address])
unless uploaded_io.nil?
- File.new(Rails.root.join('public', 'images', 'school', sl.id.to_s+'.png'), 'wb').write(sl.id)
- # File.new(Rails.root.join('public', 'images', 'school', sl.id.to_s+'.png'), 'wb') do |file|
- # file.write(uploaded_io.read)
- # end
+ File.open(Rails.root.join('public', 'images', 'school', sl.id.to_s+'.png'), 'wb') do |file|
+ file.write(uploaded_io.read)
+ end
sl.logo_link = '/images/school/'+sl.id.to_s+'.png'
+ sl.save
end
+
+ @user = User.current
+ @se = @user.extensions
+
+ # if @user.save && @se.save
+ # diskfile1 = disk_filename('school', sl.id , 'id')
+ # diskfileID = diskfile1 + 'temp'
+ # begin
+ # FileUtils.mv diskfileID, diskfile1, force: true if File.exist? diskfileID
+ # ensure
+ # File.delete(diskfileID) if File.exist?(diskfileID)
+ # end
+ # end
redirect_to departments_part_managements_path
end
@@ -764,36 +850,35 @@ end
def classroom_classment
@menu_type = 2
@sub_type = 2
- @sx_order = params[:sx_order].blank? ? "desc" : params[:sx_order]
+ @sx_order = params[:sx_order].blank? ? "desc" : params[:sx_order]
@courses = Course.where(:is_delete => 0)
- @timing = Course.where(:is_end=>false).count
- @end = Course.where(:is_end=>true).count
+ @timing=Course.where(:is_end=>false).count
+ @end=Course.where(:is_end=>true).count
@course_lists = CourseList.where(:id => Course.where(:is_delete => 0 ).map(&:course_list_id) )
unless params[:school_id] || params[:search] || params[:keyword] || params[:status]
- user_exs=UserExtensions.where(:school_id=> @courses.map(&:school_id))
- @schools = School.where(:id =>user_exs.map(&:school_id))
+ user_exs=UserExtensions.where(:school_id=> @courses.map(&:school_id))
+ @schools = School.where(:id =>user_exs.map(&:school_id))
end
@search = params[:search] # 搜索字
@keyword = params[:keyword].blank? ? "u_name" : params[:keyword] # 根据姓名/课程名搜索
- status = params[:status].to_i
- courselist = params[:course_list]
+ @status = params[:status]
+ @courselist = params[:course_list]
+ @school_id = params[:school_id]
if params[:school_id] && params[:school_id] != ''
- @school_id = params[:school_id]
- @courses = @courses.joins("join users u on courses.tea_id = u.id").joins("join user_extensions ue on u.id = ue.user_id").where("ue.school_id = #{params[:school_id]}")
+ @courses = Course.joins("join users u on courses.tea_id = u.id").joins("join user_extensions ue on u.id = ue.user_id").where("ue.school_id = #{params[:school_id]}")
end
if params[:homepage_show]
@courses = @courses.where(:homepage_show => params[:homepage_show].to_i)
end
- if courselist && courselist != ''
- @courses = @courses.where(:course_list_id => courselist)
+ if params[:course_list] && params[:course_list] != ''
+ @courses = @courses.where(:course_list_id => @courselist)
end
if params[:status] && params[:status]!=''
- @status = params[:status]
- @courses =@courses.where(:is_end =>status)
+ @courses =@courses.where(:is_end => @status.to_i)
end
if "u_name" == @keyword
if @search.blank?
@@ -806,6 +891,7 @@ end
@courses= @courses.where("name like '%#{@search}%'")
end
@courses = @courses.select("courses.*,(SELECT MAX(updated_at) FROM `course_activities` WHERE course_activities.course_id = courses.id) AS updatetime").reorder("updatetime #{@sx_order}")
+ @export_courses = @courses
@courses_count = @courses.count
limit = 20
@is_remote = true
@@ -815,6 +901,11 @@ end
respond_to do |format|
format.js
format.html
+ format.xls{
+ @export_courses = @export_courses.all
+ filename = "#{l(:label_course_list_xls)}.xls"
+ send_data(course_list_xls(@export_courses), :type => 'application/octet-stream', :filename => filename_for_content_disposition(filename))
+ }
end
end
@@ -1055,6 +1146,14 @@ end
end
end
+ # 允许复制
+ def shixun_can_copy
+ if params[:shixun_id]
+ shixun = Shixun.find params[:shixun_id]
+ shixun.update_attributes(:can_copy => !shixun.can_copy)
+ end
+ end
+
# 已关闭的实训
def close_shixuns
@menu_type = 3
@@ -1105,19 +1204,31 @@ end
def auto_users_trial
@menu_type = 7
@sub_type = 3
- @schools = School.where("0=0")
- @schools_count = @schools.count
+ @apply_action = School.where(:auto_users_trial => 1).order('updated_at desc')
+ @apply_action_count = @apply_action.count
limit = 20
@is_remote = true
- @schools_pages = Paginator.new @schools_count, limit, params['page'] || 1
- @offset ||= @schools_pages.offset
- @schools = paginateHelper @schools, limit
+ @apply_action_pages = Paginator.new @apply_action_count, limit, params['page'] || 1
+ @offset ||= @apply_action_pages.offset
+ @apply_action = paginateHelper @apply_action, limit
respond_to do |format|
format.html
format.js
end
end
+ # 添加
+ def create_auto_users_trial
+ School.where(:id => params[:school]).update_all(:auto_users_trial => 1)
+ redirect_to auto_users_trial_managements_path
+ end
+
+ # 删除
+ def update_auto_users_trial
+ School.where(:id => params[:school]).update_all(:auto_users_trial => 0)
+ redirect_to auto_users_trial_managements_path
+ end
+
def search_user
=begin
@@ -1358,7 +1469,14 @@ end
user = User.find(apply_user.user_id)
apply_user.update_attribute(:status, 1)
user.update_attribute(:authentication, true)
+
@unapproved_user = ApplyUserAuthentication.where(:status => 0, :auth_type => 1).order("updated_at desc")
+ @unapproved_user_count = @unapproved_user.count
+ @limit = 15
+ @is_remote = true
+ @unapproved_user_pages = Paginator.new @unapproved_user_count, @limit, params['page'] || 1
+ @offset ||= @unapproved_user_pages.offset
+ @unapproved_user = paginateHelper @unapproved_user, @limit
respond_to do |format|
format.js
end
@@ -1369,6 +1487,7 @@ end
apply_user = ApplyUserAuthentication.where(:id => params[:apply_id], :auth_type => 2).first
reason = apply_user.update_attributes(:status => 2, :remarks => params[:reject_reason])
render :json => {success: reason}
+
end
# 同意职业认证
@@ -1378,6 +1497,12 @@ end
apply_user.update_attribute(:status, 1)
user.update_attribute(:professional_certification, true)
@unapproved_user = ApplyUserAuthentication.where(:status => 0, :auth_type => 2).order("updated_at desc")
+ @unapproved_user_count = @unapproved_user.count
+ @limit = 15
+ @is_remote = true
+ @unapproved_user_pages = Paginator.new @unapproved_user_count, @limit, params['page'] || 1
+ @offset ||= @unapproved_user_pages.offset
+ @unapproved_user = paginateHelper @unapproved_user, @limit
respond_to do |format|
format.js
end
@@ -1406,7 +1531,8 @@ end
@menu_type = 10
@sub_type = 5
@type = trial_authorization_status params[:type]
- @authorizations = ApplyAction.where(:container_type => "ApplyShixun", :status => @type).order("created_at desc")
+ # sql = select * from apply_actions where dealer_id is null
+ @authorizations = ApplyAction.where(:container_type => "ApplyShixun", :status => @type,:dealer_id =>'').order("created_at desc")
search = params[:search]
unless search.blank?
@authorizations = @authorizations.where(:container_id => Shixun.where(:id => @authorizations.map(&:container_id)).where("name like '%#{search}%'").map(&:id)).order("created_at desc")
@@ -1509,28 +1635,29 @@ end
render_404
end
- def course_list_xls course
+ def course_list_xls courses
xls_report = StringIO.new
book = Spreadsheet::Workbook.new
sheet1 = book.create_worksheet :name => "course"
blue = Spreadsheet::Format.new :color => :blue, :weight => :bold, :size => 10
sheet1.row(0).default_format = blue
- sheet1.row(0).concat([l(:issue_xls_id),l(:issue_xls_tracker_id),l(:issue_xls_title),l(:issue_xls_description),l(:issue_xls_status),l(:issue_xls_assign),l(:issue_xls_priority),l(:issue_xls_author),l(:issue_xls_created_at),l(:milestone),l(:issue_xls_start),l(:issue_xls_due),l(:issue_xls_ratio)])
+ sheet1.row(0).concat(["ID","课堂名称","成员","资源","普通作业"," 实训作业","试卷","私有","状态","创建者单位","创建者","动态时间"])
count_row = 1
- issues.each do |issue|
- sheet1[count_row,0] = issue.id
- sheet1[count_row,1] = issue_tracker_change(issue.tracker_id)
- sheet1[count_row,2] = issue.subject
- sheet1[count_row,3] = (issue.description.gsub(/<\/?.*?>/,"")).html_safe
- sheet1[count_row,4] = issue_status_change(issue.status_id)
- sheet1[count_row,5] = issue.assigned_to.try(:show_name)
- sheet1[count_row,6] = issue_priority_change(issue.priority_id)
- sheet1[count_row,7] = issue.author.show_name
- sheet1[count_row,8] = issue.created_on.nil? ? issue.created_on : issue.created_on.strftime('%Y-%m-%d %H:%M:%S')
- sheet1[count_row,9] = issue.fixed_version.try(:name)
- sheet1[count_row,10] = issue.start_date.nil? ? issue.start_date : issue.start_date.strftime('%Y-%m-%d')
- sheet1[count_row,11] = issue.due_date.nil? ? issue.due_date : issue.due_date.strftime('%Y-%m-%d')
- sheet1[count_row,12] = issue_ratio_change(issue.done_ratio, issue.status_id)
+ courses.each do |course|
+ school = course.teacher.try(:user_extensions).try(:school).try(:name).blank? ? "--" : course.teacher.school_name
+ teacher_name = course.teacher ? course.teacher.show_real_name : ""
+ sheet1[count_row,0] = course.id
+ sheet1[count_row,1] = course.name
+ sheet1[count_row,2] = course.members.count
+ sheet1[count_row,3] = course.attachments.count
+ sheet1[count_row,4] = course.homework_commons.where(:homework_type => 1).count
+ sheet1[count_row,5] = course.homework_commons.where(:homework_type => 4).count
+ sheet1[count_row,6] = course.exercises.count
+ sheet1[count_row,7] = course.is_public.to_i == 1 ? '否' : '是'
+ sheet1[count_row,8] = course.is_end ? "已结束" : "正在进行"
+ sheet1[count_row,9] = school
+ sheet1[count_row,10] = teacher_name
+ sheet1[count_row,11] = format_time(course.updatetime)
count_row += 1
end
book.write xls_report
diff --git a/app/controllers/memos_controller.rb b/app/controllers/memos_controller.rb
index 7f4c1d48e..7e9662563 100644
--- a/app/controllers/memos_controller.rb
+++ b/app/controllers/memos_controller.rb
@@ -1,6 +1,6 @@
class MemosController < ApplicationController
default_search_scope :memos
- before_filter :find_forum, :only => [:new, :create, :preview, :update]
+ before_filter :find_forum, :only => [:new, :create, :preview, :update, :reply]
before_filter :find_attachments, :only => [:preview]
before_filter :find_memo, :except => [:new, :create, :preview]
before_filter :authenticate_user_edit, :only => [:edit, :update]
@@ -29,13 +29,14 @@ class MemosController < ApplicationController
def new
# 如何是问吧主页来的,导航不显示具体贴吧名
+ @user = User.current
@memo = Memo.new
- @my_forums_count = Memo.where("author_id =? and parent_id is null", User.current.id).count
- @my_memos_count = Memo.where("author_id =? and parent_id is not null", User.current.id).count
+ @my_forums_count = Memo.where("author_id =? and parent_id is null",@user.id).count
+ @my_memos_count = Memo.where("author_id =? and parent_id is not null", @user.id).count
@forums = Forum.reorder("topic_count desc,updated_at desc")
respond_to do |format|
format.js
- format.html {render layout: 'base_new_forum'}
+ format.html {render layout: 'base_edu'}
format.json { render json: @memo }
end
end
@@ -88,6 +89,7 @@ class MemosController < ApplicationController
REPLIES_PER_PAGE = 20 unless const_defined?(:REPLIES_PER_PAGE)
def show
+ @user = User.current
# 更新贴吧帖子留言对应的memo_messages的viewed字段
unless @memo.children.blank?
@memo.children.each do |child|
@@ -141,19 +143,20 @@ class MemosController < ApplicationController
respond_to do |format|
format.js
- format.html {render :layout => 'base_new_forum'}
+ format.html {render :layout => 'base_edu'}
format.json { render json: @memo }
format.xml { render xml: @memo }
end
end
def edit
- @my_topic_count = 0
- @my_replies_count = Memo.where(:parent_id => @memo.id).count
- @forums = Forum.reorder("topic_count desc,updated_at desc")
- @replying = false
+ #@my_topic_count = 0
+ #@my_replies_count = Memo.where(:parent_id => @memo.id).count
+ #@forums = Forum.reorder("topic_count desc,updated_at desc")
+ #@replying = false
+ @user = User.current
respond_to do |format|
- format.html {render :layout => 'base_new_forum'}
+ format.html {render :layout => 'base_edu'}
end
end
@@ -173,7 +176,7 @@ class MemosController < ApplicationController
@flag = @memo.save
# @memo.root.update_attribute(:updated_at, @memo.updated_at)
format.js
- format.html {redirect_to back_memo_url, notice: "#{l :label_memo_update_succ}"}
+ format.html {redirect_to back_memo_url}
else
format.js
format.html { render action: "edit" }
@@ -182,12 +185,64 @@ class MemosController < ApplicationController
end
end
+ def reply
+ if params[:memo].present? && params[:memo][:parent_id].present?
+ parent = Memo.find params[:memo][:parent_id]
+ @memo = params[:activity_id].blank? ? parent : Memo.find(params[:activity_id].to_i)
+ @reply = Memo.new
+ @reply.author = User.current
+ @reply.forum_id = parent.forum_id
+ @reply.content = params[:content]
+ @reply.subject = "RE: #{@memo.subject}"
+ #@reply.reply_id = params[:id]
+ @reply.root_id = parent.root_id.nil? ? parent.id : parent.root_id
+ # @reply.reply_id = params[:id]
+ parent.children << @reply
+ else
+ @reply = Memo.new()
+ @reply.content = params[:content]
+ @reply.subject = @memo.subject
+ @reply.author = User.current
+ @reply.forum_id = @forum.id
+ #@reply.content = @quote + @reply.content
+ #@reply.subject = "RE: #{@topic.subject}" unless params[:reply][:subject]
+ @reply.root_id = @memo.id
+ @reply.safe_attributes = params[:reply]
+ @memo.children << @reply
+ # @reply.reply_id = params[:id]
+ end
+
+ redirect_to message_replies_forum_memo_path(@memo.forum, @memo, :user_activity_id => params[:user_activity_id])
+ end
+
+ def message_replies
+ @replies = Memo.where(:root_id => @memo.id).order("created_at desc")
+ @reply_count = @replies.count
+ @replies = get_no_children_comments_all @replies
+ #@limit_count = @replies.count
+ #@page = params[:page] ? params[:page].to_i + 1 : 0
+ #@limit = 10
+ #@replies = @replies[@page * @limit..@page * @limit + 9]
+ @reply = Message.new()
+ @user_activity_id = params[:user_activity_id].blank? ? @memo.id : params[:user_activity_id].to_i
+ respond_to do |format|
+ format.js
+ end
+
+ end
+
def destroy
@memo.destroy
-
respond_to do |format|
- # format.html { redirect_to @back_url }
- format.html { redirect_to back_memo_or_forum_url }
+ #format.html { redirect_to @back_url }
+ format.html { redirect_to forums_path }
+ format.js{
+ @memo = Memo.find(params[:user_activity_id].to_i)
+ @replies = Memo.where(:root_id => @memo.id).order("created_at desc")
+ @reply_count = @replies.count
+ @replies = get_no_children_comments_all @replies
+ #redirect_to message_replies_forum_memo_path(@memo.forum, @memo, :user_activity_id => params[:user_activity_id])
+ }
format.json { head :no_content }
end
end
@@ -196,7 +251,13 @@ class MemosController < ApplicationController
def change_sticky
@memo.sticky ? @memo.update_attribute(:sticky, false) : @memo.update_attribute(:sticky, true)
respond_to do |format|
- format.html { redirect_to forum_memo_path(@memo.forum, @memo) }
+ format.html {
+ if params[:index]
+ redirect_to forums_path
+ else
+ redirect_to forum_memo_path(@memo.forum, @memo)
+ end
+ }
end
end
diff --git a/app/controllers/myshixuns_controller.rb b/app/controllers/myshixuns_controller.rb
index 813c790b4..a2aadf706 100644
--- a/app/controllers/myshixuns_controller.rb
+++ b/app/controllers/myshixuns_controller.rb
@@ -127,7 +127,6 @@ class MyshixunsController < ApplicationController
compile_success = jsonTestDetails['compileSuccess']
# message = Base64.decode64(params[:msg]) unless params[:msg].blank?
logger.info(outPut)
- logger.info("##################"+ compile_success)
game = Game.find(game_id)
challenge = game.challenge
unless jenkins_testsets.blank?
@@ -135,7 +134,6 @@ class MyshixunsController < ApplicationController
actual_output = tran_base64_decode64(j_test_set['output'])
game_outputs = Output.create(:code => status, :game_id => game_id, :out_put => outPut, :test_set_position => j_test_set['caseId'],
:actual_output => actual_output, :result => j_test_set['passed'].to_i, :query_index => game.query_index, :compile_success => compile_success.to_i)
- logger.info("compile_success:"+ compile_success)
# output = Output.where(:game_id => game.id, :test_set_position => j_test_set['caseId'].to_i).first
# logger.info("#############{outPut}")
# if output.nil?
diff --git a/app/controllers/shixuns_controller.rb b/app/controllers/shixuns_controller.rb
index ee87d34bc..5d44a3cbc 100644
--- a/app/controllers/shixuns_controller.rb
+++ b/app/controllers/shixuns_controller.rb
@@ -25,7 +25,7 @@ class ShixunsController < ApplicationController
end
def statistics_students
- @statistics = @shixun.myshixuns.order("created_at desc")
+ @statistics = @shixun.myshixuns.where("").order("created_at desc")
@statistics_count = @statistics.count
@limit = 10
@is_remote = true
@@ -122,9 +122,9 @@ class ShixunsController < ApplicationController
@rev = params[:rev]
@content = params[:content]
code_file = g.edit_file(@shixun.gpid, :content => params[:content], :file_path => @path, :branch_name => @rev, :commit_message => "shixun entry")
- if @shixun.try(:status).to_i < 2
- shixun_modify_status_without_publish(@shixun, 1)
- end
+ # if @shixun.try(:status).to_i < 2
+ shixun_modify_status_without_publish(@shixun, 1)
+ # end
respond_to do |format|
format.js
end
@@ -262,9 +262,9 @@ class ShixunsController < ApplicationController
# 确定 sort 1升序 2 降序
@order = params[:order] || "myshixun_count"
bsort = params[:sort] || "desc"
- @sort = bsort == "desc" ? "asc" : "desc"
+ @sort = bsort == "asc" ? "desc" : "asc"
if @order == "updated_at"
- order_str = "#{Shixun.table_name}.updated_at #{bsort}"
+ order_str = "#{Shixun.table_name}.updated_at #{@sort}"
else
order_str = "myshixun_count #{bsort}, #{Shixun.table_name}.updated_at #{bsort}"
end
@@ -289,7 +289,7 @@ class ShixunsController < ApplicationController
@courses = CourseList.where(:support_shixuns_search => 1)
#if !@course.blank? && (@major.blank? || MajorCourse.where(:major_id => @major, :course_list_id => @course).count == 1)
if !@course.blank?
- @shixuns = @shixuns.where(:id => ShixunMajorCourse.where(:course_list_id => @course).map(&:shixun_id))
+ @shixuns = @shixuns.where(:id => ShixunMajorCourse.where(:course_list_id => @course).map(&:shixun_id))
end
# if !@major.blank? && MajorCourse.where(:major_id => @major, :course_list_id => @course).count == 0
# @course = nil
@@ -424,7 +424,9 @@ class ShixunsController < ApplicationController
end
gshixun = g.fork(@shixun.gpid, User.current.gid)
if !gshixun.try(:id).blank?
- myshixun.update_column(:gpid, gshixun.id) if myshixun.try(:gpid).blank? # 为了防止多次fork
+ myshixun.update_column(:gpid, gshixun.id) if myshixun.try(:gpid).blank?
+ commit_id = g.commits(@shixun.gpid).first.try(:id)
+ myshixun.update_column(:commit_id, commit_id)
rep = Repository.create!(:myshixun_id => myshixun.id, :identifier => gshixun.name,:project_id => -1, :shixun_id => -2)
rep.update_column(:type, "Repository::Gitlab")
rep_url = Base64.urlsafe_encode64(git_shixun_url_ip @shixun, (@shixun.try(:fork_from).blank? ? "educoder" : "eduforge")) # 注意:educoder为默认给实训创建版本库的用户,如果换成别的用户,名字要相应的修改
@@ -554,6 +556,10 @@ class ShixunsController < ApplicationController
end
def copy
+ unless (@shixun.can_copy && User.current.user_extensions.try(:identity) == 0 && User.current.professional_certification)
+ render_403
+ return
+ end
ActiveRecord::Base.transaction do
begin
new_shixun = Shixun.new
@@ -582,7 +588,7 @@ class ShixunsController < ApplicationController
gshixun = g.fork(@shixun.gpid, user_gid)
raise "版本库创建失败" if gshixun.try(:id).blank?
gshixun = g.edit_project(gshixun.id, new_shixun.identifier, new_shixun.identifier)
- raise "版本库创建失败" if (gshixun.try(:name) != new_shixun.identifier || gshixun.try(:path) != new_shixun.identifier)
+ raise "实训复制失败" if (gshixun.try(:name) != new_shixun.identifier || gshixun.try(:path) != new_shixun.identifier)
new_shixun.update_column(:gpid, gshixun.id)
# 同步复制合作者,合作者加入到gitlab
@@ -592,7 +598,7 @@ class ShixunsController < ApplicationController
@shixun.shixun_members.each do |shixun_member|
if ShixunMember.where(:shixun_id => new_shixun.try(:id), :user_id => shixun_member.user_id).blank?
ShixunMember.create!(:user_id => shixun_member.try(:user_id), :shixun_id => new_shixun.try(:id),
- :role => (shixun_member.try(:user_id) == User.current.id ? 1 : 2))
+ :role => (shixun_member.try(:user_id) == User.current.id ? 1 : 2))
end
s = Trustie::Gitlab::Sync.new
gid = User.find(shixun_member.user_id).try(:gid)
@@ -729,7 +735,7 @@ class ShixunsController < ApplicationController
ActiveRecord::Base.transaction do
begin
@shixun.save!
- if language != params[:language]
+ if language != params[:language] && @shixun.status != 2 # 已发布不触发重置
add_shixun_modify_status(@shixun, 1)
end
rescue
diff --git a/app/controllers/student_work_controller.rb b/app/controllers/student_work_controller.rb
index 75c51dde5..e627ef519 100644
--- a/app/controllers/student_work_controller.rb
+++ b/app/controllers/student_work_controller.rb
@@ -336,6 +336,7 @@ class StudentWorkController < ApplicationController
def index
# 作业消息状态更新?
+ @tab = params[:tab].nil? ? 1 : params[:tab].to_i
homeworkcommon_messages = CourseMessage.where(:user_id => User.current.id, :viewed => 0, :course_message_id => @homework.id, :course_message_type => "HomeWorkCommon")
homeworkcommon_messages.update_all(:viewed => true)
studentwork_messages = CourseMessage.where(:user_id => User.current.id, :viewed => 0, :course_id => @homework.course, :course_message_type => "StudentWork")
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb
index 3e5a0c0a3..1f545fd9e 100644
--- a/app/controllers/users_controller.rb
+++ b/app/controllers/users_controller.rb
@@ -321,6 +321,11 @@ class UsersController < ApplicationController
when 'Syllabus'
@reply = JournalsForMessage.find params[:reply_id]
@type = 'Syllabus'
+ when 'Memo'
+ @reply = Memo.find params[:reply_id]
+ @user_activity_id = params[:user_activity_id]
+ @activity_id = params[:activity_id]
+ @type = 'Memo'
end
respond_to do |format|
format.js
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index e13cf05b8..20c101543 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -33,6 +33,19 @@ module ApplicationHelper
extend Forwardable
def_delegators :wiki_helper, :wikitoolbar_for, :heads_for_wiki_formatter
+ # 判断TPM的代码是否被修改了
+ def tpm_is_modified myshixun, shixun_gpid
+ g = Gitlab.client
+ myshixun_commit_id = myshixun.commit_id
+ if myshixun_commit_id.blank?
+ myshixun_commit_id = g.commits(myshixun.gpid).last.try(:id)
+ myshixun.update_column(:commit_id, myshixun_commit_id)
+ end
+ shixun_commit_id = g.commits(shixun_gpid).first.try(:id)
+ result = myshixun_commit_id != shixun_commit_id ? true :false
+ return result
+ end
+
# 定义当前关卡是否有权开启下一关
# :实训若发布了,必须通过当前关卡才能查看下一关
# :未发布的实训,除了最后一关,其它的关卡都可以进入下一关
@@ -44,7 +57,6 @@ module ApplicationHelper
end
end
-
# 适用与已经用url_safe编码后,回调字符串形式
def tran_base64_decode64 str
if str.blank?
@@ -101,6 +113,17 @@ module ApplicationHelper
shixun_modify_status_without_publish shixun, type
end
+ def shixun_modify_status_publish shixun, type
+ shixun_tomcat = Redmine::Configuration['shixun_tomcat']
+ gameInfo = shixun.gameInfo
+ uri ="#{shixun_tomcat}/bridge/game/publishGame"
+ params = {gameInfo:gameInfo}
+ res = uri_exec uri, params
+ if res && res['code'].to_i != 0
+ raise("实训云平台繁忙(繁忙等级:90)")
+ end
+ end
+
# 仅仅产生记录,用于已执行publish的方法
# ShixunModify中status 1:表示有更改,开启实训的时候需要重置,0:表示不需要重置或已重置完成
def shixun_modify_status_without_publish shixun, type
@@ -463,6 +486,14 @@ module ApplicationHelper
gitUrl = gitlab_address.to_s+"/"+login+"/"+ rep_identify + "."+"git"
end
+ # myshixun git url by domain
+ def git_myshixun_url myshixun, user_id
+ login = User.where(:id => user_id).first.try(:login)
+ rep_identify = Repository.where(:myshixun_id => myshixun.id, :type => "Repository::Gitlab").first.try(:identifier)
+ gitlab_address = Redmine::Configuration['gitlab_address']
+ gitUrl = gitlab_address.to_s+"/"+login+"/"+ rep_identify + "."+"git"
+ end
+
def uri_exec uri, params
begin
logger.error("@parmas is #{params}, url is #{uri}")
@@ -501,29 +532,29 @@ module ApplicationHelper
# homework_common状态
# 0:挂起;1:提交中;2:匿评中;3:评阅中
def new_homework_common_status status
- case status
- when 0
- "挂起"
- when 1
- "提交中"
- when 2
- "补交中"
- when 3
- "匿评中"
- when 4
- "申诉中"
- when 5
- "评阅中"
- when 6
- "已结束"
- end
+ case status
+ when 0
+ "未发布"
+ when 1
+ "提交中"
+ when 2
+ "补交中"
+ when 3
+ "匿评中"
+ when 4
+ "申诉中"
+ when 5
+ "评阅中"
+ when 6
+ "已结束"
+ end
end
# 作业不同状态的不同样式
def homework_status_color status
style = ""
case status
- when '挂起'
+ when '未发布'
style = 'edu-filter-btn-yellow'
when '提交中'
style = 'edu-filter-btn-blue'
@@ -571,7 +602,7 @@ module ApplicationHelper
if ho_detail_manual
case ho_detail_manual.comment_status
when 0
- status = "挂起"
+ status = "未发布"
when 1
if homework_common.end_time && homework_common.end_time >= Time.now
status = "提交中"
@@ -830,7 +861,7 @@ module ApplicationHelper
end
# 项目issue列表导出Excel功能
- def issue_list_xls issues
+ def issue_list_xls issues
xls_report = StringIO.new
book = Spreadsheet::Workbook.new
sheet1 = book.create_worksheet :name => "issues"
@@ -944,7 +975,7 @@ module ApplicationHelper
score = obj.issue_num * 4 + obj.issue_journal_num + (obj.changeset_num||0) * 4 + obj.board_num * 2 + obj.board_message_num + obj.attach_num * 5
end
- # 获取组织成员中文名字
+ # 获取组织成员中文名字
def get_org_member_role_name member
unless member.roles[0].nil?
case member.roles[0].name
@@ -1154,7 +1185,7 @@ module ApplicationHelper
name = h(user.name(options[:format]))
else
name = h(user.show_name)
- end
+ end
link_to name, {:controller=> 'users', :action => 'show', id: user.id, host: Setting.host_user}, :class => "pro_info_p"
else
h(user.to_s)
@@ -1761,7 +1792,7 @@ module ApplicationHelper
def authority_pubilic_for_files(project, file)
@result = false
if (is_project_manager?(User.current.id, @project.id) && User.current.allowed_to?(:manage_files, project)) || file.author_id == User.current.id || User.current.admin &&
- project_contains_attachment?(project,file) && file.container_id == project.id && file.container_type == "Project"
+ project_contains_attachment?(project,file) && file.container_id == project.id && file.container_type == "Project"
@result = true
end
return @result
@@ -2054,7 +2085,7 @@ module ApplicationHelper
title << @user.show_name
end
elsif @syllabus
- title << (@syllabus.title.nil? ? "在线课堂" : @syllabus.title)
+ title << (@syllabus.title.nil? ? "在线课堂" : @syllabus.title)
else
title << (User.current.id == 2 ? "未登录" : User.current.show_name)
end
@@ -2778,7 +2809,7 @@ module ApplicationHelper
def check_all_links(form_name)
link_to_function_none(l(:button_check_all), "checkAll('#{form_name}', true)") + " ".html_safe + " | "+ " ".html_safe +
- link_to_function_none(l(:button_uncheck_all), "checkAll('#{form_name}', false)")
+ link_to_function_none(l(:button_uncheck_all), "checkAll('#{form_name}', false)")
end
# 本次修改,修改为只显示关闭的所占%比
@@ -2792,8 +2823,8 @@ module ApplicationHelper
content_tag('span',
content_tag('tr',
(pcts[0] > 0 ? content_tag('span', '', :style => "width: #{pcts[0]}%;", :class => 'roadmap_progressbar_inner', :title => "已关闭:#{pcts[0]}%") : ''.html_safe) #+
- # (pcts[1] > 0 ? content_tag('td', '', :style => "width: #{pcts[1]}%;", :class => 'done', :title => "开发中:#{pcts[1]}%") : ''.html_safe) +
- #(pcts[1] > 0 ? content_tag('span', '', :style => "width: #{pcts[1]}%;", :class => 'roadmap_progressbar ml5', :title => "未完成:#{pcts[1]}%") : ''.html_safe), :style => "width: #{width}"
+ # (pcts[1] > 0 ? content_tag('td', '', :style => "width: #{pcts[1]}%;", :class => 'done', :title => "开发中:#{pcts[1]}%") : ''.html_safe) +
+ #(pcts[1] > 0 ? content_tag('span', '', :style => "width: #{pcts[1]}%;", :class => 'roadmap_progressbar ml5', :title => "未完成:#{pcts[1]}%") : ''.html_safe), :style => "width: #{width}"
), :class => 'roadmap_progressbar ml5').html_safe
# + content_tag('p', legend, :class => 'percent').html_safe
end
@@ -2932,11 +2963,11 @@ module ApplicationHelper
end
end
- if sources && !sources.empty?
- super(sources, options)
- else
- ''
- end
+ if sources && !sources.empty?
+ super(sources, options)
+ else
+ ''
+ end
end
def content_for(name, content = nil, &block)
@@ -3226,17 +3257,17 @@ module ApplicationHelper
# 课程某个班级的成员
def syllabus_course_member user, course
- result = false
- syllabus = course.syllabus
- if syllabus
- syllabus.courses.each do |course|
- if user.member_of_course?(course)
- result = true
- return result
+ result = false
+ syllabus = course.syllabus
+ if syllabus
+ syllabus.courses.each do |course|
+ if user.member_of_course?(course)
+ result = true
+ return result
+ end
end
end
- end
- result
+ result
end
def attachment_candown attachment
@@ -3656,48 +3687,48 @@ module ApplicationHelper
def anonymous_comment_link(bid, course)
link = case bid.comment_status
- when 0
- confirm_info = "开启匿评后学生将不能对作品进行提交、修改、删除等操作\n"
- confirm_info += anonymous_comment_notice(bid,course)
- confirm_info += '是否确定开启匿评?'
- link_to '启动匿评', start_anonymous_comment_bid_path(bid), id: "#{bid.id}_start_anonymous_comment", remote: true, :confirm => confirm_info, disable_with: '加载中...'
- when 1
- confirm_info = "关闭匿评后所有同学将不能继续进行匿评,且将公开已提交作品列表\n"
- confirm_info += anonymous_comment_notice(bid,course)
- confirm_info += '是否确定关闭匿评?'
- link_to '关闭匿评', stop_anonymous_comment_bid_path(bid), id: "#{bid.id}_stop_anonymous_comment", remote: true, :confirm => confirm_info
- when 2
- '匿评结束'
- end
+ when 0
+ confirm_info = "开启匿评后学生将不能对作品进行提交、修改、删除等操作\n"
+ confirm_info += anonymous_comment_notice(bid,course)
+ confirm_info += '是否确定开启匿评?'
+ link_to '启动匿评', start_anonymous_comment_bid_path(bid), id: "#{bid.id}_start_anonymous_comment", remote: true, :confirm => confirm_info, disable_with: '加载中...'
+ when 1
+ confirm_info = "关闭匿评后所有同学将不能继续进行匿评,且将公开已提交作品列表\n"
+ confirm_info += anonymous_comment_notice(bid,course)
+ confirm_info += '是否确定关闭匿评?'
+ link_to '关闭匿评', stop_anonymous_comment_bid_path(bid), id: "#{bid.id}_stop_anonymous_comment", remote: true, :confirm => confirm_info
+ when 2
+ '匿评结束'
+ end
content_tag('span', link, id: "#{bid.id}_anonymous_comment")
end
def anonymous_comment_notice(bid, course)
- case bid.comment_status
- when 0
- @student_size ||= searchStudent(course).size
- @homework_size = bid.homeworks.size
- percent = @homework_size.to_f / (@student_size == 0 ? 1 : @student_size)
- confirm_info = "目前#{@student_size}个学生,总共提交了#{@homework_size}份作品,占#{number_to_percentage(percent * 100, precision: 1)}\n"
- when 1
- @homework_evaluations = 0
- bid.homeworks.map { |homework| @homework_evaluations += homework.homework_evaluations.count}
- teachers = "("
- teacher_members = searchTeacherAndAssistant(course)
- teacher_members.each do |member|
- if member == teacher_members.last
- teachers += member.user_id.to_s + ")"
- else
- teachers += member.user_id.to_s + ","
- end
- end
- @has_evaluations = 0
- bid.homeworks.map { |homework| @has_evaluations += homework.rates(:quality).where("seems_rateable_rates.rater_id not in #{teachers}").count}
+ case bid.comment_status
+ when 0
+ @student_size ||= searchStudent(course).size
+ @homework_size = bid.homeworks.size
+ percent = @homework_size.to_f / (@student_size == 0 ? 1 : @student_size)
+ confirm_info = "目前#{@student_size}个学生,总共提交了#{@homework_size}份作品,占#{number_to_percentage(percent * 100, precision: 1)}\n"
+ when 1
+ @homework_evaluations = 0
+ bid.homeworks.map { |homework| @homework_evaluations += homework.homework_evaluations.count}
+ teachers = "("
+ teacher_members = searchTeacherAndAssistant(course)
+ teacher_members.each do |member|
+ if member == teacher_members.last
+ teachers += member.user_id.to_s + ")"
+ else
+ teachers += member.user_id.to_s + ","
+ end
+ end
+ @has_evaluations = 0
+ bid.homeworks.map { |homework| @has_evaluations += homework.rates(:quality).where("seems_rateable_rates.rater_id not in #{teachers}").count}
- percent = @has_evaluations.to_f / (@homework_evaluations == 0 ? 1 : @homework_evaluations)
- confirm_info = "目前总共分配了#{@homework_evaluations}份匿评作品,已评价#{@has_evaluations}份作品,占#{number_to_percentage(percent * 100, precision: 1)}\n"
- end
- confirm_info
+ percent = @has_evaluations.to_f / (@homework_evaluations == 0 ? 1 : @homework_evaluations)
+ confirm_info = "目前总共分配了#{@homework_evaluations}份匿评作品,已评价#{@has_evaluations}份作品,占#{number_to_percentage(percent * 100, precision: 1)}\n"
+ end
+ confirm_info
end
def get_technical_title user
@@ -3833,12 +3864,12 @@ module ApplicationHelper
link = link_to "启动匿评","javascript:void(0)", :class => "wpostOptionLink", :title => "作业截止日期之前不可以启动匿评"
elsif homework.student_works.has_committed.count >= 2 && homework.homework_detail_manual#作业份数大于2
case homework.homework_detail_manual.comment_status
- when 1
- link = link_to '启动匿评', Setting.protocol + "://" + Setting.host_name + "/homework_common/" + homework.id.to_s + "/alert_anonymous_comment?hw_status=" + hw_status.to_s + "&user_activity_id=" + user_activity_id.to_s, id: "#{homework.id}_start_anonymous_comment", remote: true, disable_with: '加载中...',:class => 'wpostOptionLink'
- when 2
- link = link_to '关闭匿评', Setting.protocol + "://" + Setting.host_name + "/homework_common/" + homework.id.to_s + "/alert_anonymous_comment?hw_status=" + hw_status.to_s + "&user_activity_id=" + user_activity_id.to_s, id: "#{homework.id}_stop_anonymous_comment", remote: true,:class => 'wpostOptionLink'
- when 3
- # link = link_to "匿评结束","javascript:void(0)", :class => "postOptionLink", :title => "匿评结束"
+ when 1
+ link = link_to '启动匿评', Setting.protocol + "://" + Setting.host_name + "/homework_common/" + homework.id.to_s + "/alert_anonymous_comment?hw_status=" + hw_status.to_s + "&user_activity_id=" + user_activity_id.to_s, id: "#{homework.id}_start_anonymous_comment", remote: true, disable_with: '加载中...',:class => 'wpostOptionLink'
+ when 2
+ link = link_to '关闭匿评', Setting.protocol + "://" + Setting.host_name + "/homework_common/" + homework.id.to_s + "/alert_anonymous_comment?hw_status=" + hw_status.to_s + "&user_activity_id=" + user_activity_id.to_s, id: "#{homework.id}_stop_anonymous_comment", remote: true,:class => 'wpostOptionLink'
+ when 3
+ # link = link_to "匿评结束","javascript:void(0)", :class => "postOptionLink", :title => "匿评结束"
end
else
link = link_to "启动匿评","javascript:void(0)", :class => "wpostOptionLink", :title => "学生提交作业数大于等于2时才可以启动匿评"
@@ -3980,33 +4011,33 @@ module ApplicationHelper
if User.current.allowed_to?(:as_teacher, homework.course)
link_to "查看作品", student_work_index_url_in_org(homework.id, 2), :class => 'hw_btn_green fr mt5', :title => "查看作品", :target => '_blank'
else User.current.member_of_course?(homework.course)
- work = cur_user_works_for_homework homework
- project = cur_user_projects_for_homework homework
- if work.nil? && homework.end_time >= Time.now
- if homework.homework_type ==3 && project.nil? && homework.homework_detail_group.base_on_project == 1
- link_to "关联项目", student_work_index_url_in_org(homework.id, 1), :class => 'hw_btn_green fr mt5',:title => '查看分组作业详情', :target => '_blank'
- else
- link_to "提交作品", new_student_work_url_without_domain(homework.id),:class => 'hw_btn_green fr mt5', :target => '_blank'
- end
- elsif work.nil? && homework.end_time < Time.now
- if homework.homework_type ==3 && project.nil? && homework.homework_detail_group.base_on_project == 1
- link_to "关联项目", student_work_index_url_in_org(homework.id, 1), :class => 'hw_btn_green fr mt5',:title => '查看分组作业详情', :target => '_blank'
- else
- link_to "补交作品", new_student_work_url_without_domain(homework.id),:class => 'btn_orange_big fr mt5', :target => '_blank'
- end
+ work = cur_user_works_for_homework homework
+ project = cur_user_projects_for_homework homework
+ if work.nil? && homework.end_time >= Time.now
+ if homework.homework_type ==3 && project.nil? && homework.homework_detail_group.base_on_project == 1
+ link_to "关联项目", student_work_index_url_in_org(homework.id, 1), :class => 'hw_btn_green fr mt5',:title => '查看分组作业详情', :target => '_blank'
else
- if homework.homework_detail_manual && homework.homework_detail_manual.comment_status == 2 #匿评作业,且作业状态不是在开启匿评之前
- link_to "作品匿评", student_work_index_url_in_org(homework.id, 2), :class => 'hw_btn_green fr mt5', :title => "开启匿评后不可修改作品", :target => '_blank'
- elsif homework.homework_detail_manual && homework.homework_detail_manual.comment_status == 3
- link_to "查看作品",student_work_index_url_in_org(homework.id, 2), :class => 'hw_btn_green fr mt5', :title => "匿评已结束", :target => '_blank'
- elsif homework.homework_type == 2 && homework.end_time >= Time.now#编程作业不能修改作品
- link_to "修改作品", new_student_work_url_without_domain(homework.id),:class => 'hw_btn_green fr mt5', :target => '_blank'
- elsif homework.end_time >= Time.now && work.user_id == User.current.id
- link_to "修改作品", edit_student_work_url_without_domain(work.id),:class => 'hw_btn_green fr mt5', :target => '_blank'
- else
- link_to "查看作品", student_work_index_url_in_org(homework.id, 2), :class => 'hw_btn_green fr mt5', :title => "作业截止后不可修改作品", :target => '_blank'
- end
+ link_to "提交作品", new_student_work_url_without_domain(homework.id),:class => 'hw_btn_green fr mt5', :target => '_blank'
end
+ elsif work.nil? && homework.end_time < Time.now
+ if homework.homework_type ==3 && project.nil? && homework.homework_detail_group.base_on_project == 1
+ link_to "关联项目", student_work_index_url_in_org(homework.id, 1), :class => 'hw_btn_green fr mt5',:title => '查看分组作业详情', :target => '_blank'
+ else
+ link_to "补交作品", new_student_work_url_without_domain(homework.id),:class => 'btn_orange_big fr mt5', :target => '_blank'
+ end
+ else
+ if homework.homework_detail_manual && homework.homework_detail_manual.comment_status == 2 #匿评作业,且作业状态不是在开启匿评之前
+ link_to "作品匿评", student_work_index_url_in_org(homework.id, 2), :class => 'hw_btn_green fr mt5', :title => "开启匿评后不可修改作品", :target => '_blank'
+ elsif homework.homework_detail_manual && homework.homework_detail_manual.comment_status == 3
+ link_to "查看作品",student_work_index_url_in_org(homework.id, 2), :class => 'hw_btn_green fr mt5', :title => "匿评已结束", :target => '_blank'
+ elsif homework.homework_type == 2 && homework.end_time >= Time.now#编程作业不能修改作品
+ link_to "修改作品", new_student_work_url_without_domain(homework.id),:class => 'hw_btn_green fr mt5', :target => '_blank'
+ elsif homework.end_time >= Time.now && work.user_id == User.current.id
+ link_to "修改作品", edit_student_work_url_without_domain(work.id),:class => 'hw_btn_green fr mt5', :target => '_blank'
+ else
+ link_to "查看作品", student_work_index_url_in_org(homework.id, 2), :class => 'hw_btn_green fr mt5', :title => "作业截止后不可修改作品", :target => '_blank'
+ end
+ end
end
end
@@ -4614,47 +4645,47 @@ def sortby_time_countcommon_hassticky topics,sortstr
tmpIndex = 0
tmpTopics.each_with_index do |topic,index|
- if topic.sticky == 0
- if tStart == -1
- if (index != tmpTopics.count-1) && (topic[:infocount] == tmpTopics[index+1][:infocount])
- tStart = index
- end
+ if topic.sticky == 0
+ if tStart == -1
+ if (index != tmpTopics.count-1) && (topic[:infocount] == tmpTopics[index+1][:infocount])
+ tStart = index
+ end
+ else
+ if ((topic[:infocount] == tmpTopics[index-1][:infocount]) && ((index != tmpTopics.count-1) && (topic[:infocount] == tmpTopics[index+1][:infocount])))
+ tEnd = index
else
- if ((topic[:infocount] == tmpTopics[index-1][:infocount]) && ((index != tmpTopics.count-1) && (topic[:infocount] == tmpTopics[index+1][:infocount])))
+ if (topic[:infocount] == tmpTopics[index-1][:infocount])
tEnd = index
- else
- if (topic[:infocount] == tmpTopics[index-1][:infocount])
- tEnd = index
- end
- if tEnd > tStart
- for i in tStart..tEnd
- tmpTopics_1[tmpIndex] = tmpTopics[i]
- tmpIndex = tmpIndex + 1
- end
-
- if sortstr == "created_at"
- tmpTopics_1 = tmpTopics_1.sort{|x,y| y[:created_at].to_i <=> x[:created_at].to_i }
- elsif sortstr == "created_on"
- tmpTopics_1 = tmpTopics_1.sort{|x,y| y[:created_on].to_i <=> x[:created_on].to_i }
- elsif sortstr == "updated_at"
- tmpTopics_1 = tmpTopics_1.sort{|x,y| y[:updated_at].to_i <=> x[:updated_at].to_i }
- elsif sortstr == "updated_on"
- tmpTopics_1 = tmpTopics_1.sort{|x,y| y[:updated_on].to_i <=> x[:updated_on].to_i }
- end
-
- tmpIndex = 0
- for i in tStart..tEnd
- tmpTopics[i] = tmpTopics_1[tmpIndex]
- tmpIndex = tmpIndex + 1
- end
- end
- tStart = -1
- tEnd = -1
- tmpTopics_1 = []
- tmpIndex = 0
end
+ if tEnd > tStart
+ for i in tStart..tEnd
+ tmpTopics_1[tmpIndex] = tmpTopics[i]
+ tmpIndex = tmpIndex + 1
+ end
+
+ if sortstr == "created_at"
+ tmpTopics_1 = tmpTopics_1.sort{|x,y| y[:created_at].to_i <=> x[:created_at].to_i }
+ elsif sortstr == "created_on"
+ tmpTopics_1 = tmpTopics_1.sort{|x,y| y[:created_on].to_i <=> x[:created_on].to_i }
+ elsif sortstr == "updated_at"
+ tmpTopics_1 = tmpTopics_1.sort{|x,y| y[:updated_at].to_i <=> x[:updated_at].to_i }
+ elsif sortstr == "updated_on"
+ tmpTopics_1 = tmpTopics_1.sort{|x,y| y[:updated_on].to_i <=> x[:updated_on].to_i }
+ end
+
+ tmpIndex = 0
+ for i in tStart..tEnd
+ tmpTopics[i] = tmpTopics_1[tmpIndex]
+ tmpIndex = tmpIndex + 1
+ end
+ end
+ tStart = -1
+ tEnd = -1
+ tmpTopics_1 = []
+ tmpIndex = 0
end
end
+ end
end
return tmpTopics
end
@@ -4775,7 +4806,7 @@ def get_hw_status homework_common
str = ""
if homework_common.homework_detail_manual
if homework_common.homework_detail_manual.comment_status == 0 && homework_common.publish_time.nil?
- str += '挂起'
+ str += '未发布'
elsif homework_common.homework_detail_manual.comment_status == 0
str += '未发布'
elsif homework_common.homework_detail_manual.comment_status == 1
@@ -4895,17 +4926,17 @@ def create_works_list homework
unless homework.course.nil?
students = homework.course.student
if !students.empty? && homework.student_works.empty?
- name = homework.name
- name_str = name + "的作品提交"
- str = ""
- students.each do |student|
- if str != ""
- str += ","
+ name = homework.name
+ name_str = name + "的作品提交"
+ str = ""
+ students.each do |student|
+ if str != ""
+ str += ","
+ end
+ str += "('#{name_str}',#{homework.id},#{student.student_id}, '#{format_time(Time.now)}', '#{format_time(Time.now)}')"
end
- str += "('#{name_str}',#{homework.id},#{student.student_id}, '#{format_time(Time.now)}', '#{format_time(Time.now)}')"
- end
- sql = "insert into student_works (name, homework_common_id,user_id, created_at, updated_at) values" + str
- ActiveRecord::Base.connection.execute sql
+ sql = "insert into student_works (name, homework_common_id,user_id, created_at, updated_at) values" + str
+ ActiveRecord::Base.connection.execute sql
end
end
end
@@ -5283,10 +5314,10 @@ def quote_homework_bank homework, course
)
end
homework.homework_bank_samples.each_with_index do |homework_test|
- new_homework.homework_samples << HomeworkSample.new(
- input: homework_test.input,
- output: homework_test.output
- )
+ new_homework.homework_samples << HomeworkSample.new(
+ input: homework_test.input,
+ output: homework_test.output
+ )
end
end
diff --git a/app/helpers/debates_helper.rb b/app/helpers/debates_helper.rb
new file mode 100644
index 000000000..f551d98d1
--- /dev/null
+++ b/app/helpers/debates_helper.rb
@@ -0,0 +1,2 @@
+module DebatesHelper
+end
diff --git a/app/models/apply_action.rb b/app/models/apply_action.rb
index 508371521..af19e832b 100644
--- a/app/models/apply_action.rb
+++ b/app/models/apply_action.rb
@@ -2,6 +2,5 @@
class ApplyAction < ActiveRecord::Base
default_scope :order => 'updated_at desc'
attr_accessible :container_id, :container_type, :dealer_id, :reason, :user_id, :status, :apply_reason
-
belongs_to :user
end
diff --git a/app/models/challenge_choose.rb b/app/models/challenge_choose.rb
index c14a0c02d..38b7d8685 100644
--- a/app/models/challenge_choose.rb
+++ b/app/models/challenge_choose.rb
@@ -7,6 +7,7 @@ class ChallengeChoose < ActiveRecord::Base
has_many :challenge_tags, :dependent => :destroy
has_many :challenge_questions, :dependent => :destroy
has_one :choose_outputs, :dependent => :destroy
+ #has_many :outputs, :dependent => :destroy
validates_presence_of :subject
diff --git a/app/models/game.rb b/app/models/game.rb
index 7c0e913ae..e278690c4 100644
--- a/app/models/game.rb
+++ b/app/models/game.rb
@@ -66,4 +66,18 @@ class Game < ActiveRecord::Base
challenge = self.challenge
challenge.try(:position).to_i == challenge.shixun.challenges.count ? true : false
end
+
+ def choose_correct_num
+ num = 0
+ outputs = self.outputs.where(:query_index => (self.query_index - 1))
+ if outputs.blank?
+ num = nil
+ else
+ outputs.each do |output|
+ num += output.result ? 1 : 0
+ end
+ end
+ return num
+ end
+
end
diff --git a/app/models/myshixun.rb b/app/models/myshixun.rb
index 9e7e2a0aa..ace51c51f 100644
--- a/app/models/myshixun.rb
+++ b/app/models/myshixun.rb
@@ -48,7 +48,7 @@ class Myshixun < ActiveRecord::Base
score = 0
self.games.each do |game|
if game.status == 2
- score += game.final_score
+ score += game.final_score.to_i
end
end
score
diff --git a/app/models/output.rb b/app/models/output.rb
index 4ce462eff..8f1547cfe 100644
--- a/app/models/output.rb
+++ b/app/models/output.rb
@@ -4,5 +4,5 @@ class Output < ActiveRecord::Base
# compile_success 1 表示程序未报错,有正常输出, 0.表示程序抛异常了,报错!
default_scope :order => 'query_index desc'
belongs_to :game
-
+ #belongs_to :challenge_choose
end
diff --git a/app/models/school.rb b/app/models/school.rb
index 6dc909229..d07303e09 100644
--- a/app/models/school.rb
+++ b/app/models/school.rb
@@ -1,6 +1,6 @@
class School < ActiveRecord::Base
default_scope :order => 'created_at desc'
- attr_accessible :name, :province, :pinyin, :city, :address, :logo_link
+ attr_accessible :name, :province, :pinyin, :city, :address, :logo_link,:auto_users_trial
has_many :courses
has_many :departments, :dependent => :destroy
diff --git a/app/views/boards/_course_show.html.erb b/app/views/boards/_course_show.html.erb
index 5ef891af0..f102e2f36 100644
--- a/app/views/boards/_course_show.html.erb
+++ b/app/views/boards/_course_show.html.erb
@@ -1,7 +1,7 @@
帖子列表
<%= @all_count %> +帖子列表
<% if User.current.logged? %> + 我要发布 <% end %> diff --git a/app/views/challenges/_choose_type.html.erb b/app/views/challenges/_choose_type.html.erb index 1947a3760..a47d921f9 100644 --- a/app/views/challenges/_choose_type.html.erb +++ b/app/views/challenges/_choose_type.html.erb @@ -4,8 +4,10 @@ <%= render :partial => "challenges/choose_tab" %>- <% if @shixun.status == 0 && User.current.manager_of_shixun?(@shixun) %> + <% if User.current.manager_of_shixun?(@shixun) %> 编辑 <% end %>
@@ -49,8 +49,8 @@ <% end %> -<%= match_specific_symbol test.input unless test.input.blank? %>
<%= match_specific_symbol test.output unless test.output.blank? %>
<%= match_specific_symbol test.input unless test.input.blank? %>
<%= match_specific_symbol test.output unless test.output.blank? %>
+
-
+
-
- <%= group.name %> + <%= group.name %> <%= group.members.count %>
@@ -27,3 +27,13 @@+
<%= group.name %> <%= group.members.count %> -
+
<%= group.name %> <%= group.members.count %> @@ -26,4 +26,14 @@
+
<%= group.name %> <%= group.members.count %> @@ -26,3 +26,14 @@ <%= render :partial => "courses/settings/no_group_student_list_block" %> + + + \ No newline at end of file diff --git a/app/views/courses/settings/_no_group_student_list_block.html.erb b/app/views/courses/settings/_no_group_student_list_block.html.erb index 2cb30a5a5..86b6ec0ff 100644 --- a/app/views/courses/settings/_no_group_student_list_block.html.erb +++ b/app/views/courses/settings/_no_group_student_list_block.html.erb @@ -20,8 +20,9 @@ <% end %>
diff --git a/app/views/courses/settings/_search_not_students_list.html.erb b/app/views/courses/settings/_search_not_students_list.html.erb index d0ad45ea1..882b28edc 100644 --- a/app/views/courses/settings/_search_not_students_list.html.erb +++ b/app/views/courses/settings/_search_not_students_list.html.erb @@ -7,7 +7,8 @@+ + 实验四 多周期CPU与存储器实验 +
+ 返回 +发布设置
+ 编辑 +发布之前,学生不会收到试卷
+结束之后,系统自动归档试卷
+发布设置
+发布之前,学生不会收到试卷
+结束之后,系统自动归档试卷
+答题设置
+答题时长不填写,则表示不限时长
+学生答题时间即使没有超过答题时长的限制
+但是已到截止时间点,则系统自动为正在答题的学生提交试卷
+允许补交,则在补交截止日期之前,未答题的学生可以补交答题
+但是在发布截止日期~补交截止时间内才答题的学生,将被扣迟交分
+答题设置
+答题时长不填写,则表示不限时长
+学生答题时间即使没有超过答题时长的限制
+但是已到截止时间点,则系统自动为正在答题的学生提交试卷
+允许补交,则在补交截止日期之前,未答题的学生可以补交答题
+但是在发布截止日期~补交截止时间内才答题的学生,将被扣迟交分
+主观题评分设置
+计算说明
+教师评分*其百分比+助教评分+其百分比+迟交扣分
+注意
+非零百分比的评分选项,在没有评分记录的情况下,其百分比平摊到另外
的评分选项上。例如教师评分60% + 助教评分40% ,学生A没有得到
教师评分,则最终成绩将按照助教评分100% 进行计算
+主观题评分设置
+计算说明
+教师评分*其百分比+助教评分+其百分比+迟交扣分
+注意
+非零百分比的评分选项,在没有评分记录的情况下,其百分比平摊到另外
的评分选项上。例如教师评分60% + 助教评分40% ,学生A没有得到
教师评分,则最终成绩将按照助教评分100% 进行计算
+公开设置
+公开设置
+试卷须知: + 共有选择、填空、简答、编程题4种题型,其中选择题包括单选题和多选题。 + 请大家认真答题,本次作业成绩将计入期末成绩。
++ 单选题 3 题,共 15 分 + 多选题 5 题,共 25 分 + 填空题 10 题,共 25 分 + 简答题 10 题,共 25 分 +
+合计 18 题,共 100 分
+总分:89分
+第1题:[多选题]10分
+ +10分
+ +黑盒测试和白盒测试的区别
+第2题:[单选题]5分
+0分
+黑盒测试和白盒测试的区别
+第3题:[填空题]5分
+0分
+黑盒测试和白盒测试(没有)区别
+候选答案1:哈哈哈哈
+候选答案1:呵呵呵呵
+第4题:[简答题]10分
+9分
+黑盒测试和白盒测试的区别
+参考答案
+黑盒测试也称功能测试或数据驱动测试,它是在已知产品所应具有的功能,通过测试来检测每个功能是否都能正常使用,在测试时,把程序看作一个不能打开的黑盆子,在完全不考虑程序内部结构和内部特性的情况下,
+软件测试小测
+ + + 返回 +试卷须知: + 共有选择、填空、简答、编程题4种题型,其中选择题包括单选题和多选题。 + 请大家认真答题,本次作业成绩将计入期末成绩。
++ 单选题 3 题,共 15 分 + 多选题 5 题,共 25 分 + 填空题 10 题,共 25 分 + 简答题 10 题,共 25 分 +
+合计 18 题,共 100 分
+第1题:[多选题]10分
+黑盒测试和白盒测试的区别
+第2题:[单选题]5分
+黑盒测试和白盒测试的区别
+第3题:[填空题]5分
+黑盒测试和白盒测试()区别
+第4题:[简答题]10分
+黑盒测试和白盒测试的区别
+试卷须知: + 共有选择、填空、简答、编程题4种题型,其中选择题包括单选题和多选题。 + 请大家认真答题,本次作业成绩将计入期末成绩。
++ 单选题 3 题,共 15 分 + 多选题 5 题,共 25 分 + 填空题 10 题,共 25 分 + 简答题 10 题,共 25 分 +
+合计 18 题,共 100 分
+第1题:[多选题]10分
+10分
+黑盒测试和白盒测试的区别
+第2题:[单选题]5分
+0分
+黑盒测试和白盒测试的区别
+第3题:[填空题]5分
+0分
+黑盒测试和白盒测试(没有)区别
+候选答案1:哈哈哈哈
+候选答案1:呵呵呵呵
+第4题:[简答题]10分
+9分
+黑盒测试和白盒测试的区别
+参考答案
+黑盒测试也称功能测试或数据驱动测试,它是在已知产品所应具有的功能,通过测试来检测每个功能是否都能正常使用,在测试时,把程序看作一个不能打开的黑盆子,在完全不考虑程序内部结构和内部特性的情况下,
+试卷须知: + 共有选择、填空、简答、编程题4种题型,其中选择题包括单选题和多选题。 + 请大家认真答题,本次作业成绩将计入期末成绩。
++ 单选题 3 题,共 15 分 + 多选题 5 题,共 25 分 + 填空题 10 题,共 25 分 + 简答题 10 题,共 25 分 +
+合计 18 题,共 100 分
+黑盒测试和白盒测试的区别
+黑盒测试和白盒测试的区别
++ + 胡莎莎 > 智能课堂> 计算机基础> 计算机基础学院工程专业 +
+| 序号 | +姓名 | +学号 | +提交状态 | +提交时间 | +客观题得分 | +主观题教师评分 | +主观题助教评分 | +最终成绩 | +操作 | +
|---|---|---|---|---|---|---|---|---|---|
| 48 | +李航 | +2015551337 | +按时提交 | +2016-11-24 17:53 | +-- | +-- | +91.0
+
+
+
+
+ 5名助教进行了评分 |
+
+ 91.0
+
+
+
+
+ 胡莎莎(ruanjianlihang) |
+ 评阅 | +
| 48 | +胡莎莎 | +2015551337 | +延时提交 | +2016-11-24 17:53 | +95 | +-- | +91.0
+
+
+
+
+ 1名助教进行了评分 |
+
+ 52.0
+
+
+
+
+ 李航(ruanjianlihang) |
+ 评阅 | +
| 48 | +李航 | +2015551337 | +未提交 | +2016-11-24 17:53 | +-- | +65.0 | +65.0
+
+
+
+
+ 1名助教进行了评分 |
+
+ 91.0
+
+
+
+
+ 李航(ruanjianlihang) |
+ + 评阅 + + + | +
+ + 班级首页 > 试卷 +
+新建试卷
+ 返回 +简答题
++ 温馨提示:[简答题]属于主观题需要人工评分,未作答的情况下系统将自动评分 + 参考答案仅作为人工评分的参考 + 保存 + 取消 +
++ 单选题 3 题,共 15 分 + 多选题 5 题,共 25 分 + 填空题 10 题,共 25 分 + 简答题 10 题,共 25 分 +
+ + 合计 10 题,共 100 分 + +<%= render :partial => 'course_file_filter_order', :locals => {:remote => @is_remote, :sort => @sort, :order => @order} %> diff --git a/app/views/files/_course_list.html.erb b/app/views/files/_course_list.html.erb index c1836895b..67c6a458d 100644 --- a/app/views/files/_course_list.html.erb +++ b/app/views/files/_course_list.html.erb @@ -1,3 +1,10 @@ + <% if curse_attachments.count != 0 %> <% curse_attachments.each do |file| %> <% if file.is_public? || User.current.member_of_course?(course) || User.current.admin? %> @@ -8,10 +15,15 @@
+ <% if comment.creator_user == User.current %> + 删除 + <% end %> + | + <%= link_to( + '回复'.html_safe, + {:controller => 'users' ,:action => 'reply_to',:reply_id => comment.id, :type => memo.class.to_s, :user_activity_id => memo.id}, + :remote => true, + :method => 'get', + :title => l(:button_reply),:class => "color-grey") %> + | + + <%=render :partial=> "praise_tread/edu_praise", :locals => {:activity=>comment, :user_activity_id=>comment.id,:type=>"reply"}%> + +
+