diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index c0d7c1e25..e0daa44f4 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -556,22 +556,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 { diff --git a/app/views/courses/finishcourse.js.erb b/app/views/courses/finishcourse.js.erb index 025edb056..e67426953 100644 --- a/app/views/courses/finishcourse.js.erb +++ b/app/views/courses/finishcourse.js.erb @@ -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 %> + + diff --git a/app/views/users/_course_list_have_entity_ex.html.erb b/app/views/users/_course_list_have_entity_ex.html.erb new file mode 100644 index 000000000..2307f3a2b --- /dev/null +++ b/app/views/users/_course_list_have_entity_ex.html.erb @@ -0,0 +1,22 @@ + + diff --git a/app/views/users/_my_course.html.erb b/app/views/users/_my_course.html.erb index 85f455b19..c6fd032cb 100644 --- a/app/views/users/_my_course.html.erb +++ b/app/views/users/_my_course.html.erb @@ -1,4 +1,4 @@ -
+
<% if @memberships.empty? %> <% if @user != User.current %>

diff --git a/app/views/users/_my_course_ex.html.erb b/app/views/users/_my_course_ex.html.erb new file mode 100644 index 000000000..839b28633 --- /dev/null +++ b/app/views/users/_my_course_ex.html.erb @@ -0,0 +1,33 @@ +<% if memberships.empty? %> + <% if user != User.current %> +

+ <%= l(:label_project_course_un) %> +

+ <% else %> +

+ + <%= l(:label_project_course_unadd) %><%= link_to "#{l(:label_course_new)}", {:controller => 'courses', :action => 'new'}, :class => 'icon icon-add' %> +

+ <% end %> +<% else %> + <%= render partial: 'users/course_list_have_entity_ex',:locals => {:user => user,:memberships_doing=>memberships_doing,:memberships_done=>memberships_done} %> +<% end %> + + \ No newline at end of file