@ -67,12 +67,12 @@ class CollegesController < ApplicationController
user_extensions.`school_id`=#{@school.id}) and work_status between 1 and 2 and myshixun_id !=0").first.try(:sw_count)
@teachers=User.find_by_sql("SELECT users.id, users.login, users.lastname, users.firstname, users.nickname, IFNULL((SELECT count(shixuns.id) FROM shixuns where shixuns.user_id =users.id group by shixuns.user_id), 0) AS publish_shixun_count,
(SELECTcount(c.id)FROMcoursesc,members m,member_rolesmrWHEREc.id!=1309andm.course_id=c.idANDm.id=mr.member_idANDmr.role_idin(3,7,9)andc.school_id=#{@school.id} AND m.user_id=users.id AND c.is_delete = 0) as course_count
(SELECTcount(c.id)FROMcoursesc,course_members mWHEREc.id!=1309andm.course_id=c.idANDm.role in(1,2,3)andc.school_id=#{@school.id} AND m.user_id=users.id AND c.is_delete = 0) as course_count
FROM`users`,user_extensionsuewhereusers.id=ue.user_idandue.identity=0andue.school_id=#{@school.id} ORDER BY publish_shixun_count desc, course_count desc, id desc LIMIT 10")
course_ids=Course.find_by_sql("SELECT c.id FROM courses c, members m, member_roles mr WHERE c.id != 1309 and m.course_id = c.id AND m.id=mr.member_id AND mr.role_id in (3,7,9) AND m.user_id=#{teacher.id} AND c.is_delete = 0 and c.school_id = #{@school.id}")
course_ids=Course.find_by_sql("SELECT c.id FROM courses c, course_members m WHERE c.id != 1309 and m.course_id = c.id AND m.role in (1,2,3) AND m.user_id=#{teacher.id} AND c.is_delete = 0 and c.school_id = #{@school.id}")
@courses=Course.where("courses.is_delete = 0 and courses.is_hidden = 0 #{course_ids==-1?"":"and courses.id in (#{course_ids})"}").select("courses.id, courses.tea_id, courses.name, courses.is_public, courses.members_count, courses.homework_commons_count,(SELECT MAX(created_at) FROM `course_activities` WHERE course_activities.course_id = courses.id) AS a").order("courses.id = 1309 desc, a desc")
elsif@order=="mine"
my_course_ids=Course.find_by_sql("SELECT c.id FROM courses c, members m, member_roles mr WHERE m.course_id = c.id AND m.id=mr.member_id AND mr.role_id in (3,7,9,10) AND m.user_id=#{@user.id} AND c.is_delete = 0")
my_course_ids=Course.find_by_sql("SELECT c.id FROM courses c, course_members m WHERE m.course_id = c.id AND m.role in (1,2,3,4) AND m.user_id=#{@user.id} AND c.is_delete = 0")
@courses=Course.find_by_sql("select c.id, c.tea_id, c.name, c.is_public, c.members_count, c.homework_commons_count, u.login, u.nickname, u.lastname, u.firstname, u.show_realname, ue.school_id from courses c, users u, user_extensions ue where c.tea_id = u.id and u.id = ue.user_id and c.is_delete = 0 and c.is_hidden = 0 and c.id in (#{course_ids}) order by c.id = 1309 desc, #{order_str} desc")
@ -894,7 +894,7 @@ class CoursesController < ApplicationController
@ -2438,14 +2438,14 @@ class UsersController < ApplicationController
case@type
when"a_course"
student_course_ids=Course.find_by_sql("SELECT c.id FROM courses c, students_for_courses sfc WHERE sfc.course_id = c.id AND sfc.student_id=#{@user.id} AND c.is_delete = 0 AND c.is_end in #{status}")
manage_course_ids=Course.find_by_sql("SELECT c.id FROM courses c, members m, member_roles mr WHERE m.course_id = c.id AND m.id=mr.member_id AND mr.role_id in (3,7,9) AND m.user_id=#{@user.id} AND c.is_delete = 0 AND c.is_end in #{status}")
manage_course_ids=Course.find_by_sql("SELECT c.id FROM courses c, course_members m WHERE m.course_id = c.id AND m.role in (1,2,3) AND m.user_id=#{@user.id} AND c.is_delete = 0 AND c.is_end in #{status}")
student_course_ids=Course.find_by_sql("SELECT c.id FROM courses c, students_for_courses sfc WHERE sfc.course_id = c.id AND sfc.student_id=#{@user.id} AND c.is_delete = 0 AND c.is_end in #{status}")
student_course_ids=Course.find_by_sql("SELECT c.id FROM courses c, course_members m WHERE m.course_id = c.id and m.role = 4 AND m.user_id=#{@user.id} AND c.is_delete = 0 AND c.is_end in #{status}")
course_ids=Course.find_by_sql("SELECT c.id FROM courses c, members m, member_roles mr WHERE m.course_id = c.id AND m.id=mr.member_id AND mr.role_id in (3,7,9) AND m.user_id=#{@user.id} AND c.is_delete = 0 AND c.is_end in #{status}")
course_ids=Course.find_by_sql("SELECT c.id FROM courses c, course_members m WHERE m.course_id = c.id AND m.role in (1,2,3) AND m.user_id=#{@user.id} AND c.is_delete = 0 AND c.is_end in #{status}")
@ -33,6 +33,8 @@ class Course < ActiveRecord::Base
belongs_to:syllabus
belongs_to:course_list
# has_many :bid
has_many:course_members,dependent::destroy
has_many:members,:include=>[:principal,:roles],:conditions=>"#{Principal.table_name}.type='User' AND #{Principal.table_name}.status=#{Principal::STATUS_ACTIVE}"
has_many:memberships,:class_name=>'Member'
has_many:member_principals,:class_name=>'Member',
@ -290,12 +292,16 @@ class Course < ActiveRecord::Base
<div class="openSource_2" style="background: url('<%= named_attachment_path(@images[index], @images[index].try(:filename)) %>') no-repeat top center;"></div>
<% index += 1 %>
<% @competition.competition_stages.each_with_index do |stage, i| %>
<div class="openSource_<%= index + 1 %>" style="background: url('<%= named_attachment_path(@images[index], @images[index].try(:filename)) %>') no-repeat top center;">
<div class="openSource_3" style="background: url('<%= named_attachment_path(@images[index], @images[index].try(:filename)) %>') no-repeat top center;">
<div class="openSource_4" style="background: url('<%= named_attachment_path(@images[index], @images[index].try(:filename)) %>') no-repeat top center;">
<div class="openSource_5" style="background: url('<%= named_attachment_path(@images[index], @images[index].try(:filename)) %>') no-repeat top center;"></div>
<% index += 1 %>
<div class="openSource_6" style="background: url('<%= named_attachment_path(@images[index], @images[index].try(:filename)) %>') no-repeat top center;"></div>
<% index += 1 %>
<div class="openSource_7" style="background: url('<%= named_attachment_path(@images[index], @images[index].try(:filename)) %>') no-repeat top center;"></div>
<% index += 1 %>
<div class="openSource_7" style="background: url('<%= named_attachment_path(@images[index], @images[index].try(:filename)) %>') no-repeat top center;"></div>
<script>
$(function(){
var userLogged = <%= @user.present? && @user.logged? %>;