dev_new_shixunsrepository
daiao 5 years ago
commit 068dae771b

@ -976,7 +976,7 @@ class HomeworkCommonsController < ApplicationController
elsif homework.max_group_end_time elsif homework.max_group_end_time
homework.end_time = homework.max_group_end_time homework.end_time = homework.max_group_end_time
end end
homework.homework_detail_manual.update_attribute('comment_status', 1) homework.homework_detail_manual.update_attributes!(comment_status: 1)
if homework.course_acts.size == 0 if homework.course_acts.size == 0
homework.course_acts << CourseActivity.new(user_id: homework.user_id, course_id: homework.course_id) homework.course_acts << CourseActivity.new(user_id: homework.user_id, course_id: homework.course_id)
@ -1004,7 +1004,7 @@ class HomeworkCommonsController < ApplicationController
if homework.end_time > Time.now && homework.homework_detail_manual.try(:comment_status) > 1 if homework.end_time > Time.now && homework.homework_detail_manual.try(:comment_status) > 1
homework.homework_detail_manual.update_attribute("comment_status", 1) homework.homework_detail_manual.update_attributes!(comment_status: 1)
end end
# 补交结束时间 # 补交结束时间
@ -1071,7 +1071,7 @@ class HomeworkCommonsController < ApplicationController
homework.end_time = homework.max_group_end_time homework.end_time = homework.max_group_end_time
if homework.end_time > time && homework_detail_manual.try(:comment_status) > 1 if homework.end_time > time && homework_detail_manual.try(:comment_status) > 1
homework_detail_manual.update_attribute("comment_status", 1) homework_detail_manual.update_attributes!(comment_status: 1)
end end
# 统一设置 # 统一设置
@ -1080,7 +1080,7 @@ class HomeworkCommonsController < ApplicationController
homework.end_time = time homework.end_time = time
end end
homework_detail_manual.update_attribute("comment_status", 2) if homework.end_time <= time homework_detail_manual.update_attributes!(comment_status: 2) if homework.end_time <= time
# 实训作业的作品需要计算是否迟交 # 实训作业的作品需要计算是否迟交
if homework.homework_type == "practice" if homework.homework_type == "practice"

@ -48,7 +48,7 @@ class PollVotesController < ApplicationController
ques_vote_id = question_answer_ids.map(&:to_i).max ques_vote_id = question_answer_ids.map(&:to_i).max
ques_vote = user_votes.find_by(poll_answer_id: ques_vote_id) ques_vote = user_votes.find_by(poll_answer_id: ques_vote_id)
if ques_vote.present? if ques_vote.present?
ques_vote.update_attribute!("vote_text", question_answer_text) ques_vote.update_attributes!(vote_text: question_answer_text)
else else
answer_option = { answer_option = {
:user_id => current_user.id, :user_id => current_user.id,

@ -68,7 +68,7 @@ class StudentWorksController < ApplicationController
begin begin
work = @homework.student_works.find_by!(user_id: params[:user_id]) work = @homework.student_works.find_by!(user_id: params[:user_id])
tip_exception("只有组长才能删除组员") if work.commit_user_id != current_user.id tip_exception("只有组长才能删除组员") if work.commit_user_id != current_user.id
work.update_attributes(description: nil, project_id: 0, work.update_attributes!(description: nil, project_id: 0,
late_penalty: 0, work_status: 0, late_penalty: 0, work_status: 0,
commit_time: nil, update_time: nil, group_id: 0, commit_time: nil, update_time: nil, group_id: 0,
commit_user_id: nil, final_score: nil, work_score: nil, teacher_score: nil, teaching_asistant_score: nil) commit_user_id: nil, final_score: nil, work_score: nil, teacher_score: nil, teaching_asistant_score: nil)
@ -112,7 +112,7 @@ class StudentWorksController < ApplicationController
student_ids += members student_ids += members
for i in 0 .. members.count-1 for i in 0 .. members.count-1
stu_work = @homework.student_works.find_or_initialize_by(user_id: members[i].to_i) stu_work = @homework.student_works.find_or_initialize_by(user_id: members[i].to_i)
stu_work.update_attributes(user_id: members[i].to_i, description: student_work.description, stu_work.update_attributes!(user_id: members[i].to_i, description: student_work.description,
homework_common_id: @homework.id, project_id: student_work.project_id, homework_common_id: @homework.id, project_id: student_work.project_id,
late_penalty: student_work.late_penalty, work_status: student_work.work_status, late_penalty: student_work.late_penalty, work_status: student_work.work_status,
commit_time: Time.now, update_time: Time.now, group_id: student_work.group_id, commit_time: Time.now, update_time: Time.now, group_id: student_work.group_id,
@ -177,7 +177,7 @@ class StudentWorksController < ApplicationController
# 原成员更新描述、更新时间以及附件 # 原成员更新描述、更新时间以及附件
@homework.student_works.where(group_id: @work.group_id, user_id: (work_user_ids & params_user_ids)).each do |work| @homework.student_works.where(group_id: @work.group_id, user_id: (work_user_ids & params_user_ids)).each do |work|
# work.update_attributes(update_time: Time.now, description: @work.description, commit_user_id: current_user.id) # work.update_attributes(update_time: Time.now, description: @work.description, commit_user_id: current_user.id)
work.update_attributes(update_time: Time.now, description: @work.description, update_user_id: current_user.id) work.update_attributes!(update_time: Time.now, description: @work.description, update_user_id: current_user.id)
work.attachments.destroy_all work.attachments.destroy_all
@work.attachments.each do |attachment| @work.attachments.each do |attachment|
att = attachment.copy att = attachment.copy
@ -202,7 +202,7 @@ class StudentWorksController < ApplicationController
# 新增加的成员 # 新增加的成员
(params_user_ids - work_user_ids).each do |user_id| (params_user_ids - work_user_ids).each do |user_id|
stu_work = @homework.student_works.find_or_initialize_by(user_id: user_id) stu_work = @homework.student_works.find_or_initialize_by(user_id: user_id)
stu_work.update_attributes(user_id: user_id, description: @work.description, homework_common_id: @homework.id, stu_work.update_attributes!(user_id: user_id, description: @work.description, homework_common_id: @homework.id,
project_id: @work.project_id, late_penalty: @work.late_penalty, project_id: @work.project_id, late_penalty: @work.late_penalty,
work_status: @work.work_status, commit_time: Time.now, update_time: Time.now, work_status: @work.work_status, commit_time: Time.now, update_time: Time.now,
group_id: @work.group_id, commit_user_id: @work.commit_user_id, update_user_id: current_user.id) group_id: @work.group_id, commit_user_id: @work.commit_user_id, update_user_id: current_user.id)
@ -257,12 +257,12 @@ class StudentWorksController < ApplicationController
work = @homework.student_works.find_or_create_by(user_id: current_user.id) work = @homework.student_works.find_or_create_by(user_id: current_user.id)
if work.work_status == 0 && work.project_id == 0 if work.work_status == 0 && work.project_id == 0
work.update_attributes(project_id: project.id, update_time: Time.now) work.update_attributes!(project_id: project.id, update_time: Time.now)
# 将老师加入项目 # 将老师加入项目
project_member = project.members.find_by_user_id(@homework.user_id) project_member = project.members.find_by_user_id(@homework.user_id)
if project_member.present? if project_member.present?
project_member.member_roles.take.update_attributes(role_id: 3) if project_member.member_roles.take.present? project_member.member_roles.take.update_attributes!(role_id: 3) if project_member.member_roles.take.present?
else else
member = Member.create(user_id: @homework.user_id, project_id: project.id) member = Member.create(user_id: @homework.user_id, project_id: project.id)
member.member_roles << MemberRole.new(role_id: 3) member.member_roles << MemberRole.new(role_id: 3)
@ -295,7 +295,7 @@ class StudentWorksController < ApplicationController
Tiding.where(user_id: @homework.user_id, trigger_user_id: current_user.id, container_id: work.project.id, Tiding.where(user_id: @homework.user_id, trigger_user_id: current_user.id, container_id: work.project.id,
container_type: 'ManagerJoinProject').destroy_all container_type: 'ManagerJoinProject').destroy_all
work.update_attributes(project_id: 0) work.update_attributes!(project_id: 0)
normal_status(0,"取消关联成功") normal_status(0,"取消关联成功")
rescue Exception => e rescue Exception => e
@ -329,9 +329,9 @@ class StudentWorksController < ApplicationController
# end # end
Attachment.associate_container(params[:attachment_ids], @work.id, @work.class, 7) Attachment.associate_container(params[:attachment_ids], @work.id, @work.class, 7)
revise_attachment = Attachment.where(attachtype: 7, container_id: @work.id, container_type: "StudentWork").last revise_attachment = Attachment.where(attachtype: 7, container_id: @work.id, container_type: "StudentWork").last
revise_attachment.update_attributes(description: params[:description]) if revise_attachment.present? revise_attachment.update_attributes!(description: params[:description]) if revise_attachment.present?
@work.update_attributes(update_time: Time.now) @work.update_attributes!(update_time: Time.now)
# 补交附件时给评阅过作品的教师、助教发消息 # 补交附件时给评阅过作品的教师、助教发消息
unless @work.student_works_scores.where.not(score: nil).where(reviewer_role: [1, 2]).pluck(:user_id).uniq.blank? unless @work.student_works_scores.where.not(score: nil).where(reviewer_role: [1, 2]).pluck(:user_id).uniq.blank?
@ -376,9 +376,9 @@ class StudentWorksController < ApplicationController
# 如果作品是未提交的状态则更新为已提交 # 如果作品是未提交的状态则更新为已提交
if @user_course_identity < Course::STUDENT && !new_score.score.nil? && @work.work_status == 0 if @user_course_identity < Course::STUDENT && !new_score.score.nil? && @work.work_status == 0
@work.update_attributes(work_status: 1, commit_time: Time.now) @work.update_attributes!(work_status: 1, commit_time: Time.now)
# 分组作业更新分组id # 分组作业更新分组id
@work.update_attributes(group_id: @homework.max_group_id) if @homework.homework_type == "group" @work.update_attributes!(group_id: @homework.max_group_id) if @homework.homework_type == "group"
end end
new_score.reviewer_role = reviewer_role new_score.reviewer_role = reviewer_role
@ -442,7 +442,7 @@ class StudentWorksController < ApplicationController
# 实训作品的总结 # 实训作品的总结
def update_des def update_des
@work.update_attributes(des_params) @work.update_attributes!(des_params)
tip_exception(0, "提交成功") tip_exception(0, "提交成功")
end end
@ -590,7 +590,7 @@ class StudentWorksController < ApplicationController
begin begin
score = @work.student_works_scores.find_by!(id: params[:score_id]) score = @work.student_works_scores.find_by!(id: params[:score_id])
jour = score.journals_for_messages.new(user_id: current_user.id, notes: params[:comment], reply_id: score.user_id) jour = score.journals_for_messages.new(user_id: current_user.id, notes: params[:comment], reply_id: score.user_id)
jour.save jour.save!
normal_status(0,"回复成功") normal_status(0,"回复成功")
rescue Exception => e rescue Exception => e
uid_logger(e.message) uid_logger(e.message)
@ -624,7 +624,7 @@ class StudentWorksController < ApplicationController
score_appeal = nil score_appeal = nil
ActiveRecord::Base.transaction do ActiveRecord::Base.transaction do
begin begin
score.update_attributes(appeal_status: 1) score.update_attributes!(appeal_status: 1)
score_appeal = StudentWorksScoresAppeal.create!(user_id: current_user.id, student_works_score_id: score.id, score_appeal = StudentWorksScoresAppeal.create!(user_id: current_user.id, student_works_score_id: score.id,
comment: params[:comment], appeal_status: 1) comment: params[:comment], appeal_status: 1)
@ -645,9 +645,9 @@ class StudentWorksController < ApplicationController
if score.present? && score.appeal_status == 1 if score.present? && score.appeal_status == 1
ActiveRecord::Base.transaction do ActiveRecord::Base.transaction do
begin begin
score.update_attributes(appeal_status: 2) score.update_attributes!(appeal_status: 2)
score_appeal = score.student_works_scores_appeal score_appeal = score.student_works_scores_appeal
score_appeal.update_attributes(appeal_status: 2) score_appeal.update_attributes!(appeal_status: 2)
score_appeal.tidings.destroy_all score_appeal.tidings.destroy_all
normal_status(0,"撤销成功") normal_status(0,"撤销成功")
rescue Exception => e rescue Exception => e
@ -670,18 +670,18 @@ class StudentWorksController < ApplicationController
ActiveRecord::Base.transaction do ActiveRecord::Base.transaction do
begin begin
# 更新appeal_status的值 # 更新appeal_status的值
score.update_attributes(appeal_status: params[:status].to_i) score.update_attributes!(appeal_status: params[:status].to_i)
score_appeal = score.student_works_scores_appeal score_appeal = score.student_works_scores_appeal
score_appeal.update_attributes(appeal_status: params[:status].to_i) score_appeal.update_attributes!(appeal_status: params[:status].to_i)
score_appeal.tidings.update_all(status: 1) score_appeal.tidings.update_all(status: 1)
if params[:status].to_i == 3 if params[:status].to_i == 3
# 申诉成功后该评分失效 # 申诉成功后该评分失效
score.update_attributes(is_invalid: 1) score.update_attributes!(is_invalid: 1)
# 申诉成功后 扣匿评学生的违规匿评扣分 # 申诉成功后 扣匿评学生的违规匿评扣分
sw = @homework.student_works.find_by(user_id: score.user_id) sw = @homework.student_works.find_by(user_id: score.user_id)
sw.update_attribute("appeal_penalty", @homework.homework_detail_manual.appeal_penalty + sw.appeal_penalty) if sw.present? sw.update_attributes!(appeal_penalty: @homework.homework_detail_manual.appeal_penalty + sw.appeal_penalty) if sw.present?
# 申诉成功 重新计算申诉者的匿评分 # 申诉成功 重新计算申诉者的匿评分
if @work.student_works_scores.where("reviewer_role = 3 AND appeal_status != 3").count > 0 if @work.student_works_scores.where("reviewer_role = 3 AND appeal_status != 3").count > 0
@ -689,7 +689,7 @@ class StudentWorksController < ApplicationController
else else
@work.student_score = nil @work.student_score = nil
end end
@work.save @work.save!
end end
# todo tiding # todo tiding
@ -862,7 +862,7 @@ class StudentWorksController < ApplicationController
else else
st_work.student_score = student_work.student_score st_work.student_score = student_work.student_score
end end
st_work.save st_work.save!
Tiding.create(user_id: st_work.user_id, trigger_user_id: current_user.id, container_id: st_score.id, Tiding.create(user_id: st_work.user_id, trigger_user_id: current_user.id, container_id: st_score.id,
container_type: "StudentWorksScore", parent_container_id: st_work.id, parent_container_type: "StudentWork", container_type: "StudentWorksScore", parent_container_id: st_work.id, parent_container_type: "StudentWork",

@ -75,7 +75,7 @@ zh-CN:
reference_answer: '参考答案' reference_answer: '参考答案'
student_work: student_work:
description: '内容' description: '内容'
student_work_score: student_works_score:
comment: '评语' comment: '评语'
challenge_work_score: challenge_work_score:
comment: '评语' comment: '评语'

Loading…
Cancel
Save