Merge branch 'szzh' of http://repository.trustie.net/xianbo/trustie2 into szzh
Conflicts: app/controllers/bids_controller.rb app/views/courses/new_homework.html.erb
This commit is contained in:
commit
be2faea15b
|
@ -546,22 +546,47 @@ class CoursesController < ApplicationController
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def get_courses
|
||||||
|
@user = User.current
|
||||||
|
membership = @user.coursememberships.all
|
||||||
|
membership.sort! {|older, newer| newer.created_on <=> older.created_on }
|
||||||
|
@memberships = []
|
||||||
|
membership.collect { |e|
|
||||||
|
@memberships.push(e)
|
||||||
|
}
|
||||||
|
@memberships_doing = []
|
||||||
|
@memberships_done = []
|
||||||
|
now_time = Time.now.year
|
||||||
|
@memberships.map { |e|
|
||||||
|
end_time = e.course.get_time.year
|
||||||
|
isDone = course_endTime_timeout?(e.course)
|
||||||
|
if isDone
|
||||||
|
@memberships_done.push e
|
||||||
|
else
|
||||||
|
@memberships_doing.push e
|
||||||
|
end
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
def finishcourse
|
def finishcourse
|
||||||
yesterday = Date.today.prev_day.to_time
|
yesterday = Date.today.prev_day.to_time
|
||||||
|
|
||||||
@course_prefs.endup_time = yesterday
|
@course_prefs.endup_time = yesterday
|
||||||
@save_flag = @course_prefs.save
|
@save_flag = @course_prefs.save
|
||||||
|
get_courses
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.js
|
format.js
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
def restartcourse
|
def restartcourse
|
||||||
day = Time.parse("3000-01-01")
|
day = Time.parse("3000-01-01")
|
||||||
|
|
||||||
@course_prefs.endup_time = day
|
@course_prefs.endup_time = day
|
||||||
@save_flag = @course_prefs.save
|
@save_flag = @course_prefs.save
|
||||||
|
get_courses
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.js {
|
format.js {
|
||||||
|
|
|
@ -68,6 +68,9 @@ class MessagesController < ApplicationController
|
||||||
call_hook(:controller_messages_new_after_save, { :params => params, :message => @message})
|
call_hook(:controller_messages_new_after_save, { :params => params, :message => @message})
|
||||||
render_attachment_warning_if_needed(@message)
|
render_attachment_warning_if_needed(@message)
|
||||||
redirect_to board_message_path(@board, @message)
|
redirect_to board_message_path(@board, @message)
|
||||||
|
else
|
||||||
|
layout_file = @project ? 'base_projects' : 'base_courses'
|
||||||
|
render :action => 'new', :layout => layout_file
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -116,7 +116,7 @@ class NewsController < ApplicationController
|
||||||
flash[:notice] = l(:notice_successful_create)
|
flash[:notice] = l(:notice_successful_create)
|
||||||
redirect_to project_news_index_path(@project)
|
redirect_to project_news_index_path(@project)
|
||||||
else
|
else
|
||||||
layout_file = (@project.project_type == 1) ? 'base_courses' : 'base_projects'
|
layout_file = @project ? 'base_projects' : 'base_courses'
|
||||||
render :action => 'new', :layout => layout_file
|
render :action => 'new', :layout => layout_file
|
||||||
end
|
end
|
||||||
elsif @course
|
elsif @course
|
||||||
|
|
|
@ -33,8 +33,9 @@ class Course < ActiveRecord::Base
|
||||||
acts_as_attachable :view_permission => :view_files,
|
acts_as_attachable :view_permission => :view_files,
|
||||||
:delete_permission => :manage_files
|
:delete_permission => :manage_files
|
||||||
|
|
||||||
validates_presence_of :password, :term
|
validates_presence_of :password, :term,:name
|
||||||
validates_format_of :class_period, :with =>/^[1-9]\d*$/
|
validates_format_of :class_period, :with =>/^[1-9]\d*$/
|
||||||
|
validates_format_of :name,:with =>/^[a-zA-Z0-9_\u4e00-\u9fa5]+$/
|
||||||
|
|
||||||
after_save :create_board_sync
|
after_save :create_board_sync
|
||||||
before_destroy :delete_all_members
|
before_destroy :delete_all_members
|
||||||
|
|
|
@ -33,8 +33,12 @@ class JournalsForMessage < ActiveRecord::Base
|
||||||
:description => Proc.new{|o| o.notes },
|
:description => Proc.new{|o| o.notes },
|
||||||
:type => Proc.new {|o| o.jour_type },
|
:type => Proc.new {|o| o.jour_type },
|
||||||
:url => Proc.new {|o|
|
:url => Proc.new {|o|
|
||||||
(o.jour.kind_of? Project) ? {:controller => 'projects', :action => 'feedback', :id => o.jour, :r => o.id, :anchor => "word_li_#{o.id}"} : {}
|
if o.jour.kind_of? Project
|
||||||
}#{:controller => 'documents', :action => 'show', :id => o.id}}
|
{:controller => 'projects', :action => 'feedback', :id => o.jour, :r => o.id, :anchor => "word_li_#{o.id}"}
|
||||||
|
elsif o.jour.kind_of? Course
|
||||||
|
{:controller => 'courses', :action => 'feedback', :id => o.jour, :r => o.id, :anchor => "word_li_#{o.id}"}
|
||||||
|
end
|
||||||
|
}
|
||||||
acts_as_activity_provider :author_key => :user_id,
|
acts_as_activity_provider :author_key => :user_id,
|
||||||
:timestamp => "#{self.table_name}.updated_on",
|
:timestamp => "#{self.table_name}.updated_on",
|
||||||
:find_options => {:include => :project }
|
:find_options => {:include => :project }
|
||||||
|
|
|
@ -53,7 +53,7 @@ class UserScore < ActiveRecord::Base
|
||||||
user_score = current_user.user_score_attr
|
user_score = current_user.user_score_attr
|
||||||
user_grade = nil #项目个人得分
|
user_grade = nil #项目个人得分
|
||||||
project = obj.project
|
project = obj.project
|
||||||
unless project.nil? && project.project_type == 0
|
unless project.nil?
|
||||||
user_grade = UserGrade.find_by_user_id_and_project_id(current_user.id, project.id)
|
user_grade = UserGrade.find_by_user_id_and_project_id(current_user.id, project.id)
|
||||||
if user_grade.nil?
|
if user_grade.nil?
|
||||||
user_grade = UserGrade.create(:user_id => current_user.id,:project_id => project.id)
|
user_grade = UserGrade.create(:user_id => current_user.id,:project_id => project.id)
|
||||||
|
@ -178,7 +178,7 @@ class UserScore < ActiveRecord::Base
|
||||||
current_user_grade = nil #项目个人得分
|
current_user_grade = nil #项目个人得分
|
||||||
target_user_grade = nil
|
target_user_grade = nil
|
||||||
project = obj.project
|
project = obj.project
|
||||||
unless project.nil? && project.project_type == 0
|
unless project.nil?
|
||||||
current_user_grade = UserGrade.find_by_user_id_and_project_id(current_user.id, project.id)
|
current_user_grade = UserGrade.find_by_user_id_and_project_id(current_user.id, project.id)
|
||||||
target_user_grade = UserGrade.find_by_user_id_and_project_id(target_user.id, project.id)
|
target_user_grade = UserGrade.find_by_user_id_and_project_id(target_user.id, project.id)
|
||||||
if current_user_grade.nil?
|
if current_user_grade.nil?
|
||||||
|
@ -285,7 +285,7 @@ class UserScore < ActiveRecord::Base
|
||||||
user_score = current_user.try(:user_score_attr)
|
user_score = current_user.try(:user_score_attr)
|
||||||
user_grade = nil #项目个人得分
|
user_grade = nil #项目个人得分
|
||||||
project = obj.project
|
project = obj.project
|
||||||
unless project.nil? && project.project_type == 0
|
unless project.nil?
|
||||||
user_grade = UserGrade.find_by_user_id_and_project_id(current_user.id, project.id)
|
user_grade = UserGrade.find_by_user_id_and_project_id(current_user.id, project.id)
|
||||||
if user_grade.nil?
|
if user_grade.nil?
|
||||||
user_grade = UserGrade.create(:user_id => current_user.id,:project_id => project.id)
|
user_grade = UserGrade.create(:user_id => current_user.id,:project_id => project.id)
|
||||||
|
|
|
@ -18,7 +18,6 @@
|
||||||
|
|
||||||
<% object = [] %>
|
<% object = [] %>
|
||||||
<% object << 'course' %>
|
<% object << 'course' %>
|
||||||
<% object << 'course' %>
|
|
||||||
<%= error_messages_for object %>
|
<%= error_messages_for object %>
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,11 @@
|
||||||
<%= content_tag "p", "#{format_date(member.created_on)}#{l(:label_member_since)}", :class => "float_right member_since" %>
|
<%= content_tag "p", "#{format_date(member.created_on)}#{l(:label_member_since)}", :class => "float_right member_since" %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<%= member.user.nil? ? '' : (image_tag(url_to_avatar(member.user), :class => 'avatar')) %>
|
<%= member.user.nil? ? '' : (image_tag(url_to_avatar(member.user), :class => 'avatar')) %>
|
||||||
|
<% if @canShowCode %>
|
||||||
|
<%= content_tag "div", link_to(member.user.show_name, user_path(member.user)), :class => "nomargin avatar_name" %>
|
||||||
|
<% else %>
|
||||||
<%= content_tag "div", link_to(member.user.name, user_path(member.user)), :class => "nomargin avatar_name" %>
|
<%= content_tag "div", link_to(member.user.name, user_path(member.user)), :class => "nomargin avatar_name" %>
|
||||||
|
<% end %>
|
||||||
<!--teacher's code disapeared moified by huang-->
|
<!--teacher's code disapeared moified by huang-->
|
||||||
|
|
||||||
<% unless member.user.user_extensions.identity ==0 %>
|
<% unless member.user.user_extensions.identity ==0 %>
|
||||||
|
|
|
@ -2,7 +2,11 @@
|
||||||
<% if Rails.env.development? %>
|
<% if Rails.env.development? %>
|
||||||
console.debug('课程修改成功:结束时间改为<%=Course.find_by_extra(@course.extra).try(:endup_time)%>');
|
console.debug('课程修改成功:结束时间改为<%=Course.find_by_extra(@course.extra).try(:endup_time)%>');
|
||||||
<% end %>
|
<% end %>
|
||||||
$('#finish_course_<%=@course.id%>').replaceWith("<%= j(render partial: 'courses/set_course_time', :locals => {:course => @course} )%>")
|
$('#content-title-top-div').html("<%= j(render partial: 'users/my_course_ex', :locals => {:memberships => @memberships,:user=>@user,
|
||||||
|
:memberships_doing=>@memberships_doing,:memberships_done=>@memberships_done} )%>")
|
||||||
|
//$('#finish_course_ <%=@course.id%>').replaceWith("<%= j(render partial: 'courses/set_course_time', :locals => {:course => @course} )%>")
|
||||||
<% else %>
|
<% else %>
|
||||||
alert('权限不足,设置失败,请在论坛提交问题,等待管理员处理。');
|
alert('权限不足,设置失败,请在论坛提交问题,等待管理员处理。');
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
<h3><%=l(:label_course_new_homework)%></h3>
|
<h3><%=l(:label_course_new_homework)%></h3>
|
||||||
<%= labelled_form_for @homework, :url => {:controller => 'bids', :action => 'create_homework',:course_id => "#{params[:id] || params[:course_id]}"} do |f| %>
|
|
||||||
|
<%= labelled_form_for @homework, :url => {:controller => 'bids', :action => 'create_homework',:course_id=>@course.id} do |f| %>
|
||||||
<div class="box tabular">
|
<div class="box tabular">
|
||||||
<%= render :partial => 'homework_form', :locals => { :f => f } %>
|
<%= render :partial => 'homework_form', :locals => { :f => f } %>
|
||||||
<%= submit_tag l(:button_create), :class => "enterprise" %>
|
<%= submit_tag l(:button_create), :class => "enterprise" %>
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
|
|
||||||
<%= l(:label_new_activity) %> </span>
|
<%= l(:label_new_activity) %> </span>
|
||||||
|
|
||||||
|
|
||||||
<%= link_to "#{eventToLanguageCourse(e.event_type, @course)}: "<< format_activity_title(e.event_title), (e.event_type.eql?("attachment")&&e.container.kind_of?(Course)) ? course_files_path(e.container) : e.event_url %>
|
<%= link_to "#{eventToLanguageCourse(e.event_type, @course)}: "<< format_activity_title(e.event_title), (e.event_type.eql?("attachment")&&e.container.kind_of?(Course)) ? course_files_path(e.container) : e.event_url %>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
|
@ -35,7 +35,7 @@
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
<!--加上 onload="Javascript:t()" 开始定时刷新分数 -->
|
<!--加上 onload="Javascript:t()" 开始定时刷新分数 -->
|
||||||
<body class="<%= h body_css_classes %>" onload="Javascript:t()">
|
<body class="<%= h body_css_classes %>">
|
||||||
<div id="wrapper">
|
<div id="wrapper">
|
||||||
<div id="wrapper2">
|
<div id="wrapper2">
|
||||||
<div id="wrapper3">
|
<div id="wrapper3">
|
||||||
|
|
|
@ -1,4 +1,8 @@
|
||||||
|
<% if @project %>
|
||||||
<h3><%= link_to h(@board.name), :controller => 'boards', :action => 'show', :project_id => @project, :id => @board %> » <%= l(:label_message_new) %></h3>
|
<h3><%= link_to h(@board.name), :controller => 'boards', :action => 'show', :project_id => @project, :id => @board %> » <%= l(:label_message_new) %></h3>
|
||||||
|
<% elsif @course %>
|
||||||
|
<h3><%= link_to h(@board.name), :controller => 'boards', :action => 'show', :course_id => @course, :id => @board %> » <%= l(:label_message_new) %></h3>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
<%= form_for @message, :url => {:action => 'new'}, :html => {:multipart => true, :id => 'message-form'} do |f| %>
|
<%= form_for @message, :url => {:action => 'new'}, :html => {:multipart => true, :id => 'message-form'} do |f| %>
|
||||||
<%= render :partial => 'form', :locals => {:f => f} %>
|
<%= render :partial => 'form', :locals => {:f => f} %>
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<%= error_messages_for @news %>
|
<%= error_messages_for @news %>
|
||||||
<div class="add_frame_header" >
|
<div class="add_frame_header" >
|
||||||
<% str = (@project.project_type == 1) ? l(:bale_news_notice) : l(:label_news_new) %>
|
<% str = @project ? l(:bale_news_notice) : l(:label_news_new) %>
|
||||||
<%= str %>
|
<%= str %>
|
||||||
</div>
|
</div>
|
||||||
<div class="box tabular">
|
<div class="box tabular">
|
||||||
|
|
|
@ -1,9 +1,17 @@
|
||||||
<!-- <h3><%=l(:label_news_new)%></h3> -->
|
<!-- <h3><%=l(:label_news_new)%></h3> -->
|
||||||
|
<% if @project %>
|
||||||
<%= labelled_form_for @news, :url => project_news_index_path(@project),
|
<%= labelled_form_for @news, :url => project_news_index_path(@project),
|
||||||
:html => {:id => 'news-form', :multipart => true} do |f| %>
|
:html => {:id => 'news-form', :multipart => true} do |f| %>
|
||||||
<%= render :partial => 'news/form', :locals => {:f => f} %>
|
<%= render :partial => 'news/form', :locals => {:f => f} %>
|
||||||
<%= submit_tag l(:button_create), :class => "whiteButton m3p10 h30" %>
|
<%= submit_tag l(:button_create), :class => "whiteButton m3p10 h30" %>
|
||||||
<%= preview_link preview_news_path(:project_id => @project), 'news-form', target='preview', {:class => 'whiteButton m3p10'} %>
|
<%= preview_link preview_news_path(:project_id => @project), 'news-form', target='preview', {:class => 'whiteButton m3p10'} %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
<% elsif @course %>
|
||||||
|
<%= labelled_form_for @news, :url => course_news_index_path(@course),
|
||||||
|
:html => {:id => 'news-form', :multipart => true} do |f| %>
|
||||||
|
<%= render :partial => 'news/form', :locals => {:f => f} %>
|
||||||
|
<%= submit_tag l(:button_create), :class => "whiteButton m3p10 h30" %>
|
||||||
|
<%= preview_link preview_news_path(:course_id => @course), 'news-form', target='preview', {:class => 'whiteButton m3p10'} %>
|
||||||
|
<% end %>
|
||||||
|
<% end %>
|
||||||
<div id="preview" class="wiki"></div>
|
<div id="preview" class="wiki"></div>
|
||||||
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
<div class="user_course_list menu-div">
|
||||||
|
<div class="menu">
|
||||||
|
<%= link_to "#{l(:label_course_new)}", new_course_path, class: 'icon icon-add' if user == User.current %>
|
||||||
|
<ul>
|
||||||
|
<li mode='doing' class="on">进行中</li>
|
||||||
|
<li mode='end'>已完结</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="dyn_list_wrapper" mode='doing'>
|
||||||
|
<div class='created_course'>
|
||||||
|
<%= render :partial => 'users/course_form', :locals => {:memberships => memberships_doing} %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="dyn_list_wrapper hidden" mode='end'>
|
||||||
|
<div class="created_course ">
|
||||||
|
<%= render :partial => 'users/course_form', :locals => {:memberships => memberships_done} %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
<div class="content-title-top">
|
<div class="content-title-top" id="content-title-top-div">
|
||||||
<% if @memberships.empty? %>
|
<% if @memberships.empty? %>
|
||||||
<% if @user != User.current %>
|
<% if @user != User.current %>
|
||||||
<p class="font_description">
|
<p class="font_description">
|
||||||
|
|
|
@ -0,0 +1,33 @@
|
||||||
|
<% if memberships.empty? %>
|
||||||
|
<% if user != User.current %>
|
||||||
|
<p class="font_description">
|
||||||
|
<%= l(:label_project_course_un) %>
|
||||||
|
</p>
|
||||||
|
<% else %>
|
||||||
|
<p class="font_description">
|
||||||
|
<!--teacher could create the course directly-->
|
||||||
|
<%= l(:label_project_course_unadd) %><%= link_to "#{l(:label_course_new)}", {:controller => 'courses', :action => 'new'}, :class => 'icon icon-add' %>
|
||||||
|
</p>
|
||||||
|
<% end %>
|
||||||
|
<% else %>
|
||||||
|
<%= render partial: 'users/course_list_have_entity_ex',:locals => {:user => user,:memberships_doing=>memberships_doing,:memberships_done=>memberships_done} %>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
<script type="text/javascript">
|
||||||
|
$(document).ready(function() {
|
||||||
|
var $menu = $('.user_course_list .menu');
|
||||||
|
var $li_tags = $menu.find('[mode]');
|
||||||
|
var $dyn_list = $('.dyn_list_wrapper');
|
||||||
|
|
||||||
|
$menu.find('[mode]').each(function(index, el) {
|
||||||
|
$(el).click(function() {
|
||||||
|
mode = $(el).attr('mode');
|
||||||
|
$menu.find('[mode]').removeClass( "on" );
|
||||||
|
$( this ).addClass( "on" );
|
||||||
|
var wrapper = $('[mode='+mode+']')
|
||||||
|
$dyn_list.addClass( "hidden" );
|
||||||
|
wrapper.removeClass('hidden')
|
||||||
|
})
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
Loading…
Reference in New Issue