From eb8e9f32a34c4ed02e7dfd9adcfc81c2337c5944 Mon Sep 17 00:00:00 2001 From: cxt Date: Mon, 14 Dec 2015 10:06:19 +0800 Subject: [PATCH 01/11] =?UTF-8?q?=E4=BD=9C=E5=93=81=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E7=9A=84=E7=A7=81=E6=9C=89=E9=A1=B9=E7=9B=AE=E4=B8=8D=E5=8F=AF?= =?UTF-8?q?=E7=82=B9=E5=87=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/student_work/_show.html.erb | 7 ++++++- app/views/users/_course_homework.html.erb | 4 ++-- app/views/users/_user_homework_detail.html.erb | 4 ++-- 3 files changed, 10 insertions(+), 5 deletions(-) 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..2096e3c82 100644 --- a/app/views/users/_course_homework.html.erb +++ b/app/views/users/_course_homework.html.erb @@ -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..59d7785e1 100644 --- a/app/views/users/_user_homework_detail.html.erb +++ b/app/views/users/_user_homework_detail.html.erb @@ -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 %> From 85b11010d23861f11fea2de62580c2dcb9242054 Mon Sep 17 00:00:00 2001 From: cxt Date: Mon, 14 Dec 2015 16:18:39 +0800 Subject: [PATCH 02/11] =?UTF-8?q?=E5=9C=A8=E7=BA=BF=E6=B5=8B=E9=AA=8C?= =?UTF-8?q?=E6=8A=A5500=E3=80=81=20=E5=AD=A6=E7=94=9F=E7=9C=8B=E4=B8=8D?= =?UTF-8?q?=E5=88=B0=E5=B7=B2=E6=88=AA=E6=AD=A2=E7=9A=84=E6=B5=8B=E9=AA=8C?= =?UTF-8?q?=E3=80=81=E6=B5=8B=E9=AA=8C=E5=88=97=E8=A1=A8=E7=9A=84=E6=A0=B7?= =?UTF-8?q?=E5=BC=8F=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/exercise_controller.rb | 45 +++++++------------ app/views/exercise/_exercise.html.erb | 13 +++--- .../_exercise_student_result.html.erb | 2 +- app/views/layouts/base_courses.html.erb | 2 +- 4 files changed, 25 insertions(+), 37 deletions(-) diff --git a/app/controllers/exercise_controller.rb b/app/controllers/exercise_controller.rb index 2a75d0580..286330b4c 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) - 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 + 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) + @exercise_user.update_attributes(:score => score) + respond_to do |format| + format.html {render :layout => 'base_courses'} + end #end end diff --git a/app/views/exercise/_exercise.html.erb b/app/views/exercise/_exercise.html.erb index db412672c..30f986d92 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,13 +42,16 @@ <% 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%> 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/layouts/base_courses.html.erb b/app/views/layouts/base_courses.html.erb index c37af0dc1..eede16a16 100644 --- a/app/views/layouts/base_courses.html.erb +++ b/app/views/layouts/base_courses.html.erb @@ -188,7 +188,7 @@ <%= 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) %>