<%= labelled_form_for @work,:html => { :multipart => true } do |f|%>
diff --git a/app/views/student_work/new.html.erb b/app/views/student_work/new.html.erb
index 500a0ccd3..eda09114e 100644
--- a/app/views/student_work/new.html.erb
+++ b/app/views/student_work/new.html.erb
@@ -49,8 +49,12 @@
- * 作品描述 :
- <%= f.text_area "description", :class => "w620 hwork_txt ", :maxlength => 3000, :placeholder => "最多3000个汉字", :onkeyup => "regexStudentWorkDescription();"%>
+
+ *
+ <%= @homework.homework_type == 2 ? "提交代码" : "作品描述"%>
+ :
+
+ <%= f.text_area "description", :class => "w620 hwork_txt ", :placeholder => "作品描述不能为空", :onkeyup => "regexStudentWorkDescription();"%>
diff --git a/db/migrate/20150708085629_change_studen_work_desc.rb b/db/migrate/20150708085629_change_studen_work_desc.rb
new file mode 100644
index 000000000..af3c25671
--- /dev/null
+++ b/db/migrate/20150708085629_change_studen_work_desc.rb
@@ -0,0 +1,9 @@
+class ChangeStudenWorkDesc < ActiveRecord::Migration
+ def up
+ change_column :student_works,:description,:text,:limit => 4294967295
+ end
+
+ def down
+ change_column :student_works,:description,:text
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 4016cd6a9..539dd95d3 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 => 20150708025533) do
+ActiveRecord::Schema.define(:version => 20150708085629) do
create_table "activities", :force => true do |t|
t.integer "act_id", :null => false
@@ -1222,18 +1222,18 @@ ActiveRecord::Schema.define(:version => 20150708025533) do
create_table "student_works", :force => true do |t|
t.string "name"
- t.text "description"
+ t.text "description", :limit => 2147483647
t.integer "homework_common_id"
t.integer "user_id"
t.float "final_score"
t.float "teacher_score"
t.float "student_score"
t.float "teaching_asistant_score"
- t.integer "project_id", :default => 0
- t.datetime "created_at", :null => false
- t.datetime "updated_at", :null => false
- t.integer "late_penalty", :default => 0
- t.integer "absence_penalty", :default => 0
+ t.integer "project_id", :default => 0
+ t.datetime "created_at", :null => false
+ t.datetime "updated_at", :null => false
+ t.integer "late_penalty", :default => 0
+ t.integer "absence_penalty", :default => 0
end
create_table "student_works_evaluation_distributions", :force => true do |t|
From eb1976efbbeb5adaafe9a6154ef32659ef86562a Mon Sep 17 00:00:00 2001
From: sw <939547590@qq.com>
Date: Thu, 9 Jul 2015 10:38:44 +0800
Subject: [PATCH 26/55] =?UTF-8?q?=E7=BC=96=E7=A8=8B=E4=BD=9C=E4=B8=9A?=
=?UTF-8?q?=EF=BC=8C=E6=9C=80=E7=BB=88=E8=AF=84=E5=88=86=E7=9A=84=E8=AE=A1?=
=?UTF-8?q?=E7=AE=97?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/controllers/student_work_controller.rb | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/app/controllers/student_work_controller.rb b/app/controllers/student_work_controller.rb
index 0efa0aa66..b6f69a4da 100644
--- a/app/controllers/student_work_controller.rb
+++ b/app/controllers/student_work_controller.rb
@@ -190,8 +190,10 @@ class StudentWorkController < ApplicationController
if @work.student_score.nil?
@work.final_score = @work.teaching_asistant_score
else
- final_ta_score = BigDecimal.new("#{@work.teaching_asistant_score}") * BigDecimal.new("#{@homework.homework_detail_manual.ta_proportion}")
- final_s_score = BigDecimal.new("#{@work.student_score}") * (BigDecimal.new('1.0') - BigDecimal.new("#{@homework.homework_detail_manual.ta_proportion}"))
+ ta_proportion = @homework.homework_detail_manual.ta_proportion if @homework.homework_detail_manual
+ ta_proportion = @homework.homework_detail_programing.ta_proportion if @homework.homework_detail_programing
+ final_ta_score = BigDecimal.new("#{@work.teaching_asistant_score}") * BigDecimal.new("#{ta_proportion}")
+ final_s_score = BigDecimal.new("#{@work.student_score}") * (BigDecimal.new('1.0') - BigDecimal.new("#{ta_proportion}"))
final_score = final_ta_score + final_s_score
@work.final_score = format("%.2f",final_score.to_f)
end
From 24d6c8e17e83b80d552864490b4dc9527a009831 Mon Sep 17 00:00:00 2001
From: sw <939547590@qq.com>
Date: Thu, 9 Jul 2015 15:20:59 +0800
Subject: [PATCH 27/55] =?UTF-8?q?=E7=BC=96=E7=A8=8B=E4=BD=9C=E4=B8=9A?=
=?UTF-8?q?=E8=A1=A8=E5=A2=9E=E5=8A=A0question=5Fid=E5=AD=97=E6=AE=B5?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
db/migrate/20150709071731_add_question_id_to_homework.rb | 9 +++++++++
1 file changed, 9 insertions(+)
create mode 100644 db/migrate/20150709071731_add_question_id_to_homework.rb
diff --git a/db/migrate/20150709071731_add_question_id_to_homework.rb b/db/migrate/20150709071731_add_question_id_to_homework.rb
new file mode 100644
index 000000000..d1be59431
--- /dev/null
+++ b/db/migrate/20150709071731_add_question_id_to_homework.rb
@@ -0,0 +1,9 @@
+class AddQuestionIdToHomework < ActiveRecord::Migration
+ def up
+ add_column :homework_detail_programings, :question_id, :integer
+ end
+
+ def down
+ remove_column :homework_detail_programings, :question_id
+ end
+end
From 11191f6743f958342d6888d3d1b3716459d6b90b Mon Sep 17 00:00:00 2001
From: sw <939547590@qq.com>
Date: Thu, 9 Jul 2015 15:50:04 +0800
Subject: [PATCH 28/55] =?UTF-8?q?=E4=B8=8E=E7=BC=96=E7=A8=8B=E4=BD=9C?=
=?UTF-8?q?=E4=B8=9A=E6=9C=8D=E5=8A=A1=E5=99=A8=E8=81=94=E8=B0=83?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/controllers/homework_common_controller.rb | 7 +++++++
app/controllers/student_work_controller.rb | 10 ++++++++--
db/schema.rb | 3 ++-
3 files changed, 17 insertions(+), 3 deletions(-)
diff --git a/app/controllers/homework_common_controller.rb b/app/controllers/homework_common_controller.rb
index 4ea590d54..8109a7e62 100644
--- a/app/controllers/homework_common_controller.rb
+++ b/app/controllers/homework_common_controller.rb
@@ -1,4 +1,5 @@
class HomeworkCommonController < ApplicationController
+ require 'net/http'
layout "base_courses"
before_filter :find_course, :only => [:index,:new,:create,:next_step]
before_filter :find_homework, :only => [:edit,:update,:alert_anonymous_comment,:start_anonymous_comment,:stop_anonymous_comment,:destroy]
@@ -72,6 +73,8 @@ class HomeworkCommonController < ApplicationController
homework_detail_programing.language = "C++"
homework_detail_programing.standard_code = params[:standard_code]
+ question = {title:homework.name,content:homework.description}
+ uri = URI('http://fast.forge.trustie.net/api/questions.json')
if params[:input] && params[:output]
params[:input].each do |k,v|
if params[:output].include? k
@@ -79,6 +82,10 @@ class HomeworkCommonController < ApplicationController
homework_test.input = v
homework_test.output = params[:output][k]
homework.homework_tests << homework_test
+ question[:input] = homework_test.input
+ question[:output] = homework_test.output
+
+ res = Net::HTTP.post_form(uri, question)
end
end
end
diff --git a/app/controllers/student_work_controller.rb b/app/controllers/student_work_controller.rb
index b6f69a4da..d6b79cece 100644
--- a/app/controllers/student_work_controller.rb
+++ b/app/controllers/student_work_controller.rb
@@ -80,8 +80,14 @@ class StudentWorkController < ApplicationController
end
render_attachment_warning_if_needed(stundet_work)
- if @homework.homework_type == 2 #编程作业,学生提交作品后计算系统得分
-
+ if @homework.homework_type == 2 && @homework.homework_detail_programing #编程作业,学生提交作品后计算系统得分
+ url = "http://fast.forge.trustie.net/api/questions/#{@homework.homework_detail_programing.question_id}/solutions.json"
+ uri = URI(url)
+ solutions = {
+ src:stundet_work.description,
+ language:1
+ }
+ Net::HTTP.post_form(uri, solutions)
end
if stundet_work.save
diff --git a/db/schema.rb b/db/schema.rb
index 539dd95d3..fcb925c50 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 => 20150708085629) do
+ActiveRecord::Schema.define(:version => 20150709071731) do
create_table "activities", :force => true do |t|
t.integer "act_id", :null => false
@@ -589,6 +589,7 @@ ActiveRecord::Schema.define(:version => 20150708085629) do
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.float "ta_proportion", :default => 0.1
+ t.integer "question_id"
end
create_table "homework_evaluations", :force => true do |t|
From 851b468e8d875c29e344e6e2ea9aeda955042fb8 Mon Sep 17 00:00:00 2001
From: sw <939547590@qq.com>
Date: Fri, 10 Jul 2015 10:05:28 +0800
Subject: [PATCH 29/55] =?UTF-8?q?admin=E8=83=BD=E8=AE=BF=E9=97=AE=E9=97=AE?=
=?UTF-8?q?=E5=8D=B7=E5=88=97=E8=A1=A8?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/controllers/poll_controller.rb | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/app/controllers/poll_controller.rb b/app/controllers/poll_controller.rb
index d8a9d88c3..758747e02 100644
--- a/app/controllers/poll_controller.rb
+++ b/app/controllers/poll_controller.rb
@@ -23,7 +23,7 @@ class PollController < ApplicationController
def show
@poll = Poll.find params[:id]
- if @poll.polls_status != 2 && !User.current.allowed_to?(:as_teacher,@course)
+ if @poll.polls_status != 2 && (!User.current.allowed_to?(:as_teacher,@course) || User.current.admin?)
render_403
return
end
@@ -393,7 +393,7 @@ class PollController < ApplicationController
end
def is_member_of_course
- render_403 unless(@course && User.current.member_of_course?(@course))
+ render_403 unless(@course && (User.current.member_of_course?(@course) || User.current.admin?))
end
def is_course_teacher
From 4b275bcbdf11e4d1eb0795fafe25bb80b28e7ae8 Mon Sep 17 00:00:00 2001
From: sw <939547590@qq.com>
Date: Fri, 10 Jul 2015 11:36:44 +0800
Subject: [PATCH 30/55] =?UTF-8?q?=E6=A0=B9=E6=8D=AE=E8=BF=94=E5=9B=9E?=
=?UTF-8?q?=E5=80=BC=EF=BC=8C=E4=BD=9C=E4=B8=9A=E8=8E=B7=E5=8F=96question?=
=?UTF-8?q?=E7=9A=84id?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/controllers/homework_common_controller.rb | 2 ++
config/routes.rb | 1 +
2 files changed, 3 insertions(+)
diff --git a/app/controllers/homework_common_controller.rb b/app/controllers/homework_common_controller.rb
index 8109a7e62..017d22de0 100644
--- a/app/controllers/homework_common_controller.rb
+++ b/app/controllers/homework_common_controller.rb
@@ -86,6 +86,8 @@ class HomeworkCommonController < ApplicationController
question[:output] = homework_test.output
res = Net::HTTP.post_form(uri, question)
+ result = JSON.parse(res.body)
+ homework_detail_programing.question_id = result["id"] if result["status"] && result["status"] == 0
end
end
end
diff --git a/config/routes.rb b/config/routes.rb
index f31ec9859..de8a92b66 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -86,6 +86,7 @@ RedmineApp::Application.routes.draw do
end
collection do
post 'next_step'
+ post 'set_program_score'
end
end
From aa5255c430388f79b0bdcca019b2e9a0dbdf2513 Mon Sep 17 00:00:00 2001
From: sw <939547590@qq.com>
Date: Fri, 10 Jul 2015 17:20:04 +0800
Subject: [PATCH 31/55] =?UTF-8?q?=E5=88=9B=E5=BB=BA=E4=BD=9C=E5=93=81?=
=?UTF-8?q?=E4=B9=8B=E5=90=8E=E5=86=8D=E8=B0=83=E7=94=A8=E7=BC=96=E7=A8=8B?=
=?UTF-8?q?=E4=BD=9C=E4=B8=9A=E6=8E=A5=E5=8F=A3=EF=BC=8C=E5=8F=82=E6=95=B0?=
=?UTF-8?q?=E4=BC=A0=E9=80=92=E5=A2=9E=E5=8A=A0=E4=BD=9C=E5=93=81=E7=9A=84?=
=?UTF-8?q?ID?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/controllers/student_work_controller.rb | 29 ++++++++++++++--------
config/routes.rb | 2 +-
2 files changed, 20 insertions(+), 11 deletions(-)
diff --git a/app/controllers/student_work_controller.rb b/app/controllers/student_work_controller.rb
index d6b79cece..fa14f5d42 100644
--- a/app/controllers/student_work_controller.rb
+++ b/app/controllers/student_work_controller.rb
@@ -80,17 +80,17 @@ class StudentWorkController < ApplicationController
end
render_attachment_warning_if_needed(stundet_work)
- if @homework.homework_type == 2 && @homework.homework_detail_programing #编程作业,学生提交作品后计算系统得分
- url = "http://fast.forge.trustie.net/api/questions/#{@homework.homework_detail_programing.question_id}/solutions.json"
- uri = URI(url)
- solutions = {
- src:stundet_work.description,
- language:1
- }
- Net::HTTP.post_form(uri, solutions)
- end
-
if stundet_work.save
+ if @homework.homework_type == 2 && @homework.homework_detail_programing #编程作业,学生提交作品后计算系统得分
+ url = "http://fast.forge.trustie.net/api/questions/#{@homework.homework_detail_programing.question_id}/solutions.json"
+ uri = URI(url)
+ solutions = {
+ id:stundet_work.id,
+ src:stundet_work.description,
+ language:1
+ }
+ Net::HTTP.post_form(uri, solutions)
+ end
respond_to do |format|
format.html {
flash[:notice] = l(:notice_successful_create)
@@ -321,6 +321,15 @@ class StudentWorkController < ApplicationController
end
end
+ #设置编程作业得分
+ def set_program_score
+ res = JSON.parse(response.body)
+ stundet_work = StudentWork.find_by_id res["id"]
+ if stundet_work
+ stundet_work.update_column("student_score",res["status"])
+ end
+ end
+
private
#获取作业
def find_homework
diff --git a/config/routes.rb b/config/routes.rb
index de8a92b66..0d47d2f57 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -86,7 +86,6 @@ RedmineApp::Application.routes.draw do
end
collection do
post 'next_step'
- post 'set_program_score'
end
end
@@ -101,6 +100,7 @@ RedmineApp::Application.routes.draw do
get 'student_work_absence_penalty'
get 'absence_penalty_list'
get 'evaluation_list'
+ post 'set_program_score'
end
end
From 4ae773276285e79f087cbf29aef3aebcbeb9aec4 Mon Sep 17 00:00:00 2001
From: sw <939547590@qq.com>
Date: Wed, 15 Jul 2015 14:44:58 +0800
Subject: [PATCH 32/55] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=88=9B=E5=BB=BA?=
=?UTF-8?q?=E7=BC=96=E7=A8=8B=E4=BD=9C=E4=B8=9A=E4=BD=9C=E5=93=81=E6=97=B6?=
=?UTF-8?q?=E3=80=81=E9=93=BE=E6=8E=A5=E7=BD=91=E5=9D=80?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/controllers/homework_common_controller.rb | 2 +-
app/controllers/student_work_controller.rb | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/app/controllers/homework_common_controller.rb b/app/controllers/homework_common_controller.rb
index 017d22de0..dce5bdf6c 100644
--- a/app/controllers/homework_common_controller.rb
+++ b/app/controllers/homework_common_controller.rb
@@ -74,7 +74,7 @@ class HomeworkCommonController < ApplicationController
homework_detail_programing.standard_code = params[:standard_code]
question = {title:homework.name,content:homework.description}
- uri = URI('http://fast.forge.trustie.net/api/questions.json')
+ uri = URI('http://test.gitlab.trustie.net/api/questions.json')
if params[:input] && params[:output]
params[:input].each do |k,v|
if params[:output].include? k
diff --git a/app/controllers/student_work_controller.rb b/app/controllers/student_work_controller.rb
index fa14f5d42..da4e01d8a 100644
--- a/app/controllers/student_work_controller.rb
+++ b/app/controllers/student_work_controller.rb
@@ -82,7 +82,7 @@ class StudentWorkController < ApplicationController
if stundet_work.save
if @homework.homework_type == 2 && @homework.homework_detail_programing #编程作业,学生提交作品后计算系统得分
- url = "http://fast.forge.trustie.net/api/questions/#{@homework.homework_detail_programing.question_id}/solutions.json"
+ url = "http://test.gitlab.trustie.net/api/questions/#{@homework.homework_detail_programing.question_id}/solutions.json"
uri = URI(url)
solutions = {
id:stundet_work.id,
From 4606cf7c28dc83628ec0bafa95c18348fe7ba79b Mon Sep 17 00:00:00 2001
From: sw <939547590@qq.com>
Date: Wed, 15 Jul 2015 14:57:47 +0800
Subject: [PATCH 33/55] =?UTF-8?q?1=E3=80=81=E7=BC=96=E7=A8=8B=E4=BD=9C?=
=?UTF-8?q?=E4=B8=9A=E6=94=AF=E6=8C=81=E5=A4=9A=E4=B8=AA=E8=BE=93=E5=85=A5?=
=?UTF-8?q?=E8=BE=93=E5=87=BA=202=E3=80=81=E7=BC=96=E7=A8=8B=E4=BD=9C?=
=?UTF-8?q?=E5=93=81=E5=9B=9E=E8=B0=83=E5=8F=82=E6=95=B0=E8=8E=B7=E5=8F=96?=
=?UTF-8?q?=E6=94=B9=E4=B8=BAparams=E8=8E=B7=E5=8F=96?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/controllers/homework_common_controller.rb | 13 +++++++------
app/controllers/student_work_controller.rb | 5 ++---
2 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/app/controllers/homework_common_controller.rb b/app/controllers/homework_common_controller.rb
index dce5bdf6c..a8ccf2b9a 100644
--- a/app/controllers/homework_common_controller.rb
+++ b/app/controllers/homework_common_controller.rb
@@ -75,6 +75,8 @@ class HomeworkCommonController < ApplicationController
question = {title:homework.name,content:homework.description}
uri = URI('http://test.gitlab.trustie.net/api/questions.json')
+ question[:input] = []
+ question[:output] = []
if params[:input] && params[:output]
params[:input].each do |k,v|
if params[:output].include? k
@@ -82,15 +84,14 @@ class HomeworkCommonController < ApplicationController
homework_test.input = v
homework_test.output = params[:output][k]
homework.homework_tests << homework_test
- question[:input] = homework_test.input
- question[:output] = homework_test.output
-
- res = Net::HTTP.post_form(uri, question)
- result = JSON.parse(res.body)
- homework_detail_programing.question_id = result["id"] if result["status"] && result["status"] == 0
+ question[:input] << homework_test.input
+ question[:output] << homework_test.output
end
end
end
+ res = Net::HTTP.post_form(uri, question)
+ result = JSON.parse(res.body)
+ homework_detail_programing.question_id = result["id"] if result["status"] && result["status"] == 0
homework.homework_detail_programing = homework_detail_programing
else
diff --git a/app/controllers/student_work_controller.rb b/app/controllers/student_work_controller.rb
index da4e01d8a..cf712bfc9 100644
--- a/app/controllers/student_work_controller.rb
+++ b/app/controllers/student_work_controller.rb
@@ -323,10 +323,9 @@ class StudentWorkController < ApplicationController
#设置编程作业得分
def set_program_score
- res = JSON.parse(response.body)
- stundet_work = StudentWork.find_by_id res["id"]
+ stundet_work = StudentWork.find_by_id params[:id]
if stundet_work
- stundet_work.update_column("student_score",res["status"])
+ stundet_work.update_column("student_score",params[:status] == 0 ? 100 : 0)
end
end
From 0b66097bfb7d8721efa7030b10e544c14e0e4981 Mon Sep 17 00:00:00 2001
From: sw <939547590@qq.com>
Date: Wed, 15 Jul 2015 15:21:26 +0800
Subject: [PATCH 34/55] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=AF=8F=E4=BB=BD?=
=?UTF-8?q?=E7=BC=96=E7=A8=8B=E4=BD=9C=E5=93=81=E7=9A=84=E6=B5=8B=E8=AF=95?=
=?UTF-8?q?=E7=BB=93=E6=9E=9C=E7=9A=84=E8=AE=B0=E5=BD=95?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/models/homework_test.rb | 1 +
app/models/student_work.rb | 1 +
app/models/student_work_test.rb | 6 ++++++
db/migrate/20150715070534_create_test_result.rb | 13 +++++++++++++
4 files changed, 21 insertions(+)
create mode 100644 app/models/student_work_test.rb
create mode 100644 db/migrate/20150715070534_create_test_result.rb
diff --git a/app/models/homework_test.rb b/app/models/homework_test.rb
index f7d9b20bc..7c477bfaf 100644
--- a/app/models/homework_test.rb
+++ b/app/models/homework_test.rb
@@ -2,4 +2,5 @@ class HomeworkTest < ActiveRecord::Base
attr_accessible :input, :output, :homework_common_id
belongs_to :homework_common
+ has_one :student_work_test
end
diff --git a/app/models/student_work.rb b/app/models/student_work.rb
index e2be18423..0db36b4ba 100644
--- a/app/models/student_work.rb
+++ b/app/models/student_work.rb
@@ -7,6 +7,7 @@ class StudentWork < ActiveRecord::Base
has_many :student_works_evaluation_distributions, :dependent => :destroy
has_many :student_works_scores, :dependent => :destroy
belongs_to :project
+ has_one :student_work_test
acts_as_attachable
end
diff --git a/app/models/student_work_test.rb b/app/models/student_work_test.rb
new file mode 100644
index 000000000..b9264191c
--- /dev/null
+++ b/app/models/student_work_test.rb
@@ -0,0 +1,6 @@
+class StudentWorkTest < ActiveRecord::Base
+ attr_accessible :student_work_id, :homework_test_id
+
+ belongs_to :homework_test
+ belongs_to :student_work
+end
diff --git a/db/migrate/20150715070534_create_test_result.rb b/db/migrate/20150715070534_create_test_result.rb
new file mode 100644
index 000000000..f78953129
--- /dev/null
+++ b/db/migrate/20150715070534_create_test_result.rb
@@ -0,0 +1,13 @@
+class CreateTestResult < ActiveRecord::Migration
+ def up
+ create_table :student_work_test do |t|
+ t.integer :student_work_id
+ t.integer :homework_test_id
+ t.integer :result
+ t.timestamps
+ end
+ end
+
+ def down
+ end
+end
From 536a9d7b6b65c1c0b90f3fa2e909cf26b0f814d4 Mon Sep 17 00:00:00 2001
From: sw <939547590@qq.com>
Date: Wed, 15 Jul 2015 15:28:44 +0800
Subject: [PATCH 35/55] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=A1=A8=E5=90=8D?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../20150715070534_create_test_result.rb | 3 ++-
db/schema.rb | 20 +++++++++----------
2 files changed, 11 insertions(+), 12 deletions(-)
diff --git a/db/migrate/20150715070534_create_test_result.rb b/db/migrate/20150715070534_create_test_result.rb
index f78953129..4816fbcb8 100644
--- a/db/migrate/20150715070534_create_test_result.rb
+++ b/db/migrate/20150715070534_create_test_result.rb
@@ -1,6 +1,6 @@
class CreateTestResult < ActiveRecord::Migration
def up
- create_table :student_work_test do |t|
+ create_table :student_work_tests do |t|
t.integer :student_work_id
t.integer :homework_test_id
t.integer :result
@@ -9,5 +9,6 @@ class CreateTestResult < ActiveRecord::Migration
end
def down
+ drop_table :student_work_tests
end
end
diff --git a/db/schema.rb b/db/schema.rb
index a37d2f9d8..383545cf6 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 => 20150709071731) do
+ActiveRecord::Schema.define(:version => 20150715070534) do
create_table "activities", :force => true do |t|
t.integer "act_id", :null => false
@@ -723,16 +723,6 @@ ActiveRecord::Schema.define(:version => 20150709071731) 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"
@@ -1231,6 +1221,14 @@ ActiveRecord::Schema.define(:version => 20150709071731) do
t.integer "project_id"
end
+ create_table "student_work_tests", :force => true do |t|
+ t.integer "student_work_id"
+ t.integer "homework_test_id"
+ t.integer "result"
+ t.datetime "created_at", :null => false
+ t.datetime "updated_at", :null => false
+ end
+
create_table "student_works", :force => true do |t|
t.string "name"
t.text "description", :limit => 2147483647
From f909fbb8356232502830c89ea1f409dc8142f1ea Mon Sep 17 00:00:00 2001
From: sw <939547590@qq.com>
Date: Wed, 15 Jul 2015 16:01:03 +0800
Subject: [PATCH 36/55] =?UTF-8?q?=E4=BD=9C=E5=93=81=E5=88=97=E8=A1=A8?=
=?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=88=86=E7=8F=AD=E8=BF=87=E6=BB=A4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/helpers/student_work_helper.rb | 15 +++++++++++++++
app/views/student_work/index.html.erb | 1 +
config/locales/zh.yml | 1 +
public/stylesheets/courses.css | 2 +-
public/stylesheets/public.css | 1 +
5 files changed, 19 insertions(+), 1 deletion(-)
diff --git a/app/helpers/student_work_helper.rb b/app/helpers/student_work_helper.rb
index f88b1ff21..2171d44f5 100644
--- a/app/helpers/student_work_helper.rb
+++ b/app/helpers/student_work_helper.rb
@@ -80,4 +80,19 @@ module StudentWorkHelper
end
color
end
+
+ #获取分班信息
+ def course_group_list course
+ result = []
+ if course.course_groups && !course.course_groups.empty?
+ result << l(:label_chose_group)
+ course.course_groups.each do |group|
+ option = []
+ option << group.name
+ option << group.id
+ result << option
+ end
+ end
+ result
+ end
end
\ No newline at end of file
diff --git a/app/views/student_work/index.html.erb b/app/views/student_work/index.html.erb
index 70f7c08f4..ad355c4ad 100644
--- a/app/views/student_work/index.html.erb
+++ b/app/views/student_work/index.html.erb
@@ -49,6 +49,7 @@
<% if @show_all%>
+ <%= select_tag :late_penalty,options_for_select(course_group_list(@course),@group), {:class => "fl h22 w100 ml10"} %>
搜索
<%= link_to("缺评情况",student_work_absence_penalty_student_work_index_path(:homework => @homework.id), :class => "student_work_search fl", :target => "_blank") if((@is_teacher || User.current.admin?) && @homework.homework_type == 1) %>
<% end%>
diff --git a/config/locales/zh.yml b/config/locales/zh.yml
index ac8ab40a9..2dd5bcf9a 100644
--- a/config/locales/zh.yml
+++ b/config/locales/zh.yml
@@ -2026,6 +2026,7 @@ zh:
label_file_lost_list: 缺失文件列表
lable_unset: 未设置
+ label_chose_group: 请选择分班
diff --git a/public/stylesheets/courses.css b/public/stylesheets/courses.css
index a6d8ff0a2..abeec52d3 100644
--- a/public/stylesheets/courses.css
+++ b/public/stylesheets/courses.css
@@ -665,7 +665,7 @@ a:hover.ping_pic{border:1px solid #64bdd9;}
a.down_btn{ border:1px solid #CCC; color:#999; padding:0px 5px; font-size:12px; text-align:center; display:block;}
a:hover.down_btn{ background:#14ad5a; color:#fff; border:1px solid #14ad5a;}
.fr{ float:right;}
-.min_search{ width:200px; height:20px; border:1px solid #d0d0d0; color:#666; background:url(../images/public_icon.png) 185px -193px no-repeat; cursor:pointer;}
+.min_search{ width:140px; height:20px; border:1px solid #d0d0d0; color:#666; background:url(../images/public_icon.png) 185px -193px no-repeat; }
.li_min_search{ float:right; margin-right:-10px;}
.info_ni_download{ width:100px; padding:5px;position: absolute;display:none;-moz-border-radius:3px; -webkit-border-radius:3px; border-radius:3px; box-shadow:0px 0px 5px #194a81; color:#666; background:#fff; text-align:left;margin-left: 200px;margin-top: 10px;}
.info_ni{ width:100px; padding:5px;position: absolute;display:none;-moz-border-radius:3px; -webkit-border-radius:3px; border-radius:3px; box-shadow:0px 0px 5px #194a81; color:#666; background:#fff; text-align:left;margin-left: 50px;margin-top: -5px;}
diff --git a/public/stylesheets/public.css b/public/stylesheets/public.css
index 8a128e71f..8e16c9436 100644
--- a/public/stylesheets/public.css
+++ b/public/stylesheets/public.css
@@ -110,6 +110,7 @@ h4{ font-size:14px; color:#3b3b3b;}
.w350{ width:350px;}
.w610{ width:610px;}
.w600{ width:600px;}
+.h20{height: 20px;}
.h22{ height:22px;}
.h26{ height:26px;}
.h50{ height:50px;}
From 66c1dfa77e5f0c78c5e1b768bb5fe30c2eca0724 Mon Sep 17 00:00:00 2001
From: sw <939547590@qq.com>
Date: Wed, 15 Jul 2015 17:34:34 +0800
Subject: [PATCH 37/55] =?UTF-8?q?=E4=BD=9C=E5=93=81=E5=88=97=E8=A1=A8?=
=?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=88=86=E7=8F=AD=E7=9A=84=E8=BF=87=E6=BB=A4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/controllers/student_work_controller.rb | 101 +++++++++++++-----
app/helpers/student_work_helper.rb | 5 +-
.../_evaluation_student_work.html.erb | 2 +-
.../_evaluation_student_work_title.html.erb | 26 ++---
.../student_work/_student_work_title.html.erb | 20 ++--
app/views/student_work/index.html.erb | 6 +-
public/javascripts/course.js | 8 +-
7 files changed, 110 insertions(+), 58 deletions(-)
diff --git a/app/controllers/student_work_controller.rb b/app/controllers/student_work_controller.rb
index cf712bfc9..d4a1bd4e5 100644
--- a/app/controllers/student_work_controller.rb
+++ b/app/controllers/student_work_controller.rb
@@ -9,36 +9,75 @@ class StudentWorkController < ApplicationController
before_filter :teacher_of_course, :only => [:student_work_absence_penalty, :absence_penalty_list, :evaluation_list]
def index
- @order,@b_sort,@name = params[:order] || "score",params[:sort] || "desc",params[:name] || ""
+ @order,@b_sort,@name,@group = params[:order] || "score",params[:sort] || "desc",params[:name] || "",params[:group]
@is_teacher = User.current.allowed_to?(:as_teacher,@course)
- #老师 || 非匿评作业 || 匿评结束 显示所有的作品
- @show_all = @is_teacher || @homework.homework_type != 1 || @homework.homework_detail_manual.comment_status == 3 || User.current.admin?
- if @show_all
- if @homework.homework_type == 1 || @is_teacher || User.current.admin? #超级管理员 || 老师 || 匿评结束 显示所有的作品
- if @order == "name"
- @stundet_works = search_homework_member @homework.student_works.select("*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").joins(:user).order("users.lastname #{@b_sort}, users.firstname #{@b_sort}"),@name
- else
- @stundet_works = search_homework_member @homework.student_works.select("*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").order("#{@order} #{@b_sort}"),@name
- end
- else #剩余情况: 学生 && 非匿评作业 如果未提交作品,只能看到自己的,提交了作品,能看到所有作品
- my_work = @homework.student_works.select("*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where(:user_id => User.current.id)
- if my_work.empty?
- @stundet_works = []
- else
+ unless @group == "0" || @group.nil?
+ group_students = CourseGroup.find_by_id(@group).users
+ if group_students.empty?
+ student_in_group = '(0)'
+ else
+ student_in_group = '(' + group_students.map{|user| user.id}.join(',') + ')'
+ end
+ #老师 || 非匿评作业 || 匿评结束 显示所有的作品
+ @show_all = @is_teacher || @homework.homework_type != 1 || @homework.homework_detail_manual.comment_status == 3 || User.current.admin?
+ if @show_all
+ if @homework.homework_type == 1 || @is_teacher || User.current.admin? #超级管理员 || 老师 || 匿评结束 显示所有的作品
if @order == "name"
- @stundet_works = search_homework_member @homework.student_works.select("*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").joins(:user).order("users.lastname #{@b_sort}, users.firstname #{@b_sort}"),@name
+ @stundet_works = search_homework_member @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").joins(:user).where("users.id in #{student_in_group}").order("users.lastname #{@b_sort}, users.firstname #{@b_sort}"),@name
else
- @stundet_works = search_homework_member @homework.student_works.select("*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").order("#{@order} #{@b_sort}"),@name
+ @stundet_works = search_homework_member @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").joins(:user).where("users.id in #{student_in_group}").order("#{@order} #{@b_sort}"),@name
+ end
+ else #剩余情况: 学生 && 非匿评作业 如果未提交作品,只能看到自己的,提交了作品,能看到所有作品
+ my_work = @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where(:user_id => User.current.id)
+ if my_work.empty?
+ @stundet_works = []
+ else
+ if @order == "name"
+ @stundet_works = search_homework_member @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").joins(:user).where("users.id in #{student_in_group}").order("users.lastname #{@b_sort}, users.firstname #{@b_sort}"),@name
+ else
+ @stundet_works = search_homework_member @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").joins(:user).where("users.id in #{student_in_group}").order("#{@order} #{@b_sort}"),@name
+ end
end
end
+ else #学生
+ if @homework.homework_detail_manual.comment_status == 1 #未开启匿评,只显示我的作品
+ @stundet_works = @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where(:user_id => User.current.id)
+ elsif @homework.homework_detail_manual.comment_status == 2 #匿评列表,显示匿评作品和我的作品
+ @is_evaluation = true
+ my_work = @homework.student_works.where(:user_id => User.current.id)
+ @stundet_works = my_work + User.current.student_works_evaluation_distributions.map(&:student_work).select { |work| work.homework_common_id == @homework.id}
+ end
end
- else #学生
- if @homework.homework_detail_manual.comment_status == 1 #未开启匿评,只显示我的作品
- @stundet_works = @homework.student_works.select("*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where(:user_id => User.current.id)
- elsif @homework.homework_detail_manual.comment_status == 2 #匿评列表,显示匿评作品和我的作品
- @is_evaluation = true
- my_work = @homework.student_works.where(:user_id => User.current.id)
- @stundet_works = my_work + User.current.student_works_evaluation_distributions.map(&:student_work).select { |work| work.homework_common_id == @homework.id}
+ else
+ #老师 || 非匿评作业 || 匿评结束 显示所有的作品
+ @show_all = @is_teacher || @homework.homework_type != 1 || @homework.homework_detail_manual.comment_status == 3 || User.current.admin?
+ if @show_all
+ if @homework.homework_type == 1 || @is_teacher || User.current.admin? #超级管理员 || 老师 || 匿评结束 显示所有的作品
+ if @order == "name"
+ @stundet_works = search_homework_member @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").joins(:user).order("users.lastname #{@b_sort}, users.firstname #{@b_sort}"),@name
+ else
+ @stundet_works = search_homework_member @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").order("#{@order} #{@b_sort}"),@name
+ end
+ else #剩余情况: 学生 && 非匿评作业 如果未提交作品,只能看到自己的,提交了作品,能看到所有作品
+ my_work = @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where(:user_id => User.current.id)
+ if my_work.empty?
+ @stundet_works = []
+ else
+ if @order == "name"
+ @stundet_works = search_homework_member @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").joins(:user).order("users.lastname #{@b_sort}, users.firstname #{@b_sort}"),@name
+ else
+ @stundet_works = search_homework_member @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").order("#{@order} #{@b_sort}"),@name
+ end
+ end
+ end
+ else #学生
+ if @homework.homework_detail_manual.comment_status == 1 #未开启匿评,只显示我的作品
+ @stundet_works = @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where(:user_id => User.current.id)
+ elsif @homework.homework_detail_manual.comment_status == 2 #匿评列表,显示匿评作品和我的作品
+ @is_evaluation = true
+ my_work = @homework.student_works.where(:user_id => User.current.id)
+ @stundet_works = my_work + User.current.student_works_evaluation_distributions.map(&:student_work).select { |work| work.homework_common_id == @homework.id}
+ end
end
end
@homework_commons = @course.homework_commons.order("created_at desc")
@@ -170,6 +209,12 @@ class StudentWorkController < ApplicationController
if @score
@score.comment = params[:new_form][:user_message] if params[:new_form] && params[:new_form][:user_message] && params[:new_form][:user_message] != ""
@score.score = params[:score] if params[:score]
+ if User.current.admin?
+ @score.reviewer_role = 1
+ else
+ role = User.current.members.where("course_id = ?",@course.id).first.roles.first.name
+ @score.reviewer_role = get_role_by_name(role)
+ end
@is_new = false
else
@score = StudentWorksScore.new
@@ -177,8 +222,12 @@ class StudentWorkController < ApplicationController
@score.comment = params[:new_form][:user_message] if params[:new_form] && params[:new_form][:user_message] && params[:new_form][:user_message] != ""
@score.user_id = User.current.id
@score.student_work_id = @work.id
- role = User.current.members.where("course_id = ?",@course.id).first.roles.first.name
- User.current.admin? ? @score.reviewer_role = 1 : @score.reviewer_role = get_role_by_name(role)
+ if User.current.admin?
+ @score.reviewer_role = 1
+ else
+ role = User.current.members.where("course_id = ?",@course.id).first.roles.first.name
+ @score.reviewer_role = get_role_by_name(role)
+ end
@is_new = true
end
diff --git a/app/helpers/student_work_helper.rb b/app/helpers/student_work_helper.rb
index 2171d44f5..f24d5078f 100644
--- a/app/helpers/student_work_helper.rb
+++ b/app/helpers/student_work_helper.rb
@@ -85,7 +85,10 @@ module StudentWorkHelper
def course_group_list course
result = []
if course.course_groups && !course.course_groups.empty?
- result << l(:label_chose_group)
+ base = []
+ base << l(:label_chose_group)
+ base << 0
+ result << base
course.course_groups.each do |group|
option = []
option << group.name
diff --git a/app/views/student_work/_evaluation_student_work.html.erb b/app/views/student_work/_evaluation_student_work.html.erb
index 0f66452c7..b83917481 100644
--- a/app/views/student_work/_evaluation_student_work.html.erb
+++ b/app/views/student_work/_evaluation_student_work.html.erb
@@ -9,7 +9,7 @@
<%= link_to student_work.user.show_name,user_path(student_work.user),:title => student_work.user.show_name, :class => "c_blue02"%>
- <%= link_to student_work.name, student_work_path(student_work),:remote => true,:title => student_work.name, :class => "c_blue02"%>
+ <%= link_to student_work.name, student_work_path(student_work.id),:remote => true,:title => student_work.name, :class => "c_blue02"%>
<% if Time.parse(@homework.end_time.to_s).strftime("%Y-%m-%d") < Time.parse(student_work.created_at.to_s).strftime("%Y-%m-%d") %>
diff --git a/app/views/student_work/_evaluation_student_work_title.html.erb b/app/views/student_work/_evaluation_student_work_title.html.erb
index a95106a48..f19438f78 100644
--- a/app/views/student_work/_evaluation_student_work_title.html.erb
+++ b/app/views/student_work/_evaluation_student_work_title.html.erb
@@ -2,46 +2,46 @@
学号
- <%= link_to "姓名",@show_all ? student_work_index_path(:homework => @homework.id,:order => "name", :sort => @score, :name => @name) : "javascript:void(0)",:class => "f14 f_b c_dark fl"%>
+ <%= link_to "姓名",@show_all ? student_work_index_path(:homework => @homework.id,:order => "name", :sort => @score, :name => @name, :group => @group) : "javascript:void(0)",:class => "f14 f_b c_dark fl"%>
<% if @show_all && @order == "name"%>
-
+ <%= link_to "",student_work_index_path(:homework => @homework.id,:order => "name", :sort => @score, :name => @name, :group => @group) ,:class => @score == 'desc' ? 'st_up' : 'st_down'%>
<% end%>
作品名称
- <%= link_to "时间",@show_all ? student_work_index_path(:homework => @homework.id,:order => "created_at", :sort => @score, :name => @name) : "javascript:void(0)",:class => "f14 f_b c_dark fl"%>
+ <%= link_to "时间",@show_all ? student_work_index_path(:homework => @homework.id,:order => "created_at", :sort => @score, :name => @name, :group => @group) : "javascript:void(0)",:class => "f14 f_b c_dark fl"%>
<% if @show_all && @order == "created_at"%>
- <%= link_to "",student_work_index_path(:homework => @homework.id,:order => "created_at", :sort => @score, :name => @name) ,:class => @score == 'desc' ? 'st_up' : 'st_down'%>
+ <%= link_to "",student_work_index_path(:homework => @homework.id,:order => "created_at", :sort => @score, :name => @name, :group => @group) ,:class => @score == 'desc' ? 'st_up' : 'st_down'%>
<% end%>
- <%= link_to "教师",@show_all ? student_work_index_path(:homework => @homework.id,:order => "teacher_score", :sort => @score, :name => @name) : "javascript:void(0)",:class => "f14 f_b c_dark fl"%>
+ <%= link_to "教师",@show_all ? student_work_index_path(:homework => @homework.id,:order => "teacher_score", :sort => @score, :name => @name, :group => @group) : "javascript:void(0)",:class => "f14 f_b c_dark fl"%>
<% if @show_all && @order == "teacher_score"%>
- <%= link_to "", student_work_index_path(:homework => @homework.id,:order => "teacher_score", :sort => @score, :name => @name) ,:class => @score == 'desc' ? 'st_up' : 'st_down'%>
+ <%= link_to "", student_work_index_path(:homework => @homework.id,:order => "teacher_score", :sort => @score, :name => @name, :group => @group) ,:class => @score == 'desc' ? 'st_up' : 'st_down'%>
<% end%>
- <%= link_to "教辅",@show_all ? student_work_index_path(:homework => @homework.id,:order => "teaching_asistant_score", :sort => @score, :name => @name) : "javascript:void(0)",:class => "f14 f_b c_dark fl"%>
+ <%= link_to "教辅",@show_all ? student_work_index_path(:homework => @homework.id,:order => "teaching_asistant_score", :sort => @score, :name => @name, :group => @group) : "javascript:void(0)",:class => "f14 f_b c_dark fl"%>
<% if @show_all && @order == "teaching_asistant_score"%>
- <%= link_to "", student_work_index_path(:homework => @homework.id,:order => "teaching_asistant_score", :sort => @score, :name => @name) ,:class => @score == 'desc' ? 'st_up' : 'st_down'%>
+ <%= link_to "", student_work_index_path(:homework => @homework.id,:order => "teaching_asistant_score", :sort => @score, :name => @name, :group => @group) ,:class => @score == 'desc' ? 'st_up' : 'st_down'%>
<% end%>
<% if @homework.homework_type == 1%>
- <%= link_to "匿评",@show_all ? student_work_index_path(:homework => @homework.id,:order => "student_score", :sort => @score, :name => @name) : "javascript:void(0)",:class => "f14 f_b c_dark fl"%>
+ <%= link_to "匿评",@show_all ? student_work_index_path(:homework => @homework.id,:order => "student_score", :sort => @score, :name => @name, :group => @group) : "javascript:void(0)",:class => "f14 f_b c_dark fl"%>
<% elsif @homework.homework_type == 2%>
- <%= link_to "系统",@show_all ? student_work_index_path(:homework => @homework.id,:order => "student_score", :sort => @score, :name => @name) : "javascript:void(0)",:class => "f14 f_b c_dark fl"%>
+ <%= link_to "系统",@show_all ? student_work_index_path(:homework => @homework.id,:order => "student_score", :sort => @score, :name => @name, :group => @group) : "javascript:void(0)",:class => "f14 f_b c_dark fl"%>
<% end %>
<% if @show_all && @order == "student_score"%>
- <%= link_to "", student_work_index_path(:homework => @homework.id,:order => "student_score", :sort => @score, :name => @name) ,:class => @score == 'desc' ? 'st_up' : 'st_down'%>
+ <%= link_to "", student_work_index_path(:homework => @homework.id,:order => "student_score", :sort => @score, :name => @name, :group => @group) ,:class => @score == 'desc' ? 'st_up' : 'st_down'%>
<% end%>
- <%= link_to "成绩",@show_all ? student_work_index_path(:homework => @homework.id,:order => "score", :sort => @score, :name => @name) : "javascript:void(0)",:class => "f14 f_b c_dark fl"%>
+ <%= link_to "成绩",@show_all ? student_work_index_path(:homework => @homework.id,:order => "score", :sort => @score, :name => @name, :group => @group) : "javascript:void(0)",:class => "f14 f_b c_dark fl"%>
<% if @show_all && @order == "score"%>
- <%= link_to "", student_work_index_path(:homework => @homework.id,:order => "score", :sort => @score, :name => @name) ,:class => @score == 'desc' ? 'st_up' : 'st_down'%>
+ <%= link_to "", student_work_index_path(:homework => @homework.id,:order => "score", :sort => @score, :name => @name, :group => @group) ,:class => @score == 'desc' ? 'st_up' : 'st_down'%>
<% end%>
\ No newline at end of file
diff --git a/app/views/student_work/_student_work_title.html.erb b/app/views/student_work/_student_work_title.html.erb
index c46f7dc79..24e6a1b37 100644
--- a/app/views/student_work/_student_work_title.html.erb
+++ b/app/views/student_work/_student_work_title.html.erb
@@ -2,36 +2,36 @@
学号
- <%= link_to "姓名",@show_all ? student_work_index_path(:homework => @homework.id,:order => "name", :sort => @score, :name => @name) : "javascript:void(0)",:class => "f14 f_b c_dark fl"%>
+ <%= link_to "姓名",@show_all ? student_work_index_path(:homework => @homework.id,:order => "name", :sort => @score, :name => @name, :group => @group) : "javascript:void(0)",:class => "f14 f_b c_dark fl"%>
<% if @show_all && @order == "name"%>
-
+ <%= link_to "",student_work_index_path(:homework => @homework.id,:order => "name", :sort => @score, :name => @name, :group => @group) ,:class => @score == 'desc' ? 'st_up' : 'st_down'%>
<% end%>
作品名称
- <%= link_to "时间",@show_all ? student_work_index_path(:homework => @homework.id,:order => "created_at", :sort => @score, :name => @name) : "javascript:void(0)",:class => "f14 f_b c_dark fl"%>
+ <%= link_to "时间",@show_all ? student_work_index_path(:homework => @homework.id,:order => "created_at", :sort => @score, :name => @name, :group => @group) : "javascript:void(0)",:class => "f14 f_b c_dark fl"%>
<% if @show_all && @order == "created_at"%>
- <%= link_to "",student_work_index_path(:homework => @homework.id,:order => "created_at", :sort => @score, :name => @name) ,:class => @score == 'desc' ? 'st_up' : 'st_down'%>
+ <%= link_to "",student_work_index_path(:homework => @homework.id,:order => "created_at", :sort => @score, :name => @name, :group => @group) ,:class => @score == 'desc' ? 'st_up' : 'st_down'%>
<% end%>
- <%= link_to "教师",@show_all ? student_work_index_path(:homework => @homework.id,:order => "teacher_score", :sort => @score, :name => @name) : "javascript:void(0)",:class => "f14 f_b c_dark fl"%>
+ <%= link_to "教师",@show_all ? student_work_index_path(:homework => @homework.id,:order => "teacher_score", :sort => @score, :name => @name, :group => @group) : "javascript:void(0)",:class => "f14 f_b c_dark fl"%>
<% if @show_all && @order == "teacher_score"%>
- <%= link_to "", student_work_index_path(:homework => @homework.id,:order => "teacher_score", :sort => @score, :name => @name) ,:class => @score == 'desc' ? 'st_up' : 'st_down'%>
+ <%= link_to "", student_work_index_path(:homework => @homework.id,:order => "teacher_score", :sort => @score, :name => @name, :group => @group) ,:class => @score == 'desc' ? 'st_up' : 'st_down'%>
<% end%>
- <%= link_to "教辅",@show_all ? student_work_index_path(:homework => @homework.id,:order => "teaching_asistant_score", :sort => @score, :name => @name) : "javascript:void(0)",:class => "f14 f_b c_dark fl"%>
+ <%= link_to "教辅",@show_all ? student_work_index_path(:homework => @homework.id,:order => "teaching_asistant_score", :sort => @score, :name => @name, :group => @group) : "javascript:void(0)",:class => "f14 f_b c_dark fl"%>
<% if @show_all && @order == "teaching_asistant_score"%>
- <%= link_to "", student_work_index_path(:homework => @homework.id,:order => "teaching_asistant_score", :sort => @score, :name => @name) ,:class => @score == 'desc' ? 'st_up' : 'st_down'%>
+ <%= link_to "", student_work_index_path(:homework => @homework.id,:order => "teaching_asistant_score", :sort => @score, :name => @name, :group => @group) ,:class => @score == 'desc' ? 'st_up' : 'st_down'%>
<% end%>
- <%= link_to "成绩",@show_all ? student_work_index_path(:homework => @homework.id,:order => "score", :sort => @score, :name => @name) : "javascript:void(0)",:class => "f14 f_b c_dark fl"%>
+ <%= link_to "成绩",@show_all ? student_work_index_path(:homework => @homework.id,:order => "score", :sort => @score, :name => @name, :group => @group) : "javascript:void(0)",:class => "f14 f_b c_dark fl"%>
<% if @show_all && @order == "score"%>
- <%= link_to "", student_work_index_path(:homework => @homework.id,:order => "score", :sort => @score, :name => @name) ,:class => @score == 'desc' ? 'st_up' : 'st_down'%>
+ <%= link_to "", student_work_index_path(:homework => @homework.id,:order => "score", :sort => @score, :name => @name, :group => @group) ,:class => @score == 'desc' ? 'st_up' : 'st_down'%>
<% end%>
\ No newline at end of file
diff --git a/app/views/student_work/index.html.erb b/app/views/student_work/index.html.erb
index ad355c4ad..b9148a88f 100644
--- a/app/views/student_work/index.html.erb
+++ b/app/views/student_work/index.html.erb
@@ -48,9 +48,9 @@
<%= link_to "所有作品(
#{@stundet_works.count} )".html_safe,student_work_index_path(:homework => @homework.id), :class => "fl"%>
<% if @show_all%>
-
- <%= select_tag :late_penalty,options_for_select(course_group_list(@course),@group), {:class => "fl h22 w100 ml10"} %>
-
搜索
+
+ <%= select_tag(:late_penalty,options_for_select(course_group_list(@course),@group), {:class => "fl h22 w100 ml10"}) if @is_teacher %>
+
搜索
<%= link_to("缺评情况",student_work_absence_penalty_student_work_index_path(:homework => @homework.id), :class => "student_work_search fl", :target => "_blank") if((@is_teacher || User.current.admin?) && @homework.homework_type == 1) %>
<% end%>
<% if @is_teacher%>
diff --git a/public/javascripts/course.js b/public/javascripts/course.js
index 8db456cbf..db1f761f2 100644
--- a/public/javascripts/course.js
+++ b/public/javascripts/course.js
@@ -861,14 +861,14 @@ function clickOK(path)
});
}
//查询
-function SearchByName(obj,url,event)
+function SearchByName(name,group,url,event)
{
var keycode = (event.keyCode ? event.keyCode : event.which);
if(keycode == '13'){
- location.href = url + "&name=" + obj.val();
+ location.href = url + "&name=" + name + "&group=" + group;
}
}
-function SearchByName_1(obj,url)
+function SearchByName_1(name,group,url)
{
- location.href = url + "&name=" + obj.val();
+ location.href = url + "&name=" + name + "&group=" + group;
}
From b6e123e47603f345de81cdbad2a28823522b8c2c Mon Sep 17 00:00:00 2001
From: sw <939547590@qq.com>
Date: Thu, 16 Jul 2015 10:49:39 +0800
Subject: [PATCH 38/55] =?UTF-8?q?=E5=8F=B3=E4=B8=8A=E8=A7=92=E5=AF=BC?=
=?UTF-8?q?=E8=88=AA=E6=A0=8F=E9=97=AE=E9=A2=98?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/views/layouts/_base_header.html.erb | 5 +----
public/javascripts/header.js | 20 +++++++++++++-------
2 files changed, 14 insertions(+), 11 deletions(-)
diff --git a/app/views/layouts/_base_header.html.erb b/app/views/layouts/_base_header.html.erb
index b800a1722..16fa44c73 100644
--- a/app/views/layouts/_base_header.html.erb
+++ b/app/views/layouts/_base_header.html.erb
@@ -101,10 +101,7 @@
addSlipMenu();
addProjectSlipMenu ();
addCourseSlipMenu();
- });
-
- jQuery(document).ready(function($) {
- $('.sub_menu').find("a").attr('target', '_blank');
+ $('.sub_menu').find("a").attr('target', '_blank');
$('.project_sub_menu').find("a").attr('target', '_blank');
$('.course_sub_menu').find("a").attr('target', '_blank');
});
diff --git a/public/javascripts/header.js b/public/javascripts/header.js
index e27f758d3..06748d726 100644
--- a/public/javascripts/header.js
+++ b/public/javascripts/header.js
@@ -1,11 +1,15 @@
function addSlipMenu () {
- var loggedas = $('#current_user_li:first');
+ var loggedas = $('#current_user_li a:first');
var sub_menu = $('#user_sub_menu');
- loggedas.mouseenter(function(event) {
+ loggedas.mouseenter(function() {
sub_menu.show();
+ $('#my_projects_ul').hide();
+ $('#my_courses_ul').hide();
});
- sub_menu.mouseleave(function(event) {
+ sub_menu.mouseleave(function() {
sub_menu.hide();
+ $('#my_projects_ul').hide();
+ $('#my_courses_ul').hide();
});
}
@@ -13,24 +17,26 @@ function addProjectSlipMenu () {
var loggedas = $('#my_projects_li');
var project_sub_menu = $('#my_projects_ul');
var course_sub_menu = $('#my_courses_ul');
- loggedas.mouseenter(function(event) {
+ loggedas.mouseenter(function() {
course_sub_menu.hide();
project_sub_menu.show();
});
- loggedas.mouseleave(function(event) {
+ loggedas.mouseleave(function() {
project_sub_menu.hide();
+ course_sub_menu.hide();
});
}
function addCourseSlipMenu () {
var loggedas = $('#my_courses_li');
var project_sub_menu = $('#my_projects_ul');
var course_sub_menu = $('#my_courses_ul');
- loggedas.mouseenter(function(event) {
+ loggedas.mouseenter(function() {
project_sub_menu.hide();
course_sub_menu.show();
});
- loggedas.mouseleave(function(event) {
+ loggedas.mouseleave(function() {
course_sub_menu.hide();
+ project_sub_menu.hide();
});
}
From 17e61020057a2f2f54e8edd684c993e8d9d0effa Mon Sep 17 00:00:00 2001
From: sw <939547590@qq.com>
Date: Thu, 16 Jul 2015 14:26:43 +0800
Subject: [PATCH 39/55] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=9B=9E=E8=B0=83?=
=?UTF-8?q?=E5=87=BD=E6=95=B0?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/controllers/student_work_controller.rb | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/app/controllers/student_work_controller.rb b/app/controllers/student_work_controller.rb
index d4a1bd4e5..0168e1057 100644
--- a/app/controllers/student_work_controller.rb
+++ b/app/controllers/student_work_controller.rb
@@ -124,7 +124,7 @@ class StudentWorkController < ApplicationController
url = "http://test.gitlab.trustie.net/api/questions/#{@homework.homework_detail_programing.question_id}/solutions.json"
uri = URI(url)
solutions = {
- id:stundet_work.id,
+ stundet_work_id:stundet_work.id,
src:stundet_work.description,
language:1
}
@@ -372,9 +372,15 @@ class StudentWorkController < ApplicationController
#设置编程作业得分
def set_program_score
- stundet_work = StudentWork.find_by_id params[:id]
- if stundet_work
- stundet_work.update_column("student_score",params[:status] == 0 ? 100 : 0)
+ stundet_work = StudentWork.find_by_id params[:student_work_id]
+ if stundet_work && params[:result] && params[:results].class.to_s == "Array"
+ homework_common = stundet_work.homework_common
+ params[:results].each do |result|
+ homework_test = homework_common.homework_tests.where("input = #{result[:input]} AND output = #{result[:output]}").first
+ if homework_test
+ StudentWorkTest.create(:student_work_id => stundet_work.id,:homework_test_id => homework_test.id,:result => result[:status])
+ end
+ end
end
end
From 0fc3e0077a5120ab2d06bb99bef64174322fde2b Mon Sep 17 00:00:00 2001
From: sw <939547590@qq.com>
Date: Thu, 16 Jul 2015 16:15:47 +0800
Subject: [PATCH 40/55] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=B0=83=E7=94=A8?=
=?UTF-8?q?=E7=BC=96=E7=A8=8B=E7=9A=84=E6=8E=A5=E5=8F=A3?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/controllers/homework_common_controller.rb | 19 +++++++++++++++++--
app/controllers/student_work_controller.rb | 10 ++++++++--
2 files changed, 25 insertions(+), 4 deletions(-)
diff --git a/app/controllers/homework_common_controller.rb b/app/controllers/homework_common_controller.rb
index a8ccf2b9a..698f29c56 100644
--- a/app/controllers/homework_common_controller.rb
+++ b/app/controllers/homework_common_controller.rb
@@ -1,5 +1,6 @@
class HomeworkCommonController < ApplicationController
require 'net/http'
+ require 'json'
layout "base_courses"
before_filter :find_course, :only => [:index,:new,:create,:next_step]
before_filter :find_homework, :only => [:edit,:update,:alert_anonymous_comment,:start_anonymous_comment,:stop_anonymous_comment,:destroy]
@@ -74,7 +75,6 @@ class HomeworkCommonController < ApplicationController
homework_detail_programing.standard_code = params[:standard_code]
question = {title:homework.name,content:homework.description}
- uri = URI('http://test.gitlab.trustie.net/api/questions.json')
question[:input] = []
question[:output] = []
if params[:input] && params[:output]
@@ -89,7 +89,22 @@ class HomeworkCommonController < ApplicationController
end
end
end
- res = Net::HTTP.post_form(uri, question)
+
+ # uri = URI('http://test.gitlab.trustie.net/api/questions.json')
+ # req = Net::HTTP::Post.new(uri, initheader = {'Content-Type' =>'application/json'})
+ # req.body = question.to_json
+ # res = Net::HTTP.start(uri.hostname, uri.port) do |http|
+ # http.request(req)
+ # end
+
+ uri = URI('http://test.gitlab.trustie.net/api/questions.json')
+ body = question.to_json
+ res = Net::HTTP.new(uri.host, uri.port).start do |client|
+ request = Net::HTTP::Post.new(uri.path)
+ request.body = body
+ request["Content-Type"] = "application/json"
+ client.request(request)
+ end
result = JSON.parse(res.body)
homework_detail_programing.question_id = result["id"] if result["status"] && result["status"] == 0
diff --git a/app/controllers/student_work_controller.rb b/app/controllers/student_work_controller.rb
index 0168e1057..2d8403fa2 100644
--- a/app/controllers/student_work_controller.rb
+++ b/app/controllers/student_work_controller.rb
@@ -122,13 +122,19 @@ class StudentWorkController < ApplicationController
if stundet_work.save
if @homework.homework_type == 2 && @homework.homework_detail_programing #编程作业,学生提交作品后计算系统得分
url = "http://test.gitlab.trustie.net/api/questions/#{@homework.homework_detail_programing.question_id}/solutions.json"
- uri = URI(url)
solutions = {
stundet_work_id:stundet_work.id,
src:stundet_work.description,
language:1
}
- Net::HTTP.post_form(uri, solutions)
+ uri = URI(url)
+ body = solutions.to_json
+ res = Net::HTTP.new(uri.host, uri.port).start do |client|
+ request = Net::HTTP::Post.new(uri.path)
+ request.body = body
+ request["Content-Type"] = "application/json"
+ client.request(request)
+ end
end
respond_to do |format|
format.html {
From 93905f2f325bec101e5f1b46928e3730da20349e Mon Sep 17 00:00:00 2001
From: sw <939547590@qq.com>
Date: Thu, 16 Jul 2015 17:33:15 +0800
Subject: [PATCH 41/55] =?UTF-8?q?=E7=95=8C=E9=9D=A2=E6=98=BE=E7=A4=BA?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/models/student_work_test.rb | 36 +++++++++++++++++++
.../_programing_work_show.html.erb | 18 ++++++++--
2 files changed, 52 insertions(+), 2 deletions(-)
diff --git a/app/models/student_work_test.rb b/app/models/student_work_test.rb
index b9264191c..d9ac5e935 100644
--- a/app/models/student_work_test.rb
+++ b/app/models/student_work_test.rb
@@ -1,6 +1,42 @@
+# encoding: utf-8
class StudentWorkTest < ActiveRecord::Base
attr_accessible :student_work_id, :homework_test_id
belongs_to :homework_test
belongs_to :student_work
+
+ def status_to_s
+ case self.result
+ when -1
+ '编译出错'
+ when -2
+ '答题错误'
+ when -3
+ '答案错误'
+ when 1
+ '运行出错'
+ when 2
+ '超时'
+ when 3
+ '内存超出'
+ when 4
+ '输出超出'
+ when 5
+ '禁用函数'
+ when 6
+ '其他错误'
+ when 0
+ '成功'
+ else
+ '未知错误'
+ end
+ end
+
+ def test_score
+ if self.result == 0
+ format("%.1f",100.0 / self.student_work.homework_common.homework_tests.count)
+ else
+ 0
+ end
+ end
end
diff --git a/app/views/student_work/_programing_work_show.html.erb b/app/views/student_work/_programing_work_show.html.erb
index 80284dac0..2711ad172 100644
--- a/app/views/student_work/_programing_work_show.html.erb
+++ b/app/views/student_work/_programing_work_show.html.erb
@@ -26,6 +26,19 @@
测试结果:
+
+
+
+
+
+
+
+
+
+
+
+
+
<%@homework.homework_tests.each do |test|%>
">
@@ -34,10 +47,11 @@
<%= test.output%>
- 错误
- 0
+ <%= test.student_work_test.nil? ? "正在编译队列中" : test.student_work_test.status_to_s%>
+ <%= test.student_work_test.nil? ? "0" : test.student_work_test.test_score%>
<% end%>
+
From 8a9fd7d4c09dc5e5102b876e116eab1cb7912663 Mon Sep 17 00:00:00 2001
From: sw <939547590@qq.com>
Date: Thu, 16 Jul 2015 17:34:13 +0800
Subject: [PATCH 42/55] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=BB=93=E6=9E=9C?=
=?UTF-8?q?=E6=98=BE=E7=A4=BA?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/views/student_work/_programing_work_show.html.erb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/views/student_work/_programing_work_show.html.erb b/app/views/student_work/_programing_work_show.html.erb
index 2711ad172..e73fdb1bb 100644
--- a/app/views/student_work/_programing_work_show.html.erb
+++ b/app/views/student_work/_programing_work_show.html.erb
@@ -47,7 +47,7 @@
<%= test.output%>
- <%= test.student_work_test.nil? ? "正在编译队列中" : test.student_work_test.status_to_s%>
+ <%= test.student_work_test.nil? ? "正在编译" : test.student_work_test.status_to_s%>
<%= test.student_work_test.nil? ? "0" : test.student_work_test.test_score%>
<% end%>
From 421b377785a98afb8ae3ed33986f5079afc5ebf6 Mon Sep 17 00:00:00 2001
From: sw <939547590@qq.com>
Date: Thu, 16 Jul 2015 17:54:42 +0800
Subject: [PATCH 43/55] =?UTF-8?q?=E5=B1=80=E5=9F=9F=E7=BD=91=E4=B8=8D?=
=?UTF-8?q?=E5=8F=AF=E4=BB=A5=E4=BD=BF=E7=94=A8=E5=9F=9F=E5=90=8D?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/controllers/homework_common_controller.rb | 2 +-
app/controllers/student_work_controller.rb | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/app/controllers/homework_common_controller.rb b/app/controllers/homework_common_controller.rb
index 698f29c56..8b37ca8e4 100644
--- a/app/controllers/homework_common_controller.rb
+++ b/app/controllers/homework_common_controller.rb
@@ -97,7 +97,7 @@ class HomeworkCommonController < ApplicationController
# http.request(req)
# end
- uri = URI('http://test.gitlab.trustie.net/api/questions.json')
+ uri = URI('http://192.168.80.21:8080/api/questions.json')
body = question.to_json
res = Net::HTTP.new(uri.host, uri.port).start do |client|
request = Net::HTTP::Post.new(uri.path)
diff --git a/app/controllers/student_work_controller.rb b/app/controllers/student_work_controller.rb
index 2d8403fa2..5b6de453e 100644
--- a/app/controllers/student_work_controller.rb
+++ b/app/controllers/student_work_controller.rb
@@ -121,7 +121,7 @@ class StudentWorkController < ApplicationController
if stundet_work.save
if @homework.homework_type == 2 && @homework.homework_detail_programing #编程作业,学生提交作品后计算系统得分
- url = "http://test.gitlab.trustie.net/api/questions/#{@homework.homework_detail_programing.question_id}/solutions.json"
+ url = "http://192.168.80.21:8080/api/questions/#{@homework.homework_detail_programing.question_id}/solutions.json"
solutions = {
stundet_work_id:stundet_work.id,
src:stundet_work.description,
From f9cf47804a37daaea73394a06c5e51142696c855 Mon Sep 17 00:00:00 2001
From: sw <939547590@qq.com>
Date: Thu, 16 Jul 2015 18:13:43 +0800
Subject: [PATCH 44/55] =?UTF-8?q?x=E5=AD=A6=E7=94=9F=E4=BD=9C=E5=93=81?=
=?UTF-8?q?=E4=BB=A3=E7=A0=81=E5=85=88=20base64=E7=BC=96=E7=A0=81=E5=9C=A8?=
=?UTF-8?q?=E4=BC=A0=E9=80=92?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/controllers/student_work_controller.rb | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/app/controllers/student_work_controller.rb b/app/controllers/student_work_controller.rb
index 5b6de453e..1d40415c8 100644
--- a/app/controllers/student_work_controller.rb
+++ b/app/controllers/student_work_controller.rb
@@ -2,6 +2,7 @@ class StudentWorkController < ApplicationController
layout "base_courses"
include StudentWorkHelper
require 'bigdecimal'
+ require "base64"
before_filter :find_homework, :only => [:new, :index, :create, :student_work_absence_penalty, :absence_penalty_list, :evaluation_list]
before_filter :find_work, :only => [:edit, :update, :show, :destroy, :add_score, :praise_student_work]
before_filter :member_of_course, :only => [:index, :new, :create, :show, :add_score, :praise_student_work]
@@ -124,7 +125,7 @@ class StudentWorkController < ApplicationController
url = "http://192.168.80.21:8080/api/questions/#{@homework.homework_detail_programing.question_id}/solutions.json"
solutions = {
stundet_work_id:stundet_work.id,
- src:stundet_work.description,
+ src:Base64.encode64(stundet_work.description),
language:1
}
uri = URI(url)
From 0718a2838237aa93d6937fac4cd2023b3e6c770e Mon Sep 17 00:00:00 2001
From: sw <939547590@qq.com>
Date: Fri, 17 Jul 2015 14:17:42 +0800
Subject: [PATCH 45/55] =?UTF-8?q?=E5=A2=9E=E5=8A=A0gem?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
Gemfile | 1 +
1 file changed, 1 insertion(+)
diff --git a/Gemfile b/Gemfile
index 660a7ff49..2b43cade3 100644
--- a/Gemfile
+++ b/Gemfile
@@ -26,6 +26,7 @@ gem 'spreadsheet'
gem 'ruby-ole'
gem 'rails_kindeditor',path:'lib/rails_kindeditor'
#gem "rmagick", ">= 2.0.0"
+gem 'binding_of_caller'
group :development do
gem 'grape-swagger'
From 666539a4cc89212492d486ad8ae03f16c4bda91d Mon Sep 17 00:00:00 2001
From: sw <939547590@qq.com>
Date: Fri, 17 Jul 2015 14:35:27 +0800
Subject: [PATCH 46/55] =?UTF-8?q?=E5=8F=82=E6=95=B0=E5=90=8D=E9=94=99?=
=?UTF-8?q?=E8=AF=AF?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/controllers/student_work_controller.rb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/controllers/student_work_controller.rb b/app/controllers/student_work_controller.rb
index 1d40415c8..78c12c382 100644
--- a/app/controllers/student_work_controller.rb
+++ b/app/controllers/student_work_controller.rb
@@ -124,7 +124,7 @@ class StudentWorkController < ApplicationController
if @homework.homework_type == 2 && @homework.homework_detail_programing #编程作业,学生提交作品后计算系统得分
url = "http://192.168.80.21:8080/api/questions/#{@homework.homework_detail_programing.question_id}/solutions.json"
solutions = {
- stundet_work_id:stundet_work.id,
+ student_work_id:stundet_work.id,
src:Base64.encode64(stundet_work.description),
language:1
}
From 1f6ed64e540e96850d945e9ce8c76e62dd5fc89a Mon Sep 17 00:00:00 2001
From: sw <939547590@qq.com>
Date: Fri, 17 Jul 2015 14:48:20 +0800
Subject: [PATCH 47/55] =?UTF-8?q?=E5=88=A0=E9=99=A4=E4=BD=9C=E5=93=81?=
=?UTF-8?q?=E6=97=B6=EF=BC=8C=E5=88=A0=E9=99=A4=E4=BD=9C=E5=93=81=E7=9A=84?=
=?UTF-8?q?=E7=82=B9=E8=B5=9E=E6=95=B0?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/models/student_work.rb | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/app/models/student_work.rb b/app/models/student_work.rb
index 0db36b4ba..c80d1315b 100644
--- a/app/models/student_work.rb
+++ b/app/models/student_work.rb
@@ -9,5 +9,11 @@ class StudentWork < ActiveRecord::Base
belongs_to :project
has_one :student_work_test
+ before_destroy :delete_praise
+
acts_as_attachable
+
+ def delete_praise
+ PraiseTread.where("praise_tread_object_id = #{self.id} AND praise_tread_object_type = 'StudentWork'").destroy_all
+ end
end
From fa2dfd06923de6ee37566ff67fb02d3e0eade64e Mon Sep 17 00:00:00 2001
From: sw <939547590@qq.com>
Date: Fri, 17 Jul 2015 14:53:07 +0800
Subject: [PATCH 48/55] =?UTF-8?q?=E4=BD=9C=E5=93=81=E5=BE=97=E5=88=86?=
=?UTF-8?q?=E5=BC=B9=E5=87=BA=E6=A1=86=EF=BC=8C=E4=BD=9C=E4=B8=9A=E5=90=8D?=
=?UTF-8?q?=E8=BF=87=E9=95=BF=E6=98=BE=E7=A4=BA=E9=97=AE=E9=A2=98?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/views/courses/_show_member_score.html.erb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/views/courses/_show_member_score.html.erb b/app/views/courses/_show_member_score.html.erb
index bdc1fa147..2d08e853e 100644
--- a/app/views/courses/_show_member_score.html.erb
+++ b/app/views/courses/_show_member_score.html.erb
@@ -19,7 +19,7 @@
作业名称 得分
<% @member_score.homework_common_list.each do |homework_common| %>
-
+
<%= homework_common.name %>
From c18481e89cf1cc684215f537b12ee077afb6d8d8 Mon Sep 17 00:00:00 2001
From: sw <939547590@qq.com>
Date: Fri, 17 Jul 2015 15:31:49 +0800
Subject: [PATCH 49/55] =?UTF-8?q?=E5=9B=9E=E8=B0=83=E5=87=BD=E6=95=B0?=
=?UTF-8?q?=E9=A1=B5=E9=9D=A2=E8=BF=94=E5=9B=9E=20=E5=9B=9E=E8=B0=83?=
=?UTF-8?q?=E5=87=BD=E6=95=B0=E4=B8=8D=E8=83=BD=E5=AD=98=E5=82=A8=E7=BB=93?=
=?UTF-8?q?=E6=9E=9C?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/controllers/student_work_controller.rb | 11 ++++++++---
app/views/student_work/set_program_score.html.erb | 1 +
2 files changed, 9 insertions(+), 3 deletions(-)
create mode 100644 app/views/student_work/set_program_score.html.erb
diff --git a/app/controllers/student_work_controller.rb b/app/controllers/student_work_controller.rb
index 78c12c382..71ccee592 100644
--- a/app/controllers/student_work_controller.rb
+++ b/app/controllers/student_work_controller.rb
@@ -380,12 +380,17 @@ class StudentWorkController < ApplicationController
#设置编程作业得分
def set_program_score
stundet_work = StudentWork.find_by_id params[:student_work_id]
- if stundet_work && params[:result] && params[:results].class.to_s == "Array"
+ @course = stundet_work.homework_common.course
+ if stundet_work && params[:results] && params[:results].class.to_s == "Array"
homework_common = stundet_work.homework_common
params[:results].each do |result|
- homework_test = homework_common.homework_tests.where("input = #{result[:input]} AND output = #{result[:output]}").first
+ homework_test = homework_common.homework_tests.where("input = '#{result[:input]}' AND output = '#{result[:output]}'").first
if homework_test
- StudentWorkTest.create(:student_work_id => stundet_work.id,:homework_test_id => homework_test.id,:result => result[:status])
+ student_work_test = StudentWorkTest.new
+ student_work_test.student_work = stundet_work
+ student_work_test.homework_test = homework_test
+ student_work_test.result = result[:status]
+ student_work_test.save
end
end
end
diff --git a/app/views/student_work/set_program_score.html.erb b/app/views/student_work/set_program_score.html.erb
new file mode 100644
index 000000000..6ea169c64
--- /dev/null
+++ b/app/views/student_work/set_program_score.html.erb
@@ -0,0 +1 @@
+成功
\ No newline at end of file
From eae8e71561cddf402601e16e6da14153fdd47538 Mon Sep 17 00:00:00 2001
From: sw <939547590@qq.com>
Date: Fri, 17 Jul 2015 15:49:58 +0800
Subject: [PATCH 50/55] save--->save!
---
app/controllers/student_work_controller.rb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/controllers/student_work_controller.rb b/app/controllers/student_work_controller.rb
index 71ccee592..4e97c373c 100644
--- a/app/controllers/student_work_controller.rb
+++ b/app/controllers/student_work_controller.rb
@@ -390,7 +390,7 @@ class StudentWorkController < ApplicationController
student_work_test.student_work = stundet_work
student_work_test.homework_test = homework_test
student_work_test.result = result[:status]
- student_work_test.save
+ student_work_test.save!
end
end
end
From 26843c311fc70d2b4ffc520986f54bf21b08beba Mon Sep 17 00:00:00 2001
From: sw <939547590@qq.com>
Date: Fri, 17 Jul 2015 15:53:28 +0800
Subject: [PATCH 51/55] =?UTF-8?q?=E7=BC=96=E8=AF=91=E7=BB=93=E6=9E=9C?=
=?UTF-8?q?=E8=B7=A8=E5=9F=9F=E5=AD=98=E5=82=A8?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/controllers/student_work_controller.rb | 1 +
1 file changed, 1 insertion(+)
diff --git a/app/controllers/student_work_controller.rb b/app/controllers/student_work_controller.rb
index 4e97c373c..c76bbd7b6 100644
--- a/app/controllers/student_work_controller.rb
+++ b/app/controllers/student_work_controller.rb
@@ -8,6 +8,7 @@ class StudentWorkController < ApplicationController
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]
+ protect_from_forgery :except => :set_program_score
def index
@order,@b_sort,@name,@group = params[:order] || "score",params[:sort] || "desc",params[:name] || "",params[:group]
From 59b2f247c5667c2a031320f2430cd67e95dc82fe Mon Sep 17 00:00:00 2001
From: sw <939547590@qq.com>
Date: Fri, 17 Jul 2015 16:12:29 +0800
Subject: [PATCH 52/55] =?UTF-8?q?=E7=B3=BB=E7=BB=9F=E8=AF=84=E5=88=86?=
=?UTF-8?q?=E5=90=8E=E8=8E=B7=E5=8F=96=E5=BE=97=E5=88=86=E8=B5=8B=E5=80=BC?=
=?UTF-8?q?=E5=88=B0=E7=B3=BB=E7=BB=9F=E8=AF=84=E5=88=86=E5=AD=97=E6=AE=B5?=
=?UTF-8?q?=EF=BC=8C=E5=B9=B6=E8=AE=A1=E7=AE=97=E6=9C=80=E7=BB=88=E5=BE=97?=
=?UTF-8?q?=E5=88=86?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/controllers/student_work_controller.rb | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/app/controllers/student_work_controller.rb b/app/controllers/student_work_controller.rb
index c76bbd7b6..20cdc6659 100644
--- a/app/controllers/student_work_controller.rb
+++ b/app/controllers/student_work_controller.rb
@@ -382,6 +382,7 @@ class StudentWorkController < ApplicationController
def set_program_score
stundet_work = StudentWork.find_by_id params[:student_work_id]
@course = stundet_work.homework_common.course
+ student_score_count = 0
if stundet_work && params[:results] && params[:results].class.to_s == "Array"
homework_common = stundet_work.homework_common
params[:results].each do |result|
@@ -391,9 +392,28 @@ class StudentWorkController < ApplicationController
student_work_test.student_work = stundet_work
student_work_test.homework_test = homework_test
student_work_test.result = result[:status]
+ if student_work_test.result == 0
+ student_score_count += 1
+ end
student_work_test.save!
end
end
+ unless homework_common.homework_tests.empty?
+ stundet_work.student_score = student_score_count * 100.0 / homework_common.homework_tests.count
+
+ if stundet_work.teacher_score.nil?
+ if stundet_work.teaching_asistant_score.nil?
+ stundet_work.final_score = stundet_work.student_score
+ else
+ final_ta_score = BigDecimal.new("#{stundet_work.teaching_asistant_score}") * BigDecimal.new("#{homework_common.homework_detail_programing.ta_proportion}")
+ final_s_score = BigDecimal.new("#{stundet_work.student_score}") * (BigDecimal.new('1.0') - BigDecimal.new("#{homework_common.homework_detail_programing.ta_proportion}"))
+ final_score = final_ta_score + final_s_score
+ stundet_work.final_score = format("%.1f",final_score.to_f)
+ end
+ end
+
+ stundet_work.save!
+ end
end
end
From 5799d08a0d986556406c65b420470a30f5db2779 Mon Sep 17 00:00:00 2001
From: sw <939547590@qq.com>
Date: Fri, 17 Jul 2015 16:17:38 +0800
Subject: [PATCH 53/55] =?UTF-8?q?1=E3=80=81=E8=80=81=E5=B8=88=E8=AF=84?=
=?UTF-8?q?=E7=BC=96=E7=A8=8B=E4=BD=9C=E4=B8=9A=E5=BE=97=E5=88=86=E5=90=8E?=
=?UTF-8?q?=E6=98=BE=E7=A4=BA=E9=94=99=E8=AF=AF=202=E3=80=81=E7=BC=96?=
=?UTF-8?q?=E7=A8=8B=E4=BD=9C=E4=B8=9A=E7=B3=BB=E7=BB=9F=E5=BE=97=E5=88=86?=
=?UTF-8?q?=E4=B8=8D=E7=8E=B0=E5=AE=9E=E5=90=8E=E9=9D=A2=E6=8B=AC=E5=8F=B7?=
=?UTF-8?q?=E5=92=8C=E7=9B=B8=E5=85=B3=E6=8F=90=E7=A4=BA=E4=BF=A1=E6=81=AF?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../_evaluation_student_work.html.erb | 2 +-
app/views/student_work/add_score.js.erb | 19 +++++++++++--------
2 files changed, 12 insertions(+), 9 deletions(-)
diff --git a/app/views/student_work/_evaluation_student_work.html.erb b/app/views/student_work/_evaluation_student_work.html.erb
index b83917481..b5bdd6f55 100644
--- a/app/views/student_work/_evaluation_student_work.html.erb
+++ b/app/views/student_work/_evaluation_student_work.html.erb
@@ -26,7 +26,7 @@
<%= student_work.student_score.nil? ? "--" : format("%.1f",student_work.student_score)%>
- <% unless student_work.student_score.nil?%>
+ <% unless student_work.student_score.nil? || student_work.homework_common.homework_type == 2%>
(<%= student_work.student_works_scores.where(:reviewer_role => 3).count%>)
diff --git a/app/views/student_work/add_score.js.erb b/app/views/student_work/add_score.js.erb
index 9298de8fc..1de92b51a 100644
--- a/app/views/student_work/add_score.js.erb
+++ b/app/views/student_work/add_score.js.erb
@@ -2,20 +2,23 @@ $("#add_student_score_<%= @work.id%>").html("<%= escape_javascript(render :parti
$('#score_<%= @work.id%>').peSlider({range: 'min'});
<% if @is_new%>
-$("#score_list_<%= @work.id%>").prepend("<%= escape_javascript(render :partial => 'student_work_score', :locals => {:score => @score}) %>
");
+ $("#score_list_<%= @work.id%>").prepend("<%= escape_javascript(render :partial => 'student_work_score', :locals => {:score => @score}) %>
");
<% else %>
-$("#work_score_<%= @score.id%>").html("<%= escape_javascript(render :partial => 'student_work_score', :locals => {:score => @score}) %>");
+ $("#work_score_<%= @score.id%>").html("<%= escape_javascript(render :partial => 'student_work_score', :locals => {:score => @score}) %>");
<% end%>
+
$("#score_list_<%= @work.id%>").removeAttr("style");
<% if @is_teacher %>
-<% if @homework.homework_type == 1%>
-$("#student_work_<%= @work.id%>").replaceWith("<%= escape_javascript(render :partial => 'evaluation_student_work',:locals => {:student_work => @work}) %>");
-<% else%>
-$("#student_work_<%= @work.id%>").replaceWith("<%= escape_javascript(render :partial => 'student_work',:locals => {:student_work => @work}) %>");
-<% end%>
+ <% if @homework.homework_type == 1%>
+ $("#student_work_<%= @work.id%>").replaceWith("<%= escape_javascript(render :partial => 'evaluation_student_work',:locals => {:student_work => @work}) %>");
+ <% elsif @homework.homework_type == 2%>
+ $("#student_work_<%= @work.id%>").replaceWith("<%= escape_javascript(render :partial => 'evaluation_student_work',:locals => {:student_work => @work}) %>");
+ <% else%>
+ $("#student_work_<%= @work.id%>").replaceWith("<%= escape_javascript(render :partial => 'student_work',:locals => {:student_work => @work}) %>");
+ <% end%>
<% else %>
-$("#student_work_<%= @work.id%>").replaceWith("<%= escape_javascript(render :partial => 'evaluation_work',:locals => {:student_work => @work}) %>");
+ $("#student_work_<%= @work.id%>").replaceWith("<%= escape_javascript(render :partial => 'evaluation_work',:locals => {:student_work => @work}) %>");
<% end%>
From 159d8f644e869ecc1be1a1a2bd55043d67904f96 Mon Sep 17 00:00:00 2001
From: sw <939547590@qq.com>
Date: Fri, 17 Jul 2015 16:22:00 +0800
Subject: [PATCH 54/55] =?UTF-8?q?=E7=BC=96=E7=A8=8B=E4=BD=9C=E4=B8=9A?=
=?UTF-8?q?=E4=B8=8D=E5=8F=AF=E4=BF=AE=E6=94=B9=E4=BD=9C=E5=93=81=EF=BC=8C?=
=?UTF-8?q?=E7=95=8C=E9=9D=A2=E6=98=BE=E7=A4=BA?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/helpers/application_helper.rb | 2 ++
1 file changed, 2 insertions(+)
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index c4762e8cc..64d8ce142 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -2307,6 +2307,8 @@ module ApplicationHelper
else
if homework.homework_type == 1 && homework.homework_detail_manual && homework.homework_detail_manual.comment_status != 1 #匿评作业,且作业状态不是在开启匿评之前
"#{l(:label_edit_homework)} ".html_safe
+ elsif homework.homework_type == 2 #编程作业不能修改作品
+ "作品已交 ".html_safe
else
link_to l(:label_edit_homework), edit_student_work_path(work.id),:class => 'fr mr10 work_edit'
end
From b981c4d07b113e73a3ba83635d3b3d28a6807597 Mon Sep 17 00:00:00 2001
From: sw <939547590@qq.com>
Date: Fri, 17 Jul 2015 17:30:48 +0800
Subject: [PATCH 55/55] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=96=B9=E6=B3=95?=
=?UTF-8?q?=E5=88=A4=E6=96=AD=EF=BC=9A=E5=B0=86/n=E8=BD=AC=E8=BF=98?=
=?UTF-8?q?=E6=88=90 ?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/helpers/application_helper.rb | 4 ++++
app/views/student_work/_programing_work_show.html.erb | 2 +-
app/views/student_work/_show.html.erb | 2 +-
3 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index 64d8ce142..47a3b59ae 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -2343,4 +2343,8 @@ module ApplicationHelper
end
end
+ #将文本内的/n转换为
+ def text_format text
+ text.gsub("\n"," ").html_safe
+ end
end
diff --git a/app/views/student_work/_programing_work_show.html.erb b/app/views/student_work/_programing_work_show.html.erb
index e73fdb1bb..8060b8a79 100644
--- a/app/views/student_work/_programing_work_show.html.erb
+++ b/app/views/student_work/_programing_work_show.html.erb
@@ -19,7 +19,7 @@
编程代码:
- <%= textilizable @work.description%>
+ <%= text_format @work.description%>
diff --git a/app/views/student_work/_show.html.erb b/app/views/student_work/_show.html.erb
index dfe61d3db..2b7d49402 100644
--- a/app/views/student_work/_show.html.erb
+++ b/app/views/student_work/_show.html.erb
@@ -36,7 +36,7 @@
内容:
- <%= textilizable @work.description%>
+ <%= text_format @work.description%>