Merge branch 'develop' into 'develop'

bug修复



See merge request !163
This commit is contained in:
陈晓婷 2017-03-03 19:23:00 +08:00
commit ddbef73270
8 changed files with 24 additions and 11 deletions

View File

@ -367,6 +367,8 @@ class ApplicationController < ActionController::Base
allowed = User.current.allowed_to?(:projects_attachments_download,@project,:global => false)
elsif @course
allowed = User.current.allowed_to?(:course_attachments_download, @course, :global => false)
elsif @contest
allowed = User.current.member_of_contest?(@contest)
end
when "contest"
return true

View File

@ -19,7 +19,7 @@
class AttachmentsController < ApplicationController
layout "users_base"
before_filter :verify_authenticity_token, only: [:uploa]
before_filter :verify_authenticity_token, only: [:upload]
before_filter :find_project, :only => [:show, :download, :thumbnail, :destroy, :delete_homework]#, :except => [:upload, :autocomplete]
before_filter :file_readable, :read_authorize, :only => [:show, :thumbnail]#Modified by young
@ -694,6 +694,9 @@ class AttachmentsController < ApplicationController
elsif !@attachment.container.nil? && ((@attachment.container.has_attribute?(:board) || @attachment.container.has_attribute?(:board_id)) && @attachment.container.board &&
@attachment.container.board.course)
@course = @attachment.container.board.course
elsif !@attachment.container.nil? && ((@attachment.container.has_attribute?(:board) || @attachment.container.has_attribute?(:board_id)) && @attachment.container.board &&
@attachment.container.board.contest)
@contest = @attachment.container.board.contest
else
unless @attachment.container_type == 'Syllabus' || @attachment.container_type == 'Bid' || @attachment.container_type == 'Organization' || @attachment.container_type == 'HomeworkAttach' || @attachment.container_type == 'Memo' || @attachment.container_type == 'Softapplication' || @attachment.container_type == 'PhoneAppVersion' || @attachment.container_type == 'StudentWorksScore'|| @attachment.container_type == 'StudentWork' || @attachment.container_type == 'Work'|| @attachment.container_type == 'ContestantWork'|| @attachment.container_type == 'Contest' || @attachment.container_type == 'HomeworkBank'
@project = @attachment.project

View File

@ -133,7 +133,7 @@ class ExerciseController < ApplicationController
@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[:show_result].blank? ? 1 : params[:show_result]
@exercise.show_result = params[:show_result] ? 1 : 0
@exercise.question_random = params[:question_random] ? 0 : 1
@exercise.choice_random = params[:choice_random] ? 0 : 1
if @exercise.save
@ -484,7 +484,11 @@ class ExerciseController < ApplicationController
end
=end
@is_teacher = User.current.allowed_to?(:as_teacher,@course) || User.current.admin?
@all_exercises = @course.exercises.where("exercise_status > 1").order("created_at desc")
if @is_teacher
@all_exercises = @course.exercises.order("created_at desc")
else
@all_exercises = @course.exercises.where("exercise_status > 1").order("created_at desc")
end
student_id = @course.student.blank? ? "(-1)" : "(" + @course.student.map{|student| student.student_id}.join(",") + ")"
@exercise_count = @exercise.exercise_users.where("commit_status = 1 and user_id in #{student_id}").count
if @is_teacher || (!@exercise.exercise_users.where("user_id = #{User.current.id} and user_id in #{student_id}").empty? && @exercise.end_time <= Time.now)

View File

@ -300,7 +300,11 @@ class WorksController < ApplicationController
#当前用户是不是竞赛的成员
def member_of_contest
render_403 unless @contest.is_public==1 || User.current.member_of_contest?(@contest) || User.current.admin?
if !User.current.logged?
redirect_to signin_url
else
render_403 unless @contest.is_public==1 || User.current.member_of_contest?(@contest) || User.current.admin?
end
end
end

View File

@ -96,7 +96,7 @@
<div class="mt5">
<a href="javascript:void(0);" class="BlueCirBtnMini fr" id="new_message_submit_btn">确定</a>
<span class="fr mr10 mt3">或</span>
<%= link_to "取消", contestant_work_path(:work => @contestwork.id), :class => "fr mr10 mt3"%>
<%= link_to "取消", contestant_works_path(:work => @contestwork.id), :class => "fr mr10 mt3"%>
</div>
<div class="cl"></div>
<% end%>

View File

@ -67,7 +67,7 @@ var htmlvalue = '<div id="muban_popup_box" style="width:300px;"><div class="muba
pop_box_new(htmlvalue, 300, 140);
<% elsif @state == 14 %>
var htmlvalue = '<div id="muban_popup_box" style="width:300px;"><div class="muban_popup_top"><h3 class="fl">提示</h3><a href="javascript:void(0);" class="muban_icons_close fr"></a></div>'+
'<div class="clear mt15"><p class="text_c f14">此二维码已停用,请与管理员联系</p><div class="cl"></div>'+
'<div class="clear mt15"><p class="text_c f14">此邀请码已停用,请与管理员联系</p><div class="cl"></div>'+
'<a href="javascript:void(0);" class="fr sy_btn_blue mt10" style="margin-right: 119px;" onclick="hideModal();">确&nbsp;&nbsp;定</a></div></div>';
pop_box_new(htmlvalue, 300, 140);
<% else %>

View File

@ -83,7 +83,7 @@
<h3 class="fontGrey3">多选题</h3>
<% mcq_question_list.each_with_index do |exercise_question, list_index| %>
<div id="poll_questions_<%= exercise_question.id%>">
<div id="show_poll_questions_<%= exercise_question.id %>" class="<%= (list_index + 1) == mc_question_list.count ? '' : 'border_b' %>">
<div id="show_poll_questions_<%= exercise_question.id %>" class="<%= (list_index + 1) == mcq_question_list.count ? '' : 'border_b' %>">
<div>
<div class="exercise_title">
<div>
@ -130,7 +130,7 @@
<h3 class="fontGrey3">填空题</h3>
<% single_question_list.each_with_index do |exercise_question,list_index| %>
<div id="poll_questions_<%= exercise_question.id%>">
<div id="show_poll_questions_<%= exercise_question.id %>" class="<%= (list_index + 1) == mc_question_list.count ? '' : 'border_b' %>">
<div id="show_poll_questions_<%= exercise_question.id %>" class="<%= (list_index + 1) == single_question_list.count ? '' : 'border_b' %>">
<div>
<div class="exercise_title">
<div>

View File

@ -99,9 +99,9 @@
<% if @exercise.exercise_status == 1 %>
<div class="fontGrey2 db fl ml10">发布时间:<%= format_time @exercise.publish_time %></div>
<% end %>
<% end_time = @exercise.end_time.to_time.to_i %>
<% if end_time > Time.now.to_i %>
<div class="fontGrey2 db fr">提交剩余时间: <span class="c_red"><%= (end_time - Time.now.to_i) / (24*60*60) %></span> 天
<% if @exercise.end_time && @exercise.end_time.to_time.to_i > Time.now.to_i %>
<% end_time = @exercise.end_time.to_time.to_i %>
<div class="fontGrey2 db fr">提交剩余时间: <span class="c_red"><%= (end_time - Time.now.to_i) / (24*60*60) %></span> 天
<span class="c_red"><%= ((end_time - Time.now.to_i) % (24*60*60)) / (60*60)%></span> 小时
<span class="c_red"><%= (((end_time - Time.now.to_i) % (24*60*60)) % (60*60)) / 60%></span> 分</div>
<% else %>