Conflicts:
	app/controllers/bids_controller.rb
	app/views/courses/new_homework.html.erb
This commit is contained in:
sw 2014-06-30 11:15:25 +08:00
commit be2faea15b
19 changed files with 136 additions and 27 deletions

View File

@ -546,22 +546,47 @@ class CoursesController < ApplicationController
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
yesterday = Date.today.prev_day.to_time
@course_prefs.endup_time = yesterday
@save_flag = @course_prefs.save
get_courses
respond_to do |format|
format.js
end
end
def restartcourse
day = Time.parse("3000-01-01")
@course_prefs.endup_time = day
@save_flag = @course_prefs.save
get_courses
respond_to do |format|
format.js {

View File

@ -68,6 +68,9 @@ class MessagesController < ApplicationController
call_hook(:controller_messages_new_after_save, { :params => params, :message => @message})
render_attachment_warning_if_needed(@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

View File

@ -116,7 +116,7 @@ class NewsController < ApplicationController
flash[:notice] = l(:notice_successful_create)
redirect_to project_news_index_path(@project)
else
layout_file = (@project.project_type == 1) ? 'base_courses' : 'base_projects'
layout_file = @project ? 'base_projects' : 'base_courses'
render :action => 'new', :layout => layout_file
end
elsif @course

View File

@ -129,7 +129,7 @@ class Attachment < ActiveRecord::Base
nil
end
def filename=(arg)
def filename=(arg)
write_attribute :filename, sanitize_filename(arg.to_s)
filename
end

View File

@ -33,8 +33,9 @@ class Course < ActiveRecord::Base
acts_as_attachable :view_permission => :view_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 :name,:with =>/^[a-zA-Z0-9_\u4e00-\u9fa5]+$/
after_save :create_board_sync
before_destroy :delete_all_members

View File

@ -33,9 +33,13 @@ class JournalsForMessage < ActiveRecord::Base
:description => Proc.new{|o| o.notes },
:type => Proc.new {|o| o.jour_type },
:url => Proc.new {|o|
(o.jour.kind_of? Project) ? {:controller => 'projects', :action => 'feedback', :id => o.jour, :r => o.id, :anchor => "word_li_#{o.id}"} : {}
}#{:controller => 'documents', :action => 'show', :id => o.id}}
acts_as_activity_provider :author_key => :user_id,
if o.jour.kind_of? Project
{: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,
:timestamp => "#{self.table_name}.updated_on",
:find_options => {:include => :project }

View File

@ -53,7 +53,7 @@ class UserScore < ActiveRecord::Base
user_score = current_user.user_score_attr
user_grade = nil #项目个人得分
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)
if user_grade.nil?
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 #项目个人得分
target_user_grade = nil
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)
target_user_grade = UserGrade.find_by_user_id_and_project_id(target_user.id, project.id)
if current_user_grade.nil?
@ -285,7 +285,7 @@ class UserScore < ActiveRecord::Base
user_score = current_user.try(:user_score_attr)
user_grade = nil #项目个人得分
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)
if user_grade.nil?
user_grade = UserGrade.create(:user_id => current_user.id,:project_id => project.id)

View File

@ -18,7 +18,6 @@
<% object = [] %>
<% object << 'course' %>
<% object << 'course' %>
<%= error_messages_for object %>

View File

@ -6,7 +6,11 @@
<%= content_tag "p", "#{format_date(member.created_on)}#{l(:label_member_since)}", :class => "float_right member_since" %>
<% end %>
<%= member.user.nil? ? '' : (image_tag(url_to_avatar(member.user), :class => 'avatar')) %>
<%= content_tag "div", link_to(member.user.name, user_path(member.user)), :class => "nomargin avatar_name" %>
<% 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" %>
<% end %>
<!--teacher's code disapeared moified by huang-->
<% unless member.user.user_extensions.identity ==0 %>

View File

@ -1,8 +1,12 @@
<% if @save_flag %>
<% if Rails.env.development? %>
console.debug('课程修改成功:结束时间改为<%=Course.find_by_extra(@course.extra).try(:endup_time)%>');
<% end %>
$('#finish_course_<%=@course.id%>').replaceWith("<%= j(render partial: 'courses/set_course_time', :locals => {:course => @course} )%>")
<% if Rails.env.development? %>
console.debug('课程修改成功:结束时间改为<%=Course.find_by_extra(@course.extra).try(:endup_time)%>');
<% end %>
$('#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 %>
alert('权限不足,设置失败,请在论坛提交问题,等待管理员处理。');
alert('权限不足,设置失败,请在论坛提交问题,等待管理员处理。');
<% end %>

View File

@ -1,5 +1,6 @@
<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">
<%= render :partial => 'homework_form', :locals => { :f => f } %>
<%= submit_tag l(:button_create), :class => "enterprise" %>

View File

@ -26,6 +26,7 @@
<%= 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 %>
</td>
</tr>

View File

@ -35,7 +35,7 @@
</head>
<!--加上 onload="Javascript:t()" 开始定时刷新分数 -->
<body class="<%= h body_css_classes %>" onload="Javascript:t()">
<body class="<%= h body_css_classes %>">
<div id="wrapper">
<div id="wrapper2">
<div id="wrapper3">

View File

@ -1,4 +1,8 @@
<h3><%= link_to h(@board.name), :controller => 'boards', :action => 'show', :project_id => @project, :id => @board %> &#187; <%= l(:label_message_new) %></h3>
<% if @project %>
<h3><%= link_to h(@board.name), :controller => 'boards', :action => 'show', :project_id => @project, :id => @board %> &#187; <%= l(:label_message_new) %></h3>
<% elsif @course %>
<h3><%= link_to h(@board.name), :controller => 'boards', :action => 'show', :course_id => @course, :id => @board %> &#187; <%= l(:label_message_new) %></h3>
<% end %>
<%= form_for @message, :url => {:action => 'new'}, :html => {:multipart => true, :id => 'message-form'} do |f| %>
<%= render :partial => 'form', :locals => {:f => f} %>

View File

@ -1,6 +1,6 @@
<%= error_messages_for @news %>
<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 %>
</div>
<div class="box tabular">

View File

@ -1,9 +1,17 @@
<!-- <h3><%=l(:label_news_new)%></h3> -->
<%= labelled_form_for @news, :url => project_news_index_path(@project),
: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(:project_id => @project), 'news-form' ,target='preview',{:class => 'whiteButton m3p10'}%>
<% if @project %>
<%= labelled_form_for @news, :url => project_news_index_path(@project),
: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(:project_id => @project), 'news-form', target='preview', {:class => 'whiteButton m3p10'} %>
<% 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>

View File

@ -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>

View File

@ -1,4 +1,4 @@
<div class="content-title-top">
<div class="content-title-top" id="content-title-top-div">
<% if @memberships.empty? %>
<% if @user != User.current %>
<p class="font_description">

View File

@ -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>