diff --git a/app/controllers/stages_controller.rb b/app/controllers/stages_controller.rb index cdb8712df..d653d33a3 100644 --- a/app/controllers/stages_controller.rb +++ b/app/controllers/stages_controller.rb @@ -5,14 +5,15 @@ class StagesController < ApplicationController include ApplicationHelper def create - if params[:stage_name] && params[:shixun_id] + if params[:stage_name] stage = Stage.new stage.name = params[:stage_name] + stage.description = params[:stage_des] stage.subject_id = @subject.id stage.user_id = User.current.id stage.position = @subject.stages.count + 1 ActiveRecord::Base.transaction do - if stage.save + if stage.save && params[:shixun_id] begin params[:shixun_id].each do |shixun_id| shixun = Shixun.find shixun_id @@ -34,10 +35,11 @@ class StagesController < ApplicationController end def update - if params[:stage_name] && params[:shixun_id] + if params[:stage_name] @stage.name = params[:stage_name] + @stage.description = params[:stage_des] ActiveRecord::Base.transaction do - if @stage.save + if @stage.save && params[:shixun_id] begin @stage.stage_shixuns.destroy_all params[:shixun_id].each do |shixun_id| diff --git a/app/controllers/subjects_controller.rb b/app/controllers/subjects_controller.rb index 6da59d62b..d75511204 100644 --- a/app/controllers/subjects_controller.rb +++ b/app/controllers/subjects_controller.rb @@ -3,7 +3,7 @@ class SubjectsController < ApplicationController layout 'base_subject' before_filter :require_login before_filter :check_authentication - before_filter :find_subject, :except => [:index, :create_subject, :new_subject, :append_to_stage] + before_filter :find_subject, :except => [:index, :new, :create, :create_subject, :new_subject, :append_to_stage] include ApplicationHelper @@ -30,6 +30,26 @@ class SubjectsController < ApplicationController @stages = @subject.stages end + def new + @subject = Subject.new + render :layout => "base_edu" + end + + def create + if params[:subject] + subject = Subject.create(:name => params[:subject][:name], :description => params[:subject][:description], :user_id => User.current.id, :visits => 0, :status => 0) + end + redirect_to subject_path(subject) + end + + def update_attr + if params[:name] + @subject.update_attributes(:name => params[:name]) + elsif params[:description] + @subject.update_attributes(:description => params[:description]) + end + end + def new_subject if Course.where(:tea_id => User.current.id).count > 0 @status = 1 @@ -53,8 +73,9 @@ class SubjectsController < ApplicationController end def choose_subject_shixun - course_list = @subject.course_list - @shixuns = Shixun.where(:user_id => User.current.id, :status => [0, 1, 2], :id => course_list.shixun_major_courses.map(&:shixun_id)) + #course_list = @subject.course_list + @shixuns = User.current.shixuns.where(:status => [0, 1, 2]).reorder("created_at desc") + #@shixuns = Shixun.where(:user_id => User.current.id, :status => [0, 1, 2], :id => course_list.shixun_major_courses.map(&:shixun_id)) @shixuns_count = @shixuns.count @limit = 8 @shixuns_pages = Paginator.new @shixuns_count, @limit, params['page'] || 1 @@ -72,10 +93,14 @@ class SubjectsController < ApplicationController if apply && apply.status == 0 @status = 0 else - ApplyAction.create(:container_type => "ApplySubject", :container_id => @subject.id, :user_id => User.current.id, :status => 0) - notes = User.current.show_name.to_s + " 申请发布课程实训:#{@subject.name}" - JournalsForMessage.create(:jour_id => 1, :jour_type => 'Principal', :user_id => User.current.id, :notes => notes, :private => 1, :reply_id => 0) - @status = 1 + if Shixun.where(:id => @subject.stage_shixuns.map(&:shixun_id), :status => [0, 1]).count > 0 + @status = 2 + else + ApplyAction.create(:container_type => "ApplySubject", :container_id => @subject.id, :user_id => User.current.id, :status => 0) + notes = User.current.show_name.to_s + " 申请发布课程实训:#{@subject.name}" + JournalsForMessage.create(:jour_id => 1, :jour_type => 'Principal', :user_id => User.current.id, :notes => notes, :private => 1, :reply_id => 0) + @status = 1 + end end end @@ -83,8 +108,8 @@ class SubjectsController < ApplicationController apply = ApplyAction.where(:container_type => "ApplySubject", :container_id => @subject.id).order("created_at desc").first if apply && apply.status == 0 apply.update_attributes(:status => 3) - @subject.update_column('status', 0) end + @subject.update_attributes(:status => 0) redirect_to subject_path(@subject) end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 002ed0db7..29fbf65f0 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -230,6 +230,18 @@ module ApplicationHelper end end + # TPI状态 :已通关、未通关、未开启 + def my_shixun_status shixun, user + status = "" + myshixun = Myshixun.where(:shixun_id => shixun.id, :user_id => user.id).first + if myshixun.nil? + status = "未开启" + else + status = myshixun.status == 1 ? "已通关" : "未通关" + end + status + end + # 定义实训相关方法 def sum_final_score Game.find_by_sql("SELECT sum(final_score) as total_score FROM `games` where user_id=#{User.current.id}").first.try(:total_score) @@ -1918,23 +1930,23 @@ module ApplicationHelper elsif @welcome title << "创新源于实践" elsif @course - title << (@course.name.nil? ? "实训课堂" : @course.name) + title << (@course.name.nil? ? "在线课堂" : @course.name) elsif params[:controller] == "homework_bank" title << ("题库") elsif params[:controller] == "courses" && params[:action] == "index" - title << ("实训课堂") + title << ("在线课堂") elsif @contest title << (@contest.name.nil? ? "创新源于实践" : @contest.name) elsif @shixun - title << (@shixun.name.nil? ? "实训分类" : @shixun.name) + title << (@shixun.name.nil? ? "全部实训" : @shixun.name) elsif @my_shixun title << ("我的实训") elsif params[:controller] == "shixuns" && params[:action] == "index" - title << ("实训分类") + title << ("全部实训") elsif @subject - title << (@subject.name.nil? ? "课程实训" : @subject.name) + title << (@subject.name.nil? ? "实训套件" : @subject.name) elsif params[:controller] == "subjects" && params[:action] == "index" - title << ("课程实训") + title << ("实训套件") elsif @organization title << (@organization.name.nil? ? "创新源于实践" : @organization.name) elsif @forum || params[:controller] == "forums" @@ -1945,7 +1957,7 @@ module ApplicationHelper if !@project_community.blank? || !@user_projectlist.blank? title << "项目" elsif !@course_community.blank? || !@user_courselist.blank? - title << "实训课堂" + title << "在线课堂" elsif !@contest_community.blank? title << @contest_community elsif !@manage_issues.blank? @@ -1960,7 +1972,7 @@ module ApplicationHelper title << @user.show_name end elsif @syllabus - title << (@syllabus.title.nil? ? "实训课堂" : @syllabus.title) + title << (@syllabus.title.nil? ? "在线课堂" : @syllabus.title) else title << (User.current.id == 2 ? "未登录" : User.current.try(:realname)) end diff --git a/app/views/challenges/_content_list.html.erb b/app/views/challenges/_content_list.html.erb index 1145b27a1..bad618ce9 100644 --- a/app/views/challenges/_content_list.html.erb +++ b/app/views/challenges/_content_list.html.erb @@ -13,7 +13,12 @@
<% @challenges.each_with_index do |challenge, index| -%>
-

第<%= challenge.position %>关 +

+ + + 第<%= challenge.position %>关 <%#= link_to challenge.subject, shixun_challenge_path(@shixun.id, challenge), :target => "_blank" %> <% if User.current.manager_of_shixun?(@shixun) %> <%= link_to challenge.subject, shixun_challenge_path(@shixun, challenge), :target => "_blank" %> diff --git a/app/views/courses/_member_all_student_list.html.erb b/app/views/courses/_member_all_student_list.html.erb index b7286f7b5..d0b32777b 100644 --- a/app/views/courses/_member_all_student_list.html.erb +++ b/app/views/courses/_member_all_student_list.html.erb @@ -27,14 +27,14 @@ <% end %>

-
+
-
+

@@ -44,39 +44,44 @@

-
    -
  • - 序号 - 姓名 - 用户ID - 学号 - 分班 - 操作 -
  • + + + + + + + + + + + + + <% unless @members.blank? %> <% @members.each_with_index do |member, index| %> <% user = member.user %> -
  • - <%= index + 1 + (@page - 1) * 20 %> - <%= link_to user.show_real_name, user_path(user), :target => '_blank' %> - <%= user.login %> - <%= user.user_extensions ? user.user_extensions.student_id : '' %> - <%= member.course_group_id == 0 ? '未分班' : member.course_group.name %> - +
  • + + + + + + + <% end %> <% end %> - + +
    序号姓名用户ID学号分班操作
    <%= index + 1 + (@page - 1) * 20 %><%= link_to user.show_real_name, user_path(user), :class => 'edu-txt-w140 task-hide mt5', :target => '_blank' %><%= user.login %><%= user.user_extensions ? user.user_extensions.student_id : '' %><%= member.course_group_id == 0 ? '未分班' : member.course_group.name %> <% if user == User.current %> - 删除 + 删除 <% else %> -- <% end %> - - +
-
+
    <%= pagination_links_full @member_pages, @member_count, :per_page_links => false, :remote => @is_remote, :flag => true, :is_new => true%>
diff --git a/app/views/courses/_member_group_student_list.html.erb b/app/views/courses/_member_group_student_list.html.erb index 14b0be8ea..d139d5bc6 100644 --- a/app/views/courses/_member_group_student_list.html.erb +++ b/app/views/courses/_member_group_student_list.html.erb @@ -31,14 +31,14 @@ <% end %>
-
-