添加course_group表单到数据库中,并建立对应于members和courses之间的关联,

对相应页面的修改

Signed-off-by: alan <547533434@qq.com>
course_group
alan 11 years ago
parent 3eddca8c6e
commit 63c9804da8

@ -201,13 +201,19 @@ class CoursesController < ApplicationController
@render_file = 'member_list'
@teachers= searchTeacherAndAssistant(@course)
@canShowCode = isCourseTeacher(User.current.id,@course) && params[:role] != '1'
@role = params[:role]
@course_group_id = params[:@course_group_id] unless params[:@course_group_id].nil?
case params[:role]
when '1'
@subPage_title = l :label_teacher_list
@members = searchTeacherAndAssistant(@course)
when '2'
@subPage_title = l :label_student_list
@members = searchStudent(@course)
if @course_group_id
@members = search_student_in_group(@course, @course_group_id)
else
@members = searchStudent(@course)
end
else
@subPage_title = ''
@members = @course.member_principals.includes(:roles, :principal).all.sort

@ -170,7 +170,7 @@ module CoursesHelper
members
end
def searchStudent project
def search_student_in_group(project, course_group_id)
#searchPeopleByRoles(project, StudentRoles)
members = []
project.members.each do |m|
@ -178,6 +178,14 @@ module CoursesHelper
end
members
end
def searchStudent project
#searchPeopleByRoles(project, StudentRoles)
members = []
project.members.each do |m|
members << m if m && m.user && m.user.allowed_to?(:as_student,project)
end
members
end
# =====================================================================================
#def searchCountByRoles project, roles_id

@ -29,6 +29,8 @@ class Course < ActiveRecord::Base
has_many :news, :dependent => :destroy, :include => :author
has_one :course_status, :class_name => "CourseStatus", :dependent => :destroy
has_many :course_groups, :dependent => :destroy
acts_as_taggable
acts_as_nested_set :order => 'name', :dependent => :destroy
acts_as_attachable :view_permission => :view_files,

@ -0,0 +1,15 @@
class CourseGroup < ActiveRecord::Base
# attr_accessible :title, :body
belongs_to :course
has_many :members
before_destroy :set_member_nil
attr_accessible :name
def set_member_nil
if self.members && self.members.count > 0
self.members.update_all("course_group_id = 0")
end
end
end

@ -24,6 +24,7 @@ class Member < ActiveRecord::Base
belongs_to :project
belongs_to :course
belongs_to :course_group
validates_presence_of :principal
validates_uniqueness_of :user_id, :scope => [:project_id,:course_id]
validate :validate_role

@ -1,10 +1,15 @@
<div class="member_header">
<p>
<%= @subPage_title %>
</p>
</div>
<div class="member_content">
<%= error_messages_for 'member' %>
<%= render :partial => @render_file, :locals => {:members => @members} %>
<%= stylesheet_link_tag 'course_group', :media => 'all' %>
<div class="st_list">
<div class="st_search">
<span class="f_l"><%= @subPage_title %></span>
<% if @subPage_title == l(:label_student_list) %>
<form class="f_l"><%= text_field_tag 'name', params[:name], name: "name", class: 'f_1'%></form>
<%= submit_tag l(:label_search), :class => 'f_2' %>
<% end %>
</div>
<div class="member_content">
<%= error_messages_for 'member' %>
<%= render :partial => @render_file, :locals => {:members => @members} %>
</div>
</div>

@ -0,0 +1,11 @@
class CreateCourseGroups < ActiveRecord::Migration
def change
create_table :course_groups do |t|
t.string :name
t.integer :course_id
t.timestamps
end
end
end

@ -0,0 +1,5 @@
class AddColumnToMembers < ActiveRecord::Migration
def change
add_column :members, :course_group_id, :integer, default: 0
end
end

@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20141120091234) do
ActiveRecord::Schema.define(:version => 20141126091750) do
create_table "activities", :force => true do |t|
t.integer "act_id", :null => false
@ -313,6 +313,13 @@ ActiveRecord::Schema.define(:version => 20141120091234) do
t.integer "container_id", :default => 0
end
create_table "course_groups", :force => true do |t|
t.string "name"
t.integer "course_id"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
create_table "course_infos", :force => true do |t|
t.integer "course_id"
t.integer "user_id"
@ -651,6 +658,7 @@ ActiveRecord::Schema.define(:version => 20141120091234) do
t.datetime "created_on"
t.boolean "mail_notification", :default => false, :null => false
t.integer "course_id", :default => -1
t.integer "course_group_id", :default => 0
end
add_index "members", ["project_id"], :name => "index_members_on_project_id"

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 958 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 629 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 217 B

File diff suppressed because it is too large Load Diff

@ -0,0 +1,67 @@
body{ font-size:12px; font-family:"微软雅黑","宋体"; line-height:1.9; background:#fff; font-style:normal;}
div,html,img,ul,li,p,body,h1,h2,h3,h4,p,a,table,tr,td,fieldset,input,span,textarea,form{ margin:0; padding:0;}
div,img,tr,td,textarea,form{ border:0;}
table,tr,td{border:0; cellspacing:0; cellpadding:0;}
ul,li{ list-style-type:none}
.cl{ clear:both; overflow:hidden; }
a{ text-decoration:none; }
a:hover{ }
/**** 常用***/
.f_l{ float:left;}
.f_r{ float:right;}
.b_lblue{ background:#64bdd9;}
.b_dblue{ background:#55a1b9; cursor:pointer;}
.f_b{ font-weight: bold;}
.c_blue{ color:#64bdd9;}
.c_grey{ color:#999999;}
.c_grey02{ color:#666666;}
.f_14{ font-size:14px;}
.c_dblue{ color:#3e6d8e;}
.c_red{ color:#ec0016;}
.w90{width:90px;}
.ml10{margin-left:10px;}
.container{ width:940px; margin:0 auto; font-size:12px;}
.st_list{ width:688px; padding-left:5px; height:800px;}
.st_search{ margin:10px 0;}
.st_search span{ font-size:14px; font-weight:bold; color:#606060; margin-right:35px;}
.st_search input{ border:1px solid #1c9ec7; background:#fff; height:20px; color:#c4c4c4; width:200px;}
.st_search input.f_2{ background:#1c9ec7; padding: 3px; margin-left: 3px; color:#fff;border:1px solid #1c9ec7; text-align:center; display:block; width:45px; height:28px; float:left; font-size:12px; }
.st_search a:hover{ background:#048fbb; text-decoration:none;}
.classbox{ border:1px solid #f8df8c; background:#fffce6; color:#0d90c3; padding:0 3px; float:left; margin-left:15px;}
.st_addclass{ margin-top:5px;}
.st_addclass ul li{ margin-bottom:10px;}
.st_addclass ul li,.st_addclass a,.st_addclass img{ float:left;}
.st_addclass img{ margin-top:3px;}
.st_addclass a{ color:#0d90c3;}
.st_box{ margin-top:10px; border-top:1px solid #CCC; padding-top:10px;}
.st_box ul li{ float:left;}
.st_box_top a{ font-weight:bold; color:#7a7a7a; float:left;}
.st_box_top a:hover{ color:#1c9ec7;}
a.st_up{ display: block; width:8px; float:left; height:13px; background:url(images/pic_up.png) 0 0 no-repeat; margin-top:5px; margin-left:3px;}
a.st_down{ display: block; width:8px; float:left; height:13px; background:url(images/pic_up.png) 0 -22px no-repeat; margin-top:5px; margin-left:3px;}
a.st_img { display:block;width:40px; height:40px; border:1px solid #CCC; padding:1px;}
a:hover.st_img { border:1px solid #1c9ec7; }
.st_boxlist{ border-bottom:1px dashed #CCC; height:53px; padding-top:10px; }
.st_boxlist a{ float:left;}
.st_boxlist ul{ float:left; width:200px; margin-left:10px;}
.st_boxlist ul li a{ color:#5d5d5d;}
.st_boxlist ul li a span{ color:#1c9ec7;}
.st_boxlist ul li a:hover span{ color:#ff8e15;}
.ml50{ margin-left:50px;}
.ml358{ margin-left:358px;}
.ml258{ margin-left:254px;}
.ml65{ margin-left:65px;}
a:hover.st_add{ color:#ff8e15;}
/****翻页***/
.wlist{ margin-top:15px; float:right;}
.wlist a{ float:left; border:1px solid #15bccf; padding:0 5px; margin-left:3px; color:#15bccf;}
.wlist a:hover{border:1px solid #15bccf; background-color:#15bccf; color:#fff;}
.wlist_select a { background-color:#64bdd9; color:#fff;}
.submit{height:21px;border:0; cursor:pointer; background:url(images/btn.png) no-repeat 0 0;width:42px; margin-top:2px; margin-left:3px; }
.isTxt{background:#fbfbfb url(images/inputBg.png) repeat-x left top;height:22px;line-height:22px;border:1px solid #c1c1c1;padding:0 5px;color:#666666;}

@ -0,0 +1,11 @@
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
# This model initially had no columns defined. If you add columns to the
# model remove the '{}' from the fixture names and add the columns immediately
# below each fixture, per the syntax in the comments below
#
one: {}
# column: value
#
two: {}
# column: value

@ -0,0 +1,7 @@
require 'test_helper'
class CourseGroupTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
end
Loading…
Cancel
Save