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 @@
@@ -44,39 +44,44 @@
-| 序号 | +姓名 | +用户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 %> - - + | +
<%= link_to dis.user.show_name, user_path(dis.user), :class => "fl link-color-grey" %> diff --git a/app/views/stages/_edit.html.erb b/app/views/stages/_edit.html.erb index 3ac76b6fc..3624ab4f8 100644 --- a/app/views/stages/_edit.html.erb +++ b/app/views/stages/_edit.html.erb @@ -10,12 +10,12 @@
阶段名称不能为空
<% if @status == 0 %> 已发布过申请,请等待管理员审核 - <% else %> + <% elsif @status == 1 %> 发布申请已提交,请等待管理员的审核
• 我们将在1-2个工作日内完成审核 + <% elsif @status == 2 %> + 项目实训全部发布后,才能申请发布 <% end %>
<%= @subject.name %>
- - <% if @subject.status > 1 %> --- <%= @subject.stage_shixuns.count %>
- - <%= @subject.subject_challenges %>
- - <%= @subject.subject_score %>
+
<%= @subject.name %>
+ <% if User.current.manager_of_subject?(@subject) && @subject.status == 0 %> + + <% end %> + <% if !User.current.manager_of_subject?(@subject) || @subject.status > 1 %> ++- <%= @subject.stage_shixuns.count %>
+ - <%= @subject.subject_challenges %>
+ - <%= @subject.subject_score %>
<% elsif @subject.status == 0 && @subject.stages.count > 0 && User.current.manager_of_subject?(@subject) %> <%= link_to '申请发布', publish_subject_path(@subject), :class => "course-btn fr", :remote => true %> @@ -26,16 +28,38 @@ \ 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" %>diff --git a/app/views/subjects/new.html.erb b/app/views/subjects/new.html.erb new file mode 100644 index 000000000..bfd4eb1a0 --- /dev/null +++ b/app/views/subjects/new.html.erb @@ -0,0 +1,29 @@ +
+
+ 新建实训套件
+
+
+ <%= labelled_form_for @subject do |f| %>
+ -
+
+
+
+ 请输入名称
+
+ -
+
+
+
+ -
+
+ <%= link_to "取消", subjects_path(), :class => "task-btn fl mr10 ml20" %>
+ 保存
+
+ <% end %>
+
+
\ No newline at end of file
diff --git a/app/views/subjects/publish.js.erb b/app/views/subjects/publish.js.erb
index 04bdaeee6..846edc9ca 100644
--- a/app/views/subjects/publish.js.erb
+++ b/app/views/subjects/publish.js.erb
@@ -1,2 +1,7 @@
var htmlvalue = "<%= escape_javascript(render :partial => 'subjects/publish_notice')%>";
-pop_box_new(htmlvalue,563,406);
\ No newline at end of file
+pop_box_new(htmlvalue,563,406);
+<% if @status == 2 %>
+ <% Shixun.where(:id => @subject.stage_shixuns.map(&:shixun_id), :status => [0, 1]).each do |shixun| %>
+ $("#stage_shixun_<%= shixun.id %>").find(".fa-exclamation-circle").parent().show();
+ <% end %>
+<% end %>
\ No newline at end of file
diff --git a/app/views/subjects/show.html.erb b/app/views/subjects/show.html.erb
index 113680a8c..b8fdbc93b 100644
--- a/app/views/subjects/show.html.erb
+++ b/app/views/subjects/show.html.erb
@@ -1,117 +1,94 @@
-
-
+<% if !@subject.description.blank? || (User.current.manager_of_subject?(@subject) && @subject.status == 0) %>
+
+
+<% end %>
-
-
-
- - 剩下的人去哪儿啦?
- - 1
- - 1200经验值
-
-
-
-
- - 剩下的人去哪儿啦?
- - 1
- - 1200经验值
- - 已发布编辑中待审核
-
-
- - 剩下的人去哪儿啦?
- - 1
- - 1200经验值
- - 已发布编辑中待审核
-
-
-
-
-
- - 剩下的人去哪儿啦?
- - 1
- - 1200经验值
- - 已发布编辑中待审核
-
-
- - 剩下的人去哪儿啦?
- - 1
- - 1200经验值
- - 已发布编辑中待审核
-
-
- - 剩下的人去哪儿啦?
- - 1
- - 1200经验值
- - 已发布编辑中待审核
-
-
-
-
-
-
-
-
<% @stages.each do |stage| %>
-
-
- - <%= stage.name %>
- <% if @subject.status == 0 && User.current.manager_of_subject?(@subject) %>
- -
- 删除
- 编辑
-
- <% end %>
-
-
- <% stage.stage_shixuns.each_with_index do |stage_shixun, index| %>
- <% shixun = stage_shixun.shixun %>
-
- <%= index + 1 %>
-
-
- <%= image_tag(url_to_avatar(shixun.owner), :width =>"60", :height => "60", :class => "panel-warp-img mr10 fl", :alt=>"头像") %>
- <%= shixun.owner.try(:show_name) %>
-
-
- <%= shixun.language %>
-
+
+ -
+
+ <%= shixun.name %>
+
+ -
+
+ <%= shixun.challenges.count %>
+
+ -
+ <%= shixun.shixun_score %>
+ -
+ <% if @subject.status == 0 && User.current.manager_of_subject?(@subject) %>
+ <%= shixun.shixun_status %>
+
+ <% else %>
+ <% case my_shixun_status(shixun, User.current) %>
+ <% when '已通关' %>
+
+ <% when '未通关' %>
+
+ <% when '未开启' %>
+
+ <% end %>
+ <% end %>
+
-
- <% end %>
-
-
+ <% end %>
+
<% end %>
+
<% if @subject.status == 0 && User.current.manager_of_subject?(@subject) %>
<% if @stages.count == 0 %>
@@ -132,7 +109,7 @@
-
-
+
-
<%= link_to '+选择实训', choose_subject_shixun_subject_path(@subject), :remote => true, :class => 'add-sx' %>
@@ -209,7 +186,7 @@
edithtml+="
";
edithtml+="- ";
edithtml+="";
- edithtml+="
";
+ edithtml+="";
edithtml+="- ";
edithtml+='<%= link_to '+选择实训', choose_subject_shixun_subject_path(@subject), :remote => true, :class => 'add-sx' %>';
edithtml+="
+ + <%= link_to User.current.show_name, user_path(User.current) %> > <%= link_to "实训套件", subjects_path() %> + > 新建 +
+简介
-本课程适合没有基础、或者初学C++的同学进行学习,本课程适合没有基础、或者初学C++的同学进行学习,本课程适合没有基础、或者初学C++的同学进行学习,本课程适合没有基础、或者初学C++的同学进行学习
-+ 简介 + <% if User.current.manager_of_subject?(@subject) && @subject.status == 0 %> + + <% end %> +
+ +第1章 基础入门
-程序是对数据的处理,一般程序可以分解为:“数据输入”程序是对数据的处理,一般程序可以分解为:“数据输入”程序是对数据的处理,一般程序可以分解为:“数据输入”程序是对数据的处理,一般程序可以分解为:“数据输入”
-第1章 基础入门
-程序是对数据的处理,一般程序可以分解为:“数据输入”
-- <%= shixun.name %> -
-<%= shixun.shixun_trainee %>
++ + <%= stage.name %> + <% if @subject.status == 0 && User.current.manager_of_subject?(@subject) %> + + + <% end %> +
+<%= stage.description %>
+ <% stage.stage_shixuns.each_with_index do |stage_shixun, index| %> + <% shixun = stage_shixun.shixun %> +-- <%= shixun.challenges.count %>
- - <%= shixun.myshixuns.count %>
- - <%= shixun.shixun_score %>
-
-"; @@ -248,12 +225,12 @@ } else{ $("#stage_name_notice").hide(); } - if($("input[name='shixun_id[]']").length == 0){ - status = false; - $("#sx_none_notice").show(); - } else{ - $("#sx_none_notice").hide(); - } +// if($("input[name='shixun_id[]']").length == 0){ +// status = false; +// $("#sx_none_notice").show(); +// } else{ +// $("#sx_none_notice").hide(); +// } if(status && flag){ flag = false; $("#new_stage_form").submit(); diff --git a/config/routes.rb b/config/routes.rb index 4dcd2a279..63d99e310 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -37,6 +37,7 @@ RedmineApp::Application.routes.draw do get 'choose_subject_shixun' get 'publish' get 'cancel_publish' + post 'update_attr' end collection do diff --git a/public/images/bigdata/singel.png b/public/images/bigdata/singel.png new file mode 100644 index 000000000..c62175e86 Binary files /dev/null and b/public/images/bigdata/singel.png differ diff --git a/public/javascripts/edu/base_edu.js b/public/javascripts/edu/base_edu.js index a9ea17630..6857e28f7 100644 --- a/public/javascripts/edu/base_edu.js +++ b/public/javascripts/edu/base_edu.js @@ -991,4 +991,13 @@ function destroy_all_hb(url){ }else{ $("#choose_homework_bank_to_send_notice_h").html("请先选择题目").show(); } +} + +function submit_new_subject(){ + if($("#new_subject_name").val().trim() == ""){ + $("#new_subject_name_notice").show(); + } else{ + $("#new_subject_name_notice").hide(); + $("#new_subject").submit(); + } } \ No newline at end of file diff --git a/public/stylesheets/css/edu-class.css b/public/stylesheets/css/edu-class.css index dfbc8744a..8f49deccd 100644 --- a/public/stylesheets/css/edu-class.css +++ b/public/stylesheets/css/edu-class.css @@ -279,8 +279,6 @@ em{font-style:normal;} .stud-class-set .people .right .person {background:#fff;min-height:600px;} .stud-class-set .people .right .person .teacher ul li{width:100%;height:50px;line-height:50px;border-bottom:1px dashed #ddd;} .stud-class-set .people .right .person .teacher p{width:100%;height:50px;line-height:50px;border-bottom:1px dashed #ddd;} -.stud-class-set .people .right .person .teacher span{width:120px;display:inline-block;text-align:center;padding-right:91px;} -.stud-class-set .people .right .person .teacher a{width:120px;display:inline-block;text-align:center;padding-right:91px;} .stud-class-set .people .right .person .teacher .span1{text-align:left;padding:0;} .stud-class-set .people .right .person .teacher .span5{padding:0;} .stud-class-set .people .right .person .student{min-height:600px;} diff --git a/public/stylesheets/css/edu-subject.css b/public/stylesheets/css/edu-subject.css index 9ea88df50..52823da0a 100644 --- a/public/stylesheets/css/edu-subject.css +++ b/public/stylesheets/css/edu-subject.css @@ -24,16 +24,16 @@ /*-----------新版新建实训------------*/ .produce-content:hover i{color:#29bd8b!important;} -.subject-main-name{outline: none} -.subject-produce{outline: none;} -.stage-info-line{padding-left: 50px} +.subject-main-name{outline: none;background: none;border: none;width: auto;height: 45px} +.subject-produce{outline: none;line-height: 1.5;width: 100%;border: none;background: none;height: 30px;} .stage-info-line:hover{background-color:rgba(142,212,254,0.3)} -.lesson-saved-list-item:hover{box-shadow: 0 0 8px 0 rgba(0,0,0,.2);} +.lesson-saved-list-item{border:1px solid #EEEEEE} .lesson-saved-list-item:hover .edit{color:#29bd8b!important;} .lesson-saved-list-item:hover .delete{color:#29bd8b!important;} li.li-width50{width: 50%;text-align: left} li.li-width20{width: 20%;text-align: left} li.li-width10{width: 10%;text-align: left} +.lesson-saved-list-item{background-color: #FFFFFF} /*------课程实训首页---------*/ .course_tip_box{width: 460px;padding: 10px;background-color: #FFFFFF;} @@ -70,8 +70,7 @@ li.li-width10{width: 10%;text-align: left} .allback{background-color:#FFFFFF} -.last-all-count{width: 20%;text-align: right;} -.last-all-count li{float: left;width: 33.3%;} +.last-all-count{text-align: right;} .course-option{width: 570px;padding: 10px;background-color: #FFFFFF;} .magic-radio + label:before, .magic-checkbox + label:before{top: 11px;left: 5px;} diff --git a/public/stylesheets/css/taskstyle.css b/public/stylesheets/css/taskstyle.css index 5d5f6539a..a779ecd60 100644 --- a/public/stylesheets/css/taskstyle.css +++ b/public/stylesheets/css/taskstyle.css @@ -64,6 +64,7 @@ a.rightbar-pause{ color:#29bd8b; font-size: 18px; margin-right:15px; margin-top: .content-submitbox{ width:120px; margin: 15px auto; height:135px;} .panel-inner{ background:#EFF2F7; margin:15px; padding:15px;} .panel-inner-title{ font-size: 14px; color: #666; max-width:85%; line-height:30px;word-wrap: break-word; margin-bottom: 10px} +.panel-inner-icon{width: 22px;height: 22px;line-height: 22px;border-radius: 50%;background: #29bd8b;display: block;text-align: center} .panel-footer{ min-width:1000px; height: 210px!important;} /* 弹框 */ .task-popup-text-center{ text-align: center; color: #666;}