diff --git a/app/controllers/exercise_controller.rb b/app/controllers/exercise_controller.rb index 6d6d429b6..0c794fe33 100644 --- a/app/controllers/exercise_controller.rb +++ b/app/controllers/exercise_controller.rb @@ -6,6 +6,14 @@ class ExerciseController < ApplicationController include ExerciseHelper def index + publish_exercises = Exercise.where("publish_time is not null and exercise_status = 1 and publish_time <=?",Time.now) + publish_exercises.each do |exercise| + exercise.update_column('exercise_status', 2) + end + end_exercises = Exercise.where("end_time <=? and exercise_status = 2",Time.now) + end_exercises.each do |exercise| + exercise.update_column('exercise_status', 3) + end if @course.is_public == 0 && !User.current.member_of_course?(@course) render_403 return @@ -24,6 +32,14 @@ class ExerciseController < ApplicationController end def show + publish_exercises = Exercise.where("publish_time is not null and exercise_status = 1 and publish_time <=?",Time.now) + publish_exercises.each do |exercise| + exercise.update_column('exercise_status', 2) + end + end_exercises = Exercise.where("end_time <=? and exercise_status = 2",Time.now) + end_exercises.each do |exercise| + exercise.update_column('exercise_status', 3) + end unless User.current.member_of_course?(@course) render_403 return diff --git a/app/views/exercise/_edit_head.html.erb b/app/views/exercise/_edit_head.html.erb index 64f34b5aa..a071904ce 100644 --- a/app/views/exercise/_edit_head.html.erb +++ b/app/views/exercise/_edit_head.html.erb @@ -35,6 +35,5 @@ $("#exercise_time").val("<%=exercise.time if exercise.time!= -1 %>"); $("#exercise_publish_time").val("<%= Time.parse(format_time(exercise.publish_time)).strftime("%Y-%m-%d") if !exercise.publish_time.nil?%>"); /*$("#exercise_description").text("<%#=exercise.exercise_description.html_safe %>");*/ - document.getElementById("exercise_description").innerHTML = <%=exercise.exercise_description.html_safe %>; } \ No newline at end of file diff --git a/app/views/student_work/_revise_attachments.html.erb b/app/views/student_work/_revise_attachments.html.erb new file mode 100644 index 000000000..1321da368 --- /dev/null +++ b/app/views/student_work/_revise_attachments.html.erb @@ -0,0 +1,30 @@ +
+
+ + 上传附件 + <%#= button_tag "上传附件", :type=>"button", :onclick=>"$('#_file#{work.id}').click();",:onmouseover => 'this.focus()',:class => 'blueCir ml5' %> + <%= file_field_tag 'attachments[dummy][file]', + :id => "_file#{work.id}", + :class => 'file_selector', + :multiple => true, + :onchange => "addReviseFiles(this, '#{work.id}');", + :style => 'display:none', + :data => { + :max_file_size => Setting.attachment_max_size.to_i.kilobytes, + :max_file_size_message => l(:error_attachment_too_big, :max_size => number_to_human_size(Setting.attachment_max_size.to_i.kilobytes)), + :max_concurrent_uploads => Redmine::Configuration['max_concurrent_ajax_uploads'].to_i, + :upload_path => uploads_path(:format => 'js'), + :description_placeholder => l(:label_optional_description), + :field_is_public => l(:field_is_public), + :are_you_sure => l(:text_are_you_sure), + :file_count => l(:label_file_count), + :lebel_file_uploding => l(:lebel_file_uploding), + :delete_all_files => l(:text_are_you_sure_all), + :containerid => "#{work.id}" + } %> + + <% content_for :header_tags do %> + <%= javascript_include_tag 'attachments' %> + <% end %> +
+ diff --git a/app/views/student_work/_show.html.erb b/app/views/student_work/_show.html.erb index 1b0202536..894f9fb39 100644 --- a/app/views/student_work/_show.html.erb +++ b/app/views/student_work/_show.html.erb @@ -61,6 +61,31 @@ + + <%#= text_field_tag("attachments[p#{i}][filename]", attachment.filename, :class => 'filename link_file', :readonly=>'readonly')%> + <%#= text_field_tag("attachments[p#{i}][description]", attachment.description, :maxlength => 254, :placeholder => l(:label_optional_description), :class => 'description', :style=>"display: inline-block;") %> + + <%#= check_box_tag("attachments[p#{i}][is_public_checkbox]", attachment.is_public,attachment.is_public == 1 ? true : false,:class => 'is_public')%> + <%#= link_to(' '.html_safe, attachment_path(attachment, :attachment_id => "p#{i}", :format => 'js'), :method => 'delete', :remote => true, :class => 'remove-upload') unless attachment.id.nil? %> + <%#= hidden_field_tag "attachments[p#{i}][token]", "#{attachment.token}" %> + +
<%student_work_scores.each do |student_score|%>
diff --git a/db/migrate/20151203030635_add_attachment_type.rb b/db/migrate/20151203030635_add_attachment_type.rb new file mode 100644 index 000000000..2c41aa5f2 --- /dev/null +++ b/db/migrate/20151203030635_add_attachment_type.rb @@ -0,0 +1,9 @@ +# encoding: utf-8 +class AddAttachmentType < ActiveRecord::Migration + def up + Attachmentstype.create(typeId:3,typeName:'修订附件') + end + + def down + end +end diff --git a/lib/tasks/exercise_publish.rake b/lib/tasks/exercise_publish.rake new file mode 100644 index 000000000..aacd67c1f --- /dev/null +++ b/lib/tasks/exercise_publish.rake @@ -0,0 +1,18 @@ +#coding=utf-8 + +namespace :exercise_publish do + desc "publish exercise and end exercise" + task :publish => :environment do + exercises = Exercise.where("publish_time is not null and exercise_status = 1 and publish_time <=?",Time.now) + exercises.each do |exercise| + exercise.update_column('exercise_status', 2) + end + end + + task :end => :environment do + exercises = Exercise.where("end_time <=? and exercise_status = 2",Time.now) + exercises.each do |exercise| + exercise.update_column('exercise_status', 3) + end + end +end diff --git a/public/stylesheets/courses.css b/public/stylesheets/courses.css index 57838bdba..584a49a4f 100644 --- a/public/stylesheets/courses.css +++ b/public/stylesheets/courses.css @@ -1192,3 +1192,8 @@ a:hover.memberBtn{background: url(/images/course/hwork_icon.png) -80px -90px no- .addMemberCP {width:514px; height:auto; border:3px solid #269ac9; padding-left:16px; padding-bottom:16px; background-color:#ffffff; position:absolute; z-index:1000;} .rightArrow {margin:50px 15px 0px 15px; float:left;} .relateText {font-size:16px; color:#269ac9; line-height:16px; padding-top:20px; display:inline-block; font-weight: bold;} + +.resubAtt {border-top:1px solid #dddddd; position:relative; margin-top:15px;} +.resubTitle {position:absolute; top:-10px; left:5px; background-color:#ffffff; display:block; font-weight:bold; padding:0px 2px;} +a.blueCir{ display:inline-block; padding:2px 5px; background-color:#ffffff;border:1px solid #3598db; color:#3598db; -moz-border-radius:5px; -webkit-border-radius:5px; border-radius:5px;} +a:hover.blueCir{ background:#3598db; color:#fff;}