Merge branch 'develop' of https://git.trustie.net/jacknudt/trustieforge into dev_raining
This commit is contained in:
commit
f4ea11c4c2
|
@ -22,6 +22,34 @@ class ContestsController < ApplicationController
|
|||
update_messsages_to_viewed("ContestMessage", @contest)
|
||||
@left_nav_type = 1
|
||||
|
||||
contest_activities = @contest.contest_activities
|
||||
@page = params[:page] ? params[:page].to_i + 1 : 0
|
||||
if params[:type].present?
|
||||
case params[:type]
|
||||
when "work"
|
||||
@contest_activities = contest_activities.where("contest_act_type = 'Work'").order('updated_at desc')
|
||||
when "news"
|
||||
@contest_activities = contest_activities.where("contest_act_type = 'News'").order('updated_at desc')
|
||||
when "message"
|
||||
@contest_activities = contest_activities.where("contest_act_type = 'Message'").order('updated_at desc')
|
||||
when "poll"
|
||||
@contest_activities = contest_activities.where("contest_act_type = 'Poll'").order('updated_at desc')
|
||||
when "attachment"
|
||||
@contest_activities = contest_activities.where("contest_act_type = 'Attachment'").order('updated_at desc')
|
||||
when "journalsForMessage"
|
||||
@contest_activities = contest_activities.where("contest_act_type = 'JournalsForMessage'").order('updated_at desc')
|
||||
when "news"
|
||||
@contest_activities = contest_activities.where("contest_act_type = 'News'").order('updated_at desc')
|
||||
else
|
||||
@contest_activities = contest_activities.order('updated_at desc')
|
||||
end
|
||||
else
|
||||
@contest_activities = contest_activities.order('updated_at desc')
|
||||
end
|
||||
@contest_activities_count = @contest_activities.count
|
||||
@contest_activities = @contest_activities.limit(10).offset(@page * 10)
|
||||
@type = params[:type]
|
||||
|
||||
respond_to do |format|
|
||||
format.js
|
||||
format.html
|
||||
|
|
|
@ -553,7 +553,7 @@ class CoursesController < ApplicationController
|
|||
@all_members = searchmember_by_name(student_homework_score(0, 0, 10,"desc"), q)
|
||||
end
|
||||
|
||||
@homeworks = @course.homework_commons.where("publish_time <= '#{Date.today}'").order("created_at asc")
|
||||
@homeworks = @course.homework_commons.where("publish_time <= '#{Time.now}'").order("created_at asc")
|
||||
filename="#{@course.teacher.lastname.to_s + @course.teacher.firstname.to_s }_#{@course.name}_#{@course.time.to_s + @course.term}#{l(:excel_member_list)}";
|
||||
|
||||
respond_to do |format|
|
||||
|
@ -756,8 +756,8 @@ class CoursesController < ApplicationController
|
|||
new_homework.name = homework.name
|
||||
new_homework.user_id = User.current.id
|
||||
new_homework.description = homework.description
|
||||
new_homework.publish_time = Date.today + 30
|
||||
new_homework.end_time = Date.today + 60
|
||||
new_homework.publish_time = Time.now + 30.days
|
||||
new_homework.end_time = Time.now + 60
|
||||
new_homework.homework_type = homework.homework_type
|
||||
new_homework.late_penalty = homework.late_penalty
|
||||
new_homework.course_id = @course.id
|
||||
|
@ -821,7 +821,7 @@ class CoursesController < ApplicationController
|
|||
attach_copied_obj.author_id = User.current.id
|
||||
attach_copied_obj.copy_from = attachment.copy_from.nil? ? attachment.id : attachment.copy_from
|
||||
attach_copied_obj.is_publish = 0
|
||||
attach_copied_obj.publish_time = Date.today + 30
|
||||
attach_copied_obj.publish_time = Time.now + 30.days
|
||||
if attach_copied_obj.attachtype == nil
|
||||
attach_copied_obj.attachtype = 4
|
||||
end
|
||||
|
@ -1407,7 +1407,7 @@ class CoursesController < ApplicationController
|
|||
if @is_teacher
|
||||
@homeworks = @course.homework_commons.where("name like '%#{@search}%'").order("created_at desc").limit(10).offset(@page * 10)
|
||||
else
|
||||
@homeworks = @course.homework_commons.where("name like '%#{@search}%' and publish_time <= '#{Date.today}'").order("created_at desc").limit(10).offset(@page * 10)
|
||||
@homeworks = @course.homework_commons.where("name like '%#{@search}%' and publish_time <= '#{Time.now}'").order("created_at desc").limit(10).offset(@page * 10)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -6,8 +6,12 @@ class HomeworkCommonController < ApplicationController
|
|||
|
||||
include StudentWorkHelper
|
||||
before_filter :find_course, :only => [:index,:new,:create]
|
||||
before_filter :find_homework, :only => [:edit,:update,:alert_anonymous_comment,:start_anonymous_comment,:stop_anonymous_comment,:destroy,:start_evaluation_set,:set_evaluation_attr,:score_rule_set,:alert_forbidden_anonymous_comment,:alert_open_student_works,:open_student_works,:set_score_open,:alert_score_open_modal]
|
||||
before_filter :teacher_of_course, :only => [:new, :create, :edit, :update, :destroy, :start_anonymous_comment, :stop_anonymous_comment, :alert_anonymous_comment,:start_evaluation_set,:set_evaluation_attr,:score_rule_set,:alert_forbidden_anonymous_comment,:alert_open_student_works,:open_student_works]
|
||||
before_filter :find_homework, :only => [:edit,:update,:alert_anonymous_comment,:start_anonymous_comment,:stop_anonymous_comment,:destroy,:start_evaluation_set,
|
||||
:set_evaluation_attr,:score_rule_set,:alert_forbidden_anonymous_comment,:alert_open_student_works,:open_student_works,
|
||||
:set_score_open,:alert_score_open_modal,:add_to_homework_bank,:publish_homework]
|
||||
before_filter :teacher_of_course, :only => [:new, :create, :edit, :update, :destroy, :start_anonymous_comment, :stop_anonymous_comment, :alert_anonymous_comment,
|
||||
:start_evaluation_set,:set_evaluation_attr,:score_rule_set,:alert_forbidden_anonymous_comment,:alert_open_student_works,
|
||||
:open_student_works,:add_to_homework_bank,:publish_homework]
|
||||
before_filter :member_of_course, :only => [:index]
|
||||
|
||||
def index
|
||||
|
@ -25,7 +29,7 @@ class HomeworkCommonController < ApplicationController
|
|||
@homework_commons = @course.homework_commons.where("name like '%#{search}%'").order("created_at desc")
|
||||
else
|
||||
#@homeworks = @course.homework_commons.where("publish_time <= '#{Date.today}'").order("created_at desc").limit(10).offset(@page * 10)
|
||||
@homework_commons = @course.homework_commons.where("name like '%#{search}%' and publish_time <= '#{Date.today}'").order("created_at desc")
|
||||
@homework_commons = @course.homework_commons.where("name like '%#{search}%' and publish_time <= '#{Time.now}'").order("created_at desc")
|
||||
end
|
||||
#update_homework_time @homework_commons
|
||||
@is_student = User.current.logged? && (User.current.admin? || (User.current.member_of_course?(@course) && !@is_teacher))
|
||||
|
@ -80,89 +84,105 @@ class HomeworkCommonController < ApplicationController
|
|||
|
||||
def update
|
||||
if params[:homework_common]
|
||||
is_update = @homework.name != params[:homework_common][:name] || @homework.description != params[:homework_common][:description] || params[:homework_type].to_i != @homework.homework_type
|
||||
if params[:homework_type].to_i == 2
|
||||
is_update = is_update || params[:language_type] != @homework.homework_detail_programing.language
|
||||
if !is_update && params[:sample] && params[:program]
|
||||
is_update = params[:sample][:input] != @homework.homework_samples.map(&:input) || params[:sample][:output] != @homework.homework_samples.map(&:output) || params[:program][:input] != @homework.homework_tests.map(&:input)|| params[:program][:output] != @homework.homework_tests.map(&:output)
|
||||
end
|
||||
elsif params[:homework_type].to_i == 3
|
||||
base_on_project = params[:base_on_project] ? 1 : 0
|
||||
is_update = is_update || params[:min_num].to_i != @homework.homework_detail_group.min_num || params[:max_num].to_i != @homework.homework_detail_group.max_num || base_on_project != @homework.homework_detail_group.base_on_project
|
||||
end
|
||||
@homework.is_update = @homework.is_update || is_update
|
||||
|
||||
@homework.name = params[:homework_common][:name]
|
||||
@homework.description = params[:homework_common][:description]
|
||||
if params[:homework_common][:publish_time] == ""
|
||||
@homework.publish_time = Date.today
|
||||
else
|
||||
@homework.publish_time = params[:homework_common][:publish_time]
|
||||
end
|
||||
homework_detail_manual = @homework.homework_detail_manual || HomeworkDetailManual.new
|
||||
param_end_time = Time.parse(params[:homework_common][:end_time]).strftime("%Y-%m-%d")
|
||||
homework_end_time = @homework.end_time ? Time.parse(@homework.end_time.to_s).strftime("%Y-%m-%d") : ''
|
||||
if homework_end_time != param_end_time
|
||||
if homework_end_time > param_end_time
|
||||
@homework.student_works.where("work_status = 1").each do |st|
|
||||
if param_end_time < Time.parse(st.commit_time.to_s).strftime("%Y-%m-%d")
|
||||
st.late_penalty = @homework.late_penalty
|
||||
st.work_status = 2
|
||||
st.save
|
||||
#更新CourseHomeworkStatistics中学生的迟交作品数
|
||||
course_statistics = CourseHomeworkStatistics.find_by_course_id_and_user_id(@homework.course_id, st.user_id)
|
||||
course_statistics.update_attribute('late_commit_work_num', course_statistics.late_commit_work_num + 1) if course_statistics
|
||||
end
|
||||
end
|
||||
if params[:homework_common][:end_time] != ""
|
||||
if params[:homework_common][:publish_time] == ""
|
||||
@homework.publish_time = Time.now
|
||||
else
|
||||
@homework.student_works.where("work_status = 2").each do |st|
|
||||
if param_end_time >= Time.parse(st.commit_time.to_s).strftime("%Y-%m-%d")
|
||||
st.late_penalty = 0
|
||||
st.work_status = 1
|
||||
st.save
|
||||
#更新CourseHomeworkStatistics中学生的迟交作品数
|
||||
course_statistics = CourseHomeworkStatistics.find_by_course_id_and_user_id(@homework.course_id, st.user_id)
|
||||
course_statistics.update_attribute('late_commit_work_num', (course_statistics.late_commit_work_num - 1) < 0 ? 0 : (course_statistics.late_commit_work_num - 1)) if course_statistics
|
||||
@homework.publish_time = params[:homework_common][:publish_time]
|
||||
end
|
||||
param_end_time = Time.parse(params[:homework_common][:end_time])
|
||||
homework_end_time = @homework.end_time ? @homework.end_time : ''
|
||||
if homework_end_time != param_end_time
|
||||
if homework_end_time > param_end_time
|
||||
@homework.student_works.where("work_status = 1").each do |st|
|
||||
if param_end_time < st.commit_time
|
||||
st.late_penalty = @homework.late_penalty
|
||||
st.work_status = 2
|
||||
st.save
|
||||
#更新CourseHomeworkStatistics中学生的迟交作品数
|
||||
course_statistics = CourseHomeworkStatistics.find_by_course_id_and_user_id(@homework.course_id, st.user_id)
|
||||
course_statistics.update_attribute('late_commit_work_num', course_statistics.late_commit_work_num + 1) if course_statistics
|
||||
end
|
||||
end
|
||||
else
|
||||
@homework.student_works.where("work_status = 2").each do |st|
|
||||
if param_end_time >= Time.parse(st.commit_time.to_s).strftime("%Y-%m-%d")
|
||||
st.late_penalty = 0
|
||||
st.work_status = 1
|
||||
st.save
|
||||
#更新CourseHomeworkStatistics中学生的迟交作品数
|
||||
course_statistics = CourseHomeworkStatistics.find_by_course_id_and_user_id(@homework.course_id, st.user_id)
|
||||
course_statistics.update_attribute('late_commit_work_num', (course_statistics.late_commit_work_num - 1) < 0 ? 0 : (course_statistics.late_commit_work_num - 1)) if course_statistics
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@homework.end_time = params[:homework_common][:end_time] || Time.now
|
||||
|
||||
status = false
|
||||
if @homework.publish_time > Time.now && homework_detail_manual.comment_status == 1
|
||||
homework_detail_manual.comment_status = 0
|
||||
@homework.student_works.destroy_all
|
||||
#更新CourseHomeworkStatistics中每个学生的未交作品数
|
||||
@homework.course.student.each do |student|
|
||||
course_statistics = CourseHomeworkStatistics.find_by_course_id_and_user_id(@homework.course_id, student.student_id)
|
||||
course_statistics.update_attribute('un_commit_work_num', (course_statistics.un_commit_work_num - 1) < 0 ? 0 : (course_statistics.un_commit_work_num - 1)) if course_statistics
|
||||
end
|
||||
elsif @homework.publish_time <= Time.now && homework_detail_manual.comment_status == 0
|
||||
homework_detail_manual.comment_status = 1
|
||||
create_works_list @homework if params[:homework_type].to_i != 3
|
||||
status = true
|
||||
#更新CourseHomeworkStatistics中每个学生的未交作品数
|
||||
@homework.course.student.each do |student|
|
||||
course_statistics = CourseHomeworkStatistics.find_by_course_id_and_user_id(@homework.course_id, student.student_id)
|
||||
course_statistics.update_attribute('un_commit_work_num', course_statistics.un_commit_work_num + 1) if course_statistics
|
||||
end
|
||||
end
|
||||
|
||||
eval_start = homework_detail_manual.evaluation_start
|
||||
if eval_start.nil? || (Time.parse(eval_start.to_s) <= @homework.end_time && homework_detail_manual.comment_status <= 1)
|
||||
homework_detail_manual.evaluation_start = @homework.end_time + 7
|
||||
homework_detail_manual.evaluation_end = homework_detail_manual.evaluation_start + 7
|
||||
end
|
||||
end
|
||||
@homework.end_time = params[:homework_common][:end_time] || Time.now
|
||||
@homework.course_id = params[:course_id]
|
||||
|
||||
if params[:homework_type] && params[:homework_type].to_i != @homework.homework_type
|
||||
if @homework.homework_type == 2
|
||||
@homework.homework_detail_programing.destroy if @homework.homework_detail_programing
|
||||
@homework.homework_tests.destroy_all
|
||||
elsif @homework.homework_type == 3
|
||||
@homework.homework_detail_group.destroy if @homework.homework_detail_group
|
||||
create_works_list @homework
|
||||
create_works_list @homework if homework_detail_manual.comment_status > 0 && @homework.student_works.empty?
|
||||
end
|
||||
if params[:homework_type].to_i == 3
|
||||
@homework.student_works.destroy_all
|
||||
end
|
||||
@homework.homework_type = params[:homework_type].to_i
|
||||
end
|
||||
@homework.homework_type = params[:homework_type].to_i || @homework.homework_type
|
||||
anonymous = params[:homework_common][:anonymous_comment] ? params[:homework_common][:anonymous_comment].to_i : 1
|
||||
if anonymous != @homework.anonymous_comment
|
||||
if anonymous == 1
|
||||
if anonymous == 1
|
||||
homework_detail_manual.ta_proportion = @homework.homework_type == 2 ? 0.4 : 1.0
|
||||
else
|
||||
homework_detail_manual.ta_proportion = @homework.homework_type == 2 ? 0.3 : 0.6
|
||||
end
|
||||
end
|
||||
|
||||
status = false
|
||||
if @homework.publish_time > Date.today && homework_detail_manual.comment_status == 1
|
||||
homework_detail_manual.comment_status = 0
|
||||
@homework.student_works.destroy_all
|
||||
#更新CourseHomeworkStatistics中每个学生的未交作品数
|
||||
@homework.course.student.each do |student|
|
||||
course_statistics = CourseHomeworkStatistics.find_by_course_id_and_user_id(@homework.course_id, student.student_id)
|
||||
course_statistics.update_attribute('un_commit_work_num', (course_statistics.un_commit_work_num - 1) < 0 ? 0 : (course_statistics.un_commit_work_num - 1)) if course_statistics
|
||||
end
|
||||
elsif @homework.publish_time <= Date.today && homework_detail_manual.comment_status == 0
|
||||
homework_detail_manual.comment_status = 1
|
||||
create_works_list @homework
|
||||
status = true
|
||||
#更新CourseHomeworkStatistics中每个学生的未交作品数
|
||||
@homework.course.student.each do |student|
|
||||
course_statistics = CourseHomeworkStatistics.find_by_course_id_and_user_id(@homework.course_id, student.student_id)
|
||||
course_statistics.update_attribute('un_commit_work_num', course_statistics.un_commit_work_num + 1) if course_statistics
|
||||
end
|
||||
end
|
||||
eval_start = homework_detail_manual.evaluation_start
|
||||
if eval_start.nil? || (eval_start <= @homework.end_time && homework_detail_manual.comment_status <= 1)
|
||||
homework_detail_manual.evaluation_start = @homework.end_time + 7
|
||||
homework_detail_manual.evaluation_end = homework_detail_manual.evaluation_start + 7
|
||||
end
|
||||
@homework.save_attachments(params[:attachments])
|
||||
render_attachment_warning_if_needed(@homework)
|
||||
|
||||
|
@ -179,6 +199,17 @@ class HomeworkCommonController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
@homework.homework_samples.delete_all if params[:sample]
|
||||
sample_inputs = params[:sample][:input] if params[:sample]
|
||||
if Array === sample_inputs
|
||||
sample_inputs.each_with_index do |val, i|
|
||||
@homework.homework_samples << HomeworkSample.new(
|
||||
input: val,
|
||||
output: params[:sample][:output][i]
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
@homework.homework_tests.delete_all if params[:program]
|
||||
inputs = params[:program][:input] if params[:program]
|
||||
if Array === inputs
|
||||
|
@ -212,9 +243,9 @@ class HomeworkCommonController < ApplicationController
|
|||
@homework_detail_programing.save if @homework_detail_programing
|
||||
@homework_detail_group.save if @homework_detail_group
|
||||
|
||||
if @homework.homework_type != 3 && homework_detail_manual.comment_status == 1 && status
|
||||
create_works_list @homework
|
||||
end
|
||||
# if @homework.homework_type != 3 && homework_detail_manual.comment_status == 1 && status
|
||||
# create_works_list @homework
|
||||
# end
|
||||
|
||||
@hw_status = params[:hw_status].to_i
|
||||
if params[:is_manage] == "1"
|
||||
|
@ -281,6 +312,77 @@ class HomeworkCommonController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
#加入到题库
|
||||
def add_to_homework_bank
|
||||
if params[:type] && (params[:type].to_i == 1 || params[:type].to_i == 3)
|
||||
homework_bank = add_to_homework_bank_f @homework
|
||||
homework_bank.save
|
||||
@homework.update_attributes(:homework_bank_id => homework_bank.id)
|
||||
elsif params[:type].to_i == 2
|
||||
homework_bank = HomeworkBank.where(:id => @homework.homework_bank_id).first
|
||||
if homework_bank
|
||||
homework_bank.update_attributes(:name => @homework.name, :description => @homework.description, :homework_type => @homework.homework_type)
|
||||
if @homework.homework_type == 2 && @homework.homework_detail_programing
|
||||
homework_bank.update_attributes(:language => @homework.homework_detail_programing.language)
|
||||
homework_bank.homework_bank_tests.destroy_all
|
||||
@homework.homework_tests.each_with_index do |homework_test|
|
||||
homework_bank.homework_bank_tests << HomeworkBankTest.new(
|
||||
test_type: 1,
|
||||
input: homework_test.input,
|
||||
output: homework_test.output
|
||||
)
|
||||
end
|
||||
@homework.homework_samples.each_with_index do |homework_test|
|
||||
homework_bank.homework_bank_tests << HomeworkBankTest.new(
|
||||
test_type: 0,
|
||||
input: homework_test.input,
|
||||
output: homework_test.output
|
||||
)
|
||||
end
|
||||
elsif @homework.homework_type == 3 && @homework.homework_detail_group
|
||||
homework_bank.update_attributes(:min_num => @homework.homework_detail_group.min_num, :max_num => @homework.homework_detail_group.max_num, :base_on_project => @homework.homework_detail_group.base_on_project)
|
||||
end
|
||||
end
|
||||
end
|
||||
if @homework.is_update
|
||||
@homework.update_attributes(:is_update => 0)
|
||||
end
|
||||
@user_activity_id = params[:user_activity_id].to_i
|
||||
@hw_status = params[:hw_status].to_i
|
||||
@is_teacher = User.current.admin? || User.current.allowed_to?(:as_teacher, @course)
|
||||
end
|
||||
|
||||
def publish_homework
|
||||
if @homework.homework_detail_manual.comment_status > 0
|
||||
@status = 1
|
||||
elsif @homework.publish_time.nil?
|
||||
@status = 2
|
||||
else
|
||||
homework_detail_manual = @homework.homework_detail_manual
|
||||
homework_detail_manual.update_column('comment_status', 1)
|
||||
@homework.update_attributes(:publish_time => Time.now)
|
||||
@status = 3
|
||||
if @homework.homework_type != 3
|
||||
create_works_list @homework
|
||||
end
|
||||
#更新CourseHomeworkStatistics中每个学生的未交作品数
|
||||
@course.student.each do |student|
|
||||
course_statistics = CourseHomeworkStatistics.find_by_course_id_and_user_id(@homework.course_id, student.student_id)
|
||||
course_statistics.update_attribute('un_commit_work_num', course_statistics.un_commit_work_num + 1) if course_statistics
|
||||
end
|
||||
|
||||
@course.members.each do |m|
|
||||
@homework.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => @course.id, :viewed => false, :status => nil)
|
||||
end
|
||||
if @homework.course_acts.size == 0
|
||||
@homework.course_acts << CourseActivity.new(:user_id => @homework.user_id,:course_id => @homework.course_id)
|
||||
end
|
||||
end
|
||||
@user_activity_id = params[:user_activity_id].to_i
|
||||
@hw_status = params[:hw_status].to_i
|
||||
@is_teacher = User.current.admin? || User.current.allowed_to?(:as_teacher, @course)
|
||||
end
|
||||
|
||||
# 成绩公开范围弹框
|
||||
def alert_score_open_modal
|
||||
if params[:user_activity_id]
|
||||
|
@ -302,7 +404,7 @@ class HomeworkCommonController < ApplicationController
|
|||
#statue 1:启动成功,2:启动失败,作业总数大于等于2份时才能启动匿评,3:已开启匿评,请务重复开启,4:没有开启匿评的权限
|
||||
def start_anonymous_comment
|
||||
@statue = 4 and return unless User.current.admin? || User.current.allowed_to?(:as_teacher,@course)
|
||||
@statue = 5 and return if Time.parse(@homework.end_time.to_s).strftime("%Y-%m-%d") >= Time.now.strftime("%Y-%m-%d")
|
||||
@statue = 5 and return if @homework.end_time >= Time.now
|
||||
if @homework_detail_manual.comment_status == 1
|
||||
student_works = @homework.student_works.has_committed
|
||||
if student_works && student_works.size >= 2
|
||||
|
|
|
@ -260,7 +260,7 @@ class MessagesController < ApplicationController
|
|||
elsif @course
|
||||
redirect_to course_activity_path(@course)
|
||||
elsif @contest
|
||||
redirect_to contest_activities_contest_path(@contest)
|
||||
redirect_to contest_path(@contest)
|
||||
end
|
||||
elsif params[:is_course] && params[:is_course].to_i == 1 && params[:is_board] && params[:is_board].to_i == 1
|
||||
if @project
|
||||
|
@ -351,7 +351,7 @@ class MessagesController < ApplicationController
|
|||
if params[:is_course] && params[:is_course].to_i == 0
|
||||
redirect_to user_contest_community_path(User.current.id)
|
||||
elsif params[:is_course] && params[:is_course].to_i == 1 && params[:is_board] && params[:is_board].to_i == 0
|
||||
redirect_to contest_activities_contest_path(@contest)
|
||||
redirect_to contest_path(@contest)
|
||||
elsif params[:is_course] && params[:is_course].to_i == 1 && params[:is_board] && params[:is_board].to_i == 1
|
||||
redirect_to contest_boards_path(@contest)
|
||||
elsif @message.parent
|
||||
|
|
|
@ -932,7 +932,7 @@ class ProjectsController < ApplicationController
|
|||
def training_task_status
|
||||
status = params[:status].to_i
|
||||
task_id = params[:taskId]
|
||||
message = params[:msg].to_i
|
||||
message = params[:msg]
|
||||
begin
|
||||
@training_task = TrainingTask.find(task_id)
|
||||
# 如果已经执行成功过,则不重复执行
|
||||
|
@ -953,11 +953,11 @@ class ProjectsController < ApplicationController
|
|||
@training_task.update_attribute(:status, 1)
|
||||
end
|
||||
# 创建一条回复提醒
|
||||
content = "恭喜您通过测评"
|
||||
content = position == original_tasks_count ? "恭喜您,您已经完成了实训项目的所有任务" : "恭喜您,您已经完成了本任务"
|
||||
add_training_task_journal(content, original_project.user_id)
|
||||
end
|
||||
else
|
||||
content = "很遗憾,您没有通过该步"
|
||||
content = "很抱歉,您的任务未通过,请继续加油,错误信息如下:#{message}"
|
||||
add_training_task_journal(content, original_project.user_id)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -41,7 +41,7 @@ class StudentWorkController < ApplicationController
|
|||
else
|
||||
student_work.name = params[:title]
|
||||
student_work.description = params[:src]
|
||||
if Time.parse(@homework.end_time.to_s).strftime("%Y-%m-%d") < Time.parse(Time.now.to_s).strftime("%Y-%m-%d")
|
||||
if @homework.end_time < Time.now.to_s
|
||||
student_work.late_penalty = @homework.late_penalty
|
||||
else
|
||||
student_work.late_penalty = 0
|
||||
|
@ -160,7 +160,7 @@ class StudentWorkController < ApplicationController
|
|||
student_work.name = params[:title]
|
||||
student_work.description = params[:src]
|
||||
|
||||
if Time.parse(@homework.end_time.to_s).strftime("%Y-%m-%d") < Time.parse(Time.now.to_s).strftime("%Y-%m-%d")
|
||||
if @homework.end_time < Time.now.to_s
|
||||
student_work.late_penalty = @homework.late_penalty
|
||||
else
|
||||
student_work.late_penalty = 0
|
||||
|
@ -365,7 +365,7 @@ class StudentWorkController < ApplicationController
|
|||
end
|
||||
##################################################################################################################
|
||||
@order,@b_sort,@name,@group = params[:order] || "score",params[:sort] || "desc",params[:name].to_s.strip || "",params[:group]
|
||||
@homework_commons = @course.homework_commons.where("publish_time <= ?",Time.now.strftime("%Y-%m-%d")).order("created_at desc")
|
||||
@homework_commons = @course.homework_commons.where("publish_time <= ?",Time.now).order("created_at desc")
|
||||
@all_homework_commons = @course.homework_commons.order("created_at desc")
|
||||
@is_teacher = User.current.allowed_to?(:as_teacher,@course) || User.current.admin?
|
||||
@is_evaluation = @homework.homework_detail_manual && @homework.homework_detail_manual.comment_status == 2 && !@is_teacher #是不是匿评
|
||||
|
@ -398,7 +398,7 @@ class StudentWorkController < ApplicationController
|
|||
end
|
||||
|
||||
#开放作品 || 老师 || 超级管理员 || 禁用匿评&&作业截止&&已提交作品 显示所有列表
|
||||
if (@homework.is_open == 1 && @course.is_public == 1) || (@homework.is_open == 1 && @course.is_public == 0 && User.current.member_of_course?(@course)) || @is_teacher || User.current.admin? || (User.current.member_of_course?(@course) && @homework.anonymous_comment == 1 && Time.parse(@homework.end_time.to_s).strftime("%Y-%m-%d") < Time.now.strftime("%Y-%m-%d") && !@homework.student_works.has_committed.where(:user_id => User.current.id).empty?)
|
||||
if (@homework.is_open == 1 && @course.is_public == 1) || (@homework.is_open == 1 && @course.is_public == 0 && User.current.member_of_course?(@course)) || @is_teacher || User.current.admin? || (User.current.member_of_course?(@course) && @homework.anonymous_comment == 1 && @homework.end_time < Time.now && !@homework.student_works.has_committed.where(:user_id => User.current.id).empty?)
|
||||
if @order == 'lastname'
|
||||
@stundet_works = search_homework_member @homework.student_works.no_copy.select("student_works.*,student_works.work_score as score").joins(:user).where("users.id in #{student_in_group}").order("CONVERT(lastname USING gbk) COLLATE gbk_chinese_ci #{@b_sort}, login #{@b_sort}"),@name
|
||||
elsif @order == 'student_id'
|
||||
|
@ -464,7 +464,7 @@ class StudentWorkController < ApplicationController
|
|||
|
||||
@student_work_count = (search_homework_member @homework.student_works.has_committed.select("student_works.*,student_works.work_score as score").joins(:user).where("users.id in #{student_in_group}").order("#{@order} #{@b_sort}"),@name).count
|
||||
else
|
||||
if (@homework.is_open == 1 &&@course.is_public == 1) || (@homework.is_open == 1 && @course.is_public == 0 && User.current.member_of_course?(@course)) || @is_teacher || User.current.admin? || (User.current.member_of_course?(@course) && @homework.anonymous_comment == 1 && Time.parse(@homework.end_time.to_s).strftime("%Y-%m-%d") < Time.now.strftime("%Y-%m-%d") && !@homework.student_works.has_committed.where(:user_id => User.current.id).empty?)
|
||||
if (@homework.is_open == 1 &&@course.is_public == 1) || (@homework.is_open == 1 && @course.is_public == 0 && User.current.member_of_course?(@course)) || @is_teacher || User.current.admin? || (User.current.member_of_course?(@course) && @homework.anonymous_comment == 1 && @homework.end_time < Time.now && !@homework.student_works.has_committed.where(:user_id => User.current.id).empty?)
|
||||
if @order == 'lastname'
|
||||
@stundet_works = search_homework_member @homework.student_works.no_copy.select("student_works.*,student_works.work_score as score").joins(:user).order("CONVERT(lastname USING gbk) COLLATE gbk_chinese_ci #{@b_sort}, login #{@b_sort}"),@name
|
||||
elsif @order == 'student_id'
|
||||
|
@ -596,7 +596,7 @@ class StudentWorkController < ApplicationController
|
|||
student_work.project_id = @student_work_project.project_id
|
||||
end
|
||||
#提交作品时,计算是否迟交
|
||||
if Time.parse(@homework.end_time.to_s).strftime("%Y-%m-%d") < Time.parse(Time.now.to_s).strftime("%Y-%m-%d")
|
||||
if @homework.end_time < Time.now.to_s
|
||||
student_work.late_penalty = @homework.late_penalty
|
||||
student_work.work_status = 2
|
||||
# 缺评扣分
|
||||
|
@ -669,7 +669,7 @@ class StudentWorkController < ApplicationController
|
|||
|
||||
def edit
|
||||
@user = User.current
|
||||
if (!User.current.admin? && @homework.homework_type == 2) || Time.parse(@homework.end_time.to_s).strftime("%Y-%m-%d") < Time.now.strftime("%Y-%m-%d") #编程作业不能修改作业|| 截止日期已到不能修改作业
|
||||
if (!User.current.admin? && @homework.homework_type == 2) || @homework.end_time < Time.now #编程作业不能修改作业|| 截止日期已到不能修改作业
|
||||
render_403
|
||||
else
|
||||
respond_to do |format|
|
||||
|
@ -1131,7 +1131,7 @@ class StudentWorkController < ApplicationController
|
|||
|
||||
unless @homework.late_penalty.to_s == params[:late_penalty].to_s
|
||||
@homework.late_penalty = params[:late_penalty].to_s
|
||||
@homework.student_works.where("commit_time > '#{@homework.end_time} 23:59:59'").each do |student_work|
|
||||
@homework.student_works.where("commit_time > '#{@homework.end_time}'").each do |student_work|
|
||||
student_work.late_penalty = params[:late_penalty].to_i
|
||||
student_work.save
|
||||
end
|
||||
|
|
|
@ -118,7 +118,7 @@ class SyllabusesController < ApplicationController
|
|||
if @order.to_i == 2
|
||||
@type = 2
|
||||
@courses.each do |course|
|
||||
course[:infocount] = (User.current.admin? || User.current.allowed_to?(:as_teacher,course)) ? (course.homework_commons.count + visable_attachemnts_incourse(course).count) : (course.homework_commons.where("publish_time <= '#{Date.today}'").count + visable_attachemnts_incourse(course).count)
|
||||
course[:infocount] = (User.current.admin? || User.current.allowed_to?(:as_teacher,course)) ? (course.homework_commons.count + visable_attachemnts_incourse(course).count) : (course.homework_commons.where("publish_time <= '#{Time.now}'").count + visable_attachemnts_incourse(course).count)
|
||||
if course[:infocount] < 0
|
||||
course[:infocount] = 0
|
||||
end
|
||||
|
|
|
@ -2,11 +2,12 @@
|
|||
class TrainingTasksController < ApplicationController
|
||||
|
||||
layout 'base_projects'
|
||||
before_filter :find_training_task, :only => [:show, :edit, :update, :add_journal, :complete_training_task]
|
||||
before_filter :find_project, :only => [:index, :new, :create, :update_form, :issue_commits, :commit_for_issue, :issue_commit_delete, :destroy]
|
||||
before_filter :allow_manager, :only => [:index, :show]
|
||||
before_filter :allow_members, :only => [:new, :create]
|
||||
before_filter :build_new_task_from_params, :only => [:new, :create, :update_form]
|
||||
before_filter :find_training_task, :only => [:show, :edit, :update, :add_journal, :complete_training_task]
|
||||
|
||||
|
||||
# before_filter :find_issues, :only => [:bulk_edit, :bulk_update, :destroy]
|
||||
|
||||
|
@ -95,6 +96,9 @@ class TrainingTasksController < ApplicationController
|
|||
# Add a new issue
|
||||
# The new issue will be created from an existing one if copy_from parameter is given
|
||||
def new
|
||||
if @project.is_child_training_project?
|
||||
return render_404
|
||||
end
|
||||
# 顶部导航
|
||||
@project_menu_type = 11
|
||||
respond_to do |format|
|
||||
|
@ -104,6 +108,9 @@ class TrainingTasksController < ApplicationController
|
|||
|
||||
# 用户发布新任务
|
||||
def create
|
||||
if @project.is_child_training_project?
|
||||
return render_404
|
||||
end
|
||||
@training_task.save_attachments(params[:attachments] || (params[:training_task] && params[:training_task][:uploads]))
|
||||
@training_task.subject = params[:training_task][:subject]
|
||||
@training_task.description = params[:training_task][:description]
|
||||
|
@ -312,6 +319,10 @@ class TrainingTasksController < ApplicationController
|
|||
render_404
|
||||
end
|
||||
|
||||
def find_training_task
|
||||
|
||||
end
|
||||
|
||||
def allow_members
|
||||
if !(User.current.member_of?(@project) || User.current.admin?)
|
||||
render_403
|
||||
|
@ -319,7 +330,7 @@ class TrainingTasksController < ApplicationController
|
|||
end
|
||||
|
||||
def allow_manager
|
||||
if !(User.current.admin? || is_project_member?(User.current.id, @project.id))
|
||||
if !(User.current.admin? || is_project_manager?(User.current.id, @project.id) || is_project_manager?(User.current, @project.try(:forked_from_project_id)) )
|
||||
return render_403
|
||||
end
|
||||
end
|
||||
|
|
|
@ -917,17 +917,19 @@ class UsersController < ApplicationController
|
|||
|
||||
#用户作业列表
|
||||
def user_homeworks
|
||||
@order,@b_sort = params[:order] || "publish_time",params[:sort] || "desc"
|
||||
@order,@b_sort = params[:order] || "created_at",params[:sort] || "desc"
|
||||
@user = User.current
|
||||
@r_sort = @b_sort == "desc" ? "asc" : "desc"
|
||||
if(params[:type].blank? || params[:type] == "1") #我的题库
|
||||
courses = @user.courses.where("is_delete = 1")
|
||||
course_ids = courses.empty? ? "(-1)" : "(" + courses.map{|course| course.id}.join(",") + ")"
|
||||
@homeworks = HomeworkCommon.where("user_id = #{@user.id} and course_id not in #{course_ids}").order("#{@order} #{@b_sort}")
|
||||
# courses = @user.courses.where("is_delete = 1")
|
||||
# course_ids = courses.empty? ? "(-1)" : "(" + courses.map{|course| course.id}.join(",") + ")"
|
||||
# @homeworks = HomeworkCommon.where("user_id = #{@user.id} and course_id not in #{course_ids}").order("#{@order} #{@b_sort}")
|
||||
@homeworks = @user.homework_banks.order("#{@order} #{@b_sort}")
|
||||
elsif params[:type] == "2" #公共题库
|
||||
visible_course = Course.where("is_delete = 0")
|
||||
visible_course_ids = visible_course.empty? ? "(-1)" : "(" + visible_course.map{|course| course.id}.join(",") + ")"
|
||||
@homeworks = HomeworkCommon.where("course_id in #{visible_course_ids} and publish_time <= '#{Date.today}'").order("#{@order} #{@b_sort}")
|
||||
# visible_course = Course.where("is_delete = 0")
|
||||
# visible_course_ids = visible_course.empty? ? "(-1)" : "(" + visible_course.map{|course| course.id}.join(",") + ")"
|
||||
# @homeworks = HomeworkCommon.where("course_id in #{visible_course_ids} and publish_time <= '#{Date.today}'").order("#{@order} #{@b_sort}")
|
||||
@homeworks = HomeworkBank.where(:is_public => true).order("#{@order} #{@b_sort}")
|
||||
end
|
||||
@type = params[:type] ? params[:type] : '1'
|
||||
@limit = 10
|
||||
|
@ -951,7 +953,7 @@ class UsersController < ApplicationController
|
|||
visibleCourse = @user.courses.empty? ? [] : @user.courses.where("is_delete = 0").visible
|
||||
homework_ids = []
|
||||
visibleCourse.each do |course|
|
||||
homeworks = HomeworkCommon.where("course_id = #{course.id} and publish_time <= '#{Date.today}'")
|
||||
homeworks = HomeworkCommon.where("course_id = #{course.id} and publish_time <= '#{Time.now}'")
|
||||
homework_ids << homeworks.pluck(:id) unless homeworks.empty?
|
||||
end
|
||||
visible_homework_ids = homework_ids.size == 0 ? "(-1)" :"(" + homework_ids.join(",") + ")"
|
||||
|
@ -968,7 +970,7 @@ class UsersController < ApplicationController
|
|||
end
|
||||
|
||||
def choose_user_course
|
||||
homework = HomeworkCommon.find params[:homework].to_i
|
||||
#homework = HomeworkCommon.find params[:homework].to_i
|
||||
# if homework.user != User.current && homework.course.is_public == 0 && !User.current.allowed_to?(:as_teacher,homework.course)
|
||||
# ah = ApplyHomework.where("user_id = ? and homework_common_id = ?", User.current.id, params[:send_id].to_i)
|
||||
# if ah.empty?
|
||||
|
@ -979,9 +981,9 @@ class UsersController < ApplicationController
|
|||
# end
|
||||
if !params[:search].nil?
|
||||
search = "%#{params[:search].to_s.strip.downcase}%"
|
||||
@course = @user.courses.where("is_delete = 0 and #{Course.table_name}.id != #{homework.course_id} and (#{Course.table_name}.id = #{params[:search].to_i } or #{Course.table_name}.name like :p)",:p=>search).select { |course| @user.allowed_to?(:as_teacher,course)}
|
||||
@course = @user.courses.where("is_delete = 0 and (#{Course.table_name}.id = #{params[:search].to_i } or #{Course.table_name}.name like :p)",:p=>search).select { |course| @user.allowed_to?(:as_teacher,course)}
|
||||
else
|
||||
@course = @user.courses.where("is_delete = 0 and #{Course.table_name}.id != #{homework.course_id}").select { |course| @user.allowed_to?(:as_teacher,course)}
|
||||
@course = @user.courses.where("is_delete = 0").select { |course| @user.allowed_to?(:as_teacher,course)}
|
||||
end
|
||||
@search = params[:search]
|
||||
#这里仅仅是传递需要发送的资源id
|
||||
|
@ -992,7 +994,7 @@ class UsersController < ApplicationController
|
|||
end
|
||||
|
||||
def send_homework_to_course
|
||||
homework = HomeworkCommon.find params[:send_id].to_i
|
||||
homework = HomeworkBank.find params[:send_id].to_i
|
||||
course_ids = params[:course_ids]
|
||||
course_ids.each do |course_id|
|
||||
course = Course.find course_id.to_i
|
||||
|
@ -1001,49 +1003,60 @@ class UsersController < ApplicationController
|
|||
new_homework.user_id = User.current.id
|
||||
new_homework.description = homework.description
|
||||
new_homework.homework_type = homework.homework_type
|
||||
new_homework.late_penalty = homework.late_penalty
|
||||
new_homework.late_penalty = 0
|
||||
new_homework.course_id = course.id
|
||||
new_homework.teacher_priority = homework.teacher_priority
|
||||
new_homework.anonymous_comment = homework.anonymous_comment
|
||||
new_homework.teacher_priority = 1
|
||||
new_homework.anonymous_comment = 1
|
||||
new_homework.quotes = 0
|
||||
new_homework.is_open = homework.is_open
|
||||
homework.attachments.each do |attachment|
|
||||
att = attachment.copy
|
||||
att.container_id = nil
|
||||
att.container_type = nil
|
||||
att.copy_from = attachment.id
|
||||
att.save
|
||||
new_homework.attachments << att
|
||||
end
|
||||
homework_detail_manual = homework.homework_detail_manual
|
||||
homework_detail_programing = homework.homework_detail_programing
|
||||
homework_detail_group = homework.homework_detail_group
|
||||
if homework_detail_manual
|
||||
new_homework.is_open = 0
|
||||
# homework.attachments.each do |attachment|
|
||||
# att = attachment.copy
|
||||
# att.container_id = nil
|
||||
# att.container_type = nil
|
||||
# att.copy_from = attachment.id
|
||||
# att.save
|
||||
# new_homework.attachments << att
|
||||
# end
|
||||
#homework_detail_manual = homework.homework_detail_manual
|
||||
#homework_detail_programing = homework.homework_detail_programing
|
||||
#homework_detail_group = homework.homework_detail_group
|
||||
#if homework_detail_manual
|
||||
new_homework.homework_detail_manual = HomeworkDetailManual.new
|
||||
new_homework_detail_manual = new_homework.homework_detail_manual
|
||||
new_homework_detail_manual.ta_proportion = homework_detail_manual.ta_proportion
|
||||
new_homework_detail_manual = new_homework.homework_detail_manual
|
||||
new_homework_detail_manual.ta_proportion = new_homework.homework_type == 2 ? 0.4 : 1.0
|
||||
new_homework_detail_manual.comment_status = 0
|
||||
new_homework_detail_manual.evaluation_num = homework_detail_manual.evaluation_num
|
||||
new_homework_detail_manual.absence_penalty = homework_detail_manual.absence_penalty
|
||||
end
|
||||
if homework_detail_programing
|
||||
new_homework_detail_manual.evaluation_num = 3
|
||||
new_homework_detail_manual.absence_penalty = 0
|
||||
#end
|
||||
#if homework_detail_programing
|
||||
if new_homework.homework_type == 2
|
||||
new_homework.homework_detail_programing = HomeworkDetailPrograming.new
|
||||
new_homework.homework_detail_programing.ta_proportion = homework_detail_programing.ta_proportion
|
||||
new_homework.homework_detail_programing.language = homework_detail_programing.language
|
||||
homework.homework_tests.each_with_index do |homework_test|
|
||||
new_homework.homework_tests << HomeworkTest.new(
|
||||
input: homework_test.input,
|
||||
output: homework_test.output
|
||||
)
|
||||
new_homework.homework_detail_programing.ta_proportion = 0.6
|
||||
new_homework.homework_detail_programing.language = homework.language
|
||||
homework.homework_bank_tests.each_with_index do |homework_test|
|
||||
if homework_test.test_type
|
||||
new_homework.homework_tests << HomeworkTest.new(
|
||||
input: homework_test.input,
|
||||
output: homework_test.output
|
||||
)
|
||||
else
|
||||
new_homework.homework_samples << HomeworkSample.new(
|
||||
input: homework_test.input,
|
||||
output: homework_test.output
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
#end
|
||||
|
||||
if homework_detail_group
|
||||
#if homework_detail_group
|
||||
if new_homework.homework_type == 3
|
||||
new_homework.homework_detail_group = HomeworkDetailGroup.new
|
||||
new_homework.homework_detail_group.min_num = homework_detail_group.min_num
|
||||
new_homework.homework_detail_group.max_num = homework_detail_group.max_num
|
||||
new_homework.homework_detail_group.base_on_project = homework_detail_group.base_on_project
|
||||
new_homework.homework_detail_group.min_num = homework.min_num
|
||||
new_homework.homework_detail_group.max_num = homework.max_num
|
||||
new_homework.homework_detail_group.base_on_project = homework.base_on_project
|
||||
end
|
||||
#end
|
||||
if new_homework.save
|
||||
new_homework_detail_manual.save if new_homework_detail_manual
|
||||
new_homework.homework_detail_programing.save if new_homework.homework_detail_programing
|
||||
|
@ -1062,9 +1075,9 @@ class UsersController < ApplicationController
|
|||
@user = User.current
|
||||
@select_course = params[:select_course] ? 1 : 0
|
||||
#@user_homeworks = HomeworkCommon.where(:user_id => @user.id).order("created_at desc")
|
||||
courses = @user.courses.where("is_delete = 1")
|
||||
course_ids = courses.empty? ? "(-1)" : "(" + courses.map{|course| course.id}.join(",") + ")"
|
||||
@homeworks = HomeworkCommon.where("user_id = #{@user.id} and course_id not in #{course_ids}").order("#{@order} #{@b_sort}")
|
||||
#courses = @user.courses.where("is_delete = 1")
|
||||
#course_ids = courses.empty? ? "(-1)" : "(" + courses.map{|course| course.id}.join(",") + ")"
|
||||
@homeworks = @user.homework_banks.order("#{@order} #{@b_sort}")
|
||||
@type = params[:type]
|
||||
@limit = 15
|
||||
@is_remote = true
|
||||
|
@ -1078,17 +1091,17 @@ class UsersController < ApplicationController
|
|||
end
|
||||
|
||||
def user_homework_type
|
||||
@order,@b_sort = params[:order] || "publish_time",params[:sort] || "desc"
|
||||
@order,@b_sort = params[:order] || "created_at",params[:sort] || "desc"
|
||||
@r_sort = @b_sort == "desc" ? "asc" : "desc"
|
||||
@user = User.current
|
||||
if(params[:type].blank? || params[:type] == "1") #我的题库
|
||||
courses = @user.courses.where("is_delete = 1")
|
||||
course_ids = courses.empty? ? "(-1)" : "(" + courses.map{|course| course.id}.join(",") + ")"
|
||||
@homeworks = HomeworkCommon.where("user_id = #{@user.id} and course_id not in #{course_ids}").order("#{@order} #{@b_sort}")
|
||||
#courses = @user.courses.where("is_delete = 1")
|
||||
#course_ids = courses.empty? ? "(-1)" : "(" + courses.map{|course| course.id}.join(",") + ")"
|
||||
@homeworks = @user.homework_banks
|
||||
elsif params[:type] == "2" #公共题库
|
||||
visible_course = Course.where("is_public = 1 && is_delete = 0")
|
||||
visible_course_ids = visible_course.empty? ? "(-1)" : "(" + visible_course.map{|course| course.id}.join(",") + ")"
|
||||
@homeworks = HomeworkCommon.where("course_id in #{visible_course_ids} and publish_time <= '#{Date.today}'").order("#{@order} #{@b_sort}")
|
||||
#visible_course = Course.where("is_public = 1 && is_delete = 0")
|
||||
#visible_course_ids = visible_course.empty? ? "(-1)" : "(" + visible_course.map{|course| course.id}.join(",") + ")"
|
||||
@homeworks = HomeworkBank.where(:is_public => true)
|
||||
# elsif params[:type] == "3" #申请题库
|
||||
# none_visible_course = Course.where("is_delete = 1")
|
||||
# none_visible_course_ids = none_visible_course.empty? ? "(-1)" : "(" + none_visible_course.map{|course| course.id}.join(",") + ")"
|
||||
|
@ -1100,18 +1113,20 @@ class UsersController < ApplicationController
|
|||
# @homeworks = HomeworkCommon.find_by_sql(sql)
|
||||
end
|
||||
if params[:property]
|
||||
all_homework_ids = @homeworks.empty? ? "(-1)" : "(" + @homeworks.map{|h| h.id}.join(",") + ")"
|
||||
if params[:property] == "1"
|
||||
@homeworks = HomeworkCommon.find_by_sql("select * from homework_commons where id in #{all_homework_ids} and homework_type = 1")
|
||||
#@homeworks = @homeworks.where("homework_type = 1").reorder("#{@order} #{@b_sort}")
|
||||
elsif params[:property] == "2"
|
||||
@homeworks = HomeworkCommon.find_by_sql("select * from homework_commons where id in #{all_homework_ids} and homework_type = 2")
|
||||
#@homeworks = @homeworks.where("homework_type = 2").reorder("#{@order} #{@b_sort}")
|
||||
elsif params[:property] == "3"
|
||||
@homeworks = HomeworkCommon.find_by_sql("select * from homework_commons where id in #{all_homework_ids} and homework_type = 3")
|
||||
#@homeworks = @homeworks.where("homework_type = 3").reorder("#{@order} #{@b_sort}")
|
||||
end
|
||||
@homeworks = @homeworks.where(:homework_type => params[:property].to_i)
|
||||
# all_homework_ids = @homeworks.empty? ? "(-1)" : "(" + @homeworks.map{|h| h.id}.join(",") + ")"
|
||||
# if params[:property] == "1"
|
||||
# @homeworks = HomeworkCommon.find_by_sql("select * from homework_commons where id in #{all_homework_ids} and homework_type = 1")
|
||||
# #@homeworks = @homeworks.where("homework_type = 1").reorder("#{@order} #{@b_sort}")
|
||||
# elsif params[:property] == "2"
|
||||
# @homeworks = HomeworkCommon.find_by_sql("select * from homework_commons where id in #{all_homework_ids} and homework_type = 2")
|
||||
# #@homeworks = @homeworks.where("homework_type = 2").reorder("#{@order} #{@b_sort}")
|
||||
# elsif params[:property] == "3"
|
||||
# @homeworks = HomeworkCommon.find_by_sql("select * from homework_commons where id in #{all_homework_ids} and homework_type = 3")
|
||||
# #@homeworks = @homeworks.where("homework_type = 3").reorder("#{@order} #{@b_sort}")
|
||||
# end
|
||||
end
|
||||
@homeworks = @homeworks.reorder("#{@order} #{@b_sort}")
|
||||
@type = params[:type] ? params[:type] : '1'
|
||||
@property = params[:property]
|
||||
@is_import = params[:is_import]
|
||||
|
@ -1127,7 +1142,7 @@ class UsersController < ApplicationController
|
|||
end
|
||||
|
||||
def show_homework_detail
|
||||
@homework = HomeworkCommon.find params[:homework].to_i
|
||||
@homework = HomeworkBank.find params[:homework].to_i
|
||||
# if homework.course.is_public == 0 && !User.current.allowed_to?(:as_teacher,homework.course) && User.current != homework.user
|
||||
# ah = ApplyHomework.where("user_id = ? and homework_common_id = ?", User.current.id, params[:homework].to_i)
|
||||
# if ah.empty?
|
||||
|
@ -1150,44 +1165,46 @@ class UsersController < ApplicationController
|
|||
|
||||
#用户主页过滤作业
|
||||
def user_search_homeworks
|
||||
@order,@b_sort = params[:order] || "publish_time",params[:sort] || "desc"
|
||||
@order,@b_sort = params[:order] || "created_at",params[:sort] || "desc"
|
||||
@r_sort = @b_sort == "desc" ? "asc" : "desc"
|
||||
@user = User.current
|
||||
search = params[:name].to_s.strip.downcase
|
||||
type_ids = (params[:property]=="" || params[:property].nil? || params[:property]=="0") ? "(1, 2, 3)" : "(" + params[:property] + ")"
|
||||
if(params[:type].blank? || params[:type] == "1") #我的题库
|
||||
courses = @user.courses.where("is_delete = 1")
|
||||
course_ids = courses.empty? ? "(-1)" : "(" + courses.map{|course| course.id}.join(",") + ")"
|
||||
if @order == "course_name"
|
||||
sql = "SELECT homework_commons.* FROM homework_commons INNER JOIN courses ON homework_commons.course_id = courses.id where homework_commons.course_id not in #{course_ids} and homework_commons.user_id = #{@user.id} and homework_type in #{type_ids} and (homework_commons.name like '%#{search}%') order by CONVERT (courses.name USING gbk) COLLATE gbk_chinese_ci #{@b_sort}"
|
||||
@homeworks = HomeworkCommon.find_by_sql(sql)
|
||||
elsif @order == "user_name"
|
||||
@homeworks = HomeworkCommon.where("user_id = #{@user.id} and course_id not in #{course_ids} and (name like '%#{search}%') and homework_type in #{type_ids}").joins(:user).order("CONVERT (lastname USING gbk) COLLATE gbk_chinese_ci #{@b_sort}, CONVERT (firstname USING gbk) COLLATE gbk_chinese_ci #{@b_sort},login #{@b_sort}")
|
||||
else
|
||||
@homeworks = HomeworkCommon.where("user_id = #{@user.id} and course_id not in #{course_ids} and (name like '%#{search}%') and homework_type in #{type_ids}").order("#{@order} #{@b_sort}")
|
||||
end
|
||||
#courses = @user.courses.where("is_delete = 1")
|
||||
#course_ids = courses.empty? ? "(-1)" : "(" + courses.map{|course| course.id}.join(",") + ")"
|
||||
@homeworks = @user.homework_banks.where("name like '%#{search}%' and homework_type in #{type_ids}").order("#{@order} #{@b_sort}")
|
||||
# if @order == "course_name"
|
||||
# sql = "SELECT homework_commons.* FROM homework_commons INNER JOIN courses ON homework_commons.course_id = courses.id where homework_commons.course_id not in #{course_ids} and homework_commons.user_id = #{@user.id} and homework_type in #{type_ids} and (homework_commons.name like '%#{search}%') order by CONVERT (courses.name USING gbk) COLLATE gbk_chinese_ci #{@b_sort}"
|
||||
# @homeworks = HomeworkCommon.find_by_sql(sql)
|
||||
# elsif @order == "user_name"
|
||||
# @homeworks = HomeworkCommon.where("user_id = #{@user.id} and course_id not in #{course_ids} and (name like '%#{search}%') and homework_type in #{type_ids}").joins(:user).order("CONVERT (lastname USING gbk) COLLATE gbk_chinese_ci #{@b_sort}, CONVERT (firstname USING gbk) COLLATE gbk_chinese_ci #{@b_sort},login #{@b_sort}")
|
||||
# else
|
||||
# @homeworks = HomeworkCommon.where("user_id = #{@user.id} and course_id not in #{course_ids} and (name like '%#{search}%') and homework_type in #{type_ids}").order("#{@order} #{@b_sort}")
|
||||
# end
|
||||
elsif params[:type] == "2" #题库
|
||||
visible_course = Course.where("is_public = 1 && is_delete = 0")
|
||||
visible_course_ids = visible_course.empty? ? "(-1)" : "(" + visible_course.map{|course| course.id}.join(",") + ")"
|
||||
all_homeworks = HomeworkCommon.where("course_id in #{visible_course_ids} and publish_time <= '#{Date.today}'")
|
||||
#visible_course = Course.where("is_public = 1 && is_delete = 0")
|
||||
#visible_course_ids = visible_course.empty? ? "(-1)" : "(" + visible_course.map{|course| course.id}.join(",") + ")"
|
||||
all_homeworks = HomeworkBank.where(:is_public => true)
|
||||
all_user_ids = all_homeworks.map{|hw| hw.user_id}
|
||||
user_str_ids = search_user_by_name all_user_ids, search
|
||||
user_ids = user_str_ids.empty? ? "(-1)" : "(" + user_str_ids.join(",") + ")"
|
||||
if @order == "course_name"
|
||||
sql = "SELECT homework_commons.* FROM homework_commons INNER JOIN courses ON homework_commons.course_id = courses.id where homework_type in #{type_ids} and course_id in #{visible_course_ids} and publish_time <= '#{Date.today}' and (homework_commons.name like '%#{search}%' or homework_commons.user_id in #{user_ids}) order by CONVERT (courses.name USING gbk) COLLATE gbk_chinese_ci #{@b_sort}"
|
||||
@homeworks = HomeworkCommon.find_by_sql(sql)
|
||||
elsif @order == "user_name"
|
||||
@homeworks = HomeworkCommon.where("course_id in #{visible_course_ids} and publish_time <= '#{Date.today}' and homework_type in #{type_ids} and (name like '%#{search}%' or user_id in #{user_ids})").joins(:user).order("CONVERT (lastname USING gbk) COLLATE gbk_chinese_ci #{@b_sort}, CONVERT (firstname USING gbk) COLLATE gbk_chinese_ci #{@b_sort},login #{@b_sort}")
|
||||
else
|
||||
@homeworks = HomeworkCommon.where("course_id in #{visible_course_ids} and publish_time <= '#{Date.today}' and homework_type in #{type_ids} and (name like '%#{search}%' or user_id in #{user_ids})").order("#{@order} #{@b_sort}")
|
||||
end
|
||||
@homeworks = HomeworkBank.where("is_public = 1 and (name like '%#{search}%' or user_id in #{user_ids}) and homework_type in #{type_ids}").order("#{@order} #{@b_sort}")
|
||||
# if @order == "course_name"
|
||||
# sql = "SELECT homework_commons.* FROM homework_commons INNER JOIN courses ON homework_commons.course_id = courses.id where homework_type in #{type_ids} and course_id in #{visible_course_ids} and publish_time <= '#{Date.today}' and (homework_commons.name like '%#{search}%' or homework_commons.user_id in #{user_ids}) order by CONVERT (courses.name USING gbk) COLLATE gbk_chinese_ci #{@b_sort}"
|
||||
# @homeworks = HomeworkCommon.find_by_sql(sql)
|
||||
# elsif @order == "user_name"
|
||||
# @homeworks = HomeworkCommon.where("course_id in #{visible_course_ids} and publish_time <= '#{Date.today}' and homework_type in #{type_ids} and (name like '%#{search}%' or user_id in #{user_ids})").joins(:user).order("CONVERT (lastname USING gbk) COLLATE gbk_chinese_ci #{@b_sort}, CONVERT (firstname USING gbk) COLLATE gbk_chinese_ci #{@b_sort},login #{@b_sort}")
|
||||
# else
|
||||
# @homeworks = HomeworkCommon.where("course_id in #{visible_course_ids} and publish_time <= '#{Date.today}' and homework_type in #{type_ids} and (name like '%#{search}%' or user_id in #{user_ids})").order("#{@order} #{@b_sort}")
|
||||
# end
|
||||
elsif params[:type] == "3" #申请题库
|
||||
apply_homeworks = ApplyHomework.where("user_id = ?",@user.id)
|
||||
homework_ids = apply_homeworks.empty? ? "(-1)" : "(" + apply_homeworks.map{|ah| ah.homework_common_id}.join(",") + ")"
|
||||
none_visible_course = Course.where("is_delete = 1")
|
||||
none_visible_course_ids = none_visible_course.empty? ? "(-1)" : "(" + none_visible_course.map{|course| course.id}.join(",") + ")"
|
||||
if @order == "course_name"
|
||||
sql = "SELECT homework_commons.* FROM homework_commons INNER JOIN courses ON homework_commons.course_id = courses.id where courses.is_delete = 0 and homework_commons.id in #{homework_ids} and homework_type in #{type_ids} and publish_time <= '#{Date.today}' and (homework_commons.name like '%#{search}%') order by CONVERT (courses.name USING gbk) COLLATE gbk_chinese_ci #{@b_sort}"
|
||||
sql = "SELECT homework_commons.* FROM homework_commons INNER JOIN courses ON homework_commons.course_id = courses.id where courses.is_delete = 0 and homework_commons.id in #{homework_ids} and homework_type in #{type_ids} and publish_time <= '#{Time.now}' and (homework_commons.name like '%#{search}%') order by CONVERT (courses.name USING gbk) COLLATE gbk_chinese_ci #{@b_sort}"
|
||||
@homeworks = HomeworkCommon.find_by_sql(sql)
|
||||
elsif @order == "user_name"
|
||||
@homeworks = HomeworkCommon.where("homework_commons.id in #{homework_ids} and course_id not in #{none_visible_course_ids} and (name like '%#{search}%') and homework_type in #{type_ids}").joins(:user).order("CONVERT (lastname USING gbk) COLLATE gbk_chinese_ci #{@b_sort}, CONVERT (firstname USING gbk) COLLATE gbk_chinese_ci #{@b_sort},login #{@b_sort}")
|
||||
|
@ -1221,11 +1238,16 @@ class UsersController < ApplicationController
|
|||
|
||||
#检查改作业是否可以选用
|
||||
def check_homework
|
||||
homework = HomeworkCommon.find_by_id params[:homework]
|
||||
student_ids = homework.course.student.empty? ? [] : homework.course.student.map{|student| student.student_id}.join(',')
|
||||
resultObj = {status: 2}
|
||||
if student_ids.include?(User.current.id.to_s)
|
||||
resultObj[:status] = 1
|
||||
homework_bank = HomeworkBank.find params[:homework]
|
||||
if homework_bank.homework_common_id && HomeworkCommon.find(homework_bank.homework_common_id)
|
||||
homework = HomeworkCommon.find(homework_bank.homework_common_id)
|
||||
student_ids = homework.course.student.empty? ? [] : homework.course.student.map{|student| student.student_id}.join(',')
|
||||
if student_ids.include?(User.current.id.to_s)
|
||||
resultObj[:status] = 1
|
||||
else
|
||||
resultObj[:status] = 0
|
||||
end
|
||||
else
|
||||
resultObj[:status] = 0
|
||||
end
|
||||
|
@ -1234,47 +1256,58 @@ class UsersController < ApplicationController
|
|||
|
||||
#导入作业,确定按钮
|
||||
def user_select_homework
|
||||
homework = HomeworkCommon.find_by_id params[:checkMenu]
|
||||
homework_detail_programing = homework.homework_detail_programing
|
||||
homework_detail_group = homework.homework_detail_group
|
||||
homework = HomeworkBank.find_by_id params[:checkMenu]
|
||||
#homework_detail_programing = homework.homework_detail_programing
|
||||
#homework_detail_group = homework.homework_detail_group
|
||||
@homework = HomeworkCommon.new
|
||||
@select_course = params[:select_course] || 0
|
||||
if homework
|
||||
@ref_homework = homework
|
||||
@homework.name = homework.name
|
||||
@homework.description = homework.description
|
||||
@homework.end_time = homework.end_time
|
||||
#@homework.end_time = homework.end_time
|
||||
@homework.homework_type = homework.homework_type
|
||||
@homework.course_id = homework.course_id
|
||||
homework.attachments.each do |attachment|
|
||||
att = attachment.copy
|
||||
att.container_id = nil
|
||||
att.container_type = nil
|
||||
att.copy_from = attachment.id
|
||||
att.save
|
||||
@homework.attachments << att
|
||||
end
|
||||
#@homework.course_id = homework.course_id
|
||||
# homework.attachments.each do |attachment|
|
||||
# att = attachment.copy
|
||||
# att.container_id = nil
|
||||
# att.container_type = nil
|
||||
# att.copy_from = attachment.id
|
||||
# att.save
|
||||
# @homework.attachments << att
|
||||
# end
|
||||
|
||||
if homework_detail_programing
|
||||
#if homework_detail_programing
|
||||
if homework.homework_type == 2
|
||||
@homework.homework_detail_programing = HomeworkDetailPrograming.new
|
||||
@homework_detail_programing = @homework.homework_detail_programing
|
||||
@homework_detail_programing.ta_proportion = homework_detail_programing.ta_proportion
|
||||
@homework_detail_programing.language = homework_detail_programing.language
|
||||
homework.homework_tests.each_with_index do |homework_test|
|
||||
@homework.homework_tests << HomeworkTest.new(
|
||||
input: homework_test.input,
|
||||
output: homework_test.output
|
||||
)
|
||||
#@homework_detail_programing.ta_proportion = homework_detail_programing.ta_proportion
|
||||
@homework_detail_programing.language = homework.language
|
||||
homework.homework_bank_tests.each_with_index do |homework_test|
|
||||
if homework_test.test_type
|
||||
@homework.homework_tests << HomeworkTest.new(
|
||||
input: homework_test.input,
|
||||
output: homework_test.output
|
||||
)
|
||||
else
|
||||
@homework.homework_samples << HomeworkSample.new(
|
||||
input: homework_test.input,
|
||||
output: homework_test.output
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
#end
|
||||
|
||||
if homework_detail_group
|
||||
#if homework_detail_group
|
||||
if homework.homework_type == 3
|
||||
@homework.homework_detail_group = HomeworkDetailGroup.new
|
||||
@homework_detail_group = @homework.homework_detail_group
|
||||
@homework_detail_group.min_num = homework_detail_group.min_num
|
||||
@homework_detail_group.max_num = homework_detail_group.max_num
|
||||
@homework_detail_group.base_on_project = homework_detail_group.base_on_project
|
||||
@homework_detail_group.min_num = homework.min_num
|
||||
@homework_detail_group.max_num = homework.max_num
|
||||
@homework_detail_group.base_on_project = homework.base_on_project
|
||||
end
|
||||
#end
|
||||
end
|
||||
respond_to do |format|
|
||||
format.js
|
||||
|
@ -1320,7 +1353,7 @@ class UsersController < ApplicationController
|
|||
if student_work
|
||||
|
||||
# 提交作品时,计算是否迟交
|
||||
if Time.parse(homework.end_time.to_s).strftime("%Y-%m-%d") < Time.parse(Time.now.to_s).strftime("%Y-%m-%d")
|
||||
if homework.end_time < Time.now
|
||||
student_work.late_penalty = homework.late_penalty
|
||||
student_work.work_status = 2
|
||||
# 缺评扣分
|
||||
|
@ -1357,12 +1390,12 @@ class UsersController < ApplicationController
|
|||
homework = HomeworkCommon.new
|
||||
homework.name = params[:homework_common][:name]
|
||||
homework.description = params[:homework_common][:description]
|
||||
homework.end_time = params[:homework_common][:end_time] || Date.today
|
||||
if params[:homework_common][:publish_time] == ""
|
||||
homework.publish_time = Date.today
|
||||
else
|
||||
homework.publish_time = params[:homework_common][:publish_time]
|
||||
end
|
||||
# homework.end_time = params[:homework_common][:end_time] || Time.now
|
||||
# if params[:homework_common][:publish_time] == ""
|
||||
# homework.publish_time = Time.now
|
||||
# else
|
||||
# homework.publish_time = params[:homework_common][:publish_time]
|
||||
# end
|
||||
homework.anonymous_comment = params[:homework_common][:anonymous_comment] ? params[:homework_common][:anonymous_comment].to_i : 1
|
||||
homework.homework_type = params[:homework_type].to_i || 1
|
||||
homework.late_penalty = 0
|
||||
|
@ -1379,19 +1412,31 @@ class UsersController < ApplicationController
|
|||
else
|
||||
homework_detail_manual.ta_proportion = homework.homework_type == 2 ? 0.3 : 0.6
|
||||
end
|
||||
if homework.publish_time > Date.today
|
||||
if params[:homework_common][:end_time] == ""
|
||||
homework_detail_manual.comment_status = 0
|
||||
else
|
||||
homework_detail_manual.comment_status = 1
|
||||
homework.end_time = params[:homework_common][:end_time]
|
||||
if params[:homework_common][:publish_time] == ""
|
||||
homework.publish_time = Time.now
|
||||
else
|
||||
homework.publish_time = params[:homework_common][:publish_time]
|
||||
end
|
||||
|
||||
#更新CourseHomeworkStatistics中每个学生的未交作品数
|
||||
homework.course.student.each do |student|
|
||||
course_statistics = CourseHomeworkStatistics.find_by_course_id_and_user_id(homework.course_id, student.student_id)
|
||||
course_statistics.update_attribute('un_commit_work_num', course_statistics.un_commit_work_num + 1) if course_statistics
|
||||
if homework.publish_time > Time.now
|
||||
homework_detail_manual.comment_status = 0
|
||||
else
|
||||
homework_detail_manual.comment_status = 1
|
||||
|
||||
#更新CourseHomeworkStatistics中每个学生的未交作品数
|
||||
homework.course.student.each do |student|
|
||||
course_statistics = CourseHomeworkStatistics.find_by_course_id_and_user_id(homework.course_id, student.student_id)
|
||||
course_statistics.update_attribute('un_commit_work_num', course_statistics.un_commit_work_num + 1) if course_statistics
|
||||
end
|
||||
end
|
||||
end
|
||||
homework_detail_manual.evaluation_start = params[:evaluation_start].blank? ? homework.end_time + 7 : params[:evaluation_start]
|
||||
homework_detail_manual.evaluation_end = params[:evaluation_end].blank? ? homework_detail_manual.evaluation_start + 7 : params[:evaluation_end]
|
||||
|
||||
homework_detail_manual.evaluation_start = homework.end_time + 7 if homework.end_time
|
||||
homework_detail_manual.evaluation_end = homework.end_time + 14 if homework.end_time
|
||||
homework_detail_manual.evaluation_num = params[:evaluation_num] || 3
|
||||
homework_detail_manual.absence_penalty = 0
|
||||
homework.homework_detail_manual = homework_detail_manual
|
||||
|
@ -1407,6 +1452,16 @@ class UsersController < ApplicationController
|
|||
end
|
||||
homework_detail_programing.language = params[:language_type].to_i
|
||||
|
||||
sample_inputs = params[:sample][:input]
|
||||
if Array === sample_inputs
|
||||
sample_inputs.each_with_index do |val, i|
|
||||
homework.homework_samples << HomeworkSample.new(
|
||||
input: val,
|
||||
output: params[:sample][:output][i]
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
inputs = params[:program][:input]
|
||||
if Array === inputs
|
||||
inputs.each_with_index do |val, i|
|
||||
|
@ -1437,10 +1492,14 @@ class UsersController < ApplicationController
|
|||
end
|
||||
|
||||
if params[:quotes] && !params[:quotes].blank?
|
||||
quotes_homework = HomeworkCommon.find params[:quotes].to_i
|
||||
quotes_homework = HomeworkBank.find params[:quotes].to_i
|
||||
quotes_homework.update_column(:quotes, quotes_homework.quotes+1)
|
||||
end
|
||||
|
||||
if params[:add_to_bank]
|
||||
homework_bank = add_to_homework_bank_f homework
|
||||
homework_bank.save
|
||||
end
|
||||
redirect_to homework_common_index_path(:course => homework.course_id)
|
||||
end
|
||||
end
|
||||
|
@ -1854,7 +1913,7 @@ class UsersController < ApplicationController
|
|||
@manage_homeworks = HomeworkCommon.where("course_id in #{tea_course_ids}").order("created_at desc").limit(5)
|
||||
stu_courses = @user.courses.visible.not_deleted.select{|course| @user.has_student_role(course)}
|
||||
stu_course_ids = stu_courses.empty? ? "(-1)" : "(" + stu_courses.map{|course| course.id}.join(',') + ")"
|
||||
@receive_homeworks = HomeworkCommon.where("course_id in #{stu_course_ids} and publish_time <= '#{Date.today}'").order("created_at desc").limit(5)
|
||||
@receive_homeworks = HomeworkCommon.where("course_id in #{stu_course_ids} and publish_time <= '#{Time.now}'").order("created_at desc").limit(5)
|
||||
if (@manage_homeworks.empty? && @receive_homeworks.empty?) || (@receive_homeworks.empty?) || (!@manage_homeworks.empty? && !@receive_homeworks.empty? && @manage_homeworks.first.created_at > @receive_homeworks.first.created_at)
|
||||
@manage_pre = true
|
||||
else
|
||||
|
@ -1907,7 +1966,7 @@ class UsersController < ApplicationController
|
|||
@type = @type.to_i
|
||||
stu_courses = @user.courses.visible.not_deleted.select{|course| @user.has_student_role(course)}
|
||||
stu_course_ids = stu_courses.empty? ? "(-1)" : "(" + stu_courses.map{|course| course.id}.join(',') + ")"
|
||||
@homeworks = HomeworkCommon.where("course_id in #{stu_course_ids} and publish_time <= '#{Date.today}'").order("#{@order} #{@b_sort}")
|
||||
@homeworks = HomeworkCommon.where("course_id in #{stu_course_ids} and publish_time <= '#{Time.now}'").order("#{@order} #{@b_sort}")
|
||||
if params[:property]
|
||||
all_homework_ids = @homeworks.empty? ? "(-1)" : "(" + @homeworks.map{|h| h.id}.join(",") + ")"
|
||||
if params[:property] == "1"
|
||||
|
@ -1944,7 +2003,7 @@ class UsersController < ApplicationController
|
|||
else
|
||||
stu_courses = @user.courses.visible.not_deleted.select{|course| @user.has_student_role(course)}
|
||||
stu_course_ids = stu_courses.empty? ? "(-1)" : "(" + stu_courses.map{|course| course.id}.join(',') + ")"
|
||||
@homeworks = HomeworkCommon.where("course_id in #{stu_course_ids} and publish_time <= '#{Date.today}'").order("#{@order} #{@b_sort}")
|
||||
@homeworks = HomeworkCommon.where("course_id in #{stu_course_ids} and publish_time <= '#{Time.now}'").order("#{@order} #{@b_sort}")
|
||||
end
|
||||
if params[:property]
|
||||
all_homework_ids = @homeworks.empty? ? "(-1)" : "(" + @homeworks.map{|h| h.id}.join(",") + ")"
|
||||
|
@ -1985,7 +2044,7 @@ class UsersController < ApplicationController
|
|||
stu_courses = @user.courses.visible.not_deleted.select{|course| @user.has_student_role(course)}
|
||||
stu_course_ids = stu_courses.empty? ? "(-1)" : "(" + stu_courses.map{|course| course.id}.join(',') + ")"
|
||||
#user_ids = hw_publisher_user_ids search, stu_course_ids
|
||||
@homeworks = HomeworkCommon.where("course_id in #{stu_course_ids} and homework_type in #{type_ids} and publish_time <= '#{Date.today}' and name like '%#{search}%'")
|
||||
@homeworks = HomeworkCommon.where("course_id in #{stu_course_ids} and homework_type in #{type_ids} and publish_time <= '#{Time.now}' and name like '%#{search}%'")
|
||||
if @order == "status"
|
||||
@homeworks.each do |homework|
|
||||
work = cur_user_works_for_homework homework
|
||||
|
@ -2043,7 +2102,7 @@ class UsersController < ApplicationController
|
|||
my_course_ids = StudentsForCourse.includes(:course).where("student_id = #{@user.id} and courses.is_delete = 0").blank? ? "(-1)" : "(" + StudentsForCourse.includes(:course).
|
||||
where("student_id = #{@user.id} and courses.is_delete = 0").map{|sc| sc.course_id}.join(",") + ")"
|
||||
# 用户待完成的作业
|
||||
homeworks = HomeworkCommon.where("course_id in #{my_course_ids} and publish_time <= '#{Date.today}'")
|
||||
homeworks = HomeworkCommon.where("course_id in #{my_course_ids} and publish_time <= '#{Time.now}'")
|
||||
homework_ids = homeworks.blank? ? "(-1)" : "(" + homeworks.map{|homework| homework.id}.join(",") + ")"
|
||||
student_works = StudentWork.where("user_id = #{@user.id} and homework_common_id in #{homework_ids} and work_status != 0")
|
||||
@unfinished_homework_count = homeworks.count - student_works.count
|
||||
|
@ -2185,11 +2244,11 @@ class UsersController < ApplicationController
|
|||
# 待完成的作业
|
||||
def unfinished_homework_list
|
||||
my_course_ids = StudentsForCourse.includes(:course).where("student_id = #{@user.id} and courses.is_delete = 0").blank? ? "(-1)" : "(" + StudentsForCourse.includes(:course).where("student_id = #{@user.id} and courses.is_delete = 0").map{|sc| sc.course_id}.join(",") + ")"
|
||||
homeworks = HomeworkCommon.where("course_id in #{my_course_ids} and publish_time <= '#{Date.today}'")
|
||||
homeworks = HomeworkCommon.where("course_id in #{my_course_ids} and publish_time <= '#{Time.now}'")
|
||||
homework_ids = homeworks.blank? ? "(-1)" : "(" + homeworks.map{|homework| homework.id}.join(",") + ")"
|
||||
student_works = StudentWork.where("user_id = #{@user.id} and homework_common_id in #{homework_ids} and work_status != 0")
|
||||
finished_works_id = student_works.blank? ? "(-1)" : "(" + student_works.map{ |sw| sw.homework_common_id.to_i }.join(",") + ")"
|
||||
@unfinished_homeworks = HomeworkCommon.where("course_id in #{my_course_ids} and publish_time <= '#{Date.today}' and id not in #{finished_works_id}").order("updated_at desc")
|
||||
@unfinished_homeworks = HomeworkCommon.where("course_id in #{my_course_ids} and publish_time <= '#{Time.now}' and id not in #{finished_works_id}").order("updated_at desc")
|
||||
@unfinished_homeworks_count = @unfinished_homeworks.count
|
||||
@limit = 20
|
||||
@unfinished_homework_pages = Paginator.new @unfinished_homeworks_count, @limit, params['page'] || 1
|
||||
|
@ -4140,7 +4199,7 @@ class UsersController < ApplicationController
|
|||
count = 0
|
||||
courses = syllabus.courses.not_deleted
|
||||
courses.each do |c|
|
||||
count += (User.current.admin? || User.current.allowed_to?(:as_teacher,c)) ? (c.homework_commons.count + visable_attachemnts_incourse(c).count) : (c.homework_commons.where("publish_time <= '#{Date.today}'").count + visable_attachemnts_incourse(c).count)
|
||||
count += (User.current.admin? || User.current.allowed_to?(:as_teacher,c)) ? (c.homework_commons.count + visable_attachemnts_incourse(c).count) : (c.homework_commons.where("publish_time <= '#{Time.now}'").count + visable_attachemnts_incourse(c).count)
|
||||
end
|
||||
syllabus[:infocount] = count
|
||||
end
|
||||
|
|
|
@ -126,7 +126,7 @@ class WordsController < ApplicationController
|
|||
if params[:user_activity_id] == params[:activity_id]
|
||||
redirect_to feedback_contest_path(@contest)
|
||||
else
|
||||
redirect_to contest_activities_contest_path(@contest)
|
||||
redirect_to contest_path(@contest)
|
||||
end
|
||||
return
|
||||
end
|
||||
|
|
|
@ -16,7 +16,7 @@ class WorksController < ApplicationController
|
|||
if @is_teacher
|
||||
@homework_commons = @contest.works.where("name like '%#{search}%'").order("created_at desc")
|
||||
else
|
||||
@homework_commons = @contest.works.where("name like '%#{search}%' and publish_time <= '#{Date.today}'").order("created_at desc")
|
||||
@homework_commons = @contest.works.where("name like '%#{search}%' and work_status > 0").order("created_at desc")
|
||||
end
|
||||
@is_new = params[:is_new]
|
||||
|
||||
|
@ -108,10 +108,16 @@ class WorksController < ApplicationController
|
|||
else
|
||||
@contestwork.publish_time = params[:homework_common][:publish_time]
|
||||
end
|
||||
if @contestwork.publish_time > Date.today
|
||||
@contestwork.work_status = 0
|
||||
elsif @contestwork.publish_time <= Date.today && @contestwork.work_status == 0
|
||||
@contestwork.work_status = 1
|
||||
end
|
||||
param_end_time = Time.parse(params[:homework_common][:end_time]).strftime("%Y-%m-%d")
|
||||
homework_end_time = Time.parse(@contestwork.end_time.to_s).strftime("%Y-%m-%d")
|
||||
work_detail_manual = @contestwork.work_detail_manual
|
||||
if homework_end_time != param_end_time
|
||||
@contestwork.end_time = params[:homework_common][:end_time]
|
||||
eval_start = Time.parse(work_detail_manual.evaluation_start.to_s).strftime("%Y-%m-%d")
|
||||
if eval_start.nil? || (eval_start <= param_end_time && @contestwork.work_status <= 2)
|
||||
work_detail_manual.evaluation_start = @contestwork.end_time + 7
|
||||
|
@ -133,8 +139,13 @@ class WorksController < ApplicationController
|
|||
end
|
||||
end
|
||||
end
|
||||
if @contestwork.end_time < Date.today && @contestwork.work_status == 1
|
||||
@contestwork.work_status = 2
|
||||
elsif @contestwork.end_time >= Date.today && @contestwork.work_status == 2
|
||||
@contestwork.work_status = 1
|
||||
#status = true
|
||||
end
|
||||
end
|
||||
@contestwork.end_time = params[:homework_common][:end_time] || Time.now
|
||||
if params[:homework_type] && params[:homework_type].to_i != @contestwork.work_type
|
||||
if @contestwork.work_type == 3
|
||||
@contestwork.work_detail_group.destroy if @contestwork.work_detail_group
|
||||
|
@ -142,14 +153,6 @@ class WorksController < ApplicationController
|
|||
end
|
||||
@contestwork.work_type = params[:homework_type].to_i || @contestwork.work_type
|
||||
|
||||
#status = false
|
||||
if @contestwork.publish_time <= Date.today && @contestwork.work_status == 0
|
||||
@contestwork.work_status = 1
|
||||
elsif @contestwork.end_time < Date.today && @contestwork.work_status == 1
|
||||
@contestwork.work_status = 2
|
||||
#status = true
|
||||
end
|
||||
|
||||
@contestwork.save_attachments(params[:attachments])
|
||||
render_attachment_warning_if_needed(@contestwork)
|
||||
|
||||
|
|
|
@ -102,7 +102,7 @@ module ApiHelper
|
|||
#获取作业的是否可以匿评的描述
|
||||
def homework_status_desc homework
|
||||
if homework.homework_type == 1 && homework.homework_detail_manual #匿评作业
|
||||
if Time.parse(homework.end_time.to_s).strftime("%Y-%m-%d") >= Time.now.strftime("%Y-%m-%d")
|
||||
if homework.end_time >= Time.now
|
||||
link = show_homework_deadline homework
|
||||
elsif homework.student_works.count >= 2 #作业份数大于2
|
||||
case homework.homework_detail_manual.comment_status
|
||||
|
|
|
@ -2990,7 +2990,7 @@ module ApplicationHelper
|
|||
def user_receive_homework_count
|
||||
stu_courses = @user.courses.visible.not_deleted.select{|course| @user.has_student_role(course)}
|
||||
stu_course_ids = stu_courses.empty? ? "(-1)" : "(" + stu_courses.map{|course| course.id}.join(',') + ")"
|
||||
@homeworks = HomeworkCommon.where("course_id in #{stu_course_ids} and publish_time <= '#{Date.today}'").count
|
||||
@homeworks = HomeworkCommon.where("course_id in #{stu_course_ids} and publish_time <= '#{Time.now}'").count
|
||||
end
|
||||
|
||||
# 用户发布的issue数
|
||||
|
@ -3070,7 +3070,7 @@ module ApplicationHelper
|
|||
|
||||
#获取匿评相关连接代码
|
||||
def homework_anonymous_comment (homework, hw_status, user_activity_id = -1)
|
||||
if homework.homework_detail_manual.comment_status == 0 ||Time.parse(homework.end_time.to_s).strftime("%Y-%m-%d") >= Time.now.strftime("%Y-%m-%d")
|
||||
if homework.homework_detail_manual.comment_status == 0 || homework.end_time >= Time.now
|
||||
link = link_to "启动匿评","javascript:void(0)", :class => "wpostOptionLink", :title => "作业截止日期之前不可以启动匿评"
|
||||
elsif homework.student_works.has_committed.count >= 2 && homework.homework_detail_manual#作业份数大于2
|
||||
case homework.homework_detail_manual.comment_status
|
||||
|
@ -3129,13 +3129,13 @@ module ApplicationHelper
|
|||
else #学生显示提交作品、修改作品等按钮
|
||||
work = cur_user_works_for_homework homework
|
||||
project = cur_user_projects_for_homework homework
|
||||
if work.nil? && Time.parse(homework.end_time.to_s).strftime("%Y-%m-%d") >= Time.now.strftime("%Y-%m-%d")
|
||||
if work.nil? && homework.end_time >= Time.now
|
||||
if homework.homework_type ==3 && project.nil? && homework.homework_detail_group.base_on_project == 1
|
||||
link_to "提交作品(#{count})","javascript:void(0)", :class => 'c_grey',:style=>"cursor:not-allowed",:title => '请先关联项目再提交作品'
|
||||
else
|
||||
link_to "提交作品(#{count})", new_student_work_url_without_domain(homework.id),:class => 'c_blue'
|
||||
end
|
||||
elsif work.nil? && Time.parse(homework.end_time.to_s).strftime("%Y-%m-%d") < Time.now.strftime("%Y-%m-%d")
|
||||
elsif work.nil? && homework.end_time < Time.now
|
||||
if homework.homework_type ==3 && project.nil? && homework.homework_detail_group.base_on_project == 1
|
||||
link_to "补交作品(#{count})","javascript:void(0)", :class => 'c_grey',:style=>"cursor:not-allowed",:title => '请先关联项目再补交作品'
|
||||
else
|
||||
|
@ -3155,9 +3155,9 @@ module ApplicationHelper
|
|||
end
|
||||
elsif homework.homework_detail_manual && homework.homework_detail_manual.comment_status == 3
|
||||
link_to "查看作品(#{count})",student_work_index_url_in_org(homework.id, 2), :class => 'c_blue', :title => "匿评已结束"
|
||||
elsif homework.homework_type == 2 && Time.parse(homework.end_time.to_s).strftime("%Y-%m-%d") >= Time.now.strftime("%Y-%m-%d")#编程作业不能修改作品
|
||||
elsif homework.homework_type == 2 && homework.end_time >= Time.now#编程作业不能修改作品
|
||||
link_to "修改作品(#{count})", new_student_work_url_without_domain(homework.id),:class => 'c_blue'
|
||||
elsif Time.parse(homework.end_time.to_s).strftime("%Y-%m-%d") >= Time.now.strftime("%Y-%m-%d") && work.user_id == User.current.id
|
||||
elsif homework.end_time >= Time.now && work.user_id == User.current.id
|
||||
link_to "修改作品(#{count})", edit_student_work_url_without_domain(work.id),:class => 'c_blue'
|
||||
else
|
||||
link_to "查看作品(#{count})", student_work_index_url_in_org(homework.id, 2), :class => 'c_blue', :title => "作业截止后不可修改作品"
|
||||
|
@ -3204,13 +3204,13 @@ module ApplicationHelper
|
|||
else User.current.member_of_course?(homework.course)
|
||||
work = cur_user_works_for_homework homework
|
||||
project = cur_user_projects_for_homework homework
|
||||
if work.nil? && Time.parse(homework.end_time.to_s).strftime("%Y-%m-%d") >= Time.now.strftime("%Y-%m-%d")
|
||||
if work.nil? && homework.end_time >= Time.now
|
||||
if homework.homework_type ==3 && project.nil? && homework.homework_detail_group.base_on_project == 1
|
||||
link_to "关联项目", student_work_index_url_in_org(homework.id, 1), :class => 'hw_btn_green fr mt5',:title => '查看分组作业详情', :target => '_blank'
|
||||
else
|
||||
link_to "提交作品", new_student_work_url_without_domain(homework.id),:class => 'hw_btn_green fr mt5', :target => '_blank'
|
||||
end
|
||||
elsif work.nil? && Time.parse(homework.end_time.to_s).strftime("%Y-%m-%d") < Time.now.strftime("%Y-%m-%d")
|
||||
elsif work.nil? && homework.end_time < Time.now
|
||||
if homework.homework_type ==3 && project.nil? && homework.homework_detail_group.base_on_project == 1
|
||||
link_to "关联项目", student_work_index_url_in_org(homework.id, 1), :class => 'hw_btn_green fr mt5',:title => '查看分组作业详情', :target => '_blank'
|
||||
else
|
||||
|
@ -3221,9 +3221,9 @@ module ApplicationHelper
|
|||
link_to "作品匿评", student_work_index_url_in_org(homework.id, 2), :class => 'hw_btn_green fr mt5', :title => "开启匿评后不可修改作品", :target => '_blank'
|
||||
elsif homework.homework_detail_manual && homework.homework_detail_manual.comment_status == 3
|
||||
link_to "查看作品",student_work_index_url_in_org(homework.id, 2), :class => 'hw_btn_green fr mt5', :title => "匿评已结束", :target => '_blank'
|
||||
elsif homework.homework_type == 2 && Time.parse(homework.end_time.to_s).strftime("%Y-%m-%d") >= Time.now.strftime("%Y-%m-%d")#编程作业不能修改作品
|
||||
elsif homework.homework_type == 2 && homework.end_time >= Time.now#编程作业不能修改作品
|
||||
link_to "修改作品", new_student_work_url_without_domain(homework.id),:class => 'hw_btn_green fr mt5', :target => '_blank'
|
||||
elsif Time.parse(homework.end_time.to_s).strftime("%Y-%m-%d") >= Time.now.strftime("%Y-%m-%d") && work.user_id == User.current.id
|
||||
elsif homework.end_time >= Time.now && work.user_id == User.current.id
|
||||
link_to "修改作品", edit_student_work_url_without_domain(work.id),:class => 'hw_btn_green fr mt5', :target => '_blank'
|
||||
else
|
||||
link_to "查看作品", student_work_index_url_in_org(homework.id, 2), :class => 'hw_btn_green fr mt5', :title => "作业截止后不可修改作品", :target => '_blank'
|
||||
|
@ -3302,7 +3302,7 @@ module ApplicationHelper
|
|||
#获取当前作业的提交截止时间/互评截止时间
|
||||
def cur_homework_end_time homework
|
||||
str = ""
|
||||
if homework.anonymous_comment == 0 && homework.end_time && homework.end_time < Date.today && homework.homework_detail_manual
|
||||
if homework.anonymous_comment == 0 && homework.end_time && homework.end_time < Time.now && homework.homework_detail_manual
|
||||
str = "互评截止:#{format_date homework.homework_detail_manual.evaluation_end}"
|
||||
else
|
||||
str = "提交截止:#{homework.end_time ? (format_date homework.end_time) : ' -- '}"
|
||||
|
@ -3975,7 +3975,7 @@ def get_hw_index(hw,is_teacher)
|
|||
if is_teacher
|
||||
homeworks = hw.course.homework_commons.order("created_at asc")
|
||||
else
|
||||
homeworks = hw.course.homework_commons.where("publish_time <= '#{Date.today}'").order("created_at asc")
|
||||
homeworks = hw.course.homework_commons.where("publish_time <= '#{Time.now}'").order("created_at asc")
|
||||
end
|
||||
hw_ids = homeworks.map{|hw| hw.id} if !homeworks.empty?
|
||||
index = hw_ids.index(hw.id)
|
||||
|
@ -3995,9 +3995,9 @@ def get_hw_status homework_common
|
|||
else
|
||||
str += '<span class="grey_homework_btn_cir ml5">匿评已禁用</span>'
|
||||
end
|
||||
if Time.parse(homework_common.end_time.to_s).strftime("%Y-%m-%d") >= Time.now.strftime("%Y-%m-%d")
|
||||
if homework_common.end_time >= Time.now
|
||||
str += '<span class="green_homework_btn_cir ml5">作品提交中</span>'
|
||||
elsif Time.parse(homework_common.end_time.to_s).strftime("%Y-%m-%d") < Time.now.strftime("%Y-%m-%d") && homework_common.anonymous_comment == 1 && User.current.allowed_to?(:as_teacher, homework_common.course)
|
||||
elsif homework_common.end_time < Time.now && homework_common.anonymous_comment == 1 && User.current.allowed_to?(:as_teacher, homework_common.course)
|
||||
str += '<span class="green_homework_btn_cir ml5" title="目前教师和教辅正在评阅">教师评阅中</span>'
|
||||
else
|
||||
str += '<span class="red_homework_btn_cir ml5">作品补交中</span>'
|
||||
|
@ -4117,6 +4117,33 @@ def create_works_list homework
|
|||
end
|
||||
end
|
||||
|
||||
def add_to_homework_bank_f homework
|
||||
homework_bank = HomeworkBank.new(:name => homework.name, :description => homework.description, :user_id => homework.user_id, :homework_type => homework.homework_type,
|
||||
:quotes => 0, :is_public => homework.course.is_public, :applicable_syllabus => homework.course.syllabus.title, :homework_common_id => homework.id)
|
||||
if homework.homework_type == 2 && homework.homework_detail_programing
|
||||
homework_bank.language = homework.homework_detail_programing.language
|
||||
homework.homework_tests.each_with_index do |homework_test|
|
||||
homework_bank.homework_bank_tests << HomeworkBankTest.new(
|
||||
test_type: 1,
|
||||
input: homework_test.input,
|
||||
output: homework_test.output
|
||||
)
|
||||
end
|
||||
homework.homework_samples.each_with_index do |homework_test|
|
||||
homework_bank.homework_bank_tests << HomeworkBankTest.new(
|
||||
test_type: 0,
|
||||
input: homework_test.input,
|
||||
output: homework_test.output
|
||||
)
|
||||
end
|
||||
elsif homework.homework_type == 3 && homework.homework_detail_group
|
||||
homework_bank.min_num = homework.homework_detail_group.min_num
|
||||
homework_bank.max_num = homework.homework_detail_group.max_num
|
||||
homework_bank.base_on_project = homework.homework_detail_group.base_on_project
|
||||
end
|
||||
homework_bank
|
||||
end
|
||||
|
||||
# 获取项目动态更新时间
|
||||
def get_forge_act_message(act, type)
|
||||
forge_act = ForgeActivity.where(:forge_act_id => act.id, :forge_act_type => type).first
|
||||
|
@ -4172,7 +4199,7 @@ def visable_contest_work contest
|
|||
if User.current.admin? || User.current.admin_of_contest?(contest)
|
||||
work_num = contest.works.count
|
||||
else
|
||||
work_num = contest.works.where("publish_time <= '#{Date.today}'").count
|
||||
work_num = contest.works.where("work_status > 0").count
|
||||
end
|
||||
work_num
|
||||
end
|
||||
|
|
|
@ -824,7 +824,7 @@ module CoursesHelper
|
|||
if User.current.admin? || User.current.allowed_to?(:as_teacher,course)
|
||||
homework_num = course.homework_commons.count
|
||||
else
|
||||
homework_num = course.homework_commons.where("publish_time <= '#{Date.today}'").count
|
||||
homework_num = course.homework_commons.where("publish_time <= '#{Time.now}'").count
|
||||
end
|
||||
homework_num
|
||||
end
|
||||
|
|
|
@ -161,7 +161,7 @@ module StudentWorkHelper
|
|||
def revise_attachment_status homework, attach
|
||||
date = Time.parse(format_time(attach.created_on.to_s)).strftime("%Y-%m-%d")
|
||||
status = ""
|
||||
if homework.homework_detail_manual && ((homework.anonymous_comment == 0 &&homework.homework_detail_manual.evaluation_start.to_s <= date) || (homework.anonymous_comment == 1 && homework.end_time.to_s < date))
|
||||
if homework.homework_detail_manual && ((homework.anonymous_comment == 0 &&homework.homework_detail_manual.evaluation_start.to_s <= date) || (homework.anonymous_comment == 1 && homework.end_time < attach.created_on))
|
||||
status = "此时其他同学作品已公开"
|
||||
else
|
||||
status = "此时其他同学作品尚未公开"
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
class HomeworkBank < ActiveRecord::Base
|
||||
# attr_accessible :title, :body
|
||||
belongs_to :user
|
||||
has_many :homework_bank_tests
|
||||
|
||||
def language_name
|
||||
%W(C C++ Python Java).at(self.language.to_i - 1)
|
||||
end
|
||||
end
|
|
@ -0,0 +1,4 @@
|
|||
class HomeworkBankTest < ActiveRecord::Base
|
||||
# attr_accessible :title, :body
|
||||
belongs_to :homework_bank
|
||||
end
|
|
@ -15,6 +15,7 @@ class HomeworkCommon < ActiveRecord::Base
|
|||
has_one :homework_detail_group, :dependent => :destroy
|
||||
has_many :student_work_projects, :dependent => :destroy
|
||||
has_many :homework_tests, :dependent => :destroy
|
||||
has_many :homework_samples, :dependent => :destroy
|
||||
has_many :student_works, :dependent => :destroy, :conditions => "is_test=0 and is_delete != 1"
|
||||
has_many :student_works_evaluation_distributions, :through => :student_works #一个作业的分配的匿评列表
|
||||
has_many :journals_for_messages, :as => :jour, :dependent => :destroy
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
class HomeworkSample < ActiveRecord::Base
|
||||
belongs_to :homework_common
|
||||
attr_accessible :input, :output, :homework_common_id
|
||||
end
|
|
@ -159,7 +159,7 @@ class Member < ActiveRecord::Base
|
|||
|
||||
#当前课程的作业列表
|
||||
def homework_common_list
|
||||
HomeworkCommon.where("course_id = ? and publish_time is not null and publish_time <= '#{Date.today}'", self.course_id)
|
||||
HomeworkCommon.where("course_id = ? and publish_time is not null and publish_time <= '#{Time.now}'", self.course_id)
|
||||
end
|
||||
|
||||
#当前学生在指定作业内的得分
|
||||
|
|
|
@ -190,7 +190,7 @@ class StudentWork < ActiveRecord::Base
|
|||
|
||||
# status == 0 : delay
|
||||
def act_as_message
|
||||
if self.work_status != 0 && self.created_at > self.homework_common.end_time + 1
|
||||
if self.work_status != 0 && self.created_at > self.homework_common.end_time
|
||||
self.course_messages << CourseMessage.new(:user_id => self.user_id, :course_id => self.homework_common.course_id, :viewed => false, :status => false)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -114,6 +114,8 @@ class User < Principal
|
|||
has_many :apply_homeworks, :dependent => :destroy
|
||||
has_many :apply_resources, :dependent => :destroy
|
||||
#end
|
||||
#题库
|
||||
has_many :homework_banks, :dependent => :destroy
|
||||
#竞赛
|
||||
has_many :contests, :dependent => :destroy
|
||||
has_many :works, :dependent => :destroy
|
||||
|
|
|
@ -702,7 +702,7 @@ class CoursesService
|
|||
def homework_list params,current_user
|
||||
course = Course.find(params[:id])
|
||||
if course.is_public != 0 || current_user.member_of_course?(course)
|
||||
bids = course.homework_commons.where("publish_time <= ?",Time.now.strftime("%Y-%m-%d")).page(params[:page] || 1).per(20).reorder('created_at DESC')
|
||||
bids = course.homework_commons.where("publish_time <= ?",Time.now).page(params[:page] || 1).per(20).reorder('created_at DESC')
|
||||
bids = bids.like(params[:name]) if params[:name].present?
|
||||
homeworks = []
|
||||
bids.each do |bid|
|
||||
|
|
|
@ -105,7 +105,7 @@ class HomeworkService
|
|||
def start_anonymous_comment params,current_user
|
||||
homework = HomeworkCommon.find(params[:homework_id])
|
||||
return {:status=> 4} unless current_user.admin? || current_user.allowed_to?(:as_teacher,Course.find(params[:course_id]))
|
||||
return {:status=>5} if Time.parse(homework.end_time.to_s).strftime("%Y-%m-%d") >= Time.now.strftime("%Y-%m-%d")
|
||||
return {:status=>5} if homework.end_time >= Time.now
|
||||
homework_detail_manual = homework.homework_detail_manual
|
||||
if homework_detail_manual.comment_status == 1
|
||||
student_works = homework.student_works
|
||||
|
|
|
@ -193,7 +193,7 @@ class ResourcesService
|
|||
|
||||
courses_ids = courses.empty? ? '(-1)' :"(" + courses.map(&:id).join(",") + ")"
|
||||
|
||||
homeworks = HomeworkCommon.where("course_id in #{courses_ids} and publish_time <= ?",Time.now.strftime("%Y-%m-%d")).order("created_at desc")
|
||||
homeworks = HomeworkCommon.where("course_id in #{courses_ids} and publish_time <= ?",Time.now).order("created_at desc")
|
||||
|
||||
# homeworks.each do |v|
|
||||
# course = Course.where("id=?",v.course_id).first
|
||||
|
|
|
@ -59,5 +59,5 @@
|
|||
|
||||
<% if contest_activities.count + page * 10 < @contest_activities_count %>
|
||||
<!--<div id="show_more_course_activities" class="loadMore mt10 f_grey">点击展开更多<%#= link_to "", course_activity_path(@course.id, :type => type, :page => page), :id => "more_course_activities_link", :remote => "true", :class => "none" %></div>-->
|
||||
<%= link_to "点击展开更多",contest_activities_contest_path(@contest.id, :type => type, :page => page),:id => "show_more_course_activities",:remote => "true",:class => "loadMore mt10 f_grey"%>
|
||||
<%= link_to "点击展开更多",contest_path(@contest.id, :type => type, :page => page),:id => "show_more_course_activities",:remote => "true",:class => "loadMore mt10 f_grey"%>
|
||||
<% end %>
|
||||
|
|
|
@ -1,30 +1,57 @@
|
|||
<div class="homepageRight mt0 ml10" onmouseover="$('#edit_link').show(); " onmouseout="$('#edit_link').hide();" style="background-color: #fff;">
|
||||
<div class="contestRightBanner border-bottom">
|
||||
<div class="NewsBannerName">
|
||||
竞赛介绍
|
||||
</div>
|
||||
<% if User.current.admin_of_contest?(@contest) %>
|
||||
<%= link_to "编辑", {:controller => 'contests', :action => 'settings', :id => @contest}, :class => "link-blue fr mt5 none", :id => "edit_link" %>
|
||||
<% end %>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
|
||||
<div>
|
||||
<% if (@contest.description.nil? || (@contest.description == "" && @contest.attachments.blank?)) && User.current.admin_of_contest?(@contest) %>
|
||||
<div class="icons_tishi"><img src="../images/sy/icons_tan.png" width="110" height="110" alt="" ></div>
|
||||
<p class="sy_tab_con_p">请尽快补充竞赛说明,赢得更多参赛者的青睐吧~</p>
|
||||
<% elsif (@contest.description.nil? || (@contest.description == "" && @contest.attachments.blank?)) %>
|
||||
<div class="icons_tishi"><img src="../images/sy/icons_tan.png" width="110" height="110" alt="" ></div>
|
||||
<p class="sy_tab_con_p">尚未发布竞赛说明,敬请期待~</p>
|
||||
<% else %>
|
||||
<div class="description_div">
|
||||
<div class="syllabuscon upload_img ke-block break_word" id="syllabus_description_<%= @contest.id %>">
|
||||
<%= @contest.description.html_safe %>
|
||||
</div>
|
||||
<div class="mt10" style="font-weight:normal; font-size: 12px;">
|
||||
<%= render :partial=>"attachments/activity_attach", :locals=>{:activity => @contest} %>
|
||||
</div>
|
||||
<div class="homepageRight mt0 ml10" onmouseover="$('#edit_link').show(); " onmouseout="$('#edit_link').hide();">
|
||||
<div style="background-color: #fff;">
|
||||
<div class="contestRightBanner border-bottom">
|
||||
<div class="NewsBannerName">
|
||||
竞赛介绍
|
||||
</div>
|
||||
<% end %>
|
||||
<% if User.current.admin_of_contest?(@contest) %>
|
||||
<%= link_to "编辑", {:controller => 'contests', :action => 'settings', :id => @contest}, :class => "link-blue fr mt5 none", :id => "edit_link" %>
|
||||
<% end %>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
|
||||
<div>
|
||||
<% if (@contest.description.nil? || (@contest.description == "" && @contest.attachments.blank?)) && User.current.admin_of_contest?(@contest) %>
|
||||
<div class="icons_tishi"><img src="../images/sy/icons_tan.png" width="110" height="110" alt="" ></div>
|
||||
<p class="sy_tab_con_p" style="margin-bottom: 0px; padding-bottom: 100px;">请尽快补充竞赛说明,赢得更多参赛者的青睐吧~</p>
|
||||
<% elsif (@contest.description.nil? || (@contest.description == "" && @contest.attachments.blank?)) %>
|
||||
<div class="icons_tishi"><img src="../images/sy/icons_tan.png" width="110" height="110" alt="" ></div>
|
||||
<p class="sy_tab_con_p" style="margin-bottom: 0px; padding-bottom: 100px;">尚未发布竞赛说明,敬请期待~</p>
|
||||
<% else %>
|
||||
<div class="description_div">
|
||||
<div class="syllabuscon upload_img ke-block break_word" id="syllabus_description_<%= @contest.id %>">
|
||||
<%= @contest.description.html_safe %>
|
||||
</div>
|
||||
<div class="mt10" style="font-weight:normal; font-size: 12px;">
|
||||
<%= render :partial=>"attachments/activity_attach", :locals=>{:activity => @contest} %>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mt10">
|
||||
<div class="homepageRightBanner">
|
||||
<div class="NewsBannerName">
|
||||
<%= get_acts_list_type @type %></div>
|
||||
<ul class="resourcesSelect">
|
||||
<li class="resourcesSelected"><a href="javascript:void(0);" class="resourcesIcon"></a>
|
||||
<ul class="homepagePostType" style="width:90px; left:-80px;">
|
||||
<li>
|
||||
<ul class="homepagePostTypeHomework fl">
|
||||
<li><%= link_to "全部动态", contest_path(@contest), :class =>"homepagePostTypeAll postTypeGrey"%></li>
|
||||
<li><%= link_to "作品动态", contest_path(@contest, :type => 'work'), :class => "homepagePostTypeAssignment postTypeGrey"%></li>
|
||||
<li><%= link_to "通知动态", contest_path(@contest, :type => 'news'), :class => "homepagePostTypeNotice postTypeGrey"%></li>
|
||||
<!--<li><%#= link_to "资源库动态", {:controller => "courses", :action => "show", :type => "attachment"}, :class => "homepagePostTypeResource resourcesGrey"%></li>-->
|
||||
<li><%= link_to "论坛动态", contest_path(@contest, :type => 'message'), :class => "homepagePostTypeForum postTypeGrey"%></li>
|
||||
<li><%= link_to "留言动态", contest_path(@contest, :type => 'journalsForMessage'), :class => "homepagePostTypeMessage postTypeGrey"%></li>
|
||||
<!--<li><%#= link_to "问卷动态", {:controller => "courses", :action => "show", :type => "poll"}, :class => "homepagePostTypeQuiz postTypeGrey"%></li>-->
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<%= render :partial => 'contests/contest_activity', :locals => {:contest_activities => @contest_activities,:page => 0,:type => @type} %>
|
||||
</div>
|
||||
</div>
|
|
@ -0,0 +1 @@
|
|||
$("#show_more_course_activities").replaceWith("<%= escape_javascript( render :partial => 'contests/contest_activity',:locals => {:contest_activities => @contest_activities, :page => @page,:type => @type} )%>");
|
|
@ -20,7 +20,8 @@
|
|||
<% elsif @sort_type == "score" && @score_sort_by == 'asc' %>
|
||||
<a href="javascript:void(0)" class="sy_sortdownbtn"></a>
|
||||
<% end %>
|
||||
<div class="sy_fenban_show undis" >
|
||||
<div class="sy_fenban_show undis" style="left: <%=is_teacher ? '484px;' : '481px;' %>">
|
||||
<span style="top: 16px;"></span>
|
||||
<p>积分规则<br/>
|
||||
班级作业的得分总和</p>
|
||||
</div>
|
||||
|
@ -32,7 +33,8 @@
|
|||
<% elsif @sort_type == "ex_score" && @score_sort_by == 'asc' %>
|
||||
<a href="javascript:void(0)" class="sy_sortdownbtn"></a>
|
||||
<% end %>
|
||||
<div class="sy_fenban_show undis" >
|
||||
<div class="sy_fenban_show undis" style="left: <%=is_teacher ? '399px' : '392px' %>;">
|
||||
<span style="top: 16px;"></span>
|
||||
<p>积分规则<br/>
|
||||
班级测验的得分总和</p>
|
||||
</div>
|
||||
|
@ -44,7 +46,8 @@
|
|||
<% elsif @sort_type == "act_score" && @score_sort_by == 'asc' %>
|
||||
<a href="javascript:" class= "sy_sortdownbtn"></a>
|
||||
<% end %>
|
||||
<div class="sy_fenban_show undis" >
|
||||
<div class="sy_fenban_show undis" style="left: <%=is_teacher ? '315px' : '303px' %>;">
|
||||
<span style="top: 16px;"></span>
|
||||
<p>积分规则<br/>
|
||||
资源发布:资源数 x 5 <br>
|
||||
问答发布:发帖数 x 2 <br>
|
||||
|
@ -58,7 +61,8 @@
|
|||
</div>
|
||||
</th>
|
||||
<th class="<%= is_teacher ? 'sy_th0' : 'sy_th1' %> sy_fenban_tap">总得分
|
||||
<div class="sy_fenban_show undis" style="width:180px;">
|
||||
<div class="sy_fenban_show undis" style="left: <%=is_teacher ? '230px' : '214px' %>;">
|
||||
<span style="top: 16px;"></span>
|
||||
<p>积分规则<br/>
|
||||
作业得分+测评得分+社区得分</p>
|
||||
</div>
|
||||
|
@ -212,6 +216,16 @@
|
|||
});
|
||||
});
|
||||
|
||||
$(".sy_fenban_tap").each(function(){
|
||||
$(this).mouseenter(function(){
|
||||
$(".sy_fenban_show").hide();
|
||||
$(this).children('.sy_fenban_show').show();
|
||||
});
|
||||
$(this).mouseleave(function(){
|
||||
$(this).children('.sy_fenban_show').hide(0);
|
||||
});
|
||||
});
|
||||
|
||||
$(".sy_tips_box_inner").each(function(){
|
||||
$(this).mouseover(function(){
|
||||
$(this).stop();
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
</div>
|
||||
<div class="cl"></div>
|
||||
<p class="sy_cgrey ml20">
|
||||
<% homework_count = e_course.homework_commons.where("publish_time <= '#{Date.today}'").count %>
|
||||
<% homework_count = e_course.homework_commons.where("publish_time <= '#{Time.now}'").count %>
|
||||
<% if homework_count > 0 %>
|
||||
作业<span class="sy_cir_grey ml5 mr5"><%=homework_count %></span>
|
||||
<% end %>
|
||||
|
|
|
@ -42,7 +42,6 @@
|
|||
<% elsif @select_tab == 'boards'%>
|
||||
$("#tb_4").click();
|
||||
<% end %>
|
||||
$("#homework_page_right").css("min-height",$("#courseLSide").height()+45);
|
||||
});
|
||||
|
||||
function g(o){
|
||||
|
|
|
@ -63,9 +63,9 @@
|
|||
<% end %>
|
||||
</ul>
|
||||
<% if @course.is_delete == 1 %>
|
||||
<div class="mt30 ml30"><%=link_to "恢复该班级", renew_course_path(@course) %></div>
|
||||
<div class="mt30 ml30 mb15"><%=link_to "恢复该班级", renew_course_path(@course) %></div>
|
||||
<% else %>
|
||||
<div class="mt30 ml30">
|
||||
<div class="mt30 ml30 mb15">
|
||||
<img src="/images/pic_del.gif" class="mr5"><%=link_to "删除该班级", course_path(@course), :method => :delete, :confirm=>"确认要删除该班级吗?" %>
|
||||
<span>(友情提示:删除该班级后如果您想恢复该班级,请联系系统管理员!)</span>
|
||||
</div>
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
var str = "";
|
||||
<% if params[:type].to_i == 1 %>
|
||||
str = "加入题库已成功";
|
||||
<% elsif params[:type].to_i == 2 %>
|
||||
str = "已经同步更新到题库";
|
||||
<% elsif params[:type].to_i == 3 %>
|
||||
str = "已经另存到题库";
|
||||
<% end %>
|
||||
notice_box(str);
|
||||
<% if @hw_status == 5 %>
|
||||
$("#homework_post_brief").html("<%= escape_javascript(render :partial => 'student_work/homework_post_brief', :locals => {:homework => @homework, :is_teacher => @is_teacher}) %>");
|
||||
<% else %>
|
||||
$("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'users/course_homework', :locals => {:activity => @homework,:user_activity_id =>@user_activity_id,:hw_status=>@hw_status}) %>");
|
||||
<% end %>
|
||||
<% if @user_activity_id != @homework.id %>
|
||||
sd_create_editor_from_data(<%= @user_activity_id%>,"","100%", "UserActivity");
|
||||
<% else %>
|
||||
sd_create_editor_from_data(<%= @homework.id%>,"","100%", "<%=@homework.class.to_s%>");
|
||||
<% end %>
|
|
@ -0,0 +1,17 @@
|
|||
<% if @status == 1 %>
|
||||
notice_box("该作业已发布");
|
||||
<% elsif @status == 2 %>
|
||||
notice_box("您还没有设置截止时间<br/>请先编辑作业并设置截止时间和发布时间");
|
||||
<% else %>
|
||||
notice_box("发布成功");
|
||||
<% if @hw_status == 5 %>
|
||||
$("#homework_post_brief").html("<%= escape_javascript(render :partial => 'student_work/homework_post_brief', :locals => {:homework => @homework, :is_teacher => @is_teacher}) %>");
|
||||
<% else %>
|
||||
$("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'users/course_homework', :locals => {:activity => @homework,:user_activity_id =>@user_activity_id,:hw_status=>@hw_status}) %>");
|
||||
<% end %>
|
||||
<% if @user_activity_id != @homework.id %>
|
||||
sd_create_editor_from_data(<%= @user_activity_id%>,"","100%", "UserActivity");
|
||||
<% else %>
|
||||
sd_create_editor_from_data(<%= @homework.id%>,"","100%", "<%=@homework.class.to_s%>");
|
||||
<% end %>
|
||||
<% end %>
|
|
@ -43,7 +43,7 @@
|
|||
<% end %>
|
||||
<!--实训任务-->
|
||||
<% if !@project.enabled_modules.where("name = 'training_tasks'").empty? %>
|
||||
<% if User.current.admin? || is_project_member?(User.current.id, @project.id) %>
|
||||
<% if User.current.admin? || is_project_manager?(User.current.id, @project.id) || is_project_manager?(User.current, @project.try(:forked_from_project_id)) %>
|
||||
<li id="project_menu_011">
|
||||
<%= link_to training_tasks_count > 0 ? "#{l(:project_module_training_tasks)}<span class='issues_nav_tag ml5'>#{switch_integer_into_k training_tasks_count}</span>".html_safe : "#{l(:project_module_training_tasks)}", project_training_tasks_url(@project), :class => "pro_new_proname", :title => "#{training_tasks_count}" %>
|
||||
</li>
|
||||
|
|
|
@ -44,11 +44,11 @@
|
|||
<div class="sy_class_leftnav mb12" >
|
||||
<ul class="accordion">
|
||||
<li id="sy_01" class="sy_icons_game">
|
||||
<%= link_to '竞赛首页', contest_path(@contest) %>
|
||||
</li>
|
||||
<li id="sy_02" class="sy_icons_index">
|
||||
<%= link_to '动态', contest_activities_contest_path(@contest) %>
|
||||
<a href="<%= contest_path(@contest) %>">动态<span><%=@contest.contest_activities.count %></span></a>
|
||||
</li>
|
||||
<!--<li id="sy_02" class="sy_icons_index">-->
|
||||
<!--<%#= link_to '动态', contest_activities_contest_path(@contest) %>-->
|
||||
<!--</li>-->
|
||||
<!--<li id="sy_03" class="sy_icons_boards"> <a href="">讨论区<span>26</span></a> <a href="javascript:void(0);" class="sy_class_add"></a></li>-->
|
||||
<li id="sy_03" class="sy_icons_hwork">
|
||||
<a href="<%= works_path(:contest => @contest) %>">提交<span><%= work_num%></span></a>
|
||||
|
|
|
@ -41,7 +41,7 @@
|
|||
<% when "Issue" %>
|
||||
<%= render :partial => 'projects/act_issues', :locals => {:activity => activity.forge_act, :user_activity_id => activity.id, :project_id => activity.project_id} %>
|
||||
<% when "TrainingTask" %>
|
||||
<% if User.current.admin? || is_project_member?(User.current.id, @project.id) %>
|
||||
<% if User.current.admin? || is_project_manager?(User.current.id, @project.id) || is_project_manager?(User.current, @project.try(:forked_from_project_id)) %>
|
||||
<%= render :partial => 'projects/act_training_tasks', :locals => {:activity => activity.forge_act, :user_activity_id => activity.id, :project_id => activity.project_id} %>
|
||||
<% end %>
|
||||
<!--message-->
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
<%= link_to student_work_name, student_work_path(student_work.id),:remote => true,:title => student_work.name, :class => "c_blue02"%>
|
||||
</li>
|
||||
<li class=" hwork_time_c">
|
||||
<% if Time.parse(@homework.end_time.to_s).strftime("%Y-%m-%d") < Time.parse(student_work.created_at.to_s).strftime("%Y-%m-%d") %>
|
||||
<% if @homework.end_time < student_work.created_at %>
|
||||
<span class="c_red">迟交</span>
|
||||
<% else%>
|
||||
<%= student_work.created_at.strftime("%m-%d").to_s%>
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
<td class="hworkList130 c_grey student_work_<%= student_work.id %>" onclick="show_student_work('<%= student_work_path(student_work)%>');" style="cursor: pointer;">
|
||||
<% if student_work.created_at && @homework.end_time %>
|
||||
<%= Time.parse(format_time(student_work.created_at)).strftime("%m-%d %H:%M") %>
|
||||
<% if Time.parse(@homework.end_time.to_s).strftime("%Y-%m-%d") < Time.parse(format_time(student_work.created_at)).strftime("%Y-%m-%d") %>
|
||||
<% if @homework.end_time < student_work.created_at %>
|
||||
<span class="c_red">[迟交]</span>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
<td class="hworkList110 c_grey student_work_<%= student_work.id %>" onclick="show_student_work('<%= student_work_path(student_work)%>');" style="cursor: pointer;">
|
||||
<% if student_work.created_at && @homework.end_time %>
|
||||
<%= Time.parse(format_time(student_work.created_at)).strftime("%m-%d %H:%M") %>
|
||||
<% if Time.parse(@homework.end_time.to_s).strftime("%Y-%m-%d") < Time.parse(format_time(student_work.created_at)).strftime("%Y-%m-%d") %>
|
||||
<% if @homework.end_time < student_work.created_at %>
|
||||
<span class="c_red">[迟交]</span>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
<li class="hworkList130 c_grey student_work_<%= student_work.id%>" onclick="show_student_work('<%= student_work_path(student_work)%>');" style="cursor: pointer;">
|
||||
<% if student_work.created_at && @homework.end_time%>
|
||||
<%= Time.parse(format_time(student_work.created_at)).strftime("%m-%d %H:%M")%>
|
||||
<% if Time.parse(@homework.end_time.to_s).strftime("%Y-%m-%d") < Time.parse(format_time(student_work.created_at)).strftime("%Y-%m-%d") %>
|
||||
<% if @homework.end_time < student_work.created_at %>
|
||||
<span class="c_red">[迟交]</span>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
|
|
@ -63,7 +63,7 @@
|
|||
|
||||
<li class="hworkList130 pl10 c_grey student_work_<%= student_work.id%>" onclick="show_student_work('<%= student_work_path(student_work)%>');" style="cursor: pointer;">
|
||||
<%= Time.parse(format_time(student_work.created_at)).strftime("%m-%d %H:%M")%>
|
||||
<% if Time.parse(@homework.end_time.to_s).strftime("%Y-%m-%d") < Time.parse(format_time(student_work.created_at)).strftime("%Y-%m-%d") %>
|
||||
<% if @homework.end_time < student_work.created_at %>
|
||||
<span class="c_red">[迟交]</span>
|
||||
<% end %>
|
||||
</li>
|
||||
|
|
|
@ -25,11 +25,11 @@
|
|||
<% end %>
|
||||
<% if !homework.publish_time.nil? %>
|
||||
<div class="homepagePostDeadline <%= (is_pro || is_base_group) ? 'mt8' : '' %>">
|
||||
<%= l(:label_publish_time)%>:<%= homework.publish_time%> 00:00
|
||||
<%= l(:label_publish_time)%>:<%= format_time homework.publish_time%>
|
||||
</div>
|
||||
<% end %>
|
||||
<% if !homework.end_time.nil? %>
|
||||
<div class="homepagePostDeadline ml15 <%= (is_pro || is_base_group) ? 'mt8' : '' %>">提交截止时间:<%= homework.end_time.to_s %> 23:59</div>
|
||||
<div class="homepagePostDeadline ml15 <%= (is_pro || is_base_group) ? 'mt8' : '' %>">提交截止时间:<%= format_time homework.end_time %></div>
|
||||
<% end %>
|
||||
<div class="cl"></div>
|
||||
</div>
|
||||
|
@ -40,6 +40,32 @@
|
|||
<%= homework.description.html_safe %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<% samples = homework.homework_samples %>
|
||||
<% unless samples.empty? %>
|
||||
<div class="mt5 homeworkInfo">
|
||||
<p>输入输出样例:<%= samples.count %>组</p>
|
||||
<% samples.each_with_index do |sample, index| %>
|
||||
<span class="fl mt10">#<%= index + 1 %></span>
|
||||
<ul class="fl ml20 mt10 program_input_ul">
|
||||
<li>
|
||||
<span class="fl">样例输入:</span>
|
||||
<div class="fl ml10">
|
||||
<pre class="program_input_pre"><%=sample.input %></pre>
|
||||
</div>
|
||||
</li>
|
||||
<li class="mt5">
|
||||
<span class="fl">样例输出:</span>
|
||||
<div class="fl ml10">
|
||||
<pre class="program_input_pre"><%=sample.output %></pre>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
<div class="cl"></div>
|
||||
<% end %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<% if is_pro %>
|
||||
<div class="mt10"> <span class="fontGrey3">测试集:<%=homework.homework_tests.count %>组</span>
|
||||
<table class="mt5 test-set-table">
|
||||
|
@ -62,7 +88,7 @@
|
|||
<div class="mt5">
|
||||
<% if homework.homework_detail_manual%>
|
||||
<% if homework.homework_detail_manual.comment_status == 1%>
|
||||
<% end_time = homework.end_time.to_time.to_i + 24*60*60 - 1 %>
|
||||
<% end_time = homework.end_time.to_i %>
|
||||
<% if end_time >= Time.now.to_i %>
|
||||
<div class="fontGrey2 db fr">提交剩余时间: <span class="c_red"><%= (end_time - Time.now.to_i) / (24*60*60) %></span> 天
|
||||
<span class="c_red"><%= ((end_time - Time.now.to_i) % (24*60*60)) / (60*60)%></span> 小时
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<a href="javascript:void(0);" class="linkBlue mt5 mb5" style="margin-left:165px; width: 24px;" onclick="$('#about_hwork_<%= work.id%>').html('');">收起</a>
|
||||
</li>
|
||||
|
||||
<% if work.user == User.current && Time.parse(@homework.end_time.to_s).strftime("%Y-%m-%d") >= Time.now.strftime("%Y-%m-%d") %>
|
||||
<% if work.user == User.current && @homework.end_time >= Time.now %>
|
||||
<!-- 我的作业 && 匿评作业 && 未开启匿评,显示编辑和删除按钮 -->
|
||||
<li class="fr" >
|
||||
<%= link_to("", student_work_path(work),:method => 'delete', :confirm => l(:text_are_you_sure), :class => "pic_del") %>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<% revise_attachment = work.attachments.where("attachtype = 7").first %>
|
||||
<% if @homework.end_time < Date.today %>
|
||||
<% if @homework.end_time < Time.now %>
|
||||
<% if revise_attachment && work.user != User.current %>
|
||||
<div class="resubAtt mb15">
|
||||
<span class="resubTitle">作业修订附件</span>
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
<%=format_time work.commit_time %>
|
||||
</li>
|
||||
|
||||
<% if work.user == User.current && Time.parse(@homework.end_time.to_s).strftime("%Y-%m-%d") >= Time.now.strftime("%Y-%m-%d") %>
|
||||
<% if work.user == User.current && @homework.end_time >= Time.now %>
|
||||
<!-- 我的作业 && 匿评作业 && 未开启匿评,显示编辑和删除按钮 -->
|
||||
<li class="fr" >
|
||||
<%= link_to("", student_work_path(work),:method => 'delete', :confirm => l(:text_are_you_sure), :class => "pic_del",:title=>"删除") %>
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
<%= link_to student_work_name, student_work_path(student_work),:remote => true,:title => student_work.name, :class => "c_blue02"%>
|
||||
</li>
|
||||
<li class=" hwork_time_c">
|
||||
<% if Time.parse(@homework.end_time.to_s).strftime("%Y-%m-%d") < Time.parse(student_work.created_at.to_s).strftime("%Y-%m-%d") %>
|
||||
<% if @homework.end_time < student_work.created_at %>
|
||||
<span class="c_red">迟交</span>
|
||||
<% else%>
|
||||
<%= student_work.created_at.strftime("%m-%d").to_s%>
|
||||
|
|
|
@ -16,9 +16,9 @@
|
|||
<% unless @homework.homework_type == 3 && @homework.homework_detail_group.base_on_project == 1 %>
|
||||
<%=link_to "提交作品", new_student_work_url_without_domain(@homework.id),:class => 'blueCir ml5 f12' %>
|
||||
<% end %>
|
||||
<% elsif !@is_teacher && my_work &&Time.parse(@homework.end_time.to_s).strftime("%Y-%m-%d") < Time.parse(Time.now.to_s).strftime("%Y-%m-%d") && !@stundet_works.empty?%>
|
||||
<% elsif !@is_teacher && my_work &&@homework.end_time < Time.now && !@stundet_works.empty?%>
|
||||
<span class="f12 c_red">截止日期已过,已提交且不可修改</span>
|
||||
<% elsif !@is_teacher && my_work &&Time.parse(@homework.end_time.to_s).strftime("%Y-%m-%d") >= Time.parse(Time.now.to_s).strftime("%Y-%m-%d") && !@stundet_works.empty?%>
|
||||
<% elsif !@is_teacher && my_work &&@homework.end_time >= Time.now && !@stundet_works.empty?%>
|
||||
<% if @homework.homework_type == 3 %>
|
||||
<span class="f12 c_red">组长已提交,组长还可修改</span>
|
||||
<% else %>
|
||||
|
@ -36,7 +36,7 @@
|
|||
<%= link_to "代码查重", work_canrepeat_student_work_index_path(homework:@homework.id, course_id:@course.id), class: 'BlueCirBtn fl',:remote => true %>
|
||||
<% end %>
|
||||
<% end%>
|
||||
<% if !@is_teacher && @homework.homework_type == 3 && my_work && my_work.user == User.current && Time.parse(@homework.end_time.to_s).strftime("%Y-%m-%d") < Time.parse(Time.now.to_s).strftime("%Y-%m-%d") %>
|
||||
<% if !@is_teacher && @homework.homework_type == 3 && my_work && my_work.user == User.current && @homework.end_time < Time.now %>
|
||||
<div class="mt5 fr">
|
||||
<a href="javascript:void(0);" class="memberBtn fl mt3" title="添加小组成员" onclick="add_or_delete_group_member();">合作成员</a>
|
||||
</div>
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
<%= link_to_short_attachment attachment,:length=> 58, :class => 'hidden link_file_a fl newsBlue mw360', :download => true -%>
|
||||
</span>
|
||||
</span>
|
||||
<% if attachment.id && User.current == attachment.author && (attachment.attachtype == 7 || @homework.end_time >= Date.today) %>
|
||||
<% if attachment.id && User.current == attachment.author && (attachment.attachtype == 7 || @homework.end_time >= Time.now) %>
|
||||
<%= link_to(' '.html_safe, attachment_path(attachment, :format => 'js'), :method => 'delete', :remote => true, :title => '删除', :class => 'remove-upload fl', :confirm => l(:text_are_you_sure)) %>
|
||||
<% end %>
|
||||
<span class="postAttSize">(<%= number_to_human_size attachment.filesize %>)</span>
|
||||
|
|
|
@ -41,7 +41,7 @@
|
|||
<% if User.current.admin? || User.current.allowed_to?(:as_teacher,course) %>
|
||||
<% homework_num = course.homework_commons.count %>
|
||||
<% else %>
|
||||
<% homework_num = course.homework_commons.where("publish_time <= '#{Date.today}'").count %>
|
||||
<% homework_num = course.homework_commons.where("publish_time <= '#{Time.now}'").count %>
|
||||
<% end %>
|
||||
<span class=" mr15">作业:
|
||||
<% if (course.is_public == 0 && !User.current.member_of_course?(course)) || @list_type == 1 %>
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
<% end %>
|
||||
<div class=" fl ml5">
|
||||
<div class="issues_list_titlebox clear">
|
||||
<a href="<%= training_task_path(activity)%>" class="issues_list_title fl task-list-title" target="_blank" title="<%= activity.subject.to_s %>" >
|
||||
<a href="<%= training_task_path(activity, :project_id => @project.id) %>" class="issues_list_title fl task-list-title" target="_blank" title="<%= activity.subject.to_s %>" >
|
||||
<span class="task-step mr5">step<%= activity.position %></span>
|
||||
<%= activity.subject.to_s %>
|
||||
</a>
|
||||
|
@ -31,13 +31,6 @@
|
|||
<a href="javascript:void(0);" class="fl mt2"><%= activity.journals.count %></a>
|
||||
<% end %>
|
||||
</td>
|
||||
<% if @project.is_child_training_project? %>
|
||||
<td>
|
||||
<div id="task_action_status_<%= activity.id %>">
|
||||
<%= render :partial => 'action_status', :locals => {:activity => activity} %>
|
||||
</div>
|
||||
</td>
|
||||
<% end %>
|
||||
</tr>
|
||||
<% end %>
|
||||
|
||||
|
|
|
@ -222,9 +222,6 @@
|
|||
<tr>
|
||||
<th><p class="text-left">所有<span class="issues_nav_tag ml5" style=" font-weight: normal;"><%= @training_tasks_count %></span></p></th>
|
||||
<th class="w50"> </th>
|
||||
<% if @project.is_child_training_project? %>
|
||||
<th class="w100"> </th>
|
||||
<% end %>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="issue_list">
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<div class="orig_user fl">
|
||||
<%= link_to image_tag(url_to_avatar(comment.creator_user), :width => "33", :height => "33"), user_path(comment.creator_user), :alt => "用户头像" %>
|
||||
</div>
|
||||
<div class="<%= comment.journalized_type == 'TrainingTask' ? 'new_orig_right fl' : 'orig_right fl' %>" onmouseout="$(this).find('.reply-right').hide();" onmouseover="$(this).find('.reply-right').show();">
|
||||
<div class="<%= type == 'TrainingTask' ? 'new_orig_right fl' : 'orig_right fl' %>" onmouseout="$(this).find('.reply-right').hide();" onmouseover="$(this).find('.reply-right').show();">
|
||||
<%= link_to comment.creator_user.show_name, user_path(comment.creator_user), :class => "content-username" %>
|
||||
<span class="orig_area"><%= time_from_now(comment.respond_to?(:created_on) ? comment.created_on : comment.created_at) %></span>
|
||||
<div class="orig_content">
|
||||
|
|
|
@ -34,15 +34,15 @@
|
|||
<div class="homepagePostSubmitContainer">
|
||||
<%= render :partial => 'users/homework_opr', :locals => {:activity => activity, :is_teacher => is_teacher, :hw_status => hw_status, :user_activity_id => user_activity_id} %>
|
||||
<% if !activity.end_time.nil? %>
|
||||
<div class="homepagePostDeadline">提交截止时间:<%= activity.end_time.to_s %> 23:59</div>
|
||||
<div class="homepagePostDeadline">提交截止时间:<%= format_time activity.end_time %></div>
|
||||
<% end %>
|
||||
<% if activity.homework_detail_manual.comment_status == 0 && !activity.publish_time.nil? %>
|
||||
<div class="homepagePostDeadline ml15">
|
||||
<%= l(:label_publish_time)%>:<%= activity.publish_time%> 00:00
|
||||
<%= l(:label_publish_time)%>:<%= format_time activity.publish_time%>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
<%=render :partial =>"users/intro_content", :locals=>{:user_activity_id =>user_activity_id, :content=>activity.description} %>
|
||||
<%=render :partial =>"users/intro_content", :locals=>{:user_activity_id =>user_activity_id, :content=>activity.description, :samples => activity.homework_samples} %>
|
||||
|
||||
<div class="cl"></div>
|
||||
<div id="intro_content_show_<%= user_activity_id%>" class="fr" style="display:none;"><a href="javascript:void(0);" class="linkBlue">[展开]</a></div>
|
||||
|
|
|
@ -95,6 +95,11 @@
|
|||
<li>
|
||||
<%= link_to(l(:label_bid_respond_delete), homework_common_path(activity, :hw_status => hw_status),:method => 'delete', :confirm => l(:text_are_you_sure), :class => "wpostOptionLink") %>
|
||||
</li>
|
||||
<% if comment_status == 0 %>
|
||||
<li>
|
||||
<%= link_to("立即发布", publish_homework_homework_common_path(activity, :user_activity_id => user_activity_id, :hw_status => hw_status),:remote => true, :class => "wpostOptionLink") %>
|
||||
</li>
|
||||
<% end %>
|
||||
<li>
|
||||
<%= link_to("评分设置", score_rule_set_homework_common_path(activity,:user_activity_id => user_activity_id, :hw_status => hw_status),:class => "wpostOptionLink", :remote => true) %>
|
||||
</li>
|
||||
|
@ -117,6 +122,20 @@
|
|||
:title => "匿评是同学之间的双盲互评过程:每个同学将评阅系统分配给他/她的若干个作品", :remote => true)%>
|
||||
</li>
|
||||
<% end %>
|
||||
<% if activity.user == User.current %>
|
||||
<% if activity.homework_bank_id.nil? %>
|
||||
<li>
|
||||
<%= link_to("加入题库", add_to_homework_bank_homework_common_path(activity,:user_activity_id => user_activity_id, :hw_status => hw_status, :type => 1),:class => "wpostOptionLink", :remote => true)%>
|
||||
</li>
|
||||
<% elsif activity.is_update %>
|
||||
<li>
|
||||
<%= link_to("同步到题库", add_to_homework_bank_homework_common_path(activity,:user_activity_id => user_activity_id, :hw_status => hw_status, :type => 2),:class => "wpostOptionLink", :remote => true)%>
|
||||
</li>
|
||||
<li>
|
||||
<%= link_to("另存到题库", add_to_homework_bank_homework_common_path(activity,:user_activity_id => user_activity_id, :hw_status => hw_status, :type => 3),:class => "wpostOptionLink", :remote => true)%>
|
||||
</li>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% if (activity.anonymous_comment == 1 && activity.is_open == 0) || (activity.anonymous_comment == 0 && comment_status == 3 && activity.is_open == 0) %>
|
||||
<li>
|
||||
<%= link_to("公开作品", alert_open_student_works_homework_common_path(activity,:user_activity_id => user_activity_id, :hw_status => hw_status),:class => "wpostOptionLink", :remote => true)%>
|
||||
|
|
|
@ -14,8 +14,8 @@
|
|||
对此许可证的支持或反对,请在网站中留言,我们不断完善,谢谢!</span>
|
||||
<% else %>
|
||||
<div class="subject-pop-intro mb15">标题:<%=homework.name %><br />
|
||||
来源:<%=homework.course.name %><br />
|
||||
<% if homework.homework_type == 2 && homework.homework_detail_programing %>
|
||||
适用课程:<%=homework.applicable_syllabus %><br />
|
||||
<% if homework.homework_type == 2 %>
|
||||
编程语言:<%=homework.language_name %><br/>
|
||||
<% end %>
|
||||
贡献者:<%=homework.user.show_name %>
|
||||
|
@ -30,11 +30,12 @@
|
|||
</div>
|
||||
<% if homework.homework_type == 2 %>
|
||||
<div class="subject-pop-content mt10">
|
||||
测试集:<%=homework.homework_tests.count %>组
|
||||
输入输出样例:<%=homework.homework_bank_tests.where(:test_type => 0).count %>组<br/>
|
||||
测试集:<%=homework.homework_bank_tests.where(:test_type => 1).count %>组
|
||||
</div>
|
||||
<% elsif homework.homework_type ==3 && homework.homework_detail_group %>
|
||||
<% elsif homework.homework_type == 3 %>
|
||||
<div class="subject-pop-content mt10">
|
||||
分组人数:<%=homework.homework_detail_group.min_num %> - <%=homework.homework_detail_group.max_num %>人
|
||||
分组人数:<%=homework.min_num %> - <%=homework.max_num %>人
|
||||
</div>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
<div class="homepagePostSubmit">
|
||||
<%= user_for_homework_common activity,is_teacher,work %>
|
||||
</div>
|
||||
<% if !is_teacher && !work.nil? && work.user == User.current && activity.end_time < Date.today %>
|
||||
<% if !is_teacher && !work.nil? && work.user == User.current && activity.end_time < Time.now %>
|
||||
<div class="homepagePostSubmit">
|
||||
<%=link_to "追加附件", student_work_index_url_in_org(activity.id, 2, 1), :class => 'c_blue', :title => "可追加作品修订附件" %>
|
||||
</div>
|
||||
|
|
|
@ -11,10 +11,37 @@
|
|||
<div class="hw_popup_txt">
|
||||
<p><%=@homework.description.html_safe %></p>
|
||||
<% if @homework.homework_type == 2 %>
|
||||
<div style="color: #888888;">
|
||||
<p class="subjectContent mt10">
|
||||
输入输出样例:<%=@homework.homework_bank_tests.where(:test_type => 0).count %>组
|
||||
</p>
|
||||
<% if @homework.homework_bank_tests.where(:test_type => 0).count > 0 %>
|
||||
<% @homework.homework_bank_tests.where(:test_type => 0 ).each_with_index do |sample, index| %>
|
||||
<span class="fl mt10">#<%= index + 1 %></span>
|
||||
<ul class="fl ml20 mt10 program_input_ul">
|
||||
<li>
|
||||
<span class="fl">样例输入:</span>
|
||||
<div class="fl ml10">
|
||||
<pre class="user_program_input_pre"><%=sample.input %></pre>
|
||||
</div>
|
||||
</li>
|
||||
<div class="cl"></div>
|
||||
<li class="mt5">
|
||||
<span class="fl">样例输出:</span>
|
||||
<div class="fl ml10">
|
||||
<pre class="user_program_input_pre"><%=sample.output %></pre>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
<div class="cl"></div>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</div>
|
||||
<div>
|
||||
<p class="subjectContent mt10">
|
||||
测试集:<%=@homework.homework_tests.count %>组
|
||||
测试集:<%=@homework.homework_bank_tests.where(:test_type => 1).count %>组
|
||||
</p>
|
||||
<% if @homework.user == User.current && @homework.homework_tests.count > 0 %>
|
||||
<% if @homework.user == User.current && @homework.homework_bank_tests.where(:test_type => 1).count > 0 %>
|
||||
<table class="hw_popup_testtable" cellpadding="0" cellspacing="0">
|
||||
<tbody>
|
||||
<tr>
|
||||
|
@ -22,7 +49,7 @@
|
|||
<td class="test_td_title">测试集输入</td>
|
||||
<td class="test_td_title">测试集输出</td>
|
||||
</tr>
|
||||
<% @homework.homework_tests.each_with_index do |test, i| %>
|
||||
<% @homework.homework_bank_tests.where(:test_type => 1).each_with_index do |test, i| %>
|
||||
<tr>
|
||||
<td class="test_td_min"><%=i+1 %></td>
|
||||
<td><pre style="word-wrap:break-word; white-space:pre-wrap;"><%=test.input %></pre></td>
|
||||
|
@ -32,9 +59,10 @@
|
|||
</tbody>
|
||||
</table>
|
||||
<% end %>
|
||||
<% elsif @homework.homework_type ==3 && @homework.homework_detail_group %>
|
||||
</div>
|
||||
<% elsif @homework.homework_type ==3 %>
|
||||
<p class="subjectContent mt10">
|
||||
分组人数:<%=@homework.homework_detail_group.min_num %> - <%=@homework.homework_detail_group.max_num %>人
|
||||
分组人数:<%=@homework.min_num %> - <%=@homework.max_num %>人
|
||||
</p>
|
||||
<% end %>
|
||||
</div>
|
||||
|
|
|
@ -7,18 +7,19 @@
|
|||
<span class="hw_icons_cir fl mt5 mr5"></span>
|
||||
<div class="fl ">
|
||||
<h3 class="sy_classlist_title fl">
|
||||
<% if type == "1" %>
|
||||
<%=link_to homework.name, student_work_index_path(:homework => homework), :class => 'linkGrey5', :target => "_blank" %>
|
||||
<% else %>
|
||||
<%# if type == "1" %>
|
||||
<%#=link_to homework.name, student_work_index_path(:homework => homework), :class => 'linkGrey5', :target => "_blank" %>
|
||||
<%# else %>
|
||||
<%=homework.name %>
|
||||
<% end %>
|
||||
<%# end %>
|
||||
</h3>
|
||||
<span class="<%=homework.course.is_public? ? 'hw_icon_open' : 'hw_icon_private'%> fl mt3"></span>
|
||||
<span class="<%=homework.is_public? ? 'hw_icon_open' : 'hw_icon_private'%> fl mt3"></span>
|
||||
<div class="cl"></div>
|
||||
<div class="sy_cgrey">
|
||||
<span class="fl">来源:</span>
|
||||
<span class="fl">适用课程:</span>
|
||||
<p class="fl hw_list_classname mr15">
|
||||
<%=link_to homework.course.name.to_s + "(#{current_time_and_term_short(homework.course)})", course_path(homework.course), :class => 'hw_cgrey', :target => '_blank' %>
|
||||
<%= homework.applicable_syllabus %>
|
||||
<%#=link_to homework.course.name.to_s + "(#{current_time_and_term_short(homework.course)})", course_path(homework.course), :class => 'hw_cgrey', :target => '_blank' %>
|
||||
</p>
|
||||
<% if type == "2" %>
|
||||
<span class="mr15 fl">
|
||||
|
@ -37,17 +38,22 @@
|
|||
<% end %>
|
||||
</span>
|
||||
<span class="fl mr15">引用数:<span id="subject_count_homework_<%=homework.id %>"><%= homework.quotes %></span></span>
|
||||
<% if homework.publish_time.nil? %>
|
||||
<span class="fl mr15">发布时间: - -</span>
|
||||
<% else %>
|
||||
<span class="fl mr15">发布时间:<%= format_date(homework.publish_time) %></span>
|
||||
<% end %>
|
||||
<%# if homework.publish_time.nil? %>
|
||||
<!--<span class="fl mr15">发布时间: - -</span>-->
|
||||
<%# else %>
|
||||
<span class="fl mr15">创建时间:<%= format_date(homework.created_at) %></span>
|
||||
<%# end %>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
</div>
|
||||
<% student_ids = homework.course.student.empty? ? [] : homework.course.student.map{|student| student.student_id}.join(',') %>
|
||||
<% if student_ids.include?(User.current.id.to_s) %>
|
||||
<% homework_common = HomeworkCommon.where(:id => homework.homework_common_id).first %>
|
||||
<% if homework_common %>
|
||||
<% student_ids = homework_common.course.student.empty? ? [] : homework_common.course.student.map{|student| student.student_id}.join(',') %>
|
||||
<% if student_ids.include?(User.current.id.to_s) %>
|
||||
<a href="javascript:void(0);" class="hw_btn_grey fr mt5" title="您选中的题是“我收到的作业”,不能发送">发送</a>
|
||||
<% else %>
|
||||
<a href="javascript:void(0);" class="hw_btn_green fr mt5" onclick="choose_course('<%=User.current.id%>', '<%=homework.id %>');" data-remote="true">发送</a>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<a href="javascript:void(0);" class="hw_btn_green fr mt5" onclick="choose_course('<%=User.current.id%>', '<%=homework.id %>');" data-remote="true">发送</a>
|
||||
<% end %>
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
<span class="sy_cgrey ">排序:</span>
|
||||
<%= link_to "发布时间",user_search_homeworks_user_path(@user,:name=>search,:type => type,:is_import=>is_import,:property=>property,:order => "publish_time", :sort => @r_sort),:class => "sy_cgrey fl",:remote => true%>
|
||||
<% if order == "publish_time" %>
|
||||
<%= link_to "", user_search_homeworks_user_path(@user,:name=>search,:type => type,:is_import=>is_import,:property=>property,:order => "publish_time", :sort => @r_sort), :class => "#{@r_sort == 'asc' ? 'sortupbtn' : 'sortdownbtn'} mt15 fl", :remote => true %>
|
||||
<%= link_to "创建时间",user_search_homeworks_user_path(@user,:name=>search,:type => type,:is_import=>is_import,:property=>property,:order => "created_at", :sort => @r_sort),:class => "sy_cgrey fl",:remote => true%>
|
||||
<% if order == "created_at" %>
|
||||
<%= link_to "", user_search_homeworks_user_path(@user,:name=>search,:type => type,:is_import=>is_import,:property=>property,:order => "created_at", :sort => @r_sort), :class => "#{@r_sort == 'desc' ? 'sortupbtn' : 'sortdownbtn'} mt15 fl", :remote => true %>
|
||||
<% else %>
|
||||
<%= link_to "", user_search_homeworks_user_path(@user,:name=>search,:type => type,:is_import=>is_import,:property=>property,:order => "publish_time", :sort => @r_sort), :class => "sortdownbtn sort_no mt15 fl", :remote => true %>
|
||||
<%= link_to "", user_search_homeworks_user_path(@user,:name=>search,:type => type,:is_import=>is_import,:property=>property,:order => "created_at", :sort => @r_sort), :class => "sortdownbtn sort_no mt15 fl", :remote => true %>
|
||||
<% end %>
|
||||
<%= link_to "引用数",user_search_homeworks_user_path(@user,:name=>search,:type => type,:is_import=>is_import,:property=>property,:order => "quotes", :sort => @r_sort),:class => "sy_cgrey fl",:remote => true%>
|
||||
<% if order == "quotes" %>
|
||||
<%= link_to "", user_search_homeworks_user_path(@user,:name=>search,:type => type,:is_import=>is_import,:property=>property,:order => "quotes", :sort => @r_sort), :class => "#{@r_sort == 'asc' ? 'sortupbtn' : 'sortdownbtn'} mt15 fl", :remote => true %>
|
||||
<%= link_to "", user_search_homeworks_user_path(@user,:name=>search,:type => type,:is_import=>is_import,:property=>property,:order => "quotes", :sort => @r_sort), :class => "#{@r_sort == 'desc' ? 'sortupbtn' : 'sortdownbtn'} mt15 fl", :remote => true %>
|
||||
<% else %>
|
||||
<%= link_to "", user_search_homeworks_user_path(@user,:name=>search,:type => type,:is_import=>is_import,:property=>property,:order => "quotes", :sort => @r_sort), :class => "sortdownbtn sort_no mt15 fl", :remote => true %>
|
||||
<% end %>
|
|
@ -1,7 +1,32 @@
|
|||
<div class="homepagePostIntro break_word upload_img maxh360 table_maxWidth " id="activity_description_<%= user_activity_id%>">
|
||||
<div class="homepagePostIntro break_word upload_img maxh360 table_maxWidth " id="activity_description_<%= user_activity_id%>">
|
||||
<div id="intro_content_<%= user_activity_id%>">
|
||||
<%= content.to_s.html_safe %>
|
||||
</div>
|
||||
|
||||
<% if defined?(samples) && !samples.empty? %>
|
||||
<div class="mt5 homeworkInfo">
|
||||
<p>输入输出样例:<%= samples.count %>组</p>
|
||||
<% samples.each_with_index do |sample, index| %>
|
||||
<span class="fl mt10">#<%= index + 1 %></span>
|
||||
<ul class="fl ml20 mt10 program_input_ul">
|
||||
<li>
|
||||
<span class="fl">样例输入:</span>
|
||||
<div class="fl ml10">
|
||||
<pre class="program_input_pre"><%=sample.input %></pre>
|
||||
</div>
|
||||
</li>
|
||||
<div class="cl"></div>
|
||||
<li class="mt5">
|
||||
<span class="fl">样例输出:</span>
|
||||
<div class="fl ml10">
|
||||
<pre class="program_input_pre"><%=sample.output %></pre>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
<div class="cl"></div>
|
||||
<% end %>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
$(function(){
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
<span title="<%= homework.name%>"><%= homework.name%></span>
|
||||
</label>
|
||||
</li>
|
||||
<li class="subject-pop-from fl hidden"><span title="<%=homework.course.name %>(<%=current_time_and_term(homework.course) %>)"><%=homework.course.name %>(<%=current_time_and_term_short(homework.course) %>)</span></li>
|
||||
<li class="subject-pop-from fl hidden"><span title="<%=homework.applicable_syllabus %>"><%=homework.applicable_syllabus %></span></li>
|
||||
<li class="subject-pop-type fl">
|
||||
<% case homework.homework_type %>
|
||||
<% when 1 %>
|
||||
|
@ -19,7 +19,7 @@
|
|||
</li>
|
||||
<li class="subject-pop-publisher fl hidden"><%= homework.user.show_name %></li>
|
||||
<li class="subject-pop-count fl"><%= homework.quotes %></li>
|
||||
<li class="subject-pop-date fl"><%=format_date homework.publish_time %></li>
|
||||
<li class="subject-pop-date fl"><%=format_date homework.created_at %></li>
|
||||
</ul>
|
||||
<% end %>
|
||||
<script type="text/javascript">
|
||||
|
|
|
@ -12,11 +12,11 @@
|
|||
<div>
|
||||
<ul class="subject-pop-banner mt10">
|
||||
<li class="subject-pop-name fl hidden"><span style="padding-left:15px;">作业名称</span></li>
|
||||
<li class="subject-pop-from fl">来源</li>
|
||||
<li class="subject-pop-from fl">适用课程</li>
|
||||
<li class="subject-pop-type fl">类别</li>
|
||||
<li class="subject-pop-publisher fl">贡献者</li>
|
||||
<li class="subject-pop-count fl">引用数</li>
|
||||
<li class="subject-pop-date fl">发布时间</li>
|
||||
<li class="subject-pop-date fl">创建时间</li>
|
||||
</ul>
|
||||
</div>
|
||||
<%= form_tag(user_select_homework_users_path, :multipart => true,:remote => true,:name=>"select_homework_form",:id=>'select_homework_form') do %>
|
||||
|
|
|
@ -33,8 +33,8 @@
|
|||
</td>
|
||||
<td>
|
||||
<li class="homepageTabTime ml5" >
|
||||
<% end_time = uh.end_time.to_time.to_i + 24*60*60 - 1 %>
|
||||
<% if end_time > Time.now.to_i %>
|
||||
<% end_time = uh.end_time.to_i %>
|
||||
<% if end_time > Time.now.to_i %>
|
||||
<span class="c_red"><%= (end_time - Time.now.to_i) / (24*60*60) %></span> 天
|
||||
<span class="c_red"><%= ((end_time - Time.now.to_i) % (24*60*60)) / (60*60)%></span> 小时
|
||||
<span class="c_red"><%= (((end_time - Time.now.to_i) % (24*60*60)) % (60*60)) / 60%></span> 分
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
<% if User.current.admin? || User.current.allowed_to?(:as_teacher,@course) %>
|
||||
<% homework_num = course.homework_commons.count %>
|
||||
<% else %>
|
||||
<% homework_num = course.homework_commons.where("publish_time <= '#{Date.today}'").count %>
|
||||
<% homework_num = course.homework_commons.where("publish_time <= '#{Time.now}'").count %>
|
||||
<% end %>
|
||||
<p class="list-info fr grayTxt"><span><%= homework_num %></span><span>作业</span><span>|</span><span> <%= visable_attachemnts_incourse(course).count %></span><span>资源</span></p>
|
||||
</li>
|
||||
|
|
|
@ -46,7 +46,7 @@
|
|||
<%= user_for_homework_common homework_common,is_teacher %>
|
||||
</div>
|
||||
<% work = cur_user_works_for_homework homework_common %>
|
||||
<% if !is_teacher && !work.nil? && homework_common.end_time < Date.today && work.user == User.current %>
|
||||
<% if !is_teacher && !work.nil? && homework_common.end_time < Time.now && work.user == User.current %>
|
||||
<div class="homepagePostSubmit">
|
||||
<%=link_to "追加附件", student_work_index_url_in_org(homework_common.id, 2, 1), :class => 'c_blue', :title => "可追加作品修订附件" %>
|
||||
</div>
|
||||
|
@ -73,13 +73,13 @@
|
|||
</div>
|
||||
<% end %>
|
||||
<% if homework_common.homework_detail_manual && homework_common.homework_detail_manual.comment_status < 2 && !homework_common.publish_time.nil? %>
|
||||
<div class="homepagePostDeadline">提交截止时间:<%= homework_common.end_time.to_s %> 23:59</div>
|
||||
<div class="homepagePostDeadline">提交截止时间:<%= format_time homework_common.end_time %></div>
|
||||
<% elsif homework_common.homework_detail_manual && homework_common.homework_detail_manual.comment_status >= 2 && !homework_common.publish_time.nil? && homework_common.anonymous_comment == 0 %>
|
||||
<div class="homepagePostDeadline">匿评截止时间:<%= homework_common.homework_detail_manual.evaluation_end.to_s %> 23:59</div>
|
||||
<% end %>
|
||||
<% if homework_common.homework_detail_manual.comment_status == 0 && !homework_common.publish_time.nil? %>
|
||||
<div class="homepagePostDeadline ml15">
|
||||
<%= l(:label_publish_time)%>:<%= homework_common.publish_time%> 00:00
|
||||
<%= l(:label_publish_time)%>:<%= format_time homework_common.publish_time%>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<% content_for :header_tags do %>
|
||||
<%= import_ke(enable_at: true, prettify: false, init_activity: false) %>
|
||||
|
||||
<%= javascript_include_tag 'homework','baiduTemplate' %>
|
||||
<%= javascript_include_tag 'homework', 'baiduTemplate', 'jquery.datetimepicker.js' %>
|
||||
<script type="text/javascript">
|
||||
function homework_name_focus(){
|
||||
$('#homework_editor').show();
|
||||
|
@ -11,6 +11,11 @@
|
|||
$('#select_type_nitice').show();
|
||||
}
|
||||
}
|
||||
function submit_form(){
|
||||
hideModal();
|
||||
homework_form[0].submit();
|
||||
return false;
|
||||
}
|
||||
var first_click = true;
|
||||
$(function(){
|
||||
$("#homework_type_option").on("change",function(){
|
||||
|
@ -52,10 +57,50 @@
|
|||
<% end %>
|
||||
<% if edit_mode %>
|
||||
$("#anonymous_comment").on('click',function(){
|
||||
$("#homework_end_time_span").html("更改后评分比例将恢复默认值");
|
||||
$("#anonymous_comment_notice").html("更改后评分比例将恢复默认值");
|
||||
});
|
||||
<% end %>
|
||||
|
||||
<% if !edit_mode || (edit_mode && homework.homework_detail_manual.comment_status.to_i < 2) %>
|
||||
$('#homework_end_time').datetimepicker({
|
||||
allowBlank:true,
|
||||
lang:'ch',
|
||||
format:'Y-m-d H:i',
|
||||
formatTime:'H:i',
|
||||
formatDate:'Y-m-d',
|
||||
validateOnBlur:false
|
||||
});
|
||||
<% end %>
|
||||
<% allow_edit = homework.student_works.has_committed.count == 0 && homework.student_work_projects.count ==0 %>
|
||||
|
||||
<% if allow_edit %>
|
||||
$('#homework_publish_time').datetimepicker({
|
||||
allowBlank:true,
|
||||
lang:'ch',
|
||||
format:'Y-m-d H:i',
|
||||
formatTime:'H:i',
|
||||
formatDate:'Y-m-d',
|
||||
validateOnBlur:false
|
||||
});
|
||||
<% end %>
|
||||
});
|
||||
function publish_time_show(){
|
||||
if($("#homework_end_time").val() != ""){
|
||||
$("#reset_time").show();
|
||||
$("#homework_publish_time_div").show();
|
||||
}
|
||||
}
|
||||
|
||||
function reset_end_time(){
|
||||
$("#homework_end_time").val('');
|
||||
$("#homework_publish_time").val('');
|
||||
$("#homework_publish_time_div").hide();
|
||||
}
|
||||
|
||||
function reset_publish_time(){
|
||||
$("#homework_publish_time").val('');
|
||||
}
|
||||
|
||||
function checked_val() {
|
||||
if ($("#anonymous_comment").length > 0){
|
||||
if ($("#anonymous_comment").is(":checked")) {
|
||||
|
@ -92,11 +137,8 @@
|
|||
else if(!regex_homework_name()){
|
||||
$("#homework_name").focus();
|
||||
}
|
||||
else if(!regex_homework_end_time()){
|
||||
$("#homework_end_time").focus();
|
||||
}
|
||||
else if(!regex_homework_end_publish_time()){
|
||||
$("#homework_end_time").focus();
|
||||
//$("#homework_end_time").focus();
|
||||
}
|
||||
else if(!regex_course_id()){
|
||||
$("#course_id").focus();
|
||||
|
@ -122,8 +164,15 @@
|
|||
return true;
|
||||
}else{
|
||||
first_click = false;
|
||||
$(this)[0].submit();
|
||||
return false;
|
||||
if($.trim($("#homework_end_time").val()) == ""){
|
||||
var htmlvalue = '<div id="muban_popup_box" style="width:300px;"><div class="muban_popup_top"><h3 class="fl">提示</h3><a href="javascript:void(0);" class="muban_icons_close fr"></a></div>'+
|
||||
'<div class="clear mt15"><p class="text_c f14 fontGrey7">您还没有设置作业截止时间,因此学生不可见<br/>您是否确定</p><div class="cl"></div><a href="javascript:void(0)" class="fr sy_btn_blue mt10" style="margin-right: 92px;" onclick="submit_form()">确定</a>'+
|
||||
'<a href="javascript:void(0);" class="fr sy_btn_grey mt10 mr10" onclick="hideModal();">取消</a></div></div>';
|
||||
pop_box_new(htmlvalue, 300, 140);
|
||||
} else{
|
||||
$(this)[0].submit();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
@ -132,7 +181,7 @@
|
|||
function init_homework_editor(params){
|
||||
params.textarea.removeAttr('placeholder');
|
||||
var editor = params.kindutil.create(params.textarea, {
|
||||
resizeType : 1,minWidth:"1px",width:"100%",minHeight:"30px",height:"30px",
|
||||
resizeType : 1,minWidth:"1px",width:"99.8%",minHeight:"30px",height:"30px",
|
||||
items : ['code','emoticons','fontname',
|
||||
'forecolor', 'hilitecolor', 'bold', '|', 'justifyleft', 'justifycenter', 'insertorderedlist','insertunorderedlist', '|',
|
||||
'formatblock', 'fontsize', '|','indent', 'outdent',
|
||||
|
@ -178,6 +227,7 @@
|
|||
if(params.textarea.data('init') == undefined) {
|
||||
params.editor = init_homework_editor(params);
|
||||
homework_description_editor = params.editor;
|
||||
homework_form = params.form;
|
||||
init_homework_form(params);
|
||||
params.submit_btn.click(function () {
|
||||
params.form.submit();
|
||||
|
@ -219,30 +269,29 @@
|
|||
|
||||
<div id="homework_editor" style="display: <%= edit_mode ? 'block':'none'%>">
|
||||
<div class="mt10">
|
||||
<label class="fl c_grey f14 mt5">截止日期:</label>
|
||||
<div class="calendar_div fl mr70">
|
||||
<input type="text" name="homework_common[end_time]" id="homework_end_time" class="InputBox fl W120 calendar_input" readonly="readonly" value="<%= homework.end_time%>" >
|
||||
<% if homework.homework_detail_manual.comment_status.to_i < 2 %>
|
||||
<%= calendar_for('homework_end_time')%>
|
||||
<% end %>
|
||||
</div>
|
||||
<label class="fl c_grey f14 mt5" style="margin-top: 4px;">发布日期(可选):</label>
|
||||
<label class="fl c_grey f14 mt5">截止时间(可选):</label>
|
||||
<div class="calendar_div fl">
|
||||
<% allow_edit = homework.student_works.has_committed.count == 0 && homework.student_work_projects.count ==0 %>
|
||||
<input title="<%=allow_edit ? '' : '已有学生提交作品或关联项目,发布日期不可再编辑' %>" type="text" name="homework_common[publish_time]" id="homework_publish_time" class="InputBox fl W120 calendar_input" readonly="readonly" value="<%= homework.publish_time%>" >
|
||||
<% if allow_edit %>
|
||||
<%= calendar_for('homework_publish_time')%>
|
||||
<input type="text" name="homework_common[end_time]" onblur="publish_time_show()" id="homework_end_time" class="InputBox fl W130 calendar_input" readonly="readonly" value="<%= homework.end_time ? homework.end_time.strftime('%Y-%m-%d %H:%M') : '' %>" >
|
||||
<%# if homework.homework_detail_manual.comment_status.to_i < 2 %>
|
||||
<%#= calendar_for('homework_end_time')%>
|
||||
<%# end %>
|
||||
</div>
|
||||
<% if !edit_mode || (edit_mode && homework.homework_detail_manual.comment_status.to_i < 1) %>
|
||||
<a href="javascript:void(0)" id="reset_time" class="fl sy_btn_grey ml10" onclick="reset_end_time();">清空</a>
|
||||
<% end %>
|
||||
<div class="fl <%= homework.publish_time.nil? ? 'none' : '' %> ml50" id="homework_publish_time_div">
|
||||
<label class="fl c_grey f14 mt5" style="margin-top: 4px;">发布时间(可选):</label>
|
||||
<div class="calendar_div fl">
|
||||
<% allow_edit = homework.student_works.has_committed.count == 0 && homework.student_work_projects.count ==0 %>
|
||||
<input title="<%=allow_edit ? '' : '已有学生提交作品或关联项目,发布日期不可再编辑' %>" type="text" name="homework_common[publish_time]" id="homework_publish_time" class="InputBox fl W130 calendar_input" readonly="readonly" value="<%= homework.publish_time ? homework.publish_time.strftime('%Y-%m-%d %H:%M') : '' %>">
|
||||
<%# if allow_edit %>
|
||||
<%#= calendar_for('homework_publish_time')%>
|
||||
<%# end %>
|
||||
</div>
|
||||
<% if !edit_mode || (edit_mode && homework.homework_detail_manual.comment_status.to_i < 1) %>
|
||||
<a href="javascript:void(0)" id="reset_time" class="fl sy_btn_grey ml10" onclick="reset_publish_time();">清空</a>
|
||||
<% end %>
|
||||
</div>
|
||||
<% if !edit_mode || edit_mode && homework.homework_detail_manual.comment_status < 2 %>
|
||||
<div class="fr f14 ml10" style="margin-top: 4px;">
|
||||
<input type="checkbox" value="<%=edit_mode ? homework.anonymous_comment : 1 %>" id="anonymous_comment"/>
|
||||
<span class="f14 c_grey">启用匿评</span>
|
||||
<!--<span id="anonymous_hint" style="display: none; font-size: 12px;" class="c_red">更改后评分比例将恢复默认值</span>-->
|
||||
</div>
|
||||
<% end %>
|
||||
<input type="hidden" name="homework_common[anonymous_comment]" value="<%=edit_mode ? homework.anonymous_comment : 1 %>" id="real_anonymous_comment"/>
|
||||
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
<p id="homework_end_time_span" class="c_red mt5"></p>
|
||||
|
@ -268,6 +317,25 @@
|
|||
<p id="e_tips" class="c_grey"></p>
|
||||
<div class="cl"></div>
|
||||
|
||||
<div class="homework_base_setting mt10">
|
||||
<ul>
|
||||
<li class="f14 ml10 mt5 mb5" style="">
|
||||
<input type="checkbox" <%= (!edit_mode || edit_mode && homework.homework_detail_manual.comment_status < 2) ? '' : 'disabled' %> value="<%=edit_mode ? homework.anonymous_comment : 1 %>" id="anonymous_comment"/>
|
||||
<label for="anonymous_comment" class="f14 c_grey">启用匿评(默认在截止日期后的第七日开启匿评,您可以通过匿评设置进行修改)
|
||||
<span id="anonymous_comment_notice" class="c_red f12"></span>
|
||||
</label>
|
||||
</li>
|
||||
<% if !edit_mode %>
|
||||
<li class="f14 ml10 mb5" style="">
|
||||
<input type="checkbox" value="1" name="add_to_bank" id="join_bank"/>
|
||||
<label for="join_bank" class="f14 c_grey">加入题库(同时将该作业保存到您的题库,可以随时复用)</label>
|
||||
</li>
|
||||
<% end %>
|
||||
</ul>
|
||||
<input type="hidden" name="homework_common[anonymous_comment]" value="<%=edit_mode ? homework.anonymous_comment : 1 %>" id="real_anonymous_comment"/>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="mt10 b_grey undis" style="padding:10px;" id="homeworkSetting">
|
||||
|
||||
</div>
|
||||
|
@ -284,7 +352,7 @@
|
|||
<%#= link_to "取消",user_homeworks_user_path(User.current.id),:class => "fr mr10 mt3"%>
|
||||
<a href="javascript:void(0);" id="new_message_cancel_btn" class="fr mr10 mt3">取消</a>
|
||||
<% else %>
|
||||
<a href="javascript:void(0);" id="new_message_submit_btn" class="BlueCirBtnMini fr">发送</a>
|
||||
<a href="javascript:void(0);" id="new_message_submit_btn" class="BlueCirBtnMini fr">保存</a>
|
||||
<span class="fr mr10 mt3">或</span>
|
||||
<a href="javascript:void(0);" id="new_message_cancel_btn" class="fr mr10 mt3">取消</a>
|
||||
<% end %>
|
||||
|
@ -299,8 +367,20 @@
|
|||
<label class="fl fontGrey2 mr10 mt5 w20" name="inputs_label"> </label>
|
||||
<textarea class="InputBox w265 fl mr10" placeholder="测试输入" name="program[input][]"></textarea>
|
||||
<textarea class="InputBox w265 fl mr5" placeholder="测试输出" name="program[output][]"></textarea>
|
||||
<a href="javascript:void(0);" class=" fl icon_add" title="增加测试组"></a>
|
||||
<a href="javascript:void(0);" class=" fl icon_remove" title="删除测试组"></a>
|
||||
<a href="javascript:void(0);" class=" fl icon_add test_icon_add" title="增加测试组"></a>
|
||||
<a href="javascript:void(0);" class=" fl icon_remove test_icon_remove" title="删除测试组"></a>
|
||||
<div class="cl"></div>
|
||||
</div>
|
||||
</script>
|
||||
|
||||
<script id="t:sample-answer-list" type="text/html">
|
||||
<div class="mt10" style="margin-left:57px;">
|
||||
<label class="fl fontGrey2 mr10 mt5 w20" name="sample_inputs_label"> </label>
|
||||
<textarea class="InputBox w547 fl mr5" placeholder="样例输入" name="sample[input][]"></textarea>
|
||||
<a href="javascript:void(0);" class="fl icon_add sample_icon_add" title="增加样例组"></a>
|
||||
<a href="javascript:void(0);" class="fl icon_remove sample_icon_remove" title="删除样例组"></a>
|
||||
<div class="cl"></div>
|
||||
<textarea class="InputBox w547 fl ml30 mt10" placeholder="样例输出" name="sample[output][]"></textarea>
|
||||
<div class="cl"></div>
|
||||
</div>
|
||||
</script>
|
||||
|
|
|
@ -1,76 +1,155 @@
|
|||
<div id="programHomework">
|
||||
<span class="f14 mt5 fl fontGrey3 mr10">测试集设置:</span>
|
||||
<select class="InputBox W120 language_type" name="language_type" <%=not_allow_select ? 'disabled' : '' %>>
|
||||
<%= options_for_select({"C语言"=>1, "C++"=>2, "Python"=>3, "Java"=>4}, (edit_mode && homework.is_program_homework?) ? homework.language : 1) %>
|
||||
</select>
|
||||
<span class="f12 c_red mt5 fr">温馨提示:您可以在发布作业后,在作业"模拟答题"中进行标准代码的检测。</span>
|
||||
<div class="cl"></div>
|
||||
<% if edit_mode && homework.is_program_homework? %>
|
||||
<% homework.homework_tests.each_with_index do |test, index| %>
|
||||
<div class="mt10" style="margin-left:57px;">
|
||||
<label class="fl fontGrey2 mr10 mt5 w20" name="inputs_label"><%=index+1 %> </label>
|
||||
<textarea class="InputBox w265 fl mr10" placeholder="测试输入" name="program[input][]" <%=not_allow_select ? 'disabled' : '' %>><%= test.input %></textarea>
|
||||
<textarea class="InputBox w265 fl mr5" placeholder="测试输出" name="program[output][]" <%=not_allow_select ? 'disabled' : '' %>><%= test.output %></textarea>
|
||||
<div class="mb20">
|
||||
<span class="f14 mt5 fl fontGrey3 mr10">输入输出示例:</span>
|
||||
<span class="f12 c_red mt5 fr">温馨提示:请至少输入一组样例供学生参考。</span>
|
||||
|
||||
<div class="cl"></div>
|
||||
<% if edit_mode && homework.is_program_homework? %>
|
||||
<% homework.homework_samples.each_with_index do |sample, index| %>
|
||||
<div class="mt10" style="margin-left:57px;">
|
||||
<label class="fl fontGrey2 mr10 mt5 w20" name="sample_inputs_label"><%= index+1 %> </label>
|
||||
<textarea class="InputBox w547 fl mr5" placeholder="样例输入" name="sample[input][]" <%= not_allow_select ? 'disabled' : '' %>><%= sample.input %></textarea>
|
||||
<% unless not_allow_select %>
|
||||
<a href="javascript:void(0);" class=" fl icon_add" title="增加测试组"></a>
|
||||
<% if index != 0 %>
|
||||
<a href="javascript:void(0);" class=" fl icon_remove" title="删除测试组"></a>
|
||||
<% end %>
|
||||
<a href="javascript:void(0);" class="fl icon_add sample_icon_add" title="增加样例组"></a>
|
||||
<% if index != 0 %>
|
||||
<a href="javascript:void(0);" class="fl icon_remove sample_icon_remove" title="删除样例组"></a>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<div class="cl"></div>
|
||||
</div>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<div class="mt10" style="margin-left:57px;">
|
||||
<label class="fl fontGrey2 mr10 mt5 w20" name="inputs_label">1 </label>
|
||||
<textarea class="InputBox w265 fl mr10" placeholder="测试输入" name="program[input][]" id="textarea_input_test"></textarea>
|
||||
<textarea class="InputBox w265 fl mr5" placeholder="测试输出" name="program[output][]" id="textarea_output_test"></textarea>
|
||||
<a href="javascript:void(0);" class=" fl icon_add" title="增加测试组"></a>
|
||||
<div class="cl"></div>
|
||||
</div>
|
||||
<% end %>
|
||||
<textarea class="InputBox w547 fl ml30 mt10" placeholder="样例输出" name="sample[output][]" <%= not_allow_select ? 'disabled' : '' %>><%= sample.output %></textarea>
|
||||
<div class="cl"></div>
|
||||
</div>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<div class="mt10" style="margin-left:57px;">
|
||||
<label class="fl fontGrey2 mr10 mt5 w20" name="sample_inputs_label">1 </label>
|
||||
<textarea class="InputBox w547 fl mr5" placeholder="样例输入" name="sample[input][]" id="textarea_sample_input_test"></textarea>
|
||||
<a href="javascript:void(0);" class="fl icon_add sample_icon_add" title="增加样例组"></a>
|
||||
<div class="cl"></div>
|
||||
<textarea class="InputBox w547 fl ml30 mt10" placeholder="样例输出" name="sample[output][]" id="textarea_sample_output_test"></textarea>
|
||||
<div class="cl"></div>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<span class="f14 mt5 fl fontGrey3 mr10">测试集设置:</span>
|
||||
<select class="InputBox W120 ml4 language_type" name="language_type" <%= not_allow_select ? 'disabled' : '' %>>
|
||||
<%= options_for_select({"C语言" => 1, "C++" => 2, "Python" => 3, "Java" => 4}, (edit_mode && homework.is_program_homework?) ? homework.language : 1) %>
|
||||
</select>
|
||||
<span class="f12 c_red mt5 fr">温馨提示:您可以在发布作业后,在作业"模拟答题"中进行标准代码的检测。</span>
|
||||
|
||||
<div class="cl"></div>
|
||||
<% if edit_mode && homework.is_program_homework? %>
|
||||
<% homework.homework_tests.each_with_index do |test, index| %>
|
||||
<div class="mt10" style="margin-left:57px;">
|
||||
<label class="fl fontGrey2 mr10 mt5 w20" name="inputs_label"><%= index+1 %> </label>
|
||||
<textarea class="InputBox w265 fl mr10" placeholder="测试输入" name="program[input][]" <%= not_allow_select ? 'disabled' : '' %>><%= test.input %></textarea>
|
||||
<textarea class="InputBox w265 fl mr5" placeholder="测试输出" name="program[output][]" <%= not_allow_select ? 'disabled' : '' %>><%= test.output %></textarea>
|
||||
<% unless not_allow_select %>
|
||||
<a href="javascript:void(0);" class=" fl icon_add test_icon_add" title="增加测试组"></a>
|
||||
<% if index != 0 %>
|
||||
<a href="javascript:void(0);" class=" fl icon_remove test_icon_remove" title="删除测试组"></a>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<div class="cl"></div>
|
||||
</div>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<div class="mt10" style="margin-left:57px;">
|
||||
<label class="fl fontGrey2 mr10 mt5 w20" name="inputs_label">1 </label>
|
||||
<textarea class="InputBox w265 fl mr10" placeholder="测试输入" name="program[input][]" id="textarea_input_test"></textarea>
|
||||
<textarea class="InputBox w265 fl mr5" placeholder="测试输出" name="program[output][]" id="textarea_output_test"></textarea>
|
||||
<a href="javascript:void(0);" class=" fl icon_add test_icon_add" title="增加测试组"></a>
|
||||
|
||||
<div class="cl"></div>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
$(function(){
|
||||
var bt=baidu.template;
|
||||
bt.LEFT_DELIMITER='<!';
|
||||
bt.RIGHT_DELIMITER='!>';
|
||||
$(function () {
|
||||
var bt = baidu.template;
|
||||
bt.LEFT_DELIMITER = '<!';
|
||||
bt.RIGHT_DELIMITER = '!>';
|
||||
|
||||
$("#programHomework").on('click', 'a.icon_add', function(){
|
||||
$("#programHomework").on('click', 'a.test_icon_add', function () {
|
||||
var html = bt('t:test-answer-list', null);
|
||||
$(this).parent('.mt10').after(html);
|
||||
var inputs = document.getElementsByName("program[input][]");
|
||||
var outputs = document.getElementsByName("program[output][]");
|
||||
var inputs_labels = document.getElementsByName("inputs_label");
|
||||
for(var j= 0; j<inputs_labels.length; j++){
|
||||
$(inputs_labels[j]).html(j + 1 + " " );
|
||||
for (var j = 0; j < inputs_labels.length; j++) {
|
||||
$(inputs_labels[j]).html(j + 1 + " ");
|
||||
}
|
||||
if (inputs.length == outputs.length) {
|
||||
for (var i=0; i<inputs.length; i++) {
|
||||
for (var i = 0; i < inputs.length; i++) {
|
||||
autoTextarea2(inputs[i], outputs[i], 0, 140);
|
||||
autoTextarea2(outputs[i], inputs[i], 0, 140);
|
||||
}
|
||||
}
|
||||
$(inputs[inputs.length - 1]).focus();
|
||||
});
|
||||
$("#programHomework").on('click', 'a.icon_remove', function(){
|
||||
$("#programHomework").on('click', 'a.test_icon_remove', function () {
|
||||
$(this).parent('.mt10').remove();
|
||||
var inputs_labels = document.getElementsByName("inputs_label");
|
||||
for (var j = 0; j < inputs_labels.length; j++) {
|
||||
$(inputs_labels[j]).html(j + 1 + " ");
|
||||
}
|
||||
});
|
||||
|
||||
$("#programHomework").on('click', 'a.sample_icon_add', function () {
|
||||
var html = bt('t:sample-answer-list', null);
|
||||
$(this).parent('.mt10').after(html);
|
||||
var inputs = document.getElementsByName("sample[input][]");
|
||||
var outputs = document.getElementsByName("sample[output][]");
|
||||
var inputs_labels = document.getElementsByName("sample_inputs_label");
|
||||
for (var j = 0; j < inputs_labels.length; j++) {
|
||||
$(inputs_labels[j]).html(j + 1 + " ");
|
||||
}
|
||||
if (inputs.length == outputs.length) {
|
||||
for (var i = 0; i < inputs.length; i++) {
|
||||
autoTextarea(inputs[i], 0, 140);
|
||||
autoTextarea(outputs[i], 0, 140);
|
||||
}
|
||||
}
|
||||
|
||||
$(inputs[inputs.length - 1]).focus();
|
||||
});
|
||||
$("#programHomework").on('click', 'a.sample_icon_remove', function () {
|
||||
$(this).parent('.mt10').remove();
|
||||
var inputs_labels = document.getElementsByName("sample_inputs_label");
|
||||
for (var j = 0; j < inputs_labels.length; j++) {
|
||||
$(inputs_labels[j]).html(j + 1 + " ");
|
||||
}
|
||||
});
|
||||
});
|
||||
<% if !edit_mode %>
|
||||
var text = document.getElementById("textarea_input_test");
|
||||
var text2 = document.getElementById("textarea_output_test");
|
||||
autoTextarea2(text,text2, 0, 140);
|
||||
autoTextarea2(text2,text, 0, 140);
|
||||
var text1 = document.getElementById("textarea_sample_input_test");
|
||||
var text2 = document.getElementById("textarea_sample_output_test");
|
||||
autoTextarea(text1, 0, 140);
|
||||
autoTextarea(text2, 0, 140);
|
||||
var text3 = document.getElementById("textarea_input_test");
|
||||
var text4 = document.getElementById("textarea_output_test");
|
||||
autoTextarea2(text3, text4, 0, 140);
|
||||
autoTextarea2(text4, text3, 0, 140);
|
||||
<% else %>
|
||||
var inputs = document.getElementsByName("program[input][]");
|
||||
var outputs = document.getElementsByName("program[output][]");
|
||||
if (inputs.length == outputs.length) {
|
||||
for (var i=0; i<inputs.length; i++) {
|
||||
autoTextarea2(inputs[i], outputs[i], 0, 140);
|
||||
autoTextarea2(outputs[i], inputs[i], 0, 140);
|
||||
}
|
||||
var sample_inputs = document.getElementsByName("sample[input][]");
|
||||
var sample_outputs = document.getElementsByName("sample[output][]");
|
||||
if (sample_inputs.length == sample_outputs.length) {
|
||||
for (var i = 0; i < sample_inputs.length; i++) {
|
||||
autoTextarea(sample_inputs[i], 0, 140);
|
||||
autoTextarea(sample_outputs[i], 0, 140);
|
||||
}
|
||||
}
|
||||
var inputs = document.getElementsByName("program[input][]");
|
||||
var outputs = document.getElementsByName("program[output][]");
|
||||
if (inputs.length == outputs.length) {
|
||||
for (var i = 0; i < inputs.length; i++) {
|
||||
autoTextarea2(inputs[i], outputs[i], 0, 140);
|
||||
autoTextarea2(outputs[i], inputs[i], 0, 140);
|
||||
}
|
||||
}
|
||||
<% end %>
|
||||
</script>
|
|
@ -79,7 +79,7 @@
|
|||
<%= @homework.name %>
|
||||
</div>
|
||||
<span class="fr c_grey">
|
||||
截止时间:<%= @homework.end_time %>
|
||||
截止时间:<%= format_time @homework.end_time %>
|
||||
</span>
|
||||
<div class="cl"></div>
|
||||
<a href="javascript:void(0);" class="c_blue"><%= @homework.user.show_name %></a>
|
||||
|
|
|
@ -53,7 +53,7 @@
|
|||
</div>
|
||||
<div class="HomeWorkBox">
|
||||
<div class="">
|
||||
<div class="homepagePostTitle fl"><%= @homework.name %></div><span class="fr c_grey">截止时间:<%= @homework.end_time %></span>
|
||||
<div class="homepagePostTitle fl"><%= @homework.name %></div><span class="fr c_grey">截止时间:<%= format_time @homework.end_time %></span>
|
||||
<div class="cl"></div>
|
||||
<a href="javascript:void(0);" class="c_blue"><%= @homework.user.show_name %></a>
|
||||
<p class="HomeWorkP"><%= @homework.description %> <br />
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
//$("#HomeWorkCon").replaceWith("<%#= escape_javascript(render :partial => 'users/user_homework_form', :locals => { :homework => @homework,:edit_mode => true })%>");
|
||||
hideModal('#coursesChoosePopup');
|
||||
$("#homework_name").val("<%= @homework.name%>");
|
||||
$("#homework_end_time").val("<%= @homework.end_time%>");
|
||||
//$("#homework_end_time").val("<%#= @homework.end_time%>");
|
||||
<% if @select_course == "0"%>
|
||||
$("#course_id").val("<%= @homework.course_id%>");
|
||||
<% end%>
|
||||
|
|
|
@ -65,7 +65,7 @@
|
|||
else if(!regex_homework_end_time()){
|
||||
$("#homework_end_time").focus();
|
||||
}
|
||||
else if(!regex_homework_end_publish_time()){
|
||||
else if(!regex_work_end_publish_time()){
|
||||
$("#homework_end_time").focus();
|
||||
}
|
||||
else if(!regex_course_id()){
|
||||
|
@ -188,7 +188,9 @@
|
|||
<label class="fl c_grey f14 mt5">截止日期:</label>
|
||||
<div class="calendar_div fl mr70">
|
||||
<input type="text" name="homework_common[end_time]" id="homework_end_time" class="InputBox fl W120 calendar_input" readonly="readonly" value="<%= homework.end_time%>" >
|
||||
<%= calendar_for('homework_end_time')%>
|
||||
<% if !edit_mode || (edit_mode && homework.work_status <= 2) %>
|
||||
<%= calendar_for('homework_end_time')%>
|
||||
<% end %>
|
||||
</div>
|
||||
<label class="fl c_grey f14 mt5" style="margin-top: 4px;">发布日期(可选):</label>
|
||||
<div class="calendar_div fl">
|
||||
|
|
|
@ -33,12 +33,12 @@
|
|||
<% stu_pro_count = @homework.contestant_work_projects.count %>
|
||||
<% if committed_work_count != 0 %>
|
||||
<% if @homework.work_type == 1 %>
|
||||
<p class="c_red mb5">已有<%=committed_work_count %>个学生提交作品,不允许再修改作业类型。</p>
|
||||
<p class="c_red mb5">已有<%=committed_work_count %>个学生提交作品,不允许再修改竞赛类型。</p>
|
||||
<% elsif @homework.work_type == 3 %>
|
||||
<p class="c_red mb5">已有<%=committed_work_count %>个学生提交作品,不允许再修改作业类型和分组设置(可扩大分组范围)。</p>
|
||||
<p class="c_red mb5">已有<%=committed_work_count %>个学生提交作品,不允许再修改竞赛类型和分组设置(可扩大分组范围)。</p>
|
||||
<% end %>
|
||||
<% elsif stu_pro_count != 0 && @homework.work_type == 3 %>
|
||||
<p class="c_red mb5">已有<%=stu_pro_count %>个学生关联项目,不允许再修改作业类型。</p>
|
||||
<p class="c_red mb5">已有<%=stu_pro_count %>个学生关联项目,不允许再修改竞赛类型。</p>
|
||||
<% end %>
|
||||
|
||||
<%= form_for @homework do |f| %>
|
||||
|
|
|
@ -316,6 +316,8 @@ RedmineApp::Application.routes.draw do
|
|||
post 'set_evaluation_attr'
|
||||
get 'alert_score_open_modal'
|
||||
post 'set_score_open'
|
||||
get 'add_to_homework_bank'
|
||||
get 'publish_homework'
|
||||
end
|
||||
|
||||
collection do
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
class CreateHomeworkSamples < ActiveRecord::Migration
|
||||
def change
|
||||
create_table :homework_samples do |t|
|
||||
t.text :input
|
||||
t.text :output
|
||||
t.references :homework_common
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
add_index :homework_samples, :homework_common_id
|
||||
end
|
||||
end
|
|
@ -0,0 +1,21 @@
|
|||
class CreateHomeworkBanks < ActiveRecord::Migration
|
||||
def change
|
||||
create_table :homework_banks do |t|
|
||||
t.references :user
|
||||
t.string :name
|
||||
t.text :description
|
||||
t.integer :homework_type
|
||||
t.integer :quotes, :default => 0
|
||||
t.boolean :is_public
|
||||
t.string :language
|
||||
t.text :standard_code, :limit => 4294967295
|
||||
t.integer :min_num
|
||||
t.integer :max_num
|
||||
t.boolean :base_on_project
|
||||
t.string :applicable_syllabus
|
||||
t.integer :homework_common_id
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,12 @@
|
|||
class CreateHomeworkBankTests < ActiveRecord::Migration
|
||||
def change
|
||||
create_table :homework_bank_tests do |t|
|
||||
t.text :input
|
||||
t.text :output
|
||||
t.boolean :test_type
|
||||
t.references :homework_bank
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,45 @@
|
|||
class HomeworkBankMigration < ActiveRecord::Migration
|
||||
def up
|
||||
add_column :homework_commons, :homework_bank_id, :integer
|
||||
add_column :homework_commons, :is_update, :boolean, :default => false
|
||||
|
||||
count =Course.all.count / 30 + 2
|
||||
transaction do
|
||||
for i in 1 ... count do i
|
||||
Course.page(i).per(30).each do |course|
|
||||
if course.is_delete == 0
|
||||
course.homework_commons.each do |homework|
|
||||
unless homework.user.homework_banks.select("name").to_s.include?(homework.name)
|
||||
homework_bank = HomeworkBank.create(:user_id => homework.user_id, :name => homework.name, :description => homework.description, :homework_type => homework.homework_type,
|
||||
:quotes => homework.quotes, :is_public => course.is_public, :applicable_syllabus => course.syllabus.title, :homework_common_id => homework.id, :created_at => homework.created_at)
|
||||
if homework.homework_type == 2 && homework.homework_detail_programing
|
||||
homework_bank.update_attributes(:language => homework.homework_detail_programing.language, :standard_code => homework.homework_detail_programing.standard_code)
|
||||
homework.homework_tests.each do |test|
|
||||
homework_bank.homework_bank_tests << HomeworkBankTest.create(
|
||||
input: test.input,
|
||||
output: test.output,
|
||||
test_type: true
|
||||
)
|
||||
end
|
||||
homework.homework_samples.each do |test|
|
||||
homework_bank.homework_bank_tests << HomeworkBankTest.create(
|
||||
input: test.input,
|
||||
output: test.output,
|
||||
test_type: false
|
||||
)
|
||||
end
|
||||
elsif homework.homework_type == 3 && homework.homework_detail_group
|
||||
homework_bank.update_attributes(:min_num => homework.homework_detail_group.min_num, :max_num => homework.homework_detail_group.max_num, :base_on_project => homework.homework_detail_group.base_on_project)
|
||||
end
|
||||
homework.update_column('homework_bank_id', homework_bank.id)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
end
|
||||
end
|
|
@ -0,0 +1,15 @@
|
|||
class AlterHomeworkPublishEnd < ActiveRecord::Migration
|
||||
def up
|
||||
change_column :homework_commons, :publish_time, :datetime
|
||||
change_column :homework_commons, :end_time, :datetime
|
||||
|
||||
HomeworkCommon.all.each do |homework|
|
||||
homework.update_column('end_time', homework.end_time + 1.day - 1) unless homework.end_time.nil?
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
change_column :homework_commons, :publish_time, :date
|
||||
change_column :homework_commons, :end_time, :date
|
||||
end
|
||||
end
|
|
@ -5,7 +5,7 @@ namespace :homework_publishtime do
|
|||
task :publish => :environment do
|
||||
puts "--------------------------------homework_publish start"
|
||||
Rails.logger.info("log--------------------------------homework_publish start")
|
||||
homework_commons = HomeworkCommon.where("publish_time = '#{Date.today}'")
|
||||
homework_commons = HomeworkCommon.includes(:homework_detail_manual).where("publish_time < '#{Time.now}' and homework_detail_manuals.comment_status = 0")
|
||||
homework_commons.each do |homework|
|
||||
homework_detail_manual = homework.homework_detail_manual
|
||||
if homework_detail_manual.comment_status == 0
|
||||
|
@ -20,7 +20,7 @@ namespace :homework_publishtime do
|
|||
if str != ""
|
||||
str += ","
|
||||
end
|
||||
str += "('#{name_str}',#{homework.id},#{student.student_id}, '#{Time.now}', '#{Time.now}')"
|
||||
str += "('#{name_str}',#{homework.id},#{student.student_id}, '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}', '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}')"
|
||||
end
|
||||
sql = "insert into student_works (name, homework_common_id,user_id, created_at, updated_at) values" + str
|
||||
ActiveRecord::Base.connection.execute sql
|
||||
|
|
|
@ -792,21 +792,25 @@ function regex_homework_name()
|
|||
//验证发布时间不能大于截止时间
|
||||
function regex_homework_end_publish_time()
|
||||
{
|
||||
var myDate = new Date();
|
||||
if($.trim($("#homework_publish_time").val()) == "")
|
||||
{
|
||||
$("#homework_publish_time").val(formate_date(myDate));
|
||||
}
|
||||
var publish_time = Date.parse($("#homework_publish_time").val());
|
||||
var end_time = Date.parse($("#homework_end_time").val());
|
||||
if(end_time < publish_time)
|
||||
{
|
||||
$("#homework_end_time_span").text("截止日期不能小于发布日期");
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
$("#homework_end_time_span").text("");
|
||||
if($.trim($("#homework_end_time").val()) != ""){
|
||||
var myDate = new Date();
|
||||
if($.trim($("#homework_publish_time").val()) == "")
|
||||
{
|
||||
$("#homework_publish_time").val(formate_date(myDate));
|
||||
}
|
||||
var publish_time = Date.parse($("#homework_publish_time").val());
|
||||
var end_time = Date.parse($("#homework_end_time").val());
|
||||
if(end_time < publish_time)
|
||||
{
|
||||
$("#homework_end_time_span").text("截止时间应晚于发布时间");
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
$("#homework_end_time_span").text("");
|
||||
return true;
|
||||
}
|
||||
} else{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -827,6 +831,27 @@ function regex_homework_end_time()
|
|||
}
|
||||
}
|
||||
|
||||
function regex_work_end_publish_time()
|
||||
{
|
||||
var myDate = new Date();
|
||||
if($.trim($("#homework_publish_time").val()) == "")
|
||||
{
|
||||
$("#homework_publish_time").val(formate_time(myDate));
|
||||
}
|
||||
var publish_time = Date.parse($("#homework_publish_time").val());
|
||||
var end_time = Date.parse($("#homework_end_time").val());
|
||||
if(end_time < publish_time)
|
||||
{
|
||||
$("#homework_end_time_span").text("截止日期不能小于发布日期");
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
$("#homework_end_time_span").text("");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
function formate_date(date){
|
||||
var str = "";
|
||||
var year = date.getFullYear();
|
||||
|
@ -855,6 +880,12 @@ function formate_time(time){
|
|||
if(day < 10) {
|
||||
day = '0' + day;
|
||||
}
|
||||
if(hour < 10) {
|
||||
hour = '0' + hour;
|
||||
}
|
||||
if(min < 10) {
|
||||
min = '0' + min;
|
||||
}
|
||||
str = year + '-' + month + '-' + day + ' ' + hour + ':' + min;
|
||||
return str;
|
||||
}
|
||||
|
@ -917,7 +948,13 @@ function regex_group_attr(){
|
|||
//验证编程作业的参数
|
||||
function regex_program_attr() {
|
||||
var result = true;
|
||||
$.each($('#programHomework textarea.InputBox'), function(i, val){
|
||||
$.each($("#programHomework textarea[name='sample[input][]']"), function(i, val){
|
||||
if (result && $(val).val().length<=0) {
|
||||
$(val)[0].focus();
|
||||
result = false;
|
||||
}
|
||||
});
|
||||
$.each($("#programHomework textarea[name='program[input][]']"), function(i, val){
|
||||
if (result && $(val).val().length<=0) {
|
||||
$(val)[0].focus();
|
||||
result = false;
|
||||
|
@ -1442,6 +1479,77 @@ function show_student_work(url){
|
|||
);
|
||||
}
|
||||
|
||||
//textarea自适应高度 纯js写的 有浏览器判断
|
||||
/**
|
||||
* 文本框根据输入内容自适应高度
|
||||
* @param {HTMLElement} 输入框元素
|
||||
* @param {Number} 设置光标与输入框保持的距离(默认0)
|
||||
* @param {Number} 设置最大高度(可选)
|
||||
*/
|
||||
var autoTextarea = function (elem, extra, maxHeight) {
|
||||
extra = extra || 0;
|
||||
var isFirefox = !!document.getBoxObjectFor || 'mozInnerScreenX' in window,
|
||||
isOpera = !!window.opera && !!window.opera.toString().indexOf('Opera'),
|
||||
addEvent = function (type, callback) {
|
||||
elem.addEventListener ?
|
||||
elem.addEventListener(type, callback, false) :
|
||||
elem.attachEvent('on' + type, callback);
|
||||
},
|
||||
getStyle = elem.currentStyle ? function (name) {
|
||||
var val = elem.currentStyle[name];
|
||||
|
||||
if (name === 'height' && val.search(/px/i) !== 1) {
|
||||
var rect = elem.getBoundingClientRect();
|
||||
return rect.bottom - rect.top -
|
||||
parseFloat(getStyle('paddingTop')) -
|
||||
parseFloat(getStyle('paddingBottom')) + 'px';
|
||||
};
|
||||
|
||||
return val;
|
||||
} : function (name) {
|
||||
return getComputedStyle(elem, null)[name];
|
||||
},
|
||||
minHeight = parseFloat(getStyle('height'));
|
||||
|
||||
|
||||
elem.style.resize = 'none';
|
||||
|
||||
var change = function () {
|
||||
var scrollTop, height,
|
||||
padding = 0,
|
||||
style = elem.style;
|
||||
|
||||
if (elem._length === elem.value.length) return;
|
||||
elem._length = elem.value.length;
|
||||
|
||||
if (!isFirefox && !isOpera) {
|
||||
padding = parseInt(getStyle('paddingTop')) + parseInt(getStyle('paddingBottom'));
|
||||
};
|
||||
scrollTop = document.body.scrollTop || document.documentElement.scrollTop;
|
||||
|
||||
elem.style.height = minHeight + 'px';
|
||||
if (elem.scrollHeight > minHeight) {
|
||||
if (maxHeight && elem.scrollHeight > maxHeight) {
|
||||
height = maxHeight - padding;
|
||||
style.overflowY = 'auto';
|
||||
} else {
|
||||
height = elem.scrollHeight - padding;
|
||||
style.overflowY = 'hidden';
|
||||
};
|
||||
style.height = height + extra + 'px';
|
||||
scrollTop += parseInt(style.height) - elem.currHeight;
|
||||
document.body.scrollTop = scrollTop;
|
||||
document.documentElement.scrollTop = scrollTop;
|
||||
elem.currHeight = parseInt(style.height);
|
||||
};
|
||||
};
|
||||
|
||||
addEvent('propertychange', change);
|
||||
addEvent('input', change);
|
||||
addEvent('focus', change);
|
||||
change();
|
||||
};
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
var autoTextarea2 = function (elem,elem2, extra, maxHeight) {
|
||||
|
|
|
@ -129,22 +129,24 @@ function regex_homework_name()
|
|||
//验证发布时间不能大于截止时间
|
||||
function regex_homework_end_publish_time()
|
||||
{
|
||||
var myDate = new Date();
|
||||
if($.trim($("#homework_publish_time").val()) == "")
|
||||
{
|
||||
$("#homework_publish_time").val(formate_date(myDate));
|
||||
}
|
||||
var end_time = Date.parse($("#homework_end_time").val());
|
||||
var publish_time = Date.parse($("#homework_publish_time").val());
|
||||
if(end_time < publish_time)
|
||||
{
|
||||
$("#homework_end_time_span").text("截止日期不能小于发布日期");
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
$("#homework_end_time_span").text("");
|
||||
return true;
|
||||
if($.trim($("#homework_end_time").val()) != ""){
|
||||
var myDate = new Date();
|
||||
if($.trim($("#homework_publish_time").val()) == "")
|
||||
{
|
||||
$("#homework_publish_time").val(formate_time(myDate));
|
||||
}
|
||||
var publish_time = Date.parse($("#homework_publish_time").val());
|
||||
var end_time = Date.parse($("#homework_end_time").val());
|
||||
if(end_time < publish_time)
|
||||
{
|
||||
$("#homework_end_time_span").text("截止时间应晚于发布时间");
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
$("#homework_end_time_span").text("");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -192,6 +194,12 @@ function formate_time(time){
|
|||
if(day < 10) {
|
||||
day = '0' + day;
|
||||
}
|
||||
if(hour < 10) {
|
||||
hour = '0' + hour;
|
||||
}
|
||||
if(min < 10) {
|
||||
min = '0' + min;
|
||||
}
|
||||
str = year + '-' + month + '-' + day + ' ' + hour + ':' + min;
|
||||
return str;
|
||||
}
|
||||
|
@ -254,7 +262,13 @@ function regex_group_attr(){
|
|||
//验证编程作业的参数
|
||||
function regex_program_attr() {
|
||||
var result = true;
|
||||
$.each($('#programHomework textarea.InputBox'), function(i, val){
|
||||
$.each($("#programHomework textarea[name='sample[input][]']"), function(i, val){
|
||||
if (result && $(val).val().length<=0) {
|
||||
$(val)[0].focus();
|
||||
result = false;
|
||||
}
|
||||
});
|
||||
$.each($("#programHomework textarea[name='program[input][]']"), function(i, val){
|
||||
if (result && $(val).val().length<=0) {
|
||||
$(val)[0].focus();
|
||||
result = false;
|
||||
|
@ -465,77 +479,6 @@ function show_group_member(){
|
|||
//$('#min_num').focus();
|
||||
}
|
||||
|
||||
//textarea自适应高度 纯js写的 有浏览器判断
|
||||
/**
|
||||
* 文本框根据输入内容自适应高度
|
||||
* @param {HTMLElement} 输入框元素
|
||||
* @param {Number} 设置光标与输入框保持的距离(默认0)
|
||||
* @param {Number} 设置最大高度(可选)
|
||||
*/
|
||||
var autoTextarea = function (elem, extra, maxHeight) {
|
||||
extra = extra || 0;
|
||||
var isFirefox = !!document.getBoxObjectFor || 'mozInnerScreenX' in window,
|
||||
isOpera = !!window.opera && !!window.opera.toString().indexOf('Opera'),
|
||||
addEvent = function (type, callback) {
|
||||
elem.addEventListener ?
|
||||
elem.addEventListener(type, callback, false) :
|
||||
elem.attachEvent('on' + type, callback);
|
||||
},
|
||||
getStyle = elem.currentStyle ? function (name) {
|
||||
var val = elem.currentStyle[name];
|
||||
|
||||
if (name === 'height' && val.search(/px/i) !== 1) {
|
||||
var rect = elem.getBoundingClientRect();
|
||||
return rect.bottom - rect.top -
|
||||
parseFloat(getStyle('paddingTop')) -
|
||||
parseFloat(getStyle('paddingBottom')) + 'px';
|
||||
};
|
||||
|
||||
return val;
|
||||
} : function (name) {
|
||||
return getComputedStyle(elem, null)[name];
|
||||
},
|
||||
minHeight = parseFloat(getStyle('height'));
|
||||
|
||||
|
||||
elem.style.resize = 'none';
|
||||
|
||||
var change = function () {
|
||||
var scrollTop, height,
|
||||
padding = 0,
|
||||
style = elem.style;
|
||||
|
||||
if (elem._length === elem.value.length) return;
|
||||
elem._length = elem.value.length;
|
||||
|
||||
if (!isFirefox && !isOpera) {
|
||||
padding = parseInt(getStyle('paddingTop')) + parseInt(getStyle('paddingBottom'));
|
||||
};
|
||||
scrollTop = document.body.scrollTop || document.documentElement.scrollTop;
|
||||
|
||||
elem.style.height = minHeight + 'px';
|
||||
if (elem.scrollHeight > minHeight) {
|
||||
if (maxHeight && elem.scrollHeight > maxHeight) {
|
||||
height = maxHeight - padding;
|
||||
style.overflowY = 'auto';
|
||||
} else {
|
||||
height = elem.scrollHeight - padding;
|
||||
style.overflowY = 'hidden';
|
||||
};
|
||||
style.height = height + extra + 'px';
|
||||
scrollTop += parseInt(style.height) - elem.currHeight;
|
||||
document.body.scrollTop = scrollTop;
|
||||
document.documentElement.scrollTop = scrollTop;
|
||||
elem.currHeight = parseInt(style.height);
|
||||
};
|
||||
};
|
||||
|
||||
addEvent('propertychange', change);
|
||||
addEvent('input', change);
|
||||
addEvent('focus', change);
|
||||
change();
|
||||
};
|
||||
|
||||
function limitStrsize(id,length){
|
||||
$('#'+id).keypress(function(e)
|
||||
{
|
||||
|
@ -625,92 +568,6 @@ function hideResource(){
|
|||
hideModal();
|
||||
}
|
||||
/////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
var autoTextarea2 = function (elem,elem2, extra, maxHeight) {
|
||||
extra = extra || 0;
|
||||
var isFirefox = !!document.getBoxObjectFor || 'mozInnerScreenX' in window,
|
||||
isOpera = !!window.opera && !!window.opera.toString().indexOf('Opera'),
|
||||
addEvent = function (element, type, callback) {
|
||||
element.addEventListener ?
|
||||
element.addEventListener(type, callback, false) :
|
||||
element.attachEvent('on' + type, callback);
|
||||
},
|
||||
getFirstStyle = elem.currentStyle ? function (name) {
|
||||
var val = elem.currentStyle[name];
|
||||
|
||||
if (name === 'height' && val.search(/px/i) !== 1) {
|
||||
var rect = elem.getBoundingClientRect();
|
||||
return rect.bottom - rect.top -
|
||||
parseFloat(getFirstStyle('paddingTop')) -
|
||||
parseFloat(getFirstStyle('paddingBottom')) + 'px';
|
||||
};
|
||||
|
||||
return val;
|
||||
} : function (name) {
|
||||
return getComputedStyle(elem, null)[name];
|
||||
},
|
||||
minHeight = parseFloat(getFirstStyle('height'));
|
||||
|
||||
elem.style.resize = 'none';
|
||||
elem2.style.resize = 'none';
|
||||
var change = function () {
|
||||
var scrollTop, height,
|
||||
padding = 0,
|
||||
style = elem.style,
|
||||
style2 = elem2.style;
|
||||
|
||||
|
||||
if (elem._length === elem.value.length) return;
|
||||
elem._length = elem.value.length;
|
||||
elem2._length = elem._length;
|
||||
if (!isFirefox && !isOpera) {
|
||||
padding = parseInt(getFirstStyle('paddingTop')) + parseInt(getFirstStyle('paddingBottom'));
|
||||
};
|
||||
scrollTop = document.body.scrollTop || document.documentElement.scrollTop;
|
||||
|
||||
elem.style.height = minHeight + 'px';
|
||||
elem2.style.height = minHeight + 'px';
|
||||
if (elem.scrollHeight > minHeight) {
|
||||
if (maxHeight && elem.scrollHeight > maxHeight) {
|
||||
height = maxHeight - padding;
|
||||
style.overflowY = 'auto';
|
||||
style2.overflowY = 'auto';
|
||||
} else {
|
||||
height = elem.scrollHeight - padding;
|
||||
};
|
||||
style.height = height + extra + 'px';
|
||||
style2.height = height + extra + 'px';
|
||||
scrollTop += parseInt(style.height) - elem.currHeight;
|
||||
document.body.scrollTop = scrollTop;
|
||||
document.documentElement.scrollTop = scrollTop;
|
||||
elem.currHeight = parseInt(style.height);
|
||||
};
|
||||
if (elem2.scrollHeight > minHeight) {
|
||||
if (maxHeight && elem2.scrollHeight > maxHeight) {
|
||||
height = maxHeight - padding;
|
||||
style.overflowY = 'auto';
|
||||
style2.overflowY = 'auto';
|
||||
} else {
|
||||
height = elem2.scrollHeight - padding;
|
||||
};
|
||||
style.height = height + extra + 'px';
|
||||
style2.height = height + extra + 'px';
|
||||
scrollTop += parseInt(style2.height) - elem2.currHeight;
|
||||
document.body.scrollTop = scrollTop;
|
||||
document.documentElement.scrollTop = scrollTop;
|
||||
elem2.currHeight = parseInt(style2.height);
|
||||
};
|
||||
};
|
||||
|
||||
addEvent(elem, 'propertychange', change);
|
||||
addEvent(elem, 'input', change);
|
||||
addEvent(elem, 'focus', change);
|
||||
addEvent(elem2, 'propertychange', change);
|
||||
addEvent(elem2, 'input', change);
|
||||
addEvent(elem2, 'focus', change);
|
||||
change();
|
||||
};
|
||||
|
||||
function user_name_keypress(e){
|
||||
if (e.keyCode == '13') {
|
||||
$('#main_login_form').submit();
|
||||
|
|
|
@ -114,7 +114,7 @@ h4{ font-size:14px;}/*color:#3b3b3b;*/
|
|||
.w230{width:230px !important;}.w235{ width:235px !important;}.w265{ width: 265px;}.w270{ width: 270px;}.w280{ width:280px;}.w289{ width:289px !important;}.w290{ width:290px !important;}
|
||||
.w300{ width:300px !important;}.w305{ width:305px;}.w350 {width:350px;}.w360 {width:360px;}.w362 {width:362px;}.h400{height:400px !important;}.w430{ width:430px;}
|
||||
.W440{ width:440px;}.w450 {width:450px;}.w455{width:455px !important;}.w459{ width:459px;}.w460{ width:460px;}.w465{width:465px !important;}
|
||||
.w490{width:490px;}.w536{ width:536px;}.w543{ width:543px;}.w557{ width:557px;}.w570 {width:570px !important;}.w576{ width:576px;}.w590{ width:590px !important;}
|
||||
.w490{width:490px;}.w536{ width:536px;}.w543{ width:543px;}.w547{ width:547px;}.w557{ width:557px;}.w570 {width:570px !important;}.w576{ width:576px;}.w590{ width:590px !important;}
|
||||
.w607 {width:607px;}.w664{ width:664px;}.w683{ width:683px;}.w610{ width:610px;}.w600{ width:600px !important;}.w603{ width:603px !important;}
|
||||
.w606{ width:606px; }.w620{ width:620px;}.w680{ width: 680px;}.w701{width: 701px;}.w705{ width:705px;}.w708{width: 708px;}.w709{width: 709px;}
|
||||
.w712{width:712px; max-width:712px; min-width:712px;}.w713{width: 713px;}.w720{width:721px;}.w730{width:730px;}.w770{ width:770px;}.h15{ height: 15px; }
|
||||
|
@ -123,7 +123,7 @@ h4{ font-size:14px;}/*color:#3b3b3b;*/
|
|||
.mw150 {max-width: 150px !important;}.mw220 {max-width: 220px !important;}.mw280 {max-width:280px !important;}.mw360 {max-width: 360px !important;}
|
||||
.mw380 {max-width: 380px !important;}.mw400 {max-width: 400px !important;}.mh18 {max-height: 18px;}.max_h54 {max-height:54px; }.maxHeight100 {max-height:100px; overflow-x:hidden; overflow-y:auto;}
|
||||
.maxHeight200 {max-height:200px; overflow-x:hidden; overflow-y:auto;}
|
||||
.W50{ width:50px;}.W120{ width:110px;}.W200{ width:200px;}.W300 {width:300px !important;}.W320{ width:320px;}.W420 {width:420px;}.W440{ width:440px;}
|
||||
.W50{ width:50px;}.W120{ width:110px;}.W130{ width:130px;}.W200{ width:200px;}.W300 {width:300px !important;}.W320{ width:320px;}.W420 {width:420px;}.W440{ width:440px;}
|
||||
.W600{ width:600px !important;}.W700{ width:700px; max-width:700px; min-width:700px;}.W710{ width:708px;}.W800{ width:800px !important;}
|
||||
.maxwidth150{max-width: 150px;}.m_w460{max-width: 460px;}.m_w500{max-width: 500px;}.m_w505{max-width: 505px;}.m_w530{max-width: 530px;}
|
||||
.m_w600{max-width: 600px;}.td_w70{ width:70px;}.td_w60{ width:60px;}.td_w110{ width:110px;}.width165{width: 165px;}.width180{width: 180px !important;}
|
||||
|
|
|
@ -535,4 +535,8 @@ a.banner-course-notice {position: absolute; font-size: 12px; line-height: 20px;
|
|||
.syllabus_class_open { color: #7dd26c; border: 1px solid #7dd26c;}
|
||||
.st_tips_box_inner{ position: absolute;line-height: 2.0;padding: 5px 10px; white-space: nowrap; background-color: #fff; left:100px; top: -5px; box-shadow: 0px 2px 8px rgba(146, 153, 169, 0.5);}
|
||||
.st_tips_box_inner span { display: block; border-width: 10px;position: absolute;top: 15px; left: -18px; border-style: dashed solid dashed dashed;border-color: transparent #fff transparent transparent;font-size: 0;line-height: 0;}
|
||||
.course_class_users_st_name{ display: inline-block;width:120px; overflow:hidden;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}
|
||||
.course_class_users_st_name{ display: inline-block;width:120px; overflow:hidden;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}
|
||||
|
||||
.program_input_pre{font-family: '微软雅黑','宋体'; max-width:450px; word-wrap:break-word; white-space:pre-wrap;}
|
||||
.homeworkInfo .program_input_ul li{list-style-type: none; margin-left: 0;}
|
||||
.homework_base_setting{border: 1px solid #d9d9d9; background: #F5F5F5; color: #d9d9d9;}
|
|
@ -250,10 +250,13 @@ a:hover.sy_class_ltitle{ color:#333;}
|
|||
.sy_new_table_width tr th.sy_th13{ width: 13%;}
|
||||
.sy_fenban_tap{ cursor: pointer; position: relative;}
|
||||
.sy_fenban_tap:hover .sy_fenban_show{ display: block;}
|
||||
.sy_fenban_show{ width:140px; z-index: 999;text-align: center; line-height:2.0; font-size:12px; font-weight: normal;color:#888;background-color:#fff; border:1px solid #eaeaea;border-radius:5px;position:absolute;left:20px; top:30px;padding:5px 0px;display:none; box-shadow: 0px 2px 8px rgba(146, 153, 169, 0.5);}
|
||||
.sy_fenban_show{ position: absolute;line-height: 2.0;padding: 5px 10px; white-space: nowrap; font-weight: normal;color:#888; background-color: #fff; left:30px; top: -5px; box-shadow: 0px 2px 8px rgba(146, 153, 169, 0.5);}
|
||||
.sy_fenban_show span { display: block; border-width: 10px;position: absolute;top: 15px; left: -18px; border-style: dashed solid dashed dashed;border-color: transparent #fff transparent transparent;font-size: 0;line-height: 0;}
|
||||
.sy_fenban_show em { display: block; border-width: 11px;position: absolute;top: 42px; left: -23px; border-style: dashed solid dashed dashed;border-color: transparent #eaeaea transparent transparent;font-size: 0;line-height: 0;}
|
||||
.sy_tips_box{ position: relative; cursor: pointer;}
|
||||
.sy_tips_box:hover .sy_tips_box_inner{ display: block;}
|
||||
.sy_tips_box_inner{ position: absolute;line-height: 2.0;padding: 5px 10px; white-space: nowrap; background-color: #fff; left:30px; top: -5px; box-shadow: 0px 2px 8px rgba(146, 153, 169, 0.5);}
|
||||
.sy_tips_box_inner span { display: block; border-width: 10px;position: absolute;top: 15px; left: -18px; border-style: dashed solid dashed dashed;border-color: transparent #fff transparent transparent;font-size: 0;line-height: 0;}
|
||||
.sy_tips_box_inner em { display: block; border-width: 11px;position: absolute;top: 42px; left: -23px; border-style: dashed solid dashed dashed;border-color: transparent #eaeaea transparent transparent;font-size: 0;line-height: 0;}
|
||||
|
||||
.user_program_input_pre{max-width:650px; word-wrap:break-word; white-space:pre-wrap;font-family: Helvetica, Tahoma, Arial, "Microsoft YaHei", "微软雅黑", SimSun, "宋体", STXihei, "华文细黑", Heiti, "黑体", sans-serif;}
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
FactoryGirl.define do
|
||||
factory :homework_bank_test do
|
||||
|
||||
end
|
||||
|
||||
end
|
|
@ -0,0 +1,6 @@
|
|||
FactoryGirl.define do
|
||||
factory :homework_bank do
|
||||
|
||||
end
|
||||
|
||||
end
|
|
@ -0,0 +1,8 @@
|
|||
FactoryGirl.define do
|
||||
factory :homework_sample do
|
||||
input "MyText"
|
||||
output "MyText"
|
||||
homework_common nil
|
||||
end
|
||||
|
||||
end
|
|
@ -0,0 +1,5 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe HomeworkBank, :type => :model do
|
||||
pending "add some examples to (or delete) #{__FILE__}"
|
||||
end
|
|
@ -0,0 +1,5 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe HomeworkBankTest, :type => :model do
|
||||
pending "add some examples to (or delete) #{__FILE__}"
|
||||
end
|
|
@ -0,0 +1,5 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe HomeworkSample, :type => :model do
|
||||
pending "add some examples to (or delete) #{__FILE__}"
|
||||
end
|
Loading…
Reference in New Issue