diff --git a/Gemfile b/Gemfile
index 9ba9eafd7..2a11f7477 100644
--- a/Gemfile
+++ b/Gemfile
@@ -6,6 +6,7 @@ unless RUBY_PLATFORM =~ /w32/
if RUBY_PLATFORM =~ /darwin/
gem "rmagick", "= 2.15.4" ## osx must be this version
elsif RUBY_PLATFORM =~ /linux/
+ gem 'simple_xlsx_reader'
gem "rmagick", "~> 2.13.1" ## centos yum install ImageMagick-devel
end
gem 'certified'
diff --git a/app/controllers/account_controller.rb b/app/controllers/account_controller.rb
index b7a764999..7c0ad24bb 100644
--- a/app/controllers/account_controller.rb
+++ b/app/controllers/account_controller.rb
@@ -586,9 +586,19 @@ class AccountController < ApplicationController
def apply_trail
apply_action = ApplyAction.where(:user_id => User.current.id, :container_type => "TrialAuthorization", :status => 0).first
- if apply_action.blank?
+ 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?
+ User.current.update_attributes(:certification => 1)
+ @tip = "申请成功,我们将在一分钟内完成审核"
+ if apply_action.blank?
+ ApplyAction.create(:user_id => User.current.id, :status => 1, :container_type => "TrialAuthorization", :apply_reason => params[:apply_reason])
+ else
+ apply_action.update_attributes(:status => 1)
+ end
+ else
+ @tip = "申请成功,我们将在一个工作日内完成审核"
ApplyAction.create(:user_id => User.current.id, :status => 0, :container_type => "TrialAuthorization", :apply_reason => params[:apply_reason])
end
+
respond_to do |format|
format.js
end
diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb
index 5752290f4..0c09e0c08 100644
--- a/app/controllers/courses_controller.rb
+++ b/app/controllers/courses_controller.rb
@@ -25,7 +25,7 @@ class CoursesController < ApplicationController
menu_item l(:label_sort_by_active), :only => :index
menu_item l(:label_sort_by_influence), :only => :index
- before_filter :can_show_course, :except => []
+ #before_filter :can_show_course, :except => []
before_filter :logged_user_by_apptoken,:only => [:show,:feedback]
before_filter :find_course, :except => [ :index, :search, :new, :join, :unjoin, :create, :new_join, :course, :join_private_courses, :join_course_multi_role, :unjoin_group, :search_course_list]
before_filter :authorize_course, :only => [:show, :settings, :update, :course]
diff --git a/app/controllers/games_controller.rb b/app/controllers/games_controller.rb
index ac286938c..69194f1f8 100644
--- a/app/controllers/games_controller.rb
+++ b/app/controllers/games_controller.rb
@@ -29,6 +29,7 @@ class GamesController < ApplicationController
# @st 0 实践任务 1 多选任务 2 单选任务
def show
# 展示全部实训
+ @is_subject = params[:is_subject]
if @game.status == 1
# 放置页面ajax数据还没获取就关闭
@game.update_attribute(:status, 0)
@@ -91,6 +92,7 @@ class GamesController < ApplicationController
@had_passed_testsests_hidden_count = had_test.blank? ? 0 : had_test.select{|had_test| had_test.result == true && had_test.is_public == false}.count
@had_passed_testsests_public_count = had_test.blank? ? 0 : had_test.select{|had_test| had_test.result == true && had_test.is_public == true}.count
@final_score = ((@game.answer_open? || @shixun.status <= 1) ? 0 : @game.final_score.to_i)
+ @gold = @myshixun.shixun.status <= 1 ? 0 : (@game.answer_open? ? -@game_challenge.score.to_i : @game.final_score.to_i)
@had_done = @game.had_done
@language = @game_challenge.shixun.language
error_position = had_test.blank? ? nil : had_test.select{|had_test| had_test.result == false}.last
@@ -277,6 +279,7 @@ class GamesController < ApplicationController
@had_passed_testsests_hidden_count = had_test.blank? ? 0 : had_test.select{|had_test| had_test.result == true && had_test.is_public == false}.count
@had_passed_testsests_public_count = had_test.blank? ? 0 : had_test.select{|had_test| had_test.result == true && had_test.is_public == true}.count
@final_score = ((@game.answer_open? || shixun.status <= 1) ? 0 : @game.final_score.to_i)
+ @gold = @myshixun.shixun.status <= 1 ? 0 : (@game.answer_open? ? -game_challenge.score.to_i : @game.final_score.to_i)
error_position = had_test.blank? ? nil : had_test.select{|had_test| had_test.result == false}.last
@latest_output = error_position.try(:out_put).gsub(/\n/, '
').gsub(/\t/, ' ') unless error_position.try(:out_put).blank?
logger.info("@compile_success###################{@compile_success}")
@@ -290,6 +293,7 @@ class GamesController < ApplicationController
had_passed_testsests_hidden_count: @had_passed_testsests_hidden_count,
had_passed_testsests_public_count: @had_passed_testsests_public_count,
final_score: @final_score,
+ gold: @gold,
latest_output: @latest_output,
status: game_status,
had_done: had_done,
@@ -312,7 +316,7 @@ 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.choose_outputs.blank?
+ 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
if @shixun.status > 1 && !@game.answer_open
@@ -413,7 +417,6 @@ class GamesController < ApplicationController
if challenge.shixun.status < 2 || @game.answer_open || (challenge.st != 0 && @game.status == 2)
@viewed = 1
else
- @game.update_attributes(:answer_open => true) unless @game.answer_open
if @score >= 0
@viewed = 2
else
diff --git a/app/controllers/homework_common_controller.rb b/app/controllers/homework_common_controller.rb
index 182d355f4..f0a1b84a7 100644
--- a/app/controllers/homework_common_controller.rb
+++ b/app/controllers/homework_common_controller.rb
@@ -441,27 +441,27 @@ class HomeworkCommonController < ApplicationController
is_eva_student_works = StudentWork.where(:homework_common_id => is_eva_homeworks.map{|hw| hw.id})
has_eva_homeworks = @course.homework_commons.includes(:homework_detail_manual).where("homework_commons.anonymous_comment = 0 and homework_detail_manuals.comment_status = 3")
has_eva_student_works = StudentWork.where(:homework_common_id => has_eva_homeworks.map{|hw| hw.id})
- @course.student.each do |student|
- user = student.student
- course_statistics = CourseHomeworkStatistics.find_by_course_id_and_user_id(@homework.course_id, student.student_id)
- if user && course_statistics
- committed_work_num = user.student_works.where("homework_common_id in #{homework_ids} and work_status != 0").count
- un_commit_work_num = (hw_count - committed_work_num) < 0 ? 0 : (hw_count - committed_work_num)
- late_commit_work_num = user.student_works.where("homework_common_id in #{homework_ids} and work_status = 2").count
- absence_evaluation_work_num = user.student_works_evaluation_distributions.where(:student_work_id => has_eva_student_works.map(&:id)).count -
- user.student_works_scores.where(:reviewer_role => 3, :student_work_id => has_eva_student_works.map(&:id)).group_by(&:student_work_id).count
- absence_evaluation_work_num = absence_evaluation_work_num < 0 ? 0 : absence_evaluation_work_num
- un_evaluation_work_num = user.student_works_evaluation_distributions.where(:student_work_id => is_eva_student_works.map(&:id)).count -
- user.student_works_scores.where(:reviewer_role => 3, :student_work_id => is_eva_student_works.map(&:id)).group_by(&:student_work_id).count
- un_evaluation_work_num = un_evaluation_work_num < 0 ? 0 : un_evaluation_work_num
- appeal_num = user.student_works_scores.where(:student_work_id => student_works.map(&:id), :appeal_status => 3).count
- average_score = user.student_works.where(:id => student_works.map(&:id)).select("AVG(student_works.work_score) as score").first ? user.student_works.where(:id => student_works.map(&:id)).select("AVG(student_works.work_score) as score").first.score : 0
- total_score = user.student_works.where(:id => student_works.map(&:id)).select("SUM(student_works.work_score) as score").first ? user.student_works.where(:id => student_works.map(&:id)).select("SUM(student_works.work_score) as score").first.score : 0
- course_statistics.update_attributes(:committed_work_num => committed_work_num, :un_commit_work_num => un_commit_work_num,
- :late_commit_work_num => late_commit_work_num, :absence_evaluation_work_num => absence_evaluation_work_num, :un_evaluation_work_num => un_evaluation_work_num,
- :appeal_num => appeal_num, :average_score => average_score, :total_score => total_score)
- end
- end
+ # @course.student.each do |student|
+ # user = student.student
+ # course_statistics = CourseHomeworkStatistics.find_by_course_id_and_user_id(@homework.course_id, student.student_id)
+ # if user && course_statistics
+ # committed_work_num = user.student_works.where("homework_common_id in #{homework_ids} and work_status != 0").count
+ # un_commit_work_num = (hw_count - committed_work_num) < 0 ? 0 : (hw_count - committed_work_num)
+ # late_commit_work_num = user.student_works.where("homework_common_id in #{homework_ids} and work_status = 2").count
+ # absence_evaluation_work_num = user.student_works_evaluation_distributions.where(:student_work_id => has_eva_student_works.map(&:id)).count -
+ # user.student_works_scores.where(:reviewer_role => 3, :student_work_id => has_eva_student_works.map(&:id)).group_by(&:student_work_id).count
+ # absence_evaluation_work_num = absence_evaluation_work_num < 0 ? 0 : absence_evaluation_work_num
+ # un_evaluation_work_num = user.student_works_evaluation_distributions.where(:student_work_id => is_eva_student_works.map(&:id)).count -
+ # user.student_works_scores.where(:reviewer_role => 3, :student_work_id => is_eva_student_works.map(&:id)).group_by(&:student_work_id).count
+ # un_evaluation_work_num = un_evaluation_work_num < 0 ? 0 : un_evaluation_work_num
+ # appeal_num = user.student_works_scores.where(:student_work_id => student_works.map(&:id), :appeal_status => 3).count
+ # average_score = user.student_works.where(:id => student_works.map(&:id)).select("AVG(student_works.work_score) as score").first ? user.student_works.where(:id => student_works.map(&:id)).select("AVG(student_works.work_score) as score").first.score : 0
+ # total_score = user.student_works.where(:id => student_works.map(&:id)).select("SUM(student_works.work_score) as score").first ? user.student_works.where(:id => student_works.map(&:id)).select("SUM(student_works.work_score) as score").first.score : 0
+ # course_statistics.update_attributes(:committed_work_num => committed_work_num, :un_commit_work_num => un_commit_work_num,
+ # :late_commit_work_num => late_commit_work_num, :absence_evaluation_work_num => absence_evaluation_work_num, :un_evaluation_work_num => un_evaluation_work_num,
+ # :appeal_num => appeal_num, :average_score => average_score, :total_score => total_score)
+ # end
+ # end
respond_to do |format|
format.html {
@@ -539,10 +539,10 @@ class HomeworkCommonController < ApplicationController
create_works_list @homework
end
#更新CourseHomeworkStatistics中每个学生的未交作品数
- @course.student.each do |student|
- course_statistics = CourseHomeworkStatistics.find_by_course_id_and_user_id(@homework.course_id, student.student_id)
- course_statistics.update_attribute('un_commit_work_num', course_statistics.un_commit_work_num + 1) if course_statistics
- end
+ # @course.student.each do |student|
+ # course_statistics = CourseHomeworkStatistics.find_by_course_id_and_user_id(@homework.course_id, student.student_id)
+ # course_statistics.update_attribute('un_commit_work_num', course_statistics.un_commit_work_num + 1) if course_statistics
+ # end
@course.members.each do |m|
@homework.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => @course.id, :viewed => false, :status => nil)
@@ -599,8 +599,8 @@ class HomeworkCommonController < ApplicationController
end
#更新CourseHomeworkStatistics中该学生的待匿评数
- course_statistics = CourseHomeworkStatistics.find_by_course_id_and_user_id(@homework.course_id, pro_work.user_id)
- course_statistics.update_attribute('un_evaluation_work_num', course_statistics.un_evaluation_work_num + n) if course_statistics
+ # course_statistics = CourseHomeworkStatistics.find_by_course_id_and_user_id(@homework.course_id, pro_work.user_id)
+ # course_statistics.update_attribute('un_evaluation_work_num', course_statistics.un_evaluation_work_num + n) if course_statistics
end
else
student_works.each_with_index do |work, index|
@@ -614,8 +614,8 @@ class HomeworkCommonController < ApplicationController
end
#更新CourseHomeworkStatistics中该学生的待匿评数
- course_statistics = CourseHomeworkStatistics.find_by_course_id_and_user_id(@homework.course_id, user.id)
- course_statistics.update_attribute('un_evaluation_work_num', course_statistics.un_evaluation_work_num + n) if course_statistics
+ # course_statistics = CourseHomeworkStatistics.find_by_course_id_and_user_id(@homework.course_id, user.id)
+ # course_statistics.update_attribute('un_evaluation_work_num', course_statistics.un_evaluation_work_num + n) if course_statistics
end
end
@homework_detail_manual.update_column('comment_status', 2)
@@ -650,9 +650,9 @@ class HomeworkCommonController < ApplicationController
student_work.save
#更新CourseHomeworkStatistics中该学生的待匿评数和缺评数
- course_statistics = CourseHomeworkStatistics.find_by_course_id_and_user_id(@homework.course_id, student_work.user_id)
- course_statistics.update_attribute('un_evaluation_work_num', (course_statistics.un_evaluation_work_num - absence_penalty_count) < 0 ? 0 : (course_statistics.un_evaluation_work_num - absence_penalty_count)) if course_statistics
- course_statistics.update_attribute('absence_evaluation_work_num', course_statistics.absence_evaluation_work_num + absence_penalty_count) if course_statistics
+ # course_statistics = CourseHomeworkStatistics.find_by_course_id_and_user_id(@homework.course_id, student_work.user_id)
+ # course_statistics.update_attribute('un_evaluation_work_num', (course_statistics.un_evaluation_work_num - absence_penalty_count) < 0 ? 0 : (course_statistics.un_evaluation_work_num - absence_penalty_count)) if course_statistics
+ # course_statistics.update_attribute('absence_evaluation_work_num', course_statistics.absence_evaluation_work_num + absence_penalty_count) if course_statistics
end
# 未参与匿评的缺评计算
diff --git a/app/controllers/managements_controller.rb b/app/controllers/managements_controller.rb
index 3d60ed6ec..049118784 100644
--- a/app/controllers/managements_controller.rb
+++ b/app/controllers/managements_controller.rb
@@ -688,11 +688,11 @@ end
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 = 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
@@ -701,12 +701,11 @@ end
end
if params[:course_list] && params[:course_list] != ''
- @courses = @courses.where(:course_list_id => courselist)
+ @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?
@@ -719,6 +718,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
@@ -728,6 +728,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
@@ -1379,28 +1384,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/members_controller.rb b/app/controllers/members_controller.rb
index 156a6653b..5155933e0 100644
--- a/app/controllers/members_controller.rb
+++ b/app/controllers/members_controller.rb
@@ -487,7 +487,7 @@ class MembersController < ApplicationController
CourseMessage.create(:user_id => @member.user_id, :course_id => @course.id, :course_message_type => "RemoveFromCourse", :viewed => false, :course_message_id => User.current.id)
end
respond_to do |format|
- format.html { redirect_to_settings_in_courses }
+ format.html { redirect_to members_course_path(@course) }
format.js
format.api {
if @member.destroyed?
diff --git a/app/controllers/myshixuns_controller.rb b/app/controllers/myshixuns_controller.rb
index 1c7aef02c..813c790b4 100644
--- a/app/controllers/myshixuns_controller.rb
+++ b/app/controllers/myshixuns_controller.rb
@@ -98,7 +98,7 @@ class MyshixunsController < ApplicationController
raise("实训云平台繁忙(繁忙等级:87)")
end
end
- redirect_to shixun_exec_shixun_path(shixun, :type => 1)
+ redirect_to shixun_exec_shixun_path(shixun, :type => 1, :is_subject => params[:is_subject])
rescue Exception => e
flash[:error] = "实训云平台繁忙(繁忙等级:89)"
g.delete_project(@myshixun.gpid) if !g_project.try(:id).nil?
diff --git a/app/controllers/shixuns_controller.rb b/app/controllers/shixuns_controller.rb
index 5cbeff5bd..f4bbc6ad8 100644
--- a/app/controllers/shixuns_controller.rb
+++ b/app/controllers/shixuns_controller.rb
@@ -20,7 +20,7 @@ class ShixunsController < ApplicationController
end
# push代码的时候会触发gitlab hook
def ghook
- shixun_modify_status_without_publish(@shixun, 1)
+ # shixun_modify_status_without_publish(@shixun, 1)
render :json => {status: "success"}
end
@@ -139,7 +139,7 @@ class ShixunsController < ApplicationController
@sort = "asc"
search = params[:search]
@mail = User.current.mail.blank?
- @shixun_all_count = Shixun.all.count
+ @shixun_all_count = Shixun.where(:hidden => 0).count
@shixuns = Shixun.where("name like ? and hidden = 0", "%#{search}%")
# @shixuns.each do |shixun|
# shixun[:myshixunCount] = shixun.myshixuns.count
@@ -388,7 +388,7 @@ class ShixunsController < ApplicationController
myshixun = Myshixun.where(:user_id => User.current.id, :shixun_id => @shixun.id).first
unless myshixun.blank?
logger.info("current task id is #{myshixun.current_task}")
- redirect_to myshixun_game_path(myshixun.current_task, :myshixun_id => myshixun)
+ redirect_to myshixun_game_path(myshixun.current_task, :myshixun_id => myshixun, :is_subject => params[:is_subject])
return
end
ActiveRecord::Base.transaction do
@@ -408,7 +408,9 @@ class ShixunsController < ApplicationController
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, "educoder") # 注意:educoder为默认给实训创建版本库的用户,如果换成别的用户,名字要相应的修改
+ logger.info("start openGameInstance")
uri = "#{shixun_tomcat}/bridge/game/openGameInstance"
+ logger.info("end openGameInstance")
params = {tpiID: "#{myshixun.id}", tpmID: "#{@shixun.id}", instanceGitURL:rep_url, operationEnvironment:"#{@shixun.try(:language)}"}
logger.info("openGameInstance params is #{params}")
res = uri_exec uri, params
@@ -438,7 +440,7 @@ class ShixunsController < ApplicationController
raise("实训云平台繁忙(繁忙等级:81)")
end
logger.info("myshixun id si #{myshixun.id} and current_task id is#{myshixun.current_task.id}")
- redirect_to myshixun_game_path(myshixun.current_task, :myshixun_id => myshixun)
+ redirect_to myshixun_game_path(myshixun.current_task, :myshixun_id => myshixun, :is_subject => params[:is_subject])
rescue Exception => e
flash[:error] = e.message
logger.info("failed to exec shixun: current task id is #{e}")
@@ -584,7 +586,7 @@ class ShixunsController < ApplicationController
begin
@shixun.save!
if language != params[:language]
- shixun_modify_status_without_publish(@shixun, 1)
+ add_shixun_modify_status(@shixun, 1)
end
rescue
@error = "实训保存失败"
diff --git a/app/controllers/student_work_controller.rb b/app/controllers/student_work_controller.rb
index d65032df4..70052e997 100644
--- a/app/controllers/student_work_controller.rb
+++ b/app/controllers/student_work_controller.rb
@@ -359,6 +359,9 @@ class StudentWorkController < ApplicationController
end
end
##################################################################################################################
+ if @homework.homework_type == 4 && (@homework.publish_time > Time.now || (@homework.publish_time <= Time.now && @homework.allow_late))
+ update_shixun_work_status @homework
+ end
@order,@b_sort,@name,@group,@comment,@status = params[:order] || "updated_at",params[:sort] || "desc",params[:name].to_s.strip || "",params[:group], params[:comment], params[:status]
@homework_commons = @course.homework_commons.where("publish_time <= ?",Time.now).order("created_at desc")
@all_homework_commons = @course.homework_commons.order("created_at desc")
@@ -549,17 +552,17 @@ class StudentWorkController < ApplicationController
end
#更新CourseHomeworkStatistics中学生的迟交作品数
- course_statistics = CourseHomeworkStatistics.find_by_course_id_and_user_id(@homework.course_id, User.current.id)
- course_statistics.update_attribute('late_commit_work_num', course_statistics.late_commit_work_num + 1) if course_statistics
+ # course_statistics = CourseHomeworkStatistics.find_by_course_id_and_user_id(@homework.course_id, User.current.id)
+ # course_statistics.update_attribute('late_commit_work_num', course_statistics.late_commit_work_num + 1) if course_statistics
else
student_work.late_penalty = 0
student_work.work_status = 1
end
if student_work.save
#更新CourseHomeworkStatistics中学生的未交作品数、已交作品数
- course_statistics = CourseHomeworkStatistics.find_by_course_id_and_user_id(@homework.course_id, User.current.id)
- course_statistics.update_attribute('committed_work_num', course_statistics.committed_work_num + 1) if course_statistics
- course_statistics.update_attribute('un_commit_work_num', (course_statistics.un_commit_work_num - 1) < 0 ? 0 : (course_statistics.un_commit_work_num - 1)) if course_statistics
+ # course_statistics = CourseHomeworkStatistics.find_by_course_id_and_user_id(@homework.course_id, User.current.id)
+ # course_statistics.update_attribute('committed_work_num', course_statistics.committed_work_num + 1) if course_statistics
+ # course_statistics.update_attribute('un_commit_work_num', (course_statistics.un_commit_work_num - 1) < 0 ? 0 : (course_statistics.un_commit_work_num - 1)) if course_statistics
if @homework.homework_type == 3
if @homework.homework_detail_group.base_on_project == 1
@@ -579,12 +582,12 @@ class StudentWorkController < ApplicationController
end
#更新CourseHomeworkStatistics中学生的未交作品数、已交作品数、迟交作品数
- course_statistics = CourseHomeworkStatistics.find_by_course_id_and_user_id(@homework.course_id, members[i].to_i)
- course_statistics.update_attribute('committed_work_num', course_statistics.committed_work_num + 1) if course_statistics
- course_statistics.update_attribute('un_commit_work_num', (course_statistics.un_commit_work_num - 1) < 0 ? 0 : (course_statistics.un_commit_work_num - 1)) if course_statistics
- if student_work.work_status == 2
- course_statistics.update_attribute('late_commit_work_num', course_statistics.late_commit_work_num + 1) if course_statistics
- end
+ # course_statistics = CourseHomeworkStatistics.find_by_course_id_and_user_id(@homework.course_id, members[i].to_i)
+ # course_statistics.update_attribute('committed_work_num', course_statistics.committed_work_num + 1) if course_statistics
+ # course_statistics.update_attribute('un_commit_work_num', (course_statistics.un_commit_work_num - 1) < 0 ? 0 : (course_statistics.un_commit_work_num - 1)) if course_statistics
+ # if student_work.work_status == 2
+ # course_statistics.update_attribute('late_commit_work_num', course_statistics.late_commit_work_num + 1) if course_statistics
+ # end
end
end
@homework.update_column(:updated_at, Time.now)
@@ -628,14 +631,14 @@ class StudentWorkController < ApplicationController
student_work_projects = @homework.student_work_projects.where("student_work_id=? and user_id !=?",@student_work_project.student_work_id,User.current.id)
#user_ids = student_work_projects.empty? ? "(-1)" : "(" + student_work_projects.map{|stu|stu.user_id}.join(",") + ")"
student_works = @homework.student_works.where("group_id = #{@work.group_id} and user_id != #{@work.user_id}")
- student_works.each do |sw|
- course_statistics = CourseHomeworkStatistics.find_by_course_id_and_user_id(@homework.course_id, sw.user_id)
- if @work.work_status == 2
- course_statistics.update_attribute('late_commit_work_num', (course_statistics.late_commit_work_num - 1) < 0 ? 0 : (course_statistics.late_commit_work_num - 1)) if course_statistics
- end
- course_statistics.update_attribute('committed_work_num', (course_statistics.committed_work_num - 1) < 0 ? 0 : (course_statistics.committed_work_num - 1)) if course_statistics
- course_statistics.update_attribute('un_commit_work_num', course_statistics.un_commit_work_num + 1) if course_statistics
- end
+ # student_works.each do |sw|
+ # course_statistics = CourseHomeworkStatistics.find_by_course_id_and_user_id(@homework.course_id, sw.user_id)
+ # if @work.work_status == 2
+ # course_statistics.update_attribute('late_commit_work_num', (course_statistics.late_commit_work_num - 1) < 0 ? 0 : (course_statistics.late_commit_work_num - 1)) if course_statistics
+ # end
+ # course_statistics.update_attribute('committed_work_num', (course_statistics.committed_work_num - 1) < 0 ? 0 : (course_statistics.committed_work_num - 1)) if course_statistics
+ # course_statistics.update_attribute('un_commit_work_num', course_statistics.un_commit_work_num + 1) if course_statistics
+ # end
student_works.update_all(:work_status => 0, :description => nil, :project_id => 0, :late_penalty => 0,:work_status => 0, :commit_time => nil, :group_id => 0)
student_work_projects.delete_all
@student_work_project.update_attributes(:is_leader => 1)
@@ -649,12 +652,12 @@ class StudentWorkController < ApplicationController
end
#更新CourseHomeworkStatistics中学生的未交作品数、已交作品数、迟交作品数
- course_statistics = CourseHomeworkStatistics.find_by_course_id_and_user_id(@homework.course_id, members[i].to_i)
- course_statistics.update_attribute('committed_work_num', course_statistics.committed_work_num + 1) if course_statistics
- course_statistics.update_attribute('un_commit_work_num', (course_statistics.un_commit_work_num - 1) < 0 ? 0 : (course_statistics.un_commit_work_num - 1)) if course_statistics
- if @work.work_status == 2
- course_statistics.update_attribute('late_commit_work_num', course_statistics.late_commit_work_num + 1) if course_statistics
- end
+ # course_statistics = CourseHomeworkStatistics.find_by_course_id_and_user_id(@homework.course_id, members[i].to_i)
+ # course_statistics.update_attribute('committed_work_num', course_statistics.committed_work_num + 1) if course_statistics
+ # course_statistics.update_attribute('un_commit_work_num', (course_statistics.un_commit_work_num - 1) < 0 ? 0 : (course_statistics.un_commit_work_num - 1)) if course_statistics
+ # if @work.work_status == 2
+ # course_statistics.update_attribute('late_commit_work_num', course_statistics.late_commit_work_num + 1) if course_statistics
+ # end
end
end
@@ -709,14 +712,14 @@ class StudentWorkController < ApplicationController
#更新CourseHomeworkStatistics中每个学生的未交作品数、已交作品数、迟交作品数
- student_works.each do |sw|
- course_statistics = CourseHomeworkStatistics.find_by_course_id_and_user_id(@homework.course_id, sw.user_id)
- if @work.work_status == 2
- course_statistics.update_attribute('late_commit_work_num', (course_statistics.late_commit_work_num - 1) < 0 ? 0 : (course_statistics.late_commit_work_num - 1)) if course_statistics
- end
- course_statistics.update_attribute('committed_work_num', (course_statistics.committed_work_num - 1) < 0 ? 0 : (course_statistics.committed_work_num - 1)) if course_statistics
- course_statistics.update_attribute('un_commit_work_num', course_statistics.un_commit_work_num + 1) if course_statistics
- end
+ # student_works.each do |sw|
+ # course_statistics = CourseHomeworkStatistics.find_by_course_id_and_user_id(@homework.course_id, sw.user_id)
+ # if @work.work_status == 2
+ # course_statistics.update_attribute('late_commit_work_num', (course_statistics.late_commit_work_num - 1) < 0 ? 0 : (course_statistics.late_commit_work_num - 1)) if course_statistics
+ # end
+ # course_statistics.update_attribute('committed_work_num', (course_statistics.committed_work_num - 1) < 0 ? 0 : (course_statistics.committed_work_num - 1)) if course_statistics
+ # course_statistics.update_attribute('un_commit_work_num', course_statistics.un_commit_work_num + 1) if course_statistics
+ # end
student_works.update_all(:work_status => 0, :description => nil, :project_id => 0, :late_penalty => 0,:work_status => 0, :commit_time => nil)
pros.delete_all
@@ -731,12 +734,12 @@ class StudentWorkController < ApplicationController
@work.update_all(:work_status => 0, :description => nil, :project_id => 0, :late_penalty => 0,:work_status => 0, :commit_time => nil)
else
#更新CourseHomeworkStatistics中学生的已交作品数、迟交作品数
- course_statistics = CourseHomeworkStatistics.find_by_course_id_and_user_id(@homework.course_id, @work.user_id)
- if @work.work_status == 2
- course_statistics.update_attribute('late_commit_work_num', (course_statistics.late_commit_work_num - 1) < 0 ? 0 : (course_statistics.late_commit_work_num - 1)) if course_statistics
- end
- course_statistics.update_attribute('committed_work_num', (course_statistics.committed_work_num - 1) < 0 ? 0 : (course_statistics.committed_work_num - 1)) if course_statistics
- course_statistics.update_attribute('un_commit_work_num', course_statistics.un_commit_work_num + 1) if course_statistics
+ # course_statistics = CourseHomeworkStatistics.find_by_course_id_and_user_id(@homework.course_id, @work.user_id)
+ # if @work.work_status == 2
+ # course_statistics.update_attribute('late_commit_work_num', (course_statistics.late_commit_work_num - 1) < 0 ? 0 : (course_statistics.late_commit_work_num - 1)) if course_statistics
+ # end
+ # course_statistics.update_attribute('committed_work_num', (course_statistics.committed_work_num - 1) < 0 ? 0 : (course_statistics.committed_work_num - 1)) if course_statistics
+ # course_statistics.update_attribute('un_commit_work_num', course_statistics.un_commit_work_num + 1) if course_statistics
@work.attachments.destroy_all
@work.student_works_scores.destroy_all
@@ -761,14 +764,14 @@ class StudentWorkController < ApplicationController
student_works = @homework.student_works.where("user_id in #{user_ids}")
#更新CourseHomeworkStatistics中每个学生的已交作品数、迟交作品数
- student_works.each do |sw|
- course_statistics = CourseHomeworkStatistics.find_by_course_id_and_user_id(@homework.course_id, sw.user_id)
- if @work.work_status == 2
- course_statistics.update_attribute('late_commit_work_num', (course_statistics.late_commit_work_num - 1) < 0 ? 0 : (course_statistics.late_commit_work_num - 1)) if course_statistics
- end
- course_statistics.update_attribute('committed_work_num', (course_statistics.committed_work_num - 1) < 0 ? 0 : (course_statistics.committed_work_num - 1)) if course_statistics
- course_statistics.update_attribute('un_commit_work_num', course_statistics.un_commit_work_num + 1) if course_statistics
- end
+ # student_works.each do |sw|
+ # course_statistics = CourseHomeworkStatistics.find_by_course_id_and_user_id(@homework.course_id, sw.user_id)
+ # if @work.work_status == 2
+ # course_statistics.update_attribute('late_commit_work_num', (course_statistics.late_commit_work_num - 1) < 0 ? 0 : (course_statistics.late_commit_work_num - 1)) if course_statistics
+ # end
+ # course_statistics.update_attribute('committed_work_num', (course_statistics.committed_work_num - 1) < 0 ? 0 : (course_statistics.committed_work_num - 1)) if course_statistics
+ # course_statistics.update_attribute('un_commit_work_num', course_statistics.un_commit_work_num + 1) if course_statistics
+ # end
student_works.delete_all
pros.delete_all
@@ -781,12 +784,12 @@ class StudentWorkController < ApplicationController
@work.destroy
else
#更新CourseHomeworkStatistics中学生的已交作品数、迟交作品数
- course_statistics = CourseHomeworkStatistics.find_by_course_id_and_user_id(@homework.course_id, @work.user_id)
- if @work.work_status == 2
- course_statistics.update_attribute('late_commit_work_num', (course_statistics.late_commit_work_num - 1) < 0 ? 0 : (course_statistics.late_commit_work_num - 1)) if course_statistics
- end
- course_statistics.update_attribute('committed_work_num', (course_statistics.committed_work_num - 1) < 0 ? 0 : (course_statistics.committed_work_num - 1)) if course_statistics
- course_statistics.update_attribute('un_commit_work_num', course_statistics.un_commit_work_num + 1) if course_statistics
+ # course_statistics = CourseHomeworkStatistics.find_by_course_id_and_user_id(@homework.course_id, @work.user_id)
+ # if @work.work_status == 2
+ # course_statistics.update_attribute('late_commit_work_num', (course_statistics.late_commit_work_num - 1) < 0 ? 0 : (course_statistics.late_commit_work_num - 1)) if course_statistics
+ # end
+ # course_statistics.update_attribute('committed_work_num', (course_statistics.committed_work_num - 1) < 0 ? 0 : (course_statistics.committed_work_num - 1)) if course_statistics
+ # course_statistics.update_attribute('un_commit_work_num', course_statistics.un_commit_work_num + 1) if course_statistics
@work.update_attributes(:work_status => 0, :name => "#{@homework.name}的作品提交", :description => nil, :late_penalty => 0, :commit_time => nil, :project_id => 0)
@work.attachments.destroy_all
@@ -803,14 +806,14 @@ class StudentWorkController < ApplicationController
student_works = @homework.student_works.where("user_id in #{user_ids}")
#更新CourseHomeworkStatistics中每个学生的已交作品数、迟交作品数
- student_works.each do |sw|
- course_statistics = CourseHomeworkStatistics.find_by_course_id_and_user_id(@homework.course_id, sw.user_id)
- if @work.work_status == 2
- course_statistics.update_attribute('late_commit_work_num', (course_statistics.late_commit_work_num - 1) < 0 ? 0 : (course_statistics.late_commit_work_num - 1)) if course_statistics
- end
- course_statistics.update_attribute('committed_work_num', (course_statistics.committed_work_num - 1) < 0 ? 0 : (course_statistics.committed_work_num - 1)) if course_statistics
- course_statistics.update_attribute('un_commit_work_num', course_statistics.un_commit_work_num + 1) if course_statistics
- end
+ # student_works.each do |sw|
+ # course_statistics = CourseHomeworkStatistics.find_by_course_id_and_user_id(@homework.course_id, sw.user_id)
+ # if @work.work_status == 2
+ # course_statistics.update_attribute('late_commit_work_num', (course_statistics.late_commit_work_num - 1) < 0 ? 0 : (course_statistics.late_commit_work_num - 1)) if course_statistics
+ # end
+ # course_statistics.update_attribute('committed_work_num', (course_statistics.committed_work_num - 1) < 0 ? 0 : (course_statistics.committed_work_num - 1)) if course_statistics
+ # course_statistics.update_attribute('un_commit_work_num', course_statistics.un_commit_work_num + 1) if course_statistics
+ # end
student_works.delete_all
pros.delete_all
@@ -823,12 +826,12 @@ class StudentWorkController < ApplicationController
@work.destroy
else
#更新CourseHomeworkStatistics中学生的已交作品数、迟交作品数
- course_statistics = CourseHomeworkStatistics.find_by_course_id_and_user_id(@homework.course_id, @work.user_id)
- if @work.work_status == 2
- course_statistics.update_attribute('late_commit_work_num', (course_statistics.late_commit_work_num - 1) < 0 ? 0 : (course_statistics.late_commit_work_num - 1)) if course_statistics
- end
- course_statistics.update_attribute('committed_work_num', (course_statistics.committed_work_num - 1) < 0 ? 0 : (course_statistics.committed_work_num - 1)) if course_statistics
- course_statistics.update_attribute('un_commit_work_num', course_statistics.un_commit_work_num + 1) if course_statistics
+ # course_statistics = CourseHomeworkStatistics.find_by_course_id_and_user_id(@homework.course_id, @work.user_id)
+ # if @work.work_status == 2
+ # course_statistics.update_attribute('late_commit_work_num', (course_statistics.late_commit_work_num - 1) < 0 ? 0 : (course_statistics.late_commit_work_num - 1)) if course_statistics
+ # end
+ # course_statistics.update_attribute('committed_work_num', (course_statistics.committed_work_num - 1) < 0 ? 0 : (course_statistics.committed_work_num - 1)) if course_statistics
+ # course_statistics.update_attribute('un_commit_work_num', course_statistics.un_commit_work_num + 1) if course_statistics
@work.update_attributes(:work_status => 0, :name => "#{@homework.name}的作品提交", :description => nil, :late_penalty => 0, :commit_time => nil, :project_id => 0)
@work.attachments.destroy_all
@@ -853,17 +856,17 @@ class StudentWorkController < ApplicationController
work.work_status = 2
#更新CourseHomeworkStatistics中学生的迟交作品数
- course_statistics = CourseHomeworkStatistics.find_by_course_id_and_user_id(@homework.course_id, User.current.id)
- course_statistics.update_attribute('late_commit_work_num', course_statistics.late_commit_work_num + 1) if course_statistics
+ # course_statistics = CourseHomeworkStatistics.find_by_course_id_and_user_id(@homework.course_id, User.current.id)
+ # course_statistics.update_attribute('late_commit_work_num', course_statistics.late_commit_work_num + 1) if course_statistics
else
work.late_penalty = 0
work.work_status = 1
end
if work.save
#更新CourseHomeworkStatistics中学生的未交作品数、已交作品数
- course_statistics = CourseHomeworkStatistics.find_by_course_id_and_user_id(@homework.course_id, User.current.id)
- course_statistics.update_attribute('committed_work_num', course_statistics.committed_work_num + 1) if course_statistics
- course_statistics.update_attribute('un_commit_work_num', (course_statistics.un_commit_work_num - 1) < 0 ? 0 : (course_statistics.un_commit_work_num - 1)) if course_statistics
+ # course_statistics = CourseHomeworkStatistics.find_by_course_id_and_user_id(@homework.course_id, User.current.id)
+ # course_statistics.update_attribute('committed_work_num', course_statistics.committed_work_num + 1) if course_statistics
+ # course_statistics.update_attribute('un_commit_work_num', (course_statistics.un_commit_work_num - 1) < 0 ? 0 : (course_statistics.un_commit_work_num - 1)) if course_statistics
@homework.update_column(:updated_at, Time.now)
update_course_activity(@homework.class,@homework.id)
@@ -919,9 +922,9 @@ class StudentWorkController < ApplicationController
stu_project.save
end
#更新CourseHomeworkStatistics中学生的已交作品数、未交作品数
- course_statistics = CourseHomeworkStatistics.find_by_course_id_and_user_id(@homework.course_id, @work.user_id)
- course_statistics.update_attribute('committed_work_num', course_statistics.committed_work_num + 1) if course_statistics
- course_statistics.update_attribute('un_commit_work_num', (course_statistics.un_commit_work_num - 1) < 0 ? 0 : (course_statistics.un_commit_work_num - 1)) if course_statistics
+ # course_statistics = CourseHomeworkStatistics.find_by_course_id_and_user_id(@homework.course_id, @work.user_id)
+ # course_statistics.update_attribute('committed_work_num', course_statistics.committed_work_num + 1) if course_statistics
+ # course_statistics.update_attribute('un_commit_work_num', (course_statistics.un_commit_work_num - 1) < 0 ? 0 : (course_statistics.un_commit_work_num - 1)) if course_statistics
end
if User.current.admin?
@new_score.reviewer_role = 1
@@ -976,10 +979,10 @@ class StudentWorkController < ApplicationController
end
#更新CourseHomeworkStatistics中该学生的待匿评数, 只计算第一次评分
- if User.current.student_works_scores.where(:student_work_id => @work.id, :reviewer_role => 3).count == 1
- course_statistics = CourseHomeworkStatistics.find_by_course_id_and_user_id(@homework.course_id, User.current.id)
- course_statistics.update_attribute('un_evaluation_work_num', (course_statistics.un_evaluation_work_num - 1) < 0 ? 0 : (course_statistics.un_evaluation_work_num - 1)) if course_statistics
- end
+ # if User.current.student_works_scores.where(:student_work_id => @work.id, :reviewer_role => 3).count == 1
+ # course_statistics = CourseHomeworkStatistics.find_by_course_id_and_user_id(@homework.course_id, User.current.id)
+ # course_statistics.update_attribute('un_evaluation_work_num', (course_statistics.un_evaluation_work_num - 1) < 0 ? 0 : (course_statistics.un_evaluation_work_num - 1)) if course_statistics
+ # end
end
@homework.update_column('updated_at', Time.now)
update_course_activity(@homework.class,@homework.id)
@@ -1315,10 +1318,10 @@ class StudentWorkController < ApplicationController
sw.update_attribute("appeal_penalty", homework.homework_detail_manual.appeal_penalty + sw.appeal_penalty)
#申诉成功,匿评学生的被申诉记录加一
- course_homework_statistics = CourseHomeworkStatistics.where(:user_id => @student_work_score.user_id, :course_id => course.id).first
- if course_homework_statistics
- course_homework_statistics.update_attribute('appeal_num', course_homework_statistics.appeal_num + 1)
- end
+ # course_homework_statistics = CourseHomeworkStatistics.where(:user_id => @student_work_score.user_id, :course_id => course.id).first
+ # if course_homework_statistics
+ # course_homework_statistics.update_attribute('appeal_num', course_homework_statistics.appeal_num + 1)
+ # end
# 申诉成功 重新计算申诉者的匿评分
work = @student_work_score.student_work
@@ -1529,12 +1532,12 @@ class StudentWorkController < ApplicationController
end
#更新CourseHomeworkStatistics中学生的未交作品数、已交作品数、迟交作品数
- course_statistics = CourseHomeworkStatistics.find_by_course_id_and_user_id(@homework.course_id, params[:member_id][i].to_i)
- course_statistics.update_attribute('committed_work_num', course_statistics.committed_work_num + 1) if course_statistics
- course_statistics.update_attribute('un_commit_work_num', (course_statistics.un_commit_work_num - 1) < 0 ? 0 : (course_statistics.un_commit_work_num - 1)) if course_statistics
- if student_work.work_status == 2
- course_statistics.update_attribute('late_commit_work_num', course_statistics.late_commit_work_num + 1) if course_statistics
- end
+ # course_statistics = CourseHomeworkStatistics.find_by_course_id_and_user_id(@homework.course_id, params[:member_id][i].to_i)
+ # course_statistics.update_attribute('committed_work_num', course_statistics.committed_work_num + 1) if course_statistics
+ # course_statistics.update_attribute('un_commit_work_num', (course_statistics.un_commit_work_num - 1) < 0 ? 0 : (course_statistics.un_commit_work_num - 1)) if course_statistics
+ # if student_work.work_status == 2
+ # course_statistics.update_attribute('late_commit_work_num', course_statistics.late_commit_work_num + 1) if course_statistics
+ # end
end
end
@@ -1546,12 +1549,12 @@ class StudentWorkController < ApplicationController
sp.destroy
if work
#更新CourseHomeworkStatistics中学生的未交作品数、已交作品数、迟交作品数
- course_statistics = CourseHomeworkStatistics.find_by_course_id_and_user_id(@homework.course_id, work.user_id)
- if student_work.work_status == 2
- course_statistics.update_attribute('late_commit_work_num', (course_statistics.late_commit_work_num - 1) < 0 ? 0 : (course_statistics.late_commit_work_num - 1)) if course_statistics
- end
- course_statistics.update_attribute('committed_work_num', (course_statistics.committed_work_num - 1) < 0 ? 0 : (course_statistics.committed_work_num - 1)) if course_statistics
- course_statistics.update_attribute('un_commit_work_num', course_statistics.un_commit_work_num + 1) if course_statistics
+ # course_statistics = CourseHomeworkStatistics.find_by_course_id_and_user_id(@homework.course_id, work.user_id)
+ # if student_work.work_status == 2
+ # course_statistics.update_attribute('late_commit_work_num', (course_statistics.late_commit_work_num - 1) < 0 ? 0 : (course_statistics.late_commit_work_num - 1)) if course_statistics
+ # end
+ # course_statistics.update_attribute('committed_work_num', (course_statistics.committed_work_num - 1) < 0 ? 0 : (course_statistics.committed_work_num - 1)) if course_statistics
+ # course_statistics.update_attribute('un_commit_work_num', course_statistics.un_commit_work_num + 1) if course_statistics
work.destroy
end
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb
index 8ada7be35..3e5a0c0a3 100644
--- a/app/controllers/users_controller.rb
+++ b/app/controllers/users_controller.rb
@@ -820,7 +820,7 @@ class UsersController < ApplicationController
cs.send_wechat_join_class_notice apply_user,c,7,1
end
end
- redirect_to settings_course_path(@msg.course_id, :tab => 'member')
+ redirect_to members_course_path(@msg.course_id)
end
# 处理资源引用请求
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index 3ab45f124..c1ccda04a 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -201,7 +201,7 @@ module ApplicationHelper
# 实训语言的种类
def shixun_language
- ["Java", "C", "C++", "Python2.7", "Python3.6", "MySQL/Java", "Html", "JFinal", "Docker", "Ethereum", "Dynamips", "MachineLearning"]
+ ["Java", "C", "C++", "Python2.7", "Python3.6", "MySQL/Java", "Html", "JFinal", "Docker", "Ethereum", "Dynamips", "MachineLearning", "verilog"]
end
# 实训试用专业
@@ -3894,7 +3894,13 @@ module ApplicationHelper
link_to "开始实战(#{count})", shixun_path(homework.homework_commons_shixuns.shixun),:class => 'c_blue homepagePostSubmit',:target => "_blank"
else
myshixun = Myshixun.find work.myshixun_id
- link_to "继续实战(#{count})", myshixun_game_path(myshixun.current_task, :myshixun_id => myshixun), :class => "c_blue homepagePostSubmit",:target => "_blank" if myshixun
+ is_modify = ShixunModify.where(:myshixun_id => myshixun.try(:id), :shixun_id => myshixun.shixun.try(:id), :status => 1).first
+ if myshixun && is_modify.blank?
+ link_to "继续实战(#{count})", myshixun_game_path(myshixun.current_task, :myshixun_id => myshixun), :class => "c_blue homepagePostSubmit", :target => "_blank"
+ elsif myshixun
+ link_to "继续实战(#{count})", 'javascript:void(0);', :onclick => "sure_box_redirect('#{myshixun_reset_myshixun_path(myshixun)}', '实训已经更新啦,系统正在为您重置');", :class => "c_blue homepagePostSubmit"
+ end
+ #link_to "继续实战(#{count})", myshixun_game_path(myshixun.current_task, :myshixun_id => myshixun), :class => "c_blue homepagePostSubmit",:target => "_blank" if myshixun
end
elsif work.nil? && homework.end_time >= Time.now
if homework.homework_type ==3 && project.nil? && homework.homework_detail_group.base_on_project == 1
diff --git a/app/helpers/student_work_helper.rb b/app/helpers/student_work_helper.rb
index c90e7db2f..cf6b5b5d4 100644
--- a/app/helpers/student_work_helper.rb
+++ b/app/helpers/student_work_helper.rb
@@ -2,6 +2,15 @@
include UserScoreHelper
module StudentWorkHelper
+ def update_shixun_work_status homework
+ homework.student_works.where(:work_status => 0).each do |work|
+ myshixun = Myshixun.where(:shixun_id => homework.homework_commons_shixuns.shixun_id, :user_id => work.user_id).first
+ if myshixun
+ work.update_attributes(:work_status => myshixun.created_at <= homework.publish_time ? 1 : 2, :commit_time => myshixun.created_at, :myshixun_id => myshixun.id)
+ end
+ end
+ end
+
#获取当前用户的项目列表
def user_projects_option
projects = User.current.projects.visible
@@ -99,14 +108,14 @@ module StudentWorkHelper
project = cur_user_projects_for_homework homework
if work.nil? && homework.end_time >= Time.now
if homework.homework_type == 4
- link_to "关联实战", relate_myshixun_student_work_index_path(:homework => homework.id),:class => 'white-btn orange-btn fr mr10 mt8',:remote => true
+ #link_to "关联实战", relate_myshixun_student_work_index_path(:homework => homework.id),:class => 'white-btn orange-btn fr mr10 mt8',:remote => true
else
link_to "提交作品", new_student_work_url_without_domain(homework.id),:class => 'white-btn orange-btn fr mr10 mt8'
end
elsif work.nil? && homework.end_time < Time.now
if homework.allow_late && homework.homework_detail_manual.comment_status < 6
if homework.homework_type == 4
- link_to "关联实战", relate_myshixun_student_work_index_path(:homework => homework.id),:class => 'white-btn orange-btn fr mr10 mt8',:remote => true
+ #link_to "关联实战", relate_myshixun_student_work_index_path(:homework => homework.id),:class => 'white-btn orange-btn fr mr10 mt8',:remote => true
else
link_to "补交作品", new_student_work_url_without_domain(homework.id),:class => 'white-btn orange-btn fr mr10 mt8'
end
@@ -114,7 +123,12 @@ module StudentWorkHelper
elsif work
if homework.homework_type == 4
myshixun = Myshixun.find work.myshixun_id
- link_to "继续实战", myshixun_game_path(myshixun.current_task, :myshixun_id => myshixun), :class => "white-btn orange-btn fr mr10 mt8",:target => "_blank" if myshixun
+ is_modify = ShixunModify.where(:myshixun_id => myshixun.try(:id), :shixun_id => myshixun.shixun.try(:id), :status => 1).first
+ if myshixun && is_modify.blank?
+ link_to "继续实战", myshixun_game_path(myshixun.current_task, :myshixun_id => myshixun), :class => "white-btn orange-btn fr mr10 mt8", :target => "_blank"
+ elsif myshixun
+ link_to "继续实战", 'javascript:void(0);', :onclick => "sure_box_redirect('#{myshixun_reset_myshixun_path(myshixun)}', '实训已经更新啦,系统正在为您重置');", :class => "white-btn orange-btn fr mr10 mt8"
+ end
else
work_ids = "(" + homework.student_works.has_committed.map(&:id).join(",") + ")"
if homework.homework_detail_manual && homework.homework_detail_manual.comment_status == 3 && User.current.student_works_evaluation_distributions.where("student_work_id IN #{work_ids}").count > 0 #匿评作业,且作业状态不是在开启匿评之前
diff --git a/app/models/challenge.rb b/app/models/challenge.rb
index a9e74f77c..1e389f070 100644
--- a/app/models/challenge.rb
+++ b/app/models/challenge.rb
@@ -31,7 +31,7 @@ class Challenge < ActiveRecord::Base
def choose_correct_num
num = 0
self.challenge_chooses.each do |choose|
- outputs = ChooseOutputs.where(:challenge_choose_id => choose.id).first
+ outputs = ChooseOutputs.where(:challenge_choose_id => choose.id, :user_id => User.current.id).first
if outputs.nil?
num = nil
else
diff --git a/app/models/challenge_choose.rb b/app/models/challenge_choose.rb
index 18d76790f..c14a0c02d 100644
--- a/app/models/challenge_choose.rb
+++ b/app/models/challenge_choose.rb
@@ -10,4 +10,9 @@ class ChallengeChoose < ActiveRecord::Base
validates_presence_of :subject
+ # 判断当前用户是否答题
+ def current_choose_outputs
+ ChooseOutputs.where(:challenge_choose_id => self.id, :user_id => User.current.id).first
+ end
+
end
diff --git a/app/models/student_work.rb b/app/models/student_work.rb
index 8d5cad339..8bb374ffc 100644
--- a/app/models/student_work.rb
+++ b/app/models/student_work.rb
@@ -1,7 +1,7 @@
#学生提交作品表 #work_status :0 未提交 1 已提交 2 迟交 3 分组作品复制的组员作品
class StudentWork < ActiveRecord::Base
attr_accessible :name, :description, :homework_common_id, :user_id, :final_score, :teacher_score, :student_score, :teaching_asistant_score, :system_score, :work_score, :project_id, :is_test, :simi_id,
- :simi_value, :work_status, :commit_time, :late_penalty, :absence_penalty, :re_commit, :late_reason, :group_id
+ :simi_value, :work_status, :commit_time, :late_penalty, :absence_penalty, :re_commit, :late_reason, :group_id, :myshixun_id
belongs_to :homework_common
belongs_to :user
@@ -178,16 +178,16 @@ class StudentWork < ActiveRecord::Base
#更新course_homework_statistics中的avg_score和total_score
def update_avg_sum_score
- course_homework_statistics = CourseHomeworkStatistics.where(:user_id => self.user_id, :course_id => self.homework_common.course_id).first
- if course_homework_statistics
- course = self.homework_common.course
- homework_ids = course.homework_commons.empty? ? "(-1)" : "(" + course.homework_commons.map{|hw| hw.id}.join(",") + ")"
- student_works = StudentWork.where("homework_common_id in #{homework_ids} and work_status !=0")
- user = self.user
- average_score = user.student_works.where(:id => student_works.map(&:id)).select("AVG(student_works.work_score) as score").first ? user.student_works.where(:id => student_works.map(&:id)).select("AVG(student_works.work_score) as score").first.score : 0
- total_score = user.student_works.where(:id => student_works.map(&:id)).select("SUM(student_works.work_score) as score").first ? user.student_works.where(:id => student_works.map(&:id)).select("SUM(student_works.work_score) as score").first.score : 0
- course_homework_statistics.update_attributes(:average_score => average_score, :total_score => total_score)
- end
+ # course_homework_statistics = CourseHomeworkStatistics.where(:user_id => self.user_id, :course_id => self.homework_common.course_id).first
+ # if course_homework_statistics
+ # course = self.homework_common.course
+ # homework_ids = course.homework_commons.empty? ? "(-1)" : "(" + course.homework_commons.map{|hw| hw.id}.join(",") + ")"
+ # student_works = StudentWork.where("homework_common_id in #{homework_ids} and work_status !=0")
+ # user = self.user
+ # average_score = user.student_works.where(:id => student_works.map(&:id)).select("AVG(student_works.work_score) as score").first ? user.student_works.where(:id => student_works.map(&:id)).select("AVG(student_works.work_score) as score").first.score : 0
+ # total_score = user.student_works.where(:id => student_works.map(&:id)).select("SUM(student_works.work_score) as score").first ? user.student_works.where(:id => student_works.map(&:id)).select("SUM(student_works.work_score) as score").first.score : 0
+ # course_homework_statistics.update_attributes(:average_score => average_score, :total_score => total_score)
+ # end
end
# status == 0 : delay
diff --git a/app/models/students_for_course.rb b/app/models/students_for_course.rb
index 0bf062d1b..b501db674 100644
--- a/app/models/students_for_course.rb
+++ b/app/models/students_for_course.rb
@@ -39,11 +39,20 @@ class StudentsForCourse < ActiveRecord::Base
if str != ""
str += ","
end
- str += "('#{hw.name}的作品提交',#{hw.id},#{self.student_id}, '#{format_time(Time.now)}', '#{format_time(Time.now)}')"
+ if hw.homework_type == 4
+ myshixun = Myshixun.where(:shixun_id => hw.homework_commons_shixuns.shixun_id, :user_id => self.student_id).first
+ if myshixun
+ str += "('#{hw.name}的作品提交',#{hw.id},#{self.student_id}, 1, #{myshixun.id}, '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}', '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}', '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}')"
+ else
+ str += "('#{hw.name}的作品提交',#{hw.id},#{self.student_id}, 0, null, null, '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}', '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}')"
+ end
+ else
+ str += "('#{hw.name}的作品提交',#{hw.id},#{self.student_id}, 0, null, null, '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}', '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}')"
+ end
end
end
if str != ""
- sql = "insert into student_works (name, homework_common_id,user_id, created_at, updated_at) values" + str
+ sql = "insert into student_works (name, homework_common_id, user_id, work_status, myshixun_id, commit_time, created_at, updated_at) values" + str
ActiveRecord::Base.connection.execute sql
end
end
diff --git a/app/views/account/apply_trail.js.erb b/app/views/account/apply_trail.js.erb
index c7b789ae5..82cdc09cb 100644
--- a/app/views/account/apply_trail.js.erb
+++ b/app/views/account/apply_trail.js.erb
@@ -1 +1 @@
-$("body").append('<%= j( render :partial => 'welcome/one_btn_mask_pop', :locals => {:btn => "确定", :tip1 => "申请成功,我们将在一个工作日内完成审核", :url => "#{my_account_path()}"}) %>');
\ No newline at end of file
+$("body").append('<%= j( render :partial => 'welcome/one_btn_mask_pop', :locals => {:btn => "确定", :tip1 => @tip, :url => "#{my_account_path()}"}) %>');
\ No newline at end of file
diff --git a/app/views/challenges/_choose_type.html.erb b/app/views/challenges/_choose_type.html.erb
index 320e5ba9f..b1e6f8b02 100644
--- a/app/views/challenges/_choose_type.html.erb
+++ b/app/views/challenges/_choose_type.html.erb
@@ -41,15 +41,15 @@
<%#= render :partial => 'single_or_multiple_question_show'%>
\ No newline at end of file
diff --git a/app/views/challenges/choose_type_show.js.erb b/app/views/challenges/choose_type_show.js.erb
index 2934cbc53..402097644 100644
--- a/app/views/challenges/choose_type_show.js.erb
+++ b/app/views/challenges/choose_type_show.js.erb
@@ -1,6 +1,7 @@
$("#task_content").html("<%= j(render :partial => 'single_or_multiple_question_show')%>");
$("#challenge_choose_tab").html("<%= j(render :partial => "challenges/choose_tab") %>");
+/*
// JS局部刷新时,有可能加载不成功,需要重新加载一次(具体原因不明)
editormd.loadKaTeX(function() {
editormd.markdownToHTML("challenge_choose_subject_show", {
@@ -17,4 +18,4 @@ editormd.loadKaTeX(function() {
flowChart: true, // 默认不解析
sequenceDiagram: true // 默认不解析
})
-});
\ No newline at end of file
+});*/
diff --git a/app/views/challenges/edit.html.erb b/app/views/challenges/edit.html.erb
index 148133a98..342c17084 100644
--- a/app/views/challenges/edit.html.erb
+++ b/app/views/challenges/edit.html.erb
@@ -56,9 +56,9 @@
新建话题
+标题不能超过60个字符
+内容不能为空
++ + kosasa > 讨论 +
+ + +问吧
+ + 新话题 +1.练习口语 在线英语: http://dwz.cn/1XHGmL(免费在线口语课领取,外教一对一交流互动~) 特点:有正式课程挂网上公开,注册可免费听口语课,与外国老师实时交流哦~哈哈哈哈哈哈
++ 10 + 10 + 10 + + 最后更新:2小时前 +
+ + +1.练习口语 在线英语: http://dwz.cn/1XHGmL(免费在线口语课领取,外教一对一交流互动~) 特点:有正式课程挂网上公开,注册可免费听口语课,与外国老师实时交流哦~哈哈哈哈哈哈
++ 10 + 10 + 10 + + 最后更新:2小时前 +
+ + +1.练习口语 在线英语: http://dwz.cn/1XHGmL(免费在线口语课领取,外教一对一交流互动~) 特点:有正式课程挂网上公开,注册可免费听口语课,与外国老师实时交流哦~哈哈哈哈哈哈
++ 10 + 10 + 10 + + 最后更新:2小时前 +
+ + +<% if choose.category == 1 %> - name="answer[<%= index + 1 %>]" category="<%= choose.category %>" value="<%= (question.position + 65).chr %>" id="result_<%= index %>_<%= i %>" class="ml-3 mr5 magic-radio ml5"> + name="answer[<%= index + 1 %>]" category="<%= choose.category %>" value="<%= (question.position + 65).chr %>" id="result_<%= index %>_<%= i %>" class="ml-3 mr5 magic-radio ml5"> <% else %> - name="answer[]" category="<%= choose.category %>" value="<%= (question.position + 65).chr %>" id="result_<%= index %>_<%= i %>" class="ml-3 mr5 magic-checkbox ml5"> + name="answer[]" category="<%= choose.category %>" value="<%= (question.position + 65).chr %>" id="result_<%= index %>_<%= i %>" class="ml-3 mr5 magic-checkbox ml5"> <% end %> - +
<% end %> diff --git a/app/views/games/_code_actions.html.erb b/app/views/games/_code_actions.html.erb index 7ad488035..47f53c442 100644 --- a/app/views/games/_code_actions.html.erb +++ b/app/views/games/_code_actions.html.erb @@ -189,6 +189,7 @@ data.had_passed_testsests_hidden_count, data.had_passed_testsests_public_count, data.final_score, + data.gold, data.latest_output, data.language, data.compile_success @@ -204,7 +205,7 @@ console.log(data.tag_count); console.log($("#shixun_exp_<%=@game_challenge.id %>")[0]); $("#shixun_exp_<%=@game_challenge.id %>").html("经验值+"+ data.score + ""); - $("#shixun_grade_<%=@game_challenge.id %>").html("金币+"+ data.score + ""); + $("#shixun_grade_<%=@game_challenge.id %>").html("金币+"+ data.gold + ""); $("#shixun_tag_<%=@game_challenge.id %>").html("技能标签+"+ data.tag_count + ""); icon.find("i").attr("class", "fa fa-unlock fr font-18 mt5 color-light-green w20_center"); icon.find("a:last").attr("title", "已完成"); diff --git a/app/views/games/_game_choose_results.html.erb b/app/views/games/_game_choose_results.html.erb index fab1b9eeb..67afd3dc4 100644 --- a/app/views/games/_game_choose_results.html.erb +++ b/app/views/games/_game_choose_results.html.erb @@ -28,11 +28,12 @@ 题目<%= index + 1 %> <%# outputs = ChooseOutputs.where(:challenge_choose_id => choose.id).first %> - <% unless choose.choose_outputs.blank? %> - <% if choose.choose_outputs.try(:answer) != choose.standard_answer %> - - <% else %> + <% unless choose.current_choose_outputs.blank? %> + <%# if choose.choose_outputs.try(:answer) != choose.standard_answer %> + <% if choose.current_choose_outputs.try(:answer) == choose.standard_answer %> + <% else %> + <% end %> <% else %> @@ -44,7 +45,7 @@系统评分是根据学生的任务完成情况,按照百分比计算
例如实训任务5关,学生A完成3关,则最终成绩为 3 / 5 * 100 = 60分
- 注意:学生完成实训后,必须关联实训项目,否则成绩为零
系统评分是根据学生的任务完成情况,按照百分比计算
例如实训任务5关,学生A完成3关,则最终成绩为 3 / 5 * 100 = 60分
- 注意:学生完成实训后,必须关联实训项目,否则成绩为零
<%= link_to "加入班级", join_private_courses_courses_path, :remote => true, :method => "post", :class => 'color_white' %>
+<%= link_to "加入课堂", join_private_courses_courses_path, :remote => true, :method => "post", :class => 'color_white' %>
LOADING
+