diff --git a/app/controllers/exercise_controller.rb b/app/controllers/exercise_controller.rb index d53dc067c..d4050da18 100644 --- a/app/controllers/exercise_controller.rb +++ b/app/controllers/exercise_controller.rb @@ -5,14 +5,17 @@ class ExerciseController < ApplicationController before_filter :find_course, :only => [:index,:new,:create,:student_exercise_list] include ExerciseHelper - include ExerciseHelper def index + if @course.is_public == 0 && !User.current.member_of_course?(@course) + render_403 + return + end remove_invalid_exercise(@course) @is_teacher = User.current.allowed_to?(:as_teacher,@course) if @is_teacher - exercises = @course.exercises + exercises = @course.exercises.order("created_at asc") else - exercises = @course.exercises.where(:exercise_status => 2) + exercises = @course.exercises.where(:exercise_status => 2).order("created_at asc") end @exercises = paginateHelper exercises,20 #分页 respond_to do |format| @@ -31,17 +34,24 @@ class ExerciseController < ApplicationController render_403 return end - @can_edit_excercise = (!has_commit_exercise?(@exercise.id,User.current.id)) || User.current.admin? + exercise_end = Time.parse(format_time(@exercise.end_time)).strftime("%Y-%m-%d %H:%M:%S") > Time.now.strftime("%Y-%m-%d %H:%M:%S") + if @exercise.time == -1 + @can_edit_excercise = exercise_end + else + @can_edit_excercise = (!has_commit_exercise?(@exercise.id,User.current.id)&& exercise_end) || User.current.admin? + end @exercise_user = ExerciseUser.where("user_id=? and exercise_id=?", User.current.id, @exercise.id).first # 学生点击的时候即创建关联,自动保存 #eu = ExerciseUser.create(:user_id => User.current, :exercise_id => @exercise.id, :start_at => Time.now, :status => false) # 已提交问卷的用户不能再访问该界面 +=begin if has_commit_exercise?(@exercise.id, User.current.id) && (!User.current.admin?) respond_to do |format| format.html {render :layout => 'base_courses'} end else +=end if !@is_teacher && !has_click_exercise?(@exercise.id, User.current.id) eu = ExerciseUser.create(:user_id => User.current.id, :exercise_id => @exercise.id, :start_at => Time.now, :status => false) @exercise_user = ExerciseUser.where("user_id=? and exercise_id=?", User.current.id, @exercise.id).first @@ -52,7 +62,7 @@ class ExerciseController < ApplicationController respond_to do |format| format.html {render :layout => 'base_courses'} end - end + #end end def new @@ -65,7 +75,6 @@ class ExerciseController < ApplicationController :end_time => "", :publish_time => "", :exercise_description => "", - :show_result => "", :show_result => 1 } @exercise = Exercise.create option @@ -80,7 +89,7 @@ class ExerciseController < ApplicationController exercise ||= Exercise.new exercise.exercise_name = params[:exercise][:exercise_name] exercise.exercise_description = params[:exercise][:exercise_description] - exercise.end_time = params[:exercise][:end_time] + exercise.end_time = Time.at(params[:exercise][:end_time].to_time.to_i + 16*60*60 -1) exercise.publish_time = params[:exercise][:publish_time] exercise.user_id = User.current.id exercise.time = params[:exercise][:time] @@ -104,10 +113,10 @@ class ExerciseController < ApplicationController def update @exercise.exercise_name = params[:exercise][:exercise_name] @exercise.exercise_description = params[:exercise][:exercise_description] - @exercise.time = params[:exercise][:time] - @exercise.end_time = params[:exercise][:end_time] + @exercise.time = params[:exercise][:time].blank? ? -1 : params[:exercise][:time] + @exercise.end_time = Time.at(params[:exercise][:end_time].to_time.to_i + 16*60*60 -1) @exercise.publish_time = params[:exercise][:publish_time] - @exercise.show_result = params[:exercise][:show_result] + @exercise.show_result = params[:exercise][:show_result].blank? ? 1 : params[:exercise][:show_result] if @exercise.save respond_to do |format| format.js @@ -300,6 +309,7 @@ class ExerciseController < ApplicationController # 发布试卷 def publish_exercise @is_teacher = User.current.allowed_to?(:as_teacher,@course) + @index = params[:index] @exercise.exercise_status = 2 @exercise.publish_time = Time.now if @exercise.save @@ -314,11 +324,13 @@ class ExerciseController < ApplicationController # 重新发布的时候会删除所有的答题 def republish_exercise @is_teacher = User.current.allowed_to?(:as_teacher,@course) + @index = params[:index] @exercise.exercise_questions.each do |exercise_question| exercise_question.exercise_answers.destroy_all end @exercise.exercise_users.destroy_all @exercise.exercise_status = 1 + @exercise.publish_time = nil @exercise.save respond_to do |format| format.js @@ -328,7 +340,7 @@ class ExerciseController < ApplicationController 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") + @all_exercises = @course.exercises.where("exercise_status > 1").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') @@ -346,8 +358,8 @@ class ExerciseController < ApplicationController # 学生提交答卷,选中答案的过程中提交 def commit_answer eq = ExerciseQuestion.find(params[:exercise_question_id]) - # 已提交过的则不允许答题 - if has_commit_exercise?(@exercise.id,User.current.id) && (!User.current.admin?) + # 已提交过的且是限时的则不允许答题 + if has_commit_exercise?(@exercise.id,User.current.id) && (!User.current.admin?) && @exercise.time != -1 render :json => {:text => "failure"} return end @@ -447,6 +459,17 @@ class ExerciseController < ApplicationController def commit_exercise # 老师不需要提交 if User.current.allowed_to?(:as_teacher,@course) + if @exercise.publish_time.nil? + @exercise.update_attributes(:show_result => params[:show_result]) + @exercise.update_attributes(:exercise_status => 2) + @exercise.update_attributes(:publish_time => Time.now) + redirect_to exercise_url(@exercise) + return + elsif Time.parse(@exercise.publish_time.to_s).strftime("%Y-%m-%d-%H-%M-%S") > Time.now.strftime("%Y-%m-%d-%H-%M-%S") + @exercise.update_attributes(:show_result => params[:show_result]) + redirect_to exercise_url(@exercise) + return + end @exercise.update_attributes(:show_result => params[:show_result]) redirect_to exercise_url(@exercise) # REDO: 提示提交成功 diff --git a/app/controllers/student_work_controller.rb b/app/controllers/student_work_controller.rb index 9ad46cd69..3c60fcaed 100644 --- a/app/controllers/student_work_controller.rb +++ b/app/controllers/student_work_controller.rb @@ -76,7 +76,7 @@ class StudentWorkController < ApplicationController end ################################################################################################################## @order,@b_sort,@name,@group = params[:order] || "score",params[:sort] || "desc",params[:name] || "",params[:group] - @homework_commons = @course.homework_commons.order("created_at desc") + @homework_commons = @course.homework_commons.where("publish_time <= ?",Time.now.strftime("%Y-%m-%d")).order("created_at desc") @is_teacher = User.current.allowed_to?(:as_teacher,@course) || User.current.admin? @is_evaluation = @homework.homework_detail_manual && @homework.homework_detail_manual.comment_status == 2 && !@is_teacher #是不是匿评 @show_all = false diff --git a/app/views/exercise/_commit_alert.html.erb b/app/views/exercise/_commit_alert.html.erb index d92ca51fb..23aee5a90 100644 --- a/app/views/exercise/_commit_alert.html.erb +++ b/app/views/exercise/_commit_alert.html.erb @@ -1,12 +1,18 @@
- <% if status == 0 %> + <% if status == 0 && exercise.time != -1%>

提交成功!您的分数是:<%=@score %>分。

<%= link_to "确定", exercise_path(),:class => 'commit'%> + <% elsif status == 0 && Time.parse(format_time(exercise.end_time)).strftime("%Y-%m-%d %H:%M:%S") > Time.now.strftime("%Y-%m-%d %H:%M:%S") %> +

提交成功!

+ <%= link_to "确定", exercise_index_path(:course_id => @course.id),:class => 'commit'%> <% elsif status == 1 %>

您还有尚未作答的题目请完成后再提交!

<%= link_to "确定", "javascript:void(0)",:onclick => 'hidden_atert_form();',:class => 'commit'%> - <% else %> + <% elsif status == 2 %>

发生未知错误,请检查您的网络。

<%= link_to "确定", "javascript:void(0)",:onclick => 'hidden_atert_form();',:class => 'commit'%> + <% else %> +

时间已到!您的分数是:<%=@score %>分。

+ <%= link_to "确定", exercise_path(),:class => 'commit'%> <% end %>
diff --git a/app/views/exercise/_edit_MC.html.erb b/app/views/exercise/_edit_MC.html.erb index 008c95c24..f4ececf8f 100644 --- a/app/views/exercise/_edit_MC.html.erb +++ b/app/views/exercise/_edit_MC.html.erb @@ -1,63 +1,63 @@ -<%= form_for("",:url => update_exercise_question_exercise_index_path(:exercise_question => exercise_question.id),:remote => true) do |f|%> - - - -
-
- - - -
-
- -
- -
-
- +<%= 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_MCQ.html.erb b/app/views/exercise/_edit_MCQ.html.erb index 2b900d648..18ae79d1c 100644 --- a/app/views/exercise/_edit_MCQ.html.erb +++ b/app/views/exercise/_edit_MCQ.html.erb @@ -1,63 +1,63 @@ -<%= form_for("",:url => update_exercise_question_exercise_index_path(:exercise_question => exercise_question.id),:remote => true) do |f|%> - - - -
-
- - - -
-
- -
- -
-
- +<%= 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_head.html.erb b/app/views/exercise/_edit_head.html.erb index 3090cc2c5..c8ba0c4d7 100644 --- a/app/views/exercise/_edit_head.html.erb +++ b/app/views/exercise/_edit_head.html.erb @@ -3,31 +3,37 @@
- <%# if edit_mode %> - - <%# end %> -
- " > - <%= calendar_for('exercise_publish_time')%> -
- <%# if edit_mode %> - - <%# end %> +
- " > + "/> <%= calendar_for('exercise_end_time')%>
-
测验时长:分钟
+
测验时长:分钟
+ +
+ "/> + <%= calendar_for('exercise_publish_time')%> +
-<% end %> \ No newline at end of file +<% 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 d2e4a6f2c..0ce2f0943 100644 --- a/app/views/exercise/_edit_single.html.erb +++ b/app/views/exercise/_edit_single.html.erb @@ -8,7 +8,7 @@ $("#poll_answers_<%=exercise_question.id%>").html("<% exercise_question.exercise_standard_answers.reorder("created_at").each_with_index do |exercise_choice,index| %>" + "
  • " + "" + - "" + + "" + "" + "" + @@ -24,7 +24,7 @@ -
    +
    • @@ -35,7 +35,7 @@ <% exercise_question.exercise_standard_answers.reorder("created_at").each_with_index do |exercise_choice,index| %>
    • - +
    • diff --git a/app/views/exercise/_exercise.html.erb b/app/views/exercise/_exercise.html.erb index f5896c5e3..db412672c 100644 --- a/app/views/exercise/_exercise.html.erb +++ b/app/views/exercise/_exercise.html.erb @@ -1,61 +1,60 @@ -<%# has_commit = has_commit_poll?(poll.id ,User.current)%> -<% exercise_name = exercise.exercise_name.empty? ? l(:label_poll_new) : exercise.exercise_name%> -<% if @is_teacher%> -
    • -
      - <%# if has_commit %> - <%#= link_to poll_name, poll_result_poll_path(poll.id), :class => "polls_title polls_title_w fl c_dblue"%> - <%# else %> - <%#= link_to poll_name, exercise_path(poll.id), :class => "polls_title polls_title_w fl c_dblue" %> - <%# end %> - <%= link_to exercise_name, exercise_path(exercise.id), :class => "polls_title polls_title_w fl c_dblue" %> -
      -
    • - - <% if exercise.exercise_status == 1%> -
    • 统计结果
    • - <% else %> -
    • <%= link_to l(:label_statistical_results), student_exercise_list_exercise_path(exercise.id,:course_id => @course.id), :class => "pollsbtn fl ml10"%>
    • - <% end%> - - <% if exercise.exercise_status == 1 %> -
    • 发布试卷
    • - <% elsif exercise.exercise_status == 2%> -
    • 取消发布
    • - <% else%> -
    • 发布试卷
    • - <% end%> - - <%= link_to(l(:button_delete), exercise,:method => :delete, :confirm => l(:text_are_you_sure), :remote => true, :class => "polls_de fr ml5 mr10") %> - - <% if exercise.exercise_status == 1 %> -
    • <%= link_to l(:button_edit), edit_exercise_path(exercise.id), :class => "polls_de fr ml5"%>
    • - <% else%> -
    • 编辑
    • - <% end%> - - <%# if exercise.exercise_status == 2 %> - - <%# else %> - - <%# end%> - - <%# if exercise.exercise_status == 1%> - - <%# elsif exercise.exercise_status == 2 || exercise.exercise_status == 3 %> - - <%# end%> - - -
    • <%= format_date exercise.created_at.to_date%>
    • -<% else%> - <% if exercise.exercise_status == 2%> - <%# if has_commit%> - - <%#else%> - <%= link_to exercise_name, exercise_path(exercise.id), :class => "polls_title polls_title_st fl c_dblue"%> - <%#end%> - <% end%> -
    • <%= format_date exercise.created_at.to_date%>
    • +<%# has_commit = has_commit_poll?(poll.id ,User.current)%> +<% exercise_name = exercise.exercise_name.empty? ? l(:label_poll_new) : exercise.exercise_name%> +<% if @is_teacher%> +
    • +
      + <%# if has_commit %> + <%#= link_to poll_name, poll_result_poll_path(poll.id), :class => "polls_title polls_title_w fl c_dblue"%> + <%# else %> + <%#= link_to poll_name, exercise_path(poll.id), :class => "polls_title polls_title_w fl c_dblue" %> + <%# end %> + <%= link_to (index.to_i+1).to_s+". "+exercise_name, exercise_path(exercise.id), :class => "polls_title polls_title_w fl c_dblue" %> +
      +
    • + + <%# if exercise.exercise_status == 2 %> + + <%# else %> + + <%# end%> + + <%# if exercise.exercise_status == 1%> + + <%# elsif exercise.exercise_status == 2 || exercise.exercise_status == 3 %> + + <%# end%> + <% if exercise.exercise_status == 1 %> +
    • 发布试卷
    • + <% elsif exercise.exercise_status == 2%> +
    • 取消发布
    • + <% else%> +
    • 发布试卷
    • + <% end%> + + <% if exercise.exercise_status == 1%> +
    • 统计结果
    • + <% else %> +
    • <%= link_to l(:label_statistical_results), student_exercise_list_exercise_path(exercise.id,:course_id => @course.id), :class => "pollsbtn fr mr10"%>
    • + <% end%> + + <%= link_to(l(:button_delete), exercise,:method => :delete, :confirm => l(:text_are_you_sure), :remote => true, :class => "polls_de fr ml5 mr10") %> + + <% if exercise.exercise_status == 1 %> +
    • <%= link_to l(:button_edit), edit_exercise_path(exercise.id), :class => "polls_de fr ml10"%>
    • +
    • <%=exercise.publish_time.nil? ? "未发布" : "将于"+format_time(exercise.publish_time.to_s)+"发布"%>
    • + <% else%> +
    • 编辑
    • +
    • 已发布
    • + <% end%> + +<% else%> + <% if exercise.exercise_status == 2%> + <%# if has_commit%> + + <%#else%> + <%= link_to (index.to_i+1).to_s+". "+exercise_name, exercise_path(exercise.id), :class => "polls_title polls_title_st fl c_dblue"%> + <%#end%> + <% end%> +
    • 截止时间:<%= format_time(exercise.end_time.to_s)%>
    • <% 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 1f415886f..e283f8b0c 100644 --- a/app/views/exercise/_exercise_form.html.erb +++ b/app/views/exercise/_exercise_form.html.erb @@ -1,194 +1,219 @@ -<%= stylesheet_link_tag 'polls', :media => 'all' %> - -
      -
      - - -
      - <%= render :partial => 'edit_head', :locals => {:exercise => @exercise}%> -
      - <% current_score = get_current_score @exercise %> -
      " id="current_score_div">目前试卷总分:<%=current_score %>分
      - -
      - <%= render :partial => 'exercise_content', :locals => {:exercise => @exercise}%> -
      - -
      - <%= render :partial => 'new_question', :locals => {:exercise => @exercise} %> -
      - - -
      -
      - -
      - <%= render :partial => 'exercise_submit', :locals => {:exercise => @exercise} %> -
      -
      - -
      -
      +<%= stylesheet_link_tag 'polls', :media => 'all' %> + +
      +
      + + +
      + <%= render :partial => 'edit_head', :locals => {:exercise => @exercise} %> +
      + <% current_score = get_current_score @exercise %> +
      " id="current_score_div">目前试卷总分:<%= current_score %> + 分
      + +
      + <%= render :partial => 'exercise_content', :locals => {:exercise => @exercise} %> +
      + +
      + <%= render :partial => 'new_question', :locals => {:exercise => @exercise} %> +
      + + + +
      +
      + +
      + <%= render :partial => 'exercise_submit', :locals => {:exercise => @exercise} %> +
      +
      + +
      +
      diff --git a/app/views/exercise/_exercise_student.html.erb b/app/views/exercise/_exercise_student.html.erb index 45d6ccf70..a5c0f2a46 100644 --- a/app/views/exercise/_exercise_student.html.erb +++ b/app/views/exercise/_exercise_student.html.erb @@ -3,6 +3,8 @@ $("#RSide").removeAttr("id"); $("#homework_page_right").css("min-height",$("#LSide").height()-30); $("#Container").css("width","1000px"); + end_time = <%=exercise.end_time.to_i%> + getTime(end_time); /*start_time = new Date(); start_time.setFullYear(<%#=exercise_user.start_at.year%>); start_time.setMonth(<%#=exercise_user.start_at.month%>); @@ -17,11 +19,16 @@ function getTime(end_time) { //alert(end_time); now = new Date(); - var total_seconds = (now.getTime() - end_time)/1000; + var total_seconds = now.getTime()/1000 - end_time; + if (total_seconds > 0) { + $("#exercise_submit_btn").click(); + return; + } + setTimeout("getTime("+end_time+");", 1000); //start = new Date(start_time); //end_time = start_time; //var total_seconds = total_seconds - 1; - var hours = total_seconds / 60 / 60; + /*var hours = total_seconds / 60 / 60; var hoursRound = Math.floor(hours); var minutes = total_seconds /60 - (60 * hoursRound); var minutesRound = Math.floor(minutes); @@ -29,9 +36,9 @@ var secondsRound = Math.round(seconds); $("#rest_hours").html(hoursRound); $("#rest_minutes").html(minutesRound); - $("#rest_seconds").html(secondsRound); + $("#rest_seconds").html(secondsRound);*/ //if(total_seconds >0) { - setTimeout("getTime("+end_time+");", 1000); + //setTimeout("getTime("+end_time+");", 1000); //} } @@ -41,8 +48,11 @@

      <%= exercise.exercise_name%>

      - 开始时间:<%=format_time(exercise_user.start_at.to_s)%> - 测验时长:<%=exercise.time %>分钟 + 开始时间:<%=Time.parse(h(exercise_user.start_at)).strftime("%Y-%m-%d %H:%M:%S")%> + 截止时间:<%=Time.parse(h(exercise.end_time)).strftime("%Y-%m-%d %H:%M:%S")%> + <% unless exercise.time == -1 %> + 测验时长:<%=exercise.time %>分钟 + <% end %> @@ -191,7 +201,7 @@ } - > + >
    @@ -199,7 +209,7 @@ <% end %>
    - <%= link_to l(:button_submit),commit_exercise_exercise_path(exercise), :method => :post,:class => "ur_button_submit",:style => "margin-left:80px;",:format => 'js',:remote=>true %> + <%= link_to l(:button_submit),commit_exercise_exercise_path(exercise),:id=>"exercise_submit_btn", :method => :post,:class => "ur_button_submit",:style => "margin-left:80px;",:format => 'js',:remote=>true %>
    diff --git a/app/views/exercise/_exercise_student_result.html.erb b/app/views/exercise/_exercise_student_result.html.erb index b9306b0d2..93e52b0a1 100644 --- a/app/views/exercise/_exercise_student_result.html.erb +++ b/app/views/exercise/_exercise_student_result.html.erb @@ -10,8 +10,11 @@

    <%= exercise.exercise_name%>

    - 开始时间:<%=format_time(exercise_user.start_at.to_s) %> - 测验时长:<%=exercise.time %>分钟 + 开始时间:<%=Time.parse(h(exercise_user.start_at)).strftime("%Y-%m-%d %H:%M:%S") %> + 截止时间:<%=Time.parse(h(exercise.end_time)).strftime("%Y-%m-%d %H:%M:%S")%> + <% unless exercise.time == -1 %> + 测验时长:<%=exercise.time %>分钟 + <% end %> <%# time = exercise_user.end_at - exercise_user.start_at %>
    <%= exercise.exercise_description.nil? ? "" : exercise.exercise_description.html_safe%>
    @@ -31,12 +34,12 @@ <% answer = get_user_answer(exercise_question, User.current)%> <% standard_answer = get_user_standard_answer(exercise_question, User.current)%> - <% if answer.first.exercise_choice.choice_position == standard_answer.first.exercise_choice_id %> + <% if !answer.empty? && !standard_answer.empty? && answer.first.exercise_choice.choice_position == standard_answer.first.exercise_choice_id %> √ <% else %> × <% end %>
    - 标准答案:<%= convert_to_char(exercise_question.exercise_standard_answers.first.exercise_choice_id.to_s) %> + 标准答案:<%= convert_to_char(exercise_question.exercise_standard_answers.first.exercise_choice_id.to_s) if exercise_question.exercise_standard_answers.first %>
    @@ -70,7 +73,7 @@ <% answer = get_user_answer(exercise_question, User.current)%> <% standard_answer = get_user_standard_answer(exercise_question, User.current)%> - <% if get_mulscore(exercise_question, User.current).to_i == standard_answer.first.exercise_choice_id %> + <% if !standard_answer.empty? && get_mulscore(exercise_question, User.current).to_i == standard_answer.first.exercise_choice_id %> √ <% else %> × @@ -109,12 +112,12 @@ <% answer = get_user_answer(exercise_question, User.current)%> <% standard_answer = get_user_standard_answer(exercise_question, User.current)%> - <% if standard_answer.include?(answer.first.answer_text) %> + <% if !answer.empty? && !standard_answer.empty? && standard_answer.include?(answer.first.answer_text) %> √ <% else %> × <% end %>
    - 标准答案:<%= convert_to_char(exercise_question.exercise_standard_answers.first.exercise_choice_id.to_s) %> + 标准答案:<%= convert_to_char(exercise_question.exercise_standard_answers.first.exercise_choice_id.to_s) if exercise_question.exercise_standard_answers.first %>
    diff --git a/app/views/exercise/_exercise_submit_info.html.erb b/app/views/exercise/_exercise_submit_info.html.erb index 0d7e8928c..0744b4fd1 100644 --- a/app/views/exercise/_exercise_submit_info.html.erb +++ b/app/views/exercise/_exercise_submit_info.html.erb @@ -19,14 +19,9 @@ <% mc_count = exercise.exercise_questions.where("question_type=1").count %> <% mcq_count = exercise.exercise_questions.where("question_type=2").count %> <% single_count = exercise.exercise_questions.where("question_type=3").count %> -

    当前测验 - <% if question_count > 0 %>共有<%= question_count %>道题,其中<% end %> - <% if mc_count > 0 %><%= mc_count %>道单选、<% end %> - <% if mcq_count > 0 %><%= mcq_count %>道多选、<% end %> - <% if single_count > 0%><%= single_count %>道填空,<% end %> - 总分为<%=current_score %>分。 +

    当前测验<%if question_count >0%>共有<%= question_count %>道题,其中<%end%><%if mc_count > 0%><%=mc_count %>道单选、<%end%><%if mcq_count > 0%><%=mcq_count %>道多选、<%end%><%if single_count > 0%><%=single_count %>道填空,<%end%>总分为<%=current_score %>分。

    - 是否确定提交该测验? + <% if exercise.publish_time.nil? %>点击提交后测验将立即发布,<% end %>是否确定提交该测验?

    diff --git a/app/views/exercise/_exercise_teacher.html.erb b/app/views/exercise/_exercise_teacher.html.erb index a3f6380cf..6e00fc41d 100644 --- a/app/views/exercise/_exercise_teacher.html.erb +++ b/app/views/exercise/_exercise_teacher.html.erb @@ -10,9 +10,13 @@

    <%= exercise.exercise_name%>

    - 发布时间:<%=format_time(exercise.publish_time.to_s) %> - 截止时间:<%=format_time(exercise.end_time.to_s) %> - 测验时长:<%=exercise.time %>分钟 + <% unless exercise.publish_time.nil? %> + 发布时间:<%=Time.parse(h(exercise.publish_time)).strftime("%Y-%m-%d %H:%M:%S") %> + <% end %> + 截止时间:<%=Time.parse(h(exercise.end_time)).strftime("%Y-%m-%d %H:%M:%S") %> + <% if exercise.time != -1 %> + 测验时长:<%=exercise.time %>分钟 + <% end %>
    <%= exercise.exercise_description.nil? ? "" : exercise.exercise_description.html_safe%>
    diff --git a/app/views/exercise/_exercises_list.html.erb b/app/views/exercise/_exercises_list.html.erb index d1774f637..89964f032 100644 --- a/app/views/exercise/_exercises_list.html.erb +++ b/app/views/exercise/_exercises_list.html.erb @@ -1,25 +1,25 @@ -
    -

    所有试卷 - (<%= @obj_count%>) -

    - <% if @is_teacher%> - <%#= link_to "导入", other_poll_poll_index_path(:polls_group_id => @course.id), :remote=>true,:class => "newbtn"%> - <%= link_to "新建试卷 ", new_exercise_path(:course_id => @course.id), :class => "newbtn" %> - <% end%> -
    -
    -
    - - <% @exercises.each do |exercise|%> -
      - <%= render :partial => 'exercise', :locals => {:exercise => exercise} %> -
    -
    - <% end%> - -
      - <%= pagination_links_full @obj_pages, @obj_count, :per_page_links => false, :remote => false, :flag => true%> -
    - -
    +
    +

    所有试卷 + (<%= @obj_count%>) +

    + <% if @is_teacher%> + <%#= link_to "导入", other_poll_poll_index_path(:polls_group_id => @course.id), :remote=>true,:class => "newbtn"%> + <%= link_to "新建试卷 ", new_exercise_path(:course_id => @course.id), :class => "newbtn" %> + <% end%> +
    +
    +
    + + <% @exercises.each_with_index do |exercise,index|%> +
      + <%= render :partial => 'exercise', :locals => {:exercise => exercise,:index => index} %> +
    +
    + <% end%> + +
      + <%= pagination_links_full @obj_pages, @obj_count, :per_page_links => false, :remote => false, :flag => true%> +
    + +
    \ No newline at end of file diff --git a/app/views/exercise/_new_MC.html.erb b/app/views/exercise/_new_MC.html.erb index d65e01ca7..0d7350570 100644 --- a/app/views/exercise/_new_MC.html.erb +++ b/app/views/exercise/_new_MC.html.erb @@ -1,60 +1,62 @@ -<%= form_for(ExerciseQuestion.new, - :html => { :multipart => true }, - :url=>create_exercise_question_exercise_path(exercise.id), - :remote=>true ) do |f| %> -
    +<%= form_for(ExerciseQuestion.new, + :html => { :multipart => true }, + :url=>create_exercise_question_exercise_path(exercise.id), + :remote=>true ) do |f| %> +
    +
    + + + +
    +
    +
      +
    • + <% score = exercise.exercise_questions.where("question_type=1").last.nil? ? "": exercise.exercise_questions.where("question_type=1").last.question_score %> + + 分 +
    • +
      +
      +
    • + + + + +
    • +
      +
    • + + + + +
    • +
      +
    • + + + + +
    • +
      +
    • + + + + +
    • +
      +
      +
    • + + +
    • +
      +
    +
    + +
    +
    <% 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 0555b997c..3ea198d8f 100644 --- a/app/views/exercise/_new_MCQ.html.erb +++ b/app/views/exercise/_new_MCQ.html.erb @@ -1,60 +1,62 @@ -<%= form_for(ExerciseQuestion.new, - :html => { :multipart => true }, - :url=>create_exercise_question_exercise_path(exercise.id), - :remote=>true ) do |f| %> -
    -
    - - - -
    -
    -
      -
    • - <% score = exercise.exercise_questions.where("question_type=2").last.nil? ? "": exercise.exercise_questions.where("question_type=2").last.question_score %> - - 分 -
    • -
      -
    • - - - - -
    • -
      -
    • - - - - -
    • -
      -
    • - - - - -
    • -
      -
    • - - - - -
    • -
      -
    • - - -
    • -
      -
    -
    - -
    -
    +<%= form_for(ExerciseQuestion.new, + :html => { :multipart => true }, + :url=>create_exercise_question_exercise_path(exercise.id), + :remote=>true ) do |f| %> +
    +
    + + + +
    +
    +
      +
    • + <% score = exercise.exercise_questions.where("question_type=2").last.nil? ? "": exercise.exercise_questions.where("question_type=2").last.question_score %> + + 分 +
    • +
      +
      +
    • + + + + +
    • +
      +
    • + + + + +
    • +
      +
    • + + + + +
    • +
      +
    • + + + + +
    • +
      +
      +
    • + + +
    • +
      +
    +
    + +
    +
    <% 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 08b31087a..061b053fd 100644 --- a/app/views/exercise/_new_single.html.erb +++ b/app/views/exercise/_new_single.html.erb @@ -8,7 +8,7 @@
    -
    +
    • <% score = exercise.exercise_questions.where("question_type=3").last.nil? ? "": exercise.exercise_questions.where("question_type=3").last.question_score %> @@ -16,26 +16,28 @@
    • -
    • - - - - -
    • -
      -
    • - - - - -
    • -
      -
    • - - - - -
    • +
      +
    • + + + + +
    • +
      +
    • + + + + +
    • +
      +
    • + + + + +
    • +
    diff --git a/app/views/exercise/_show_MC.html.erb b/app/views/exercise/_show_MC.html.erb index f6ee29266..d052bd6da 100644 --- a/app/views/exercise/_show_MC.html.erb +++ b/app/views/exercise/_show_MC.html.erb @@ -1,111 +1,111 @@ -
    -
    第<%= exercise_question.question_number%>题.(<%= exercise_question.question_score %>分)
    - <%= exercise_question.question_title %> - (<%= convert_to_char(exercise_question.exercise_standard_answers.first.exercise_choice_id.to_s) %>) -
    - - <%= link_to("", delete_exercise_question_exercise_index_path(:exercise_question => exercise_question.id, :quest_num => exercise_question.question_number), - method: :delete, :confirm => l(:text_are_you_sure), :remote => true, :class => "ur_icon_de") %> - - -
    -
    - - - <% exercise_question.exercise_choices.reorder("choice_position").each_with_index do |exercise_choice,index| %> - - - - <% end %> - -
    - -
    -
    -
    - -
    -
    - - \ 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 d7a7c2b6d..a477303d7 100644 --- a/app/views/exercise/_show_MCQ.html.erb +++ b/app/views/exercise/_show_MCQ.html.erb @@ -1,109 +1,109 @@ -
    -
    第<%= exercise_question.question_number%>题.(<%= exercise_question.question_score %>分)
    - <%= exercise_question.question_title %> - (<%= convert_to_char(exercise_question.exercise_standard_answers.first.exercise_choice_id.to_s) %>) -
    - <%= link_to("", delete_exercise_question_exercise_index_path(:exercise_question => exercise_question.id, :quest_num => exercise_question.question_number), - method: :delete, :confirm => l(:text_are_you_sure), :remote => true, :class => "ur_icon_de") %> - - -
    -
    - - - <% exercise_question.exercise_choices.reorder("choice_position").each_with_index do |exercise_choice,index| %> - - - - <% end %> - -
    - -
    -
    -
    - -
    -
    - - \ No newline at end of file diff --git a/app/views/exercise/_show_head.html.erb b/app/views/exercise/_show_head.html.erb index ac7c1c162..f385e58b8 100644 --- a/app/views/exercise/_show_head.html.erb +++ b/app/views/exercise/_show_head.html.erb @@ -3,9 +3,14 @@

    <%= exercise.exercise_name%>

    - 发布时间:<%=Time.parse(format_time(exercise.publish_time)).strftime("%Y-%m-%d %H:%M:%S") if exercise.publish_time%> - 截止时间:<%=Time.parse(format_time(exercise.end_time)).strftime("%Y-%m-%d %H:%M:%S") if exercise.end_time %> - 测验时长:<%= exercise.time %>分钟
    + <% unless exercise.publish_time.nil? %> + 发布时间:<%=Time.parse(h(exercise.publish_time)).strftime("%Y-%m-%d %H:%M:%S") if exercise.publish_time%> + <% end %> + 截止时间:<%=Time.parse(h(exercise.end_time)).strftime("%Y-%m-%d %H:%M:%S") if exercise.end_time %> + <% if exercise.time != -1 %> + 测验时长:<%= exercise.time %>分钟 + <% end %> +
    <%= exercise.exercise_description.nil? ? "" : exercise.exercise_description.html_safe%>
    diff --git a/app/views/exercise/_show_single.html.erb b/app/views/exercise/_show_single.html.erb index a6bb5afe9..86203b8bb 100644 --- a/app/views/exercise/_show_single.html.erb +++ b/app/views/exercise/_show_single.html.erb @@ -1,85 +1,85 @@ -
    -
    第<%= exercise_question.question_number%>题.(<%= exercise_question.question_score %>分)
    - <%= exercise_question.question_title %> -
    - <%= link_to("", delete_exercise_question_exercise_index_path(:exercise_question => exercise_question.id, :quest_num => exercise_question.question_number), - method: :delete, :confirm => l(:text_are_you_sure), :remote => true, :class => "ur_icon_de") %> - - -
    -
    - <% exercise_question.exercise_standard_answers.reorder("created_at").each_with_index do |exercise_choice,index| %> - 候选答案:<%= exercise_choice.answer_text%>
    - <% end %> -
    -
    - -
    -
    - - \ No newline at end of file diff --git a/app/views/exercise/commit_exercise.js.erb b/app/views/exercise/commit_exercise.js.erb index 2a40df2a5..5ede8a951 100644 --- a/app/views/exercise/commit_exercise.js.erb +++ b/app/views/exercise/commit_exercise.js.erb @@ -1,4 +1,4 @@ -$('#ajax-modal').html('<%= escape_javascript(render :partial => 'commit_alert',:locals => {:status => @status}) %>'); +$('#ajax-modal').html('<%= escape_javascript(render :partial => 'commit_alert',:locals => {:status => @status,:exercise =>@exercise}) %>'); showModal('ajax-modal', '270px'); $('#ajax-modal').css('height','110px'); $('#ajax-modal').siblings().remove(); diff --git a/app/views/exercise/index.html.erb b/app/views/exercise/index.html.erb index 3cff84e1c..9b6961e6c 100644 --- a/app/views/exercise/index.html.erb +++ b/app/views/exercise/index.html.erb @@ -1,63 +1,68 @@ -<%= stylesheet_link_tag 'polls', :media => 'all' %> - -
    - <%= render :partial => 'exercises_list'%> +<%= stylesheet_link_tag 'polls', :media => 'all' %> + +
    + <%= render :partial => 'exercises_list'%>
    \ No newline at end of file diff --git a/app/views/exercise/publish_exercise.js.erb b/app/views/exercise/publish_exercise.js.erb index ac2899402..c1c4a4fd5 100644 --- a/app/views/exercise/publish_exercise.js.erb +++ b/app/views/exercise/publish_exercise.js.erb @@ -1,4 +1,4 @@ -$("#exercises_<%= @exercise.id %>").html("<%= escape_javascript(render :partial => 'exercise',:locals => {:exercise => @exercise}) %>"); +$("#exercises_<%= @exercise.id %>").html("<%= escape_javascript(render :partial => 'exercise',:locals => {:exercise => @exercise,:index =>@index}) %>"); $('#ajax-modal').html("<%= escape_javascript(render :partial => 'alert', locals: { :message => l(:label_memo_create_succ)}) %>"); showModal('ajax-modal', '250px'); //$('#ajax-modal').css('height','111px'); diff --git a/app/views/exercise/republish_exercise.js.erb b/app/views/exercise/republish_exercise.js.erb index b7172fe9e..2b4e67606 100644 --- a/app/views/exercise/republish_exercise.js.erb +++ b/app/views/exercise/republish_exercise.js.erb @@ -1,4 +1,4 @@ -$("#exercises_<%= @exercise.id %>").html("<%= escape_javascript(render :partial => 'exercise',:locals => {:exercise => @exercise}) %>"); +$("#exercises_<%= @exercise.id %>").html("<%= escape_javascript(render :partial => 'exercise',:locals => {:exercise => @exercise,:index => @index}) %>"); $('#ajax-modal').html("<%= escape_javascript(render :partial => 'alert', locals: { :message => l(:label_poll_republish_success)}) %>"); showModal('ajax-modal', '250px'); //$('#ajax-modal').css('height','80px'); diff --git a/app/views/exercise/student_exercise_list.html.erb b/app/views/exercise/student_exercise_list.html.erb index 8653836ca..2e51d61af 100644 --- a/app/views/exercise/student_exercise_list.html.erb +++ b/app/views/exercise/student_exercise_list.html.erb @@ -73,7 +73,7 @@
      <% @all_exercises.each_with_index do |exercise,index |%>
    • - <%= link_to "作业#{@all_exercises.count - index}:#{exercise.exercise_name}",''%> + <%= link_to "测验#{@all_exercises.count - index}:#{exercise.exercise_name}",student_exercise_list_exercise_path(exercise.id,:course_id => @course.id)%> <%#= link_to "第#{@homework_commons.count - index}次作业",student_work_index_path(:homework => homework_common.id)%>
    • <% end%> diff --git a/db/schema.rb b/db/schema.rb index 8b018ecd7..ced4e23f5 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,11 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20151120134208) do +<<<<<<< HEAD +ActiveRecord::Schema.define(:version => 20151124032319) do +======= +ActiveRecord::Schema.define(:version => 20151120115137) do +>>>>>>> 1ae514ca4857d7e2ad53b338731c1e01f899fb4d create_table "activities", :force => true do |t| t.integer "act_id", :null => false @@ -591,7 +595,7 @@ ActiveRecord::Schema.define(:version => 20151120134208) do end create_table "exercise_questions", :force => true do |t| - t.text "question_title" + t.string "question_title" t.integer "question_type" t.integer "question_number" t.integer "exercise_id" @@ -620,7 +624,7 @@ ActiveRecord::Schema.define(:version => 20151120134208) do end create_table "exercises", :force => true do |t| - t.text "exercise_name" + t.string "exercise_name" t.text "exercise_description" t.integer "course_id" t.integer "exercise_status" @@ -1137,6 +1141,10 @@ ActiveRecord::Schema.define(:version => 20151120134208) do create_table "org_members", :force => true do |t| t.integer "user_id" t.integer "organization_id" +<<<<<<< HEAD + t.string "role" +======= +>>>>>>> 1ae514ca4857d7e2ad53b338731c1e01f899fb4d t.datetime "created_at", :null => false t.datetime "updated_at", :null => false end diff --git a/public/stylesheets/courses.css b/public/stylesheets/courses.css index 5ff34a4e1..17ed37e05 100644 --- a/public/stylesheets/courses.css +++ b/public/stylesheets/courses.css @@ -1156,7 +1156,7 @@ a:hover.btn_cancel{ color:#666;} .mr118 {margin-right:118px !important;} .questionContainer {width:698px; border:1px solid #cbcbcb;background:#eeeeee; padding:10px; margin-bottom:10px;} .questionTitle{ width:644px; height:30px; border:1px solid #cbcbcb; padding-left:5px; background:#fff;} -.examTime {width:40px; border:1px solid #cbcbcb; outline:none; height:28px; text-align:center; padding-left:0px; } +.examTime {width:90px; border:1px solid #cbcbcb; outline:none; height:28px; text-align:center; padding-left:0px; } .testStatus{width:698px; border:1px solid #cbcbcb; padding:10px; margin-bottom:10px; background:#ffffff; position:relative; color:#767676;} .testEdit{ background:url(images/icons.png) 0px -272px no-repeat; width:16px; height:27px; display:block;float:right; bottom:10px; right:10px; position:absolute;} a:hover.testEdit{ background:url(images/icons.png) -21px -272px no-repeat;} @@ -1166,4 +1166,5 @@ a:hover.testEdit{ background:url(images/icons.png) -21px -272px no-repeat;} .questionEditContainer {border:1px solid #cbcbcb;background:#eeeeee; padding:10px; margin-bottom:10px; margin-top:10px;} .fillInput {border:1px solid #cbcbcb; padding-left:5px; background-color:#ffffff; width:693px; height:30px; color:#888888;} .mr130 {margin-right:130px;} +.mr100 {margin-right:100px;} .ur_button_submit{ display:block; width:106px; height:31px; margin:0 auto; background:#15bccf; color:#fff; font-size:16px; text-align:center; padding-top:4px; margin-bottom:10px; } \ No newline at end of file diff --git a/public/stylesheets/polls.css b/public/stylesheets/polls.css index 9f7b2d021..cfc3b1b4a 100644 --- a/public/stylesheets/polls.css +++ b/public/stylesheets/polls.css @@ -89,7 +89,7 @@ a:hover.btn_cancel{ color:#666;} .ur_question_title{ width:534px; height:30px; border:1px solid #cbcbcb; padding-left:5px; margin-right:10px; background:#fff;} .ur_editor_title{ margin-bottom:10px;} .ur_editor_content{ } -.ur_item{ margin-bottom:5px; height:32px; } +.ur_item{ margin-bottom:5px; height:32px; line-height: 32px; vertical-align: middle; } .ur_item input{ width:324px; height:30px;border:1px solid #cbcbcb; padding-left:5px; float:left; margin-right:10px; background:#fff;} .ur_item label{ float:left;} .icon_add{ background:url(images/icons.png) 0px -310px no-repeat; width:16px; height:27px; display:block;float:left; margin-right:5px;}