diff --git a/app/controllers/homework_common_controller.rb b/app/controllers/homework_common_controller.rb index 9d5768948..00d814bd3 100644 --- a/app/controllers/homework_common_controller.rb +++ b/app/controllers/homework_common_controller.rb @@ -5,9 +5,9 @@ class HomeworkCommonController < ApplicationController layout "base_courses" include StudentWorkHelper - before_filter :find_course, :only => [:index,:new,:create,:next_step] - before_filter :find_homework, :only => [:edit,:update,:alert_anonymous_comment,:start_anonymous_comment,:stop_anonymous_comment,:destroy] - before_filter :teacher_of_course, :only => [:new, :create, :edit, :update, :destroy, :start_anonymous_comment, :stop_anonymous_comment, :alert_anonymous_comment] + before_filter :find_course, :only => [:index,:new,:create] + before_filter :find_homework, :only => [:edit,:update,:alert_anonymous_comment,:start_anonymous_comment,:stop_anonymous_comment,:destroy,:start_evaluation_set,:set_evaluation_attr] + before_filter :teacher_of_course, :only => [:new, :create, :edit, :update, :destroy, :start_anonymous_comment, :stop_anonymous_comment, :alert_anonymous_comment,:start_evaluation_set,:set_evaluation_attr] before_filter :member_of_course, :only => [:index] def index @@ -23,116 +23,11 @@ class HomeworkCommonController < ApplicationController #新建作业,在个人作业列表创建作业 def new render_404 - # @homework_type = "1" - # - # @homework = HomeworkCommon.new - # @homework.safe_attributes = params[:homework_common] - # @homework.late_penalty = 2 - # @homework.end_time = (Time.now + 3600 * 24).strftime('%Y-%m-%d') - # @homework.publish_time = Time.now.strftime('%Y-%m-%d') - # - # if @homework_type == "1" - # #匿评作业相关属性 - # @homework_detail_manual = HomeworkDetailManual.new - # @homework_detail_manual.ta_proportion = 0.6 - # @homework_detail_manual.absence_penalty = 2 - # @homework_detail_manual.evaluation_num = 3 - # @homework_detail_manual.evaluation_start = Time.now.strftime('%Y-%m-%d') - # @homework_detail_manual.evaluation_end = (Time.now + 3600 * 24).strftime('%Y-%m-%d') - # @homework.homework_detail_manual = @homework_detail_manual - # elsif @homework_type == "2" - # #编程作业相关属性 - # @homework_detail_programing = HomeworkDetailPrograming.new - # @homework.homework_detail_programing = @homework_detail_programing - # end - # respond_to do |format| - # format.html - # end end #新建作业,在个人作业列表创建作业 def create redirect_to user_homeworks_user_path(User.current.id) - # if params[:homework_common] - # homework = HomeworkCommon.new - # homework.name = params[:homework_common][:name] - # homework.description = params[:homework_common][:description] - # homework.end_time = params[:homework_common][:end_time] - # homework.publish_time = params[:homework_common][:publish_time] - # homework.homework_type = params[:homework_common][:homework_type] - # homework.late_penalty = params[:late_penalty] - # homework.user_id = User.current.id - # homework.course_id = @course.id - # - # homework.save_attachments(params[:attachments]) - # render_attachment_warning_if_needed(homework) - # - # if homework.homework_type == 2 - # homework_detail_programing = HomeworkDetailPrograming.new - # homework_detail_programing.language = params[:language] - # homework_detail_programing.standard_code = params[:standard_code] - # homework_detail_programing.ta_proportion = params[:ta_proportion] || 0.6 - # question = {title:homework.name,content:homework.description} - # question[:input] = [] - # question[:output] = [] - # if params[:input] && params[:output] && params[:result] - # params[:input].each do |k,v| - # if params[:output].include? k - # homework_test = HomeworkTest.new - # homework_test.input = v - # homework_test.output = params[:output][k] - # homework_test.result = params[:result][k] - # homework_test.error_msg = params[:error_msg] - # homework.homework_tests << homework_test - # question[:input] << homework_test.input - # question[:output] << homework_test.output - # end - # end - # end - # - # # uri = URI('http://192.168.80.21:8080/api/questions.json') - # # body = question.to_json - # # res = Net::HTTP.new(uri.host, uri.port).start do |client| - # # request = Net::HTTP::Post.new(uri.path) - # # request.body = body - # # request["Content-Type"] = "application/json" - # # client.request(request) - # # end - # # result = JSON.parse(res.body) - # # homework_detail_programing.question_id = result["id"] if result["status"] && result["status"] == 0 - # - # homework.homework_detail_programing = homework_detail_programing - # else - # #匿评作业相关属性 - # homework_detail_manual = HomeworkDetailManual.new - # homework_detail_manual.ta_proportion = params[:ta_proportion] || 0.6 - # homework_detail_manual.comment_status = 1 - # homework_detail_manual.evaluation_start = params[:evaluation_start] - # homework_detail_manual.evaluation_end = params[:evaluation_end] - # homework_detail_manual.evaluation_num = params[:evaluation_num] - # homework_detail_manual.absence_penalty = params[:absence_penalty] - # homework.homework_detail_manual = homework_detail_manual - # end - # - # if homework.save - # homework_detail_programing.save if homework_detail_programing - # homework_detail_manual.save if homework_detail_manual - # respond_to do |format| - # format.html { - # flash[:notice] = l(:notice_successful_create) - # redirect_to homework_common_index_path(:course => @course.id) - # } - # end - # return - # end - # end - # - # respond_to do |format| - # format.html { - # flash[:notice] = l(:notice_failed_create) - # redirect_to new_homework_common_path(:course => @course.id) - # } - # end end def edit @@ -150,6 +45,10 @@ class HomeworkCommonController < ApplicationController @homework.end_time = params[:homework_common][:end_time] || Time.now @homework.course_id = params[:course_id] + homework_detail_manual = @homework.homework_detail_manual || HomeworkDetailManual.new + homework_detail_manual.evaluation_start = params[:evaluation_start].blank? ? @homework.end_time + 7 : params[:evaluation_start] + homework_detail_manual.evaluation_end = params[:evaluation_end].blank? ? homework_detail_manual.evaluation_start + 7 : params[:evaluation_end] + @homework.save_attachments(params[:attachments]) render_attachment_warning_if_needed(@homework) @@ -290,6 +189,27 @@ class HomeworkCommonController < ApplicationController end end + #启动匿评参数设置 + def start_evaluation_set + + end + + #设置匿评参数 + def set_evaluation_attr + if @homework_detail_manual + unless params[:evaluation_start].to_s == @homework_detail_manual.evaluation_start.to_s + @homework_detail_manual.evaluation_start = params[:evaluation_start] + end + + unless @homework_detail_manual.evaluation_end.to_s == params[:evaluation_end].to_s + @homework_detail_manual.evaluation_end = params[:evaluation_end] + end + + @homework_detail_manual.evaluation_num = params[:evaluation_num] + @homework_detail_manual.save + end + end + private #获取课程 def find_course diff --git a/app/controllers/student_work_controller.rb b/app/controllers/student_work_controller.rb index 251fd80c4..90a0f3ed6 100644 --- a/app/controllers/student_work_controller.rb +++ b/app/controllers/student_work_controller.rb @@ -77,28 +77,60 @@ class StudentWorkController < ApplicationController @is_teacher = User.current.allowed_to?(:as_teacher,@course) || User.current.admin? @is_evaluation = @homework.homework_detail_manual.comment_status == 2 && !@is_teacher #是不是匿评 @show_all = false - if @is_teacher #老师 || 超级管理员 显示所有列表 - @stundet_works = search_homework_member @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").order("#{@order} #{@b_sort}"),@name - @show_all = true - elsif @homework.homework_detail_manual.comment_status == 1 #学生 && 未开启匿评 只看到自己的 - @stundet_works = @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where(:user_id => User.current.id) - elsif @homework.homework_detail_manual.comment_status == 2 #学生 && 开启匿评 看到匿评列表 - my_work = @homework.student_works.where(:user_id => User.current.id) - @stundet_works = my_work + User.current.student_works_evaluation_distributions.map(&:student_work).select { |work| work.homework_common_id == @homework.id} - elsif @homework.homework_detail_manual.comment_status == 3 #学生 && 关闭匿评 未提交作品之前列表为空,提交了作品看到所有的 - my_work = @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where(:user_id => User.current.id) - if my_work.empty? - @stundet_works = [] + + course_group = CourseGroup.find_by_id(@group) if @group + if course_group + group_students = course_group.users + if group_students.empty? + student_in_group = '(0)' else - @stundet_works = search_homework_member @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").order("#{@order} #{@b_sort}"),@name + student_in_group = '(' + group_students.map{|user| user.id}.join(',') + ')' + end + if @is_teacher #老师 || 超级管理员 显示所有列表 + @stundet_works = search_homework_member @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").joins(:user).where("users.id in #{student_in_group}").order("#{@order} #{@b_sort}"),@name @show_all = true + elsif @homework.homework_detail_manual.comment_status == 1 #学生 && 未开启匿评 只看到自己的 + @stundet_works = @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where(:user_id => User.current.id) + elsif @homework.homework_detail_manual.comment_status == 2 #学生 && 开启匿评 看到匿评列表 + my_work = @homework.student_works.where(:user_id => User.current.id) + @stundet_works = my_work + User.current.student_works_evaluation_distributions.map(&:student_work).select { |work| work.homework_common_id == @homework.id} + elsif @homework.homework_detail_manual.comment_status == 3 #学生 && 关闭匿评 未提交作品之前列表为空,提交了作品看到所有的 + my_work = @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where(:user_id => User.current.id) + if my_work.empty? + @stundet_works = [] + else + @stundet_works = search_homework_member @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").joins(:user).where("users.id in #{student_in_group}").order("#{@order} #{@b_sort}"),@name + @show_all = true + end + else + @stundet_works = [] end else - @stundet_works = [] + if @is_teacher #老师 || 超级管理员 显示所有列表 + @stundet_works = search_homework_member @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").order("#{@order} #{@b_sort}"),@name + @show_all = true + elsif @homework.homework_detail_manual.comment_status == 1 #学生 && 未开启匿评 只看到自己的 + @stundet_works = @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where(:user_id => User.current.id) + elsif @homework.homework_detail_manual.comment_status == 2 #学生 && 开启匿评 看到匿评列表 + my_work = @homework.student_works.where(:user_id => User.current.id) + @stundet_works = my_work + User.current.student_works_evaluation_distributions.map(&:student_work).select { |work| work.homework_common_id == @homework.id} + elsif @homework.homework_detail_manual.comment_status == 3 #学生 && 关闭匿评 未提交作品之前列表为空,提交了作品看到所有的 + my_work = @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where(:user_id => User.current.id) + if my_work.empty? + @stundet_works = [] + else + @stundet_works = search_homework_member @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").order("#{@order} #{@b_sort}"),@name + @show_all = true + end + else + @stundet_works = [] + end end + @score = @b_sort == "desc" ? "asc" : "desc" respond_to do |format| + format.js format.html format.xls { send_data(homework_to_xls(@stundet_works), :type => "text/excel;charset=utf-8; header=present", diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 874f9c607..35860c728 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -480,8 +480,8 @@ class UsersController < ApplicationController homework_detail_manual = HomeworkDetailManual.new homework_detail_manual.ta_proportion = homework.homework_type == 1 ? 0.6 : 0.3 homework_detail_manual.comment_status = 1 - homework_detail_manual.evaluation_start = Time.now - homework_detail_manual.evaluation_end = Time.now + homework_detail_manual.evaluation_start = params[:evaluation_start].blank? ? homework.end_time + 7 : params[:evaluation_start] + homework_detail_manual.evaluation_end = params[:evaluation_end].blank? ? homework_detail_manual.evaluation_start + 7 : params[:evaluation_end] homework_detail_manual.evaluation_num = params[:evaluation_num] || 3 homework_detail_manual.absence_penalty = 5 homework.homework_detail_manual = homework_detail_manual diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index d7fac9a7d..e100a8fc9 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -2306,7 +2306,7 @@ module ApplicationHelper when 2 link = link_to '关闭匿评', alert_anonymous_comment_homework_common_path(homework), id: "#{homework.id}_stop_anonymous_comment", remote: true,:class => 'postOptionLink' when 3 - link = link_to "匿评结束","javascript:void(0)", :class => "postOptionLink", :title => "匿评结束" + # link = link_to "匿评结束","javascript:void(0)", :class => "postOptionLink", :title => "匿评结束" end else link = link_to "启动匿评","javascript:void(0)", :class => "postOptionLink", :title => "学生提交作业数大于2时才可以启动匿评" diff --git a/app/models/student_work_test.rb b/app/models/student_work_test.rb index 1cfb7f8b2..0246ecabf 100644 --- a/app/models/student_work_test.rb +++ b/app/models/student_work_test.rb @@ -45,7 +45,7 @@ class StudentWorkTest < ActiveRecord::Base private def get_success_count self.results.inject(0) do |sum, result| - sum += (result["status"].to_i == 0 ? 1 : 0) + sum += (result["status"] && result["status"].to_i == 0 ? 1 : 0) end || 0 end diff --git a/app/views/boards/_course_show.html.erb b/app/views/boards/_course_show.html.erb index f117acd7f..db174f30e 100644 --- a/app/views/boards/_course_show.html.erb +++ b/app/views/boards/_course_show.html.erb @@ -99,7 +99,7 @@ // } }); -
基本规则设置(总分为100分)
- -学生互评设置
- -每个学生将收到 3 份待匿评作品
- -学生漏评1个作品将扣 <%= homework.homework_detail_manual.absence_penalty%> 分
- -编程评测设置
- -- 错误信息: - | -- <% if homework.homework_tests.first && homework.homework_tests.first && homework.homework_tests.first.error_msg %> - <%= homework.homework_tests.first.error_msg%> - <% end%> - | -
状态 :
+ +<%= @issue.status.name %>
+指派给 :
+ <%= @issue.assigned_to ? link_to_isuue_user(@issue.assigned_to) : "--" %> +优先级 :
+ <%= @issue.priority.name %> +% 完成 :
+ <%= @issue.done_ratio %>% +开始 :
+ +<%= format_date(@issue.start_date) %>
+周期 :
+ <%= l_hours(@issue.estimated_hours) %> +计划完成 :
+ <%= format_date(@issue.due_date) ? format_date(@issue.due_date) : "--" %> +目标版本 :
+ <%= (@issue.fixed_version ? link_to_version(@issue.fixed_version, :class => "pro_info_p") : "--") %> +