1、作品列表 学号、姓名过长会换行

2、作品作业相关数据迁移
3、student_work缺少字段project_id
This commit is contained in:
sw 2015-06-02 09:33:34 +08:00
parent 007aa00174
commit e4046851cf
4 changed files with 129 additions and 10 deletions

View File

@ -1,6 +1,6 @@
#学生提交作品表
class StudentWork < ActiveRecord::Base
attr_accessible :name, :description, :homework_common_id, :user_id, :final_score, :teacher_score, :student_score, :teaching_asistant_score
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

View File

@ -0,0 +1,119 @@
#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.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

View File

@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20150519030544) do
ActiveRecord::Schema.define(:version => 20150601032112) do
create_table "activities", :force => true do |t|
t.integer "act_id", :null => false
@ -1203,13 +1203,13 @@ ActiveRecord::Schema.define(:version => 20150519030544) do
t.text "description"
t.integer "homework_common_id"
t.integer "user_id"
t.float "final_score", :default => 0.0
t.float "teacher_score", :default => 0.0
t.float "student_score", :default => 0.0
t.float "teaching_asistant_score", :default => 0.0
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.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
create_table "student_works_evaluation_distributions", :force => true do |t|

View File

@ -639,8 +639,8 @@ a:hover.icon_add{background:url(images/icons.png) -20px -310px no-repeat;}
.hwork_tit_e a{ width:455px; display:block; overflow:hidden; white-space: nowrap; text-overflow:ellipsis; }
.hwork_code{ width:60px; text-align:center; margin-right:15px;}
.hwork_code02{ width:60px; text-align:center; margin-right:10px;}
a.hwork_center{ display:block; width:60px; text-align:center; margin-right:5px;overflow: hidden;}
a.hwork_name{ display:block;width:65px; text-align:center; margin-right:10px;overflow: hidden;}
a.hwork_center{ display:block; width:60px; text-align:center; margin-right:5px;overflow: hidden; white-space: nowrap; text-overflow:ellipsis;}
a.hwork_name{ display:block;width:65px; text-align:center; margin-right:10px;overflow: hidden;white-space: nowrap; text-overflow:ellipsis;min-height: 1px;}
.show_hwork{ border:2px solid #64bdd9; width:646px; padding:10px; color:#666666; padding-bottom:0px; }
.show_hwork ul li{ margin-bottom:5px;}
.show_hwork_arrow{ position:relative; top:2px; left:25px;background:url(../images/course/arrow_up.jpg) 0 0 no-repeat; width:20px; height:11px;}