diff --git a/app/controllers/exercise_controller.rb b/app/controllers/exercise_controller.rb index d53dc067c..6d6d429b6 100644 --- a/app/controllers/exercise_controller.rb +++ b/app/controllers/exercise_controller.rb @@ -1,18 +1,21 @@ class ExerciseController < ApplicationController layout "base_courses" - before_filter :find_exercise_and_course, :only => [:create_exercise_question, :edit, :update, :show, :destroy, :commit_exercise, :commit_answer,:publish_exercise,:republish_exercise] + before_filter :find_exercise_and_course, :only => [:create_exercise_question, :edit, :update, :show, :destroy, :commit_exercise, :commit_answer,:publish_exercise,:republish_exercise,:show_student_result] 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 = @exercise.end_time > Time.now + 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 @@ -49,10 +59,13 @@ class ExerciseController < ApplicationController # @percent = get_percent(@exercise,User.current) exercise_questions = @exercise.exercise_questions @exercise_questions = paginateHelper exercise_questions,5 #分页 + score = calculate_student_score(@exercise, User.current) + eu = get_exercise_user(@exercise.id, User.current.id) + eu.update_attributes(:score => score) respond_to do |format| format.html {render :layout => 'base_courses'} end - end + #end end def new @@ -65,7 +78,6 @@ class ExerciseController < ApplicationController :end_time => "", :publish_time => "", :exercise_description => "", - :show_result => "", :show_result => 1 } @exercise = Exercise.create option @@ -80,7 +92,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 +116,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 +312,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 +327,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,12 +343,12 @@ 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")) + if @is_teacher || (!@exercise.exercise_users.where(:user_id => User.current.id).empty? && @exercise.end_time <= Time.now) @exercise_users_list = @exercise.exercise_users.where('score is not NULL') @show_all = true; - 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") + elsif !@exercise.exercise_users.where(:user_id => User.current.id).empty? && @exercise.end_time > Time.now @exercise_users_list = @exercise.exercise_users.where("user_id = ? and score is not NULL",User.current.id) else @exercise_users_list = [] @@ -346,8 +361,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) || @exercise.end_time < Time.now render :json => {:text => "failure"} return end @@ -364,8 +379,14 @@ class ExerciseController < ApplicationController ea.exercise_choice_id = params[:exercise_choice_id] if ea.save # 保存成功返回成功信息及当前以答题百分比 + uncomplete_question = get_uncomplete_question(@exercise, User.current) + if uncomplete_question.count < 1 + complete = 1; + else + complete = 0; + end @percent = get_percent(@exercise,User.current) - render :json => {:text => "ok" ,:percent => format("%.2f" ,@percent)} + render :json => {:text => "ok" ,:complete => complete,:percent => format("%.2f" ,@percent)} else #返回失败信息 render :json => {:text => "failure"} @@ -380,8 +401,14 @@ class ExerciseController < ApplicationController ea.exercise_question_id = params[:exercise_question_id] ea.exercise_choice_id = params[:exercise_choice_id] if ea.save + uncomplete_question = get_uncomplete_question(@exercise, User.current) + if uncomplete_question.count < 1 + complete = 1; + else + complete = 0; + end @percent = get_percent(@exercise,User.current) - render :json => {:text => "ok",:percent => format("%.2f" ,@percent)} + render :json => {:text => "ok",:complete => complete,:percent => format("%.2f" ,@percent)} else render :json => {:text => "failure"} end @@ -410,8 +437,14 @@ class ExerciseController < ApplicationController ea.exercise_question_id = params[:exercise_question_id] ea.answer_text = params[:answer_text] if ea.save + uncomplete_question = get_uncomplete_question(@exercise, User.current) + if uncomplete_question.count < 1 + complete = 1; + else + complete = 0; + end @percent = get_percent(@exercise,User.current) - render :json => {:text => ea.answer_text,:percent => format("%.2f",@percent)} + render :json => {:text => ea.answer_text,:complete => complete,:percent => format("%.2f",@percent)} else render :json => {:text => "failure"} end @@ -447,6 +480,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 @exercise.publish_time > Time.now + @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: 提示提交成功 @@ -480,6 +524,20 @@ class ExerciseController < ApplicationController end end + #查看学生的答卷情况 + def show_student_result + @user = User.find params[:user_id] + @can_edit_excercise = false + @exercise_user = ExerciseUser.where("user_id =? and exercise_id=?", @user.id, @exercise.id).first + @exercise_questions = @exercise.exercise_questions + score = calculate_student_score(@exercise, @user) + eu = get_exercise_user(@exercise.id, @user.id) + eu.update_attributes(:score => score) + respond_to do |format| + format.html {render :layout => 'base_courses'} + end + end + # 计算学生得分 def calculate_student_score(exercise, user) score = 0 @@ -490,7 +548,7 @@ class ExerciseController < ApplicationController exercise_qustions.each do |question| answer = get_user_answer(question, user) standard_answer = get_user_standard_answer(question, user) - unless answer.nil? + unless answer.empty? # 问答题有多个答案 if question.question_type == 3 if standard_answer.include?(answer.first.answer_text) @@ -532,19 +590,6 @@ class ExerciseController < ApplicationController eu end - #获取未完成的题目 - def get_uncomplete_question exercise,user - all_questions = exercise.exercise_questions - uncomplete_question = [] - all_questions.each do |question| - answers = get_user_answer(question, user) - if answers.nil? - uncomplete_question << question - end - end - uncomplete_question - end - # 获取当前学生回答问题的答案 def get_user_answer(question,user) # user_answer = ExerciseAnswer.where("user_id=? and exercise_question_id=?", user.id, question.id).first @@ -563,7 +608,8 @@ class ExerciseController < ApplicationController standard_answer = question.exercise_standard_answers.first end standard_answer - end # 是否完成了答题 + end + # 是否完成了答题 def get_complete_question(exercise,user) questions = exercise.exercise_questions complete_question = [] diff --git a/app/controllers/org_document_comments_controller.rb b/app/controllers/org_document_comments_controller.rb index 776bd132d..02527bdfc 100644 --- a/app/controllers/org_document_comments_controller.rb +++ b/app/controllers/org_document_comments_controller.rb @@ -39,7 +39,7 @@ class OrgDocumentCommentsController < ApplicationController end respond_to do |format| format.html { - if params[:flag] == 0 + if params[:flag].to_i == 0 redirect_to organization_org_document_comments_path(:organization_id => @org_document.organization.id) else redirect_to org_document_comment_path(@org_document.root.id, :organization_id => @org_document.organization.id) diff --git a/app/controllers/organizations_controller.rb b/app/controllers/organizations_controller.rb index ba4dda939..b326051e6 100644 --- a/app/controllers/organizations_controller.rb +++ b/app/controllers/organizations_controller.rb @@ -161,7 +161,7 @@ class OrganizationsController < ApplicationController def more_org_projects @organization = Organization.find params[:id] @page = params[:page] - @org_projects = @organization.projects.reorder('created_at').page((params[:page].to_i || 1) +1).per(5) + @org_projects = @organization.projects.reorder('created_at').uniq.page((params[:page].to_i || 1) +1).per(5) respond_to do |format| format.js end @@ -170,7 +170,7 @@ class OrganizationsController < ApplicationController def more_org_courses @organization = Organization.find(params[:id]) @page = params[:page] - @org_courses = @organization.courses.reorder('created_at').page((params[:page].to_i || 1) + 1 ).per(5) + @org_courses = @organization.courses.reorder('created_at').uniq.page((params[:page].to_i || 1) + 1 ).per(5) respond_to do |format| format.js end @@ -189,16 +189,17 @@ class OrganizationsController < ApplicationController if !params[:name].nil? condition = "%#{params[:name].strip}%".gsub(" ","") end - #sql = "select courses.* from courses inner join members on courses.id = members.course_id inner join org_courses on courses.id = org_courses.course_id where org_courses.organization_id != #{@organization.id} and members.user_id = #{User.current.id} and courses.name like '#{condition}'" - sql = "select courses.* from courses inner join members on courses.id = members.course_id where members.user_id = #{User.current.id} and courses.name like '#{condition}'" - user_courses = Course.find_by_sql(sql) - @added_course_ids = @organization.courses.map(&:id) - @courses = [] - user_courses.each do |course| - if !@added_course_ids.include?(course.id) - @courses << course - end - end + sql = "select courses.* from courses inner join members on courses.id = members.course_id where members.user_id = #{User.current.id} and courses.name like '#{condition}'"+ + "and courses.id not in (select distinct org_courses.course_id from org_courses where org_courses.organization_id = #{@organization.id})" + #user_courses = Course.find_by_sql(sql) + @courses = Course.find_by_sql(sql) + # @added_course_ids = @organization.courses.map(&:id) + # @courses = [] + # user_courses.each do |course| + # if !@added_course_ids.include?(course.id) + # @courses << course + # end + # end end def join_courses @@ -225,15 +226,17 @@ class OrganizationsController < ApplicationController if !params[:name].nil? condition = "%#{params[:name].strip}%".gsub(" ","") end - sql = "select projects.* from projects inner join members on projects.id = members.project_id where members.user_id = #{User.current.id} and projects.status != 9 and projects.name like '#{condition}'" - user_projects = Course.find_by_sql(sql) - @added_course_ids = @organization.projects.map(&:id) - @projects = [] - user_projects.each do |project| - if !@added_course_ids.include?(project.id) - @projects << project - end - end + sql = "select projects.* from projects inner join members on projects.id = members.project_id where members.user_id = #{User.current.id} and projects.status != 9 and projects.name like '#{condition}'" + + " and projects.id not in (select org_projects.project_id from org_projects where organization_id = #{@organization.id})" + #user_projects = Course.find_by_sql(sql) + @projects = Course.find_by_sql(sql) + # @added_course_ids = @organization.projects.map(&:id) + # @projects = [] + # user_projects.each do |project| + # if !@added_course_ids.include?(project.id) + # @projects << project + # end + # end end def join_projects diff --git a/app/controllers/student_work_controller.rb b/app/controllers/student_work_controller.rb index 7eac379e4..d2aba1386 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/helpers/exercise_helper.rb b/app/helpers/exercise_helper.rb index bb87f3b82..b0d0118e5 100644 --- a/app/helpers/exercise_helper.rb +++ b/app/helpers/exercise_helper.rb @@ -107,6 +107,19 @@ module ExerciseHelper end end + #获取未完成的题目 + def get_uncomplete_question exercise,user + all_questions = exercise.exercise_questions + uncomplete_question = [] + all_questions.each do |question| + answers = get_user_answer(question, user) + if answers.empty? + uncomplete_question << question + end + end + uncomplete_question + end + #获取文本题答案 def get_anwser_vote_text(question_id,user_id) pv = ExerciseAnswer.find_by_exercise_question_id_and_user_id(question_id,user_id) diff --git a/app/views/courses/_tool_expand.html.erb b/app/views/courses/_tool_expand.html.erb index 9a36b8efb..e032496ea 100644 --- a/app/views/courses/_tool_expand.html.erb +++ b/app/views/courses/_tool_expand.html.erb @@ -30,7 +30,7 @@ <% if show_nav?(course_feedback_count) %> <% end %> <% if show_nav?(course_poll_count) %> diff --git a/app/views/exercise/_commit_alert.html.erb b/app/views/exercise/_commit_alert.html.erb index d92ca51fb..e9c3ebf57 100644 --- a/app/views/exercise/_commit_alert.html.erb +++ b/app/views/exercise/_commit_alert.html.erb @@ -1,12 +1,21 @@
- <% if status == 0 %> + <% if status == 0 && exercise.time != -1%>

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

<%= link_to "确定", exercise_path(),:class => 'commit'%> - <% elsif status == 1 %> -

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

- <%= link_to "确定", "javascript:void(0)",:onclick => 'hidden_atert_form();',:class => 'commit'%> - <% else %> + <% 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 && 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 && 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_path(),:class => 'commit'%> + <% 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..b69f52a56 100644 --- a/app/views/exercise/_edit_head.html.erb +++ b/app/views/exercise/_edit_head.html.erb @@ -3,31 +3,38 @@
- <%# 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..f0bef74bf 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..adaab5021 100644 --- a/app/views/exercise/_exercise_student.html.erb +++ b/app/views/exercise/_exercise_student.html.erb @@ -3,6 +3,12 @@ $("#RSide").removeAttr("id"); $("#homework_page_right").css("min-height",$("#LSide").height()-30); $("#Container").css("width","1000px"); + <%uncomplete_question =get_uncomplete_question(exercise, User.current) %>; + <% if (uncomplete_question.count < 1) %> + $("#exercise_submit_btn").html("提交"); + <% end %> + var 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 +23,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 +40,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 +52,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 %> @@ -90,6 +104,11 @@ { obj.checked = false; } + if(dataObj.complete == 1) { + $("#exercise_submit_btn").html("提交"); + } else { + $("#exercise_submit_btn").html("保存"); + } } }); } @@ -144,6 +163,11 @@ { obj.checked = false; } + if(dataObj.complete == 1) { + $("#exercise_submit_btn").html("提交"); + } else { + $("#exercise_submit_btn").html("保存"); + } } }); } @@ -186,12 +210,17 @@ success: function (data) { var dataObj = eval(data); obj.value = dataObj.text; + if(dataObj.complete == 1) { + $("#exercise_submit_btn").html("提交"); + } else { + $("#exercise_submit_btn").html("保存"); + } } }); } - > + >
    @@ -199,7 +228,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 "保存",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..529a73da3 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%>
    @@ -29,14 +32,14 @@
    第<%= list_index+1%>题:<%= exercise_question.question_title %>  (<%= exercise_question.question_score %>分) - <% 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 %> + <% answer = get_user_answer(exercise_question, user)%> + <% standard_answer = get_user_standard_answer(exercise_question, user)%> + <% 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 %>
    @@ -46,7 +49,7 @@ @@ -68,9 +71,9 @@
    第<%= list_index+1%>题:<%= exercise_question.question_title %>  (<%= exercise_question.question_score %>分) - <% 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 %> + <% answer = get_user_answer(exercise_question, user)%> + <% standard_answer = get_user_standard_answer(exercise_question, user)%> + <% if !standard_answer.empty? && get_mulscore(exercise_question, user).to_i == standard_answer.first.exercise_choice_id %> √ <% else %> × @@ -85,7 +88,7 @@ @@ -107,14 +110,14 @@
    第<%= list_index+1%>题:<%= exercise_question.question_title %>  (<%= exercise_question.question_score %>分) - <% 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) %> + <% answer = get_user_answer(exercise_question, user)%> + <% standard_answer = get_user_standard_answer(exercise_question, user)%> + <% 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 %>
    @@ -123,7 +126,7 @@ <% end %>
    - > + >
    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..24687d28b 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%>
    @@ -92,7 +96,7 @@
    第<%= list_index+1%>题:<%= exercise_question.question_title %>  (<%= exercise_question.question_score %>分)
    - 标准答案:<%= 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/_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..cfa814c2e 100644 --- a/app/views/exercise/_show_head.html.erb +++ b/app/views/exercise/_show_head.html.erb @@ -3,10 +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 %>分钟
    -
    <%= exercise.exercise_description.nil? ? "" : exercise.exercise_description.html_safe%>
    -
    + <% 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%>
    \ 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 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/_student_exercise.html.erb b/app/views/exercise/_student_exercise.html.erb index 25bf3f7cd..4e27d57cb 100644 --- a/app/views/exercise/_student_exercise.html.erb +++ b/app/views/exercise/_student_exercise.html.erb @@ -44,7 +44,13 @@