Merge branch 'Homework' of http://repository.trustie.net/xianbo/trustie2 into Homework

Conflicts:
	config/locales/zh.yml
This commit is contained in:
z9hang 2014-11-02 14:43:00 +08:00
commit 8bfcbcc602
21 changed files with 1572 additions and 1396 deletions

View File

@ -997,6 +997,46 @@ class BidsController < ApplicationController
def manage
end
# 启动匿评
def start_anonymous_comment
@bid = Bid.find(params[:id])
homeworks = @bid.homeworks
users = homeworks.map { |h| h.user }
@start_index = rand(homeworks.size)
while users[0] == homeworks[@start_index].user
@start_index = rand(homeworks.size)
end
3.times do |i|
homework_start_index = @start_index + i
users.each_with_index do |user, index|
actual_index = homework_start_index + index
actual_index = (actual_index < homeworks.size ? actual_index : actual_index - homeworks.size)
if user != homeworks[actual_index]
@homework_evaluation = HomeworkEvaluation.new(user_id: user.id, homework_attach_id: homeworks[actual_index].id)
@homework_evaluation.save
end
end
end
# 修改状态为 '启动匿评'
@bid.update_column('comment_status', 1)
respond_to do |format|
format.js
end
end
def stop_anonymous_comment
@bid = Bid.find(params[:id])
@bid.update_column('comment_status', 2)
respond_to do |format|
format.js
end
end
private

View File

@ -128,9 +128,6 @@ class HomeworkAttachController < ApplicationController
pt.praise_tread_object_id = @homework.id
pt.praise_tread_object_type = "HomeworkAttach"
pt.praise_or_tread = 1
@is_my_homework = params[:is_my_homework]
@is_student_batch_homework = params[:is_student_batch_homework]
@is_teacher = params[:is_teacher]
if pt.save
respond_to do |format|
format.js
@ -185,6 +182,9 @@ class HomeworkAttachController < ApplicationController
homework_user = @homework.homework_users.where("user_id = #{params[:user_id]}").first
homework_user.destroy
get_homework_member @homework
@homework_list = []
@is_my_homework = true
respond_to do |format|
format.js
end

View File

@ -3,4 +3,7 @@ class HomeworkEvaluation < ActiveRecord::Base
belongs_to :homework_attach
belongs_to :user
validate :user, presence: true
validate :homework_attach, presence: true
end

View File

@ -34,6 +34,16 @@
<% end %>
<% end %>
<% if (User.current.admin?||User.current.id==bid.author_id) %>
<span id="<%=bid.id %>_anonymous_comment">
<% case bid.comment_status %>
<% when 0 %>
<%= link_to '启动匿评', start_anonymous_comment_bid_path(bid), id: "#{bid.id}_start_anonymous_comment", remote: true %>
<% when 1 %>
<%= link_to '关闭匿评', stop_anonymous_comment_bid_path(bid), id: "#{bid.id}_stop_anonymous_comment", remote: true %>
<% when 2 %>
已关闭匿评
<% end %>
</span>
<%= link_to(
l(:button_edit),
{:action => 'edit', :controller=>'bids', :course_id =>@course.id, :bid_id => bid.id},

View File

@ -26,6 +26,15 @@
{
$("#what_is_project_div").slideToggle();
}
window.onready = function()
{
<% if !@is_teacher && @homework_list.count > 0%>
$('#ajax-modal').html('<%= escape_javascript(render :partial => 'homework_attach/praise_alert') %>');
showModal('ajax-modal', '480px');
$('#ajax-modal').css('height','240px');
<% end %>
}
</script>
</div>
<div id='bidding_project_list'>

View File

@ -39,7 +39,9 @@
</li>
<li id="tb_8" class="normaltab">
<%= link_to "留言", get_homework_jours_homework_attach_index_path(:bid_id => @bid.id), {:remote => true}%>
(<span id="jours_count" class="c_red f_12"><%= @jours_count %></span>)
(<span id="jours_count" class="c_red f_12">
<%= @jours_count %>
</span>)
</li>
</ul>
<% end %>
@ -47,11 +49,14 @@
<div class="cl"></div>
<div class="ctt">
<div class="dis" id="tbc_01">
<%= render :partial => 'homework_attach/homeworks_list', :locals => {:homeworks => @homework_list, :homework_count => @obj_count, :remote => false, :is_student_batch_homework => @is_student_batch_homework}%>
<%= render :partial => 'homework_attach/homeworks_list',
:locals => {:homeworks => @homework_list,
:homework_count => @obj_count,
:remote => false,
:is_student_batch_homework => @is_student_batch_homework}%>
</div>
</div>
</div>
<div id="show_homework_attach_model"></div>
</body>
</html>

View File

@ -0,0 +1,2 @@
alert('启动成功')
$("#<%= @bid.id %>_start_anonymous_comment").html('<%= link_to "关闭匿评", stop_anonymous_comment_bid_path(@bid), remote: true %>')

View File

@ -0,0 +1,2 @@
alert('关闭成功')
$("#<%= @bid.id %>_anonymous_comment").html('已关闭匿评')

View File

@ -45,8 +45,13 @@
<li class="wmine">
<%= link_to l(:button_edit), edit_homework_attach_path(homework) %>
<% if homework.user == User.current || User.current.admin? %>
<!-- 作业创建者显示删除作业 -->
<%= link_to(l(:label_bid_respond_delete), homework,
method: :delete, :confirm => l(:text_are_you_sure), :remote => true ) %>
<% else %>
<!-- 作业参与者显示退出作业 -->
<%= link_to l(:label_logout), destory_homework_users_homework_attach_path(homework,:user_id=>User.current.id),
:remote => true, :confirm => l(:label_sure_exit_homework) %>
<% end %>
</li>
<% elsif is_student_batch_homework%>
@ -59,23 +64,8 @@
</li>
<% else %>
<!-- 学生众评列表,显示为点赞 -->
<% if is_praise_homework User.current.id,homework.id %>
<li class="wzan" title="点赞">
<%= link_to "",praise_homework_homework_attach_path(homework,:is_my_homework => is_my_homework,
:is_student_batch_homework => is_student_batch_homework,
:is_teacher => is_teacher),
:class => "wzan_img wzan_visited", :remote => true%>
<a>
<%= praise_homework_count homework.id %>
</a>
</li>
<% else %>
<li class="wzan" title="您已经赞过该作业">
<a href="#" target="_blank" class="wzan_img"></a>
<a>
<%= praise_homework_count homework.id %>
</a>
</li>
<% end %>
<li class="wzan" id="homeworl_praise_li_<%= homework.id%>">
<%= render :partial => "homework_attach/homework_praise", locals: {:homework => homework} %>
</li>
<% end %>
<% end %>

View File

@ -0,0 +1,9 @@
<% if is_praise_homework User.current.id,homework.id %>
<%= link_to "",praise_homework_homework_attach_path(homework),
:class => "wzan_img", :remote => true, :title => "点赞"%>
<% else %>
<a class="wzan_img wzan_visited" title="您已经赞过该作业"></a>
<% end %>
<a>
<%= praise_homework_count homework.id %>
</a>

View File

@ -0,0 +1,27 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>作业评分弹框</title>
<%= stylesheet_link_tag 'css', :media => 'all' %>
</head>
<body>
<div id="popbox02">
<!--<div class="alert" style="position: fixed;">-->
<!--<div>-->
<!--<span class="close02" style="display: block;" onclick="hideModal(this)"></span>-->
<!--</div>-->
<!--</div>-->
<div class="ni_con">
<h2><img src="/images/bid/pic_top.jpg" width="188" height="37" alt="匿名评价" /></h2>
<p>&nbsp;&nbsp;&nbsp;&nbsp;据说雷锋做完好事是从来不留名的呢,我们这次评分也不留名!!!但是,但是,您给的分数一定要公正哦,老天爷看不到,我们的系统可是清楚得很!</p>
<p style="margin-bottom:15px;">&nbsp;&nbsp;&nbsp;&nbsp;别怪我没告诉你,系统分配给你的作品不评价可是要扣分的哈!</p>
<a href="#" class="tijiao" style="margin-left:100px;" onclick="hideModal(this)">匿名评分</a>
<a href="#" style="color:#15bccf; margin-top:20px; display:block;" onclick="hideModal(this)">冒着扣分的危险残忍拒绝</a>
</div>
</div>
</body>
</html>

View File

@ -1 +1,4 @@
$('#content2').html('<%= escape_javascript(render(:partial => 'homework_member', :locals => {:members => @members,:hoemwork_users =>@hoemwork_users,:homework => @homework} )) %>');
$('#content2').html('<%= escape_javascript(render(:partial => 'homework_member', :locals => {:members => @members,:hoemwork_users =>@hoemwork_users,:homework => @homework} )) %>');
$('#tbc_01').html('<%= escape_javascript(render(:partial => 'homeworks_list',
:locals => {:homeworks => @homework_list, :bid => @bid, :remote => true, :is_my_homework => @is_my_homework} )) %>');

View File

@ -1,51 +1,119 @@
<p style="font-weight: bold; color: rgb(237,137,36)" xmlns="http://www.w3.org/1999/html">
<%=h l(:label_new_homework)%>
</p>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>新建作业</title>
<%= stylesheet_link_tag 'css', :media => 'all' %>
<script type="text/javascript" language="javascript">
function g(o){return document.getElementById(o);}
function HoverLi(n){
for(var i=1;i<=2;i++){g('tb_'+i).className='normaltab';g('tbc_0'+i).className='undis';}g('tbc_0'+n).className='dis';g('tb_'+n).className='hovertab';
}
</script>
<div class="box">
<%= form_for('new_form', :method => :post,
:url => {:controller => 'homework_attach',
:action => 'create',
:user_id => User.current.id,
:bid_id => @bid
}) do |f|%>
<p style=" padding: 3px 0 3px 0;padding-left: 50px; clear:left;">
<strong>标&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;题&nbsp;<span style="color: red">*</span></strong>
<%= f.text_field "name", :required => true, :size => 60, :style => "width:490px;", :maxlength => 254 %>
</p>
<p style=" padding: 3px 0 3px 0;padding-left: 50px; clear:left;">
<strong>
提交项目&nbsp;&nbsp;
</strong>
<%= f.select :project_id,options_for_select(user_projects_option), {},{:style => "width:490px;"} %>
<%= link_to '创建项目', new_project_path(course: 0, project_type: 0), :target => '_blank' %>
<p class="font_lighter" style="padding-left:120px;clear:left;">
提交项目可以为空
</p>
</p>
<p style=" padding: 3px 0 3px 0;padding-left: 50px; clear:left;">
<strong style="vertical-align: top">
描&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;述&nbsp;&nbsp;
</strong>
<span style="margin-left:-10px;padding-right: 20px;">
<%= f.text_area "description", :rows => 8, :class => 'wiki-edit', :style => "font-size:small;width:490px;margin-left:10px;", :maxlength => 5000 %>
</span>
</p>
<p style="padding-left: 60px">
<fieldset style="text-align: left;">
<legend>
<%= l(:label_attachment_plural) %>
</legend>
<p style=" padding: 3px 0 3px 0;padding-left: 50px; clear:left;">
<%= render :partial => 'attachments/form' %>
</head>
<body>
<div class="container">
<div class="Newwork">
<div id="tb_" class="tb_">
<ul>
<li id="tb_1" class="hovertab" onmouseover="x:HoverLi(1);" style="width: auto; padding:5px 10px 0;">
课程名称课程名称</li>
<li id="tb_2" class="normaltab" onmouseover="i:HoverLi(2);">
成员</li>
<li class="N_top" ><a href="#" target="_blank" >创建项目</a></li>
</ul>
</div>
<div class="ctt">
<div class="dis" id="tbc_01">
<div class="N_con">
<form>
<p>
<label><span class="c_red">*</span>&nbsp;&nbsp;作品名称&nbsp;&nbsp;&nbsp;&nbsp;</label>
<input id="" type="text" name="" class="w430 bo" placeholder="作品名称">
</p>
</fieldset>
</p>
<p>
<label>&nbsp;&nbsp;&nbsp;提交项目<img src="images/pic_question.png" width="16" height="16" Title="项目是一种由用户创建的基于网络的协作空间能够为个人或小组提供分布式的协同交流和资料管理等方面的支持。项目托管平台http://forge.trustie.ne"></label>
<select name="" id="" class="w350 bo">
<option value="1">N</option>
<option value="2">M</option>
</select>
</p>
<p>
<label style="float:left;"><span class="c_red">*</span>&nbsp;&nbsp;作业描述&nbsp;&nbsp;&nbsp;&nbsp;</label>
<textarea id="" name="" placeholder="最多3000个汉字(或6000个英文字符)" class="w620" ></textarea>
</p>
<div class="cl"></div>
<p>
<label>&nbsp;&nbsp;&nbsp;添加附件&nbsp;&nbsp;&nbsp;&nbsp;</label>
<input type="button" name="" value="文件浏览" style="width:80px; height:26px; color:#606060;">&nbsp;&nbsp;&nbsp;&nbsp;<span style="font-weight:normal; color:#999;">-文件不超过200MB</span>
</p>
<p>
<span style="float: left;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>
<a href="#" target="_blank" class="tijiao">提交作业</a><a href="#" target="_blank" class="tijiao">重&nbsp;&nbsp;置</a>
<div class="cl"></div>
</p>
</form>
</div><!---创建作业内容结束-->
</div>
<div class="undis" id="tbc_02">
<div class="members_left">
<ul style=" border-bottom:none;">
<li><span class="w260 f_b" >用户</span><span class="w260 f_b">角色</span><span></span></li>
<li ><a href="#" class="w260">gugu01</a><span class="w260">发布人员</span><a href="#">删除</a></li>
<li><a href="#" class="w260">gugu01</a><span class="w260">参与人员</span ><a href="#">删除</a></li>
<li><a href="#" class="w260">gugu01</a><span class="w260">参与人员</span ><a href="#">删除</a></li>
<li><a href="#" class="w260">gugu01</a><span class="w260">参与人员</span ><a href="#">删除</a></li>
</ul>
</div><!-- 左边-->
<div class="members_right">
<fieldset style=" border:none; margin-top:10px;">
<legend style=" font-weight:bold; color:#15bccf;">添加成员</legend>
<p><label for="principal_search">搜索用户或组:</label><input id="principal_search" name="principal_search" type="text" class="N_search" data-value-was=""></p>
<div id="principals_for_new_member">
<div id="principals">
<label><input name="membership[user_ids][]" type="checkbox" value="195"> alan</label><br>
<label><input name="membership[user_ids][]" type="checkbox" value="231"> zoujiang09</label><br>
<label><input name="membership[user_ids][]" type="checkbox" value="241"> FANG_nudt</label><br>
<label><input name="membership[user_ids][]" type="checkbox" value="282"> gcm3651</label><br>
<label><input name="membership[user_ids][]" type="checkbox" value="307"> fhx569287825</label><br>
<label><input name="membership[user_ids][]" type="checkbox" value="500"> windleos</label><br>
<label><input name="membership[user_ids][]" type="checkbox" value="502"> acbuwa</label><br>
<label><input name="membership[user_ids][]" type="checkbox" value="575"> dislu</label><br>
<label><input name="membership[user_ids][]" type="checkbox" value="597"> huai_wang</label><br>
<label><input name="membership[user_ids][]" type="checkbox" value="603"> H.Lee</label><br>
</div>
<div class="pagination_new">
<ul class="wlist" style=" float:left;">
<li><a href="#">上一页</a></li>
<li><a href="#">1</a></li>
<li><a href="#">2</a></li>
<li><a href="#">...</a></li>
<li><a href="#">下一页</a></li>
</ul>
<div class="cl"></div>
</div>
</div>
<p><a href="#" class="tijiao">新增成员</a></p>
</fieldset>
</div><!-- 右边-->
</div><!---成员结束-->
</div>
</div>
</div><!--新建作业结束-->
<p style="padding-left: 60px;padding-top: 5px;">
<span >
<%= submit_tag t(:label_button_ok), :sta => 0, :class => "enterprise"%>
</span>
</p>
<% end %>
</div>
</body>
</html>

View File

@ -1,4 +1,3 @@
$('#homework_li_<%= @homework.id%>').
html('<%= escape_javascript(render :partial => 'homework_attach/homework',
:locals => {:homework => @homework, :is_student_batch_homework => @is_student_batch_homework,
:is_my_homework => @is_my_homework, :is_teacher => @is_teacher})%>');
$('#homeworl_praise_li_<%= @homework.id%>').
html('<%= escape_javascript(render :partial => 'homework_attach/homework_praise',
:locals => {:homework => @homework})%>');

View File

@ -1,3 +1,4 @@
$('#ajax-modal').html('<%= escape_javascript(render :partial => 'show',:locals => {:comprehensive_evaluation => @comprehensive_evaluation,:homework => @homework, :teaher_score => @teaher_score}) %>');
showModal('ajax-modal', '503px');
$('#ajax-modal').css('height','569px');

View File

@ -2179,5 +2179,6 @@ zh:
label_create_person: 创建人员
label_participation_person: 参与人员
label_homework_without_description: 该作业无任何描述!
label_sure_exit_homework: 是否确认退出该作业
label_teacher_comments: 教师评论
label_anonymous_comments: 匿评

View File

@ -329,6 +329,8 @@ RedmineApp::Application.routes.draw do
resources :bids, :only=>[:edit,:update,:show] do
member do
match 'homework_ajax_modal'
get 'start_anonymous_comment', as: 'start_anonymous_comment'
get 'stop_anonymous_comment', as: 'stop_anonymous_comment'
end
end
resources :projects do

View File

@ -0,0 +1,5 @@
class AddCommentStatusToBid < ActiveRecord::Migration
def change
add_column :bids, :comment_status, :integer, default: 0
end
end

File diff suppressed because it is too large Load Diff

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.6 KiB

View File

@ -8,10 +8,7 @@ ul,li{ list-style-type:none}
a{ text-decoration:none; }
a:hover{ text-decoration:underline;}
.container{ width:940px; margin:0 auto; padding-top:125px;}
.container{ width:940px; margin:0 auto; }
/* 作业列表 */
.ttl{ }
.ctt{height:820px;clear:both; }
@ -60,7 +57,7 @@ ul.wlist{ float:right; border-bottom:none; height:30px; margin-top:20px; }
.dis ul li.wmine{ margin:12px 0 0 10px;}
.dis ul li.wmine a{ color:#3d7ec2; text-align:center; width:50px; font-weight: bold;}
.wzan{ margin:15px 0 0 25px; width:32px; height:44px;}
.wzan a{ display: block;}
.wzan a{ display: block;text-align: center;}
a.wzan_img{background:url(images/pic_zan.png) 0 -59px no-repeat; display:block; height:31px; width:30px; color:#fff;}
a.wzan_visited{background:url(images/pic_zan.png) 0 0 no-repeat;}
@ -122,7 +119,7 @@ a:hover.ping_sub{ background:#14a8b9;}
/* 创建作业 */
.Newwork{ width:918px; height:418px; border:1px solid #c3c3c3;}
.N_top{ height:35px; background:#e5e5e5; border:1px solid #fff; width:891px; padding:5px 10px 0 15px;}
.N_top{ height:35px; background:#e5e5e5; border:1px solid #fff; width:669px; padding:5px 10px 0 15px;}
.N_top h2{ color:#616161; font-size:14px; float:left;}
.N_top a{ float:right; font-size:14px; color:#15bccf; display:block; background:url(images/pic_ad.png) 0 5px no-repeat; height:20px; width:60px; padding-left:16px;}
.N_con{ color:#484747; font-weight:bold; width:720px; margin:15px auto;}
@ -136,13 +133,15 @@ a.tijiao{ height:28px; display:block; width:80px; color:#fff; background:#15bccf
a:hover.tijiao{ background:#0f99a9;}
/* 匿名评分弹框 */
#popbox02{width:480px;height:200px;position:absolute;z-index:100;left:50%;top:50%;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;}
.alert .close02{width:26px;height:26px;overflow:hidden;position:absolute;top:-10px;right:-490px;background:url(images/close.png) no-repeat;cursor:pointer;}
.ni_con { width:425px; margin:25px 30px;}
.ni_con h2{ display:block; height:40px; width:188px; margin:0 auto;}
.ni_con p{ color:#808181;}
.ni_con a:hover{ text-decoration:none;}
/*.ui-widget-header{display: none;}*/