diff --git a/app/controllers/exercise_controller.rb b/app/controllers/exercise_controller.rb
index 18248331c..69e8ebd80 100644
--- a/app/controllers/exercise_controller.rb
+++ b/app/controllers/exercise_controller.rb
@@ -374,7 +374,7 @@ class ExerciseController < ApplicationController
ea.answer_text = params[:answer_text]
if ea.save
@percent = get_percent(@exercise,User.current)
- render :json => {:text => pv.vote_text,:percent => format("%.2f",@percent)}
+ render :json => {:text => ea.answer_text,:percent => format("%.2f",@percent)}
else
render :json => {:text => "failure"}
end
@@ -416,13 +416,13 @@ class ExerciseController < ApplicationController
# 答题过程中需要统计完成量
@uncomplete_question = get_uncomplete_question(@exercise, User.current)
# 获取改学生的考试得分
- score = calculate_student_score(@exercise, User.current)
+ @score = calculate_student_score(@exercise, User.current)
if @uncomplete_question.count < 1
# 查看是否有已提交记录
eu = get_exercise_user(@exercise.id, User.current.id)
eu.user_id = User.current.id
eu.exercise_id = @exercise.id
- eu.score = score
+ eu.score = @score
if eu.save
#redirect_to poll_index_path(:polls_group_id => @course.id,:polls_type => 'Course')
@status = 0 #提交成功
diff --git a/app/helpers/exercise_helper.rb b/app/helpers/exercise_helper.rb
index 7f3d1862e..5b28234e8 100644
--- a/app/helpers/exercise_helper.rb
+++ b/app/helpers/exercise_helper.rb
@@ -72,4 +72,23 @@ module ExerciseHelper
return score
end
+ def answer_be_selected?(answer,user)
+ pv = answer.exercise_answers.where("#{ExerciseAnswer.table_name}.user_id = #{user.id} ")
+ if !pv.nil? && pv.count > 0
+ true
+ else
+ false
+ end
+ end
+
+ #获取文本题答案
+ def get_anwser_vote_text(question_id,user_id)
+ pv = ExerciseAnswer.find_by_exercise_question_id_and_user_id(question_id,user_id)
+ if pv.nil?
+ ''
+ else
+ pv.answer_text
+ end
+ end
+
end
\ No newline at end of file
diff --git a/app/views/exercise/_commit_alert.html.erb b/app/views/exercise/_commit_alert.html.erb
new file mode 100644
index 000000000..d92ca51fb
--- /dev/null
+++ b/app/views/exercise/_commit_alert.html.erb
@@ -0,0 +1,12 @@
+
+ <% if status == 0 %>
+
提交成功!您的分数是:<%=@score %>分。
+ <%= link_to "确定", exercise_path(),:class => 'commit'%>
+ <% elsif status == 1 %>
+ 您还有尚未作答的题目请完成后再提交!
+ <%= link_to "确定", "javascript:void(0)",:onclick => 'hidden_atert_form();',:class => 'commit'%>
+ <% else %>
+ 发生未知错误,请检查您的网络。
+ <%= link_to "确定", "javascript:void(0)",:onclick => 'hidden_atert_form();',:class => 'commit'%>
+ <% end %>
+
diff --git a/app/views/exercise/_exercise_student.html.erb b/app/views/exercise/_exercise_student.html.erb
index 5a139fd5d..0cc34958f 100644
--- a/app/views/exercise/_exercise_student.html.erb
+++ b/app/views/exercise/_exercise_student.html.erb
@@ -4,33 +4,15 @@
$("#homework_page_right").css("min-height",$("#LSide").height()-30);
$("#Container").css("width","1000px");
});
- function click_<%= pa.id %>(obj)
- {
- $.ajax({
- type: "post",
- url: "<%= commit_answer_poll_path(@poll) %>",
- data: {
- poll_answer_id: <%= pa.id %>,
- poll_question_id: <%= pq.id %>
- },
- success: function (data) {
- var dataObj = eval(data);
- obj.checked = true;
- var span = $('#percent');
- span.html(dataObj.percent);
- }
- });
- }
- function student_submit_exercise(){
-
- }