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

This commit is contained in:
z9hang 2014-11-06 15:19:55 +08:00
commit 3689b5e228
17 changed files with 170 additions and 90 deletions

View File

@ -508,6 +508,7 @@ class BidsController < ApplicationController
WHERE table1.t_score IS NULL")
@cur_type = 1
else
m_score_null = @bid.comment_status == 2 ? "IS NOT NULL" : "IS NULL"
all_homework_list = HomeworkAttach.eager_load(:attachments,:user,:rate_averages).find_by_sql("SELECT * FROM(SELECT homework_attaches.*,
(SELECT AVG(stars) FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND rater_id IN #{teachers}) AS t_score,
(SELECT AVG(stars) FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND rater_id NOT IN #{teachers}) AS s_score,
@ -515,7 +516,7 @@ class BidsController < ApplicationController
FROM homework_attaches
INNER JOIN homework_evaluations ON homework_evaluations.homework_attach_id = homework_attaches.id
WHERE homework_attaches.bid_id = #{@bid.id} AND homework_evaluations.user_id = #{User.current.id} ORDER BY s_score DESC) AS table1
WHERE table1.m_score IS NULL")
WHERE table1.m_score #{m_score_null}")
@is_student_batch_homework = true
@cur_type = 4
end
@ -823,7 +824,7 @@ class BidsController < ApplicationController
flash[:notice] = l(:label_bid_succeed)
end
end
redirect_to course_for_bid_path(@bid)
redirect_to course_homework_url(params[:course_id])
else
@bid.safe_attributes = params[:bid]
@homework = @bid

View File

@ -410,6 +410,7 @@ class CoursesController < ApplicationController
@course = Course.new
@course.safe_attributes = params[:course]
month = Time.now.month
render :layout => 'base'
end

View File

@ -98,6 +98,7 @@ class HomeworkAttachController < ApplicationController
#获取学生匿评列表
def get_student_batch_homework
m_score_null = @bid.comment_status == 2 ? "IS NOT NULL" : "IS NULL"
@is_student_batch_homework = true
teachers = find_course_teachers @course
all_homework_list = HomeworkAttach.eager_load(:attachments,:user,:rate_averages).find_by_sql("SELECT * FROM(SELECT homework_attaches.*,
@ -107,7 +108,7 @@ class HomeworkAttachController < ApplicationController
FROM homework_attaches
INNER JOIN homework_evaluations ON homework_evaluations.homework_attach_id = homework_attaches.id
WHERE homework_attaches.bid_id = #{@bid.id} AND homework_evaluations.user_id = #{User.current.id} ORDER BY s_score DESC) AS table1
WHERE table1.m_score IS NULL")
WHERE table1.m_score #{m_score_null}")
@cur_page = params[:page] || 1
@cur_type = 4
@homework_list = paginateHelper all_homework_list,10
@ -227,7 +228,7 @@ class HomeworkAttachController < ApplicationController
def create
bid = Bid.find params[:bid_id]
if User.current.admin? || User.current.member_of_course?(bid.courses.first) # modify by nwb
if bid.homeworks.where("user_id = ?",User.current).count == 0
if bid.homeworks.where("user_id = ?",User.current).empty?
user_id = params[:user_id]
bid_id = params[:bid_id]
if params[:homework_attach]

View File

@ -1911,19 +1911,13 @@ module ApplicationHelper
def anonymous_comment_link(bid, course)
link = case bid.comment_status
when 0
@student_size ||= searchStudent(course).size
@homework_size = bid.homeworks.size
percent = @homework_size.to_f / @student_size
confirm_info = "开启匿评后学生将不能对作业进行提交、修改、删除等操作\n"
confirm_info += percent >= 0.8 ? '' : "目前#{@student_size}个学生,总共提交了#{@homework_size}份作业,只占#{number_to_percentage(percent * 100, precision: 1)}\n"
confirm_info += anonymous_comment_notice(bid,course)
confirm_info += '是否确定开启匿评?'
link_to '启动匿评', start_anonymous_comment_bid_path(bid), id: "#{bid.id}_start_anonymous_comment", remote: true, :confirm => confirm_info, disable_with: '加载中...'
when 1
@student_size ||= searchStudent(course).size
@homework_size = bid.homeworks.size
percent = @homework_size.to_f / @student_size
confirm_info = "关闭匿评后所有同学将看到匿评的结果。学生将可以自由的进行公开互评了,但公开互评不影响作业的匿名评分\n"
confirm_info += "" # TODO 当前有多少学生完成了匿评有多少学生没有进行匿评并据此给出建议建议老师暂缓关闭匿评因为只有x%的学生完成了匿评任务。。。
confirm_info = "关闭匿评后所有同学将不能继续进行匿评,且将公开已提交作业列表\n"
confirm_info += anonymous_comment_notice(bid,course)
confirm_info += '是否确定关闭匿评?'
link_to '关闭匿评', stop_anonymous_comment_bid_path(bid), id: "#{bid.id}_stop_anonymous_comment", remote: true, :confirm => confirm_info
when 2
@ -1931,4 +1925,33 @@ module ApplicationHelper
end
content_tag('span', link, id: "#{bid.id}_anonymous_comment")
end
def anonymous_comment_notice(bid, course)
link =
case bid.comment_status
when 0
@student_size ||= searchStudent(course).size
@homework_size = bid.homeworks.size
percent = @homework_size.to_f / @student_size
confirm_info = "目前#{@student_size}个学生,总共提交了#{@homework_size}份作业,占#{number_to_percentage(percent * 100, precision: 1)}\n"
when 1
@homework_evaluations = 0
bid.homeworks.map { |homework| @homework_evaluations += homework.homework_evaluations.count}
teachers = "("
teacher_members = searchTeacherAndAssistant(course)
teacher_members.each do |member|
if member == teacher_members.last
teachers += member.user_id.to_s + ")"
else
teachers += member.user_id.to_s + ","
end
end
@has_evaluations = 0
bid.homeworks.map { |homework| @has_evaluations += homework.rates(:quality).where("seems_rateable_rates.rater_id not in #{teachers}").count}
percent = @has_evaluations.to_f / @homework_evaluations
confirm_info = "目前总共分配了#{@homework_evaluations}份匿评作业,已评价#{@has_evaluations}份作业,占#{number_to_percentage(percent * 100, precision: 1)}\n"
end
confirm_info
end
end

View File

@ -343,8 +343,7 @@ module CoursesHelper
end
#获取当前用户在指定作业下提交的作业的集合
def cur_user_homework_for_bid bid
cur_user_homework = HomeworkAttach.where("user_id = ? and bid_id = ?",User.current,bid.id)
cur_user_homework
bid.homeworks.where("user_id = ?",User.current)
end
#判断当前用户对指定作业是否已经评价过
@ -476,6 +475,17 @@ module CoursesHelper
type << option2
type
end
def cur_course_term
month = Time.now.month
if month >= 9 || month < 3
term = "秋季学期"
else
term = "春季学期"
end
term
end
#获取课程动态
def get_course_activity courses, activities
@course_ids=activities.keys()

View File

@ -27,20 +27,30 @@
$("#what_is_project_div").slideToggle();
}
window.onready = function()
{
<% if !@is_teacher && @homework_list.count > 0 && @bid.comment_status == 1%>
//登录者不是老师且作业列表数目不为0且作业处于开启匿评阶段
var alert_model = "'#ajax-modal'";
$('#ajax-modal').html('<%= escape_javascript(render :partial => 'homework_attach/praise_alert') %>');
showModal('ajax-modal', '480px');
$('#ajax-modal').css('height','240px');
$('#ajax-modal').before("<span style='float: right;cursor:pointer;'>" +
"<a href='#' onclick='hiddent_alert_model();'><img src='/images/bid/close.png' width='26px' height='26px' /></a></span>");
$('#ajax-modal').parent().css("top","").css("left","").css("width","511");
$('#ajax-modal').parent().addClass("alert_praise");
<% end %>
}
$(document).ready(
function()
{
<% if !@is_teacher && @homework_list.count > 0 && @bid.comment_status == 1%>
//登录者不是老师且作业列表数目不为0且作业处于开启匿评阶段
var alert_model = "'#ajax-modal'";
$('#ajax-modal').html('<%= escape_javascript(render :partial => 'homework_attach/praise_alert') %>');
showModal('ajax-modal', '480px');
$('#ajax-modal').css('height','240px');
$('#ajax-modal').before("<span style='float: right;cursor:pointer;'>" +
"<a href='#' onclick='hiddent_alert_model();'><img src='/images/bid/close.png' width='26px' height='26px' /></a></span>");
$('#ajax-modal').parent().css("top","").css("left","").css("width","511");
$('#ajax-modal').parent().addClass("alert_praise");
<% end %>
<% unless @is_teacher%>
<% if @bid.comment_status == 0%>
$("#my_homework").click();
<% elsif @bid.comment_status == 2%>
$("#all_homeworks").click();
<% end %>
<% end %>
}
);
function hiddent_alert_model(){hideModal($('#popbox02'));}

View File

@ -29,15 +29,15 @@
<% else %>
<ul>
<li id="tb_5" class="hovertab">
<%= link_to "待评作品", get_student_batch_homework_homework_attach_index_path(:bid_id => @bid.id), {:remote => true}%>
<%= link_to @bid.comment_status == 2 ? "已评作品" : "待评作品", get_student_batch_homework_homework_attach_index_path(:bid_id => @bid.id), {id: 'student_batch_homework',:remote => true}%>
</li>
<li id="tb_6" class="normaltab">
<%= link_to "我的作品", get_my_homework_homework_attach_index_path(:bid_id => @bid.id), {:remote => true}%>
<%= link_to "我的作品", get_my_homework_homework_attach_index_path(:bid_id => @bid.id), {id: 'my_homework',:remote => true}%>
</li>
<% if @bid.comment_status == 2 %>
<!-- 匿评结束后才能看到全部作业列表 -->
<li id="tb_7" class="normaltab">
<%= link_to "所有作品", get_homeworks_homework_attach_index_path(:bid_id => @bid.id), {:remote => true}%>
<%= link_to "所有作品", get_homeworks_homework_attach_index_path(:bid_id => @bid.id), {id: 'all_homeworks',:remote => true}%>
</li>
<% end %>
<li id="tb_8" class="normaltab">

View File

@ -1,7 +1,8 @@
<% if @statue == 1%>
alert('启动成功');
$("#<%= @bid.id %>_start_anonymous_comment").remove();
$("#<%= @bid.id %>_anonymous_comment").append('<%= link_to "关闭匿评", stop_anonymous_comment_bid_path(@bid), remote: true %>');
$("#<%= @bid.id %>_anonymous_comment").append('<%= link_to "关闭匿评", stop_anonymous_comment_bid_path(@bid), remote: true, id:"#{@bid.id}_stop_anonymous_comment" %>');
$("#<%= @bid.id%>_stop_anonymous_comment").attr("data-confirm","关闭匿评后学生将不能对作业进行评分,且学生作业列表将会被公开\n是否确定关闭匿评");
<% elsif @statue == 2 %>
alert('启动失败\n作业总数大于等于2份时才能启动匿评');
<% elsif @statue == 3%>

View File

@ -43,7 +43,11 @@
<span class="info" style="width: 10px;">
<%= text_field_tag :class_period, @course.class_period, :placeholder => "#{l(:lable_input_class)}", :maxlength => 5 %>
</span>
<span>&nbsp;<strong><%= l(:label_class_hour) %></strong></span>
<span>&nbsp;
<strong>
<%= l(:label_class_hour) %>
</strong>
</span>
</td>
</tr>
</table>
@ -53,12 +57,16 @@
<table>
<tr>
<td>
<span class="info" align="right" style="width: 90px; font-weight: bold ;margin-left:22px"><%= l(:label_class_period) %>
<span class="required"> *&nbsp;&nbsp;</span></span>
<span class="info" align="right" style="width: 90px; font-weight: bold ;margin-left:22px">
<%= l(:label_class_period) %>
<span class="required"> *&nbsp;&nbsp;</span>
</span>
<span class="info" style="width: 10px;">
<%= text_field_tag :class_period, nil, :placeholder => "#{l(:lable_input_class)}", :maxlength => 5 %>
</span>
<strong><%= l(:label_class_hour) %></strong>
<strong>
<%= l(:label_class_hour) %>
</strong>
</td>
</tr>
</table>
@ -72,13 +80,16 @@
<table>
<tr>
<td class="info" align="right" style="width: 86px">
<strong><%= l(:label_term) %><span class="required"> *&nbsp;&nbsp;</span></strong>
<strong>
<%= l(:label_term) %>
<span class="required"> *&nbsp;&nbsp;</span>
</strong>
</td>
<td class="info" style="width: 10px">
<%= select_tag :time,options_for_select(course_time_option,@course.time), {} %>
</td>
<td class="info" style="width: 10px">
<%= select_tag :term,options_for_select(course_term_option,@course.term),{} %>
<%= select_tag :term,options_for_select(course_term_option,@course.term || cur_course_term),{} %>
</td>
</tr>
</table>
@ -88,12 +99,15 @@
</table>
</p>
<p style="margin-left:-10px;">
<label for="course[course]_password" style="font-size: 13px;"><%= l(:label_new_course_password) %>
<label for="course[course]_password" style="font-size: 13px;">
<%= l(:label_new_course_password) %>
<span class="required">*</span>
</label>
<input id="course_course_password" type="text" style="width:488px;margin-left: 10px;" value="<%= @course.password %>" size="60" name="course[password]"/>
</p>
<em class="info" style="margin-left:95px;"><%= l(:text_command) %></em>
<em class="info" style="margin-left:95px;">
<%= l(:text_command) %>
</em>
<% end %>
<p style="padding-right: 20px;">
<label for="course_description" style="font-size: 13px;">
@ -111,10 +125,14 @@
<%= l(:label_course_public_info) %>
</em>
</p><!-- modified by bai -->
<p style="display:none;"><%= f.text_field :course_type, :value => 1 %></p>
<p style="display:none;">
<%= f.text_field :course_type, :value => 1 %>
</p>
<%= wikitoolbar_for 'course_description' %>
<% @course.custom_field_values.each do |value| %>
<p><%= custom_field_tag_with_label :course, value %></p>
<p>
<%= custom_field_tag_with_label :course, value %>
</p>
<% end %>
<%= call_hook(:view_courses_form, :course => @course, :form => f) %>
<!--[eoform:course]-->

View File

@ -6,7 +6,9 @@
<%= labelled_form_for @course do |f| %>
<div class="box tabular">
<%= render :partial => 'course_form', :locals => { :f => f } %>
<span style="padding-left: 60px"><%= submit_tag l(:button_create), :class => "enterprise"%></span>
<span style="padding-left: 60px">
<%= submit_tag l(:button_create), :class => "enterprise"%>
</span>
<!-- <%#= submit_tag l(:button_create_and_continue), :name => 'course_continue' %> -->
<%= javascript_tag "$('#course_name').focus();" %>
</div>

View File

@ -24,16 +24,18 @@
<%= link_to "(#{homework.attachments.count.to_s}个附件)", zipdown_download_user_homework_path(:homework => homework)%>
</li>
<li class="wscore">
<%= l(:label_teacher_score)%>:
<span class="c_red">
<%= homework.t_score.nil? ? l(:label_without_score) : format("%.2f",homework.t_score)%>
</span>
&nbsp;&nbsp;
<% unless is_student_batch_homework %>
<%= l(:label_teacher_score)%>:
<span class="c_red">
<%= homework.t_score.nil? ? l(:label_without_score) : format("%.2f",homework.t_score)%>
</span>
&nbsp;&nbsp;
<% end %>
</li>
<li class="wscore">
<%= l(:label_student_score)%>:
<%= is_student_batch_homework ? l(:label_my_score) : l(:label_student_score)%>:
<span class="c_red">
<%= homework.s_score.nil? ? l(:label_without_score) : format("%.2f",homework.s_score) %>
<%= homework.s_score.nil? ? l(:label_without_score) : format("%.2f",(is_student_batch_homework ? homework.m_score : homework.s_score)) %>
</span>
</li>
<% if is_teacher %>

View File

@ -65,3 +65,9 @@
<%= pagination_links_full @obj_pages, @obj_count, :per_page_links => false, :remote => remote, :flag => true%>
</ul>
<% end %>
<% if is_teacher %>
<span style="color: red;">
<%= anonymous_comment_notice(@bid, @bid.courses.first) %>
</span>
<% end %>

View File

@ -64,18 +64,6 @@
<%= f.text_field :name, :required => true, :name => "homework_name", :class => "w430 bo", :maxlength => 254, :placeholder => "作品名称", :onblur => "regexName();"%>
<span id="homework_attach_name_span"></span>
</p>
<p>
<label>&nbsp;&nbsp;&nbsp;提交项目
<img src="/images/bid/pic_question.png" width="16" height="16"
title="项目是一种由用户创建的基于网络的协作空间,能够为个人或小组提供分布式的协同交流和资料管理等方面的支持。
项目托管平台http://forge.trustie.ne">
</label>
<% if @homework.project.nil? %>
<%= f.select :project_id, options_for_select(user_projects_option),{}, {:name => "project_id", :required => true,:class => "w350 bo"}%>
<% else %>
<%= f.select :project_id, options_for_select(user_projects_option,@homework.project.id),{},{:name => "project_id", :required => true, :class => "w350 bo"}%>
<% end %>
</p>
<p>
<label style="float:left;">
<span class="c_red">*</span>
@ -88,15 +76,29 @@
<p>
<label style="float: left;">&nbsp;&nbsp;&nbsp;添加附件&nbsp;&nbsp;&nbsp;&nbsp;</label>
<%#= render :partial => 'attachments/form' %>
<p style=" padding: 3px 0 3px 0;padding-left: 90px;">
<% options = {:author => true, :deletable => attach_delete(@homework)} %>
<%= render :partial => 'attachments/links',
:locals => {:attachments => @homework.attachments, :options => options} %>
</p>
<% unless @homework.attachments.empty?%>
<p style=" padding: 3px 0 3px 0;padding-left: 90px;">
<% options = {:author => true, :deletable => attach_delete(@homework)} %>
<%= render :partial => 'attachments/links',
:locals => {:attachments => @homework.attachments, :options => options} %>
</p>
<% end %>
<p style=" padding: 3px 0 3px 0;padding-left: 90px;">
<%= render :partial => 'attachments/form' %>
</p>
</p>
<p>
<label>&nbsp;&nbsp;&nbsp;开发项目
<img src="/images/bid/pic_question.png" width="16" height="16"
title="项目是一种由用户创建的基于网络的协作空间,能够为个人或小组提供分布式的协同交流和资料管理等方面的支持。
项目托管平台http://forge.trustie.ne">
</label>
<% if @homework.project.nil? %>
<%= f.select :project_id, options_for_select(user_projects_option),{}, {:name => "project_id", :required => true,:class => "w350 bo"}%>
<% else %>
<%= f.select :project_id, options_for_select(user_projects_option,@homework.project.id),{},{:name => "project_id", :required => true, :class => "w350 bo"}%>
<% end %>
</p>
<p>
<span style="float: left;">

View File

@ -54,14 +54,6 @@
<%= f.text_field "name", :required => true, :size => 60, :class => "w430 bo", :maxlength => 254, :placeholder => "作品名称", :onblur => "regexName();" %>
<span id="homework_attach_name_span"></span>
</p>
<p>
<label>&nbsp;&nbsp;&nbsp;提交项目
<img src="/images/bid/pic_question.png" width="16" height="16"
title="项目是一种由用户创建的基于网络的协作空间,能够为个人或小组提供分布式的协同交流和资料管理等方面的支持。
项目托管平台http://forge.trustie.ne">
</label>
<%= f.select :project_id,options_for_select(user_projects_option), {},{:class => "w350 bo"} %>
</p>
<p>
<label style="float:left;">
<span class="c_red">
@ -79,6 +71,14 @@
<%= render :partial => 'attachments/form' %>
</p>
</p>
<p>
<label>&nbsp;&nbsp;&nbsp;开发项目
<img src="/images/bid/pic_question.png" width="16" height="16"
title="项目是一种由用户创建的基于网络的协作空间,能够为个人或小组提供分布式的协同交流和资料管理等方面的支持。
项目托管平台http://forge.trustie.ne">
</label>
<%= f.select :project_id,options_for_select(user_projects_option), {},{:class => "w350 bo"} %>
</p>
<p>
<span style="float: left;">

View File

@ -79,7 +79,7 @@
<td style="vertical-align: top;font-size: 15px;">
<span style=" word-wrap: break-word; word-break: break-all">
<strong>
<%= link_to course.name.to_s, homework_course_path(course) if course %>
<%= link_to "返回课程主页", homework_course_path(course) if course %>
</strong>
</span>
</td>
@ -87,7 +87,9 @@
<tr>
<td style=" word-wrap: break-word; word-break: break-all;font-size: 15px;">
<span style=" color:#ed8924">
<strong><%=link_to(@bid.name, course_for_bid_path(@bid)) %></strong>
<strong>
<%=link_to("第#{course.homeworks.index(@bid) + 1}次作业", course_for_bid_path(@bid)) %>
</strong>
</span>
</td>
</tr>

View File

@ -5,17 +5,17 @@
</div>
<!-- 上左下右 -->
<div class='desc_item'>
<span class=''>
<% unless course.is_public == 1 %>
<span class="private_project"><%= l(:label_private) %></span>
<% end %>
<%= link_to(course.name.truncate(30, omission: '...')+":", course_path(course.id), :class => "d-g-blue d-p-project-name", :title => "#{course.name}") %>
<span class=''>
<% unless course.is_public == 1 %>
<span class="private_project"><%= l(:label_private) %></span>
<% end %>
<%= link_to(course.name.truncate(30, omission: '...')+":", course_path(course.id), :class => "d-g-blue d-p-project-name", :title => "#{course.name}") %>
</span>
<span class='font_bolder'>
<%= link_to(course.try(:teacher).try(:realname), user_path(course.teacher)) %>
<%#=course.try(:teacher).try(:name)%>
</span>
</span>
<span class='font_bolder'>
<%= link_to(course.try(:teacher).try(:realname), user_path(course.teacher)) %>
<%#=course.try(:teacher).try(:name)%>
</span>
</div>
<div class='desc_item text_nowrap'>
[<%= get_course_term course %>]

View File

@ -1459,7 +1459,7 @@ zh:
label_newtype_contest: 发布竞赛
label_user_information: "与我相关"
label_bid_succeed: "需求发布成功"
label_bid_succeed: "作业创建成功"
label_wrong_budget: 错误的金额格式
label_wrong_date: 时间格式错误,请输入正确的时间 yyyy-mm-dd
label_bidding_succeed: 应标成功
@ -2184,4 +2184,5 @@ zh:
label_anonymous_comments: 匿评
label_anonymous: 匿名
label_submit_comments: 提交评论
field_evaluation_num: 匿评分配数量
field_evaluation_num: 匿评分配数量
label_my_score: 我的评分