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|%> + + + +
+
+ + + +
+
+ +
+ +
+
+ +<% 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|%> + + + +
+
+ + + +
+
+ +
+ +
+
+ +<% 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|%> -
-
- <% if exercise_question.question_type == 1%> - <%= render :partial => 'show_MC', :locals => {:exercise_question => exercise_question} %> - <% elsif exercise_question.question_type == 2%> - <%= render :partial => 'show_MCQ', :locals => {:exercise_question => exercise_question} %> - <% elsif exercise_question.question_type == 3%> - <%= render :partial => 'show_single', :locals => {:exercise_question => exercise_question} %> - <% end%> +<% mc_question_list = exercise.exercise_questions.where("question_type=1") %> +<% mcq_question_list = exercise.exercise_questions.where("question_type=2") %> +<% single_question_list = exercise.exercise_questions.where("question_type=3") %> +
"> +

单选题

+ <% mc_question_list.each do |exercise_question| %> +
+
+ <%= render :partial => 'show_MC', :locals => {:exercise_question => exercise_question} %> +
+
- +
"> +

多选题

+ <% mcq_question_list.each do |exercise_question| %> +
+
+ <%= render :partial => 'show_MCQ', :locals => {:exercise_question => exercise_question} %> +
+
-
-<% end %> \ No newline at end of file + <% end %> +
+
"> +

填空题

+ <% single_question_list.each do |exercise_question| %> +
+
+ <%= render :partial => 'show_single', :locals => {:exercise_question => exercise_question} %> +
+ +
+ <% end %> +
+<%# exercise.exercise_questions.each do |exercise_question|%> + +<%# end %> \ 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 1d78fb435..4ac594d76 100644 --- a/app/views/exercise/_exercise_form.html.erb +++ b/app/views/exercise/_exercise_form.html.erb @@ -335,7 +335,7 @@ <%= render :partial => 'edit_head', :locals => {:exercise => @exercise}%>
<% current_score = get_current_score @exercise %> -
">目前试卷总分:<%=current_score %>分
+
" id="current_score_div">目前试卷总分:<%=current_score %>分
<%= render :partial => 'exercise_content', :locals => {:exercise => @exercise}%> diff --git a/app/views/exercise/_show_MC.html.erb b/app/views/exercise/_show_MC.html.erb index e7bf20206..d44652603 100644 --- a/app/views/exercise/_show_MC.html.erb +++ b/app/views/exercise/_show_MC.html.erb @@ -10,7 +10,7 @@
- +
<% exercise_question.exercise_choices.reorder("choice_position").each_with_index do |exercise_choice,index| %> diff --git a/app/views/exercise/_show_MCQ.html.erb b/app/views/exercise/_show_MCQ.html.erb index f69b855bd..db9fa2dd4 100644 --- a/app/views/exercise/_show_MCQ.html.erb +++ b/app/views/exercise/_show_MCQ.html.erb @@ -9,7 +9,7 @@
-
+
<% exercise_question.exercise_choices.reorder("choice_position").each_with_index do |exercise_choice,index| %> diff --git a/app/views/exercise/_show_single.html.erb b/app/views/exercise/_show_single.html.erb index 07ecce94d..591848d76 100644 --- a/app/views/exercise/_show_single.html.erb +++ b/app/views/exercise/_show_single.html.erb @@ -8,8 +8,8 @@
- <% exercise_question.exercise_choices.reorder("choice_position").each_with_index do |exercise_choice,index| %> - 候选答案:<%= exercise_choice.choice_text%>
+ <% exercise_question.exercise_standard_answers.reorder("created_at").each_with_index do |exercise_choice,index| %> + 候选答案:<%= exercise_choice.answer_text%>
<% end %>
diff --git a/app/views/exercise/create_exercise_question.js.erb b/app/views/exercise/create_exercise_question.js.erb index 224dc0a95..db9468350 100644 --- a/app/views/exercise/create_exercise_question.js.erb +++ b/app/views/exercise/create_exercise_question.js.erb @@ -1,27 +1,57 @@ <% if @is_insert %> -$("#poll_content").html('<%= escape_javascript(render :partial => 'exercise_content', :locals => {:exercise => @exercise})%>'); + $("#poll_content").html('<%= escape_javascript(render :partial => 'exercise_content', :locals => {:exercise => @exercise})%>'); <% else %> -$("#new_poll_question").html(""); - -$("#poll_content").append("
" + - "
" + - "<% if @exercise_questions.question_type == 1%>" + - "<%= escape_javascript(render :partial => 'show_MC', :locals => {:exercise_question => @exercise_questions}) %>" + - "<% elsif @exercise_questions.question_type == 2%>" + - "<%= escape_javascript(render :partial => 'show_MCQ', :locals => {:exercise_question => @exercise_questions}) %>" + - "<% elsif @exercise_questions.question_type == 3%>" + - "<%= escape_javascript(render :partial => 'show_single', :locals => {:exercise_question => @exercise_questions}) %>" + - "<% end%>" + + $("#new_poll_question").html(""); + <%if @exercise_questions.question_type == 1%> + $("#mc_question_list").show().append("
" + + "
" + + "<%= escape_javascript(render :partial => 'show_MC', :locals => {:exercise_question => @exercise_questions}) %>" + + "
" + + "" + + "
"); + <% end %> + <%if @exercise_questions.question_type == 2%> + $("#mcq_question_list").show().append("
" + + "
" + + "<%= escape_javascript(render :partial => 'show_MCQ', :locals => {:exercise_question => @exercise_questions}) %>" + + "
" + + "" + + "
"); + <% end %> + <%if @exercise_questions.question_type == 3%> + $("#single_question_list").show().append("
" + + "
" + + "<%= escape_javascript(render :partial => 'show_single', :locals => {:exercise_question => @exercise_questions}) %>" + + "
" + + "" + + "
"); + <% end %> +/*$("#poll_content").append("
" + + "
" + + "<%# if @exercise_questions.question_type == 1%>" + + "<%#= escape_javascript(render :partial => 'show_MC', :locals => {:exercise_question => @exercise_questions}) %>" + + "<%# elsif @exercise_questions.question_type == 2%>" + + "<%#= escape_javascript(render :partial => 'show_MCQ', :locals => {:exercise_question => @exercise_questions}) %>" + + "<%# elsif @exercise_questions.question_type == 3%>" + + "<%#= escape_javascript(render :partial => 'show_single', :locals => {:exercise_question => @exercise_questions}) %>" + + "<%# end%>" + "
" + - ""); + "
");*/ $("#current_score").html("<%=get_current_score @exercise %>分"); +$("#current_score_div").show(); <% end %> diff --git a/app/views/exercise/update_exercise_question.js.erb b/app/views/exercise/update_exercise_question.js.erb index e69de29bb..0f0a23cec 100644 --- a/app/views/exercise/update_exercise_question.js.erb +++ b/app/views/exercise/update_exercise_question.js.erb @@ -0,0 +1,19 @@ +$("#poll_questions_<%= @exercise_question.id%>").html("
" + + "<% if @exercise_question.question_type == 1%>" + + "<%= escape_javascript(render :partial => 'show_MC', :locals => {:exercise_question => @exercise_question}) %>" + + "<% elsif @exercise_question.question_type == 2%>" + + "<%= escape_javascript(render :partial => 'show_MCQ', :locals => {:exercise_question => @exercise_question}) %>" + + "<% elsif @exercise_question.question_type == 3%>" + + "<%= escape_javascript(render :partial => 'show_single', :locals => {:exercise_question => @exercise_question}) %>" + + "<% end%>" + + "
" + + ""); +$("#current_score").html("<%=get_current_score @exercise %>分");