教师评奖功能初步完成

This commit is contained in:
wanglinchun 2014-05-14 16:19:12 +08:00
parent 65340f604d
commit 4ea8611942
7 changed files with 207 additions and 15 deletions

View File

@ -5,7 +5,7 @@ class ContestsController < ApplicationController
menu_item :project, :only => :show_project
menu_item :application, :only => :show_softapplication
menu_item :attendingcontest, :only => :show_attendingcontest
before_filter :find_contest, :only => [:show_contest, :show_project, :show_softapplication, :show_attendingcontest, :create,:destroy,:more,:back,:add,:add_softapplication,:new,:show_results, :set_reward,
before_filter :find_contest, :only => [:show_contest, :show_project, :show_softapplication, :show_attendingcontest, :set_reward_project, :set_reward_softapplication, :create,:destroy,:more,:back,:add,:add_softapplication,:new,:show_results, :set_reward,
:show_contest_project, :show_contest_user, :join_in_contest, :unjoin_in_contest, :new_join,:show_participator, :settings]
# added by fq
@ -355,6 +355,44 @@ class ContestsController < ApplicationController
end
###end
def set_reward_project
@c_p = nil
@contesting_project_id = nil
if params[:set_reward_project][:reward]&&((User.current.id==@contest.author_id)||User.current.admin)
# @bid_id = params[:id]
@contesting_project_id = params[:set_reward_project][:c_id]
@c_p = ContestingProject.find_by_id(@contesting_project_id)
# 把字段存进表中
@c_p.update_reward(params[:set_reward_project][:reward].to_s)
end
respond_to do |format|
format.js
end
end
def set_reward_softapplication
@c_sa = nil
@contesting_softapplication_id = nil
if params[:set_reward_softapplication][:reward]&&((User.current.id==@contest.author_id)||User.current.admin)
# @bid_id = params[:id]
@contesting_softapplication_id = params[:set_reward_softapplication][:c_id]
@c_sa = ContestingSoftapplication.find_by_id(@contesting_softapplication_id)
# 把字段存进表中
@c_sa.update_reward(params[:set_reward_softapplication][:reward].to_s)
end
respond_to do |format|
format.js
end
end
###添加已创建的参赛项目
def add
project = Project.find(params[:contest])

View File

@ -92,6 +92,10 @@ module ContestsHelper
c_project.get_reward
end
def get_prize(c_softapplication)
c_softapplication.get_reward
end
def count_contest_project
contests = Contest.find(:id)
@projects = []

View File

@ -17,4 +17,12 @@ class ContestingSoftapplication < ActiveRecord::Base
:softapplication_id => softapplication_id)
end
def update_reward(which)
self.update_attribute(:reward,which)
end
def get_reward
self.reward
end
end

View File

@ -1,15 +1,14 @@
$('#reward_result_<%= @contesting_project_id %>').html('<%= j(
if get_prize(@b_p).nil? or get_prize(@b_p) == ""
if get_prize(@c_p).nil? or get_prize(@c_p) == ""
if @contest.deadline < Date.today
puts '未评奖'
end
else
case get_prize(@b_p)
case get_prize(@c_p)
when '-1'
image_tag("/images/bid/special_reward.png")
when '1'
when '0'
image_tag("/images/bid/first_reward.png")
when '1'

View File

@ -0,0 +1,30 @@
$('#reward_result_<%= @contesting_softapplication_id %>').html('<%= j(
if get_prize(@c_sa).nil? or get_prize(@c_sa) == ""
if @contest.deadline < Date.today
puts '未评奖'
end
else
case get_prize(@c_sa)
when '-1'
image_tag("/images/bid/special_reward.png")
when '0'
image_tag("/images/bid/first_reward.png")
when '1'
image_tag("/images/bid/second_reward.png")
when '2'
image_tag("/images/bid/third_reward.png")
when '3'
image_tag("/images/bid/forth_reward.png")
when '4'
image_tag("/images/bid/fifth_reward.png")
when '5'
image_tag("/images/bid/qualified.png")
end
end
)
%>')
$('#<%= @contesting_softapplication_id %>').hide()

View File

@ -193,6 +193,61 @@
</tr>
</div>
<div style="padding-left: 68px">
<tr>
<td style="color: #ec6300;" align="right" valign="0.1em" width="16%">
<strong>
<span id="reward_result_<%=c_project.id%>"> <!-- 调用js进行刷新 -->
<% if get_prize(c_project).nil? or get_prize(c_project) == "" %>
<% if @contest.deadline < Date.today %>
<%= l(:label_noawards)%>
<% end %>
<% else %>
<% case get_prize(c_project) %>
<% when '-1' %>
<%= image_tag("/images/bid/special_reward.png")%>
<% when '0' %>
<%= image_tag("/images/bid/first_reward.png")%>
<% when '1' %>
<%= image_tag("/images/bid/second_reward.png")%>
<% when '2' %>
<%= image_tag("/images/bid/third_reward.png")%>
<% when '3' %>
<%= image_tag("/images/bid/forth_reward.png")%>
<% when '4' %>
<%= image_tag("/images/bid/fifth_reward.png")%>
<% when '5' %>
<%= image_tag("/images/bid/qualified.png")%>
<% end %>
<% end %>
</span>
</strong>
</td>
<!-- 评价显隐控制按钮-->
<% if ((User.current.id == @contest.author_id) && (@contest.deadline > Date.today))||User.current.admin %>
<td valign="top" align="right" width="10%">
<span> <%= toggle_link '评价', c_project.id.to_s %></span>
<!-- 评价应标项目的表单 -->
<span style="display: none; vertical-align: top " id = '<%= c_project.id %>'>
<%= form_for "set_reward_project",:remote=>true,:url=>set_reward_project_contest_path do |f| %>
<%= f.text_field :c_id,:style => "display:none",:value => c_project.id,:size=>"0" %>
<%= f.select :reward,"<option value = '-1'>#{l(:label_special_reward)}</option>
<option value = '0'>#{l(:label_first_reward)}</option>
<option value = '1'>#{l(:label_second_reward)}</option>
<option value = '2'>三等奖</option>
<option value = '3'>四等奖</option>
<option value = '4'>五等奖</option>
<option value = '5'>#{l(:label_comfort_reward)}</option>".html_safe %>
<%= f.submit "提交",:class=>"submit" %>
<% end %>
</span>
</td>
<% end %>
</tr>
<tr>
</tr>
</div>
</div>
<% end %>
<div class="underline-contests_three"></div>
@ -219,6 +274,62 @@
</div>
<!--获奖及教师评奖-->
<div style="padding-left: 68px">
<tr>
<td style="color: #ec6300;" align="right" valign="0.1em" width="16%">
<strong>
<span id="reward_result_<%=c_softapplication.id%>"> <!-- 调用js进行刷新 -->
<% if get_prize(c_softapplication).nil? or get_prize(c_softapplication) == "" %>
<% if @contest.deadline < Date.today %>
<%= l(:label_noawards)%>
<% end %>
<% else %>
<% case get_prize(c_softapplication) %>
<% when '-1' %>
<%= image_tag("/images/bid/special_reward.png")%>
<% when '0' %>
<%= image_tag("/images/bid/first_reward.png")%>
<% when '1' %>
<%= image_tag("/images/bid/second_reward.png")%>
<% when '2' %>
<%= image_tag("/images/bid/third_reward.png")%>
<% when '3' %>
<%= image_tag("/images/bid/forth_reward.png")%>
<% when '4' %>
<%= image_tag("/images/bid/fifth_reward.png")%>
<% when '5' %>
<%= image_tag("/images/bid/qualified.png")%>
<% end %>
<% end %>
</span>
</strong>
</td>
<!-- 评价显隐控制按钮-->
<% if ((User.current.id == @contest.author_id) && (@contest.deadline > Date.today))||User.current.admin %>
<td valign="top" align="right" width="10%">
<span> <%= toggle_link '评价', c_softapplication.id.to_s %></span>
<!-- 评价应标项目的表单 -->
<span style="display: none; vertical-align: top " id = '<%= c_softapplication.id %>'>
<%= form_for "set_reward_softapplication",:remote=>true,:url=>set_reward_softapplication_contest_path do |f| %>
<%= f.text_field :c_id,:style => "display:none",:value => c_softapplication.id,:size=>"0" %>
<%= f.select :reward,"<option value = '-1'>#{l(:label_special_reward)}</option>
<option value = '0'>#{l(:label_first_reward)}</option>
<option value = '1'>#{l(:label_second_reward)}</option>
<option value = '2'>三等奖</option>
<option value = '3'>四等奖</option>
<option value = '4'>五等奖</option>
<option value = '5'>#{l(:label_comfort_reward)}</option>".html_safe %>
<%= f.submit "提交",:class=>"submit" %>
<% end %>
</span>
</td>
<% end %>
</tr>
<tr>
</tr>
</div>
</div>
<% end %>
<div class="underline-contests_three"></div>

View File

@ -73,6 +73,8 @@ RedmineApp::Application.routes.draw do
match 'show_softapplication' , via: :get
match 'show_attendingcontest' , via: :get
match 'show_participator' , via: :get
match 'set_reward_project' , via: [:get, :post]
match 'set_reward_softapplication' , via: [:get, :post]
match 'add' , via: [:get, :post]
match 'add_softapplication' , via: [:get, :post]
match 'create' , via: :post