Merge branch 'dev_hjq' of http://repository.trustie.net/xianbo/trustie2 into dev_hjq
This commit is contained in:
commit
1e97f9224f
|
@ -206,8 +206,8 @@ class HomeworkCommonController < ApplicationController
|
|||
end
|
||||
@homework_detail_manual.update_column('comment_status', 2)
|
||||
@statue = 1
|
||||
|
||||
|
||||
send_message_anonymous_comment(@homework, open=true)
|
||||
Mailer.send_mail_anonymous_comment_open(@homework).deliver
|
||||
else
|
||||
@statue = 2
|
||||
end
|
||||
|
@ -219,13 +219,6 @@ class HomeworkCommonController < ApplicationController
|
|||
#关闭匿评
|
||||
def stop_anonymous_comment
|
||||
@homework_detail_manual.update_column('comment_status', 3)
|
||||
# 关闭匿评消息提示
|
||||
# status 标记匿评状态 1为关闭 0为开启
|
||||
course = @homework.course
|
||||
course.student.each do |st|
|
||||
@homework.course_messages << CourseMessage.new(:user_id => st.user_id, :course_id => course.id, :viewed => false, :status => false)
|
||||
end
|
||||
# end
|
||||
#计算缺评扣分
|
||||
work_ids = "(" + @homework.student_works.map(&:id).join(",") + ")"
|
||||
@homework.student_works.each do |student_work|
|
||||
|
@ -233,12 +226,21 @@ class HomeworkCommonController < ApplicationController
|
|||
student_work.absence_penalty = absence_penalty_count > 0 ? absence_penalty_count * @homework_detail_manual.absence_penalty : 0
|
||||
student_work.save
|
||||
end
|
||||
|
||||
send_message_anonymous_comment(@homework, open = false)
|
||||
Mailer.send_mail_anonymous_comment_close(@homework).deliver
|
||||
respond_to do |format|
|
||||
format.js
|
||||
end
|
||||
end
|
||||
|
||||
# 开启/关闭匿评消息通知
|
||||
def send_message_anonymous_comment(homework, open)
|
||||
# status 标记匿评状态 1为关闭 0为开启
|
||||
course = @homework.course
|
||||
course.student.each do |st|
|
||||
@homework.course_messages << CourseMessage.new(:user_id => st.user_id, :course_id => course.id, :viewed => false, :status => open ? true : false)
|
||||
end
|
||||
end
|
||||
#提示
|
||||
def alert_anonymous_comment
|
||||
@cur_size = 0
|
||||
|
|
|
@ -464,6 +464,10 @@ class ProjectsController < ApplicationController
|
|||
# by young
|
||||
# include CoursesHelper
|
||||
def member
|
||||
# 消息"同意加入项目"
|
||||
if params[:message_id]
|
||||
message_invite(params[:message_id], params[:key])
|
||||
end
|
||||
# params[:login]为邮箱邀请用户加入,主要功能:
|
||||
# 1、自动注册
|
||||
# 2、加入项目、创建角色
|
||||
|
@ -519,6 +523,14 @@ class ProjectsController < ApplicationController
|
|||
@members = paginateHelper @members
|
||||
end
|
||||
|
||||
def message_invite(message_id, key)
|
||||
forge_message = ForgeMessage.find(message_id)
|
||||
if key == forge_message.secret_key
|
||||
Member.create(:role_ids => [4], :user_id => forge_message.user_id, :project_id => forge_message.project_id)
|
||||
UserGrade.create(:user_id => forge_message.user_id, :project_id => forge_message.project_id)
|
||||
end
|
||||
end
|
||||
|
||||
#判断指定用户是否为课程教师
|
||||
def isCourseTeacher(id)
|
||||
result = false
|
||||
|
|
|
@ -83,7 +83,7 @@ module ProjectsHelper
|
|||
elsif ivite_list.user.active?
|
||||
value = "邀请已发送,等待用户加入!"
|
||||
else
|
||||
value = "账号尚未激活,等待用户应答!"
|
||||
value = "邀请已发送,等待用户激活账号!"
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ module StudentWorkHelper
|
|||
def user_projects_option
|
||||
projects = User.current.projects.visible
|
||||
not_have_project = []
|
||||
not_have_project << "没有可选项目,请直接为本作品创建一个项目"
|
||||
not_have_project << "请选择关联项目"
|
||||
not_have_project << 0
|
||||
type = []
|
||||
type << not_have_project
|
||||
|
|
|
@ -8,7 +8,7 @@ class ForgeMessage < ActiveRecord::Base
|
|||
TYPE_OF_WIKI_ACT = "Wiki"
|
||||
TYPE_OF_NEWS_ACT = "News"
|
||||
|
||||
attr_accessible :forge_message_id, :forge_message_type, :project_id, :user_id, :viewed
|
||||
attr_accessible :forge_message_id, :forge_message_type, :project_id, :user_id, :viewed, :secret_key
|
||||
|
||||
belongs_to :forge_message ,:polymorphic => true
|
||||
belongs_to :project
|
||||
|
|
|
@ -4,6 +4,6 @@ class HomeworkDetailPrograming < ActiveRecord::Base
|
|||
belongs_to :homework_common
|
||||
|
||||
def language_name
|
||||
%W(c c++).at(self.language.to_i - 1)
|
||||
%W(C C++).at(self.language.to_i - 1)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -47,6 +47,40 @@ class Mailer < ActionMailer::Base
|
|||
MailerProxy.new(self)
|
||||
end
|
||||
|
||||
# 作业匿评开启
|
||||
def send_mail_anonymous_comment_open(homework_common)
|
||||
course = homework_common.course
|
||||
course.student.each do |student|
|
||||
user = student.user
|
||||
@subject = "#{l(:mail_homework)}#{homework_common.name} #{l(:mail_anonymous_comment_open)}"
|
||||
@token = Token.get_token_from_user(user, 'autologin')
|
||||
@anonymous_comment_close_url = url_for(student_work_index_url(:homework => homework_common.id, :token => @token.value))
|
||||
@anonymous_comment_close_name = homework_common.name
|
||||
@author = homework_common.user
|
||||
#收件人邮箱
|
||||
recipient = user.mail
|
||||
mail :to => recipient,
|
||||
:subject => @subject
|
||||
end
|
||||
end
|
||||
|
||||
# 作业匿评关闭
|
||||
def send_mail_anonymous_comment_close(homework_common)
|
||||
course = homework_common.course
|
||||
course.student.each do |student|
|
||||
user = student.user
|
||||
@subject = "#{l(:mail_homework)}#{homework_common.name} #{l(:mail_anonymous_comment_open)}"
|
||||
@token = Token.get_token_from_user(user, 'autologin')
|
||||
@anonymous_comment_close_url = url_for(student_work_index_url(:homework => homework_common.id, :token => @token.value))
|
||||
@anonymous_comment_close_name = homework_common.name
|
||||
@author = homework_common.user
|
||||
#收件人邮箱
|
||||
recipient = user.mail
|
||||
mail :to => recipient,
|
||||
:subject => @subject
|
||||
end
|
||||
end
|
||||
|
||||
# author: alan
|
||||
# 邀请未注册用户加入项目
|
||||
# 功能: 在加入项目的同时自动注册用户
|
||||
|
@ -82,14 +116,15 @@ class Mailer < ActionMailer::Base
|
|||
@token = Token.get_token_from_user(user, 'autologin')
|
||||
@project_url = url_for(:controller => 'projects', :action => 'member', :id => project.id, :user_id => user.id, :mail => true, :token => @token.value)
|
||||
# 发送消息邀请
|
||||
send_message(user,project)
|
||||
send_message_request_member(user,project)
|
||||
# end
|
||||
mail :to => email, :subject => @subject
|
||||
end
|
||||
|
||||
# 邀请信息消息 注:forge_message_id 为邀请人ID(特殊情况)
|
||||
def send_message(user, project)
|
||||
ForgeMessage.create(:user_id => user.id, :project_id => project.id, :forge_message_type => "Project_Invite",:forge_message_id => User.current.id, :viewed => false)
|
||||
def send_message_request_member(user, project)
|
||||
key = newpass(6).to_s
|
||||
ForgeMessage.create(:user_id => user.id, :project_id => project.id, :forge_message_type => "ProjectInvite",:forge_message_id => User.current.id, :viewed => false, :secret_key =>key)
|
||||
end
|
||||
|
||||
# author: alan
|
||||
|
|
|
@ -31,9 +31,8 @@ class StudentWork < ActiveRecord::Base
|
|||
else
|
||||
self.system_score = last_test.test_score
|
||||
end
|
||||
set_final_score self.homework_common,self
|
||||
end
|
||||
|
||||
set_final_score self.homework_common,self
|
||||
end
|
||||
def set_src
|
||||
self.description = last_test.src if last_test
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
<div class="mail_box" style="border:1px solid #c8c8c8; width:570px; height: auto; padding:15px; margin-top:10px; margin-bottom:10px;">
|
||||
<ul style="list-style-type:none; margin:0; padding:0;">
|
||||
<li style="list-style-type:none; margin:0; padding:0;"><span style="float: left;"><strong><%= l(:mail_issue_content)%></strong></span>
|
||||
<span style="float: left; width: 526px">
|
||||
<p><%=link_to @author, user_url(@author) %> 发布的作业:<%=link_to @homework_endtime_name, @homework_endtime_url%> <span style="color: red; padding-left: 10px;">已经关闭了匿评!</span></p>
|
||||
</span>
|
||||
</li>
|
||||
</ul>
|
||||
<div class="cl" style="margin-top: 30px; clear:both; overflow:hidden;"></div>
|
||||
</div>
|
|
@ -0,0 +1,10 @@
|
|||
<div class="mail_box" style="border:1px solid #c8c8c8; width:570px; height: auto; padding:15px; margin-top:10px; margin-bottom:10px;">
|
||||
<ul style="list-style-type:none; margin:0; padding:0;">
|
||||
<li style="list-style-type:none; margin:0; padding:0;"><span style="float: left;"><strong><%= l(:mail_issue_content)%></strong></span>
|
||||
<span style="float: left; width: 526px">
|
||||
<p><%=link_to @author, user_url(@author) %> 发布的作业:<%=link_to @homework_endtime_name, @homework_endtime_url%> <span style="color: red; padding-left: 10px;">已经开启匿评了!</span></p>
|
||||
</span>
|
||||
</li>
|
||||
</ul>
|
||||
<div class="cl" style="margin-top: 30px; clear:both; overflow:hidden;"></div>
|
||||
</div>
|
|
@ -57,7 +57,7 @@
|
|||
</li>
|
||||
|
||||
<!-- 成绩 -->
|
||||
<% score = student_work.respond_to?("score") ? student_work.score : student_work.final_score - student_work.absence_penalty - student_work.late_penalty%>
|
||||
<% score = student_work.respond_to?("score") ? student_work.score : (student_work.final_score || 0) - student_work.absence_penalty - student_work.late_penalty%>
|
||||
<li class="hworkList50 <%= score_color score%> student_final_scor_info">
|
||||
<%= score.nil? ? "--" : format("%.1f",score)%>
|
||||
<% unless score.nil?%>
|
||||
|
|
|
@ -87,13 +87,13 @@
|
|||
<div class="dis" id="tbc_01">
|
||||
<div class="codeList">
|
||||
<span class="fl mt3">
|
||||
<%= link_to "所有作品<font class='f12 c_red'>[共#{@homework.student_works.count}份]</font>".html_safe,student_work_index_path(:homework => @homework.id),:class => "fl f14"%>
|
||||
<%= link_to "所有作品<font class='f12 c_red'>[共#{@stundet_works.count}份]</font>".html_safe,student_work_index_path(:homework => @homework.id),:class => "fl f14"%>
|
||||
</span>
|
||||
<%if @is_teacher || @homework.homework_detail_manual.comment_status == 3%>
|
||||
<form class="resourcesSearchloadBox fr">
|
||||
<input type="text" id="course_student_name" value="<%= @name%>" placeholder="输入资源关键词进行搜索" class="searchResource" onkeypress="SearchByName('<%= student_work_index_path(:homework => @homework.id)%>',event);"/>
|
||||
<div class="resourcesSearchloadBox fr">
|
||||
<input type="text" id="course_student_name" value="<%= @name%>" placeholder="姓名、学号、邮箱" class="searchResource" onkeypress="SearchByName('<%= student_work_index_path(:homework => @homework.id)%>',event);"/>
|
||||
<a class="homepageSearchIcon" onclick="SearchByName_1('<%= student_work_index_path(:homework => @homework.id)%>');" href="javascript:void(0)"></a>
|
||||
</form>
|
||||
</div>
|
||||
<% end%>
|
||||
<div class="cl"></div>
|
||||
</div>
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
<% end %>
|
||||
|
||||
<div class="mt10">
|
||||
<span class="f12 c_red db mt5 fl">温馨提示:您可以在发布作业后,在作业“模拟答题”中进行标准代码的检测和提交。</span>
|
||||
<span class="f12 c_red db mt5 fl">温馨提示:您可以在发布作业后,在作业“模拟答题”中进行标准代码的检测。</span>
|
||||
<a href="javascript:void(0);" class="BlueCirBtn fr">确 定</a>
|
||||
<div class="cl"></div>
|
||||
</div>
|
||||
|
|
|
@ -74,9 +74,10 @@
|
|||
</ul>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<%# 课程消息 %>
|
||||
<!--总消息列表-->
|
||||
<% unless @message_alls.nil? %>
|
||||
<% @message_alls.each do |ma| %>
|
||||
<%# 课程消息 %>
|
||||
<% if ma.class == CourseMessage %>
|
||||
<% if ma.course_message_type == "News" %>
|
||||
<ul class="homepageNewsList fl">
|
||||
|
@ -252,6 +253,7 @@
|
|||
<% end %>
|
||||
<!--项目消息-->
|
||||
<% if ma.class == ForgeMessage %>
|
||||
<!--申请加入项目-->
|
||||
<% if ma.forge_message_type == "AppliedProject" %>
|
||||
<ul class="homepageNewsList fl">
|
||||
<li class="homepageNewsPortrait fl">
|
||||
|
@ -272,6 +274,37 @@
|
|||
<li class="homepageNewsTime fl"><%= time_tag(ma.created_at).html_safe %> </li>
|
||||
</ul>
|
||||
<% end %>
|
||||
<!--邀请加入项目-->
|
||||
<% if ma.forge_message_type == "ProjectInvite" %>
|
||||
<% inviter = User.find(ma.forge_message_id) %>
|
||||
<ul class="homepageNewsList fl">
|
||||
<li class="homepageNewsPortrait fl">
|
||||
<a href="javascript:void(0);"><%=link_to image_tag(url_to_avatar(inviter), :width => "30", :height => "30"), user_path(inviter) %></a>
|
||||
</li>
|
||||
<li class="homepageNewsPubType fl">
|
||||
<%=link_to inviter, user_path(inviter), :class => "newsBlue homepageNewsPublisher" %>
|
||||
<span class="<%= ma.viewed == 0 ? "homepageNewsTypeNotRead fl" : "homepageNewsType fl" %>">邀请你加入项目:</span>
|
||||
</li>
|
||||
<li class="homepageHomeworkContent fl">
|
||||
<%= link_to ma.project, project_path(ma.project),
|
||||
: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.project %>
|
||||
</div>
|
||||
<% if User.current == @user %>
|
||||
<li class="homepageHomeworkContentWarn fl">
|
||||
<%=link_to "同意加入", {:controller => 'projects', :action => 'member', :id => ma.project_id, :message_id =>ma.id, :key => ma.secret_key},
|
||||
:value => ma.secret_key,
|
||||
:class => "green_btn_cir ml10",
|
||||
:style => "color:#fff" %>
|
||||
</li>
|
||||
<% end %>
|
||||
<li class="homepageNewsTime fl"><%= time_tag(ma.created_at).html_safe %> </li>
|
||||
</ul>
|
||||
<% end %>
|
||||
<% if ma.forge_message_type == "Issue" %>
|
||||
<ul class="homepageNewsList fl">
|
||||
<li class="homepageNewsPortrait fl">
|
||||
|
|
|
@ -25,4 +25,6 @@ zh:
|
|||
mail_course_homework_active: "中发布了作业"
|
||||
mail_attention: "请您关注!"
|
||||
mail_homework_endtime: "作业截止时间快到了!"
|
||||
mail_homework: "作业:"
|
||||
mail_homework: "作业:"
|
||||
mail_anonymous_comment_close: "作业匿评已经关闭!"
|
||||
mail_anonymous_comment_open: "作业匿评已经开启!"
|
|
@ -0,0 +1,8 @@
|
|||
class NormalHomeworkType < ActiveRecord::Migration
|
||||
def up
|
||||
HomeworkCommon.where("homework_type = 0").update_all(:homework_type => 1)
|
||||
end
|
||||
|
||||
def down
|
||||
end
|
||||
end
|
|
@ -0,0 +1,5 @@
|
|||
class AddSecretKeyToForgeMessage < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :forge_messages, :secret_key, :string
|
||||
end
|
||||
end
|
|
@ -11,7 +11,7 @@
|
|||
#
|
||||
# It's strongly recommended to check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(:version => 20150917081214) do
|
||||
ActiveRecord::Schema.define(:version => 20150918135051) do
|
||||
|
||||
create_table "activities", :force => true do |t|
|
||||
t.integer "act_id", :null => false
|
||||
|
@ -575,6 +575,8 @@ ActiveRecord::Schema.define(:version => 20150917081214) do
|
|||
t.integer "viewed"
|
||||
t.datetime "created_at", :null => false
|
||||
t.datetime "updated_at", :null => false
|
||||
t.string "secret_key"
|
||||
t.string "code"
|
||||
end
|
||||
|
||||
create_table "forums", :force => true do |t|
|
||||
|
@ -1329,7 +1331,7 @@ ActiveRecord::Schema.define(:version => 20150917081214) do
|
|||
t.datetime "updated_at", :null => false
|
||||
t.integer "late_penalty", :default => 0
|
||||
t.integer "absence_penalty", :default => 0
|
||||
t.integer "system_score"
|
||||
t.float "system_score", :default => 0.0
|
||||
t.boolean "is_test", :default => false
|
||||
end
|
||||
|
||||
|
|
|
@ -474,7 +474,7 @@ a.homepageSearchIcon:hover {background:url(../images/nav_icon.png) -49px 3px no-
|
|||
.homepageFollow {background:url(../images/homepage_icon.png) -10px -8px no-repeat; width:20px; height:20px; position:absolute; right:9px; top:9px;}
|
||||
.homepageFollowCancel {background:url(../images/homepage_icon.png) -178px -8px no-repeat; width:20px; height:20px; position:absolute; right:9px; top:9px;}
|
||||
.homepageEditProfile {width:16px; height:16px; border-radius:2px; background-color:#888888; position:absolute; right:5px; bottom:5px; font-size:12px; filter:alpha(opacity=50); -moz-opacity:0.5; opacity: 0.5;}
|
||||
.homepageEditProfileIcon {background:url(../images/homepage_icon.png) -14px -37px no-repeat; width:20px; height:20px; display:block;}
|
||||
.homepageEditProfileIcon {background:url(../images/homepage_icon2.png) -14px -37px no-repeat; width:20px; height:20px; display:block;}
|
||||
.homepageImageName {font-size:16px; color:#484848; height:25px; float:left; font-weight: bold; max-width:90px;overflow: hidden; white-space:nowrap; text-overflow:ellipsis;}
|
||||
.homepageImageSexMan {top:116px; left:5px; width:20px; height:20px; background:url(../images/homepage_icon.png) -10px -112px no-repeat; float:left;}
|
||||
.homepageImageSexWomen {width: 20px;height: 20px;background: url(../images/homepage_icon.png) -10px -149px no-repeat;float: left;}
|
||||
|
|
Loading…
Reference in New Issue