+<% end%>
\ No newline at end of file
diff --git a/app/views/exercise/_exercises_list.html.erb b/app/views/exercise/_exercises_list.html.erb
new file mode 100644
index 000000000..16fa24b0e
--- /dev/null
+++ b/app/views/exercise/_exercises_list.html.erb
@@ -0,0 +1,25 @@
+
\ No newline at end of file
diff --git a/app/views/exercise/index.html.erb b/app/views/exercise/index.html.erb
index 52cfcc97f..1a8d15181 100644
--- a/app/views/exercise/index.html.erb
+++ b/app/views/exercise/index.html.erb
@@ -1 +1,4 @@
-111111111111
\ No newline at end of file
+<%= stylesheet_link_tag 'polls', :media => 'all' %>
+
+ <%= render :partial => 'exercises_list'%>
+
\ No newline at end of file
diff --git a/config/routes.rb b/config/routes.rb
index 9c557c9a5..f1c41f65f 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -99,6 +99,8 @@ RedmineApp::Application.routes.draw do
#show、index、new、create、edit、update、destroy路由自动生成
resources :exercise do
member do #生成路径为 /exercise/:id/方法名
+ get 'statistics_result'
+ get 'export_exercise'
end
collection do #生成路径为 /exercise/方法名
From ee8d9d7b4ecef7c35dc6efb9270642c66177fc5a Mon Sep 17 00:00:00 2001
From: cxt
Date: Fri, 13 Nov 2015 17:47:29 +0800
Subject: [PATCH 06/83] =?UTF-8?q?=E6=8F=90=E4=BA=A4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
db/schema.rb | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/db/schema.rb b/db/schema.rb
index 418382a64..19bd05677 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -575,7 +575,7 @@ ActiveRecord::Schema.define(:version => 20151113025751) do
create_table "exercise_answers", :force => true do |t|
t.integer "user_id"
t.integer "exercise_question_id"
- t.integer "exercise_choices_id"
+ t.integer "exercise_choice_id"
t.text "answer_text"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
@@ -600,7 +600,7 @@ ActiveRecord::Schema.define(:version => 20151113025751) do
create_table "exercise_standard_answers", :force => true do |t|
t.integer "exercise_question_id"
- t.integer "exercise_choices_id"
+ t.integer "exercise_choice_id"
t.text "answer_text"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
From 5400b907e6a491cea534d9e7575c6a29e423f3e9 Mon Sep 17 00:00:00 2001
From: cxt
Date: Tue, 17 Nov 2015 09:33:40 +0800
Subject: [PATCH 07/83] =?UTF-8?q?=E5=AD=A6=E7=94=9F=E6=B5=8B=E9=AA=8C?=
=?UTF-8?q?=E5=88=97=E8=A1=A8?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/controllers/exercise_controller.rb | 19 ++-
app/views/exercise/_exercise.html.erb | 2 +-
app/views/exercise/_student_exercise.html.erb | 46 ++++++
.../exercise/student_exercise_list.html.erb | 138 ++++++++++++++++++
config/routes.rb | 1 +
...4_add_publish_time_end_time_to_exercise.rb | 6 +
db/schema.rb | 4 +-
7 files changed, 213 insertions(+), 3 deletions(-)
create mode 100644 app/views/exercise/_student_exercise.html.erb
create mode 100644 app/views/exercise/student_exercise_list.html.erb
create mode 100644 db/migrate/20151116065904_add_publish_time_end_time_to_exercise.rb
diff --git a/app/controllers/exercise_controller.rb b/app/controllers/exercise_controller.rb
index bed3d9061..296c744b6 100644
--- a/app/controllers/exercise_controller.rb
+++ b/app/controllers/exercise_controller.rb
@@ -1,7 +1,7 @@
class ExerciseController < ApplicationController
layout "base_courses"
- before_filter :find_course, :only => [:index,:new,:create]
+ before_filter :find_course, :only => [:index,:new,:create,:student_exercise_list]
def index
@is_teacher = User.current.allowed_to?(:as_teacher,@course)
if @is_teacher
@@ -44,6 +44,23 @@ class ExerciseController < ApplicationController
end
+ def student_exercise_list
+ @is_teacher = User.current.allowed_to?(:as_teacher,@course) || User.current.admin?
+ @exercise = Exercise.find params[:id]
+ @all_exercises = @course.exercises.order("created_at desc")
+ @exercise_count = @exercise.exercise_users.where('score is not NULL').count
+ if @is_teacher || (!@exercise.exercise_users.where(:user_id => User.current.id).empty? && Time.parse(@exercise.end_time.to_s).strftime("%Y-%m-%d-%H-%M-%S") <= Time.now.strftime("%Y-%m-%d-%H-%M-%S"))
+ @exercise_users_list = @exercise.exercise_users.where('score is not NULL')
+ elsif !@exercise.exercise_users.where(:user_id => User.current.id).empty? && Time.parse(@exercise.end_time.to_s).strftime("%Y-%m-%d-%H-%M-%S") > Time.now.strftime("%Y-%m-%d-%H-%M-%S")
+ @exercise_users_list = @exercise.exercise_users.where("user_id = ? and score is not NULL",User.current.id)
+ else
+ @exercise_users_list = []
+ end
+ respond_to do |format|
+ format.html
+ end
+ end
+
private
def find_course
@course = Course.find params[:course_id]
diff --git a/app/views/exercise/_exercise.html.erb b/app/views/exercise/_exercise.html.erb
index e469c471c..15a684a62 100644
--- a/app/views/exercise/_exercise.html.erb
+++ b/app/views/exercise/_exercise.html.erb
@@ -15,7 +15,7 @@
<% if exercise.exercise_status == 1%>
\ No newline at end of file
diff --git a/app/views/exercise/_exercise_content.html.erb b/app/views/exercise/_exercise_content.html.erb
new file mode 100644
index 000000000..76bad6a83
--- /dev/null
+++ b/app/views/exercise/_exercise_content.html.erb
@@ -0,0 +1,23 @@
+
+<% poll.exercise_questions.each do |poll_question|%>
+
diff --git a/app/views/exercise/_new_MC.html.erb b/app/views/exercise/_new_MC.html.erb
new file mode 100644
index 000000000..0ff662b3f
--- /dev/null
+++ b/app/views/exercise/_new_MC.html.erb
@@ -0,0 +1,38 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/views/exercise/_new_MCQ.html.erb b/app/views/exercise/_new_MCQ.html.erb
new file mode 100644
index 000000000..0ba2a0133
--- /dev/null
+++ b/app/views/exercise/_new_MCQ.html.erb
@@ -0,0 +1,39 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/views/exercise/_new_single.html.erb b/app/views/exercise/_new_single.html.erb
new file mode 100644
index 000000000..0082303b7
--- /dev/null
+++ b/app/views/exercise/_new_single.html.erb
@@ -0,0 +1,28 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/views/exercise/_student_exercise.html.erb b/app/views/exercise/_student_exercise.html.erb
index b133baa04..25bf3f7cd 100644
--- a/app/views/exercise/_student_exercise.html.erb
+++ b/app/views/exercise/_student_exercise.html.erb
@@ -10,37 +10,64 @@
您已提交
<% end %>
- <%if @is_teacher || @exercise.exercise_status == 3%>
-
+
<% end%>
\ No newline at end of file
diff --git a/app/views/exercise/_student_table.html.erb b/app/views/exercise/_student_table.html.erb
new file mode 100644
index 000000000..719667973
--- /dev/null
+++ b/app/views/exercise/_student_table.html.erb
@@ -0,0 +1,22 @@
+
\ No newline at end of file
+<%= form_for(@exercise,
+ :html => { :multipart => true },
+ :url => {:controller => 'exercise',
+ :action => 'create',
+ :course_id => @course.id
+ },:remote=>true ) do |f| %>
+
+
+
+
+ <%# if edit_mode %>
+
+ <%# end %>
+
+
+ <%= calendar_for('exercise_publish_time')%>
+
+ <%# if edit_mode %>
+
+ <%# end %>
+
+
+ <%= calendar_for('exercise_end_time')%>
+
+
考试时长:分钟
+
+
+
+
+
+<% end %>
\ No newline at end of file
diff --git a/app/views/exercise/_exercise_content.html.erb b/app/views/exercise/_exercise_content.html.erb
index 76bad6a83..bffd7e221 100644
--- a/app/views/exercise/_exercise_content.html.erb
+++ b/app/views/exercise/_exercise_content.html.erb
@@ -1,5 +1,5 @@
-<% poll.exercise_questions.each do |poll_question|%>
+<% exercise.exercise_questions.each do |poll_question|%>
<% end %>
\ No newline at end of file
diff --git a/app/views/exercise/_new_MCQ.html.erb b/app/views/exercise/_new_MCQ.html.erb
index 0ba2a0133..cabd9bf57 100644
--- a/app/views/exercise/_new_MCQ.html.erb
+++ b/app/views/exercise/_new_MCQ.html.erb
@@ -1,8 +1,8 @@
+ <% exercise_question.exercise_choices.reorder("choice_position").each_with_index do |exercise_choice,index| %>
+
+
+
+
+
+
+
+ <% end %>
+
+
+
+
+
+
+
+
+
+
+
+
+<% end%>
\ No newline at end of file
diff --git a/app/views/exercise/_new_single.html.erb b/app/views/exercise/_new_single.html.erb
index e4e1db695..4d9baf729 100644
--- a/app/views/exercise/_new_single.html.erb
+++ b/app/views/exercise/_new_single.html.erb
@@ -19,17 +19,17 @@
-
+
-
+
-
+
diff --git a/config/routes.rb b/config/routes.rb
index 8dba79d2c..422f470d5 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -157,6 +157,7 @@ RedmineApp::Application.routes.draw do
collection do #生成路径为 /exercise/方法名
delete 'delete_exercise_question'
+ post 'update_exercise_question'
end
end
From 1606e9ddab70950b194a7a5fc2d5c9a535580bcd Mon Sep 17 00:00:00 2001
From: huang
Date: Wed, 18 Nov 2015 18:28:17 +0800
Subject: [PATCH 36/83] 0
---
app/controllers/exercise_controller.rb | 4 +++-
app/helpers/exercise_helper.rb | 4 ++++
2 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/app/controllers/exercise_controller.rb b/app/controllers/exercise_controller.rb
index 89a5c195e..f83e31a56 100644
--- a/app/controllers/exercise_controller.rb
+++ b/app/controllers/exercise_controller.rb
@@ -136,6 +136,7 @@ class ExerciseController < ApplicationController
:question_score => params[:question_score]
}
@exercise_questions = @exercise.exercise_questions.new option
+ # params[:question_answer] 题目选项
if params[:question_answer]
for i in 1..params[:question_answer].count
answer = (params[:question_answer].values[i-1].nil? || params[:question_answer].values[i-1].empty?) ? l(:label_new_answer) : params[:question_answer].values[i-1]
@@ -154,6 +155,7 @@ class ExerciseController < ApplicationController
@exercise_questions.question_number = params[:quest_num].to_i + 1
end
if @exercise_questions.save
+ # params[:exercise_choice] 标准答案参数
standart_answer = ExerciseStandardAnswer.new
standart_answer.exercise_question_id = @exercise_questions.id
if @exercise_questions.question_type == 1
@@ -161,7 +163,7 @@ class ExerciseController < ApplicationController
elsif @exercise_questions.question_type == 2
standart_answer.exercise_choice_id = multiselect_standard_answer(params[:exercise_choice])
else
- standart_answer.answer_text = sigle_selection_standard_answer(params[:exercise_choice])
+ standart_answer.answer_text = fill_standart_answer(params[:exercise_choice])
end
standart_answer.save
respond_to do |format|
diff --git a/app/helpers/exercise_helper.rb b/app/helpers/exercise_helper.rb
index c1bf07407..3a7c0a00a 100644
--- a/app/helpers/exercise_helper.rb
+++ b/app/helpers/exercise_helper.rb
@@ -27,6 +27,10 @@ module ExerciseHelper
answer.to_i
end
+ def fill_standart_answer(params)
+
+ end
+
#判断用户是否已经提交了问卷
def has_commit_exercise?(exercise_id, user_id)
pu = ExerciseUser.find_by_exercise_id_and_user_id(exercise_id, user_id)
From 8cf22767f9d75046fd8a1010771d17b21b53d201 Mon Sep 17 00:00:00 2001
From: huang
Date: Wed, 18 Nov 2015 19:58:00 +0800
Subject: [PATCH 37/83] =?UTF-8?q?=E6=96=B0=E5=BB=BA=E9=97=AE=E7=AD=94?=
=?UTF-8?q?=E9=A2=98?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/controllers/exercise_controller.rb | 39 ++++++++++++++++----------
app/helpers/exercise_helper.rb | 7 +++--
2 files changed, 29 insertions(+), 17 deletions(-)
diff --git a/app/controllers/exercise_controller.rb b/app/controllers/exercise_controller.rb
index f363b9297..0afc9dfda 100644
--- a/app/controllers/exercise_controller.rb
+++ b/app/controllers/exercise_controller.rb
@@ -156,16 +156,24 @@ class ExerciseController < ApplicationController
end
if @exercise_questions.save
# params[:exercise_choice] 标准答案参数
- standart_answer = ExerciseStandardAnswer.new
- standart_answer.exercise_question_id = @exercise_questions.id
- if @exercise_questions.question_type == 1
- standart_answer.exercise_choice_id = sigle_selection_standard_answer(params[:exercise_choice])
- elsif @exercise_questions.question_type == 2
- standart_answer.exercise_choice_id = multiselect_standard_answer(params[:exercise_choice])
+ # 问答题标准答案有三个,单独处理
+ if @exercise_questions.question_type == 3
+ for i in 1..params[:exercise_choice].count
+ standart_answer = ExerciseStandardAnswer.new
+ standart_answer.exercise_question_id = @exercise_questions.id
+ standart_answer.answer_text = params[:exercise_choice].values[i-1]
+ standart_answer.save
+ end
else
- standart_answer.answer_text = fill_standart_answer(params[:exercise_choice])
+ standart_answer = ExerciseStandardAnswer.new
+ standart_answer.exercise_question_id = @exercise_questions.id
+ if @exercise_questions.question_type == 1
+ standart_answer.exercise_choice_id = sigle_selection_standard_answer(params[:exercise_choice])
+ else
+ standart_answer.exercise_choice_id = multiselect_standard_answer(params[:exercise_choice])
+ end
+ standart_answer.save
end
- standart_answer.save
respond_to do |format|
format.js
end
@@ -178,16 +186,17 @@ class ExerciseController < ApplicationController
# params[:question_answer] eg:A、B、C选项
def update_exercise_question
@exercise_question = ExerciseQuestion.find params[:exercise_question]
- @exercise_question.question_title = params[:exercise_questions_title].nil? || params[:exercise_questions_title].empty? ? l(:label_enter_single_title) : params[:exercise_questions_title]
+ @exercise_question.question_title = params[:question_title].nil? || params[:question_title].empty? ? l(:label_enter_single_title) : params[:question_title]
+ @exercise_question.question_score = params[:question_score]
################处理选项
if params[:question_answer]
- @exercise_question.exercise_answers.each do |answer|
- answer.destroy unless params[:question_answer].keys.include? answer.id.to_s
- end
+ # @exercise_question.exercise_choices.each do |answer|
+ # answer.destroy unless params[:question_answer].keys.include? answer.id.to_s
+ # end
# 界面需要判断选择题至少有一个选项
- for i in 1..params[:question_answer].count
- question = @exercise_question.exercise_answers.find_by_id params[:question_answer].keys[i-1]
- answer = (params[:question_answer].values[i-1].nil? || params[:question_answer].values[i-1].empty?) ? l(:label_new_answer) : params[:question_answer].values[i-1]
+ for i in 1..@exercise_question.exercise_choices.count
+ question = @exercise_question.exercise_choices.find_by_id params[:question_answer].keys[i-1]
+ # answer = (params[:question_answer].values[i-1].nil? || params[:question_answer].values[i-1].empty?) ? l(:label_new_answer) : params[:question_answer].values[i-1]
if question
question.exercise_choices_id = i
question.answer_text = answer
diff --git a/app/helpers/exercise_helper.rb b/app/helpers/exercise_helper.rb
index 3a7c0a00a..7f3d1862e 100644
--- a/app/helpers/exercise_helper.rb
+++ b/app/helpers/exercise_helper.rb
@@ -27,8 +27,11 @@ module ExerciseHelper
answer.to_i
end
- def fill_standart_answer(params)
-
+ def fill_standart_answer(params, standart_answer)
+ params.each do |param|
+ standart_answer.answer_text = param.value
+ standart_answer.save
+ end
end
#判断用户是否已经提交了问卷
From 368fc339c0a4a47b1c358a2bb4cb896ecb5dd622 Mon Sep 17 00:00:00 2001
From: cxt
Date: Wed, 18 Nov 2015 20:14:19 +0800
Subject: [PATCH 38/83] =?UTF-8?q?=E6=A0=B7=E5=BC=8F=E8=B0=83=E6=95=B4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/views/exercise/_edit_MCQ.html.erb | 63 ++++++++++++++
app/views/exercise/_edit_single.html.erb | 58 +++++++++++++
app/views/exercise/_exercise_content.html.erb | 83 ++++++++++++++-----
app/views/exercise/_exercise_form.html.erb | 2 +-
app/views/exercise/_show_MC.html.erb | 2 +-
app/views/exercise/_show_MCQ.html.erb | 2 +-
app/views/exercise/_show_single.html.erb | 4 +-
.../exercise/create_exercise_question.js.erb | 72 +++++++++++-----
.../exercise/update_exercise_question.js.erb | 19 +++++
9 files changed, 259 insertions(+), 46 deletions(-)
diff --git a/app/views/exercise/_edit_MCQ.html.erb b/app/views/exercise/_edit_MCQ.html.erb
index e69de29bb..bd7270688 100644
--- a/app/views/exercise/_edit_MCQ.html.erb
+++ b/app/views/exercise/_edit_MCQ.html.erb
@@ -0,0 +1,63 @@
+<%= form_for("",:url => update_exercise_question_exercise_index_path(:exercise_question => exercise_question.id),:remote => true) do |f|%>
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 分
+
+
+
+ <% exercise_question.exercise_choices.reorder("choice_position").each_with_index do |exercise_choice,index| %>
+
+
+
+
+
+
+
+ <% end %>
+
+
+
+
+
+
+
+
+
+
+
+
+<% end%>
\ No newline at end of file
diff --git a/app/views/exercise/_edit_single.html.erb b/app/views/exercise/_edit_single.html.erb
index e69de29bb..070e99343 100644
--- a/app/views/exercise/_edit_single.html.erb
+++ b/app/views/exercise/_edit_single.html.erb
@@ -0,0 +1,58 @@
+<%= form_for("",:url => update_exercise_question_exercise_index_path(:exercise_question => exercise_question.id),:remote => true) do |f|%>
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 分
+
+
+
+ <% exercise_question.exercise_standard_answers.reorder("created_at").each_with_index do |exercise_choice,index| %>
+
+
+
+
+
+
+
+ <% end %>
+
+
+
+
+
+
+
+
+<% end%>
\ No newline at end of file
diff --git a/app/views/exercise/_exercise_content.html.erb b/app/views/exercise/_exercise_content.html.erb
index 9e139fe32..c5f8f3c94 100644
--- a/app/views/exercise/_exercise_content.html.erb
+++ b/app/views/exercise/_exercise_content.html.erb
@@ -1,22 +1,65 @@
-<% exercise.exercise_questions.each do |exercise_question|%>
-
+
+
+
\ No newline at end of file
diff --git a/app/views/exercise/_new_single.html.erb b/app/views/exercise/_new_single.html.erb
index a8c6f57ea..ad5af1937 100644
--- a/app/views/exercise/_new_single.html.erb
+++ b/app/views/exercise/_new_single.html.erb
@@ -13,8 +13,9 @@
+
+
\ No newline at end of file
diff --git a/app/views/exercise/_show_MCQ.html.erb b/app/views/exercise/_show_MCQ.html.erb
index 7dd52b30a..08a012fd3 100644
--- a/app/views/exercise/_show_MCQ.html.erb
+++ b/app/views/exercise/_show_MCQ.html.erb
@@ -28,12 +28,77 @@
-
-
-
-
-
\ No newline at end of file
+
+
\ No newline at end of file
diff --git a/app/views/exercise/_show_single.html.erb b/app/views/exercise/_show_single.html.erb
index 452a14bc4..8232e68f3 100644
--- a/app/views/exercise/_show_single.html.erb
+++ b/app/views/exercise/_show_single.html.erb
@@ -15,4 +15,66 @@
-
\ No newline at end of file
+
+
+
\ No newline at end of file
diff --git a/app/views/exercise/create_exercise_question.js.erb b/app/views/exercise/create_exercise_question.js.erb
index db9468350..37199a70e 100644
--- a/app/views/exercise/create_exercise_question.js.erb
+++ b/app/views/exercise/create_exercise_question.js.erb
@@ -1,6 +1,7 @@
<% if @is_insert %>
$("#poll_content").html('<%= escape_javascript(render :partial => 'exercise_content', :locals => {:exercise => @exercise})%>');
<% else %>
+ $("#new_exercise_question").html('<%= escape_javascript(render :partial => 'new_question', :locals => {:exercise => @exercise}) %>');
$("#new_poll_question").html("");
<%if @exercise_questions.question_type == 1%>
$("#mc_question_list").show().append("
" +
From bc47382115689c4cfdddc93717b9e7c53c564e31 Mon Sep 17 00:00:00 2001
From: huang
Date: Thu, 19 Nov 2015 11:38:44 +0800
Subject: [PATCH 42/83] =?UTF-8?q?=E7=94=A8=E6=88=B7=E6=8F=90=E4=BA=A4?=
=?UTF-8?q?=E7=AD=94=E5=8D=B7=E5=90=8E=EF=BC=8C=E7=BB=99=E5=87=BA=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/exercise_controller.rb | 42 +++++++++++++++++++++-----
1 file changed, 35 insertions(+), 7 deletions(-)
diff --git a/app/controllers/exercise_controller.rb b/app/controllers/exercise_controller.rb
index a291a2229..58c6f772b 100644
--- a/app/controllers/exercise_controller.rb
+++ b/app/controllers/exercise_controller.rb
@@ -190,9 +190,9 @@ class ExerciseController < ApplicationController
@exercise_question.question_score = params[:question_score]
################处理选项
if params[:question_answer]
- # @exercise_question.exercise_choices.each do |answer|
- # answer.destroy unless params[:question_answer].keys.include? answer.id.to_s
- # end
+ @exercise_question.exercise_choices.each do |answer|
+ answer.destroy unless params[:question_answer].keys.include? answer.id.to_s
+ end
# 界面需要判断选择题至少有一个选项
for i in 1..@exercise_question.exercise_choices.count
question = @exercise_question.exercise_choices.find_by_id params[:question_answer].keys[i-1]
@@ -265,9 +265,10 @@ class ExerciseController < ApplicationController
end
end
- # 学生提交答卷
+ # 学生提交答卷,选着答案的课程中提交
def commit_answer
- eq = ExerciseQuestion.find(params[:poll_question_id])
+ eq = ExerciseQuestion.find(params[:exercise_question_id])
+ # 已提交过的则不允许答题
if has_commit_exercise?(@exercise.id,User.current.id) && (!User.current.admin?)
render :json => {:text => "failure"}
return
@@ -369,11 +370,12 @@ class ExerciseController < ApplicationController
# 老师不需要提交
if User.current.allowed_to?(:as_teacher,@course)
redirect_to exercise_url(@exercise)
+ # REDO: 提示提交成功
else
# 答题过程中需要统计完成量
@uncomplete_question = get_uncomplete_question(@exercise, User.current)
# 获取改学生的考试得分
- score = get_answer_score(@exercise)
+ score = calculate_student_score(@exercise, User.current)
if @uncomplete_question.count < 1
# 查看是否有已提交记录
eu = get_exercise_user(@exercise.id, User.current.id)
@@ -395,6 +397,26 @@ class ExerciseController < ApplicationController
end
end
+ # 计算学生得分
+ def calculate_student_score(exercise, user)
+ score = 0
+ exercise_qustions = exercise.exercise_questions
+ exercise_qustions.each do |question|
+ answer = get_user_answer(question, user)
+ standard_answer = get_user_standard_answer(question, user)
+ # 问答题有多个答案
+ if question.question_type == 3
+ if standard_answer.exercise_choice_id.include?(answer.exercise_choice_id)
+ score = score + question.question_score
+ end
+ else
+ if answer.exercise_choice_id == standard_answer.exercise_choice_id
+ score = score + question.question_score
+ end
+ end
+ end
+ score
+ end
private
# ExerciseUser记录用户是否已提交问卷有对应的记录则已提交,没有则新建一个
@@ -419,12 +441,18 @@ class ExerciseController < ApplicationController
uncomplete_question
end
- # 获取问题的答案
+ # 获取当前学生回答问题的答案
def get_user_answer(question,user)
user_answer = question.exercise_answers.where("#{ExerciseAnswer.table_name}.user_id = #{user.id}")
user_answer
end
+ # 获取问题的标准答案
+ def get_user_standard_answer(question,user)
+ standard_answer = question.exercise_standard_answers
+ standard_answer
+ end
+
# 是否完成了答题
def get_complete_question(exercise,user)
questions = exercise.exercise_questions
From 3929aa6dded402df31197c038d00d25875cc713f Mon Sep 17 00:00:00 2001
From: cxt
Date: Thu, 19 Nov 2015 13:06:17 +0800
Subject: [PATCH 43/83] =?UTF-8?q?=E7=BC=96=E8=BE=91?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/views/exercise/_edit_MC.html.erb | 4 ++--
app/views/exercise/_edit_MCQ.html.erb | 4 ++--
app/views/exercise/_edit_head.html.erb | 2 +-
app/views/exercise/_new_MC.html.erb | 1 +
app/views/exercise/_new_MCQ.html.erb | 1 +
app/views/exercise/_new_single.html.erb | 1 +
6 files changed, 8 insertions(+), 5 deletions(-)
diff --git a/app/views/exercise/_edit_MC.html.erb b/app/views/exercise/_edit_MC.html.erb
index c769fe634..ef46e47a8 100644
--- a/app/views/exercise/_edit_MC.html.erb
+++ b/app/views/exercise/_edit_MC.html.erb
@@ -1,4 +1,4 @@
-<%= form_for("",:url => update_exercise_question_exercise_index_path(:exercise_question => exercise_question.id),:remote => true) do |f|%>
+<%= form_for("",:class => 'new_or_edit_question',:url => update_exercise_question_exercise_index_path(:exercise_question => exercise_question.id),:remote => true) do |f|%>
\ No newline at end of file
diff --git a/app/views/exercise/_new_single.html.erb b/app/views/exercise/_new_single.html.erb
index 06b8939c3..ad5af1937 100644
--- a/app/views/exercise/_new_single.html.erb
+++ b/app/views/exercise/_new_single.html.erb
@@ -1,6 +1,5 @@
<%= form_for(ExerciseQuestion.new,
:html => { :multipart => true },
- :class => 'new_or_edit_question',
:url => {:controller => 'exercise',
:action => 'create_exercise_question',
:course_id => @course.id
diff --git a/app/views/exercise/_show_MC.html.erb b/app/views/exercise/_show_MC.html.erb
index 1c90f6908..21d6ef4bb 100644
--- a/app/views/exercise/_show_MC.html.erb
+++ b/app/views/exercise/_show_MC.html.erb
@@ -32,75 +32,80 @@
\ No newline at end of file
diff --git a/app/views/exercise/_show_MCQ.html.erb b/app/views/exercise/_show_MCQ.html.erb
index 08a012fd3..a6ffbeb82 100644
--- a/app/views/exercise/_show_MCQ.html.erb
+++ b/app/views/exercise/_show_MCQ.html.erb
@@ -31,74 +31,79 @@
\ No newline at end of file
diff --git a/app/views/exercise/_show_single.html.erb b/app/views/exercise/_show_single.html.erb
index 8232e68f3..4e36530ed 100644
--- a/app/views/exercise/_show_single.html.erb
+++ b/app/views/exercise/_show_single.html.erb
@@ -19,62 +19,67 @@
\ No newline at end of file
From 841ebb78468d1ec0198d03e4cd9ce05f89139feb Mon Sep 17 00:00:00 2001
From: huang
Date: Thu, 19 Nov 2015 16:21:31 +0800
Subject: [PATCH 46/83] =?UTF-8?q?=E7=AE=80=E5=8D=95=E9=A2=98=E6=9B=B4?=
=?UTF-8?q?=E6=96=B0=EF=BC=8C=E6=9C=AA=E5=AE=8C?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/controllers/exercise_controller.rb | 54 ++++++++++++++++++------
app/views/exercise/_edit_MC.html.erb | 2 +-
app/views/exercise/_edit_MCQ.html.erb | 4 +-
app/views/exercise/_edit_single.html.erb | 2 +-
4 files changed, 44 insertions(+), 18 deletions(-)
diff --git a/app/controllers/exercise_controller.rb b/app/controllers/exercise_controller.rb
index dd4e543ff..faaae4997 100644
--- a/app/controllers/exercise_controller.rb
+++ b/app/controllers/exercise_controller.rb
@@ -188,30 +188,43 @@ class ExerciseController < ApplicationController
@exercise_question = ExerciseQuestion.find params[:exercise_question]
@exercise_question.question_title = params[:question_title].nil? || params[:question_title].empty? ? l(:label_enter_single_title) : params[:question_title]
@exercise_question.question_score = params[:question_score]
- # 处理选项
+ # 处理选项:如果选了某个选项,那么则要删除之前的选项
if params[:question_answer]
- @exercise_question.exercise_choices.each do |answer|
- answer.destroy unless params[:question_answer].keys.include? answer.id.to_s
- end
+ # @exercise_question.exercise_choices.each do |answer|
+ # answer.destroy unless params[:question_answer].keys.include? answer.id.to_s
+ # end
for i in 1..params[:question_answer].count
question = @exercise_question.exercise_choices.find_by_id params[:question_answer].keys[i-1]
answer = (params[:question_answer].values[i-1].nil? || params[:question_answer].values[i-1].empty?) ? l(:label_new_answer) : params[:question_answer].values[i-1]
if question
- question.exercise_choices_id = i
- question.answer_text = answer
+ question.choice_position = i
+ question.choice_text = answer
question.save
else
question_option = {
- :exercise_choice_id => i,
- :answer_text => answer
+ :choice_position => i,
+ :choice_text => answer
}
- @exercise_question.exercise_answers.new question_option
+ @exercise_question.exercise_choices.new question_option
end
end
end
- @exercise_question.save
- respond_to do |format|
- format.js
+ # 更新标准答案
+ if params[:exercise_choice]
+ if @exercise_question.question_type == 3
+ for i in 1..params[:exercise_choice].count
+ question_standart = @exercise_question.exercise_standard_answers.find_by_id params[:exercise_choice].keys[i]
+ answer_standart = (params[:question_answer].values[i-1].nil? || params[:question_answer].values[i-1].empty?) ? l(:label_new_answer) : params[:question_answer].values[i-1]
+ end
+ else
+ answer_standart = @exercise_question.exercise_standard_answers.first
+ answer_standart.exercise_choice_id = params[:exercise_choice]
+ answer_standart.save
+ end
+ @exercise_question.save
+ respond_to do |format|
+ format.js
+ end
end
end
@@ -231,7 +244,7 @@ class ExerciseController < ApplicationController
end
end
- #发布问卷
+ # 发布试卷
def publish_excercise
@exercise.exercise_status = 2
@exercise.publish_time = Time.now
@@ -246,6 +259,19 @@ class ExerciseController < ApplicationController
end
end
+ # 重新发布试卷
+ def republish_excercise
+ @exercise.exercise_questions.each do |exercise_question|
+ exercise_question.exercise_ansers.destroy_all
+ end
+ # @poll.poll_users.destroy_all
+ # @poll.polls_status = 1
+ # @poll.save
+ # respond_to do |format|
+ # format.js
+ # end
+ end
+
def student_exercise_list
@is_teacher = User.current.allowed_to?(:as_teacher,@course) || User.current.admin?
@exercise = Exercise.find params[:id]
@@ -264,7 +290,7 @@ class ExerciseController < ApplicationController
end
end
- # 学生提交答卷,选着答案的课程中提交
+ # 学生提交答卷,选中答案的过程中提交
def commit_answer
eq = ExerciseQuestion.find(params[:exercise_question_id])
# 已提交过的则不允许答题
diff --git a/app/views/exercise/_edit_MC.html.erb b/app/views/exercise/_edit_MC.html.erb
index 9c6f3c396..76bad697c 100644
--- a/app/views/exercise/_edit_MC.html.erb
+++ b/app/views/exercise/_edit_MC.html.erb
@@ -35,7 +35,7 @@
<% exercise_question.exercise_choices.reorder("choice_position").each_with_index do |exercise_choice,index| %>
<% end %>
-
-<%# exercise.exercise_questions.each do |exercise_question|%>
-
-<%# end %>
\ No newline at end of file
+
\ No newline at end of file
diff --git a/app/views/exercise/_exercise_form.html.erb b/app/views/exercise/_exercise_form.html.erb
index 934e51b71..6e0953e74 100644
--- a/app/views/exercise/_exercise_form.html.erb
+++ b/app/views/exercise/_exercise_form.html.erb
@@ -134,6 +134,12 @@
""+
"");
}
+ function add_candidate_answer(doc)
+ {
+ doc.parent().after("