Merge branch 'cxt_course' into develop

Conflicts:
	db/schema.rb
This commit is contained in:
cxt 2016-10-19 18:11:02 +08:00
commit 6109a1602b
47 changed files with 793 additions and 79 deletions

View File

@ -0,0 +1,3 @@
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/

View File

@ -0,0 +1,3 @@
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/

View File

@ -0,0 +1,3 @@
// Place all the styles related to the ArticleHomepages controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/

View File

@ -0,0 +1,3 @@
// Place all the styles related to the Homepages controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/

View File

@ -0,0 +1,71 @@
class ArticleHomepagesController < ApplicationController
before_filter :find_article_homepage, :only => [:show, :edit, :update, :destroy]
def new
@article = ArticleHomepage.new
respond_to do |format|
format.html {render :layout=>'static_base'}
end
end
def create
if User.current.logged?
@article = ArticleHomepage.new
@article.user = User.current
@article.homepage_id = User.current.homepage.id
@article.title = params[:article_homepage][:title]
@article.content = params[:article_homepage][:content]
if @article.save
if params[:set_homepage]
User.current.homepage.update_attribute(:article_id, @article.id)
end
redirect_to user_homepages_path(:user_id => User.current.id)
end
else
redirect_to signin_path
end
end
def show
respond_to do |format|
format.html {render :layout => 'clear_base'}
end
end
def edit
if User.current.admin? || User.current.id == @article.user_id
respond_to do |format|
format.html { render :layout => 'static_base' }
end
else
render_403
end
end
def update
if User.current.logged?
@article.title = params[:article_homepage][:title]
@article.content = params[:article_homepage][:content]
if @article.save
redirect_to user_homepages_path(:user_id => User.current.id)
end
else
redirect_to signin_path
end
end
def destroy
if @article
if @article.homepage.article_id == @article.id
@article.homepage.update_attribute(:article_id, nil)
end
@article.destroy
redirect_to user_homepages_path(:user_id => User.current.id)
end
end
private
def find_article_homepage
@article = ArticleHomepage.find params[:id]
end
end

View File

@ -0,0 +1,72 @@
class HomepagesController < ApplicationController
before_filter :find_user
def index
if User.current.logged? && User.current == @user
@b_sort = params[:sort] || 1
@b_sort = @b_sort.to_i == 1 ? 2 : 1
sort_type = @b_sort == 1 ? "asc" : "desc"
@articles = @user.homepage.article_homepages.reorder("updated_at #{sort_type}")
@limit = 20
@is_remote = true
@atta_count = @articles.count
@atta_pages = Paginator.new @atta_count, @limit, params['page'] || 1
@offset ||= @atta_pages.offset
@articles = paginateHelper @articles,@limit
respond_to do |format|
format.js
format.html {render :layout=>'new_base_user'}
end
else
render_403
end
end
def show
end
def set_homepage
@homepage = Homepage.find(params[:id])
@homepage.update_attribute(:article_id, params[:article_id])
@articles = @user.homepage.article_homepages.reorder("updated_at desc")
@limit = 20
@is_remote = true
@atta_count = @articles.count
@atta_pages = Paginator.new @atta_count, @limit, 1
@articles = paginateHelper @articles,@limit
if params[:show]
redirect_to homepage_user_path(@user.id)
return
else
respond_to do |format|
format.js
end
end
end
def cancel_homepage
@homepage = Homepage.find(params[:id])
@homepage.update_attribute(:article_id, nil)
@articles = @user.homepage.article_homepages.reorder("updated_at desc")
@limit = 20
@is_remote = true
@atta_count = @articles.count
@atta_pages = Paginator.new @atta_count, @limit, 1
@articles = paginateHelper @articles,@limit
if params[:show]
redirect_to user_homepage_article_homepage_path(:user_id=>@user.id, :homepage_id=>@homepage.id,:id=>params[:article_id].to_i)
return
else
respond_to do |format|
format.js
end
end
end
private
def find_user
@user = User.find(params[:user_id])
end
end

View File

@ -42,7 +42,7 @@ class UsersController < ApplicationController
:activity_new_score_index, :influence_new_score_index, :score_new_index,:user_projects_index,:user_resource,
:user_courses4show,:user_projects4show,:user_course_activities,:user_project_activities,:user_feedback4show,:user_visitorlist,:user_messages,:edit_brief_introduction,
:user_import_homeworks,:user_search_homeworks,:user_import_resource, :user_system_messages,:choose_user_course,:user_courselist,:user_projectlist,:sort_syllabus_list,
:sort_project_list,:my_homeworks,:manage_or_receive_homeworks,:search_m_r_homeworks, :cancel_or_collect,:expand_courses]
:sort_project_list,:my_homeworks,:manage_or_receive_homeworks,:search_m_r_homeworks, :cancel_or_collect,:expand_courses,:homepage]
before_filter :auth_user_extension, only: :show
#before_filter :rest_user_score, only: :show
#before_filter :select_entry, only: :user_projects
@ -3580,6 +3580,15 @@ class UsersController < ApplicationController
end
end
def homepage
if @user.base_homepage
@article = @user.base_homepage
respond_to do |format|
format.html {render :layout => 'clear_base'}
end
end
end
private
def find_user

View File

@ -0,0 +1,2 @@
module ArticleHomepagesHelper
end

View File

@ -0,0 +1,2 @@
module HomepagesHelper
end

View File

@ -9,4 +9,5 @@ module OwnerTypeHelper
HOMEWORKCOMMON = 8
BLOGCOMMENT = 9
SYLLABUS = 10
ArticleHomepage = 11
end

View File

@ -0,0 +1,5 @@
class ArticleHomepage < ActiveRecord::Base
belongs_to :user
belongs_to :homepage
attr_accessible :content, :title, :user_id, :homepage_id
end

5
app/models/homepage.rb Normal file
View File

@ -0,0 +1,5 @@
class Homepage < ActiveRecord::Base
belongs_to :user
has_many :article_homepages
attr_accessible :name, :article_id, :user_id
end

View File

@ -30,15 +30,15 @@ class StudentWork < ActiveRecord::Base
student_work_tests.order('id desc').first
end
private
private
def set_program_score
if self.homework_common.is_program_homework? #编程作业,学生提交作品后计算系统得分
#根据最后一次测试计算得分
unless last_test
self.system_score = 0
else
self.system_score = last_test.test_score
end
#根据最后一次测试计算得分
unless last_test
self.system_score = 0
else
self.system_score = last_test.test_score self.homework_common.homework_tests.size
end
end
set_final_score self.homework_common,self
end
@ -133,7 +133,7 @@ class StudentWork < ActiveRecord::Base
else
student_work.work_score = nil
end
end
end
else #不考虑教师评分
if student_work.teaching_asistant_score.nil? #教辅未评分
if student_work.student_score.nil?

View File

@ -32,13 +32,14 @@ class StudentWorkTest < ActiveRecord::Base
end
end
def test_score
if self.status.to_i == 0
#必须和测试集个数一样才能得100分
def test_score(testcount)
if self.status.to_i == 0 && testcount == self.results.count
100
elsif self.results.empty?
0
else
get_success_count * 100 / self.results.count
else
get_success_count * 100 / testcount
end
end

View File

@ -208,6 +208,9 @@ class User < Principal
acts_as_watchable
has_one :user_extensions,:dependent => :destroy
has_one :homepage, :dependent => :destroy
has_many :article_homepages, :dependent => :destroy
## end
# default_scope -> { includes(:user_extensions, :user_score) }
@ -347,6 +350,25 @@ class User < Principal
@blog
end
def homepage
@homepage = Homepage.where("user_id = #{self.id}").all[0]
if @homepage.nil?
#如果某个user的blog不存在那么就创建一条并且跳转
@homepage = Homepage.create(:name=>(User.find(self.id).login), :user_id=>self.id)
@homepage.save
end
@homepage
end
def base_homepage
@base_homepage = nil
@homepage = self.homepage
if @homepage.article_id and ArticleHomepage.where("id=?", @homepage.article_id).count > 0
@base_homepage = ArticleHomepage.where("id=?", @homepage.article_id).first
end
@base_homepage
end
# 查询指派给我的缺陷记录
def count_new_issue_assign_to
self.issue_assigns

View File

@ -0,0 +1,50 @@
<%= content_for(:header_tags) do %>
<%= import_ke(enable_at: false, prettify: false) %>
<%= javascript_include_tag 'homepage' %>
<% end %>
<div>
<input type="text" name="article_homepage[title]" id="message_subject" class="InputBox" style="width: 99.5%;" maxlength="255" onkeyup="regexTopicSubject();" placeholder="请输入标题,该标题不会在个人主页中显示" value="<%=@article.title %>" />
<p id="subjectmsg"></p>
</div>
<div>
<div class="mt10">
<div id="message_quote" class="wiki" style="width: 92%;word-break: break-all;word-wrap: break-word;margin-left: 40px;"></div>
<%= text_area :quote,:quote,:style => 'display:none' %>
<%= hidden_field_tag :asset_id,params[:asset_id],:required => false,:style => 'display:none' %>
<%= f.kindeditor :content, :editor_id => 'message_content_editor',
:owner_id => @article.nil? ? 0: @article.id,
:owner_type => OwnerTypeHelper::ArticleHomepage,
:width => '100%',
:height => 500,
:minHeight=>500,
:class => 'talk_text fl',
:input_html => { :id => 'message_content',
:class => 'talk_text fl',
:maxlength => 5000 }%>
<div class="cl"></div>
<p id="message_content_span"></p>
<p id="e_tip" class="c_grey"></p>
<p id="e_tips" class="c_grey"></p>
</div>
<% unless is_edit %>
<div class="mt10">
<input type="checkbox" value="1" id="set_homepage" name="set_homepage"/>
<label for="set_homepage">设为主页</label>
</div>
<% end %>
<div class="cl"></div>
<div class="mt5">
<a href="javascript:void(0);" class="BlueCirBtnMini fr" onclick="submit_article();">确定</a>
<span class="fr mr10 mt3">或</span>
<a href="javascript:void(0);" class="fr mr10 mt3" onclick="reset_article();">取消</a>
</div>
<div class="cl"></div>
</div>
<script>
function reset_article(){
window.location.href = "<%=user_homepages_path(:user_id => User.current.id) %>";
}
</script>

View File

@ -0,0 +1,54 @@
<div class="homepageContentContainer" style="margin-top: 25px;">
<div class="homepageContent">
<div class="postContainer mb10 pr">
<% if User.current && User.current == @article.user %>
<div class="homepagePostSetting" id="message_setting_<%= @article.id%>" style="top: -25px;">
<ul>
<li class="homepagePostSettingIcon">
<ul class="homepagePostSettiongText">
<li>
<% if @article.id == @article.homepage.article_id %>
<%= link_to(
l(:button_cancel_base_homepage),
{:controller => 'homepages',:action => 'cancel_homepage',:user_id=>@article.user_id,:id=>@article.homepage_id, :article_id => @article.id, :show => 1},
:method => :post,
:class => 'postOptionLink'
)%>
<% else %>
<%= link_to(
l(:button_set_base_homepage),
{:controller => 'homepages',:action => 'set_homepage',:user_id=>@article.user_id,:id=>@article.homepage_id, :article_id => @article.id, :show => 1},
:method => :post,
:class => 'postOptionLink'
) %>
<% end %>
</li>
<li>
<%= link_to(
l(:button_edit),
{:controller => 'article_homepages',:action => 'edit', :id => @article.id},
:class => 'postOptionLink'
) %>
</li>
<li>
<%= link_to(
l(:button_delete),
{:controller => 'article_homepages',:action => 'destroy', :id => @article.id},
:method => :delete,
:data => {:confirm => l(:text_are_you_sure)},
:class => 'postOptionLink'
) %>
</li>
</ul>
</li>
</ul>
</div>
<% end %>
<div class="cl"></div>
<div class="break_word" style="padding: 5px 5px 0 0">
<%=@article.content.html_safe %>
</div>
</div>
</div>
</div>

View File

@ -0,0 +1,18 @@
<div class="homepageContentContainer">
<div class="homepageContent">
<div class="postContainer mb10">
<%= labelled_form_for @article, :url =>{:controller=>'article_homepages',:action => 'update'},
:html => {:nhname=>'form',:multipart => true, :id => 'message-form'} do |f| %>
<%= render :partial => 'article_form', :locals => {:is_edit => true, :f => f} %>
<% end %>
</div>
</div>
</div>
<script type="text/javascript">
$(function(){
setTimeout(function(){
elocalStorage(message_content_editor,'article_homepage_edit_<%=User.current.id %>');
}, 10000);
});
</script>

View File

@ -0,0 +1,18 @@
<div class="homepageContentContainer">
<div class="homepageContent">
<div class="postContainer mb10">
<%= labelled_form_for @article, :url =>{:controller=>'article_homepages',:action => 'create'},
:html => {:nhname=>'form',:multipart => true, :id => 'message-form'} do |f| %>
<%= render :partial => 'article_form', :locals => {:is_edit => false, :f => f} %>
<% end %>
</div>
</div>
</div>
<script type="text/javascript">
$(function(){
setTimeout(function(){
elocalStorage(message_content_editor,'article_homepage_<%=User.current.id %>');
}, 10000);
});
</script>

View File

@ -0,0 +1 @@
<%= render :partial => 'article_show' %>

View File

@ -3,7 +3,7 @@
<%= javascript_include_tag 'blog' %>
<% end %>
<div class="resources mt10">
<div class="resources">
<div id="new_course_topic">
<div class="homepagePostBrief c_grey">
<div>

View File

@ -59,23 +59,23 @@
:class => 'postOptionLink'
) if User.current.admin? || User.current.id == @article.author.id %>
</li>
<li>
<% if @article.id == @article.blog.homepage_id %>
<%= link_to(
l(:button_cancel_homepage),
{:controller => 'blogs',:action => 'cancel_homepage',:user_id=>@article.author_id,:id=>@article.blog_id, :article_id => @article.id},
:method => :post,
:class => 'postOptionLink'
<!--<li>-->
<!--<%# if @article.id == @article.blog.homepage_id %>-->
<%#= link_to(
# l(:button_cancel_homepage),
# {:controller => 'blogs',:action => 'cancel_homepage',:user_id=>@article.author_id,:id=>@article.blog_id, :article_id => @article.id},
# :method => :post,
# :class => 'postOptionLink'
) if User.current && User.current.id == @article.blog.author_id %>
<% else %>
<%= link_to(
l(:button_set_homepage),
{:controller => 'blogs',:action => 'set_homepage',:user_id=>@article.author_id,:id=>@article.blog_id, :article_id => @article.id},
:method => :post,
:class => 'postOptionLink'
<!--<%# else %>-->
<%#= link_to(
# l(:button_set_homepage),
# {:controller => 'blogs',:action => 'set_homepage',:user_id=>@article.author_id,:id=>@article.blog_id, :article_id => @article.id},
# :method => :post,
# :class => 'postOptionLink'
) if User.current && User.current.id == @article.blog.author_id %>
<% end %>
</li>
<!--<%# end %>-->
<!--</li>-->
</ul>
</li>
</ul>

View File

@ -25,9 +25,9 @@
<% else %>
<%= link_to activity.title.subject.to_s.html_safe, user_blog_blog_comment_path(:user_id=>activity.author_id, :blog_id=>activity.blog.id,:id=>activity), :class=> "list-title fl"%>
<% end %>
<% if activity.blog.homepage_id and activity.id == activity.blog.homepage_id %>
<span class="font_normal ml10 fr">[已设为首页]</span>
<% end %>
<%# if activity.blog.homepage_id and activity.id == activity.blog.homepage_id %>
<!--<span class="font_normal ml10 fr">[已设为首页]</span>-->
<%# end %>
<% if activity.sticky == 1 %>
<span class="fl ml10 red-cir-btn">顶</span>
<% end%>

View File

@ -0,0 +1,99 @@
<div class="cl"> </div>
<div id="blog-list">
<div class="listbox mt10">
<h2 class="list-h2 fl">个人主页列表</h2>
<div class="fr">
<%=link_to '新 建', new_article_homepage_path(), :target => "_blank", :class => 'BlueCirBtn' %>
</div>
<div class="cl"></div>
<div class="category">
<span class="grayTxt">排序:</span>
<%= link_to "时间", {:controller => 'homepages', :action => 'index', :id =>@user, :sort => @b_sort}, :class => "sortTxt", :remote => true %>
<%= link_to "", {:controller => 'homepages', :action => 'index', :id =>@user, :sort => @b_sort}, :class => "#{@b_sort.to_i == 1 ? 'sortupbtn' : 'sortdownbtn'} ", :remote => true %>
<div class="cl"></div>
</div>
<div class="bloglistbox">
<% if @articles.any? %>
<% @articles.each do |activity| %>
<ul class="list-file pr" onmouseover='$("#message_setting_<%= activity.id%>").show();' onmouseout='$("#message_setting_<%= activity.id%>").hide();'>
<li><span class="item_list fl"></span>
<%= link_to activity.title.to_s.html_safe, user_homepage_article_homepage_path(:user_id=>activity.user_id, :homepage_id=>activity.homepage_id,:id=>activity), :class=> "list-title fl", :target => '_blank' %>
<% if activity.homepage.article_id and activity.id == activity.homepage.article_id %>
<span class="red_homework_btn_cir ml5">主页</span>
<% end %>
<div class="cl"></div>
</li>
<li class="ml15">
<span class="grayTxt">更新:<%= format_time(activity.updated_at) %></span>
</li>
<div class="cl"></div>
<div class="homepagePostSetting" id="message_setting_<%= activity.id%>" style="display: none">
<ul>
<li class="homepagePostSettingIcon">
<ul class="homepagePostSettiongText">
<li>
<% if activity.id == activity.homepage.article_id %>
<%= link_to(
l(:button_cancel_base_homepage),
{:controller => 'homepages',:action => 'cancel_homepage',:user_id=>activity.user_id,:id=>activity.homepage_id, :article_id => activity.id},
:method => :post,
:remote => true,
:class => 'postOptionLink'
) if User.current && User.current.id == activity.homepage.user_id %>
<% else %>
<%= link_to(
l(:button_set_base_homepage),
{:controller => 'homepages',:action => 'set_homepage',:user_id=>activity.user_id,:id=>activity.homepage_id, :article_id => activity.id},
:method => :post,
:remote => true,
:class => 'postOptionLink'
) if User.current && User.current.id == activity.homepage.user_id %>
<% end %>
</li>
<li>
<%= link_to(
l(:button_edit),
{:controller => 'article_homepages',:action => 'edit', :id => activity.id},
:class => 'postOptionLink'
) if User.current.admin? || User.current.id == activity.user_id %>
</li>
<li>
<%= link_to(
l(:button_delete),
{:controller => 'article_homepages',:action => 'destroy', :id => activity.id},
:method => :delete,
:data => {:confirm => l(:text_are_you_sure)},
:class => 'postOptionLink'
) if User.current.admin? || User.current.id == activity.user_id %>
</li>
</ul>
</li>
</ul>
</div>
</ul>
<% end %>
<div>
<ul class="wlist" id="pages" >
<%= pagination_links_full @atta_pages, @atta_count, :per_page_links => false, :remote => @is_remote, :flag => true %>
</ul>
<div class="cl"></div>
</div>
<% else %>
<p class="nodata"><%= l(:label_no_data) %></p>
<% end %>
</div>
</div>
</div>
<script type="text/javascript">
//如果右边的博客列表比左边的高度低则将右边的高度设为与左边对齐
$(function() {
var leftHeight = $("#LSide").height() - $(".fontGrey5").height() - 10;
var rightHeight = $(".homepageRight").height();
if (rightHeight < leftHeight) {
var diffHeight = leftHeight - rightHeight;
var tmpHeight = $(".listbox").height() + diffHeight;
$(".listbox").css("height", tmpHeight);
}
});
</script>

View File

@ -0,0 +1,8 @@
<% if !@articles.empty? && @user.base_homepage.nil? %>
<p class="nodata mt10 mb0" style="text-align: left;">您还没有设置个人主页,其他用户无法查看哦</p>
<% end %>
<% if !@articles.empty? %>
<%= render :partial => 'article_list' %>
<% else %>
<p class="nodata mt10" style="text-align: left;">您还没有创建属于自己的个人主页。<%=link_to '新建', new_user_homepage_article_homepage_path(:user_id=> @user.id, :homepage_id => @user.homepage.id), :target => "_blank", :class => 'linkBlue' %></p>
<% end%>

View File

@ -0,0 +1 @@
$("#user_homepages").html('<%= escape_javascript(render :partial => 'articles') %>');

View File

@ -0,0 +1,12 @@
<div class="homepageRight mt0">
<div class="homepageRightBanner">
<div class="f16 fl fontGrey3">
个人主页
</div>
</div>
<div class="cl"></div>
<div id="user_homepages">
<%= render :partial => 'articles' %>
</div>
</div>

View File

@ -0,0 +1 @@
$("#blog-list").replaceWith('<%= escape_javascript( render :partial => 'articles') %>');

View File

@ -0,0 +1 @@
$("#user_homepages").html('<%= escape_javascript(render :partial => 'articles') %>');

View File

@ -1,11 +1,25 @@
<% if User.current.logged?%>
<% if User.current == target%>
<%= link_to("编辑个人资料", my_account_path, :class => "user_editinfo")%>
<% else%>
<%if(target.watched_by?(User.current))%>
<%= link_to "取消关注",watch_path(:object_type=> 'user',:object_id=>target.id,:target_id=>target.id),:class => "user_editinfo", :method => "delete",:remote => "true", :title => "取消关注"%>
<% else %>
<%= link_to "添加关注",watch_path(:object_type=> 'user',:object_id=>target.id,:target_id=>target.id),:class => "user_editinfo", :method => "post",:remote => "true", :title => "添加关注"%>
<% end %>
<% end%>
<% end %>
<ul>
<% if User.current.logged?%>
<% if User.current == target%>
<li style="width: 119px; float: left; border-right: 1px solid #ddd;"><%= link_to("编辑基本资料", my_account_path, :class => "user_editinfo") %></li>
<li style="width: 118px; float: left;"><%= link_to '个人主页', user_homepages_path(:user_id => @user.id) , :class => "user_editinfo" %></li>
<li class="cl"></li>
<% else%>
<li style="width: 119px; float: left; border-right: 1px solid #ddd;">
<% if @user.base_homepage.nil? %>
<a href="javascript:void(0)" class ="user_editinfo" style="color: #cccccc" title="该用户暂未设置主页">主页</a>
<% else %>
<%=link_to "主页", homepage_user_path(@user), :class => 'user_editinfo', :target => '_blank' %>
<% end %>
</li>
<li style="width: 118px; float: left;">
<%if(target.watched_by?(User.current))%>
<%= link_to "取消关注",watch_path(:object_type=> 'user',:object_id=>target.id,:target_id=>target.id),:class => "user_editinfo", :method => "delete",:remote => "true", :title => "取消关注"%>
<% else %>
<%= link_to "添加关注",watch_path(:object_type=> 'user',:object_id=>target.id,:target_id=>target.id),:class => "user_editinfo", :method => "post",:remote => "true", :title => "添加关注"%>
<% end %>
</li>
<li class="cl"></li>
<% end%>
<% end %>
</ul>

View File

@ -0,0 +1,46 @@
<!DOCTYPE html>
<html lang="<%= current_language %>">
<head>
<meta charset="utf-8" />
<title><%=h html_title %></title>
<meta name="description" content="<%= Redmine::Info.app_name %>" />
<meta name="keywords" content="issue,bug,tracker" />
<%= csrf_meta_tag %>
<%= favicon %>
<%= stylesheet_link_tag 'jquery/jquery-ui-1.9.2', 'application', 'nyan','prettify', :media => 'all' %>
<%= stylesheet_link_tag 'rtl', :media => 'all' if l(:direction) == 'rtl' %>
<%= javascript_heads %>
<%= javascript_include_tag "jquery.leanModal.min",'prettify' %>
<%= javascript_include_tag 'seems_rateable/jRating', 'seems_rateable/rateable'%>
<%= heads_for_theme %>
<%= call_hook :view_layouts_base_html_head %>
<!-- page specific tags -->
<%= yield :header_tags -%>
<%= stylesheet_link_tag 'css/common','css/structure','css/public','css/popup', :media => 'all'%>
<!-- MathJax的配置 -->
<script type="text/javascript"
src="/javascripts/MathJax/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
</script>
<!-- 配置 在生成的公式图片上去掉Math定义的右键菜单$$ $$ \( \) \[ \] 中的公式给予显示-->
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
showMathMenu: false,
showMathMenuMSIE: false,
tex2jax: {inlineMath: [['$','$'], ['\\(','\\)']]}
});
</script>
</head>
<body>
<div class="cl"></div>
<div>
<%= yield %>
<div style="clear:both;"></div>
</div>
<div class="cl"></div>
<div id="ajax-modal" style="display:none;"></div>
<div id="ajax-indicator" style="display:none;">
<span><%= l(:label_loading) %></span>
</div>
<%= call_hook :view_layouts_base_body_bottom %>
</body>
</html>

View File

@ -179,7 +179,18 @@
<label class="ml10"><%= check_box_tag 'no_self_notified', 1, @user.pref[:no_self_notified], :style => "height:14px;" %>不要发送对我自己提交的修改的通知</label>
</li>
<!--<li><input name="brief_introduction" class="w450" type="text" maxlength="255" value="<%#= (@user.user_extensions.nil?) ? '' : @user.user_extensions.brief_introduction %>"></li>-->
<li style="height:auto;"><textarea name="description" class="w450 h200" maxlength="255" style="resize:none;"><%= (@user.user_extensions.nil?) ? '' : @user.user_extensions.description %></textarea></li>
<li style="height:auto;">
<% if @user.homepage && !@user.homepage.article_homepages.empty? %>
<% if @user.base_homepage %>
<%=link_to '查看', homepage_user_path(@user), :class => 'linkBlue',:target => '_blank' %>
<% else %>
<%=link_to '查看', user_homepages_path(:user_id => @user.id),:target => '_blank', :class => 'linkBlue' %>
<% end %>
<% else %>
<p class="nodata" style="height: 22px; font-size: 14px; text-align: left; line-height: 20px;">您还没有创建属于自己的个人主页。<%=link_to '新建', new_user_homepage_article_homepage_path(:user_id=> @user.id, :homepage_id => @user.homepage.id), :target => "_blank", :class => 'linkBlue' %></p>
<% end %>
<!--<textarea name="description" class="w450 h200" maxlength="255" style="resize:none;"><%#= (@user.user_extensions.nil?) ? '' : @user.user_extensions.description %></textarea>-->
</li>
<li style="display:none;"><%= f.select :language, :Chinese => :zh, :English => :en %></li>
<li class="ml2">
<a href="javascript:void(0);" id="my_account_form_link" class="blue_btn fl" onclick="my_account_form_submit();" style="background: #3b94d6; padding: 0 25px;">确定</a>

View File

@ -93,9 +93,9 @@
<%# cache (act) do %>
<% case user_activity.act_type.to_s %>
<% when 'BlogComment' %>
<% if !(act.blog.homepage_id and act.id == act.blog.homepage_id) %>
<%# if !(act.blog.homepage_id and act.id == act.blog.homepage_id) %>
<%= render :partial => 'user_blog', :locals => {:activity => act,:user_activity_id =>user_activity.id} %>
<% end %>
<%# end %>
<% end %>
<%# end %>
<% end %>

View File

@ -0,0 +1 @@
<%= render :partial => 'article_homepages/article_show' %>

View File

@ -44,8 +44,8 @@
</div>
<!--显示个人主页-->
<% if @user.blog.homepage_id and BlogComment.where("id=?", @user.blog.homepage_id).count > 0 %>
<% homepage = BlogComment.find(@user.blog.homepage_id) %>
<%= render :partial => 'blogs/homepage', :locals => {:activity => homepage, :user_activity_id => homepage.id} %>
<% end %>
<%# if @user.blog.homepage_id and BlogComment.where("id=?", @user.blog.homepage_id).count > 0 %>
<%# homepage = BlogComment.find(@user.blog.homepage_id) %>
<%#= render :partial => 'blogs/homepage', :locals => {:activity => homepage, :user_activity_id => homepage.id} %>
<%# end %>
<%= render :partial => 'users/user_activities', :locals => {:user_activities => @user_activities,:page => 0,:type => @type, :user_id => (@user.type == "AnonymousUser" ? User.current.id : @user.id)} %>

View File

@ -911,6 +911,8 @@ zh:
button_edit: 编辑
button_delete: 删除
button_approve: 批准
button_set_base_homepage: 设为主页
button_cancel_base_homepage: 取消主页
button_set_homepage: 设为首页
button_cancel_homepage: 取消首页
button_edit_homepage: 编辑首页

View File

@ -674,6 +674,7 @@ RedmineApp::Application.routes.draw do
get 'search_m_r_homeworks'
get 'expand_courses'
get 'cancel_or_collect'
get 'homepage'
# end
end
#resources :blogs
@ -685,12 +686,32 @@ RedmineApp::Application.routes.draw do
end
end
end
resources :homepages do
resources :article_homepages do
member do
end
end
end
end
resources :blog_comments do
collection do
get :search
end
end
resource :homepages do
member do
post 'set_homepage'
post 'cancel_homepage'
end
collection do
end
end
resources :article_homepages do
member do
end
end
match 'users/:id/user_newfeedback', :to => 'users#user_newfeedback', :via => :get, :as => "feedback"
match 'users/:id/user_projects', :to => 'users#user_projects', :via => :get
#消息

View File

@ -0,0 +1,21 @@
class CreateHomepages < ActiveRecord::Migration
def change
create_table :homepages do |t|
t.string :name
t.integer :article_id
t.references :user
t.timestamps
end
add_index :homepages, :user_id
count = User.all.count / 30 + 2
transaction do
for i in 1 ... count do i
User.page(i).per(30).each do |user|
Homepage.create(:user_id => user.id, :name => user.login)
end
end
end
end
end

View File

@ -0,0 +1,27 @@
# encoding: utf-8
class CreateArticleHomepages < ActiveRecord::Migration
def change
create_table :article_homepages do |t|
t.string :title
t.text :content
t.references :user
t.references :homepage
t.timestamps
end
add_index :article_homepages, :user_id
add_index :article_homepages, :homepage_id
count = User.all.count / 30 + 2
transaction do
for i in 1 ... count do i
User.page(i).per(30).each do |user|
if user.user_extensions && !user.user_extensions.description.nil? && user.user_extensions.description != ""
article = ArticleHomepage.create(:user_id => user.id,:title => '个人简介', :content => user.user_extensions.description, :homepage_id => user.homepage.id)
user.homepage.update_column('article_id', article.id)
end
end
end
end
end
end

View File

@ -0,0 +1,54 @@
function regexTopicSubject() {
var name = $("#message_subject").val();
if(name.length ==0)
{
$("#subjectmsg").text("标题不能为空");
$("#subjectmsg").css('color','#ff0000');
$("#message_subject").focus();
return false;
}
else if(name.length <= 255)
{
$("#subjectmsg").text("填写正确");
$("#subjectmsg").css('color','#008000');
return true;
}
else
{
$("#subjectmsg").text("标题超过255个字符");
$("#subjectmsg").css('color','#ff0000');
$("#message_subject").focus();
return false;
}
}
function submit_article()
{
if(regexTopicSubject() && regexTopicDescription())
{
message_content_editor.sync();
$("#message-form").submit();
}
}
function regexTopicDescription()
{
var name = message_content_editor.html();
if(message_content_editor.isEmpty())
{
$("#message_content_span").text("描述不能为空");
$("#message_content_span").css('color','#ff0000');
return false;
}
else if(name.length >=20000){
$("#message_content_span").text("描述最多20000个汉字(或40000个英文字符)");
$("#message_content_span").css('color','#ff0000');
return false;
}
else
{
$("#message_content_span").text("填写正确");
$("#message_content_span").css('color','#008000');
return true;
}
}

View File

@ -1,10 +1,10 @@
$(function(){
//提交作业
var bt=baidu.template;
bt.LEFT_DELIMITER='<!';
bt.RIGHT_DELIMITER='!>';
var tested = false;
var valid_form = function() {
var src = $('#program-src').val();
@ -26,6 +26,7 @@ $(function(){
var test_program = function(cb){
$('#test-program-btn').hide();
$('#commit-program-work-btn').hide();
var homework_id = $('#test-program-btn').attr('data-homework-id');
var student_work_id = $('#test-program-btn').attr('data-student-work-id');
var src = $('#program-src').val();
@ -34,6 +35,7 @@ $(function(){
if(!valid_form()){
$('#test-program-btn').show();
$('#commit-program-work-btn').show();
return;
}
//先测试一次并返回测试集个数及结果再判断是否需要继续进行测试
@ -42,7 +44,7 @@ $(function(){
'/student_work/program_test_ex',
{homework: homework_id, student_work_id: student_work_id,
src: src, title: title, is_test: is_test,tIndex:i,
testid: testid},
testid: testid},
function(data,status){
if (data.status==-4 || data.status==-5 ){
//弹框
@ -52,12 +54,14 @@ $(function(){
pop_up_box(htmlvalue,580,30,50);
$('#test-program-btn').show();
$('#commit-program-work-btn').show();
return;
}
else if (data.status==-3){
var htmlvalue = "</br><div style='width:550px;text-align:center'>由于目前大量用户正在测试,系统繁忙,请稍后再试。我们将尽快提升平台的处理能力,谢谢您的支持!</div></br><div style='width:67px; margin:0 auto; text-align:center'><a href='javascript:void(0);' class='Blue-btn' onclick='hideModal()'>确定</a></div>";
pop_up_box(htmlvalue,580,30,50);
$('#test-program-btn').show();
$('#commit-program-work-btn').show();
return;
}
var tSeq = data.tseq;
@ -74,17 +78,19 @@ $(function(){
$('.ProResult').prepend(html);
if (data.status==0 && is_test != 'true') {
if (typeof cb == 'function') {cb(data);$('#test-program-btn').show(); return;}
var htmlvalue = "</br><div style='width:550px;text-align:center'>答题正确,是否立刻提交?</div></br><div style='width:164px; margin:0 auto; text-align:center'><a href='javascript:void(0);' class='Blue-btn fl' onclick='submit_code()'>确定</a><a href='javascript:void(0);' class='Blue-btn fl' onclick='hideModal()'>取消</a></div><script>function submit_code(){$('.HomeWorkCon form').submit();hideModal();}</script>";
if (typeof cb == 'function') {cb(data);return;}
var htmlvalue = "</br><div style='width:550px;text-align:center'>答题正确,是否立刻提交?</div></br><div style='width:164px; margin:0 auto; text-align:center'><a href='javascript:void(0);' class='Blue-btn fl' onclick='submit_code()'>确定</a><a href='javascript:void(0);' class='Blue-btn fl' onclick='hideModal()'>取消</a></div><script>function submit_code(){$('#commit-program-work-btn').hide();$('#test-program-btn').hide();$('.HomeWorkCon form').submit();hideModal();}</script>";
pop_up_box(htmlvalue,580,30,50);
$('#test-program-btn').show();
$('#commit-program-work-btn').show();
return;
}
//2 超时 -2 编译错误 测试结束
if (data.status == 2 || data.status == -2 || tSeq >= tCount ){
if (typeof cb == 'function') {cb(data);$('#test-program-btn').show(); return;}
if (typeof cb == 'function') {cb(data);$('#test-program-btn').show();$('#commit-program-work-btn').show(); return;}
$('#test-program-btn').show();
$('#commit-program-work-btn').show();
return;
}
@ -95,10 +101,11 @@ $(function(){
var htmlvalue = "</br><div style='width:550px;text-align:center'>您的答案超时了, 请检查代码是否存在死循环的错误!</div></br><div style='width:67px; margin:0 auto; text-align:center'><a href='javascript:void(0);' class='Blue-btn' onclick='hideModal()'>确定</a></div>";
pop_up_box(htmlvalue,580,30,50);
} else {
var htmlvalue = "</br><div style='width:550px;text-align:center'>对不起,服务器繁忙请稍后再试!</div></br><div style='width:67px; margin:0 auto; text-align:center'><a href='javascript:void(0);' class='Blue-btn' onclick='hideModal()'>确定</a></div>";
var htmlvalue = "</br><div style='width:550px;text-align:center'>由于目前大量用户正在测试,系统繁忙,请稍后再试。我们将尽快提升平台的处理能力,谢谢您的支持!</div></br><div style='width:67px; margin:0 auto; text-align:center'><a href='javascript:void(0);' class='Blue-btn' onclick='hideModal()'>确定</a></div>";
pop_up_box(htmlvalue,580,30,50);
}
$('#test-program-btn').show();
$('#commit-program-work-btn').show();
return;
});
};
@ -113,6 +120,7 @@ $(function(){
if(!valid_form()){
return;
}
$('#commit-program-work-btn').hide();
if($('.ProResult .ProResultTop').length<=0){
var htmlvalue = "</br><div style='width:550px;text-align:center'>测试后才能提交,是否立刻测试?</div></br><div style='width:164px; margin:0 auto; text-align:center'><a href='javascript:void(0);' id='code-test-button' class='Blue-btn fl'>确定</a><a href='javascript:void(0);' class='Blue-btn fl' onclick='hideModal()'>取消</a></div>";
pop_up_box(htmlvalue,580,30,50);
@ -125,16 +133,20 @@ $(function(){
if (!tested) {
test_program(function(data){
if (data.status!=0) {
var htmlvalue = "</br><div style='width:550px;text-align:center'>测试不通过,是否强制提交?</div></br><div style='width:164px; margin:0 auto; text-align:center'><a href='javascript:void(0);' class='Blue-btn fl' onclick='submit_code()'>确定</a><a href='javascript:void(0);' class='Blue-btn fl' onclick='hideModal()'>取消</a></div><script>function submit_code(){$('.HomeWorkCon form').submit();hideModal();}</script>";
var htmlvalue = "</br><div style='width:550px;text-align:center'>测试不通过,是否强制提交?</div></br><div style='width:164px; margin:0 auto; text-align:center'><a href='javascript:void(0);' class='Blue-btn fl' onclick='submit_code()'>确定</a><a href='javascript:void(0);' class='Blue-btn fl' onclick='hideModal()'>取消</a></div><script>function submit_code(){$('#commit-program-work-btn').hide();$('.HomeWorkCon form').submit();hideModal();}</script>";
pop_up_box(htmlvalue,580,30,50);
$('#commit-program-work-btn').show();
return;
};
$(".HomeWorkCon form").submit();
$('#commit-program-work-btn').hide();
$('#test-program-btn').hide();
$(".HomeWorkCon form").submit();
});
return;
}
$('#commit-program-work-btn').hide();
$('#test-program-btn').hide();
$(".HomeWorkCon form").submit();
});
@ -147,7 +159,7 @@ $(function(){
$('#program-src').focus(function(){
$(this).css('height', '100px');
});
var datepickerOptions={dateFormat:'yy-mm-dd',firstDay:0,showWeek:true,showOtherMonths:true,selectOtherMonths:true};
$('input.date-input').datepicker(datepickerOptions);
@ -207,10 +219,10 @@ $(function(){
$("#BluePopupBox").dialog({
modal: true,
autoOpen: false,
dialogClass: 'BluePopupBox',
minWidth: 771
modal: true,
autoOpen: false,
dialogClass: 'BluePopupBox',
minWidth: 771
});
$('#BluePopupBox').parent().resizable("disable");
$('#BluePopupBox').parent().removeClass("ui-state-disabled");
@ -249,7 +261,7 @@ $(function(){
var saveProgramAnswers = function() {
var test_numbers = 0;
var valid = true;
var valid = true;
var input = null;
var output = null;
var input_groups = [];
@ -300,7 +312,7 @@ $(function(){
$("#BluePopupBox a.BlueCirBtn").live('click', function(){
if(saveProgramAnswers()){
if($( "#BluePopupBox" ).dialog( "isOpen" )){
$("#BluePopupBox").dialog( "close" );
$("#BluePopupBox").dialog( "close" );
}
}
});
@ -449,7 +461,7 @@ $(function(){
var program_name = "text/x-csrc";
var language = $('#data-language').attr('data-language');
if (language == 1) {
program_name = 'text/x-csrc';
program_name = 'text/x-csrc';
} else if(language==2){
program_name = 'text/x-c++src';
}else if(language==3){
@ -483,8 +495,8 @@ class Main\n\
}\n\
}\n\
';
}
else if(language==1){
}
else if(language==1){
src = '\
//注意\n\
//1:该程序每次运行的时间必须小于200毫秒否则会超时,程序超时将不会测试剩余的测试集\n\
@ -504,8 +516,8 @@ int main()\n\
return 0;\n\
}\n\
';
} else if(language==2){
src = '\
} else if(language==2){
src = '\
//注意\n\
//1:该程序每次运行的时间必须小于200毫秒否则会超时,程序超时将不会测试剩余的测试集\n\
//2:该程序每次运行使用的内存不能超过1M否则会返回错误\n\
@ -525,8 +537,8 @@ int main()\n\
return 0;\n\
}\n\
';
} else if(language==3){
src = '\
} else if(language==3){
src = '\
#-*-coding:utf-8-*-\n\
#注意\n\
#1:该程序每次运行的时间必须小于200毫秒否则会超时,程序超时将不会测试剩余的测试集\n\
@ -541,15 +553,15 @@ import sys \n\
#结果输出使用 print \n\
#print (str(int(a)+int(b)))\n\
';
}
}
$('#program-src').val(src);
$('#program-src').val(src);
};
var editor = CodeMirror.fromTextArea(document.getElementById("program-src"), {
mode: {name: program_name,
version: 2,
singleLineStringErrors: false},
version: 2,
singleLineStringErrors: false},
lineNumbers: true,
indentUnit: 2,
matchBrackets: true
@ -560,7 +572,7 @@ import sys \n\
$('#program-src').val(cMirror.getValue());
});
}
});

View File

@ -0,0 +1,5 @@
require 'rails_helper'
RSpec.describe ArticleHomepagesController, :type => :controller do
end

View File

@ -0,0 +1,5 @@
require 'rails_helper'
RSpec.describe HomepagesController, :type => :controller do
end

View File

@ -0,0 +1,10 @@
# Read about factories at https://github.com/thoughtbot/factory_girl
FactoryGirl.define do
factory :article_homepage do
title "MyString"
content "MyText"
user nil
homepage nil
end
end

View File

@ -0,0 +1,10 @@
# Read about factories at https://github.com/thoughtbot/factory_girl
FactoryGirl.define do
factory :homepage do
title "MyString"
content "MyText"
default 1
user nil
end
end

View File

@ -0,0 +1,5 @@
require 'rails_helper'
RSpec.describe ArticleHomepage, :type => :model do
pending "add some examples to (or delete) #{__FILE__}"
end

View File

@ -0,0 +1,5 @@
require 'rails_helper'
RSpec.describe Homepage, :type => :model do
pending "add some examples to (or delete) #{__FILE__}"
end