Merge remote-tracking branch 'origin/szzh' into szzh

This commit is contained in:
lizanle 2015-09-25 09:44:29 +08:00
commit f99ccf724c
13 changed files with 1914 additions and 181 deletions

View File

@ -160,6 +160,7 @@ class MessagesController < ApplicationController
@reply.safe_attributes = params[:reply]
@reply.content = @quote + @reply.content
@reply.subject = "RE: #{@topic.subject}" unless params[:reply][:subject]
# @reply.reply_id = params[:id]
@topic.children << @reply
user_activity = UserActivity.where("act_type='Message' and act_id =#{@topic.id}").first
user_activity.updated_at = Time.now

View File

@ -189,6 +189,7 @@ class ProjectsController < ApplicationController
@project.organization_id = params[:organization_id]
@project.user_id = User.current.id
@project.project_new_type = params[:project_new_type]
params[:project][:is_public] ? @project.is_public = 1 : @project.is_public = 0
if validate_parent_id && @project.save
@project.set_allowed_parent!(params[:project]['parent_id']) if params[:project].has_key?('parent_id')
# Add current user as a project member if he is not admin

View File

@ -2356,8 +2356,8 @@ module ApplicationHelper
if work.nil?
link_to "提交作品", new_student_work_path(:homework => homework.id),:class => 'c_blue'
else
if homework.homework_type == 1 && homework.homework_detail_manual && homework.homework_detail_manual.comment_status != 1 #匿评作业,且作业状态不是在开启匿评之前
link_to "作品已交", "", :class => 'c_blue', :title => "开启匿评后不可修改作品"
if homework.homework_detail_manual && homework.homework_detail_manual.comment_status != 1 #匿评作业,且作业状态不是在开启匿评之前
link_to "作品已交", "javascript:void(0)", :class => 'c_blue', :title => "开启匿评后不可修改作品"
elsif homework.homework_type == 2 #编程作业不能修改作品
link_to "修改作品", new_student_work_path(:homework => homework.id),:class => 'c_blue'
else

View File

@ -4,6 +4,6 @@ class HomeworkDetailPrograming < ActiveRecord::Base
belongs_to :homework_common
def language_name
%W(C C++ Python).at(self.language.to_i - 1)
%W(C C++ Python Java).at(self.language.to_i - 1)
end
end

View File

@ -86,7 +86,7 @@ class Message < ActiveRecord::Base
}
safe_attributes 'subject', 'content'
safe_attributes 'subject', 'content', 'reply_id'
safe_attributes 'board_id','locked', 'sticky',
:if => lambda {|message, user|
if message.project

View File

@ -45,134 +45,13 @@
<div class="cl"></div>
<!--属性-->
<<<<<<< .mine
<%= render :partial => 'attributes_show' %>
<!--pro_info_box 属性 end-->
=======
<div class="pro_info_box mb10">
<%= issue_fields_rows do |rows| %>
<ul class="fl">
<li><p class="label03">&nbsp;状态&nbsp;&nbsp;:&nbsp;</p>
<p class="pro_info_p"><%= @issue.status.name %></p>
</li>
<div class="cl"></div>
<% unless @issue.disabled_core_fields.include?('assigned_to_id') %>
<li><p class="label03">&nbsp;指派给&nbsp;&nbsp;:&nbsp;</p>
<span class="pro_info_p"><%= @issue.assigned_to ? link_to_isuue_user(@issue.assigned_to) : "--" %></span>
</li>
<% end %>
<div class="cl"></div>
</ul>
<ul class="fl">
<li><p class="label03">&nbsp;优先级&nbsp;&nbsp;:&nbsp;</p>
<span class="pro_info_p" style="width:50px;"><%= @issue.priority.name %></span>
</li>
<div class="cl"></div>
<% unless @issue.disabled_core_fields.include?('done_ratio') %>
<li><p class="label03">&nbsp;% 完成&nbsp;&nbsp;:&nbsp;</p>
<span class="pro_info_p" style="width:50px;"><%= @issue.done_ratio %>%</span>
</li>
<% end %>
<div class="cl"></div>
</ul>
>>>>>>> .theirs
<<<<<<< .mine
<%# 该应用是对issue主题内容的引用对应:to => 'journals#new %>
<!--<div class="cl"></div>-->
<!--<%#= link_to l(:button_quote), quoted_issue_path(@issue.id), :remote => true, :method => 'post', :class => 'talk_edit fr' if authorize_for('issues', 'edit') %>-->
<div class="cl"></div>
=======
<ul class="fl ">
<% unless @issue.disabled_core_fields.include?('start_date') %>
<li><p class="label03" style="width:50px;">&nbsp;开始&nbsp;&nbsp;:&nbsp;</p>
<p class="pro_info_p"><%= format_date(@issue.start_date) %></p>
</li>
<% end %>
<div class="cl"></div>
>>>>>>> .theirs
<<<<<<< .mine
=======
<% unless @issue.disabled_core_fields.include?('estimated_hours') %>
<li><p class="label03" style="width:50px;">&nbsp;周期&nbsp;&nbsp;:&nbsp;</p>
<span class="pro_info_p"><%= l_hours(@issue.estimated_hours) %></span>
</li>
<% end %>
<div class="cl"></div>
</ul>
<ul class="fl ">
<% unless @issue.disabled_core_fields.include?('due_date') %>
<li><p class="label03">&nbsp;计划完成&nbsp;&nbsp;:&nbsp;</p>
<span class="pro_info_p" style="width:120px;"><%= format_date(@issue.due_date) ? format_date(@issue.due_date) : "--" %></span>
</li>
<% end %>
<div class="cl"></div>
<% unless @issue.disabled_core_fields.include?('fixed_version_id') %>
<li><p class="label03">&nbsp;目标版本&nbsp;&nbsp;:&nbsp;</p>
<span class="pro_info_p" style="width:120px;"><%= (@issue.fixed_version ? link_to_version(@issue.fixed_version, :class => "pro_info_p") : "--") %></span>
</li>
<% end %>
<div class="cl"></div>
</ul>
<% end %><!--pro_info_box end-->
<%#= render_custom_fields_rows(@issue) %>
<%#= call_hook(:view_issues_show_details_bottom, :issue => @issue) %>
>>>>>>> .theirs
</div>
<!--problem_main end-->

View File

@ -3,7 +3,7 @@
<li class="hworkList340 <%= @homework.homework_type == 2 ? '' : 'width385'%>">
<ul>
<li class="hworkPortrait mt15 mr10">
<%= link_to(image_tag(url_to_avatar(User.current),:width =>"40",:height => "40"),user_activities_path(User.current.id))%>
<%= link_to(image_tag(url_to_avatar(student_work.user),:width =>"40",:height => "40"),user_activities_path(User.current.id))%>
</li>
<div onclick="show_student_work('<%= student_work_path(student_work)%>');" style="cursor: pointer;">
<li class="hworkName mt15 mr15 <%= @homework.homework_type == 2 ? '' : 'width165'%>">

View File

@ -4,7 +4,7 @@
<div class="HomeWorkCon">
<div class="mt15">
<select class="InputBox W120 language_type" >
<%= options_for_select({"C语言"=>1, "C++"=>2, "Python"=>3}, (edit_mode && homework.is_program_homework?) ? homework.language : 1) %>
<%= options_for_select({"C语言"=>1, "C++"=>2, "Python"=>3, "Java"=>4}, (edit_mode && homework.is_program_homework?) ? homework.language : 1) %>
</select>
</div>
<% if edit_mode && homework.is_program_homework? %>

View File

@ -224,65 +224,89 @@
<li class="homepageNewsTime fl"><%= time_tag(ma.created_at).html_safe %> </li>
</ul>
<% end %>
<!--作品开启匿评 待整合:时间紧-->
<% if ma.course_message_type == "HomeworkCommon" && ma.status == 2 %>
<ul class="homepageNewsList fl">
<li class="homepageNewsPortrait fl"><a href="javascript:void(0);"><%=link_to image_tag(url_to_avatar(ma.course_message.user), :width => "30", :height => "30"), user_path(ma.course_message.user) %></a></li>
<li class="homepageNewsPubType fl"><%=link_to ma.course_message.user, user_path(ma.course_message.user), :class => "newsBlue homepageNewsPublisher" %><span class="<%= ma.viewed == 0 ? "homepageNewsTypeNotRead fl":"homepageNewsType fl" %>">发布的作业:</span></li>
<% if ma.viewed == 0 %>
<li class="homepageHomeworkContent fl">
<%= link_to ma.course_message.name, student_work_index_path(:homework => ma.course_message.id),
:class =>"#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}",
:onmouseover =>"message_titile_show($(this),event)",
:onmouseout => "message_titile_hide($(this))" %>
</li>
<div style="display: none" class="message_title_red system_message_style">
<%= ma.course_message.name %>
</div>
<li class="homepageHomeworkContentWarn fl"> &nbsp;&nbsp; 开启匿评了!</li>
<% else %>
<li class="homepageNewsContent fl">
<%= link_to ma.course_message.name, student_work_index_path(:homework => ma.course_message.id), :class =>"#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}",
:onmouseover =>"message_titile_show($(this),event)",
:onmouseout => "message_titile_hide($(this))"%>
</li>
<div style="display: none" class="message_title_red system_message_style">
<%= ma.course_message.name %>
</div>
<% end %>
<li class="homepageNewsTime fl"><%= time_tag(ma.created_at).html_safe %> </li>
</ul>
<% end %>
<!--作品开启匿评 待整合:时间紧-->
<% if ma.course_message_type == "HomeworkCommon" && ma.status == 2 %>
<ul class="homepageNewsList fl">
<li class="homepageNewsPortrait fl">
<a href="javascript:void(0);"><%= link_to image_tag(url_to_avatar(ma.course_message.user), :width => "30", :height => "30"), user_path(ma.course_message.user) %></a>
</li>
<li class="homepageNewsPubType fl">
<%= link_to ma.course_message.user.lastname + ma.course_message.user.firstname + "老师",
user_path(ma.course_message.user), :class => "newsBlue homepageNewsPublisher" %>
<span class="<%= ma.viewed == 0 ? "homepageNewsTypeNotRead fl" : "homepageNewsType fl" %>">启动了作业匿评:</span>
</li>
<li class="homepageNewsContent fl">
<%= link_to "作业题目:" + ma.course_message.name, student_work_index_path(:homework => ma.course_message.id), :class => "#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}",
:onmouseover => "message_titile_show($(this),event)",
:onmouseout => "message_titile_hide($(this))" %>
</li>
<div style="display: none" class="message_title_red system_message_style">
<p>您好!<%= ma.course_message.user.lastname + ma.course_message.user.firstname %>老师开启了匿评,作业详情如下:</p>
<p><strong>课程:</strong><%= ma.course_message.course.name %>(<%= ma.course_message.course.term %>)</p>
<p><strong>作业标题:</strong><%= ma.course_message.name %></p>
<% unless ma.course_message.description.blank? %>
<div class="fl"><strong>作业内容:</strong></div>
<div class="ml60"><%= ma.course_message.description.html_safe %></div>
<% end %>
<p><strong>匿评自动关闭日期:</strong><%= ma.course_message.homework_detail_manual.evaluation_end %>
</p>
</div>
<li class="homepageNewsTime fl"><%= time_tag(ma.created_at).html_safe %> </li>
</ul>
<% end %>
<!--作品关闭匿评-->
<% if ma.course_message_type == "HomeworkCommon" && ma.status == 3 %>
<ul class="homepageNewsList fl">
<li class="homepageNewsPortrait fl"><a href="javascript:void(0);"><%=link_to image_tag(url_to_avatar(ma.course_message.user), :width => "30", :height => "30"), user_path(ma.course_message.user) %></a></li>
<li class="homepageNewsPubType fl"><%=link_to ma.course_message.user, user_path(ma.course_message.user), :class => "newsBlue homepageNewsPublisher" %><span class="<%= ma.viewed == 0 ? "homepageNewsTypeNotRead fl":"homepageNewsType fl" %>">发布的作业:</span></li>
<% if ma.viewed == 0 %>
<li class="homepageHomeworkContent fl">
<%= link_to ma.course_message.name, student_work_index_path(:homework => ma.course_message.id),
:class =>"#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}",
:onmouseover =>"message_titile_show($(this),event)",
:onmouseout => "message_titile_hide($(this))" %>
</li>
<div style="display: none" class="message_title_red system_message_style">
<%= ma.course_message.name %>
</div>
<li class="homepageHomeworkContentWarn fl"> &nbsp;&nbsp; 匿评已经关闭!</li>
<% else %>
<li class="homepageNewsPubType fl">
<%=link_to ma.course_message.user.lastname + ma.course_message.user.firstname + "老师",
user_path(ma.course_message.user), :class => "newsBlue homepageNewsPublisher" %><span class="<%= ma.viewed == 0 ? "homepageNewsTypeNotRead fl":"homepageNewsType fl" %>">关闭了作业匿评:</span></li>
<li class="homepageNewsContent fl">
<%= link_to ma.course_message.name, student_work_index_path(:homework => ma.course_message.id), :class =>"#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}",
<%= link_to "作业题目:" + ma.course_message.name, student_work_index_path(:homework => ma.course_message.id), :class =>"#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}",
:onmouseover =>"message_titile_show($(this),event)",
:onmouseout => "message_titile_hide($(this))"%>
</li>
<div style="display: none" class="message_title_red system_message_style">
<%= ma.course_message.name %>
<p>您好!<%= ma.course_message.user.lastname + ma.course_message.user.firstname %>老师关闭了匿评,作业详情如下:</p>
<p><strong>课程:</strong><%= ma.course_message.course.name %>(<%= ma.course_message.course.term %>)</p>
<p><strong>作业标题:</strong><%= ma.course_message.name %></p>
<% unless ma.course_message.description.blank? %>
<div class="fl"><strong>作业内容:</strong></div>
<div class="ml60"><%= ma.course_message.description.html_safe %></div>
<% end %>
</div>
<% end %>
<li class="homepageNewsTime fl"><%= time_tag(ma.created_at).html_safe %> </li>
</ul>
<% end %>
<% if ma.course_message_type == "HomeworkCommon" && ma.status == 4 %>
<ul class="homepageNewsList fl">
<li class="homepageNewsPortrait fl">
<a href="javascript:void(0);"><%= link_to image_tag(url_to_avatar(ma.course_message.user), :width => "30", :height => "30"), user_path(ma.course_message.user) %></a>
</li>
<li class="homepageNewsPubType fl">
<%= link_to ma.course_message.user.lastname + ma.course_message.user.firstname + "老师",
user_path(ma.course_message.user), :class => "newsBlue homepageNewsPublisher" %>
<span class="<%= ma.viewed == 0 ? "homepageNewsTypeNotRead fl" : "homepageNewsType fl" %>">启动作业匿评失败</span>
</li>
<li class="homepageNewsContent fl">
<%= link_to "作业题目:" + ma.course_message.name, student_work_index_path(:homework => ma.course_message.id), :class => "#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}",
:onmouseover => "message_titile_show($(this),event)",
:onmouseout => "message_titile_hide($(this))" %>
</li>
<div style="display: none" class="message_title_red system_message_style">
<p>您好!<%= ma.course_message.user.lastname + ma.course_message.user.firstname %>老师启动作业匿评失败,作业详情如下:</p>
<p><strong>课程:</strong><%= ma.course_message.course.name %>(<%= ma.course_message.course.term %>)</p>
<p><strong>作业标题:</strong><%= ma.course_message.name %></p>
<% unless ma.course_message.description.blank? %>
<div class="fl"><strong>作业内容:</strong></div>
<div class="ml60"><%= ma.course_message.description.html_safe %></div>
<% end %>
</div>
<li class="homepageNewsTime fl"><%= time_tag(ma.created_at).html_safe %> </li>
</ul>
<% end %>
<% if ma.course_message_type == "Poll" %>
<ul class="homepageNewsList fl">
<li class="homepageNewsPortrait fl"><a href="javascript:void(0);"><%=link_to image_tag(url_to_avatar(ma.course_message.user), :width => "30", :height => "30"), user_path(ma.course_message.user) %></a></li>
@ -335,10 +359,20 @@
<% end %>
<% if ma.course_message_type == "StudentWorksScore" %>
<ul class="homepageNewsList fl">
<li class="homepageNewsPortrait fl"><a href="javascript:void(0);"><%=link_to image_tag(url_to_avatar(ma.course_message.user), :width => "30", :height => "30"), user_path(ma.course_message.user) %></a></li>
<li class="homepageNewsPortrait fl">
<% if ma.course_message.reviewer_role == 3 %>
<%=link_to image_tag(url_to_avatar(""), :width => "30", :height => "30") %>
<% else %>
<%=link_to image_tag(url_to_avatar(ma.course_message.user), :width => "30", :height => "30"), user_path(ma.course_message.user) %>
<% end %>
</li>
<li class="homepageNewsPubType fl">
<%= link_to ma.course_message.user.lastname + ma.course_message.user.firstname + "老师",
user_path(ma.course_message.user), :class => "newsBlue homepageNewsPublisher" %>
<% if ma.course_message.reviewer_role == 3 %>
匿名用户
<% else %>
<%= link_to ma.course_message.user.lastname + ma.course_message.user.firstname + "老师",
user_path(ma.course_message.user), :class => "newsBlue homepageNewsPublisher" %>
<% end %>
<span class="<%= ma.viewed == 0 ? "homepageNewsTypeNotRead fl" : "homepageNewsType fl" %>">
<%= ma.status == 0 ? "评阅了您的作品:" : "重新评阅了您的作品:" %>
</span>

View File

@ -0,0 +1,5 @@
class AddReplyIdToMessage < ActiveRecord::Migration
def change
add_column :messages, :reply_id, :integer
end
end

File diff suppressed because it is too large Load Diff

View File

@ -25,9 +25,25 @@ namespace :homework_evaluation do
end
end
homework_detail_manual.update_column('comment_status', 2)
# 匿评开启消息邮件通知
# 匿评开启消息邮件通知,# 所有人
course = homework_common.course
course.members.each do |m|
homework_common.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => course.id, :viewed => false, :status => 2)
end
# 邮件通知
Mailer.send_mail_anonymous_comment_close(homework_common).deliver
else
#作业数小于2启动失败
#作业数小于2启动失败, 只给老师发
# status==4 发送失败
# 匿评开启消息邮件通知,# 所有人
course = homework_common.course
course.members.each do |m|
if m.user.allowed_to?(:as_teacher,course)
homework_common.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => course.id, :viewed => false, :status => 4)
end
end
# 邮件通知
# Mailer.send_mail_anonymous_comment_close(homework_common).deliver
end
end
end
@ -47,7 +63,13 @@ namespace :homework_evaluation do
student_work.save
end
homework_detail_manual.update_column('comment_status', 3)
# 匿评关闭消息邮件通知
# 匿评关闭消息通知 给所有人发
course = homework_common.course
course.members.each do |m|
homework_common.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => course.id, :viewed => false, :status => 3)
end
# 邮件通知
Mailer.send_mail_anonymous_comment_close(homework_common).deliver
end
end
end

View File

@ -153,6 +153,8 @@ $(function(){
language = 'C++';
}else if($('select.language_type').val() == 3){
language = 'Python';
}else if($('select.language_type').val() == 4){
language = 'Java';
}
if (valid) {
@ -199,8 +201,81 @@ $(function(){
program_name = 'text/x-c++src';
}else if(language==3){
program_name = 'text/x-cython';
} else if(language==4){
program_name = 'text/x-java';
}
if ($('#program-src').val().length<=0) {
var src = '';
if(language==4){
src = '\
import java.io.*;\n\
import java.util.*;\n\
\n\
//请一定不要修改类名\n\
class Main\n\
{\n\
public static void main (String args[])\n\
{\n\
//获取参数方式\n\
//Scanner in = new Scanner(System.in);\n\
//int a = in.nextInt();\n\
//int b = in.nextInt();\n\
\n\
//您的代码\n\
}\n\
}\n\
';
}
else if(language==1){
src = '#include <stdio.h>\n\
\n\
int main()\n\
{\n\
//获取参数方式 scanf\n\
//int x =0;\n\
//int y = 0;\n\
//scanf("%d", &x);\n\
\n\
//结果输出使用prinf\n\
//printf("%d",x);\n\
\n\
return 0;\n\
}\n\
';
} else if(language==2){
src = '\
#include <iostream>\n\
using namespace std;\n\
\n\
int main()\n\
{\n\
//获取参数方式 cin\n\
//int x =0;\n\
//cin >> x;\n\
\n\
//结果输出使用 cout\n\
//cout<<"1";\n\
\n\
return 0;\n\
}\n\
';
} else if(language==3){
src = '\
import sys \n\
\n\
#获取参数方式使用raw_input\n\
#input = raw_input()\n\
#a, b = input.split()\n\
\n\
#结果输出使用 print \n\
#print (str(int(a)+int(b)))\n\
';
}
$('#program-src').val(src);
};
var editor = CodeMirror.fromTextArea(document.getElementById("program-src"), {
mode: {name: program_name,
version: 2,