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..e73ce0214 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 @@ -67,15 +88,19 @@ class SubjectsController < ApplicationController end def publish - @subject.update_attributes(:status => 1) apply = ApplyAction.where(:container_type => "ApplySubject", :container_id => @subject.id).order("created_at desc").first 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 + @subject.update_attributes(:status => 1) + 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 3b199c484..7a36fa413 100644 --- a/app/views/challenges/_content_list.html.erb +++ b/app/views/challenges/_content_list.html.erb @@ -5,10 +5,10 @@ <%= @challenges.count %> <% end %> <% if User.current.manager_of_shixun?(@shixun) && @shixun.status == 0 %> - - - - 新建阶段 + +单选任务 + +多选任务 + +编程任务 + <% end %>
<% @challenges.each_with_index do |challenge, index| -%> diff --git a/app/views/challenges/_edit_task_pass.html.erb b/app/views/challenges/_edit_task_pass.html.erb index 0e602d69d..4781c0bb5 100644 --- a/app/views/challenges/_edit_task_pass.html.erb +++ b/app/views/challenges/_edit_task_pass.html.erb @@ -31,11 +31,41 @@ <% end %> <% end %> + +
<%# if @challenge.st == 1 %> - - <%# end %>
  • @@ -25,11 +31,14 @@
  • - - - - - + +
  • 保存 <% if params[:action] == "new" %> @@ -68,7 +77,62 @@ imageFormats : ["jpg", "jpeg", "gif", "png", "bmp", "webp", "JPG", "JPEG", "GIF", "PNG", "BMP", "WEBP"], imageUploadURL : "<%= upload_with_markdown_path(:container_id => @shixun.id, :container_type => @shixun.class) %>"//url }); + + var bt = baidu.template; + bt.LEFT_DELIMITER = ''; + + $("#shixun_form").on('click', 'a.option_icon_add', function () { + var html = bt('t:set-option-list', null); + $(this).parent().parent('.clearfix').before(html); + var inputs = document.getElementsByName("option_inputs_label"); + var inputs_spans = document.getElementsByName("option_span"); + for (var j = 0; j < inputs_spans.length; j++) { + if(j >= 0 && j <= 26){ + $(inputs_spans[j]).html(String.fromCharCode(65 + j)); + } + } + for (var i = 0; i < inputs.length; i++) { + autoTextarea(inputs[i], 0, 140); + } + $(inputs[inputs.length - 1]).focus(); + }); + $("#shixun_form").on('click', 'a.option_icon_remove', function () { + $(this).parent('.clearfix').remove(); + var inputs_spans = document.getElementsByName("option_span"); + for (var j = 0; j < inputs_spans.length; j++) { + if(j >= 0 && j <= 26){ + if(j >= 0 && j <= 26){ + $(inputs_spans[j]).html(String.fromCharCode(65 + j)); + } + } + } + }); }); + //设置选项答案 + function selectchoice(item){ + //判断是否选中,如果选中,再次点击的时候取消选中 + if($(item).hasClass('check-option-bg')){ + $(item).removeClass('check-option-bg'); + }else{ + if(true){ + //单选 + $(".select-choice").removeClass('check-option-bg'); + $(item).addClass('check-option-bg'); + }else{ + //多选 + $(item).addClass('check-option-bg'); + } + } + $("#current-option").html(""); + if($(".check-option-bg").length>0){ + for(var i=0;i<$(".check-option-bg").length;i++){ + $("#current-option").html($("#current-option").html()+$(".check-option-bg").eq(i).html()); + } + }else{ + $("#current-option").html("请点击正确选项"); + } + } window.onload = function(){ $("#challenge_task_pass [type=\"latex\"]").bind("click", function(){ taskpass_editormd.cm.replaceSelection("```latex"); 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 %>
    -
    -
  • <% end %>
    - <% if @path == @game.challenge.path.strip %> + <% if @path == @game.challenge.path.try(:strip) %> <% end %> diff --git a/app/views/layouts/base_subject.html.erb b/app/views/layouts/base_subject.html.erb index 644061f94..eca18d661 100644 --- a/app/views/layouts/base_subject.html.erb +++ b/app/views/layouts/base_subject.html.erb @@ -16,7 +16,7 @@ -
    +
    <%= render :partial => User.current.logged? ? 'layouts/logined_header' : 'layouts/unlogin_header' %>
    diff --git a/app/views/stages/_edit.html.erb b/app/views/stages/_edit.html.erb index 765989165..3624ab4f8 100644 --- a/app/views/stages/_edit.html.erb +++ b/app/views/stages/_edit.html.erb @@ -8,10 +8,16 @@
    -
  • -
  • - -

    +
  • + + +

    +
  • +
  • + + +
  • +
  • <%= link_to '+选择实训', choose_subject_shixun_subject_path(@subject), :remote => true, :class => 'add-sx' %>

    至少选择一个实训 diff --git a/app/views/subjects/_publish_notice.html.erb b/app/views/subjects/_publish_notice.html.erb index b9c3f093d..7b546e7eb 100644 --- a/app/views/subjects/_publish_notice.html.erb +++ b/app/views/subjects/_publish_notice.html.erb @@ -7,9 +7,11 @@

    <% if @status == 0 %> 已发布过申请,请等待管理员审核 - <% else %> + <% elsif @status == 1 %> 发布申请已提交,请等待管理员的审核
    • 我们将在1-2个工作日内完成审核 + <% elsif @status == 2 %> + 项目实训全部发布后,才能申请发布 <% end %>

  • diff --git a/app/views/subjects/_subject_createnew.html b/app/views/subjects/_subject_createnew.html new file mode 100644 index 000000000..a86d57578 --- /dev/null +++ b/app/views/subjects/_subject_createnew.html @@ -0,0 +1,46 @@ + + + + + + + + + + + + + +
    +
    +
    +

    + + kosasa > 实训套件 + >新建 +

    +
    + 新建实训套件 +
    +
    +
  • + + +
  • +
  • + + +
  • +
  • + + 保存 + 取消 +
  • +
    +
    +
    +
    + + diff --git a/app/views/subjects/_subject_top.html.erb b/app/views/subjects/_subject_top.html.erb index cdd006272..add31b9ef 100644 --- a/app/views/subjects/_subject_top.html.erb +++ b/app/views/subjects/_subject_top.html.erb @@ -7,12 +7,15 @@ <%= @subject.user.show_name %>

    -

    <%= @subject.name %>

    - <% if @subject.status > 1 %> -
    -
    \ No newline at end of file + + + \ No newline at end of file diff --git a/app/views/subjects/index.html.erb b/app/views/subjects/index.html.erb index 6adc1f717..7efca3b78 100644 --- a/app/views/subjects/index.html.erb +++ b/app/views/subjects/index.html.erb @@ -3,7 +3,7 @@

    实训套件

    - <%= link_to "+ 创建套件".html_safe, new_subject_subjects_path, :remote => true, :class => "fr color_white font-20" %> + <%= link_to "+ 创建套件".html_safe, new_subject_path(), :class => "fr color_white font-20" %>