Merge branch 'develop' into experiment

This commit is contained in:
Wen 2014-03-19 17:14:06 +08:00
commit 3c0f41a64c
1 changed files with 16 additions and 9 deletions

View File

@ -7,20 +7,16 @@ class CoursesController < ApplicationController
def join
if User.current.logged?
course = Project.find(params[:object_id])
if ( !course_endTime_timeout?(course) )
course_prefs = Course.find_by_extra(course.identifier)
if params[:course_password] == course_prefs.password
course_prefs = Course.find_by_extra(course.identifier)
if params[:course_password] == course_prefs.password
members = []
members << Member.new(:role_ids => [10], :user_id => User.current.id)
course.members << members
StudentsForCourse.create(:student_id => User.current.id, :course_id => params[:object_id])
@state = 0
else
@state = 1
end
else
@state = 2
@state = 1
end
end
respond_to do |format|
@ -49,7 +45,18 @@ class CoursesController < ApplicationController
private
def allow_join
course_endTime_timeout? Project.find(params[:object_id])
if course_endTime_timeout? Project.find(params[:object_id])
respond_to do |format|
format.js{
@state = 2
render :partial => 'set_join',
:locals => {:user => User.current,
:course => Project.find(params[:object_id]),
:object_id => params[:object_id]
}
}
end
end
end
end