From 68a29d813157db74396dbd934d92f2449361306b Mon Sep 17 00:00:00 2001
From: cxt
Date: Tue, 1 Dec 2015 15:18:14 +0800
Subject: [PATCH] =?UTF-8?q?=E5=AD=A6=E7=94=9F=E6=8F=90=E4=BA=A4=E4=BD=9C?=
=?UTF-8?q?=E5=93=81=E5=90=8E=E5=8F=AF=E7=82=B9=E5=87=BB=E9=87=8D=E8=AF=95?=
=?UTF-8?q?=E9=87=8D=E6=96=B0=E4=B8=8A=E4=BC=A0=E4=BD=9C=E5=93=81?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/controllers/student_work_controller.rb | 23 ++++++++++++++++---
.../student_work/_work_information.html.erb | 3 ++-
app/views/student_work/create.js.erb | 2 +-
app/views/student_work/new.html.erb | 4 ++--
app/views/student_work/retry_work.js.erb | 2 ++
config/routes.rb | 2 ++
6 files changed, 29 insertions(+), 7 deletions(-)
create mode 100644 app/views/student_work/retry_work.js.erb
diff --git a/app/controllers/student_work_controller.rb b/app/controllers/student_work_controller.rb
index d2aba1386..dd2a5b5fc 100644
--- a/app/controllers/student_work_controller.rb
+++ b/app/controllers/student_work_controller.rb
@@ -3,8 +3,8 @@ class StudentWorkController < ApplicationController
include StudentWorkHelper
require 'bigdecimal'
require "base64"
- before_filter :find_homework, :only => [:new, :index, :create, :student_work_absence_penalty, :absence_penalty_list, :evaluation_list, :program_test,:set_score_rule,:forbidden_anonymous_comment]
- before_filter :find_work, :only => [:edit, :update, :show, :destroy, :add_score, :praise_student_work]
+ before_filter :find_homework, :only => [:new, :index, :create, :student_work_absence_penalty, :absence_penalty_list, :evaluation_list, :program_test,:set_score_rule,:forbidden_anonymous_comment,:delete_work]
+ before_filter :find_work, :only => [:edit, :update, :show, :destroy, :add_score, :praise_student_work,:retry_work]
before_filter :member_of_course, :only => [:index, :new, :create, :show, :add_score, :praise_student_work]
before_filter :author_of_work, :only => [:edit, :update, :destroy]
before_filter :teacher_of_course, :only => [:student_work_absence_penalty, :absence_penalty_list, :evaluation_list, :set_score_rule, :forbidden_anonymous_comment]
@@ -222,7 +222,7 @@ class StudentWorkController < ApplicationController
def edit
@user = User.current
- if !User.current.admin? && @homework.homework_type == 2 #编程作业不能修改作业
+ 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") #编程作业不能修改作业|| 截止日期已到不能修改作业
render_403
else
respond_to do |format|
@@ -284,6 +284,23 @@ class StudentWorkController < ApplicationController
end
end
+ def delete_work
+ @work = StudentWork.where("user_id =? and homework_common_id =?", User.current.id, @homework.id).first
+ if @work
+ @work.destroy
+ end
+ redirect_to user_homeworks_user_path(User.current.id)
+ end
+
+ def retry_work
+ if @work.destroy
+ @student_work = StudentWork.new
+ respond_to do |format|
+ format.js
+ end
+ end
+ end
+
#添加评分,已评分则为修改评分
def add_score
@is_last = params[:is_last] == "true"
diff --git a/app/views/student_work/_work_information.html.erb b/app/views/student_work/_work_information.html.erb
index f8a55a03d..90d749af1 100644
--- a/app/views/student_work/_work_information.html.erb
+++ b/app/views/student_work/_work_information.html.erb
@@ -19,9 +19,10 @@
-
+
确 定
+ <%= link_to("重试", retry_work_student_work_path(@student_work.id),:class => "tijiao",:style =>"margin-bottom: 15px;margin-top:15px;",:remote => true)%>
diff --git a/app/views/student_work/create.js.erb b/app/views/student_work/create.js.erb
index afd8617aa..67a1ccb50 100644
--- a/app/views/student_work/create.js.erb
+++ b/app/views/student_work/create.js.erb
@@ -11,7 +11,7 @@
showModal('ajax-modal', '500px');
$('#ajax-modal').siblings().remove();
$('#ajax-modal').before("" +
- "");
+ "");
$('#ajax-modal').parent().css("top","").css("left","");
$('#ajax-modal').parent().addClass("anonymos");
<% else %>
diff --git a/app/views/student_work/new.html.erb b/app/views/student_work/new.html.erb
index 4f9999277..45c26654e 100644
--- a/app/views/student_work/new.html.erb
+++ b/app/views/student_work/new.html.erb
@@ -111,9 +111,9 @@
-
确定
+
提交
或
- <%= link_to "取消", user_homeworks_user_path(User.current.id), :class => "fr mr10 mt3"%>
+ <%= link_to "取消", delete_work_student_work_index_path(:homework =>@homework.id), :class => "fr mr10 mt3"%>
<% end%>
diff --git a/app/views/student_work/retry_work.js.erb b/app/views/student_work/retry_work.js.erb
new file mode 100644
index 000000000..c5fca76d4
--- /dev/null
+++ b/app/views/student_work/retry_work.js.erb
@@ -0,0 +1,2 @@
+hideModal('#popbox02');
+$("#homework_attachments").html("<%= escape_javascript(render :partial => 'users/user_homework_attachment', :locals => {:container => @student_work, :has_program=>false})%>");
\ No newline at end of file
diff --git a/config/routes.rb b/config/routes.rb
index bfe62bc3f..f6fe95a33 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -206,11 +206,13 @@ RedmineApp::Application.routes.draw do
resources :student_work do
member do
post 'add_score'
+ get 'retry_work'
get 'praise_student_work'
get 'forbidden_anonymous_comment'
end
collection do
post 'add_score_reply'
+ get 'delete_work'
get 'destroy_score_reply'
get 'student_work_absence_penalty'
get 'absence_penalty_list'