commit
032bd86367
@ -0,0 +1,300 @@
|
||||
class StudentWorkController < ApplicationController
|
||||
layout "base_courses"
|
||||
include StudentWorkHelper
|
||||
require 'bigdecimal'
|
||||
before_filter :find_homework, :only => [:new, :index, :create]
|
||||
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]
|
||||
|
||||
def index
|
||||
@order,@b_sort,@name = params[:order] || "final_score",params[:sort] || "desc",params[:name] || ""
|
||||
@is_teacher = User.current.allowed_to?(:as_teacher,@course)
|
||||
#老师 || 非匿评作业 || 匿评结束 显示所有的作品
|
||||
@show_all = @is_teacher || @homework.homework_type != 1 || @homework.homework_detail_manual.comment_status == 3
|
||||
if @show_all
|
||||
if @homework.homework_type == 1 || @is_teacher || User.current.admin?
|
||||
@stundet_works = search_homework_member @homework.student_works.order("#{@order} #{@b_sort}"),@name
|
||||
else
|
||||
my_work = @homework.student_works.where(:user_id => User.current.id)
|
||||
if my_work.empty?
|
||||
@stundet_works = []
|
||||
else
|
||||
@stundet_works = search_homework_member @homework.student_works.order("#{@order} #{@b_sort}"),@name
|
||||
end
|
||||
end
|
||||
else #学生
|
||||
if @homework.homework_detail_manual.comment_status == 1 #未开启匿评,只显示我的作品
|
||||
@stundet_works = @homework.student_works.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
|
||||
@homework_commons = @course.homework_commons.order("created_at desc")
|
||||
@score = @b_sort == "desc" ? "asc" : "desc"
|
||||
respond_to do |format|
|
||||
format.html
|
||||
format.xls {
|
||||
send_data(homework_to_xls(@stundet_works), :type => "text/excel;charset=utf-8; header=present",
|
||||
:filename => "#{@course.teacher.lastname.to_s + @course.teacher.firstname}_#{@course.name}_#{@course.time.to_s + @course.term}_#{@homework.name}#{l(:excel_homework_list)}.xls")
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
def new
|
||||
student_work = @homework.student_works.where("user_id = ?",User.current.id).first
|
||||
if student_work.nil?
|
||||
@stundet_work = StudentWork.new
|
||||
respond_to do |format|
|
||||
format.html
|
||||
end
|
||||
else
|
||||
render_403
|
||||
end
|
||||
end
|
||||
|
||||
def create
|
||||
if params[:student_work]
|
||||
stundet_work = StudentWork.new
|
||||
stundet_work.name = params[:student_work][:name]
|
||||
stundet_work.description = params[:student_work][:description]
|
||||
stundet_work.project_id = params[:student_work][:project_id]
|
||||
stundet_work.homework_common_id = @homework.id
|
||||
stundet_work.user_id = User.current.id
|
||||
stundet_work.save_attachments(params[:attachments])
|
||||
render_attachment_warning_if_needed(stundet_work)
|
||||
if stundet_work.save
|
||||
respond_to do |format|
|
||||
format.html {
|
||||
flash[:notice] = l(:notice_successful_create)
|
||||
redirect_to student_work_index_url(:homework => @homework.id)
|
||||
}
|
||||
end
|
||||
return
|
||||
end
|
||||
end
|
||||
respond_to do |format|
|
||||
format.html {
|
||||
flash[:notice] = l(:notice_failed_create)
|
||||
redirect_to new_student_work_url(:homework => @homework.id)
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
def edit
|
||||
respond_to do |format|
|
||||
format.html
|
||||
end
|
||||
end
|
||||
|
||||
def update
|
||||
if params[:student_work]
|
||||
@work.name = params[:student_work][:name]
|
||||
@work.description = params[:student_work][:description]
|
||||
@work.project_id = params[:student_work][:project]
|
||||
@work.save_attachments(params[:attachments])
|
||||
render_attachment_warning_if_needed(@work)
|
||||
if @work.save
|
||||
respond_to do |format|
|
||||
format.html {
|
||||
flash[:notice] = l(:notice_successful_edit)
|
||||
redirect_to student_work_index_url(:homework => @homework.id)
|
||||
}
|
||||
end
|
||||
return
|
||||
end
|
||||
end
|
||||
respond_to do |format|
|
||||
format.html{redirect_to edit_student_work_url(@work)}
|
||||
end
|
||||
end
|
||||
|
||||
def show
|
||||
@score = student_work_score @work,User.current
|
||||
@is_teacher = User.current.allowed_to?(:as_teacher,@course)
|
||||
respond_to do |format|
|
||||
format.js
|
||||
end
|
||||
end
|
||||
|
||||
def destroy
|
||||
if @work.destroy
|
||||
respond_to do |format|
|
||||
format.html {
|
||||
redirect_to student_work_index_url(:homework => @homework.id)
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
#添加评分,已评分则为修改评分
|
||||
def add_score
|
||||
render_403 and return if User.current == @work.user #不可以匿评自己的作品
|
||||
@is_teacher = User.current.allowed_to?(:as_teacher,@course)
|
||||
#老师、教辅可以随时评分,学生只能在匿评作业的匿评阶段进行评分
|
||||
render_403 and return unless @is_teacher || (@homework.homework_type == 1 && @homework.homework_detail_manual.comment_status == 2)
|
||||
@score = student_work_score @work,User.current
|
||||
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]
|
||||
@is_new = false
|
||||
else
|
||||
@score = StudentWorksScore.new
|
||||
@score.score = params[:score] if params[:score]
|
||||
@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)
|
||||
@is_new = true
|
||||
end
|
||||
|
||||
@score.save_attachments(params[:attachments])
|
||||
render_attachment_warning_if_needed(@score)
|
||||
|
||||
if @score.save
|
||||
case @score.reviewer_role
|
||||
when 1 #教师评分:最后一个教师评分为最终评分
|
||||
@work.teacher_score = @score.score
|
||||
@work.final_score = @score.score
|
||||
when 2 #教辅评分 教辅评分显示平均分
|
||||
@work.teaching_asistant_score = @work.student_works_scores.where(:reviewer_role => 2).average(:score).try(:round, 2).to_f
|
||||
if @work.teacher_score.nil?
|
||||
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}"))
|
||||
final_score = final_ta_score + final_s_score
|
||||
@work.final_score = format("%.2f",final_score.to_f)
|
||||
end
|
||||
end
|
||||
when 3 #学生评分 学生评分显示平均分
|
||||
@work.student_score = @work.student_works_scores.where(:reviewer_role => 3).average(:score).try(:round, 2).to_f
|
||||
if @work.teacher_score.nil?
|
||||
if @work.teaching_asistant_score.nil?
|
||||
@work.final_score = @work.student_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}"))
|
||||
final_score = final_ta_score + final_s_score
|
||||
@work.final_score = format("%.2f",final_score.to_f)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if @work.save
|
||||
respond_to do |format|
|
||||
format.js
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
#添加评分的回复
|
||||
def add_score_reply
|
||||
@score = StudentWorksScore.find params[:score_id]
|
||||
@jour = @score.journals_for_messages.new(:user_id => User.current.id,:notes =>params[:message], :reply_id => 0)
|
||||
if @jour.save
|
||||
@status = 1
|
||||
else
|
||||
@status = 2
|
||||
end
|
||||
respond_to do |format|
|
||||
format.js
|
||||
end
|
||||
end
|
||||
|
||||
#删除评分的回复
|
||||
def destroy_score_reply
|
||||
@jour = JournalsForMessage.find params[:jour_id]
|
||||
if @jour.destroy
|
||||
respond_to do |format|
|
||||
format.js
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
#为作品点赞
|
||||
def praise_student_work
|
||||
pt = PraiseTread.new
|
||||
pt.user_id = User.current.id
|
||||
pt.praise_tread_object_id = @work.id
|
||||
pt.praise_tread_object_type = "StudentWork"
|
||||
pt.praise_or_tread = 1
|
||||
if pt.save
|
||||
respond_to do |format|
|
||||
format.js
|
||||
end
|
||||
else
|
||||
render_404
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
#获取作业
|
||||
def find_homework
|
||||
@homework = HomeworkCommon.find params[:homework]
|
||||
@course = @homework.course
|
||||
rescue
|
||||
render_404
|
||||
end
|
||||
#获取作品
|
||||
def find_work
|
||||
@work = StudentWork.find params[:id]
|
||||
@homework = @work.homework_common
|
||||
@course = @homework.course
|
||||
rescue
|
||||
render_404
|
||||
end
|
||||
|
||||
#是不是当前课程的成员
|
||||
#当前课程成员才可以看到作品列表
|
||||
def member_of_course
|
||||
render_403 unless User.current.member_of_course? @course
|
||||
end
|
||||
|
||||
#判断是不是当前作品的提交者
|
||||
#提交者 && (非匿评作业 || 未开启匿评) 可以编辑作品
|
||||
def author_of_work
|
||||
render_403 unless User.current.id == @work.user_id && (@homework.homework_type != 1 || @homework.homework_detail_manual.comment_status == 1 )
|
||||
end
|
||||
|
||||
#根据条件过滤作业结果
|
||||
def search_homework_member homeworks,name
|
||||
name = name.downcase
|
||||
select_homework = homeworks.select{ |homework|
|
||||
homework.user[:login].to_s.downcase.include?(name) || homework.user.user_extensions[:student_id].to_s.downcase.include?(name) || (homework.user[:lastname].to_s.downcase + homework.user[:firstname].to_s.downcase).include?(name)
|
||||
}
|
||||
select_homework
|
||||
end
|
||||
|
||||
def homework_to_xls items
|
||||
xls_report = StringIO.new
|
||||
book = Spreadsheet::Workbook.new
|
||||
sheet1 = book.create_worksheet :name => "homework"
|
||||
blue = Spreadsheet::Format.new :color => :blue, :weight => :bold, :size => 10
|
||||
sheet1.row(0).default_format = blue
|
||||
sheet1.row(0).concat([l(:excel_user_id),l(:excel_user_name),l(:excel_nickname),l(:excel_student_id),l(:excel_mail),l(:excel_homework_name),
|
||||
l(:excel_t_score),l(:excel_ta_score),l(:excel_n_score),l(:excel_f_score),l(:excel_commit_time)])
|
||||
count_row = 1
|
||||
items.each do |homework|
|
||||
sheet1[count_row,0]=homework.user.id
|
||||
sheet1[count_row,1] = homework.user.lastname.to_s + homework.user.firstname.to_s
|
||||
sheet1[count_row,2] = homework.user.login
|
||||
sheet1[count_row,3] = homework.user.user_extensions.student_id
|
||||
sheet1[count_row,4] = homework.user.mail
|
||||
sheet1[count_row,5] = homework.name
|
||||
sheet1[count_row,6] = homework.teacher_score.nil? ? l(:label_without_score) : format("%.2f",homework.teacher_score)
|
||||
sheet1[count_row,7] = homework.teaching_asistant_score.nil? ? l(:label_without_score) : format("%.2f",homework.teaching_asistant_score)
|
||||
sheet1[count_row,8] = homework.student_score.nil? ? l(:label_without_score) : format("%.2f",homework.student_score)
|
||||
sheet1[count_row,9] = homework.final_score.nil? ? l(:label_without_score) : format("%.2f",homework.final_score)
|
||||
sheet1[count_row,10] = format_time(homework.created_at)
|
||||
count_row += 1
|
||||
end
|
||||
book.write xls_report
|
||||
xls_report.string
|
||||
end
|
||||
end
|
@ -0,0 +1,53 @@
|
||||
# encoding: utf-8
|
||||
module HomeworkCommonHelper
|
||||
#迟交扣分下拉框
|
||||
def late_penalty_option
|
||||
type = []
|
||||
for i in (1..5)
|
||||
option = []
|
||||
option << i
|
||||
option << i
|
||||
type << option
|
||||
end
|
||||
type
|
||||
end
|
||||
|
||||
#教辅评分比例下拉框
|
||||
def ta_proportion_option
|
||||
type = []
|
||||
i = 10
|
||||
while i <= 100
|
||||
option = []
|
||||
option << i.to_s + "%"
|
||||
option << i.to_f / 100
|
||||
type << option
|
||||
i += 10
|
||||
end
|
||||
type
|
||||
end
|
||||
|
||||
#缺评扣分
|
||||
def absence_penalty_option
|
||||
type = []
|
||||
i = 1
|
||||
while i <= 5
|
||||
option = []
|
||||
option << i
|
||||
option << i
|
||||
type << option
|
||||
i += 1
|
||||
end
|
||||
type
|
||||
end
|
||||
|
||||
#根据传入作业确定跳转到开启匿评还是关闭匿评功能
|
||||
def alert_anonyoms_path homework,homework_detail_manual
|
||||
link = ""
|
||||
if homework_detail_manual.comment_status == 1
|
||||
link = start_anonymous_comment_homework_common_url homework.id
|
||||
elsif homework_detail_manual.comment_status == 2
|
||||
link = stop_anonymous_comment_homework_common_url homework.id
|
||||
end
|
||||
link
|
||||
end
|
||||
end
|
@ -0,0 +1,63 @@
|
||||
# encoding: utf-8
|
||||
module StudentWorkHelper
|
||||
def user_projects_option
|
||||
cond = Project.visible_condition(User.current) + " AND projects.project_type <> 1"
|
||||
memberships = User.current.memberships.all(:conditions => cond)
|
||||
projects = memberships.map(&:project)
|
||||
not_have_project = []
|
||||
not_have_project << Setting.please_chose
|
||||
not_have_project << 0
|
||||
type = []
|
||||
type << not_have_project
|
||||
projects.each do |project|
|
||||
if project != nil
|
||||
option = []
|
||||
option << project.name
|
||||
option << project.id
|
||||
type << option
|
||||
end
|
||||
end
|
||||
type
|
||||
end
|
||||
|
||||
#获取指定用户对某一作业的评分结果
|
||||
def student_work_score work,user
|
||||
StudentWorksScore.where(:user_id => user.id,:student_work_id => work.id).first
|
||||
end
|
||||
|
||||
#获取指定评分的角色
|
||||
def student_work_score_role score
|
||||
case score.reviewer_role
|
||||
when 1
|
||||
role = "教师"
|
||||
when 2
|
||||
role = "助教"
|
||||
when 3
|
||||
role = "学生"
|
||||
end
|
||||
end
|
||||
|
||||
def get_role_by_name role
|
||||
case role
|
||||
when "Teacher"
|
||||
result = 1
|
||||
when "Manager"
|
||||
result = 1
|
||||
when "TeachingAsistant"
|
||||
result = 2
|
||||
when "Student"
|
||||
result = 3
|
||||
end
|
||||
result
|
||||
end
|
||||
|
||||
#获取赞的总数
|
||||
def praise_homework_count obj_id
|
||||
PraiseTread.where("praise_tread_object_id = #{obj_id} AND praise_tread_object_type = 'StudentWork'").count
|
||||
end
|
||||
|
||||
#判断指定用户是不是已经赞过该作业
|
||||
def is_praise_homework user_id, obj_id
|
||||
PraiseTread.where("user_id = #{user_id} AND praise_tread_object_id = #{obj_id} AND praise_tread_object_type = 'StudentWork'").empty?
|
||||
end
|
||||
end
|
@ -0,0 +1,31 @@
|
||||
#老师布置的作业表
|
||||
#homework_type: 0:普通作业;1:匿评作业;2:编程作业
|
||||
class HomeworkCommon < ActiveRecord::Base
|
||||
# attr_accessible :name, :user_id, :description, :publish_time, :end_time, :homework_type, :late_penalty, :course_id
|
||||
include Redmine::SafeAttributes
|
||||
include ApplicationHelper
|
||||
|
||||
belongs_to :course
|
||||
belongs_to :user
|
||||
has_one :homework_detail_manual, :dependent => :destroy
|
||||
has_one :homework_detail_programing, :dependent => :destroy
|
||||
has_many :homework_tests, :dependent => :destroy
|
||||
has_many :student_works, :dependent => :destroy
|
||||
has_many :student_works_evaluation_distributions, :through => :student_works #一个作业的分配的匿评列表
|
||||
has_many :acts, :class_name => 'Activity', :as => :act, :dependent => :destroy #用户活动
|
||||
acts_as_attachable
|
||||
acts_as_event :title => Proc.new {|o| "#{l(:label_course_homework)} ##{o.id}: #{o.name}" },
|
||||
:description => :description,
|
||||
:author => :author,
|
||||
:url => Proc.new {|o| {:controller => 'student_work', :action => 'index', :homework => o.id}}
|
||||
after_create :act_as_activity
|
||||
after_destroy :delete_kindeditor_assets
|
||||
|
||||
def act_as_activity
|
||||
self.acts << Activity.new(:user_id => self.user_id)
|
||||
end
|
||||
#删除对应的图片
|
||||
def delete_kindeditor_assets
|
||||
delete_kindeditor_assets_from_disk self.id,OwnerTypeHelper::HOMEWORKCOMMON
|
||||
end
|
||||
end
|
@ -0,0 +1,5 @@
|
||||
class HomeworkDetailPrograming < ActiveRecord::Base
|
||||
attr_accessible :language, :standard_code, :homework_common_id
|
||||
|
||||
belongs_to :homework_common
|
||||
end
|
@ -0,0 +1,5 @@
|
||||
class HomeworkTest < ActiveRecord::Base
|
||||
attr_accessible :input, :output, :homework_common_id
|
||||
|
||||
belongs_to :homework_common
|
||||
end
|
@ -0,0 +1,12 @@
|
||||
#学生提交作品表
|
||||
class StudentWork < ActiveRecord::Base
|
||||
attr_accessible :name, :description, :homework_common_id, :user_id, :final_score, :teacher_score, :student_score, :teaching_asistant_score, :project_id
|
||||
|
||||
belongs_to :homework_common
|
||||
belongs_to :user
|
||||
has_many :student_works_evaluation_distributions, :dependent => :destroy
|
||||
has_many :student_works_scores, :dependent => :destroy
|
||||
belongs_to :project
|
||||
|
||||
acts_as_attachable
|
||||
end
|
@ -0,0 +1,7 @@
|
||||
#学生作品匿评分配表
|
||||
class StudentWorksEvaluationDistribution < ActiveRecord::Base
|
||||
attr_accessible :student_work_id, :user_id
|
||||
|
||||
belongs_to :student_work
|
||||
belongs_to :user
|
||||
end
|
@ -0,0 +1,10 @@
|
||||
class StudentWorksScore < ActiveRecord::Base
|
||||
#reviewer_role: 1:教师评分;2:教辅评分;3:学生匿评
|
||||
attr_accessible :student_work_id, :user_id, :score, :comment, :reviewer_role
|
||||
|
||||
belongs_to :user
|
||||
belongs_to :student_work
|
||||
has_many :journals_for_messages, :as => :jour, :dependent => :destroy
|
||||
|
||||
acts_as_attachable
|
||||
end
|
@ -1,4 +0,0 @@
|
||||
<%= javascript_include_tag "/assets/kindeditor/kindeditor" %>
|
||||
<%= labelled_form_for @homework, :html => { :multipart => true }, :url => {:controller => 'bids', :action => 'create_homework',:course_id => "#{params[:id] || params[:course_id]}"} do |f| %>
|
||||
<%= render :partial => 'bids/new_homework_form', :locals => { :bid => @homework,:bid_id => "new_bid",:f => f,:edit_mode => false } %>
|
||||
<% end %>
|
@ -0,0 +1,7 @@
|
||||
$('#ajax-modal').html('<%= escape_javascript(render :partial => 'alert_anonyoms') %>');
|
||||
showModal('ajax-modal', '500px');
|
||||
$('#ajax-modal').siblings().remove();
|
||||
$('#ajax-modal').before("<span style='float: right;cursor:pointer;'>" +
|
||||
"<a href='javascript:' onclick='clickCanel();'><img src='/images/bid/close.png' width='26px' height='26px' /></a></span>");
|
||||
$('#ajax-modal').parent().css("top","").css("left","");
|
||||
$('#ajax-modal').parent().addClass("anonymos");
|
@ -0,0 +1,16 @@
|
||||
<%= javascript_include_tag "/assets/kindeditor/kindeditor" %>
|
||||
<%= error_messages_for 'homework_common' %>
|
||||
|
||||
<div class="project_r_h">
|
||||
<h2 class="project_h2">
|
||||
<%= l(:label_course_homework_edit)%>
|
||||
</h2>
|
||||
</div>
|
||||
<div class="hwork_new">
|
||||
<%= form_for @homework do |f| %>
|
||||
<%= render :partial => 'homework_common/homework_common_form', :locals => { :homework => @homework,:f => f,:edit_mode => true } %>
|
||||
<a href="javascript:void(0)" class="blue_btn fl mr10" onClick="submit_homework('edit_homework_common_<%= @homework.id%>');" >提交</a>
|
||||
<%= link_to '取消',homework_common_index_path(:course => @course.id),:class => 'grey_btn fl'%>
|
||||
<% end%>
|
||||
</div><!--hwork_new end-->
|
||||
<div class="cl"></div>
|
@ -0,0 +1,17 @@
|
||||
<%= javascript_include_tag "/assets/kindeditor/kindeditor" %>
|
||||
<%= error_messages_for 'homework_common' %>
|
||||
|
||||
<div class="project_r_h">
|
||||
<h2 class="project_h2">
|
||||
<%= l(:label_course_homework_new)%>
|
||||
</h2>
|
||||
</div>
|
||||
<div class="hwork_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 } %>
|
||||
<a href="javascript:void(0)" class="blue_btn fl mr10" onClick="submit_homework('new_homework_common');" >提交</a>
|
||||
<%= link_to '取消',homework_common_index_path(:course => @course.id),:class => 'grey_btn fl'%>
|
||||
<% end%>
|
||||
</div><!--hwork_new end-->
|
||||
<div class="cl"></div>
|
@ -0,0 +1,10 @@
|
||||
<% if @statue == 1%>
|
||||
alert('启动成功');
|
||||
$("#<%= @homework.id %>_start_anonymous_comment").replaceWith('<%= escape_javascript(link_to "关闭匿评", alert_anonymous_comment_homework_common_path(@homework), remote: true, id:"#{@homework.id}_stop_anonymous_comment",:class => "fr mr10 work_edit")%>');
|
||||
<% elsif @statue == 2 %>
|
||||
alert('启动失败\n作业总数大于等于2份时才能启动匿评');
|
||||
<% elsif @statue == 3%>
|
||||
alert("已开启匿评,请务重复开启");
|
||||
<% elsif @statue == 3%>
|
||||
alert("您没有权限开启匿评");
|
||||
<% end %>
|
@ -0,0 +1,2 @@
|
||||
$("#<%= @homework.id %>_stop_anonymous_comment").replaceWith('<span class="fr pr_join_span mr10" title="匿评结束">匿评结束</span>');
|
||||
alert('关闭成功');
|
@ -1,12 +1,5 @@
|
||||
<% if course %>
|
||||
<li id="homework_loggedas_li" style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis;" title="<%=course.name%>" onmouseover="homeworkSlipMenuOver(<%= course.id%>);" onmouseout="homeworkSlipMenuOut(<%= course.id%>);">
|
||||
<%= link_to course.name, course_path(course.id, host: Setting.host_course) %>
|
||||
<ul class="homework_sub_menu" id="homework_loggedas_ul_<%= course.id%>" style="top:<%= course_index * 28.1%>px;">
|
||||
<% course.homework_for_courses.map(&:bid).each do |bid| %>
|
||||
<li style="overflow: hidden;text-overflow: ellipsis;white-space: nowrap;" title="<%=bid.name%>">
|
||||
<%= link_to bid.name, course_for_bid_path(bid, host: Setting.host_course), :target => "_blank" %>
|
||||
</li>
|
||||
<% end %>
|
||||
</ul>
|
||||
</li>
|
||||
<% end %>
|
@ -0,0 +1,22 @@
|
||||
<%= form_for('new_form', :remote => true, :method => :post,:url => add_score_student_work_path(work.id)) do |f|%>
|
||||
<li >
|
||||
<span class="tit_fb"> 评价:</span>
|
||||
<%= f.text_area 'user_message', :class => 'hwork_ping_text', :placeholder => l(:text_caracters_maximum,:count=>250),:maxlength => 250 %>
|
||||
<div class="cl"></div>
|
||||
</li>
|
||||
<li >
|
||||
<span class="tit_fb mt2"> 评分:</span>
|
||||
<input type="number" name="score" id="score_<%= work.id%>" value="<%= score.nil? ? 60 : score.score%>" min="0" max="100" size="4" data-units="dollars" />
|
||||
<span class=" ml5">分</span>
|
||||
<div class="cl"></div></li>
|
||||
<li >
|
||||
<% if @is_teacher%> <!-- 老师才可以上传批阅结果 -->
|
||||
<span class="tit_fb"> 批阅结果:</span>
|
||||
<div>
|
||||
<%= render :partial => 'student_work/student_work_attachment_form', :locals => {:work => work,:score => score} %>
|
||||
</div>
|
||||
<%end%>
|
||||
<a href="javascript:void(0);" class="blue_n_btn fr" onclick="$(this).parent().parent().submit();">提交</a>
|
||||
<div class="cl"></div>
|
||||
</li>
|
||||
<% end%>
|
@ -0,0 +1,4 @@
|
||||
<%= form_for('', :remote => true, :method => :post,:url => add_score_reply_student_work_index_path(:score_id => score.id)) do |f|%>
|
||||
<%= f.text_area 'message', :class => 'ping_text', :placeholder => l(:text_caracters_maximum,:count=>250),:maxlength => 250 %>
|
||||
<a href="javascript:void(0);" class="fr blue_n_btn" onclick="$('#add_score_reply_<%= score.id%>').find('form').submit();">回复</a>
|
||||
<% end%>
|
@ -0,0 +1,26 @@
|
||||
<!-- 匿评作品列表,显示某一个作品的信息 -->
|
||||
<ul class="hwork_ul <%= cycle("b_grey", "") %>" id="student_work_<%= student_work.id%>">
|
||||
<% is_my_work = student_work.user == User.current%>
|
||||
<li style="min-height: 1px;width: 65px;">
|
||||
<% if is_my_work%>
|
||||
<%= link_to student_work.user.user_extensions.nil? ? "--" : student_work.user.user_extensions.student_id,user_path(student_work.user),:class => "c_blue02 hwork_center"%>
|
||||
<% else%>
|
||||
<%= link_to "--", "javascript:void(0)",:class => "c_blue02 hwork_center"%>
|
||||
<% end%>
|
||||
</li>
|
||||
<li>
|
||||
<% if is_my_work%>
|
||||
<%= link_to student_work.user.show_name,user_path(student_work.user),:class => "c_blue02 hwork_name"%>
|
||||
<% else%>
|
||||
<%= link_to "匿名","javascript:void(0)",:class => "c_blue02 hwork_name"%>
|
||||
<% end%>
|
||||
</li>
|
||||
<li class=" hwork_tit_e" style="width: 440px">
|
||||
<%= link_to student_work.name, student_work_path(student_work),:remote => true%>
|
||||
</li>
|
||||
<% my_score = student_work_score(student_work,User.current) %>
|
||||
<li class=" hwork_code <%= my_score.nil? ? 'c_grey' : 'c_red'%>">
|
||||
<%= my_score.nil? ? "--" : format("%.2f",my_score.score)%>
|
||||
</li>
|
||||
<div class="cl"></div>
|
||||
</ul><!---hwork_ul end-->
|
@ -0,0 +1,12 @@
|
||||
<li class="w70 ">
|
||||
<span href="javascript:void(0);" class="c_dark f14 fb fl ml15 ">学号</span>
|
||||
</li>
|
||||
<li class="w70">
|
||||
<span class="c_dark f14 fb fl ">学生姓名</span>
|
||||
</li>
|
||||
<li class="hwork_tit_e">
|
||||
<span class="c_dark f14 fb fl">作品名称</span>
|
||||
</li>
|
||||
<li class="w70 mr5" >
|
||||
<%= link_to "我的评分","javascript:void(0)",:class => "c_dark f14 fb fl"%>
|
||||
</li>
|
@ -0,0 +1,20 @@
|
||||
<div class="ping_back mt10" id="jour_replay_<%= jour.id%>">
|
||||
<%= link_to image_tag(url_to_avatar(jour.user), :width => "32", :height => "32"), user_path(jour.user),:class => "st_img fl" %>
|
||||
<div class="ping_back_tit">
|
||||
<a href="javascript:void(0);" class="c_blue fl" >
|
||||
<%= link_to jour.user.show_name, user_path(jour.user), :title => jour.user.show_name, :class => "c_blue fl" %>
|
||||
</a>
|
||||
<% if jour.user==User.current || User.current.admin? %>
|
||||
<%= link_to(l(:label_bid_respond_delete), destroy_score_reply_student_work_index_path(:jour_id => jour.id),
|
||||
:remote => true, :confirm => l(:text_are_you_sure), :title => l(:button_delete), :class => "fr c_purple") %>
|
||||
<% end %>
|
||||
<span class=" fr c_grey mr10">
|
||||
<%=format_time jour.created_on %>
|
||||
</span>
|
||||
<div class="cl mb5"></div>
|
||||
<p class="break_word">
|
||||
<%= jour.notes%>
|
||||
</p>
|
||||
</div><!---ping_box_tit end--->
|
||||
<div class="cl"></div>
|
||||
</div><!---ping_back end--->
|
@ -0,0 +1,72 @@
|
||||
<div class="show_hwork_arrow"></div>
|
||||
<div class="show_hwork">
|
||||
<ul>
|
||||
<li class="fl">
|
||||
<span class="tit_fb">上交时间:</span>
|
||||
<%=format_time @work.created_at %>
|
||||
</li>
|
||||
|
||||
<% if !@is_teacher && @work.user == User.current && (@homework.homework_type != 1 || @homework.homework_detail_manual.comment_status == 1) %>
|
||||
<!-- 我的作业 && (非匿评作业 || 为开启匿评),显示编辑和删除按钮 -->
|
||||
<li class="fr" >
|
||||
<%= link_to("", student_work_path(@work),:method => 'delete', :confirm => l(:text_are_you_sure), :class => "pic_del") %>
|
||||
</li>
|
||||
<li class="fr" >
|
||||
<%= link_to "",edit_student_work_path(@work),:class => "pic_edit"%>
|
||||
</li>
|
||||
<% end%>
|
||||
<% if (@homework.homework_type != 1 || @homework.homework_detail_manual.comment_status == 3) && @work.user != User.current%>
|
||||
<!-- 普通作业或者编程作业,或者是匿评结束阶段,显示点赞按钮 -->
|
||||
<li class="fr" id="student_work_praise_<%= @work.id%>">
|
||||
<%= render :partial => 'student_work_praise' %>
|
||||
</li>
|
||||
<% end%>
|
||||
<div class="cl"></div>
|
||||
|
||||
<!--<li >-->
|
||||
<!--<span class="tit_fb"> 参与人员:</span>-->
|
||||
<!--程梦雯 王强-->
|
||||
<!--</li>-->
|
||||
<% if @work.project%>
|
||||
<li >
|
||||
<span class="tit_fb"> 关联项目:</span>
|
||||
<%= link_to( @work.project.name, project_path(@work.project.id), :class => "c_blue02" )%>
|
||||
</li>
|
||||
<% end%>
|
||||
<li >
|
||||
<span class="tit_fb ">内容:</span>
|
||||
<p class="show_hwork_p break_word">
|
||||
<%= @work.description%>
|
||||
</p>
|
||||
<div class="cl"></div>
|
||||
</li>
|
||||
<li >
|
||||
<span class="tit_fb"> 附件:</span>
|
||||
<% if @work.attachments.empty?%>
|
||||
<span style="color: #999999">尚未提交附件</span>
|
||||
<% else%>
|
||||
<div class="fl">
|
||||
<%= render :partial => 'work_attachments', :locals => {:attachments => @work.attachments} %>
|
||||
</div>
|
||||
<% end%>
|
||||
</li>
|
||||
<div class="cl"></div>
|
||||
|
||||
<% if @is_teacher || (@homework.homework_type == 1 && @homework.homework_detail_manual.comment_status == 2 && @work.user != User.current )%>
|
||||
<!-- 老师 || 匿评作业 && 开启匿评状态 && 不是当前用户自己的作品 -->
|
||||
<div id="add_student_score_<%= @work.id%>" class="mt10 ">
|
||||
<%= render :partial => 'add_score',:locals => {:work => @work,:score => @score}%>
|
||||
</div>
|
||||
<% end%>
|
||||
</ul>
|
||||
|
||||
<div class="ping_box" id="score_list_<%= @work.id%>" style="<%= @work.student_works_scores.empty? ? 'padding:0px;' : ''%>">
|
||||
<%@work.student_works_scores.order("created_at desc").each do |score|%>
|
||||
<div id="work_score_<%= score.id%>">
|
||||
<%= render :partial => 'student_work_score',:locals => {:score => score}%>
|
||||
</div>
|
||||
<% end%>
|
||||
</div><!---ping_box end--->
|
||||
<a href="javascript:void(0);" class="fr c_blue mt5 mb5" onclick="$('#about_hwork_<%= @work.id%>').html('');">收起</a>
|
||||
<div class="cl"></div>
|
||||
</div><!---show_hwork end--->
|
@ -0,0 +1,36 @@
|
||||
<!-- 作品列表,显示某一个作品的信息 -->
|
||||
<ul class="hwork_ul <%= cycle("b_grey", "") %>" id="student_work_<%= student_work.id%>">
|
||||
<li style="min-height: 1px;width: 65px;">
|
||||
<%= link_to student_work.user.user_extensions.nil? ? "--" : student_work.user.user_extensions.student_id,user_path(student_work.user),:class => "c_blue02 hwork_center"%>
|
||||
</li>
|
||||
<li>
|
||||
<%= link_to student_work.user.show_name,user_path(student_work.user),:class => "c_blue02 hwork_name"%>
|
||||
</li>
|
||||
<li class=" hwork_tit">
|
||||
<%= link_to student_work.name, student_work_path(student_work),:remote => true%>
|
||||
</li>
|
||||
<li class=" hwork_code <%= student_work.teacher_score.nil? ? 'c_grey' : 'c_red'%>">
|
||||
<%= student_work.teacher_score.nil? ? "--" : format("%.2f",student_work.teacher_score)%>
|
||||
</li>
|
||||
<li class=" hwork_code <%= student_work.teaching_asistant_score.nil? ? 'c_grey' : 'c_red'%>">
|
||||
<%= student_work.teaching_asistant_score.nil? ? "--" : format("%.2f",student_work.teaching_asistant_score)%>
|
||||
</li>
|
||||
<li class=" hwork_code02 <%= student_work.student_score.nil? ? 'c_grey' : 'c_red'%> student_score_info">
|
||||
<%= student_work.student_score.nil? ? "--" : format("%.2f",student_work.student_score)%>
|
||||
<% unless student_work.student_score.nil?%>
|
||||
<span class="c_blue">
|
||||
(<%= student_work.student_works_scores.where(:reviewer_role => 3).count%>)
|
||||
</span>
|
||||
<div class="info_ni">
|
||||
现共有
|
||||
<span class="c_red"> <%= student_work.student_works_scores.where(:reviewer_role => 3).count%> </span>
|
||||
名学生进行了匿评,平均分为
|
||||
<span class="c_red"> <%= format("%.2f",student_work.student_score)%> </span>分。
|
||||
</div>
|
||||
<% end%>
|
||||
</li>
|
||||
<li class=" hwork_code02 <%= student_work.final_score.nil? ? 'c_grey' : 'c_red'%>">
|
||||
<%= student_work.final_score.nil? ? "--" : format("%.2f",student_work.final_score)%>
|
||||
</li>
|
||||
<div class="cl"></div>
|
||||
</ul><!---hwork_ul end-->
|
@ -0,0 +1,35 @@
|
||||
<div class="fl">
|
||||
<span id="attachments_fields<%= work.id%>" xmlns="http://www.w3.org/1999/html">
|
||||
</span>
|
||||
<div class="cl"></div>
|
||||
<span class="add_attachment" style="font-weight:normal;">
|
||||
<%= button_tag "文件浏览", :type=>"button", :onclick=>"$('#_file#{work.id}').click();",:onmouseover => 'this.focus()',:class => 'sub_btn' %>
|
||||
<%= file_field_tag 'attachments[dummy][file]',
|
||||
:id => "_file#{work.id}",
|
||||
:class => 'file_selector',
|
||||
:multiple => true,
|
||||
:onchange => "addInputFiles_board(this, '#{work.id}');",
|
||||
:style => 'display:none',
|
||||
:data => {
|
||||
:max_file_size => Setting.attachment_max_size.to_i.kilobytes,
|
||||
:max_file_size_message => l(:error_attachment_too_big, :max_size => number_to_human_size(Setting.attachment_max_size.to_i.kilobytes)),
|
||||
:max_concurrent_uploads => Redmine::Configuration['max_concurrent_ajax_uploads'].to_i,
|
||||
:upload_path => uploads_path(:format => 'js'),
|
||||
:description_placeholder => l(:label_optional_description),
|
||||
:field_is_public => l(:field_is_public),
|
||||
:are_you_sure => l(:text_are_you_sure),
|
||||
:file_count => l(:label_file_count),
|
||||
:delete_all_files => l(:text_are_you_sure_all),
|
||||
:containerid => "#{work.id}"
|
||||
} %>
|
||||
<span id="upload_file_count<%= work.id%>">
|
||||
<%= l(:label_no_file_uploaded) %>
|
||||
</span>
|
||||
(<%= l(:label_max_size) %>:
|
||||
<%= number_to_human_size(Setting.attachment_max_size.to_i.kilobytes) %>)
|
||||
</span>
|
||||
<% content_for :header_tags do %>
|
||||
<%= javascript_include_tag 'attachments' %>
|
||||
<% end %>
|
||||
</div>
|
||||
|
@ -0,0 +1,5 @@
|
||||
<% if is_praise_homework User.current.id,@work.id %>
|
||||
<%= link_to "赞(#{praise_homework_count @work.id})",praise_student_work_student_work_path(@work), :remote => true,:class => 'orange_btn', :style => 'font-size:12px;'%>
|
||||
<% else %>
|
||||
<%= link_to "赞(#{praise_homework_count @work.id})","javascript:void(0)",:class => 'grey_btn', :style => 'font-size:12px;'%>
|
||||
<% end %>
|
@ -0,0 +1,33 @@
|
||||
<li class="w70 ">
|
||||
<span href="javascript:void(0);" class="c_dark f14 fb fl ">学号</span>
|
||||
</li>
|
||||
<li class="w70">
|
||||
<span class="c_dark f14 fb fl ">学生姓名</span>
|
||||
</li>
|
||||
<li class="hwork_tit">
|
||||
<span class="c_dark f14 fb fl">作品名称</span>
|
||||
</li>
|
||||
<li class="w70 mr5" >
|
||||
<%= link_to "教师评分",@show_all ? student_work_index_path(:homework => @homework.id,:order => "teacher_score", :sort => @score, :name => @name) : "javascript:void(0)",:class => "c_dark f14 fb fl"%>
|
||||
<% if @show_all && @order == "teacher_score"%>
|
||||
<a href="javascript:void(0);" class="<%= @score == 'desc' ? 'st_up' : 'st_down'%>" ></a>
|
||||
<% end%>
|
||||
</li>
|
||||
<li class="w70 mr5">
|
||||
<%= link_to "教辅评分",@show_all ? student_work_index_path(:homework => @homework.id,:order => "teaching_asistant_score", :sort => @score, :name => @name) : "javascript:void(0)",:class => "c_dark f14 fb fl"%>
|
||||
<% if @show_all && @order == "teaching_asistant_score"%>
|
||||
<a href="javascript:void(0);" class="<%= @score == 'desc' ? 'st_up' : 'st_down'%>" ></a>
|
||||
<% end%>
|
||||
</li>
|
||||
<li class="w60 mr5 ml10">
|
||||
<%= link_to "匿评",@show_all ? student_work_index_path(:homework => @homework.id,:order => "student_score", :sort => @score, :name => @name) : "javascript:void(0)",:class => "c_dark f14 fb fl"%>
|
||||
<% if @show_all && @order == "student_score"%>
|
||||
<a href="javascript:void(0);" class="<%= @score == 'desc' ? 'st_up' : 'st_down'%>" ></a>
|
||||
<% end%>
|
||||
</li>
|
||||
<li class="w40 ml10" id="final_sort">
|
||||
<%= link_to "成绩",@show_all ? student_work_index_path(:homework => @homework.id,:order => "final_score", :sort => @score, :name => @name) : "javascript:void(0)",:class => "c_dark f14 fb fl"%>
|
||||
<% if @show_all && @order == "final_score"%>
|
||||
<a href="javascript:void(0);" class="<%= @score == 'desc' ? 'st_up' : 'st_down'%>" ></a>
|
||||
<% end%>
|
||||
</li>
|
@ -0,0 +1,5 @@
|
||||
<% for attachment in attachments %>
|
||||
<%= link_to_short_attachment attachment, :class => 'link_file', :download => true -%>
|
||||
<span class="ml5">(<%= number_to_human_size attachment.filesize %>)</span>
|
||||
<div class="cl"></div>
|
||||
<% end -%>
|
@ -0,0 +1,29 @@
|
||||
$("#add_student_score_<%= @work.id%>").html("<%= escape_javascript(render :partial => 'add_score',:locals => {:work => @work,:score => @score}) %>");
|
||||
$('#score_<%= @work.id%>').peSlider({range: 'min'});
|
||||
|
||||
<% if @is_new%>
|
||||
$("#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}) %>");
|
||||
<% end%>
|
||||
$("#score_list_<%= @work.id%>").removeAttr("style");
|
||||
|
||||
<% if @is_teacher %>
|
||||
$("#student_work_<%= @work.id%>").replaceWith("<%= escape_javascript(render :partial => 'student_work',:locals => {:student_work => @work}) %>");
|
||||
<% else %>
|
||||
$("#student_work_<%= @work.id%>").replaceWith("<%= escape_javascript(render :partial => 'evaluation_work',:locals => {:student_work => @work}) %>");
|
||||
<% end%>
|
||||
|
||||
|
||||
$(function(){
|
||||
$(".student_score_info").bind("mouseover",function(e){
|
||||
//alert($(this).html());
|
||||
$(this).find("div").show();
|
||||
$(this).find("div").css("top",e.pageY);
|
||||
$(this).find("div").css("left",e.pageX);
|
||||
});
|
||||
$(".student_score_info").bind("mouseout",function(e){
|
||||
//alert($(this).html());
|
||||
$(this).find("div").hide();
|
||||
});
|
||||
});
|
@ -0,0 +1,6 @@
|
||||
$("#add_score_reply_<%= @score.id%>").html("<%= escape_javascript(render :partial => 'add_score_reply', :locals => {:score => @score}) %>");
|
||||
<% if @status && @status == 1%>
|
||||
$("#replay_histroy_<%= @score.id%>").prepend("<%= escape_javascript(render :partial => 'jour_replay', :locals => {:jour => @jour}) %>");
|
||||
<% else%>
|
||||
alert("回复内容不能为空");
|
||||
<% end%>
|
@ -0,0 +1 @@
|
||||
$("#jour_replay_<%= @jour.id%>").remove();
|
@ -0,0 +1,124 @@
|
||||
<div class="project_r_h">
|
||||
<div id="menu_r">
|
||||
<ul class="menu_r">
|
||||
<li><a href="javascript:void(0);" class="parent">作业批次</a>
|
||||
<ul>
|
||||
<% @homework_commons.each_with_index { |homework_common,index |%>
|
||||
<li>
|
||||
<%= link_to "第#{@homework_commons.count - index}次作业",student_work_index_path(:homework => homework_common.id)%>
|
||||
</li>
|
||||
<%}%>
|
||||
</ul>
|
||||
</li><!---level1 end--->
|
||||
</ul><!---menu_r end--->
|
||||
</div>
|
||||
</div><!--contentbox end-->
|
||||
|
||||
<div class="to_top" id="goTopBtn" style="display: none;">
|
||||
返<br/>回<br/>顶<br/>部
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
|
||||
<div id="contentbox">
|
||||
<div id="tb_" class="hwork_tb_">
|
||||
<ul>
|
||||
<li id="tb_1" class="hwork_hovertab" onclick="course_setting(1)">全部作品</li>
|
||||
<li id="tb_2" class="hwork_normaltab" onclick="course_setting(2)">作业信息</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
|
||||
<div class="ctt">
|
||||
<div class="dis" id="tbc_01">
|
||||
<div class="code_list">
|
||||
<span class="fl mt3">
|
||||
<%= link_to "所有作品(<span class='c_red'>#{@stundet_works.count}</span>)".html_safe,student_work_index_path(:homework => @homework.id), :class => "fl"%>
|
||||
</span>
|
||||
<% if @show_all%>
|
||||
<input type="text" value="<%= @name%>" placeholder="昵称、学号、姓名搜索" class="min_search ml10 fl" onkeypress="SearchByName($(this),'<%= student_work_index_path(:homework => @homework.id)%>',event);">
|
||||
<% end%>
|
||||
<% if @is_teacher%>
|
||||
<div class="fr">
|
||||
<% if @homework.student_works.empty?%>
|
||||
<%= link_to "附件", "javascript:void(0)", class: "down_btn fr", :onclick => "alert('没有学生提交作业,无法下载附件')" %>
|
||||
<% else%>
|
||||
<%= link_to "附件", zipdown_assort_path(obj_class: @homework.class, obj_id: @homework, format: :json),
|
||||
remote: true, class: "down_btn fr", :id => "download_homework_attachments" %>
|
||||
<% end%>
|
||||
|
||||
<%= link_to l(:label_list), student_work_index_path(:homework => @homework.id,:order => @order, :sort => @b_sort, :name => @name, :format => 'xls'),:class=>'down_btn fr'%>
|
||||
<span class="mt3 fr " style="color:#136b3b;">导出全部:</span>
|
||||
</div>
|
||||
<% end%>
|
||||
<div class="cl"></div>
|
||||
</div><!---code_list end--->
|
||||
<ul class="hwork_ul">
|
||||
<% if @is_evaluation.nil?%>
|
||||
<%= render :partial => 'student_work_title'%>
|
||||
<% else%>
|
||||
<%= render :partial => 'evaluation_work_title'%>
|
||||
<% end%>
|
||||
</ul><!---hwork_ul end-->
|
||||
<div class="cl"></div>
|
||||
|
||||
<% @stundet_works.each do |student_work|%>
|
||||
<%= render :partial => (@is_evaluation ? 'evaluation_work' :'student_work'),:locals => {:student_work => student_work}%>
|
||||
<div id="about_hwork_<%= student_work.id%>" ></div>
|
||||
<% end%>
|
||||
|
||||
<div class="cl"></div>
|
||||
</div><!---tbc_01 end-->
|
||||
|
||||
<div class="undis" id="tbc_02">
|
||||
<div class="problem_main mt10">
|
||||
<%= link_to(image_tag(url_to_avatar(@homework.user), :width => "42", :height => "42"), user_path(@homework.user), :class => "problem_pic fl") %>
|
||||
<div class="problem_txt fl mt5">
|
||||
<h4 class="r_txt_tit mb5">
|
||||
<%= @homework.name%>
|
||||
</h4>
|
||||
<% if @is_teacher%>
|
||||
<%= homework_anonymous_comment(@homework)%>
|
||||
<%= link_to(l(:button_edit),edit_homework_common_path(@homework), :class => "fr mr10 work_edit") %>
|
||||
<% else%>
|
||||
<%= student_anonymous_comment @homework %>
|
||||
<%= student_new_homework @homework %>
|
||||
<% end %>
|
||||
|
||||
<div class="cl"></div>
|
||||
<div id="bid_description_<%= @homework.id%>" class="mt5 upload_img">
|
||||
<%= @homework.description.html_safe %>
|
||||
</div>
|
||||
|
||||
<div class="cl"></div>
|
||||
<div class="mt5">
|
||||
<% unless @homework.attachments.empty?%>
|
||||
<span class="tit_fb" style="width: auto;"> 附件:</span>
|
||||
<div class="fl mb5">
|
||||
<%= render :partial => 'student_work/work_attachments', :locals => {:attachments => @homework.attachments} %>
|
||||
</div>
|
||||
<% end%>
|
||||
</div>
|
||||
|
||||
<div class="cl"></div>
|
||||
<span class="fl">截止时间:<%= @homework.end_time%></span>
|
||||
<div >
|
||||
<% if betweentime(@homework.end_time) < 0 %>
|
||||
<span class='fr mr10 c_red '>
|
||||
<%= l(:label_commit_limit)%>
|
||||
</span>
|
||||
<% else %>
|
||||
<script type="text/javascript">
|
||||
window.setInterval(function(){show_bid_dead_line(<%= @homework.end_time.year%>,<%= @homework.end_time.month%>,<%= @homework.end_time.day + 1%>,"bid_deadline_<%= @homework.id%>");},1000)
|
||||
</script>
|
||||
<div id="bid_deadline_<%= @homework.id%>">
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
</div> <!--problem_txt end-->
|
||||
<div class="cl"></div>
|
||||
</div><!--problem_main end-->
|
||||
</div><!---tbc_02 end-->
|
||||
|
||||
|
||||
</div><!--ctt end-->
|
||||
</div><!--contentbox end-->
|
@ -0,0 +1 @@
|
||||
$('#student_work_praise_<%= @work.id%>').html('<%= escape_javascript(render :partial => 'student_work/student_work_praise')%>');
|
@ -0,0 +1,7 @@
|
||||
if($("#about_hwork_<%= @work.id%>").children().length > 0)
|
||||
{$("#about_hwork_<%= @work.id%>").html("");}
|
||||
else
|
||||
{
|
||||
$("#about_hwork_<%= @work.id%>").html("<%= escape_javascript(render :partial => 'show') %>");
|
||||
$('#score_<%= @work.id%>').peSlider({range: 'min'});
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
class CreateHomeworkCommons < ActiveRecord::Migration
|
||||
def up
|
||||
create_table :homework_commons do |t|
|
||||
t.string :name
|
||||
t.integer :user_id
|
||||
t.text :description
|
||||
t.date :publish_time
|
||||
t.date :end_time
|
||||
t.integer :homework_type, default: 1
|
||||
t.string :late_penalty
|
||||
t.integer :course_id
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
drop_table :homework_commons
|
||||
end
|
||||
end
|
@ -0,0 +1,19 @@
|
||||
class CreateHomeworkDetailManuals < ActiveRecord::Migration
|
||||
def up
|
||||
create_table :homework_detail_manuals do |t|
|
||||
t.float :ta_proportion
|
||||
t.integer :comment_status
|
||||
t.date :evaluation_start
|
||||
t.date :evaluation_end
|
||||
t.integer :evaluation_num
|
||||
t.integer :absence_penalty, default: 1
|
||||
t.integer :homework_common_id
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
drop_table :homework_detail_manuals
|
||||
end
|
||||
end
|
@ -0,0 +1,15 @@
|
||||
class CreateHomeworkDetailProgramings < ActiveRecord::Migration
|
||||
def up
|
||||
create_table :homework_detail_programings do |t|
|
||||
t.string :language
|
||||
t.text :standard_code, :limit => 4294967295
|
||||
t.integer :homework_common_id
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
drop_table :homework_detail_programings
|
||||
end
|
||||
end
|
@ -0,0 +1,15 @@
|
||||
class CreateHomeworkTests < ActiveRecord::Migration
|
||||
def up
|
||||
create_table :homework_tests do |t|
|
||||
t.text :input
|
||||
t.text :output
|
||||
t.integer :homework_common_id
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
drop_table :homework_tests
|
||||
end
|
||||
end
|
@ -0,0 +1,21 @@
|
||||
class CreateStudentWorks < ActiveRecord::Migration
|
||||
def up
|
||||
create_table :student_works do |t|
|
||||
t.string :name
|
||||
t.text :description
|
||||
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.timestamps
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
drop_table :student_works
|
||||
end
|
||||
end
|
@ -0,0 +1,14 @@
|
||||
class CreateStudentWorksEvaluationDistributions < ActiveRecord::Migration
|
||||
def up
|
||||
create_table :student_works_evaluation_distributions do |t|
|
||||
t.integer :student_work_id
|
||||
t.integer :user_id
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
drop_table :student_works_evaluation_distributions
|
||||
end
|
||||
end
|
@ -0,0 +1,16 @@
|
||||
class CreateStudentWorksScores < ActiveRecord::Migration
|
||||
def up
|
||||
create_table :student_works_scores do |t|
|
||||
t.integer :student_work_id
|
||||
t.integer :user_id
|
||||
t.integer :score
|
||||
t.text :comment
|
||||
t.integer :reviewer_role
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
drop_table :student_works_scores
|
||||
end
|
||||
end
|
@ -0,0 +1,126 @@
|
||||
#encoding=UTF-8
|
||||
class AboutHomework < ActiveRecord::Migration
|
||||
def up
|
||||
Bid.where("reward_type = 3").each do |bid|
|
||||
transaction do
|
||||
if bid.courses.first
|
||||
# 作品基础属性
|
||||
homework = HomeworkCommon.new
|
||||
homework.name = bid.name
|
||||
homework.description = bid.description
|
||||
homework.user_id = bid.author_id
|
||||
homework.end_time = bid.deadline
|
||||
homework.publish_time = bid.deadline
|
||||
bid.open_anonymous_evaluation == 1 ? homework.homework_type = 1 : homework.homework_type = 0
|
||||
homework.late_penalty = 0
|
||||
homework.course_id = bid.courses.first.id
|
||||
homework.created_at = bid.created_on
|
||||
homework.updated_at = bid.updated_on
|
||||
homework.save
|
||||
|
||||
#个人动态
|
||||
bid.acts.each do |act|
|
||||
act.act_type = homework.class.to_s
|
||||
act.act_id = homework.id
|
||||
act.save
|
||||
end
|
||||
|
||||
#作业附件
|
||||
bid.attachments.each do |attach|
|
||||
attach.container = homework
|
||||
attach.save
|
||||
end
|
||||
|
||||
# 匿评作业相关属性
|
||||
homework_detail_manual = HomeworkDetailManual.new
|
||||
homework_detail_manual.ta_proportion = 0.6
|
||||
homework_detail_manual.comment_status = bid.comment_status + 1
|
||||
homework_detail_manual.evaluation_start = bid.created_on
|
||||
homework_detail_manual.evaluation_end = bid.created_on
|
||||
homework_detail_manual.evaluation_num = bid.evaluation_num
|
||||
homework_detail_manual.absence_penalty = 0
|
||||
homework_detail_manual.homework_common = homework
|
||||
homework_detail_manual.save
|
||||
|
||||
#作品列表
|
||||
bid.homeworks.each do |homework_attach|
|
||||
student_work = StudentWork.new
|
||||
student_work.name = homework_attach.name
|
||||
student_work.description = homework_attach.description
|
||||
student_work.user_id = homework_attach.user_id
|
||||
student_work.project_id = homework_attach.project_id
|
||||
student_work.homework_common = homework
|
||||
student_work.save
|
||||
|
||||
#作品文件
|
||||
homework_attach.attachments.each do |attach|
|
||||
attach.container = student_work
|
||||
attach.save
|
||||
end
|
||||
|
||||
#作品匿评列表
|
||||
homework_attach.homework_evaluations.each do |homework_evaluation|
|
||||
student_work_evaluation = StudentWorksEvaluationDistribution.new
|
||||
student_work_evaluation.user_id = homework_evaluation.user_id
|
||||
student_work_evaluation.student_work = student_work
|
||||
student_work_evaluation.save
|
||||
end
|
||||
|
||||
#评分评论相关
|
||||
stars_reates = homework_attach.rates(:quality)
|
||||
if stars_reates
|
||||
stars_reates.each do |reate|
|
||||
student_work_score = StudentWorksScore.new
|
||||
student_work_score.user_id = reate.rater_id
|
||||
student_work_score.score = reate.stars * 20
|
||||
student_work_score.student_work = student_work
|
||||
rater = User.find reate.rater_id
|
||||
if rater
|
||||
member = rater.members.where("course_id = ?",bid.courses.first.id).first
|
||||
if member
|
||||
role = member.roles.first.name
|
||||
case role
|
||||
when "Teacher"
|
||||
student_work_score.reviewer_role = 1
|
||||
when "Manager"
|
||||
student_work_score.reviewer_role = 1
|
||||
when "TeachingAsistant"
|
||||
student_work_score.reviewer_role = 2
|
||||
when "Student"
|
||||
student_work_score.reviewer_role = 3
|
||||
end
|
||||
else
|
||||
student_work_score.reviewer_role = 3
|
||||
end
|
||||
else
|
||||
student_work_score.reviewer_role = 3
|
||||
end
|
||||
|
||||
jour = homework_attach.journals_for_messages.where("is_comprehensive_evaluation = 1 and user_id = #{reate.rater_id}").order("created_on DESC").first
|
||||
if jour
|
||||
student_work_score.comment = jour.notes
|
||||
student_work_score.save
|
||||
#老师反馈附件
|
||||
homework_attach.attachments.each do |attach|
|
||||
attach.container = student_work_score
|
||||
attach.save
|
||||
end
|
||||
else
|
||||
student_work_score.save
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
HomeworkCommon.destroy_all
|
||||
HomeworkDetailManual.destroy_all
|
||||
StudentWork.destroy_all
|
||||
StudentWorksScore.destroy_all
|
||||
StudentWorksEvaluationDistribution.destroy_all
|
||||
end
|
||||
end
|
@ -0,0 +1,60 @@
|
||||
class AddScoreToWork < ActiveRecord::Migration
|
||||
require 'bigdecimal'
|
||||
|
||||
def up
|
||||
count = StudentWork.all.count / 10 + 1
|
||||
transaction do
|
||||
for i in 1 ... count do i
|
||||
StudentWork.page(i).per(10).each do |work|
|
||||
teacher_score = work.student_works_scores.where(:reviewer_role => 1).order("created_at desc")
|
||||
unless teacher_score.empty?
|
||||
work.teacher_score = teacher_score.first.score
|
||||
end
|
||||
|
||||
teaching_asistant_score = work.student_works_scores.where(:reviewer_role => 2)
|
||||
unless teaching_asistant_score.empty?
|
||||
work.teaching_asistant_score = teaching_asistant_score.average(:score).try(:round, 2).to_f
|
||||
end
|
||||
|
||||
student_socre = work.student_works_scores.where(:reviewer_role => 3)
|
||||
unless student_socre.empty?
|
||||
work.student_score = student_socre.average(:score).try(:round, 2).to_f
|
||||
end
|
||||
|
||||
if work.teacher_score.nil?
|
||||
if work.teaching_asistant_score.nil? #教辅评分为空,最终评分为学生匿评
|
||||
work.final_score = work.student_score
|
||||
elsif work.student_score.nil? #学生匿评评分为空,最终评分为教辅评分
|
||||
work.final_score = work.teaching_asistant_score
|
||||
else #都不为空,按比例来
|
||||
final_ta_score = BigDecimal.new("#{work.teaching_asistant_score}") * BigDecimal.new("0.6")
|
||||
final_s_score = BigDecimal.new("#{work.student_score}") * BigDecimal.new('0.4')
|
||||
final_score = final_ta_score + final_s_score
|
||||
work.final_score = format("%.2f",final_score.to_f)
|
||||
end
|
||||
else #教师评分不为空,最终评分为教师评分
|
||||
work.final_score = work.teacher_score
|
||||
end
|
||||
work.save
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
def down
|
||||
count = StudentWork.all.count / 10 + 1
|
||||
transaction do
|
||||
for i in 1 ... count do i
|
||||
StudentWork.page(i).per(10).each do |work|
|
||||
work.teacher_score = nil
|
||||
work.teaching_asistant_score = nil
|
||||
work.student_score = nil
|
||||
work.final_score = nil
|
||||
work.save
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,7 @@
|
||||
class RemoveBidActivity < ActiveRecord::Migration
|
||||
def change
|
||||
Activity.where(:act_type => "Bid").each do |act|
|
||||
act.destroy
|
||||
end
|
||||
end
|
||||
end
|
After Width: | Height: | Size: 281 B |
After Width: | Height: | Size: 18 KiB |
File diff suppressed because it is too large
Load Diff
Loading…
Reference in new issue