diff --git a/Gemfile b/Gemfile index 660a7ff49..2b43cade3 100644 --- a/Gemfile +++ b/Gemfile @@ -26,6 +26,7 @@ gem 'spreadsheet' gem 'ruby-ole' gem 'rails_kindeditor',path:'lib/rails_kindeditor' #gem "rmagick", ">= 2.0.0" +gem 'binding_of_caller' group :development do gem 'grape-swagger' diff --git a/app/controllers/homework_common_controller.rb b/app/controllers/homework_common_controller.rb index c0685ea0a..8b37ca8e4 100644 --- a/app/controllers/homework_common_controller.rb +++ b/app/controllers/homework_common_controller.rb @@ -1,6 +1,8 @@ class HomeworkCommonController < ApplicationController + require 'net/http' + require 'json' layout "base_courses" - before_filter :find_course, :only => [:index,:new,:create] + 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 :member_of_course, :only => [:index] @@ -16,20 +18,37 @@ class HomeworkCommonController < ApplicationController end def new + respond_to do |format| + format.html + end + end + + #新建作业下一步 + def next_step + @homework_type = params[:homework_common_type] + @homework = HomeworkCommon.new @homework.safe_attributes = params[:homework_common] @homework.late_penalty = 0 @homework.end_time = (Time.now + 3600 * 24).strftime('%Y-%m-%d') @homework.publish_time = Time.now.strftime('%Y-%m-%d') - #匿评作业相关属性 - @homework_detail_manual = HomeworkDetailManual.new - @homework_detail_manual.ta_proportion = 0.6 - @homework_detail_manual.absence_penalty = 0 - @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 + if @homework_type == "1" + #匿评作业相关属性 + @homework_detail_manual = HomeworkDetailManual.new + @homework_detail_manual.ta_proportion = 0.6 + @homework_detail_manual.absence_penalty = 0 + @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 @@ -50,15 +69,57 @@ class HomeworkCommonController < ApplicationController homework.save_attachments(params[:attachments]) render_attachment_warning_if_needed(homework) - #匿评作业相关属性 - 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 + if homework.homework_type == 2 + homework_detail_programing = HomeworkDetailPrograming.new + homework_detail_programing.language = "C++" + homework_detail_programing.standard_code = params[:standard_code] + + question = {title:homework.name,content:homework.description} + question[:input] = [] + question[:output] = [] + if params[:input] && params[:output] + 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.homework_tests << homework_test + question[:input] << homework_test.input + question[:output] << homework_test.output + end + end + end + + # uri = URI('http://test.gitlab.trustie.net/api/questions.json') + # req = Net::HTTP::Post.new(uri, initheader = {'Content-Type' =>'application/json'}) + # req.body = question.to_json + # res = Net::HTTP.start(uri.hostname, uri.port) do |http| + # http.request(req) + # 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 respond_to do |format| @@ -98,10 +159,10 @@ class HomeworkCommonController < ApplicationController end @homework.late_penalty = params[:late_penalty] end - @homework.course_id = @course.id + # @homework.course_id = @course.id #匿评作业相关属性 - if @homework.homework_type == 1 + if @homework.homework_type == 1 && @homework_detail_manual @homework_detail_manual.ta_proportion = params[:ta_proportion] || 0.6 @homework_detail_manual.evaluation_start = params[:evaluation_start] @homework_detail_manual.evaluation_end = params[:evaluation_end] @@ -117,18 +178,49 @@ class HomeworkCommonController < ApplicationController end @homework_detail_manual.absence_penalty = params[:absence_penalty] end - else #不是匿评作业,缺评扣分为0分,每个作品的缺评扣分改为0分,防止某些作业在结束匿评之后改为普通作业 + elsif @homework.homework_type == 0 #普通作业,缺评扣分为0分,每个作品的缺评扣分改为0分,防止某些作业在结束匿评之后改为普通作业 @homework.student_works.where("absence_penalty != 0").each do |student_work| student_work.late_penalty = 0 student_work.save end - @homework_detail_manual.absence_penalty = 0 + @homework_detail_manual.absence_penalty = 0 if @homework_detail_manual + end + + if @homework.homework_type == 2 && @homework_detail_programing #编程作业 + @homework_detail_programing.language = "C++" + @homework_detail_programing.standard_code = params[:standard_code] + homework_tests = @homework.homework_tests + #需要删除的测试 + ids = homework_tests.map(&:id) - params[:input].keys.map(&:to_i) + ids.each do |id| + homework_test = HomeworkTest.find id + homework_test.destroy if homework_test + end + if params[:input] && params[:output] + params[:input].each do |k,v| + if params[:output].include? k + homework_test = HomeworkTest.find_by_id k + if homework_test #已存在的测试,修改 + homework_test.input = v + homework_test.output = params[:output][k] + else #不存在的测试,增加 + homework_test = HomeworkTest.new + homework_test.input = v + homework_test.output = params[:output][k] + homework_test.homework_common = @homework + end + homework_test.save + end + end + end end @homework.save_attachments(params[:attachments]) render_attachment_warning_if_needed(@homework) - if @homework.save && @homework_detail_manual.save + if @homework.save + @homework_detail_manual.save if @homework_detail_manual + @homework_detail_programing.save if @homework_detail_programing respond_to do |format| format.html { flash[:notice] = l(:notice_successful_edit) @@ -227,6 +319,7 @@ class HomeworkCommonController < ApplicationController def find_homework @homework = HomeworkCommon.find params[:id] @homework_detail_manual = @homework.homework_detail_manual + @homework_detail_programing = @homework.homework_detail_programing @course = @homework.course rescue render_404 diff --git a/app/controllers/poll_controller.rb b/app/controllers/poll_controller.rb index d8a9d88c3..758747e02 100644 --- a/app/controllers/poll_controller.rb +++ b/app/controllers/poll_controller.rb @@ -23,7 +23,7 @@ class PollController < ApplicationController def show @poll = Poll.find params[:id] - if @poll.polls_status != 2 && !User.current.allowed_to?(:as_teacher,@course) + if @poll.polls_status != 2 && (!User.current.allowed_to?(:as_teacher,@course) || User.current.admin?) render_403 return end @@ -393,7 +393,7 @@ class PollController < ApplicationController end def is_member_of_course - render_403 unless(@course && User.current.member_of_course?(@course)) + render_403 unless(@course && (User.current.member_of_course?(@course) || User.current.admin?)) end def is_course_teacher diff --git a/app/controllers/student_work_controller.rb b/app/controllers/student_work_controller.rb index cc858cc19..20cdc6659 100644 --- a/app/controllers/student_work_controller.rb +++ b/app/controllers/student_work_controller.rb @@ -2,47 +2,87 @@ class StudentWorkController < ApplicationController layout "base_courses" include StudentWorkHelper require 'bigdecimal' + require "base64" before_filter :find_homework, :only => [:new, :index, :create, :student_work_absence_penalty, :absence_penalty_list, :evaluation_list] before_filter :find_work, :only => [:edit, :update, :show, :destroy, :add_score, :praise_student_work] before_filter :member_of_course, :only => [:index, :new, :create, :show, :add_score, :praise_student_work] before_filter :author_of_work, :only => [:edit, :update, :destroy] before_filter :teacher_of_course, :only => [:student_work_absence_penalty, :absence_penalty_list, :evaluation_list] + protect_from_forgery :except => :set_program_score def index - @order,@b_sort,@name = params[:order] || "score",params[:sort] || "desc",params[:name] || "" + @order,@b_sort,@name,@group = params[:order] || "score",params[:sort] || "desc",params[:name] || "",params[:group] @is_teacher = User.current.allowed_to?(:as_teacher,@course) - #老师 || 非匿评作业 || 匿评结束 显示所有的作品 - @show_all = @is_teacher || @homework.homework_type != 1 || @homework.homework_detail_manual.comment_status == 3 || User.current.admin? - if @show_all - if @homework.homework_type == 1 || @is_teacher || User.current.admin? #超级管理员 || 老师 || 匿评结束 显示所有的作品 - if @order == "name" - @stundet_works = search_homework_member @homework.student_works.select("*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").joins(:user).order("users.lastname #{@b_sort}, users.firstname #{@b_sort}"),@name - else - @stundet_works = search_homework_member @homework.student_works.select("*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").order("#{@order} #{@b_sort}"),@name - end - else #剩余情况: 学生 && 非匿评作业 如果未提交作品,只能看到自己的,提交了作品,能看到所有作品 - my_work = @homework.student_works.select("*,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 + unless @group == "0" || @group.nil? + group_students = CourseGroup.find_by_id(@group).users + if group_students.empty? + student_in_group = '(0)' + else + student_in_group = '(' + group_students.map{|user| user.id}.join(',') + ')' + end + #老师 || 非匿评作业 || 匿评结束 显示所有的作品 + @show_all = @is_teacher || @homework.homework_type != 1 || @homework.homework_detail_manual.comment_status == 3 || User.current.admin? + if @show_all + if @homework.homework_type == 1 || @is_teacher || User.current.admin? #超级管理员 || 老师 || 匿评结束 显示所有的作品 if @order == "name" - @stundet_works = search_homework_member @homework.student_works.select("*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").joins(:user).order("users.lastname #{@b_sort}, users.firstname #{@b_sort}"),@name + @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("users.lastname #{@b_sort}, users.firstname #{@b_sort}"),@name else - @stundet_works = search_homework_member @homework.student_works.select("*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").order("#{@order} #{@b_sort}"),@name + @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 + end + else #剩余情况: 学生 && 非匿评作业 如果未提交作品,只能看到自己的,提交了作品,能看到所有作品 + 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 + if @order == "name" + @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("users.lastname #{@b_sort}, users.firstname #{@b_sort}"),@name + 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 + end end end + else #学生 + if @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 #匿评列表,显示匿评作品和我的作品 + @is_evaluation = true + 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} + end end - else #学生 - if @homework.homework_detail_manual.comment_status == 1 #未开启匿评,只显示我的作品 - @stundet_works = @homework.student_works.select("*,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 #匿评列表,显示匿评作品和我的作品 - @is_evaluation = true - 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} + else + #老师 || 非匿评作业 || 匿评结束 显示所有的作品 + @show_all = @is_teacher || @homework.homework_type != 1 || @homework.homework_detail_manual.comment_status == 3 || User.current.admin? + if @show_all + if @homework.homework_type == 1 || @is_teacher || User.current.admin? #超级管理员 || 老师 || 匿评结束 显示所有的作品 + if @order == "name" + @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).order("users.lastname #{@b_sort}, users.firstname #{@b_sort}"),@name + 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 + end + else #剩余情况: 学生 && 非匿评作业 如果未提交作品,只能看到自己的,提交了作品,能看到所有作品 + 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 + if @order == "name" + @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).order("users.lastname #{@b_sort}, users.firstname #{@b_sort}"),@name + 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 + end + end + end + else #学生 + if @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 #匿评列表,显示匿评作品和我的作品 + @is_evaluation = true + 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} + end end end @homework_commons = @course.homework_commons.order("created_at desc") - @homework_commons = @course.homework_commons.order("created_at desc") @score = @b_sort == "desc" ? "asc" : "desc" respond_to do |format| format.html @@ -80,7 +120,24 @@ class StudentWorkController < ApplicationController stundet_work.late_penalty = 0 end render_attachment_warning_if_needed(stundet_work) + if stundet_work.save + if @homework.homework_type == 2 && @homework.homework_detail_programing #编程作业,学生提交作品后计算系统得分 + url = "http://192.168.80.21:8080/api/questions/#{@homework.homework_detail_programing.question_id}/solutions.json" + solutions = { + student_work_id:stundet_work.id, + src:Base64.encode64(stundet_work.description), + language:1 + } + uri = URI(url) + body = solutions.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 + end respond_to do |format| format.html { flash[:notice] = l(:notice_successful_create) @@ -99,8 +156,12 @@ class StudentWorkController < ApplicationController end def edit - respond_to do |format| - format.html + if @homework.homework_type == 2 #编程作业不能修改作业 + render_403 + else + respond_to do |format| + format.html + end end end @@ -135,7 +196,9 @@ class StudentWorkController < ApplicationController end def destroy - if @work.destroy + if @homework.homework_type == 2 #编程作业,作品提交后不可以删除 + render_403 + elsif @work.destroy respond_to do |format| format.html { redirect_to student_work_index_url(:homework => @homework.id) @@ -154,6 +217,12 @@ class StudentWorkController < ApplicationController if @score @score.comment = params[:new_form][:user_message] if params[:new_form] && params[:new_form][:user_message] && params[:new_form][:user_message] != "" @score.score = params[:score] if params[:score] + if User.current.admin? + @score.reviewer_role = 1 + else + role = User.current.members.where("course_id = ?",@course.id).first.roles.first.name + @score.reviewer_role = get_role_by_name(role) + end @is_new = false else @score = StudentWorksScore.new @@ -161,8 +230,12 @@ class StudentWorkController < ApplicationController @score.comment = params[:new_form][:user_message] if params[:new_form] && params[:new_form][:user_message] && params[:new_form][:user_message] != "" @score.user_id = User.current.id @score.student_work_id = @work.id - role = User.current.members.where("course_id = ?",@course.id).first.roles.first.name - User.current.admin? ? @score.reviewer_role = 1 : @score.reviewer_role = get_role_by_name(role) + if User.current.admin? + @score.reviewer_role = 1 + else + role = User.current.members.where("course_id = ?",@course.id).first.roles.first.name + @score.reviewer_role = get_role_by_name(role) + end @is_new = true end @@ -180,8 +253,10 @@ class StudentWorkController < ApplicationController if @work.student_score.nil? @work.final_score = @work.teaching_asistant_score else - final_ta_score = BigDecimal.new("#{@work.teaching_asistant_score}") * BigDecimal.new("#{@homework.homework_detail_manual.ta_proportion}") - final_s_score = BigDecimal.new("#{@work.student_score}") * (BigDecimal.new('1.0') - BigDecimal.new("#{@homework.homework_detail_manual.ta_proportion}")) + ta_proportion = @homework.homework_detail_manual.ta_proportion if @homework.homework_detail_manual + ta_proportion = @homework.homework_detail_programing.ta_proportion if @homework.homework_detail_programing + final_ta_score = BigDecimal.new("#{@work.teaching_asistant_score}") * BigDecimal.new("#{ta_proportion}") + final_s_score = BigDecimal.new("#{@work.student_score}") * (BigDecimal.new('1.0') - BigDecimal.new("#{ta_proportion}")) final_score = final_ta_score + final_s_score @work.final_score = format("%.2f",final_score.to_f) end @@ -303,6 +378,45 @@ class StudentWorkController < ApplicationController end end + #设置编程作业得分 + def set_program_score + stundet_work = StudentWork.find_by_id params[:student_work_id] + @course = stundet_work.homework_common.course + student_score_count = 0 + if stundet_work && params[:results] && params[:results].class.to_s == "Array" + homework_common = stundet_work.homework_common + params[:results].each do |result| + homework_test = homework_common.homework_tests.where("input = '#{result[:input]}' AND output = '#{result[:output]}'").first + if homework_test + student_work_test = StudentWorkTest.new + student_work_test.student_work = stundet_work + student_work_test.homework_test = homework_test + student_work_test.result = result[:status] + if student_work_test.result == 0 + student_score_count += 1 + end + student_work_test.save! + end + end + unless homework_common.homework_tests.empty? + stundet_work.student_score = student_score_count * 100.0 / homework_common.homework_tests.count + + if stundet_work.teacher_score.nil? + if stundet_work.teaching_asistant_score.nil? + stundet_work.final_score = stundet_work.student_score + else + final_ta_score = BigDecimal.new("#{stundet_work.teaching_asistant_score}") * BigDecimal.new("#{homework_common.homework_detail_programing.ta_proportion}") + final_s_score = BigDecimal.new("#{stundet_work.student_score}") * (BigDecimal.new('1.0') - BigDecimal.new("#{homework_common.homework_detail_programing.ta_proportion}")) + final_score = final_ta_score + final_s_score + stundet_work.final_score = format("%.1f",final_score.to_f) + end + end + + stundet_work.save! + end + end + end + private #获取作业 def find_homework diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index a31bd6189..47a3b59ae 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -2292,6 +2292,8 @@ module ApplicationHelper else link = "启动匿评".html_safe end + elsif homework.homework_type == 2 && homework.homework_detail_programing #编程作业作业 + link = "编程作业".html_safe else link = "启动匿评".html_safe end @@ -2305,6 +2307,8 @@ module ApplicationHelper else if homework.homework_type == 1 && homework.homework_detail_manual && homework.homework_detail_manual.comment_status != 1 #匿评作业,且作业状态不是在开启匿评之前 "#{l(:label_edit_homework)}".html_safe + elsif homework.homework_type == 2 #编程作业不能修改作品 + "作品已交".html_safe else link_to l(:label_edit_homework), edit_student_work_path(work.id),:class => 'fr mr10 work_edit' end @@ -2324,7 +2328,7 @@ module ApplicationHelper elsif homework.homework_type == 0 "未启用匿评".html_safe elsif homework.homework_type == 2 - "编程作业".html_safe + " 编程作业  ".html_safe end end @@ -2339,4 +2343,8 @@ module ApplicationHelper end end + #将文本内的/n转换为
+ def text_format text + text.gsub("\n","
").html_safe + end end diff --git a/app/helpers/student_work_helper.rb b/app/helpers/student_work_helper.rb index f88b1ff21..f24d5078f 100644 --- a/app/helpers/student_work_helper.rb +++ b/app/helpers/student_work_helper.rb @@ -80,4 +80,22 @@ module StudentWorkHelper end color end + + #获取分班信息 + def course_group_list course + result = [] + if course.course_groups && !course.course_groups.empty? + base = [] + base << l(:label_chose_group) + base << 0 + result << base + course.course_groups.each do |group| + option = [] + option << group.name + option << group.id + result << option + end + end + result + end end \ No newline at end of file diff --git a/app/models/homework_test.rb b/app/models/homework_test.rb index f7d9b20bc..7c477bfaf 100644 --- a/app/models/homework_test.rb +++ b/app/models/homework_test.rb @@ -2,4 +2,5 @@ class HomeworkTest < ActiveRecord::Base attr_accessible :input, :output, :homework_common_id belongs_to :homework_common + has_one :student_work_test end diff --git a/app/models/student_work.rb b/app/models/student_work.rb index e2be18423..c80d1315b 100644 --- a/app/models/student_work.rb +++ b/app/models/student_work.rb @@ -7,6 +7,13 @@ class StudentWork < ActiveRecord::Base has_many :student_works_evaluation_distributions, :dependent => :destroy has_many :student_works_scores, :dependent => :destroy belongs_to :project + has_one :student_work_test + + before_destroy :delete_praise acts_as_attachable + + def delete_praise + PraiseTread.where("praise_tread_object_id = #{self.id} AND praise_tread_object_type = 'StudentWork'").destroy_all + end end diff --git a/app/models/student_work_test.rb b/app/models/student_work_test.rb new file mode 100644 index 000000000..d9ac5e935 --- /dev/null +++ b/app/models/student_work_test.rb @@ -0,0 +1,42 @@ +# encoding: utf-8 +class StudentWorkTest < ActiveRecord::Base + attr_accessible :student_work_id, :homework_test_id + + belongs_to :homework_test + belongs_to :student_work + + def status_to_s + case self.result + when -1 + '编译出错' + when -2 + '答题错误' + when -3 + '答案错误' + when 1 + '运行出错' + when 2 + '超时' + when 3 + '内存超出' + when 4 + '输出超出' + when 5 + '禁用函数' + when 6 + '其他错误' + when 0 + '成功' + else + '未知错误' + end + end + + def test_score + if self.result == 0 + format("%.1f",100.0 / self.student_work.homework_common.homework_tests.count) + else + 0 + end + end +end diff --git a/app/views/bids/new_contest.html.erb b/app/views/bids/new_contest.html.erb index 216816bd1..899aea1e7 100644 --- a/app/views/bids/new_contest.html.erb +++ b/app/views/bids/new_contest.html.erb @@ -1,10 +1,10 @@ - -

<%=l(:label_newtype_contest)%>

+ + -<%= labelled_form_for @bid, :url => {:controller => 'bids', :action => 'create_contest'} do |f| %> -
- <%= render :partial => 'form_contest', :locals => { :f => f } %> - <%= submit_tag l(:button_create) %> - <%= javascript_tag "$('#bid_name').focus();" %> - <% end %> -
\ No newline at end of file + + + + + + + \ No newline at end of file diff --git a/app/views/courses/_show_member_score.html.erb b/app/views/courses/_show_member_score.html.erb index bdc1fa147..2d08e853e 100644 --- a/app/views/courses/_show_member_score.html.erb +++ b/app/views/courses/_show_member_score.html.erb @@ -19,7 +19,7 @@
  • 作业名称得分
  • <% @member_score.homework_common_list.each do |homework_common| %>
  • - + <%= homework_common.name %> diff --git a/app/views/homework_common/_homework_common_form.html.erb b/app/views/homework_common/_homework_detail_manual_form.html.erb similarity index 97% rename from app/views/homework_common/_homework_common_form.html.erb rename to app/views/homework_common/_homework_detail_manual_form.html.erb index 4542be9f5..ffec93e73 100644 --- a/app/views/homework_common/_homework_common_form.html.erb +++ b/app/views/homework_common/_homework_detail_manual_form.html.erb @@ -10,7 +10,6 @@
  • -
    <% if edit_mode %> <%= f.kindeditor :description,:editor_id => 'homework_description_editor',:owner_id => homework.id,:owner_type =>OwnerTypeHelper::HOMEWORKCOMMON %> diff --git a/app/views/homework_common/_homework_detail_programing_form.html.erb b/app/views/homework_common/_homework_detail_programing_form.html.erb new file mode 100644 index 000000000..008f88138 --- /dev/null +++ b/app/views/homework_common/_homework_detail_programing_form.html.erb @@ -0,0 +1,125 @@ + + +
    +
    +

    编程评测设置

    +
    +
      +
    • + + +
      +
    • + +
    • + + <%= select_tag :ta_proportion,options_for_select(ta_proportion_option,homework.homework_detail_programing.ta_proportion), {:class => "fl mb10 h26 w70"} %> + × 教辅评分 +   +   + + × 系统评分 + = 学生得分 +
      +
    • +
    • + + 如果教师对学生作品进行了评分,则教师评分为学生最终得分。 +
      +
    • + +
    • + + +
      +
    • + + <% if edit_mode %> + <% homework.homework_tests.each do |homework_test|%> +
      +
    • + + +
    • +
    • + + +
    • +
    • + + + 测试 +
    • +
      +
      + <% end%> + <% else %> +
      +
    • + + +
    • +
    • + + +
    • +
    • + + + 测试 +
    • +
      +
      + <% end %> +
    +
    \ No newline at end of file diff --git a/app/views/homework_common/edit.html.erb b/app/views/homework_common/edit.html.erb index 50feca946..5b65b5982 100644 --- a/app/views/homework_common/edit.html.erb +++ b/app/views/homework_common/edit.html.erb @@ -7,10 +7,18 @@
    - <%= form_for @homework do |f| %> - <%= render :partial => 'homework_common/homework_common_form', :locals => { :homework => @homework,:f => f,:edit_mode => true } %> - 提交 - <%= link_to '取消',homework_common_index_path(:course => @course.id),:class => 'grey_btn fl'%> + <%if @homework.homework_type == 2%> + <%= form_for @homework do |f| %> + <%= render :partial => 'homework_common/homework_detail_programing_form', :locals => { :homework => @homework,:f => f,:edit_mode => true } %> + 提交 + <%= link_to '取消',homework_common_index_path(:course => @course.id),:class => 'grey_btn fl'%> + <% end%> + <% else %> + <%= form_for @homework do |f| %> + <%= render :partial => 'homework_common/homework_detail_manual_form', :locals => { :homework => @homework,:f => f,:edit_mode => true } %> + 提交 + <%= link_to '取消',homework_common_index_path(:course => @course.id),:class => 'grey_btn fl'%> + <% end%> <% end%>
    diff --git a/app/views/homework_common/new.html.erb b/app/views/homework_common/new.html.erb index dc67b5079..01fcb9f4d 100644 --- a/app/views/homework_common/new.html.erb +++ b/app/views/homework_common/new.html.erb @@ -1,17 +1,27 @@ -<%= javascript_include_tag "/assets/kindeditor/kindeditor",'/assets/kindeditor/pasteimg' %> -<%= error_messages_for 'homework_common' %> -

    <%= l(:label_course_homework_new)%>

    -
    - <%= labelled_form_for @homework,:url => {:controller => 'homework_common',:action => 'create'} do |f| %> - <%= hidden_field_tag "course",@course.id%> - <%= render :partial => 'homework_common/homework_common_form', :locals => { :homework => @homework,:f => f,:edit_mode => false } %> - 提交 - <%= link_to '取消',homework_common_index_path(:course => @course.id),:class => 'grey_btn fl'%> +
    + <%= form_for("new_homework_common",:url => next_step_homework_common_index_path) do |f|%> + +

    + 请选择将要发布的作业类型 +

    + + + 人工评分的作业(支持匿名互评、灵活设置评分比例) + +
    + + + 自动评测的编程作业(支持C++程序的自动评分) + +
    + + 下一步 + <% end%>
    diff --git a/app/views/homework_common/next_step.html.erb b/app/views/homework_common/next_step.html.erb new file mode 100644 index 000000000..75e9f4c0a --- /dev/null +++ b/app/views/homework_common/next_step.html.erb @@ -0,0 +1,30 @@ +<%= javascript_include_tag "/assets/kindeditor/kindeditor" %> +<%= error_messages_for 'homework_common' %> +
    +

    + <%= l(:label_course_homework_new)%> +

    +
    +<% if @homework_type == "1"%> +
    + <%= labelled_form_for @homework,:url => {:controller => 'homework_common',:action => 'create'} do |f| %> + <%= hidden_field_tag "course",@course.id%> + <%= render :partial => 'homework_common/homework_detail_manual_form', :locals => { :homework => @homework,:f => f,:edit_mode => false } %> + 提交 + <%= link_to "上一步", new_homework_common_path(:course => @course.id), :class => "orange_btn_homework fl"%> + <%= link_to '取消',homework_common_index_path(:course => @course.id),:class => 'grey_btn fl'%> + <% end%> +
    +<% elsif @homework_type == "2"%> +
    + <%= labelled_form_for @homework,:url => {:controller => 'homework_common',:action => 'create'} do |f| %> + <%= hidden_field_tag "course",@course.id%> + <%= hidden_field_tag "homework_common[homework_type]","2"%> + <%= render :partial => 'homework_common/homework_detail_programing_form', :locals => { :homework => @homework,:f => f,:edit_mode => false } %> + 提交 + <%= link_to "上一步", new_homework_common_path(:course => @course.id), :class => "orange_btn_homework fl"%> + <%= link_to '取消',homework_common_index_path(:course => @course.id),:class => 'grey_btn fl'%> + <% end%> +
    +
    +<% end%> \ No newline at end of file diff --git a/app/views/layouts/_base_header.html.erb b/app/views/layouts/_base_header.html.erb index b800a1722..16fa44c73 100644 --- a/app/views/layouts/_base_header.html.erb +++ b/app/views/layouts/_base_header.html.erb @@ -101,10 +101,7 @@ addSlipMenu(); addProjectSlipMenu (); addCourseSlipMenu(); - }); - - jQuery(document).ready(function($) { - $('.sub_menu').find("a").attr('target', '_blank'); + $('.sub_menu').find("a").attr('target', '_blank'); $('.project_sub_menu').find("a").attr('target', '_blank'); $('.course_sub_menu').find("a").attr('target', '_blank'); }); diff --git a/app/views/student_work/_evaluation_student_work.html.erb b/app/views/student_work/_evaluation_student_work.html.erb index 0f66452c7..b5bdd6f55 100644 --- a/app/views/student_work/_evaluation_student_work.html.erb +++ b/app/views/student_work/_evaluation_student_work.html.erb @@ -9,7 +9,7 @@ <%= link_to student_work.user.show_name,user_path(student_work.user),:title => student_work.user.show_name, :class => "c_blue02"%>
  • - <%= link_to student_work.name, student_work_path(student_work),:remote => true,:title => student_work.name, :class => "c_blue02"%> + <%= link_to student_work.name, student_work_path(student_work.id),:remote => true,:title => student_work.name, :class => "c_blue02"%>
  • <% if Time.parse(@homework.end_time.to_s).strftime("%Y-%m-%d") < Time.parse(student_work.created_at.to_s).strftime("%Y-%m-%d") %> @@ -26,7 +26,7 @@
  • <%= student_work.student_score.nil? ? "--" : format("%.1f",student_work.student_score)%> - <% unless student_work.student_score.nil?%> + <% unless student_work.student_score.nil? || student_work.homework_common.homework_type == 2%> (<%= student_work.student_works_scores.where(:reviewer_role => 3).count%>) diff --git a/app/views/student_work/_evaluation_student_work_title.html.erb b/app/views/student_work/_evaluation_student_work_title.html.erb index 0e4151065..f19438f78 100644 --- a/app/views/student_work/_evaluation_student_work_title.html.erb +++ b/app/views/student_work/_evaluation_student_work_title.html.erb @@ -2,42 +2,46 @@ 学号
  • - <%= link_to "姓名",@show_all ? student_work_index_path(:homework => @homework.id,:order => "name", :sort => @score, :name => @name) : "javascript:void(0)",:class => "f14 f_b c_dark fl"%> + <%= link_to "姓名",@show_all ? student_work_index_path(:homework => @homework.id,:order => "name", :sort => @score, :name => @name, :group => @group) : "javascript:void(0)",:class => "f14 f_b c_dark fl"%> <% if @show_all && @order == "name"%> - + <%= link_to "",student_work_index_path(:homework => @homework.id,:order => "name", :sort => @score, :name => @name, :group => @group) ,:class => @score == 'desc' ? 'st_up' : 'st_down'%> <% end%>
  • 作品名称
  • - <%= link_to "时间",@show_all ? student_work_index_path(:homework => @homework.id,:order => "created_at", :sort => @score, :name => @name) : "javascript:void(0)",:class => "f14 f_b c_dark fl"%> + <%= link_to "时间",@show_all ? student_work_index_path(:homework => @homework.id,:order => "created_at", :sort => @score, :name => @name, :group => @group) : "javascript:void(0)",:class => "f14 f_b c_dark fl"%> <% if @show_all && @order == "created_at"%> - <%= link_to "",student_work_index_path(:homework => @homework.id,:order => "created_at", :sort => @score, :name => @name) ,:class => @score == 'desc' ? 'st_up' : 'st_down'%> + <%= link_to "",student_work_index_path(:homework => @homework.id,:order => "created_at", :sort => @score, :name => @name, :group => @group) ,:class => @score == 'desc' ? 'st_up' : 'st_down'%> <% end%>
  • - <%= link_to "教师",@show_all ? student_work_index_path(:homework => @homework.id,:order => "teacher_score", :sort => @score, :name => @name) : "javascript:void(0)",:class => "f14 f_b c_dark fl"%> + <%= link_to "教师",@show_all ? student_work_index_path(:homework => @homework.id,:order => "teacher_score", :sort => @score, :name => @name, :group => @group) : "javascript:void(0)",:class => "f14 f_b c_dark fl"%> <% if @show_all && @order == "teacher_score"%> - <%= link_to "", student_work_index_path(:homework => @homework.id,:order => "teacher_score", :sort => @score, :name => @name) ,:class => @score == 'desc' ? 'st_up' : 'st_down'%> + <%= link_to "", student_work_index_path(:homework => @homework.id,:order => "teacher_score", :sort => @score, :name => @name, :group => @group) ,:class => @score == 'desc' ? 'st_up' : 'st_down'%> <% end%>
  • - <%= link_to "教辅",@show_all ? student_work_index_path(:homework => @homework.id,:order => "teaching_asistant_score", :sort => @score, :name => @name) : "javascript:void(0)",:class => "f14 f_b c_dark fl"%> + <%= link_to "教辅",@show_all ? student_work_index_path(:homework => @homework.id,:order => "teaching_asistant_score", :sort => @score, :name => @name, :group => @group) : "javascript:void(0)",:class => "f14 f_b c_dark fl"%> <% if @show_all && @order == "teaching_asistant_score"%> - <%= link_to "", student_work_index_path(:homework => @homework.id,:order => "teaching_asistant_score", :sort => @score, :name => @name) ,:class => @score == 'desc' ? 'st_up' : 'st_down'%> + <%= link_to "", student_work_index_path(:homework => @homework.id,:order => "teaching_asistant_score", :sort => @score, :name => @name, :group => @group) ,:class => @score == 'desc' ? 'st_up' : 'st_down'%> <% end%>
  • -
  • - <%= link_to "匿评",@show_all ? student_work_index_path(:homework => @homework.id,:order => "student_score", :sort => @score, :name => @name) : "javascript:void(0)",:class => "f14 f_b c_dark fl"%> +
  • + <% if @homework.homework_type == 1%> + <%= link_to "匿评",@show_all ? student_work_index_path(:homework => @homework.id,:order => "student_score", :sort => @score, :name => @name, :group => @group) : "javascript:void(0)",:class => "f14 f_b c_dark fl"%> + <% elsif @homework.homework_type == 2%> + <%= link_to "系统",@show_all ? student_work_index_path(:homework => @homework.id,:order => "student_score", :sort => @score, :name => @name, :group => @group) : "javascript:void(0)",:class => "f14 f_b c_dark fl"%> + <% end %> <% if @show_all && @order == "student_score"%> - <%= link_to "", student_work_index_path(:homework => @homework.id,:order => "student_score", :sort => @score, :name => @name) ,:class => @score == 'desc' ? 'st_up' : 'st_down'%> + <%= link_to "", student_work_index_path(:homework => @homework.id,:order => "student_score", :sort => @score, :name => @name, :group => @group) ,:class => @score == 'desc' ? 'st_up' : 'st_down'%> <% end%>
  • - <%= link_to "成绩",@show_all ? student_work_index_path(:homework => @homework.id,:order => "score", :sort => @score, :name => @name) : "javascript:void(0)",:class => "f14 f_b c_dark fl"%> + <%= link_to "成绩",@show_all ? student_work_index_path(:homework => @homework.id,:order => "score", :sort => @score, :name => @name, :group => @group) : "javascript:void(0)",:class => "f14 f_b c_dark fl"%> <% if @show_all && @order == "score"%> - <%= link_to "", student_work_index_path(:homework => @homework.id,:order => "score", :sort => @score, :name => @name) ,:class => @score == 'desc' ? 'st_up' : 'st_down'%> + <%= link_to "", student_work_index_path(:homework => @homework.id,:order => "score", :sort => @score, :name => @name, :group => @group) ,:class => @score == 'desc' ? 'st_up' : 'st_down'%> <% end%>
  • \ No newline at end of file diff --git a/app/views/student_work/_programing_work_show.html.erb b/app/views/student_work/_programing_work_show.html.erb new file mode 100644 index 000000000..8060b8a79 --- /dev/null +++ b/app/views/student_work/_programing_work_show.html.erb @@ -0,0 +1,75 @@ +
    +
    + + +
    + <%@work.student_works_scores.order("updated_at desc").each do |score|%> +
    + <%= render :partial => 'student_work_score',:locals => {:score => score}%> +
    + <% end%> +
    + 收起 +
    \ No newline at end of file diff --git a/app/views/student_work/_show.html.erb b/app/views/student_work/_show.html.erb index dfe61d3db..2b7d49402 100644 --- a/app/views/student_work/_show.html.erb +++ b/app/views/student_work/_show.html.erb @@ -36,7 +36,7 @@
  • 内容:
    - <%= textilizable @work.description%> + <%= text_format @work.description%>
  • diff --git a/app/views/student_work/_student_work_title.html.erb b/app/views/student_work/_student_work_title.html.erb index c46f7dc79..24e6a1b37 100644 --- a/app/views/student_work/_student_work_title.html.erb +++ b/app/views/student_work/_student_work_title.html.erb @@ -2,36 +2,36 @@ 学号
  • - <%= link_to "姓名",@show_all ? student_work_index_path(:homework => @homework.id,:order => "name", :sort => @score, :name => @name) : "javascript:void(0)",:class => "f14 f_b c_dark fl"%> + <%= link_to "姓名",@show_all ? student_work_index_path(:homework => @homework.id,:order => "name", :sort => @score, :name => @name, :group => @group) : "javascript:void(0)",:class => "f14 f_b c_dark fl"%> <% if @show_all && @order == "name"%> - + <%= link_to "",student_work_index_path(:homework => @homework.id,:order => "name", :sort => @score, :name => @name, :group => @group) ,:class => @score == 'desc' ? 'st_up' : 'st_down'%> <% end%>
  • 作品名称
  • - <%= link_to "时间",@show_all ? student_work_index_path(:homework => @homework.id,:order => "created_at", :sort => @score, :name => @name) : "javascript:void(0)",:class => "f14 f_b c_dark fl"%> + <%= link_to "时间",@show_all ? student_work_index_path(:homework => @homework.id,:order => "created_at", :sort => @score, :name => @name, :group => @group) : "javascript:void(0)",:class => "f14 f_b c_dark fl"%> <% if @show_all && @order == "created_at"%> - <%= link_to "",student_work_index_path(:homework => @homework.id,:order => "created_at", :sort => @score, :name => @name) ,:class => @score == 'desc' ? 'st_up' : 'st_down'%> + <%= link_to "",student_work_index_path(:homework => @homework.id,:order => "created_at", :sort => @score, :name => @name, :group => @group) ,:class => @score == 'desc' ? 'st_up' : 'st_down'%> <% end%>
  • - <%= link_to "教师",@show_all ? student_work_index_path(:homework => @homework.id,:order => "teacher_score", :sort => @score, :name => @name) : "javascript:void(0)",:class => "f14 f_b c_dark fl"%> + <%= link_to "教师",@show_all ? student_work_index_path(:homework => @homework.id,:order => "teacher_score", :sort => @score, :name => @name, :group => @group) : "javascript:void(0)",:class => "f14 f_b c_dark fl"%> <% if @show_all && @order == "teacher_score"%> - <%= link_to "", student_work_index_path(:homework => @homework.id,:order => "teacher_score", :sort => @score, :name => @name) ,:class => @score == 'desc' ? 'st_up' : 'st_down'%> + <%= link_to "", student_work_index_path(:homework => @homework.id,:order => "teacher_score", :sort => @score, :name => @name, :group => @group) ,:class => @score == 'desc' ? 'st_up' : 'st_down'%> <% end%>
  • - <%= link_to "教辅",@show_all ? student_work_index_path(:homework => @homework.id,:order => "teaching_asistant_score", :sort => @score, :name => @name) : "javascript:void(0)",:class => "f14 f_b c_dark fl"%> + <%= link_to "教辅",@show_all ? student_work_index_path(:homework => @homework.id,:order => "teaching_asistant_score", :sort => @score, :name => @name, :group => @group) : "javascript:void(0)",:class => "f14 f_b c_dark fl"%> <% if @show_all && @order == "teaching_asistant_score"%> - <%= link_to "", student_work_index_path(:homework => @homework.id,:order => "teaching_asistant_score", :sort => @score, :name => @name) ,:class => @score == 'desc' ? 'st_up' : 'st_down'%> + <%= link_to "", student_work_index_path(:homework => @homework.id,:order => "teaching_asistant_score", :sort => @score, :name => @name, :group => @group) ,:class => @score == 'desc' ? 'st_up' : 'st_down'%> <% end%>
  • - <%= link_to "成绩",@show_all ? student_work_index_path(:homework => @homework.id,:order => "score", :sort => @score, :name => @name) : "javascript:void(0)",:class => "f14 f_b c_dark fl"%> + <%= link_to "成绩",@show_all ? student_work_index_path(:homework => @homework.id,:order => "score", :sort => @score, :name => @name, :group => @group) : "javascript:void(0)",:class => "f14 f_b c_dark fl"%> <% if @show_all && @order == "score"%> - <%= link_to "", student_work_index_path(:homework => @homework.id,:order => "score", :sort => @score, :name => @name) ,:class => @score == 'desc' ? 'st_up' : 'st_down'%> + <%= link_to "", student_work_index_path(:homework => @homework.id,:order => "score", :sort => @score, :name => @name, :group => @group) ,:class => @score == 'desc' ? 'st_up' : 'st_down'%> <% end%>
  • \ No newline at end of file diff --git a/app/views/student_work/add_score.js.erb b/app/views/student_work/add_score.js.erb index 9298de8fc..1de92b51a 100644 --- a/app/views/student_work/add_score.js.erb +++ b/app/views/student_work/add_score.js.erb @@ -2,20 +2,23 @@ $("#add_student_score_<%= @work.id%>").html("<%= escape_javascript(render :parti $('#score_<%= @work.id%>').peSlider({range: 'min'}); <% if @is_new%> -$("#score_list_<%= @work.id%>").prepend("
    <%= escape_javascript(render :partial => 'student_work_score', :locals => {:score => @score}) %>
    "); + $("#score_list_<%= @work.id%>").prepend("
    <%= escape_javascript(render :partial => 'student_work_score', :locals => {:score => @score}) %>
    "); <% else %> -$("#work_score_<%= @score.id%>").html("<%= escape_javascript(render :partial => 'student_work_score', :locals => {:score => @score}) %>"); + $("#work_score_<%= @score.id%>").html("<%= escape_javascript(render :partial => 'student_work_score', :locals => {:score => @score}) %>"); <% end%> + $("#score_list_<%= @work.id%>").removeAttr("style"); <% if @is_teacher %> -<% if @homework.homework_type == 1%> -$("#student_work_<%= @work.id%>").replaceWith("<%= escape_javascript(render :partial => 'evaluation_student_work',:locals => {:student_work => @work}) %>"); -<% else%> -$("#student_work_<%= @work.id%>").replaceWith("<%= escape_javascript(render :partial => 'student_work',:locals => {:student_work => @work}) %>"); -<% end%> + <% if @homework.homework_type == 1%> + $("#student_work_<%= @work.id%>").replaceWith("<%= escape_javascript(render :partial => 'evaluation_student_work',:locals => {:student_work => @work}) %>"); + <% elsif @homework.homework_type == 2%> + $("#student_work_<%= @work.id%>").replaceWith("<%= escape_javascript(render :partial => 'evaluation_student_work',:locals => {:student_work => @work}) %>"); + <% else%> + $("#student_work_<%= @work.id%>").replaceWith("<%= escape_javascript(render :partial => 'student_work',:locals => {:student_work => @work}) %>"); + <% end%> <% else %> -$("#student_work_<%= @work.id%>").replaceWith("<%= escape_javascript(render :partial => 'evaluation_work',:locals => {:student_work => @work}) %>"); + $("#student_work_<%= @work.id%>").replaceWith("<%= escape_javascript(render :partial => 'evaluation_work',:locals => {:student_work => @work}) %>"); <% end%> diff --git a/app/views/student_work/edit.html.erb b/app/views/student_work/edit.html.erb index dfa995f47..6e36447d2 100644 --- a/app/views/student_work/edit.html.erb +++ b/app/views/student_work/edit.html.erb @@ -2,14 +2,6 @@

    编辑作品

    - - - - - - - -
    <%= labelled_form_for @work,:html => { :multipart => true } do |f|%> diff --git a/app/views/student_work/index.html.erb b/app/views/student_work/index.html.erb index 76ae71459..b9148a88f 100644 --- a/app/views/student_work/index.html.erb +++ b/app/views/student_work/index.html.erb @@ -48,8 +48,9 @@ <%= link_to "所有作品(#{@stundet_works.count})".html_safe,student_work_index_path(:homework => @homework.id), :class => "fl"%> <% if @show_all%> - - 搜索 + + <%= select_tag(:late_penalty,options_for_select(course_group_list(@course),@group), {:class => "fl h22 w100 ml10"}) if @is_teacher %> + 搜索 <%= link_to("缺评情况",student_work_absence_penalty_student_work_index_path(:homework => @homework.id), :class => "student_work_search fl", :target => "_blank") if((@is_teacher || User.current.admin?) && @homework.homework_type == 1) %> <% end%> <% if @is_teacher%> @@ -89,7 +90,7 @@
    <% end%> <% else %> - <% if @homework.homework_type == 1%> + <% if @homework.homework_type == 1 || @homework.homework_type == 2%>
      <%= render :partial => 'evaluation_student_work_title'%>
    diff --git a/app/views/student_work/new.html.erb b/app/views/student_work/new.html.erb index b4162c4da..eda09114e 100644 --- a/app/views/student_work/new.html.erb +++ b/app/views/student_work/new.html.erb @@ -33,9 +33,12 @@

    <%= f.text_field "name", :required => true, :size => 60, :class => "bo fl", :maxlength => 200, :placeholder => "作品名称", :onkeyup => "regexStudentWorkName();" %> - 项目信息 - - + <% if @homework.homework_type != 2%> + + 项目信息 + + + <% end%>

    @@ -46,17 +49,23 @@

    - - <%= f.text_area "description", :class => "w620 hwork_txt ", :maxlength => 3000, :placeholder => "最多3000个汉字", :onkeyup => "regexStudentWorkDescription();"%> + + <%= f.text_area "description", :class => "w620 hwork_txt ", :placeholder => "作品描述不能为空", :onkeyup => "regexStudentWorkDescription();"%>

    -

    - - <%= render :partial => 'attachments/new_form' %> -

    -
    + <% if @homework.homework_type != 2%> +

    + + <%= render :partial => 'attachments/new_form' %> +

    +
    + <% end%>

    提交作品 <%= link_to "返  回".html_safe, student_work_index_path(:homework => @homework), :class => "blue_btn grey_btn fl c_white"%> diff --git a/app/views/student_work/set_program_score.html.erb b/app/views/student_work/set_program_score.html.erb new file mode 100644 index 000000000..6ea169c64 --- /dev/null +++ b/app/views/student_work/set_program_score.html.erb @@ -0,0 +1 @@ +成功 \ No newline at end of file diff --git a/app/views/student_work/show.js.erb b/app/views/student_work/show.js.erb index fa12e097d..1c8874c2f 100644 --- a/app/views/student_work/show.js.erb +++ b/app/views/student_work/show.js.erb @@ -2,6 +2,10 @@ if($("#about_hwork_<%= @work.id%>").children().length > 0) {$("#about_hwork_<%= @work.id%>").html("");} else { - $("#about_hwork_<%= @work.id%>").html("<%= escape_javascript(render :partial => 'show') %>"); + <% if @homework.homework_type == 2%> + $("#about_hwork_<%= @work.id%>").html("<%= escape_javascript(render :partial => 'programing_work_show') %>"); + <% else%> + $("#about_hwork_<%= @work.id%>").html("<%= escape_javascript(render :partial => 'show') %>"); + <% end%> $('#score_<%= @work.id%>').peSlider({range: 'min'}); } \ No newline at end of file diff --git a/config/locales/zh.yml b/config/locales/zh.yml index ac8ab40a9..2dd5bcf9a 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -2026,6 +2026,7 @@ zh: label_file_lost_list: 缺失文件列表 lable_unset: 未设置 + label_chose_group: 请选择分班 diff --git a/config/routes.rb b/config/routes.rb index 0132b8fc6..0d47d2f57 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -85,7 +85,7 @@ RedmineApp::Application.routes.draw do get 'alert_anonymous_comment' end collection do - + post 'next_step' end end @@ -100,6 +100,7 @@ RedmineApp::Application.routes.draw do get 'student_work_absence_penalty' get 'absence_penalty_list' get 'evaluation_list' + post 'set_program_score' end end diff --git a/db/migrate/20150708025533_add_proportion_to_programing.rb b/db/migrate/20150708025533_add_proportion_to_programing.rb new file mode 100644 index 000000000..b3da59c25 --- /dev/null +++ b/db/migrate/20150708025533_add_proportion_to_programing.rb @@ -0,0 +1,9 @@ +class AddProportionToPrograming < ActiveRecord::Migration + def up + add_column :homework_detail_programings, :ta_proportion, :float, :default => 0.1 + end + + def down + remove_column :homework_detail_programings, :ta_proportion + end +end diff --git a/db/migrate/20150708085629_change_studen_work_desc.rb b/db/migrate/20150708085629_change_studen_work_desc.rb new file mode 100644 index 000000000..af3c25671 --- /dev/null +++ b/db/migrate/20150708085629_change_studen_work_desc.rb @@ -0,0 +1,9 @@ +class ChangeStudenWorkDesc < ActiveRecord::Migration + def up + change_column :student_works,:description,:text,:limit => 4294967295 + end + + def down + change_column :student_works,:description,:text + end +end diff --git a/db/migrate/20150709071731_add_question_id_to_homework.rb b/db/migrate/20150709071731_add_question_id_to_homework.rb new file mode 100644 index 000000000..d1be59431 --- /dev/null +++ b/db/migrate/20150709071731_add_question_id_to_homework.rb @@ -0,0 +1,9 @@ +class AddQuestionIdToHomework < ActiveRecord::Migration + def up + add_column :homework_detail_programings, :question_id, :integer + end + + def down + remove_column :homework_detail_programings, :question_id + end +end diff --git a/db/migrate/20150715070534_create_test_result.rb b/db/migrate/20150715070534_create_test_result.rb new file mode 100644 index 000000000..4816fbcb8 --- /dev/null +++ b/db/migrate/20150715070534_create_test_result.rb @@ -0,0 +1,14 @@ +class CreateTestResult < ActiveRecord::Migration + def up + create_table :student_work_tests do |t| + t.integer :student_work_id + t.integer :homework_test_id + t.integer :result + t.timestamps + end + end + + def down + drop_table :student_work_tests + end +end diff --git a/db/schema.rb b/db/schema.rb index 78dfb5eee..383545cf6 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20150702073308) do +ActiveRecord::Schema.define(:version => 20150715070534) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false @@ -586,8 +586,10 @@ ActiveRecord::Schema.define(:version => 20150702073308) do t.string "language" t.text "standard_code", :limit => 2147483647 t.integer "homework_common_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.float "ta_proportion", :default => 0.1 + t.integer "question_id" end create_table "homework_evaluations", :force => true do |t| @@ -721,16 +723,6 @@ ActiveRecord::Schema.define(:version => 20150702073308) do add_index "journal_details", ["journal_id"], :name => "journal_details_journal_id" - create_table "journal_details_copy", :force => true do |t| - t.integer "journal_id", :default => 0, :null => false - t.string "property", :limit => 30, :default => "", :null => false - t.string "prop_key", :limit => 30, :default => "", :null => false - t.text "old_value" - t.text "value" - end - - add_index "journal_details_copy", ["journal_id"], :name => "journal_details_journal_id" - create_table "journal_replies", :id => false, :force => true do |t| t.integer "journal_id" t.integer "user_id" @@ -1229,20 +1221,28 @@ ActiveRecord::Schema.define(:version => 20150702073308) do t.integer "project_id" end + create_table "student_work_tests", :force => true do |t| + t.integer "student_work_id" + t.integer "homework_test_id" + t.integer "result" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + create_table "student_works", :force => true do |t| t.string "name" - t.text "description" + t.text "description", :limit => 2147483647 t.integer "homework_common_id" t.integer "user_id" t.float "final_score" t.float "teacher_score" t.float "student_score" t.float "teaching_asistant_score" - t.integer "project_id", :default => 0 - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.integer "late_penalty", :default => 0 - t.integer "absence_penalty", :default => 0 + t.integer "project_id", :default => 0 + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.integer "late_penalty", :default => 0 + t.integer "absence_penalty", :default => 0 end create_table "student_works_evaluation_distributions", :force => true do |t| diff --git a/public/javascripts/course.js b/public/javascripts/course.js index c8e3b533e..db1f761f2 100644 --- a/public/javascripts/course.js +++ b/public/javascripts/course.js @@ -394,6 +394,7 @@ function show_bid_dead_line(year,month,day,divname) + "" + "

    作品提交还剩:

    "); } + //验证新建作业的名字 function regex_homework_name() { @@ -414,6 +415,7 @@ function regex_homework_name() //验证匿评数量 function regex_evaluation_num() { + if($("#evaluation_num").length == 0){ return true;} var evaluation_num = $.trim($("#evaluation_num").val()); var regex = /^\d+$/; if(evaluation_num=="") @@ -471,15 +473,18 @@ $(function(){ }); //第一次加载时,如果未开启匿评作业,隐藏显示匿评配置信息 $(function(){ - if($("#homework_common_homework_type").attr("checked") == "checked") + if($("#homework_common_homework_type").attr("id") != null && $("#homework_common_homework_type").val() != 2) { - $("#evaluation_setting").show(); - $("#ta_proportion").removeAttr("disabled"); - } - else - { - $("#evaluation_setting").hide(); - $("#ta_proportion").attr("disabled","disabled"); + if($("#homework_common_homework_type").attr("checked") == "checked") + { + $("#evaluation_setting").show(); + $("#ta_proportion").removeAttr("disabled"); + } + else + { + $("#evaluation_setting").hide(); + $("#ta_proportion").attr("disabled","disabled"); + } } }); @@ -501,6 +506,25 @@ function submit_homework(id) } } +//增加测试结果 +function add_programing_test(obj) { + var now = new Date().getTime(); + obj.after("
  • " + + "
  • " + + "
  • " + + "" + + "测试
  • "); +} +//删除测试结果 +function remove_programing_test(obj) { + if(obj.siblings("div").length == 0){ + alert("至少需要一组测试"); + } + else{ + obj.remove(); + } +} + function show_window (id1,id2,top,left) { $('#'+ id1).css('top',top); $('#'+ id1).css('left',left); @@ -837,14 +861,14 @@ function clickOK(path) }); } //查询 -function SearchByName(obj,url,event) +function SearchByName(name,group,url,event) { var keycode = (event.keyCode ? event.keyCode : event.which); if(keycode == '13'){ - location.href = url + "&name=" + obj.val(); + location.href = url + "&name=" + name + "&group=" + group; } } -function SearchByName_1(obj,url) +function SearchByName_1(name,group,url) { - location.href = url + "&name=" + obj.val(); + location.href = url + "&name=" + name + "&group=" + group; } diff --git a/public/javascripts/header.js b/public/javascripts/header.js index e27f758d3..06748d726 100644 --- a/public/javascripts/header.js +++ b/public/javascripts/header.js @@ -1,11 +1,15 @@ function addSlipMenu () { - var loggedas = $('#current_user_li:first'); + var loggedas = $('#current_user_li a:first'); var sub_menu = $('#user_sub_menu'); - loggedas.mouseenter(function(event) { + loggedas.mouseenter(function() { sub_menu.show(); + $('#my_projects_ul').hide(); + $('#my_courses_ul').hide(); }); - sub_menu.mouseleave(function(event) { + sub_menu.mouseleave(function() { sub_menu.hide(); + $('#my_projects_ul').hide(); + $('#my_courses_ul').hide(); }); } @@ -13,24 +17,26 @@ function addProjectSlipMenu () { var loggedas = $('#my_projects_li'); var project_sub_menu = $('#my_projects_ul'); var course_sub_menu = $('#my_courses_ul'); - loggedas.mouseenter(function(event) { + loggedas.mouseenter(function() { course_sub_menu.hide(); project_sub_menu.show(); }); - loggedas.mouseleave(function(event) { + loggedas.mouseleave(function() { project_sub_menu.hide(); + course_sub_menu.hide(); }); } function addCourseSlipMenu () { var loggedas = $('#my_courses_li'); var project_sub_menu = $('#my_projects_ul'); var course_sub_menu = $('#my_courses_ul'); - loggedas.mouseenter(function(event) { + loggedas.mouseenter(function() { project_sub_menu.hide(); course_sub_menu.show(); }); - loggedas.mouseleave(function(event) { + loggedas.mouseleave(function() { course_sub_menu.hide(); + project_sub_menu.hide(); }); } diff --git a/public/stylesheets/courses.css b/public/stylesheets/courses.css index 41514ab12..abeec52d3 100644 --- a/public/stylesheets/courses.css +++ b/public/stylesheets/courses.css @@ -30,6 +30,10 @@ a:hover.news_foot{ color:#787b7e; border:1px solid #d4d4d4;} .box_h3{ color:#15bccf; text-align:center; font-size:16px;} .box_p{ color:#404040; margin-bottom:5px;} .fb_item{ color:#919191; border:1px solid #919191; height:28px; margin-bottom:10px; padding-left:5px; width:290px;} +a.icon_addm{ background:url(../images/img_floatbox.png) 0 -33px no-repeat; width:16px; height:16px; display:block; margin:5px 0 0 5px;} +a:hover.icon_addm{background:url(../images/img_floatbox.png) 0 -61px no-repeat; } +a.icon_removem{ background:url(../images/img_floatbox.png) -22px -33px no-repeat;width:16px; height:16px; display:block; margin:5px 0 0 5px} +a:hover.icon_removem{background:url(../images/img_floatbox.png) -22px -61px no-repeat;} a.btn_free{ background:#ff5722; display:block; width:80px; text-align:center; color:#fff; height:26px; padding-top:3px; margin-bottom:10px;} a:hover.btn_free{ background:#d63502;} /*成员邀请*/ @@ -338,7 +342,6 @@ a:hover.st_add{ color:#ff8e15;} .upbtn{ margin:40px 0 0 15px; display:block; padding:2px 5px; border:1px solid #eaeaea;} .upbtn:hover{border:1px solid #64bdd9; color:#64bdd9;cursor: pointer;} .upload_file{margin-left: -60px;margin-top: 40px;width: 50px;position: absolute;height: 24px;opacity: 0;cursor: pointer} - /* 功能倒计时*/ .w_img{ float:left; margin:10px 10px 15px 0px;} .w_p{ float:left; color:#15bccf; font-size:16px; font-weight:bold; margin-top:70px; } @@ -349,7 +352,9 @@ a:hover.st_add{ color:#ff8e15;} .upload_con h2{ display:block; background:#eaeaea; font-size:14px; color:#343333; height:31px; width: auto; margin-top:25px; padding-left:20px; padding-top:5px;} .upload_box{ width:430px; margin:15px auto;} +a.link_file{ background:url(../images/pic_file.png) 0 2px no-repeat; padding-left:20px; } a:hover.link_file{ background:url(../images/pic_file.png) 0 -25px no-repeat; color:#3ca5c6;} +.r_txt_tit{width:510px; overflow:hidden; white-space: nowrap; text-overflow:ellipsis;color:#15bccf; float:left; color:#09658c; font-size:14px;} blockquote {background: #eeeeee;padding: 10px;margin-bottom: 10px;word-break: break-all;word-wrap: break-word;} .respond-form{display: none;margin: auto;clear: both;} @@ -561,8 +566,8 @@ a.files_tag_select{ background:#64bdd9; color:#fff; border:1px solid #64bdd9; pa .hwork_new_left{ width:220px; float:left; } .hwork_new_right{ width:350px; float:left; margin-left:40px;} .w305{ width:305px;} -.icon_add{ background:url(images/icons.png) 0px -310px no-repeat; width:16px; height:27px; display:block;float:left; margin-right:5px;} -a:hover.icon_add{background:url(images/icons.png) -20px -310px no-repeat;} +.icon_add{ background:url(../stylesheets/images/icons.png) 0px -310px no-repeat; width:16px; height:27px; display:block;float:left; margin-right:5px;} +a:hover.icon_add{background:url(../stylesheets/images/icons.png) -20px -310px no-repeat;} /* 20150505讨论区*/ .w664{ width:664px;} @@ -598,10 +603,12 @@ a:hover.Reply_pic{border:1px solid #64bdd9;} /*.talk_new{ border-bottom:1px dashed #d9d9d9; padding-bottom:10px;}*/ #about_newtalk{ display:none;} +/* 20150423作业评分*/ .ml14{ margin-left:14px;} .w548{ width:552px;} .w547{ width:544px;} .w196{ width:196px;} +.w186{ width:186px;} .w459{ width:459px;} .hwork_new_set{border:1px dashed #CCC; background:#f5f5f5; text-align:center; padding:10px 0; margin-bottom:10px;} .hwork_new_grey{background:#dbdbdb; width:610px; padding:10px 20px; margin:0 auto; text-align:left; margin-bottom:5px;} @@ -610,6 +617,8 @@ a:hover.Reply_pic{border:1px solid #64bdd9;} .w305{ width:305px;} .icon_add{background:url(images/icons.png) 0px -310px no-repeat; width:16px; height:27px; display:block;float:left; margin-right:5px;} a:hover.icon_add{background:url(images/icons.png) -20px -310px no-repeat;} +.icon_remove{background:url(images/icons.png) 0px -338px no-repeat; width:16px; height:27px; display:block;float:left;} +a:hover.icon_remove{background:url(images/icons.png) -20px -338px no-repeat;} /* 20150506上传头像*/ .uppicBox{ width:265px; height:265px; background:#f2f2f5; float:left; color:#666; text-align:center;} @@ -656,6 +665,7 @@ a:hover.ping_pic{border:1px solid #64bdd9;} a.down_btn{ border:1px solid #CCC; color:#999; padding:0px 5px; font-size:12px; text-align:center; display:block;} a:hover.down_btn{ background:#14ad5a; color:#fff; border:1px solid #14ad5a;} .fr{ float:right;} +.min_search{ width:140px; height:20px; border:1px solid #d0d0d0; color:#666; background:url(../images/public_icon.png) 185px -193px no-repeat; } .li_min_search{ float:right; margin-right:-10px;} .info_ni_download{ width:100px; padding:5px;position: absolute;display:none;-moz-border-radius:3px; -webkit-border-radius:3px; border-radius:3px; box-shadow:0px 0px 5px #194a81; color:#666; background:#fff; text-align:left;margin-left: 200px;margin-top: 10px;} .info_ni{ width:100px; padding:5px;position: absolute;display:none;-moz-border-radius:3px; -webkit-border-radius:3px; border-radius:3px; box-shadow:0px 0px 5px #194a81; color:#666; background:#fff; text-align:left;margin-left: 50px;margin-top: -5px;} @@ -674,6 +684,12 @@ input#score{ width:40px;} .ui-slider .ui-slider-handle:hover,.ui-slider .ui-slider-handle:focus{background:#64bdd9;} .ui-slider .ui-slider-handle:active{background-image:none;} .ui-slider .ui-slider-range{position:absolute;z-index:1;font-size:.7em;display:block;border:0;top:0;height:100%;background:#64bdd9;left:0;} +/* 编程作品 */ +.border_ce{ border:1px solid #e4e4e4; } +.border_ce tr td{ height:26px; } +.td_tit{width:155px; text-align:center;} +.td_50{width:50px; text-align:center;} +a.work_list_tit{width:610px; display:block; overflow:hidden; white-space: nowrap; text-overflow:ellipsis;} .filename { background: url(../images/pic_file.png) 0 -25px no-repeat;color: #3ca5c6;max-width: 150px;border: none; padding-left: 20px;margin-right: 10px;margin-bottom: 5px; white-space: nowrap; text-overflow:ellipsis;} .evaluation{position: relative;} diff --git a/public/stylesheets/public.css b/public/stylesheets/public.css index 27792347a..8e16c9436 100644 --- a/public/stylesheets/public.css +++ b/public/stylesheets/public.css @@ -79,6 +79,7 @@ h4{ font-size:14px; color:#3b3b3b;} .mr50{margin-right: 50px;} .mr55{margin-right: 55px;} .mr70{margin-right: 70px;} +.mt1{margin-top: 1px;} .mt3{ margin-top:3px;} .mt5{ margin-top:5px;} .mt8{ margin-top:8px;} @@ -109,6 +110,7 @@ h4{ font-size:14px; color:#3b3b3b;} .w350{ width:350px;} .w610{ width:610px;} .w600{ width:600px;} +.h20{height: 20px;} .h22{ height:22px;} .h26{ height:26px;} .h50{ height:50px;} @@ -166,6 +168,7 @@ a.green_btn{background:#28be6c;color:#fff;font-size:14px; font-weight:normal; pa a:hover.green_btn{ background:#14ad5a;} .blue_btn{ background:#64bdd9; color:#fff; font-size:14px; font-weight:normal;padding:2px 10px; text-align:center;} a.blue_btn{background:#64bdd9;color:#fff;font-size:14px; font-weight:normal; padding:2px 10px; text-align:center;} +a.orange_btn_homework{background:#d63502;color:#fff;font-size:14px; font-weight:normal; padding:2px 10px; text-align:center;} a:hover.blue_btn{ background:#329cbd;cursor: pointer;} a.orange_btn{ background:#ff5722;color:#fff;font-size:14px; font-weight:normal; padding:2px 10px; text-align:center; } a:hover.orange_btn{ background:#d63502;}