From e4046851cf58680f34f95f71f57fd9412cd08995 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Tue, 2 Jun 2015 09:33:34 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E4=BD=9C=E5=93=81=E5=88=97=E8=A1=A8?= =?UTF-8?q?=20=20=20=E5=AD=A6=E5=8F=B7=E3=80=81=E5=A7=93=E5=90=8D=E8=BF=87?= =?UTF-8?q?=E9=95=BF=E4=BC=9A=E6=8D=A2=E8=A1=8C=202=E3=80=81=E4=BD=9C?= =?UTF-8?q?=E5=93=81=E4=BD=9C=E4=B8=9A=E7=9B=B8=E5=85=B3=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E8=BF=81=E7=A7=BB=203=E3=80=81student=5Fwork=E7=BC=BA=E5=B0=91?= =?UTF-8?q?=E5=AD=97=E6=AE=B5project=5Fid?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/student_work.rb | 2 +- db/migrate/20150601032112_about_homework.rb | 119 ++++++++++++++++++++ db/schema.rb | 14 +-- public/stylesheets/courses.css | 4 +- 4 files changed, 129 insertions(+), 10 deletions(-) create mode 100644 db/migrate/20150601032112_about_homework.rb diff --git a/app/models/student_work.rb b/app/models/student_work.rb index c8e69a4a3..e2be18423 100644 --- a/app/models/student_work.rb +++ b/app/models/student_work.rb @@ -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 diff --git a/db/migrate/20150601032112_about_homework.rb b/db/migrate/20150601032112_about_homework.rb new file mode 100644 index 000000000..317748741 --- /dev/null +++ b/db/migrate/20150601032112_about_homework.rb @@ -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 diff --git a/db/schema.rb b/db/schema.rb index 4c6be4b35..a55201b4b 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 => 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| diff --git a/public/stylesheets/courses.css b/public/stylesheets/courses.css index 4f8708120..9d0df5d55 100644 --- a/public/stylesheets/courses.css +++ b/public/stylesheets/courses.css @@ -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;}