Merge branch 'szzh' into develop

This commit is contained in:
huang 2015-10-30 16:51:46 +08:00
commit e41a53cb8f
33 changed files with 2139 additions and 69 deletions

1
.gitignore vendored
View File

@ -29,3 +29,4 @@ vendor/cache
/public/images/avatars
/public/files
/tags
/config/initializers/gitlab_config.rb

View File

@ -56,12 +56,20 @@ class BlogCommentsController < ApplicationController
end
def destroy
@article = BlogComment.find(params[:id])
if @article.parent_id.nil? #如果是文章被删,那么跳转到用户博客界面
@article.children.delete
@article.delete
redirect_to user_blogs_path(:user_id=>User.current)
if @article.parent_id.nil? #如果是文章被删那么跳转到用户博客界面如果带了course_id过来那么就要跳转到课程首页
if params[:course_id] #如果带了课程id过来说明这是课程大纲不要删除只需取消课程大纲就ok了
@course = Course.find(params[:course_id])
@course.outline = 0
@course.save
redirect_to course_path(:id=>params[:course_id])
else
@article.children.delete
@article.delete
redirect_to user_blogs_path(:user_id=>User.current)
end
else#如果是回复被删,
if params[:course_id] #如果呆了course_id过来了那么这是要跳到课程大纲去的
if params[:course_id] #如果了course_id过来了那么这是要跳到课程大纲去的
@article.delete
redirect_to show_course_outline_course_path(:id=>params[:course_id])
else

View File

@ -715,6 +715,7 @@ class CoursesController < ApplicationController
def course_outline
@teacher = User.find(@course.tea_id)
@blog_articles = @teacher.blog.articles
@is_in_show_outline_page = params[:is_in_show_outline_page]
respond_to do |format|
format.js
end
@ -732,6 +733,7 @@ class CoursesController < ApplicationController
def set_course_outline
@course.outline = params[:outline_id]
@course.save
@is_in_show_outline_page = params[:is_in_show_outline_page]
respond_to do |format|
format.js
end

View File

@ -47,10 +47,18 @@ class HomeworkCommonController < ApplicationController
if params[:homework_common]
@homework.name = params[:homework_common][:name]
@homework.description = params[:homework_common][:description]
if params[:homework_common][:publish_time] == ""
@homework.publish_time = Date.today
else
@homework.publish_time = params[:homework_common][:publish_time]
end
@homework.end_time = params[:homework_common][:end_time] || Time.now
@homework.course_id = params[:course_id]
homework_detail_manual = @homework.homework_detail_manual || HomeworkDetailManual.new
if @homework.publish_time <= Date.today && homework_detail_manual.comment_status == 0
homework_detail_manual.comment_status = 1
end
homework_detail_manual.evaluation_start = params[:evaluation_start].blank? ? @homework.end_time + 7 : params[:evaluation_start]
homework_detail_manual.evaluation_end = params[:evaluation_end].blank? ? homework_detail_manual.evaluation_start + 7 : params[:evaluation_end]

View File

@ -263,7 +263,7 @@ update
@course_tag = params[:course]
project_path_cut = RepositoriesHelper::PROJECT_PATH_CUT
ip = RepositoriesHelper::REPO_IP_ADDRESS
gitlab_address = RepositoriesHelper::REPO_GITLAB_ADDRESS
gitlab_address = Redmine::Configuration['gitlab_address']
if @repository.type.to_s=="Repository::Gitlab"
@repos_url = "http://"+gitlab_address.to_s+"/"+@project.owner.to_s+"/"+@repository.identifier+"."+"git"
else

View File

@ -243,7 +243,7 @@ class UsersController < ApplicationController
#status 1 同意 2 拒绝
def dealwith_apply_request
@msg = CourseMessage.find(params[:msg_id])
#CourseMessage content存的是role 7教辅 9 教师
case params[:agree]
when 'Y'
apply_user = User.find(@msg.course_message_id)
@ -368,8 +368,12 @@ class UsersController < ApplicationController
if User.current == @user
@page = params[:page] ? params[:page].to_i + 1 : 0
user_course_ids = @user.courses.empty? ? "(-1)" :"(" + @user.courses.visible.map{|course| course.id}.join(",") + ")"
@homework_commons = HomeworkCommon.where("course_id in #{user_course_ids}").order("created_at desc").limit(10).offset(@page * 10)
@is_teacher = User.current.user_extensions && User.current.user_extensions.identity == 0 && User.current.allowed_to?(:add_course, nil, :global => true)
if @is_teacher
@homework_commons = HomeworkCommon.where("course_id in #{user_course_ids}").order("created_at desc").limit(10).offset(@page * 10)
else
@homework_commons = HomeworkCommon.where("course_id in #{user_course_ids} and publish_time <= '#{Date.today}'").order("created_at desc").limit(10).offset(@page * 10)
end
@is_in_course = params[:is_in_course].to_i || 0
respond_to do |format|
format.js
@ -493,8 +497,12 @@ class UsersController < ApplicationController
homework = HomeworkCommon.new
homework.name = params[:homework_common][:name]
homework.description = params[:homework_common][:description]
homework.end_time = params[:homework_common][:end_time] || Time.now
homework.publish_time = Time.now
homework.end_time = params[:homework_common][:end_time] || Date.today
if params[:homework_common][:publish_time] == ""
homework.publish_time = Date.today
else
homework.publish_time = params[:homework_common][:publish_time]
end
homework.homework_type = params[:homework_type].to_i || 1
homework.late_penalty = 10
homework.teacher_priority = 1
@ -506,7 +514,11 @@ class UsersController < ApplicationController
homework_detail_manual = HomeworkDetailManual.new
homework_detail_manual.ta_proportion = homework.homework_type == 1 ? 0.6 : 0.3
homework_detail_manual.comment_status = 1
if homework.publish_time > Date.today
homework_detail_manual.comment_status = 0
else
homework_detail_manual.comment_status = 1
end
homework_detail_manual.evaluation_start = params[:evaluation_start].blank? ? homework.end_time + 7 : params[:evaluation_start]
homework_detail_manual.evaluation_end = params[:evaluation_end].blank? ? homework_detail_manual.evaluation_start + 7 : params[:evaluation_end]
homework_detail_manual.evaluation_num = params[:evaluation_num] || 3

View File

@ -45,6 +45,11 @@ module RepositoriesHelper
end
end
def user_commit_rep(mail)
user = User.find_by_mail(mail)
user.nil? ? User.find(2) : User.find_by_mail(mail)
end
def render_properties(properties)
unless properties.nil? || properties.empty?
content = ''

View File

@ -23,7 +23,8 @@ class HomeworkCommon < ActiveRecord::Base
:description => :description,
:author => :author,
:url => Proc.new {|o| {:controller => 'student_work', :action => 'index', :homework => o.id}}
after_create :act_as_activity, :send_mail, :act_as_course_activity, :act_as_course_message
after_create :act_as_activity, :send_mail, :act_as_course_message
after_save :act_as_course_activity
after_destroy :delete_kindeditor_assets
def act_as_activity
@ -33,17 +34,27 @@ class HomeworkCommon < ActiveRecord::Base
#课程动态公共表记录
def act_as_course_activity
if self.course
self.course_acts << CourseActivity.new(:user_id => self.user_id,:course_id => self.course_id)
if self.homework_detail_manual.comment_status == 0
self.course_acts.destroy_all
else
if self.course_acts.size == 0
self.course_acts << CourseActivity.new(:user_id => self.user_id,:course_id => self.course_id)
end
end
end
end
#课程作业消息记录
def act_as_course_message
if self.course
self.course.members.each do |m|
# if m.user_id != self.user_id
if self.homework_detail_manual.comment_status == 0
self.course_messages.destroy_all
else
self.course.members.each do |m|
# if m.user_id != self.user_id
self.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => self.course_id, :viewed => false)
# end
# end
end
end
end
end
@ -54,7 +65,9 @@ class HomeworkCommon < ActiveRecord::Base
end
def send_mail
Mailer.run.homework_added(self)
if self.homework_detail_manual.comment_status != 0
Mailer.run.homework_added(self)
end
end
def is_program_homework?

View File

@ -260,7 +260,7 @@ class User < Principal
@blog = Blog.where("author_id = #{self.id}").all[0]
if @blog.nil?
#如果某个user的blog不存在那么就创建一条并且跳转
@blog = Blog.create(:name=>(User.find(self.id).realname),
@blog = Blog.create(:name=>(User.find(self.id).realname.blank? ? User.find(self.id).login : User.find(self.id).realname ),
:description=>'',
:author_id=>self.id)
@blog.save

View File

@ -301,26 +301,46 @@ class CoursesService
#@state == 5 您还未登录
#@state == 6 申请成功,请等待审核完毕
#@state == 7 您已经发送过申请了,请耐心等待
#@state == 8 您已经是该课程的教师了
#@state == 9 您已经是该课程的教辅了
#@state 其他 未知错误,请稍后再试
def join_course params,current_user
course = Course.find_by_id params[:object_id]
@state = 10
if course
if course_endTime_timeout? course
@state = 2
else
if current_user.member_of_course?(course) #如果已经是成员
member = course.members.where("user_id=#{current_user.id} and course_id=#{course.id}")[0]
roleName = member.roles[0].name if member
if params[:course_password] == course.password
#如果加入角色为学生
if params[:role] == "10"
#如果加入角色为学生 并且当前是学生
if params[:role] == "10" && roleName == "Student"
@state = 3
elsif current_user.allowed_to?(:as_teacher,course)
@state = 3
else
Mailer.run.join_course_request(course, User.current, params[:role])
#如果加入角色为教师或者教辅
CourseMessage.create(:user_id => course.tea_id, :course_id => course.id, :viewed => false,:content=> params[:role],:course_message_id=>User.current.id,:course_message_type=>'JoinCourseRequest',:status=>0)
@state = 6
#如果加入的角色为老师,并且当前已经是老师
elsif params[:role] == "9" && roleName == "Teacher"
@state = 8
#如果加入的角色教辅并且当前为教辅
elsif params[:role] == "7" && roleName == "TeachingAsistant"
@state = 9
#如果加入角色为教师或者教辅,并且当前是学生,或者是要成为教辅,当前不是教辅,或者要成为教师,当前不是教师。那么要发送请求
elsif (params[:role] != "10" && roleName == "Student") || (params[:role] == "7" && roleName != "TeachingAsistant" ) || (params[:role] == "9" && roleName != "Teacher" )
#如果已经发送过消息了,那么就要给个提示
if CourseMessage.where("course_message_type = 'JoinCourseRequest' and user_id = #{course.tea_id} and content = #{params[:role]} and course_message_id = #{User.current.id} and course_id = #{course.id} and status = 0 ").count != 0
@state = 7
else
Mailer.run.join_course_request(course, User.current, params[:role])
CourseMessage.create(:user_id => course.tea_id, :course_id => course.id, :viewed => false,:content=> params[:role],:course_message_id=>User.current.id,:course_message_type=>'JoinCourseRequest',:status=>0)
@state = 6
end
#如果加入角色是学生,但是是当前课程的教师或者教辅
elsif params[:role] == "10" && roleName != "Student"
member.role_ids = [params[:role]]
member.save
StudentsForCourse.create(:student_id => current_user.id, :course_id => params[:object_id])
@state = 0
end
else
@state = 1

View File

@ -23,7 +23,7 @@
<input type="hidden" name="blog_comment[title]" id="reply_subject">
<textarea placeholder="有问题或有建议,请直接给我留言吧!" style="display: none" nhname='new_message_textarea_<%= reply.id%>' name="blog_comment[content]"></textarea>
<div nhname='toolbar_container_<%= reply.id%>' style="float:left; margin-left: 5px; padding-top:3px;"></div>
<a id="new_message_submit_btn_<%= reply.id%>" href="javascript:void(0)" class="blue_n_btn fr" style="display:none;margin-top:6px;">发送</a>
<a id="new_message_submit_btn_<%= reply.id%>" href="javascript:void(0)" class="blue_n_btn fr" style="display:none;margin-top:2px;">发送</a>
<div class="cl"></div>
<p nhname='contentmsg_<%= reply.id%>'></p>
<% end%>

View File

@ -10,6 +10,7 @@
</div>
<span class="f12 c_red fl mb8" id="course_outline_hint" style="display: none">未搜索到对应大纲,请重新输入</span>
<%= form_tag(url_for(:controller=>'courses',:action=>'set_course_outline',:id=>course.id),:method=>'post',:remote=>'true') do %>
<input name="is_in_show_outline_page" value="<%= show_page %>" type="hidden" />
<div class="blogBlock fl" id="course_outline_list" >
<% unless articles.blank? %>
<% articles.each do |article|%>
@ -24,7 +25,7 @@
<% end %>
</div>
<div>
<div class="courseSendSubmit"><a href="javascript:void(0);" class="sendSourceText" onclick="$(this).parent().parent().submit();">确定</a></div>
<div class="courseSendSubmit"><a href="javascript:void(0);" class="sendSourceText" onclick="if($('input[name=outline_id]:radio:checked').length != 0 ) { $(this).parent().parent().submit(); }else{ return false;}">确定</a></div>
<div class="courseSendCancel"><a href="javascript:void(0);" class="sendSourceText" onclick="hideModal();">取消</a></div>
</div>
<div class="cl"></div>

View File

@ -1,4 +1,4 @@
$('#ajax-modal').html('<%= escape_javascript(render :partial => 'course_outlines_list',:locals => {:articles=>@blog_articles,:course=>@course}) %>');
$('#ajax-modal').html('<%= escape_javascript(render :partial => 'course_outlines_list',:locals => {:articles=>@blog_articles,:course=>@course,:show_page=>@is_in_show_outline_page}) %>');
showModal('ajax-modal', '300px');
//$('#ajax-modal').css('height','250px');
$('#ajax-modal').css('padding-top','0px');
@ -6,4 +6,4 @@ $('#ajax-modal').siblings().remove();
$('#ajax-modal').before(' <a href="javascript:void(0);" onclick="hideModal()" class="resourceClose" style="margin-left: 285px"></a>');
$('#ajax-modal').parent().css("top","30%").css("left","50%");
$('#ajax-modal').parent().addClass("courseOutlinePopup");
$('#ajax-modal').css("padding-left","16px")//.css("padding-bottom","16px");
$('#ajax-modal').css("padding-left","16px")//.css("padding-bottom","16px");

View File

@ -24,6 +24,14 @@ hidden_join_course_form();
<% elsif @state == 7%>
alert("您已经发送过申请了,请耐心等待");
hidden_join_course_form();
<% elsif @state == 8%>
alert("您已经是该课程的教师了");
hidden_join_course_form();
window.location.href= "http://"+"<%= Setting.host_name%>"+"/courses/" + "<%= @course.id%>"
<% elsif @state == 9%>
alert("您已经是该课程的教辅了");
hidden_join_course_form();
window.location.href= "http://"+"<%= Setting.host_name%>"+"/courses/" + "<%= @course.id%>"
<% else %>
alert("未知错误,请稍后再试");
<% end %>

View File

@ -3,3 +3,6 @@ hideModal();
<% else %>
$("#course_outline_bar").html('<a href="<%=show_course_outline_course_path(@course) %>" title="课程大纲" class="mr5 syllabusIcon fl"> </a>')
<%end %>
<%if @is_in_show_outline_page && @is_in_show_outline_page == 'Y'%>
window.location.href='<%=show_course_outline_course_path(@course) %>';
<% end %>

View File

@ -1,5 +1,16 @@
<%= javascript_include_tag "/assets/kindeditor/kindeditor",'/assets/kindeditor/pasteimg',"init_activity_KindEditor",'blog' %>
<style type="text/css">
/*回复框*/
div.ke-toolbar{display:none;width:400px;border:none;background:none;padding:0px 0px;}
span.ke-toolbar-icon{line-height:26px;font-size:14px;padding-left:26px;}
span.ke-toolbar-icon-url{background-image:url( /images/public_icon.png )}
div.ke-toolbar .ke-outline{padding:0px 0px;line-height:26px;font-size:14px;}
span.ke-icon-emoticons{background-position:0px -671px;width:50px;height:26px;}
span.ke-icon-emoticons:hover{background-position:-79px -671px;width:50px;height:26px;}
div.ke-toolbar .ke-outline{border:none;}
.ke-inline-block{display: none;}
div.ke-container{float:left;}
</style>
<script type="text/javascript">
$(function(){
$("#RSide").removeAttr("id");
@ -24,25 +35,45 @@
}
}
$(function() {
init_activity_KindEditor_data(<%= @article.id%>,null,"85%");
init_activity_KindEditor_data(<%= @article.id%>,null,"87%");
showNormalImage('message_description_<%= @article.id %>');
});
</script>
<div class="postRightContainer ml10" onmouseover="$('#message_setting_<%= @article.id%>').show();" onmouseout="$('#message_setting_<%= @article.id%>').hide();">
<div class="postRightContainer ml10" >
<div class="postThemeContainer">
<div class="postDetailPortrait">
<%= link_to image_tag(url_to_avatar(@article.author),:width=>50,:height => 50,:alt=>'图像' ),user_path(@article.author) %>
</div>
<div class="postThemeWrap">
<% if @article.author.id == User.current.id%>
<% if User.current && @article.author.id == User.current.id%>
<div class="homepagePostSetting" id="message_setting_<%= @article.id%>" >
<ul>
<li class="homepagePostSettingIcon">
<ul class="homepagePostSettiongText">
<li>
<a class="postOptionLink " onclick="course_outline('<%= @course.id%>','Y')" >重设大纲</a>
</li>
<li>
<%= link_to(
'取消大纲',
{:controller => 'blog_comments',:action => 'destroy',:user_id=>BlogComment.find(@course.outline).author_id,:blog_id=>BlogComment.find(@course.outline).blog_id, :id => @course.outline,:course_id=>@course.id},
:method => :delete,
:data => {:confirm => l(:text_are_you_sure)},
:class => 'postOptionLink'
) if User.current && User.current.id == @article.author.id %>
</li>
</ul>
</li>
</ul>
</div>
<!--<div class="homepagePostSetting" id="message_setting_<%#= @article.id%>" >-->
<!--<ul>-->
<!--<li class="syllabusSettingIcon" >-->
<!--</li>-->
<!--</ul>-->
<!--</div>-->
<a class="syllabusSettingIcon fr" style="width: 100px" onclick="course_outline('<%= @course.id%>')" ><span class="f14 fontGrey2" style="padding-left: 20px">[设置大纲]</span>
</a>
<!--<a class="syllabusSettingIcon fr" style="width: 100px" onclick="course_outline('<%= @course.id%>')" ><span class="f14 fontGrey2" style="padding-left: 20px">[设置大纲]</span>-->
<!--</a>-->
<%end%>
<div class="postDetailTitle fl" style="width: 550px !important;">
<a href="javascript:void(0);" class="f14 linkGrey4 fb" style="overflow:hidden;">主题: <%= @article.title%></a>
@ -142,18 +173,39 @@
<% end %>
<div class="cl"></div>
<% if !@article.locked? && User.current.logged?%>
<div class="talkWrapMsg" nhname="about_talk_reply">
<em class="talkWrapArrow"></em>
<div class="cl"></div>
<div class="talkConIpt ml5 mb10" id="reply<%= @article.id %>">
<%= form_for :blog_comment, :url => {:action => 'reply',:controller => 'blog_comments',:user_id=>@article.author.id,:blog_id=>@article.blog_id, :id => @article.id}, :html => {:multipart => true, :id => 'message_form'} do |f| %>
<input type="hidden" name="course_id" value="<%= @course.id%>">
<%= render :partial => 'blog_comments/reply_form', :locals => {:f => f,:user=>@user,:article=>@article} %>
<%= link_to l(:button_cancel), "javascript:void(0)", :onclick => 'canel_message_replay();', :class => " grey_btn fr c_white mt10 mr5" %>
<%= link_to l(:button_submit), "javascript:void(0)", :onclick => 'submit_message_replay();', :class => "blue_btn fr c_white mt10", :style => "margin-right: 5px;" %>
<% end %>
<!--<div class="talkWrapMsg" nhname="about_talk_reply">-->
<!--<em class="talkWrapArrow"></em>-->
<!--<div class="cl"></div>-->
<!--<div class="talkConIpt ml5 mb10" id="reply<%#= @article.id %>">-->
<!--<%#= form_for :blog_comment, :url => {:action => 'reply',:controller => 'blog_comments',:user_id=>@article.author.id,:blog_id=>@article.blog_id, :id => @article.id}, :html => {:multipart => true, :id => 'message_form'} do |f| %>-->
<!--<input type="hidden" name="course_id" value="<%#= @course.id%>">-->
<!--<%#= render :partial => 'blog_comments/reply_form', :locals => {:f => f,:user=>@user,:article=>@article} %>-->
<!--<%#= link_to l(:button_cancel), "javascript:void(0)", :onclick => 'canel_message_replay();', :class => " grey_btn fr c_white mt10 mr5" %>-->
<!--<%#= link_to l(:button_submit), "javascript:void(0)", :onclick => 'submit_message_replay();', :class => "blue_btn fr c_white mt10", :style => "margin-right: 5px;" %>-->
<!--<%# end %>-->
<!--<div class="cl"></div>-->
<!--</div>-->
<!--</div>-->
<div class="homepagePostReplyContainer borderBottomNone minHeight48">
<div class="homepagePostReplyPortrait mr15 imageFuzzy" id="reply_image_<%= @article.id%>"><%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33"), user_path(@article.author_id), :alt => "用户头像" %></div>
<div class="homepagePostReplyInputContainer" style="margin-top: 8px">
<div nhname='new_message_<%= @article.id%>' style="display:none;">
<%= form_for 'blog_comment',:url => {:action => 'reply',:controller => 'blog_comments',:user_id=>@article.author.id,:blog_id=>@article.blog_id, :id => @article.id},:method => "post",:html => {:multipart => true, :id => 'message_form'} do |f|%>
<input type="hidden" name="course_id" value="<%= @course.id%>"
<input type="hidden" name="blog_comment[title]" value="RE:<%= @article.title%>">
<input type="hidden" name="blog_comment[sticky]" value="0">
<input type="hidden" name="quote[quote]" value="">
<input type="hidden" name="blog_comment[locked]" value="0">
<textarea placeholder="有问题或有建议,请直接给我留言吧!" style="display: none" nhname='new_message_textarea_<%= @article.id%>' name="blog_comment[content]"></textarea>
<div nhname='toolbar_container_<%= @article.id%>' style="float:left; margin-left: 5px;"></div>
<a id="new_message_submit_btn_<%= @article.id%>" href="javascript:void(0)" class="blue_n_btn fr" style="display:none;margin-top:2px;">发送</a>
<div class="cl"></div>
<p nhname='contentmsg_<%= @article.id%>'></p>
<% end%>
</div>
<div class="cl"></div>
</div>
<div class="cl"></div>
</div>
<% end %>
</div>

View File

@ -1,6 +1,7 @@
<script type="text/javascript">
function reset_homework(){
$("#homework_name").val("");
$("#homework_publish_time").val("");
$("#homework_end_time").val("");
$("#course_id").val($("#option_select").val());
$("#homework_attachments").html("<%= escape_javascript(render :partial => 'users/user_homework_attachment', :locals => { :container => HomeworkCommon.new })%>");

View File

@ -1,6 +1,7 @@
<script type="text/javascript">
function reset_homework(){
$("#homework_name").val("");
$("#homework_publish_time").val("");
$("#homework_end_time").val("");
$("#course_id").val($("#option_select").val());
$("#homework_attachments").html("<%= escape_javascript(render :partial => 'users/user_homework_attachment', :locals => { :container => HomeworkCommon.new,:has_program => true })%>");

View File

@ -86,11 +86,15 @@
</span>
<% end %>
<span id="course_outline_bar">
<%if @course.tea_id == User.current.id && (@course.outline == 0 || BlogComment.where(:id=>@course.outline).count == 0) %>
<%if User.current && @course.tea_id == User.current.id && (@course.outline == 0 || BlogComment.where(:id=>@course.outline).count == 0) %>
<a href="javascript:void(0);" title="设置课程大纲" onclick="course_outline('<%= @course.id%>')" class="mr5 syllabusSetting fl"> </a>
<% elsif @course.tea_id == User.current.id && @course.outline != 0 && BlogComment.where(:id=>@course.outline).count != 0%>
<% elsif User.current && @course.tea_id == User.current.id && @course.outline != 0 && BlogComment.where(:id=>@course.outline).count != 0%>
<a href="<%=show_course_outline_course_path(@course) %>" title="课程大纲" class="mr5 syllabusIcon fl"> </a>
<% elsif @course.tea_id != User.current.id %>
<% elsif User.current && @course.tea_id != User.current.id && !@course.is_public? && User.current.member_of_course?(@course)%>
<a href="<%=show_course_outline_course_path(@course) %>" title="课程大纲" class="mr5 syllabusIcon fl"> </a>
<% elsif User.current && @course.tea_id != User.current.id && @course.is_public?%>
<a href="<%=show_course_outline_course_path(@course) %>" title="课程大纲" class="mr5 syllabusIcon fl"> </a>
<%else%>
<%end %>
</span>
</div>
@ -233,6 +237,7 @@
}
}else{
$("#course_outline_list").html('');
$("#course_outline_hint").show();
}
}

View File

@ -16,15 +16,31 @@
<% show_diff = revisions.size > 1 %>
<% line_num = 1 %>
<% revisions.each do |changeset| %>
<tr class="changeset <%= cycle 'odd', 'even' %>">
<td class="id"><%= h truncate(changeset.id.to_s, :length => 20) %></td>
<!--<td class="checkbox"><%#= radio_button_tag('rev_to', changeset.id, (line_num==2), :id => "cbto-#{line_num}", :onclick => "if ($('#cb-#{line_num}').attr('checked')) {$('#cb-#{line_num-1}').attr('checked',true);}") if show_diff && (line_num > 1) %></td>-->
<td class="committed_on"><%= format_time(changeset.created_at) %></td>
<td class="author"><%= h truncate(changeset.author_name.to_s, :length => 30) %></td>
<td class="comments"><%= textilizable(truncate_at_line_break(changeset.message)) %></td>
</tr>
<% line_num += 1 %>
<div class="col-md-10 col-sm-12">
<ul class="bordered-list">
<li class="commit js-toggle-container">
<div class="commit-row-title">
<strong class="str-truncated">
<a class="commit-row-message"><%= textilizable(truncate_at_line_break(changeset.message)) %></a>
</strong>
<div class="pull-right" title="修订号">
<%= h truncate(changeset.short_id.to_s, :length => 20) %>
</div>
<div class="notes_count">
</div>
</div>
<div class="commit-row-info">
<a class="commit-author-link has_tooltip"> <span class="commit-author-name">
<%= image_tag(url_to_avatar(user_commit_rep(changeset.author_email)), :width => "20", :height => "20", :class => "fl portraitRadius mt2 ml4 mr5") %>
<%= link_to user_commit_rep(changeset.author_email), user_path(user_commit_rep(changeset.author_email)), :length => 30 %></span></a>
提交于
<div class="committed_ago">
<time class="time_ago js-timeago" title="<%= changeset.created_at %>"><%= time_tag(changeset.created_at) %> 前</time> &nbsp;
</div>
</div>
</li>
</ul>
</div>
<% end %>
</tbody>
</table>

View File

@ -30,8 +30,8 @@
<div class="cl"></div>
<div class="recordBanner mt10">
<% if @changesets && !@changesets.empty? %>
<%= image_tag(url_to_avatar(@changesets_latest_coimmit.author_name), :width => "25", :height => "25", :class => "fl portraitRadius mt2 ml4 mr5") %>
<span class="fl"><div class="fb fontGrey3 mr5 fl"><%=link_to @changesets_latest_coimmit.author_name, user_path(@changesets_latest_coimmit.author_name) %></div>
<%= image_tag(url_to_avatar(user_commit_rep(@changesets_latest_coimmit.author_email)), :width => "25", :height => "25", :class => "fl portraitRadius mt2 ml4 mr5") %>
<span class="fl"><div class="fb fontGrey3 mr5 fl"><%=link_to user_commit_rep(@changesets_latest_coimmit.author_email), user_path(@changesets_latest_coimmit.author_name) %></div>
<div class="fl">提交于<%= time_tag(@changesets_latest_coimmit.created_at) %></div>
<div class="commit_content_dec fl" title="<%= @changesets_latest_coimmit.comments %>"><%= @changesets_latest_coimmit.message %></div>
</span>

View File

@ -15,7 +15,9 @@
</span>
<% if homework_common.homework_detail_manual%>
<% if homework_common.homework_detail_manual.comment_status == 1%>
<% if homework_common.homework_detail_manual.comment_status == 0 %>
<span class="grey_btn_cir ml10">未发布</span>
<% elsif homework_common.homework_detail_manual.comment_status == 1%>
<span class="grey_btn_cir ml10">未开启匿评</span>
<% elsif homework_common.homework_detail_manual.comment_status == 2%>
<span class="green_btn_cir ml10">匿评中</span>
@ -72,7 +74,9 @@
<%= link_to("评分设置", score_rule_set_homework_common_path(homework_common, :is_in_course => is_in_course),:class => "postOptionLink", :remote => true) %>
</li>
<li>
<%= link_to("匿评设置", start_evaluation_set_homework_common_path(homework_common),:class => "postOptionLink", :remote => true) if homework_common.homework_detail_manual.comment_status == 1%>
<% if homework_common.homework_detail_manual.comment_status == 0 || homework_common.homework_detail_manual.comment_status == 1%>
<%= link_to("匿评设置", start_evaluation_set_homework_common_path(homework_common),:class => "postOptionLink", :remote => true)%>
<% end %>
</li>
<li>
<%= homework_anonymous_comment homework_common %>

View File

@ -18,6 +18,10 @@
<div class=" mt10">
<%= link_to("导入作业", user_import_homeworks_user_path(User.current.id,:select_course => defined?(select_course)),:class => "BlueCirBtn fl mr10",:remote => true) unless edit_mode%>
<div class="calendar_div fl">
<input type="text" name="homework_common[publish_time]" id="homework_publish_time" placeholder="发布日期" class="InputBox fl W120 calendar_input" readonly="readonly" value="<%= homework.publish_time%>" >
<%= calendar_for('homework_publish_time')%>
</div>
<div class="calendar_div fl ml10">
<input type="text" name="homework_common[end_time]" id="homework_end_time" placeholder="截止日期" class="InputBox fl W120 calendar_input" readonly="readonly" value="<%= homework.end_time%>" >
<%= calendar_for('homework_end_time')%>
</div>

View File

@ -1,6 +1,7 @@
<script type="text/javascript">
function reset_homework(){
$("#homework_name").val("");
$("#homework_publish_time").val("");
$("#homework_end_time").val("");
$("#course_id").val($("#option_select").val());
$("#homework_attachments").html("<%= escape_javascript(render :partial => 'users/user_homework_attachment', :locals => { :container => HomeworkCommon.new,:has_program => true })%>");

View File

@ -200,6 +200,9 @@ default:
repository_root_path: '/tmp/htdocs'
judge_server: 'http://judge.trustie.net/'
# Git's url
gitlab_address: 'http://gitfast.trustie.net'
# specific configuration options for production environment
# that overrides the default ones
production:

View File

@ -1,7 +1,7 @@
Gitlab.configure do |config|
# config.endpoint = 'http://192.168.41.130:3000/trustie/api/v3' # API endpoint URL, default: ENV['GITLAB_API_ENDPOINT']
# config.private_token = 'cK15gUDwvt8EEkzwQ_63' # user's private token, default: ENV['GITLAB_API_PRIVATE_TOKEN']
config.endpoint = 'http://git.trustie.net/trustie/api/v3' # API endpoint URL, default: ENV['GITLAB_API_ENDPOINT']
config.endpoint = 'http://gitfast.trustie.net/api/v3' # API endpoint URL, default: ENV['GITLAB_API_ENDPOINT']
config.private_token = 'fPc_gBmEiSANve8TCfxW' # user's private token, default: ENV['GITLAB_API_PRIVATE_TOKEN']
# Optional
# config.user_agent = 'Custom User Agent' # user agent, default: 'Gitlab Ruby Gem [version]'

View File

@ -0,0 +1,16 @@
class UpdateHomeworkCommonPublishTime < ActiveRecord::Migration
def up
count = HomeworkCommon.all.count / 30 + 2
transaction do
for i in 1 ... count do i
HomeworkCommon.page(i).per(30).each do |homework|
homework.publish_time = homework.created_at.strftime('%d-%b-%Y')
homework.save
end
end
end
end
def down
end
end

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,23 @@
#coding=utf-8
namespace :homework_publishtime do
desc "start publish homework"
task :publish => :environment do
homework_commons = HomeworkCommon.where("publish_time = '#{Date.today}'")
homework_commons.each do |homework|
homework_detail_manual = homework.homework_detail_manual
if homework_detail_manual.comment_status == 0
homework_detail_manual.update_column('comment_status', 1)
course = homework.course
course.members.each do |m|
homework.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => course.id, :viewed => false, :status => nil)
end
if homework.course_acts.size == 0
homework.course_acts << CourseActivity.new(:user_id => homework.user_id,:course_id => homework.course_id)
end
# 邮件通知
Mailer.run.homework_added(homework)
end
end
end
end

View File

@ -629,6 +629,9 @@ function submit_homework(id){
else if(!regex_homework_end_time()){
$("#homework_end_time").focus();
}
else if(!regex_homework_end_publish_time()){
$("#homework_end_time").focus();
}
else if(!regex_course_id()){
$("#course_id").focus();
}
@ -654,6 +657,27 @@ function regex_homework_name()
return true;
}
}
//验证发布时间不能大于截止时间
function regex_homework_end_publish_time()
{
var myDate = new Date();
if($.trim($("#homework_publish_time").val()) == "")
{
$("#homework_publish_time").val(myDate.toLocaleDateString());
}
var publish_time = Date.parse($("#homework_publish_time").val());
if(end_time < publish_time)
{
$("#homework_end_time_span").text("截止日期不能小于发布日期");
return false;
}
else
{
$("#homework_end_time_span").text("");
return true;
}
}
//验证截止时间
function regex_homework_end_time()
{
@ -1224,14 +1248,14 @@ var autoTextarea2 = function (elem,elem2, extra, maxHeight) {
change();
};
//课程大纲选择请求
//课程大纲选择请求,第二个参数是可选的,判断当前页面是大纲显示页面还是 课程首页
function course_outline(id){
$.get(
' /courses/'+id+'/course_outline'
' /courses/'+id+'/course_outline'+"?is_in_show_outline_page="+(arguments[1] ? arguments[1] : 'N')
)
}
//$(function(){
// $('#course_outline_search').on('input',function(){
// alert('<%= @course.id%>')
// })
//})
//})

View File

@ -63,6 +63,9 @@ function submit_homework(id){
else if(!regex_homework_end_time()){
$("#homework_end_time").focus();
}
else if(!regex_homework_end_publish_time()){
$("#homework_end_time").focus();
}
else if(!regex_course_id()){
$("#course_id").focus();
}
@ -88,6 +91,28 @@ function regex_homework_name()
return true;
}
}
//验证发布时间不能大于截止时间
function regex_homework_end_publish_time()
{
var myDate = new Date();
if($.trim($("#homework_publish_time").val()) == "")
{
$("#homework_publish_time").val(myDate.toLocaleDateString());
}
var end_time = Date.parse($("#homework_end_time").val());
var publish_time = Date.parse($("#homework_publish_time").val());
if(end_time < publish_time)
{
$("#homework_end_time_span").text("截止日期不能小于发布日期");
return false;
}
else
{
$("#homework_end_time_span").text("");
return true;
}
}
//验证截止时间
function regex_homework_end_time()
{

View File

@ -148,7 +148,7 @@ a.postReplyCancel:hover {color:#ffffff;}
.homepagePostSetting ul li:hover ul {display:block;}
.homepagePostSettingIcon {background:url(../images/homepage_icon.png) -93px -5px no-repeat; width:20px; height:20px;}
.homepagePostSettiongText {width:85px; line-height:2; font-size:12px; color:#616060; background-color:#ffffff; border:1px solid #eaeaea; border-radius:3px; position:absolute; left:-68px; top:20px; padding:5px 0px; display:none;}
.homepagePostSettingIcon:hover {background:url(../images/homepage_icon.png) -93px -44px no-repeat;}
.homepagePostSettingIcon:hover {background:url(../images/homepage_icon.png) -93px -44px no-repeat;cursor: pointer}
a.postOptionLink {color:#616060; display:block; width:55px; padding:0px 15px;}
a.postOptionLink:hover {color:#ffffff; background-color:#269ac9;}
.homepagePostReplyPortrait {float:left; width:33px;}
@ -1095,7 +1095,7 @@ a.postRouteLink:hover {text-decoration:underline;}
.searchIconPopup{width:31px; height:25px; background-color:#ffffff; background:url(../images/homepage_icon.png) 5px -394px no-repeat; display:inline-block; float:left; cursor: pointer;}
.searchIconPopup:hover {background:url(../images/homepage_icon.png) 5px -420px no-repeat;}
.blogTitle {max-width:240px; font-size:12px; color:#484848; overflow:hidden; text-overflow:ellipsis; white-space:nowrap;}
.blogBlock {overflow-x:hidden; max-height:200px;min-height: 200px; overflow-y:auto; margin-bottom:5px;}
.blogBlock {overflow-x:hidden; max-height:200px;min-height: 20px; overflow-y:auto; margin-bottom:5px;width: 246px}
.blogRow {width:280px; height:15px; line-height:15px;}
.blogSearchBox {border:1px solid #e6e6e6; height:25px; background-color:#ffffff; margin-top:8px; margin-bottom:8px;}/*width:280px;*/
.blogSearchContent {border:none; outline:none; background-color:#ffffff; width:216px; height:25px; padding-left:10px; display:inline-block; float:left;}

View File

@ -219,3 +219,60 @@
.mt1 {margin-top:1px;}
.mt2 {margin-top:2px;}
.commit_content_dec{width: 300px;overflow: hidden; white-space: nowrap;text-overflow: ellipsis;}
/*提交信息列表*/
.col-md-10 {
width: 100%;
}
ul.bordered-list {
margin: 5px 0px;
padding: 0px;
}
ul.bordered-list li {
padding: 5px 0px;
border-bottom: 1px solid #EEE;
overflow: hidden;
display: block;
margin: 0px;
}
.commits-row ul li.commit {
padding: 8px 0px;
}
li.commit .commit-row-title {
font-size: 15px;
line-height: 20px;
margin-bottom: 2px;
}
li.commit .commit-row-title .str-truncated {
max-width: 70%;
}
.str-truncated {
display: inline-block;
overflow: hidden;
text-overflow: ellipsis;
vertical-align: top;
white-space: nowrap;
max-width: 82%;
}
li.commit .commit-row-title .commit-row-message {
color: #444;
}
.pull-right {
float: right;
color: #777;
}
li.commit .commit-row-title .commit_short_id {
min-width: 65px;
font-family: "Menlo","Liberation Mono","Consolas","DejaVu Sans Mono","Ubuntu Mono","Courier New","andale mono","lucida console",monospace;
}
li.commit .commit-row-info {
color: #777;
line-height: 24px;
font-size: 13px;
}
li.commit .commit-row-info a {
color: #777;
}
li.commit .commit-row-info .committed_ago {
display: inline-block;
}