实训套件的改版

This commit is contained in:
cxt 2017-08-24 20:01:34 +08:00
parent e884b0285a
commit 49bbd36c12
14 changed files with 129 additions and 49 deletions

View File

@ -37,7 +37,7 @@ class SubjectsController < ApplicationController
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)
subject = Subject.create(:name => params[:subject][:name], :learning_notes => params[:subject][:learning_notes], :introduction => params[:subject][:introduction], :description => params[:subject][:description], :user_id => User.current.id, :visits => 0, :status => 0)
end
redirect_to subject_path(subject)
end
@ -48,7 +48,7 @@ class SubjectsController < ApplicationController
def update
if params[:subject]
subject = @subject.update_attributes(:name => params[:subject][:name], :description => params[:subject][:description])
subject = @subject.update_attributes(:name => params[:subject][:name], :learning_notes => params[:subject][:learning_notes], :introduction => params[:subject][:introduction], :description => params[:subject][:description])
end
redirect_to subject_path(@subject)
end
@ -103,15 +103,15 @@ class SubjectsController < ApplicationController
if apply && apply.status == 0
@status = 0
else
if Shixun.where(:id => @subject.stage_shixuns.map(&:shixun_id), :status => [0, 1]).count > 0
@status = 2
else
#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 + " 申请发布课程实训:<a href='#{subject_path(@subject)}'>#{@subject.name}</a>"
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
end

View File

@ -1972,9 +1972,9 @@ module ApplicationHelper
elsif params[:controller] == "shixuns" && params[:action] == "index"
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"

View File

@ -3,11 +3,29 @@ class Subject < ActiveRecord::Base
belongs_to :user
belongs_to :course_list
belongs_to :major
attr_accessible :description, :name, :status, :visits, :user_id, :course_list_id, :major_id
attr_accessible :description, :name, :status, :visits, :user_id, :course_list_id, :major_id, :learning_notes, :introduction
has_many :stages, :dependent => :destroy, :order => "stages.id ASC"
has_many :stage_shixuns, :dependent => :destroy
def subject_choices
count = 0
self.stage_shixuns.each do |stage_shixun|
shixun = stage_shixun.shixun
count += shixun.challenges.where(:st => [1, 2]).count
end
count
end
def subject_shixuns
count = 0
self.stage_shixuns.each do |stage_shixun|
shixun = stage_shixun.shixun
count += shixun.challenges.where(:st => 0).count
end
count
end
def subject_challenges
count = 0
self.stage_shixuns.each do |stage_shixun|

View File

@ -16,7 +16,7 @@
</div>
<ul class="fl innner-nav">
<li><%= link_to "全部实训", shixuns_path, :class => "new-nav-a font-16" %></li>
<li><%= link_to "实训套件", subjects_path, :class => "new-nav-a font-16" %></li>
<li><%= link_to "实训课程", subjects_path, :class => "new-nav-a font-16" %></li>
<li><%= link_to "在线课堂", courses_path, :class => "new-nav-a font-16" %></li>
<!-- <li><%#= link_to "论坛", forums_path, :class =>"new-nav-a", :target => "_blank" %></li>-->

View File

@ -20,7 +20,7 @@
<li><%#= link_to "帮助中心", "#{Setting.protocol}://#{Setting.host_name}/forums/1/memos/1168", :class => "new-nav-a", :target=>"_blank" %></li>-->
<li><%= link_to "全部实训", shixuns_path, :class => "new-nav-a font-16" %></li>
<!--<li><%#= link_to "课程实训", subjects_path, :class => "new-nav-a font-16", :target => "_blank" %></li>-->
<li><%= link_to "实训套件", subjects_path, :class => "new-nav-a font-16" %></li>
<li><%= link_to "实训课程", subjects_path, :class => "new-nav-a font-16" %></li>
<li><%= link_to "在线课堂", courses_path, :class => "new-nav-a font-16" %></li>
<div class="cl"></div>
</ul>

View File

@ -30,7 +30,7 @@
<% when 3 %>
<%= @sub_type == 1 ? "实训列表" :(@sub_type == 2 ? "已发布的实训": (@sub_type == 3 ? "已关闭的实训": "镜像管理")) %>
<% when 4 %>
<%= @sub_type == 1 ? "实训套件" : "已发布实训套件" %>
<%= @sub_type == 1 ? "实训课程" : "已发布实训套件" %>
<% when 5 %>
竞赛
<% when 6 %>
@ -66,7 +66,7 @@
<li><%= link_to "镜像管理", mirror_repository_managements_path %></li>
</ul>
</li>
<li class="fl edu-admin-nav-li edu-position <%= 'active' if @menu_type == 4 %>" style="width: 100px"><a href="javascript:void(0);" class="edu-admin-nav-a" >实训套件+</a>
<li class="fl edu-admin-nav-li edu-position <%= 'active' if @menu_type == 4 %>" style="width: 100px"><a href="javascript:void(0);" class="edu-admin-nav-a" >实训课程+</a>
<ul class="edu-admin-nav-inner edu-absolute">
<li style="width: 100px"><%= link_to "实训套件列表", class_shixuns_managements_path %></li>
<li style="width: 100px"><%= link_to "已发布实训套件", class_publish_shixuns_managements_path %></li>

View File

@ -18,7 +18,7 @@
<div class="active-class">
<p style="line-height: 42px;">
<i class="fa fa-map-marker mr5 color-grey"></i>
<a href="/users/kosasa">kosasa</a> &gt; <a href="/courses">实训套件</a>
<a href="/users/kosasa">kosasa</a> &gt; <a href="/courses">实训课程</a>
&gt;<span>新建</span>
</p>
<div class="edu-con-top ">

View File

@ -72,19 +72,19 @@
<a href="javascript:void(0);" style="height: 44px;display: block;line-height: 22px;"><%= subject.name %></a>
</p>
<p class="font-14 three_lines_show task-text-center mb20 color-dark-grey" style="text-align: left;">
计算思维导论计算思维导论计算思维导论计算思维导论计算思维导论计算思维导论计算思维导论计算思维导论计算思
<%= subject.introduction.blank? ? "轻松学习#{subject.name}~" : subject.introduction %>
</p>
<p class="color-grey bor-bottom-greyE mb5 clearfix" style="text-align: center;">
<span class="pl10 pr10"><i class="fa fa-pause-circle color-light-green transform90" aria-hidden="true" data-tip-down="章节"></i><em class="ml10"><%= subject.stage_shixuns.count %></em></span>
<span class="pl10 pr10"><i class="fa fa-gamepad color-light-green pr10" aria-hidden="true" data-tip-down="实训"></i><em><%= subject.stage_shixuns.count %></em></span>
<span class="pl10 pr10"><i class="fa fa-viacoin color-light-green pr10" aria-hidden="true" data-tip-down="总经验值"></i><em><%= subject.subject_score %></em></span>
<span class="pl10 pr10"><i class="fa fa-users color-light-green pr10" aria-hidden="true" data-tip-down="学习人数"></i><em><%= subject.subject_challenges %></em></span>
<span class="pl10 pr5"><i class="fa fa-pause-circle color-light-green transform90" aria-hidden="true" data-tip-down="章节"></i><em class="ml10"><%= subject.stages.count %></em></span>
<span class="pl10 pr5"><i class="fa fa-gamepad color-light-green pr10" aria-hidden="true" data-tip-down="实训"></i><em><%= subject.stage_shixuns.count %></em></span>
<span class="pl10 pr5"><i class="fa fa-viacoin color-light-green pr10" aria-hidden="true" data-tip-down="总经验值"></i><em><%= subject.subject_score %></em></span>
<span class="pl10 pr5"><i class="fa fa-users color-light-green pr10" aria-hidden="true" data-tip-down="学习人数"></i><em><%= subject.subject_challenges %></em></span>
</p>
<div class="clearfix mb10 df">
<a href="javascript:void(0);"><%= image_tag(url_to_avatar(subject.user), :width =>"40", :height => "40", :class => "bor-radius-all mr10 fl mt8", :alt=>"头像") %></a>
<div class="fl" style="flex: 1;text-align: left">
<p class="color-dark-grey"><%= subject.user.try(:show_name) %></p>
<p class="font-12 unit-name color-dark-grey">国防科学技术大学讲师国防科学技术大学讲师</p>
<p class="font-12 unit-name color-dark-grey"><%= subject.user.school_name + subject.user.identity %></p>
</div>
</div>
</div>

View File

@ -1,8 +1,8 @@
<div class="subhead">
<div class="subhead_content">
<p class="font-24 color_white subject-main-name"><%= @subject.name %>
<% if User.current.manager_of_subject?(@subject) && @subject.status == 0 %>
<i class="fa fa-pencil mt15 ml10 color-grey edit_subject_name font-18"></i>
<% if User.current.manager_of_subject?(@subject) %>
<a href="<%= edit_subject_path(@subject) %>"><i class="fa fa-pencil mt15 ml10 color-grey edit_subject_name font-18"></i></a>
<% end %>
</p>
<p class="color-light-grey-E font-16 mb30">
@ -17,17 +17,15 @@
<%# end %>
<%# if !User.current.manager_of_subject?(@subject) || @subject.status > 1 %>
<ul class="fl mt5 color-light-grey-E">
<li class="fl mr30"><i class="fa fa-pause-circle transform90" aria-hidden="true" data-tip-down="章节"></i><span class="ml5">5&nbsp;章节</span></li>
<li class="fl mr30"><i class="fa fa-pause-circle transform90" aria-hidden="true" data-tip-down="章节"></i><span class="ml5"><%= @subject.stages.count %>&nbsp;章节</span></li>
<li class="fl mr30"><i class="fa fa-gamepad fl mt5" title="实训"></i><span class="ml5"><%= @subject.stage_shixuns.count %>&nbsp;实训</span></li>
<li class="fl mr30">
<!--<span class="panel-inner-icon fl mt3">-->
<i class="fa fa-th-list" title="选择题任务"></i>
<!--</span>-->
<span class="ml5">5&nbsp;选择题任务</span>
<span class="ml5"><%= @subject.subject_choices %>&nbsp;选择题任务</span>
</li>
<li class="fl mr30">
<i class="fa fa-code" style="font-weight: bold;" title="实践任务"></i>
<span class="ml5">5&nbsp;实践任务</span>
<span class="ml5"><%= @subject.subject_shixuns %>&nbsp;实践任务</span>
</li>
<li class="fl mr30"><i class="fa fa-viacoin" title="经验值"></i><span class="ml5"><%= @subject.subject_score %>&nbsp;经验值</span></li>
</ul>

View File

@ -1,7 +1,7 @@
<div class="active-class ">
<p style="line-height: 42px;">
<i class="fa fa-map-marker mr5 color-grey"></i>
<%= link_to User.current.show_name, user_path(User.current) %> &gt; <%= link_to "实训套件", subjects_path() %>
<%= link_to User.current.show_name, user_path(User.current) %> &gt; <%= link_to "实训课程", subjects_path() %>
&gt; <span>编辑</span>
</p>
<div class="edu-con-top user_bg_shadow">
@ -15,6 +15,18 @@
<div class="cl"></div>
<span class="color-orange ml20 fl none" style="margin-left: 12%;" id="new_subject_name_notice"><i class="fa fa-exclamation-circle mr5" ></i>请输入名称</span>
</li>
<li class="clearfix pt20">
<label class="panel-form-label label fl"><span class="color-orange">*</span>&nbsp;描述</label>
<input type="text" name="subject[introduction]" value="<%= @subject.introduction %>" id="new_subject_intro" class="task task-height-40 panel-box-sizing task-form-80 fl color-grey ml20" maxlength="50" placeholder="一句话描述一下吸引更多人学习吧不超过50个字符">
<div class="cl"></div>
<span class="color-orange ml20 fl none" style="margin-left: 12%;" id="new_subject_intro_notice"><i class="fa fa-exclamation-circle mr5" ></i>请输入描述</span>
</li>
<li class="clearfix pt20">
<label class="panel-form-label label fl"><span class="color-orange">*</span>&nbsp;学习须知</label>
<textarea type="text" name="subject[learning_notes]" id="new_learning_notes" class="task task-height-220 panel-box-sizing task-form-70 fl color-grey ml20" placeholder=""><%= @subject.learning_notes %></textarea>
<div class="cl"></div>
<span class="color-orange ml20 fl none" style="margin-left: 12%;" id="new_learning_notes_notice"><i class="fa fa-exclamation-circle mr5" ></i>请输入学习须知</span>
</li>
<li class="clearfix pt20">
<label class="panel-form-label label fl">简介</label>
<textarea name="subject[description]" class="task task-height-220 panel-box-sizing task-form-70 fl color-grey ml20"><%= @subject.description %></textarea>

View File

@ -1,7 +1,7 @@
<div class="active-class ">
<p style="line-height: 42px;">
<i class="fa fa-map-marker mr5 color-grey"></i>
<%= link_to User.current.show_name, user_path(User.current) %> &gt; <%= link_to "实训套件", subjects_path() %>
<%= link_to User.current.show_name, user_path(User.current) %> &gt; <%= link_to "实训课程", subjects_path() %>
&gt; <span>新建</span>
</p>
<div class="edu-con-top user_bg_shadow">
@ -11,14 +11,22 @@
<%= labelled_form_for @subject do |f| %>
<li class="clearfix pt20">
<label class="panel-form-label label fl"><span class="color-orange">*</span>&nbsp;名称</label>
<input type="text" name="subject[name]" id="new_subject_name" class="task task-height-40 panel-box-sizing task-form-80 fl color-grey ml20" maxlength="100" placeholder="例如Python程序设计-从入门到精通">
<input type="text" name="subject[name]" id="new_subject_name" class="task task-height-40 panel-box-sizing task-form-80 fl color-grey ml20" maxlength="50" placeholder="例如Python程序设计-从入门到精通">
<div class="cl"></div>
<span class="color-orange ml20 fl none" style="margin-left: 12%;" id="new_subject_name_notice"><i class="fa fa-exclamation-circle mr5" ></i>请输入名称</span>
</li>
<!--<li class="clearfix pt20">
<li class="clearfix pt20">
<label class="panel-form-label label fl"><span class="color-orange">*</span>&nbsp;描述</label>
<input type="text" name="subject[describe]" id="new_subject_name" class="task task-height-40 panel-box-sizing task-form-80 fl color-grey ml20" maxlength="100" placeholder="一句话描述一下吸引更多人学习吧不超过50个字符">
</li>-->
<input type="text" name="subject[introduction]" id="new_subject_intro" class="task task-height-40 panel-box-sizing task-form-80 fl color-grey ml20" maxlength="50" placeholder="一句话描述一下吸引更多人学习吧不超过50个字符">
<div class="cl"></div>
<span class="color-orange ml20 fl none" style="margin-left: 12%;" id="new_subject_intro_notice"><i class="fa fa-exclamation-circle mr5" ></i>请输入描述</span>
</li>
<li class="clearfix pt20">
<label class="panel-form-label label fl"><span class="color-orange">*</span>&nbsp;学习须知</label>
<textarea type="text" name="subject[learning_notes]" id="new_learning_notes" class="task task-height-220 panel-box-sizing task-form-70 fl color-grey ml20" placeholder=""></textarea>
<div class="cl"></div>
<span class="color-orange ml20 fl none" style="margin-left: 12%;" id="new_learning_notes_notice"><i class="fa fa-exclamation-circle mr5" ></i>请输入学习须知</span>
</li>
<li class="clearfix pt20">
<label class="panel-form-label label fl">简介</label>
<textarea name="subject[description]" class="task task-height-220 panel-box-sizing task-form-80 fl color-grey ml20"></textarea>

View File

@ -1,9 +1,9 @@
<div class="with75 fl">
<!--简介-->
<% if !@subject.description.blank? || (User.current.manager_of_subject?(@subject) && @subject.status == 0) %>
<% if !@subject.description.blank? || User.current.manager_of_subject?(@subject) %>
<div class="pb20 produce-content bor-bottom-greyE">
<p class="clearfix">
<% if User.current.manager_of_subject?(@subject) && @subject.status == 0 %>
<% if User.current.manager_of_subject?(@subject) %>
<a href="<%= edit_subject_path(@subject) %>"><i class="fa fa-pencil fr mt10 mr5 color-grey-c edit-produce"></i></a>
<% end %>
</p>
@ -15,11 +15,11 @@
<!--新版阶段列表-->
<div class="lesson-saved-list mb20">
<% count = 0 %>
<% @stages.each do |stage| %>
<% @stages.each_with_index do |stage, index| %>
<div class="lesson-saved-list-item pt10 pb10 bor-bottom-greyE" id="stage_div_<%= stage.id %>">
<p class="clearfix">
<i class="fa fa-pause-circle color-light-green font-16 transform90"></i>
<span class="font-16 font-bd">第章&nbsp;&nbsp;<%= stage.name %></span>
<span class="font-16 font-bd">第<%= index + 1 %>章&nbsp;&nbsp;<%= stage.name %></span>
<% if @subject.status == 0 && User.current.manager_of_subject?(@subject) %>
<a href="javascript:void(0);" class="fr" onclick="edit_stage(<%= stage.id %>)"><i class="fa fa-pencil mt8 color-grey-c delete"></i></a>
<a href="javascript:void(0);" class="fr" onclick="delete_confirm_box_2('<%= stage_path(stage) %>', '确定要删除该阶段吗?');"><i class="fa fa-trash mt8 mr10 color-grey-c edit"></i></a>
@ -28,7 +28,7 @@
<% end %>
</p>
<div class="detail_for_paragraph clearfix">
<p class="ml20 color-dark-grey mt10 mb10">描述<%= stage.description %></p>
<p class="ml20 color-dark-grey mt10 mb10"><%= stage.description %></p>
<% stage.stage_shixuns.each_with_index do |stage_shixun, index| %>
<% shixun = stage_shixun.shixun %>
<div class="clearfix pt10 pb10 ml20 pl10 mb10 paragraph" id="stage_shixun_<%= shixun.id %>" style="cursor: pointer;" onclick="shixun_link('<%= shixun.identifier %>')">
@ -37,9 +37,8 @@
<span class="color-grey3"><%= shixun.name %></span>
</li>
<li class="fr mr20">
<% if @subject.status == 0 && User.current.manager_of_subject?(@subject) %>
<% if @subject.status < 2 %>
<span class="color-grey"><%= shixun.shixun_status %></span>
<span class="none ml10"><i class="fa fa-exclamation-circle color-red ml5 mr5"></i></span>
<% else %>
<% case my_shixun_status(shixun, User.current) %>
<% when '已通关' %>
@ -50,9 +49,12 @@
<span>未开启</span>&nbsp;&nbsp;<i class="fr fa fa-play-circle color-grey-c font-18 mr5 mt5" title="未开启"></i>
<% end %>
<% end %>
</li>
<li class="fr mr20">
<a href="" class="task-btn task-btn-orange">开始实战</a>
<% myshixun = Myshixun.where(:user_id => User.current.id, :shixun_id => shixun.id).first %>
<% if myshixun.blank? %>
<%= link_to "开始实战", shixun_path(shixun), :class => "task-btn task-btn-orange" %>
<% else %>
<%= link_to "继续实战", shixun_path(shixun), :class => "task-btn task-btn-orange" %>
<% end %>
</li>
</div>
<% end %>
@ -105,17 +107,21 @@
</div>
<div class="with25 fr">
<div class="edu-class-right-box ml15 mb20 user_bg_shadow bor-grey-e pl15 pt15 pr15">
<p class="font-16">学习须知<i class="fa fa-pencil fr mt10 mr5 color-grey-c edit-produce font-12"></i></p>
<p class="mt10 mb10 color-dark-grey">数据结构是计算机存储、组织数据的方式。数据结构是指相互之间存在一种或多种特定关系的数据元素的集合。通常情况下,精心选择的数据结构可以带来更高的运行或者存储效率。数据结构往往同高效的检索算法和索引技术有关。</p>
<p class="font-16">学习须知
<% if User.current.manager_of_subject?(@subject) %>
<a href="<%= edit_subject_path(@subject) %>"><i class="fa fa-pencil fr mt10 mr5 color-grey-c edit-produce font-12"></i></a>
<% end %>
</p>
<p class="mt10 mb10 color-dark-grey"><%= @subject.learning_notes.blank? ? "暂未填写" : @subject.learning_notes %></p>
</div>
<div class="edu-class-right-box ml15 user_bg_shadow bor-grey-e pl15 pt15 pr15">
<p class="font-16">教学名师<i class="fa fa-pencil fr mt10 mr5 color-grey-c edit-produce font-12"></i></p>
<div style="text-align: center" class="bor-bottom-greyE">
<p style="line-height: 15px"><img src="/images/avatars/User/15739?1501123240" class="bor-radius-all" width="40" height="40"/></p>
<p style="line-height: 15px">蔡世</p>
<p style="line-height: 27px" class="color-dark-grey font-12">国防科学技术大学讲师</p>
<p style="line-height: 15px"><%= image_tag(url_to_avatar(@subject.user), :width =>"40", :height => "40", :class => "bor-radius-all", :alt=>"头像") %></p>
<p style="line-height: 15px"><%= @subject.user.try(:show_name) %></p>
<p style="line-height: 27px" class="color-dark-grey font-12"><%= @subject.user.school_name + @subject.user.identity %></p>
</div>
<p class="mt10 mb10 color-dark-grey">数据结构是计算机存储、组织数据的方式。数据结构是指相互之间存在一种或多种特定关系的数据元素的集合。通常情况下,精心选择的数据结构可以带来更高的运行或者存储效率。数据结构往往同高效的检索算法和索引技术有关。</p>
<p class="mt10 mb10 color-dark-grey"><%= @subject.user.user_extensions.brief_introduction.blank? ? "暂未填写" : @subject.user.user_extensions.brief_introduction %></p>
<textarea class="undis with100 panel-box-sizing">
数据结构是计算机存储、组织数据的方式。数据结构是指相互之间存在一种或多种特定关系的数据元素的集合。通常情况下,精心选择的数据结构可以带来更高的运行或者存储效率。数据结构往往同高效的检索算法和索引技术有关。
</textarea>

View File

@ -0,0 +1,6 @@
class AddLearningNotesToSubjects < ActiveRecord::Migration
def change
add_column :subjects, :learning_notes, :text
add_column :subjects, :introduction, :string
end
end

View File

@ -1023,19 +1023,51 @@ function destroy_all_hb(url){
}
function submit_new_subject(){
var check = true;
if($("#new_subject_name").val().trim() == ""){
check = false;
$("#new_subject_name_notice").show();
} else{
$("#new_subject_name_notice").hide();
}
if($("#new_subject_intro").val().trim() == ""){
check = false;
$("#new_subject_intro_notice").show();
} else{
$("#new_subject_intro_notice").hide();
}
if($("#new_learning_notes").val().trim() == ""){
check = false;
$("#new_learning_notes_notice").show();
} else {
$("#new_learning_notes_notice").hide();
}
if(check){
$("#new_subject").submit();
}
}
function submit_edit_subject(id){
var check = true;
if($("#new_subject_name").val().trim() == ""){
check = false;
$("#new_subject_name_notice").show();
} else{
$("#new_subject_name_notice").hide();
}
if($("#new_subject_intro").val().trim() == ""){
check = false;
$("#new_subject_intro_notice").show();
} else{
$("#new_subject_intro_notice").hide();
}
if($("#new_learning_notes").val().trim() == ""){
check = false;
$("#new_learning_notes_notice").show();
} else {
$("#new_learning_notes_notice").hide();
}
if(check){
$("#edit_subject_"+id).submit();
}
}