From 68a29d813157db74396dbd934d92f2449361306b Mon Sep 17 00:00:00 2001
From: cxt
Date: Tue, 1 Dec 2015 15:18:14 +0800
Subject: [PATCH 1/2] =?UTF-8?q?=E5=AD=A6=E7=94=9F=E6=8F=90=E4=BA=A4?=
=?UTF-8?q?=E4=BD=9C=E5=93=81=E5=90=8E=E5=8F=AF=E7=82=B9=E5=87=BB=E9=87=8D?=
=?UTF-8?q?=E8=AF=95=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'
From 77e96af78f042e01f5f8ee4c77ed40bdf72f73c8 Mon Sep 17 00:00:00 2001
From: cxt
Date: Thu, 3 Dec 2015 10:41:27 +0800
Subject: [PATCH 2/2] =?UTF-8?q?=E8=BF=98=E5=8E=9F=E5=88=86=E7=BB=84?=
=?UTF-8?q?=E4=BD=9C=E4=B8=9A?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/controllers/words_controller.rb | 2 +
app/models/attachment.rb | 2 +-
app/models/course.rb | 2 +-
app/models/project.rb | 2 +-
app/models/user.rb | 4 +-
app/views/student_work/new.html.erb | 2 +-
app/views/users/_user_homework_form.html.erb | 2 +-
app/views/users/_user_message_course.html.erb | 8 +--
config/application.rb | 2 +-
db/schema.rb | 56 ++++++++++--------
public/images/course/hwork_icon.png | Bin 0 -> 4494 bytes
public/images/course/right-arrow.png | Bin 0 -> 1325 bytes
public/javascripts/homework.js | 4 +-
public/stylesheets/courses.css | 18 +++++-
public/stylesheets/new_user.css | 16 +++++
15 files changed, 79 insertions(+), 41 deletions(-)
create mode 100644 public/images/course/hwork_icon.png
create mode 100644 public/images/course/right-arrow.png
diff --git a/app/controllers/words_controller.rb b/app/controllers/words_controller.rb
index 6cc622c49..c9c4dcce3 100644
--- a/app/controllers/words_controller.rb
+++ b/app/controllers/words_controller.rb
@@ -3,6 +3,8 @@
class WordsController < ApplicationController
include ApplicationHelper
before_filter :find_user, :only => [:new, :create, :destroy, :more, :back]
+ before_filter :require_login, :only => [:create_reply]
+
def create
if params[:new_form][:user_message].size>0 && User.current.logged?
unless params[:user_id].nil?
diff --git a/app/models/attachment.rb b/app/models/attachment.rb
index aa436965b..999cefdaa 100644
--- a/app/models/attachment.rb
+++ b/app/models/attachment.rb
@@ -43,7 +43,7 @@ class Attachment < ActiveRecord::Base
#elasticsearch kaminari init
Kaminari::Hooks.init
Elasticsearch::Model::Response::Response.__send__ :include, Elasticsearch::Model::Response::Pagination::Kaminari
- settings index: { number_of_shards: 1 } do
+ settings index: { number_of_shards: 5 } do
mappings dynamic: 'false' do
indexes :filename, analyzer: 'smartcn',index_options: 'offsets'
indexes :downloads, analyzer: 'smartcn',index_options: 'offsets'
diff --git a/app/models/course.rb b/app/models/course.rb
index edc5e105b..30a6bb439 100644
--- a/app/models/course.rb
+++ b/app/models/course.rb
@@ -12,7 +12,7 @@ class Course < ActiveRecord::Base
#elasticsearch kaminari init
Kaminari::Hooks.init
Elasticsearch::Model::Response::Response.__send__ :include, Elasticsearch::Model::Response::Pagination::Kaminari
- settings index: { number_of_shards: 1 } do
+ settings index: { number_of_shards: 5 } do
mappings dynamic: 'false' do
indexes :name, analyzer: 'smartcn',index_options: 'offsets'
indexes :description, analyzer: 'smartcn',index_options: 'offsets'
diff --git a/app/models/project.rb b/app/models/project.rb
index c68e73369..ff546e098 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -35,7 +35,7 @@ class Project < ActiveRecord::Base
#elasticsearch kaminari init
Kaminari::Hooks.init
Elasticsearch::Model::Response::Response.__send__ :include, Elasticsearch::Model::Response::Pagination::Kaminari
- settings index: { number_of_shards: 1 } do
+ settings index: { number_of_shards: 5 } do
mappings dynamic: 'false' do
indexes :name, analyzer: 'smartcn',index_options: 'offsets'
indexes :description, analyzer: 'smartcn',index_options: 'offsets'
diff --git a/app/models/user.rb b/app/models/user.rb
index cdec39a3d..9c437a186 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -30,7 +30,7 @@ class User < Principal
#elasticsearch kaminari init
Kaminari::Hooks.init
Elasticsearch::Model::Response::Response.__send__ :include, Elasticsearch::Model::Response::Pagination::Kaminari
- settings index: { number_of_shards: 1 } do
+ settings index: { number_of_shards: 5 } do
mappings dynamic: 'false' do
indexes :login, analyzer: 'smartcn',index_options: 'offsets'
indexes :firstname, analyzer: 'smartcn',index_options: 'offsets'
@@ -477,7 +477,7 @@ class User < Principal
end
if user
# user is already in local database
- #return nil unless user.active?
+ return nil if user.locked?
return nil unless user.check_password?(password)
else
# user is not yet registered, try to authenticate with available sources
diff --git a/app/views/student_work/new.html.erb b/app/views/student_work/new.html.erb
index 45c26654e..ee0dd7e9b 100644
--- a/app/views/student_work/new.html.erb
+++ b/app/views/student_work/new.html.erb
@@ -99,7 +99,7 @@
diff --git a/app/views/users/_user_homework_form.html.erb b/app/views/users/_user_homework_form.html.erb
index efaed2d9d..cfc098645 100644
--- a/app/views/users/_user_homework_form.html.erb
+++ b/app/views/users/_user_homework_form.html.erb
@@ -97,7 +97,7 @@
-
+
diff --git a/app/views/users/_user_message_course.html.erb b/app/views/users/_user_message_course.html.erb
index c2b1b509f..6e8fda92e 100644
--- a/app/views/users/_user_message_course.html.erb
+++ b/app/views/users/_user_message_course.html.erb
@@ -126,7 +126,7 @@
<% end %>
- 截止时间快到了!
+ 截止时间快到啦
<%= time_tag(ma.created_at).html_safe %>
<% end %>
@@ -158,7 +158,7 @@
匿评截止:<%= ma.course_message.homework_detail_manual.evaluation_end %> 23:59
<% unless User.current.allowed_to?(:as_teacher, ma.course_message.course)%>
- 请您尽早完成匿评!如果您在截止日期前未完成匿评,您的最终成绩将被扣除<%= ma.course_message.homework_detail_manual.absence_penalty %>分乘以缺评份数。
+ 请您尽早完成匿评,如果您在截止日期前未完成匿评,您的最终成绩将被扣除<%= ma.course_message.homework_detail_manual.absence_penalty %>分乘以缺评份数。
例如,您缺评了两份作品,则您的最终成绩将被扣除 <%= ma.course_message.homework_detail_manual.absence_penalty %> * 2 = <%= ma.course_message.homework_detail_manual.absence_penalty * 2 %>分
<% end%>
@@ -209,7 +209,7 @@
<%= User.current.lastname + User.current.firstname %><%= User.current.allowed_to?(:as_teacher, ma.course_message.course) ? '老师':'同学'%>您好!
- <%= User.current.eql?(ma.course_message.user) ?"您":(ma.course_message.user.lastname + ma.course_message.user.firstname + "老师") %>启动作业匿评失败!
+ <%= User.current.eql?(ma.course_message.user) ?"您":(ma.course_message.user.lastname + ma.course_message.user.firstname + "老师") %>启动作业匿评失败啦
如需获得最终成绩,请您联系主讲老师对您的作品进行单独评分!
- 您迟交了作品!
+ 您成功提交了作品(但被标记为迟交啦)
<%= time_tag(ma.created_at).html_safe %>
<% end %>
diff --git a/config/application.rb b/config/application.rb
index 61f73ee3d..9e6d41abe 100644
--- a/config/application.rb
+++ b/config/application.rb
@@ -80,7 +80,7 @@ module RedmineApp
elsif RbConfig::CONFIG['target_os'] == 'linux' && ["testtrustie11","agent12"].include?(`hostname`.gsub("\n",""))
Elasticsearch::Client.new hosts: ['localhost:9200','192.168.80.11:9200','192.168.80.12:9200'], retry_on_failure: true
elsif RbConfig::CONFIG['target_os'] == 'linux' && ["trustie168","trustieserver14","trustieserver16","Trustie18"].include?(`hostname`.gsub("\n",""))
- Elasticsearch::Client.new hosts: ['localhost:9200','192.168.80.168:9200','192.168.80.14:9200','192.168.80.16:9200','192.168.80.18:9200'], retry_on_failure: true
+ Elasticsearch::Client.new hosts: ['localhost:9200','192.168.80.168:9200'], retry_on_failure: true
else
Elasticsearch::Client.new hosts: ['localhost:9200'], retry_on_failure: true
end
diff --git a/db/schema.rb b/db/schema.rb
index c6ca6a0ce..442ceaab9 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
-ActiveRecord::Schema.define(:version => 20151130033906) do
+ActiveRecord::Schema.define(:version => 20151202064455) do
create_table "activities", :force => true do |t|
t.integer "act_id", :null => false
@@ -543,23 +543,26 @@ ActiveRecord::Schema.define(:version => 20151130033906) do
add_index "documents", ["created_on"], :name => "index_documents_on_created_on"
add_index "documents", ["project_id"], :name => "documents_project_id"
- create_table "dts", :force => true do |t|
- t.string "IPLineCode"
- t.string "Description"
- t.string "Num"
- t.string "Variable"
- t.string "TraceInfo"
- t.string "Method"
+ create_table "dts", :primary_key => "Num", :force => true do |t|
+ t.string "Defect", :limit => 50
+ t.string "Category", :limit => 50
t.string "File"
- t.string "IPLine"
- t.string "Review"
- t.string "Category"
- t.string "Defect"
- t.string "PreConditions"
- t.string "StartLine"
+ t.string "Method"
+ t.string "Module", :limit => 20
+ t.string "Variable", :limit => 50
+ t.integer "StartLine"
+ t.integer "IPLine"
+ t.string "IPLineCode", :limit => 200
+ t.string "Judge", :limit => 15
+ t.integer "Review", :limit => 1
+ t.string "Description"
+ t.text "PreConditions", :limit => 2147483647
+ t.text "TraceInfo", :limit => 2147483647
+ t.text "Code", :limit => 2147483647
t.integer "project_id"
- t.datetime "created_at", :null => false
- t.datetime "updated_at", :null => false
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ t.integer "id", :null => false
end
create_table "enabled_modules", :force => true do |t|
@@ -735,6 +738,17 @@ ActiveRecord::Schema.define(:version => 20151130033906) do
add_index "homework_commons", ["course_id", "id"], :name => "index_homework_commons_on_course_id_and_id"
+ create_table "homework_detail_groups", :force => true do |t|
+ t.integer "homework_common_id"
+ t.integer "min_num"
+ t.integer "max_num"
+ t.integer "base_on_project"
+ t.datetime "created_at", :null => false
+ t.datetime "updated_at", :null => false
+ end
+
+ add_index "homework_detail_groups", ["homework_common_id"], :name => "index_homework_detail_groups_on_homework_common_id"
+
create_table "homework_detail_manuals", :force => true do |t|
t.float "ta_proportion"
t.integer "comment_status"
@@ -891,16 +905,6 @@ ActiveRecord::Schema.define(:version => 20151130033906) do
add_index "journal_details", ["journal_id"], :name => "journal_details_journal_id"
- create_table "journal_details_copy", :force => true do |t|
- t.integer "journal_id", :default => 0, :null => false
- t.string "property", :limit => 30, :default => "", :null => false
- t.string "prop_key", :limit => 30, :default => "", :null => false
- t.text "old_value"
- t.text "value"
- end
-
- add_index "journal_details_copy", ["journal_id"], :name => "journal_details_journal_id"
-
create_table "journal_replies", :id => false, :force => true do |t|
t.integer "journal_id"
t.integer "user_id"
diff --git a/public/images/course/hwork_icon.png b/public/images/course/hwork_icon.png
new file mode 100644
index 0000000000000000000000000000000000000000..82c78ac60defdaafaf7e2e8c55530e6939b5b86f
GIT binary patch
literal 4494
zcmb_g2UJtpx<<#LS+D^L48(vKYDj?4g@h!)AfbqWR3QWikOY!o=-B8*PyqphGbkuV
zKuV1CQA9x6pfr(yG%2AdAidl$>dd_N?z;EgweDG`{AaKK``iBZzxFw?78s-bf?|R^
zJUshNjFDE{Cz*Rq@bhx-s(>eU+{bY$%8q)LNbx`EnU0|Xq^6%a`9B~r8l^?-la)#l1O
z!(brb4;8A99`I{Wc4ig;LlPMWP*+w}!m2Wd^{0|+=G)dZ;r)I_Li!Zg)XU}
z+GrG9)ewe6YH6V15C}>gp{}NaRzs<(YH7mZS{fSPu_i0^pCj
zYUBTjf4Bxz1*!%|7;0*1a1(}TqP1Ws6*LT?u7cKpXc+>(Vcq|eT7kJifOp97H*$O*
z;xcYW{FCb3mp>N^j>ughWbRT3Jtn%ByFA-WkZ|k3zG-?$f@6