加入题库报错

dev_haigong
cxt 6 years ago
parent 904880044c
commit b66140bcfe

@ -1677,7 +1677,8 @@ class StudentWorkController < ApplicationController
def student_work_project def student_work_project
project = Project.where(:id => params[:projectName].to_i).first project = Project.where(:id => params[:projectName].to_i).first
if project.present? if project.present?
@work = @homework.student_works.where("user_id = #{User.current.id} and work_status = 0").first @work = @homework.student_works.where("user_id = #{User.current.id} and work_status = 0").first ||
StudentWork.create(homework_common_id: @homework.id, user_id: User.current.id)
if @work if @work
@work.update_column('project_id', params[:projectName].to_i) @work.update_column('project_id', params[:projectName].to_i)
end end

@ -6920,6 +6920,7 @@ def quote_resource_bank resource, course
end end
def quote_homework_bank homework, course def quote_homework_bank homework, course
ActiveRecord::Base.transaction do
new_homework = HomeworkCommon.new(:name => homework.name, :user_id => User.current.id, :description => homework.description, :homework_type => homework.homework_type, :late_penalty => 5, new_homework = HomeworkCommon.new(:name => homework.name, :user_id => User.current.id, :description => homework.description, :homework_type => homework.homework_type, :late_penalty => 5,
:course_id => course.id, :teacher_priority => 1, :anonymous_comment => 1, :quotes => 0, :is_open => 0, :homework_bank_id => homework.id, :score_open => 1, :course_id => course.id, :teacher_priority => 1, :anonymous_comment => 1, :quotes => 0, :is_open => 0, :homework_bank_id => homework.id, :score_open => 1,
:anonymous_appeal => 0, :is_public => 0, :reference_answer => homework.reference_answer, :answer_public => 1, :allow_late => 1) :anonymous_appeal => 0, :is_public => 0, :reference_answer => homework.reference_answer, :answer_public => 1, :allow_late => 1)
@ -6982,8 +6983,10 @@ def quote_homework_bank homework, course
end end
return new_homework return new_homework
end end
end
def quote_exercise_bank exercise, course def quote_exercise_bank exercise, course
ActiveRecord::Base.transaction do
new_exercise = Exercise.new(:exercise_name => exercise.name, :exercise_description => exercise.description, :user_id => User.current.id, :is_public => 0, new_exercise = Exercise.new(:exercise_name => exercise.name, :exercise_description => exercise.description, :user_id => User.current.id, :is_public => 0,
:exercise_status => 1, :show_result => 1, :course_id => course.id, :time => -1, :exercise_bank_id => exercise.id) :exercise_status => 1, :show_result => 1, :course_id => course.id, :time => -1, :exercise_bank_id => exercise.id)
@ -7032,8 +7035,10 @@ def quote_exercise_bank exercise, course
end end
return new_exercise return new_exercise
end end
end
def quote_poll_bank poll, course def quote_poll_bank poll, course
ActiveRecord::Base.transaction do
new_poll = Poll.new(:polls_name => poll.name, :polls_description => poll.description, :user_id => User.current.id, :is_public => 0, new_poll = Poll.new(:polls_name => poll.name, :polls_description => poll.description, :user_id => User.current.id, :is_public => 0,
:polls_status => 1, :show_result => 1, :polls_type => 'Course', :course_id => course.id, :exercise_bank_id => poll.id) :polls_status => 1, :show_result => 1, :polls_type => 'Course', :course_id => course.id, :exercise_bank_id => poll.id)
@ -7063,6 +7068,7 @@ def quote_poll_bank poll, course
end end
return new_poll return new_poll
end end
end
def major_level_option def major_level_option
content = [] content = []

@ -15,7 +15,7 @@ class HomeworkCommon < ActiveRecord::Base
belongs_to :homework_bank belongs_to :homework_bank
has_many :homework_group_settings, :dependent => :destroy has_many :homework_group_settings, :dependent => :destroy
has_one :homework_detail_manual, :dependent => :destroy has_one :homework_detail_manual, :dependent => :destroy
# has_one :homework_detail_programing, :dependent => :destroy has_one :homework_detail_programing, :dependent => :destroy
has_one :homework_detail_group, :dependent => :destroy has_one :homework_detail_group, :dependent => :destroy
has_one :homework_commons_shixuns, :dependent => :destroy has_one :homework_commons_shixuns, :dependent => :destroy
has_many :homework_challenge_settings, :dependent => :destroy has_many :homework_challenge_settings, :dependent => :destroy

@ -113,7 +113,7 @@
<% elsif work.present? && work.try(:work_status) != 0 %> <% elsif work.present? && work.try(:work_status) != 0 %>
<%= link_to "查看作品", student_work_path(work), :class => 'white-btn orange-btn fr mr20 mt8', :target => "_blank" %> <%= link_to "查看作品", student_work_path(work), :class => 'white-btn orange-btn fr mr20 mt8', :target => "_blank" %>
<% elsif ((work.present? && work.try(:work_status) == 0) || work.nil?) && setting_time.end_time > Time.now %> <% elsif ((work.present? && work.try(:work_status) == 0) || work.nil?) && setting_time.end_time > Time.now %>
<% if homework_common.homework_type == 3 && homework_common.homework_detail_group.base_on_project == 1 && (work.project_id.nil? || work.project_id == 0 || work.project_id = -1) %> <% if homework_common.homework_type == 3 && homework_common.homework_detail_group.base_on_project == 1 && (work.try(:project_id).nil? || work.try(:project_id) == 0 || work.try(:project_id) == -1) %>
<%= link_to "关联项目", new_student_work_project_student_work_index_path(:homework => homework_common.id, :user_activity_id=> homework_common.id, :hw_status => 1), :remote => true, :class=> 'white-btn orange-btn fr mr20 mt8', :title=> '请各组长关联作业项目' %> <%= link_to "关联项目", new_student_work_project_student_work_index_path(:homework => homework_common.id, :user_activity_id=> homework_common.id, :hw_status => 1), :remote => true, :class=> 'white-btn orange-btn fr mr20 mt8', :title=> '请各组长关联作业项目' %>
<% else %> <% else %>
<%= link_to "提交作品", new_student_work_path(:homework => homework_common.id), :class => 'white-btn orange-btn fr mr20 mt8', :target => "_blank" %> <%= link_to "提交作品", new_student_work_path(:homework => homework_common.id), :class => 'white-btn orange-btn fr mr20 mt8', :target => "_blank" %>

Loading…
Cancel
Save