diff --git a/app/controllers/exercise_controller.rb b/app/controllers/exercise_controller.rb index 2a75d0580..75751e4f7 100644 --- a/app/controllers/exercise_controller.rb +++ b/app/controllers/exercise_controller.rb @@ -27,7 +27,7 @@ class ExerciseController < ApplicationController if @is_teacher || User.current.admin? exercises = @course.exercises.order("created_at asc") else - exercises = @course.exercises.where(:exercise_status => 2).order("created_at asc") + exercises = @course.exercises.where("exercise_status <> 1").order("created_at asc") end @exercises = paginateHelper exercises,20 #分页 respond_to do |format| @@ -54,41 +54,26 @@ class ExerciseController < ApplicationController end @exercise = Exercise.find params[:id] @is_teacher = User.current.allowed_to?(:as_teacher,@course) || User.current.admin? - if @exercise.exercise_status != 2 && (!(User.current.allowed_to?(:as_teacher,@course) || User.current.admin?)) - render_403 - return - end 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? + @can_edit_excercise = !has_commit_exercise?(@exercise.id,User.current.id)&& exercise_end 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) + unless @is_teacher + @exercise_user = ExerciseUser.where("user_id=? and exercise_id=?", User.current.id, @exercise.id).first + if @exercise_user.nil? 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 end - # @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 + @exercise_user.update_attributes(:score => score) + end + # @percent = get_percent(@exercise,User.current) + @exercise_questions = @exercise.exercise_questions + respond_to do |format| + format.html {render :layout => 'base_courses'} + end #end end @@ -537,12 +522,9 @@ class ExerciseController < ApplicationController # @score = 100 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 - if eu.save - #redirect_to poll_index_path(:polls_group_id => @course.id,:polls_type => 'Course') + cur_exercise_user.score = @score + if cur_exercise_user.save + #redirect_to poll_index_path(:polls_group_id => @course.id,:polls_type => 'Course') @status = 0 #提交成功 else @status = 2 #未知错误 @@ -550,6 +532,7 @@ class ExerciseController < ApplicationController else @status = 1 #有未做得必答题 end + @save = params[:save].to_i if params[:save] respond_to do |format| format.js end diff --git a/app/views/exercise/_commit_alert.html.erb b/app/views/exercise/_commit_alert.html.erb index e9c3ebf57..bed7b6d82 100644 --- a/app/views/exercise/_commit_alert.html.erb +++ b/app/views/exercise/_commit_alert.html.erb @@ -1,12 +1,15 @@
- <% if status == 0 && exercise.time != -1%> + <% if @save == 1 %> +

保存成功,测验日期截止前您还可以继续答题。

+ <%= link_to "确定", exercise_index_path(:course_id => @course.id),:class => 'commit'%> + <% elsif 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 && 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")%>

时间已到!

diff --git a/app/views/exercise/_exercise.html.erb b/app/views/exercise/_exercise.html.erb index db412672c..19bc520d4 100644 --- a/app/views/exercise/_exercise.html.erb +++ b/app/views/exercise/_exercise.html.erb @@ -24,11 +24,11 @@ <%# end%> <% if exercise.exercise_status == 1 %> -
  • 发布试卷
  • +
  • 发布试卷
  • <% elsif exercise.exercise_status == 2%> -
  • 取消发布
  • +
  • 取消发布
  • <% else%> -
  • 发布试卷
  • +
  • 发布试卷
  • <% end%> <% if exercise.exercise_status == 1%> @@ -42,18 +42,24 @@ <% 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%> + <% elsif exercise.exercise_status == 2 %>
  • 编辑
  • 已发布
  • + <% else %> +
  • 编辑
  • +
  • 已截止
  • <% end%> <% else%> - <% if exercise.exercise_status == 2%> + <% if exercise.exercise_status != 1%> <%# 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"%> + <%= link_to (index.to_i+1).to_s+". "+exercise_name, exercise_path(exercise.id), :class => "polls_title polls_title_st fl c_dblue"%> + <% if exercise.end_time <= Time.now && has_commit_exercise?(exercise.id, User.current.id) %> +
  • 已答
  • + <% end %> <%#end%> <% end%>
  • 截止时间:<%= format_time(exercise.end_time.to_s)%>
  • diff --git a/app/views/exercise/_exercise_student.html.erb b/app/views/exercise/_exercise_student.html.erb index adaab5021..8a1f3dbd6 100644 --- a/app/views/exercise/_exercise_student.html.erb +++ b/app/views/exercise/_exercise_student.html.erb @@ -3,10 +3,6 @@ $("#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(); @@ -104,11 +100,6 @@ { obj.checked = false; } - if(dataObj.complete == 1) { - $("#exercise_submit_btn").html("提交"); - } else { - $("#exercise_submit_btn").html("保存"); - } } }); } @@ -163,11 +154,6 @@ { obj.checked = false; } - if(dataObj.complete == 1) { - $("#exercise_submit_btn").html("提交"); - } else { - $("#exercise_submit_btn").html("保存"); - } } }); } @@ -210,11 +196,6 @@ success: function (data) { var dataObj = eval(data); obj.value = dataObj.text; - if(dataObj.complete == 1) { - $("#exercise_submit_btn").html("提交"); - } else { - $("#exercise_submit_btn").html("保存"); - } } }); @@ -228,7 +209,8 @@ <% end %>
    - <%= 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 %> + <%= link_to "保存",commit_exercise_exercise_path(exercise,:save => 1),:id=>"exercise_submit_btn", :method => :post,:class => "ur_button_submit",:format => 'js',:remote=>true %> + <%= link_to "提交",commit_exercise_exercise_path(exercise), :data => {:confirm => "您确定要提交吗?"},:id=>"exercise_submit_btn", :method => :post,:class => "ur_button_submit",:style => "margin-left:20px;",: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 529a73da3..58ebcaf20 100644 --- a/app/views/exercise/_exercise_student_result.html.erb +++ b/app/views/exercise/_exercise_student_result.html.erb @@ -78,7 +78,7 @@ <% else %> × <% end %>
    - 标准答案:<%= convert_to_char(exercise_question.exercise_standard_answers.first.exercise_choice_id.to_s) %> + 标准答案:<%= convert_to_char(standard_answer.first.exercise_choice_id.to_s) if !standard_answer.empty? %>
    diff --git a/app/views/exercise/_student_exercise.html.erb b/app/views/exercise/_student_exercise.html.erb index 9c9916e60..9b07e0626 100644 --- a/app/views/exercise/_student_exercise.html.erb +++ b/app/views/exercise/_student_exercise.html.erb @@ -38,9 +38,9 @@ $("#show_student_result_div").on('click',show_result); <% else %> $("#show_student_result_div").attr("title","截止日期未到,暂不能查看学生答题结果"); - $("#student_name_id").attr("title","截止日期未到,暂不能查看学生答题结果"); - $("#student_id_id").attr("title","截止日期未到,暂不能查看学生答题结果"); - $("#student_class_id").attr("title","截止日期未到,暂不能查看学生答题结果"); + $("#student_name_<%= exercise.id%>").attr("title","截止日期未到,暂不能查看学生答题结果"); + $("#student_id_<%= exercise.id%>").attr("title","截止日期未到,暂不能查看学生答题结果"); + $("#student_class_<%= exercise.id%>").attr("title","截止日期未到,暂不能查看学生答题结果"); <% end %> }); function show_result() { @@ -56,13 +56,13 @@
    • -
    • +
    • <%=exercise.user.show_name %>
    • -
    • +
    • <%= exercise.user.user_extensions.nil? ? "--" : exercise.user.user_extensions.student_id%>
    • -
    • +
    • --
    diff --git a/app/views/exercise/commit_exercise.js.erb b/app/views/exercise/commit_exercise.js.erb index 5ede8a951..ac8c242d1 100644 --- a/app/views/exercise/commit_exercise.js.erb +++ b/app/views/exercise/commit_exercise.js.erb @@ -1,6 +1,5 @@ $('#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(); $('#ajax-modal').before("" + ""); diff --git a/app/views/exercise/edit.html.erb b/app/views/exercise/edit.html.erb index 0b20dc90e..48d307c78 100644 --- a/app/views/exercise/edit.html.erb +++ b/app/views/exercise/edit.html.erb @@ -1 +1,9 @@ -<%= render :partial => 'exercise_form'%> \ No newline at end of file +<%= render :partial => 'exercise_form'%> + diff --git a/app/views/layouts/base_courses.html.erb b/app/views/layouts/base_courses.html.erb index c37af0dc1..e0a6ece50 100644 --- a/app/views/layouts/base_courses.html.erb +++ b/app/views/layouts/base_courses.html.erb @@ -188,10 +188,10 @@ <%= link_to( "", new_poll_path(:polls_type => "Course",:polls_group_id => @course.id), :class => 'courseMenuSetting', :title =>"#{l(:label_new_poll)}") if is_teacher %>
  • <% end %> - <% unless show_nav?(User.current.allowed_to?(:as_teacher,@course)? @course.exercises.count : @course.exercises.where("exercise_status=2").count) %> + <% unless show_nav?(User.current.allowed_to?(:as_teacher,@course)? @course.exercises.count : @course.exercises.where("exercise_status <> 1").count) %> <% end %> diff --git a/app/views/student_work/_new_student_work_alert.html.erb b/app/views/student_work/_new_student_work_alert.html.erb index 8e0c8a954..42a891d60 100644 --- a/app/views/student_work/_new_student_work_alert.html.erb +++ b/app/views/student_work/_new_student_work_alert.html.erb @@ -2,7 +2,11 @@

    当前作业 - 已开启匿评 + <% if @homework.homework_detail_manual.comment_status == 2 %> + 已开启匿评 + <% elsif @homework.homework_detail_manual.comment_status == 3 %> + 已关闭匿评 + <% end %> 您提交作品后将 不会收到任何匿评作品, 您的作品也 diff --git a/app/views/student_work/_show.html.erb b/app/views/student_work/_show.html.erb index 801c252cb..f92614e10 100644 --- a/app/views/student_work/_show.html.erb +++ b/app/views/student_work/_show.html.erb @@ -46,7 +46,12 @@ <% if @homework.homework_detail_group.base_on_project == 1 %>

  • 关联项目: - <%= link_to( work.project.name, project_path(work.project.id), :class => "linkBlue" )%> + <% if work.project.is_public || User.current.member_of?(work.project) || User.current.admin? %> + <%= link_to( work.project.name, project_path(work.project.id), :class => "linkBlue" )%> + <% else %> + <%=work.project.name %> + <% end %> + <%#= link_to( work.project.name, project_path(work.project.id), :class => "linkBlue" )%> (综合评分:<%=work.project.project_score.score.to_i %>)
  • <% end %> diff --git a/app/views/users/_course_homework.html.erb b/app/views/users/_course_homework.html.erb index b38a17bea..a3aa5d5b1 100644 --- a/app/views/users/_course_homework.html.erb +++ b/app/views/users/_course_homework.html.erb @@ -51,7 +51,7 @@ 系统提示:该作业要求各组长提交作品,提交作品时请添加组成员。谢谢配合! <% end %>
    - <% if activity.homework_type == 3 && !is_teacher && activity.homework_detail_group.base_on_project == 1 %> + <% if activity.homework_type == 3 && !is_teacher && activity.homework_detail_group.base_on_project == 1 && User.current.member_of_course?(activity.course)%> <% projects = cur_user_projects_for_homework activity %> <% works = cur_user_works_for_homework activity %> <% if works.nil? && projects.nil? %> @@ -105,8 +105,8 @@
    <% activity.student_work_projects.where("is_leader = 1").each do |pro| %>
    - <% project = Project.find pro.project_id || User.current.member_of?(project) || User.current.admin? %> - <% if project.is_public || project.user_id == User.current.id %> + <% project = Project.find pro.project_id %> + <% if project.is_public || User.current.member_of?(project) || User.current.admin?%> <%= link_to image_tag(url_to_avatar(project),:width=>"40",:height => "40",:class => "borderRadius"),project_path(project.id,:host=>Setting.host_name),:alt =>"项目头像" %> <% else %> <%= image_tag(url_to_avatar(project),:width=>"40",:height => "40",:class => "borderRadius") %> diff --git a/app/views/users/_user_homework_detail.html.erb b/app/views/users/_user_homework_detail.html.erb index 57fe57c07..4217cf1a9 100644 --- a/app/views/users/_user_homework_detail.html.erb +++ b/app/views/users/_user_homework_detail.html.erb @@ -49,7 +49,7 @@ 系统提示:该作业要求各组长<%=link_to "创建项目", new_project_path(:host=>Setting.host_name),:class=>"c_red",:title=>"新建项目",:style=>"text-decoration:underline;"%>,组成员加入项目,然后由组长关联项目。谢谢配合! <% end %>
    - <% if homework_common.homework_type == 3 && !is_teacher && homework_common.homework_detail_group.base_on_project == 1%> + <% if homework_common.homework_type == 3 && !is_teacher && homework_common.homework_detail_group.base_on_project == 1 && User.current.member_of_course?(homework_common.course) %> <% projects = cur_user_projects_for_homework homework_common %> <% works = cur_user_works_for_homework homework_common %> <% if works.nil? && projects.nil? %> @@ -108,8 +108,8 @@ <% homework_common.student_work_projects.where("is_leader = 1").each do |pro| %>
    <% project = Project.find pro.project_id %> - <% if project.is_public == 1 || User.current.member_of?(project) || User.current.admin? %> - <%=link_to image_tag(url_to_avatar(project),:width=>"40",:height => "40",:class => "borderRadius"),project_path(project.id,:host=>Setting.host_name) %> + <% if project.is_public || User.current.member_of?(project) || User.current.admin? %> + <%= link_to image_tag(url_to_avatar(project),:width=>"40",:height => "40",:class => "borderRadius"),project_path(project.id,:host=>Setting.host_name),:alt =>"项目头像" %> <% else %> <%= image_tag(url_to_avatar(project),:width=>"40",:height => "40",:class => "borderRadius") %> <% end %> diff --git a/public/javascripts/course.js b/public/javascripts/course.js index b3618cda4..c147850ef 100644 --- a/public/javascripts/course.js +++ b/public/javascripts/course.js @@ -598,11 +598,11 @@ function regex_evaluation_end(){ } var evaluation_start_time = new Date(evaluation_start); var evaluation_end_time = new Date(evaluation_end); - if(evaluation_end_time > evaluation_start_time){ + if(evaluation_end_time >= evaluation_start_time){ $("#homework_evaluation_end_time").text(""); return true; }else{ - $("#homework_evaluation_end_time").text("关闭匿评日期必须大于开启匿评日期"); + $("#homework_evaluation_end_time").text("关闭匿评日期不能小于开启匿评日期"); return false; } } @@ -1387,4 +1387,4 @@ function submit_course_feedback() { $("#course_feedback_new").submit(); var flag = true } -} +} diff --git a/public/javascripts/new_user.js b/public/javascripts/new_user.js index d375a90ee..67892fe0f 100644 --- a/public/javascripts/new_user.js +++ b/public/javascripts/new_user.js @@ -213,11 +213,11 @@ function regex_evaluation_end(){ } var evaluation_start_time = new Date(evaluation_start); var evaluation_end_time = new Date(evaluation_end); - if(evaluation_end_time > evaluation_start_time){ + if(evaluation_end_time >= evaluation_start_time){ $("#homework_evaluation_end_time").text(""); return true; }else{ - $("#homework_evaluation_end_time").text("关闭匿评日期必须大于开启匿评日期"); + $("#homework_evaluation_end_time").text("关闭匿评日期不能小于开启匿评日期"); return false; } } diff --git a/public/stylesheets/polls.css b/public/stylesheets/polls.css index cfc3b1b4a..bcace8cf2 100644 --- a/public/stylesheets/polls.css +++ b/public/stylesheets/polls.css @@ -145,7 +145,7 @@ a:hover.btn_pu{ background:#3cb761;} /*问卷提交时弹出框*/ .alert_box{width:250px;height:180px;position:fixed !important;z-index:100;left:60%;top:65%;margin:-215px 0 0 -300px; background:#fff; -moz-border-radius:5px; -webkit-border-radius:5px; border-radius:5px; box-shadow:0px 0px 8px #194a81; overflow:auto;} -.commit{height: 28px;display: block;width: 80px;color: #fff !important;background: #15bccf;text-align: center;padding-top: 4px;margin-left: 60px;margin-top: 4px;margin-right: 10px;} +.commit{font-size: 1.2em;height: 28px;display: block;width: 80px;color: #fff !important;background: #15bccf;text-align: center;padding-top: 4px;margin-left: 70px;margin-top: 4px;margin-right: 10px;} /******确定弹框***********/ .poll_alert_form{width:140px;height:180px;position:fixed;z-index:100;left:50%;top:50%;margin:-100px 0 0 -150px; background:#fff; -moz-border-radius:5px; -webkit-border-radius:5px; border-radius:5px; box-shadow:0px 0px 8px #194a81; overflow:auto;} .polls_alert_btn_box{width: 100%;margin: 0 auto;padding-left: 45px;}