parent
cf83209c58
commit
479b23a1fd
|
@ -300,6 +300,7 @@ class CoursesService
|
|||
#@state == 4 您加入的课程不存在
|
||||
#@state == 5 您还未登录
|
||||
#@state == 6 申请成功,请等待审核完毕
|
||||
#@state == 7 您已经发送过申请了,请耐心等待
|
||||
#@state 其他 未知错误,请稍后再试
|
||||
def join_course params,current_user
|
||||
course = Course.find_by_id params[:object_id]
|
||||
|
@ -313,6 +314,8 @@ class CoursesService
|
|||
#如果加入角色为学生
|
||||
if params[:role] == "10"
|
||||
@state = 3
|
||||
elsif current_user.allowed_to?(:as_teacher,course)
|
||||
@state = 3
|
||||
else
|
||||
#如果加入角色为教师或者教辅
|
||||
CourseMessage.create(:user_id => course.tea_id, :course_id => course.id, :viewed => false,:content=> params[:role],:course_message_id=>User.current.id,:course_message_type=>'JoinCourseRequest',:status=>0)
|
||||
|
@ -329,10 +332,15 @@ class CoursesService
|
|||
course.members << members
|
||||
StudentsForCourse.create(:student_id => current_user.id, :course_id => params[:object_id])
|
||||
@state = 0
|
||||
else
|
||||
#如果已经发送过消息了,那么就要给个提示
|
||||
if CourseMessage.where("course_message_type = 'JoinCourseRequest' and user_id = #{course.tea_id} and content = #{params[:role]} and course_message_id = #{User.current.id} and course_id = #{course.id} and status = 0").count != 0
|
||||
@state = 7
|
||||
else
|
||||
CourseMessage.create(:user_id => course.tea_id, :course_id => course.id, :viewed => false,:content=> params[:role],:course_message_id=>User.current.id,:course_message_type=>'JoinCourseRequest',:status=>0)
|
||||
@state = 6
|
||||
end
|
||||
end
|
||||
else
|
||||
@state = 1
|
||||
end
|
||||
|
|
|
@ -5,21 +5,25 @@ $("#join_in_course_header").html("<%= escape_javascript(join_in_course_header(@c
|
|||
<% if @state == 0 %>
|
||||
alert("加入成功");
|
||||
hideModal($("#popbox02"));
|
||||
$("#try_join_course_link").replaceWith("<a href='<%=url_for(:controller => 'homework_common', :action => 'index',:course=>course.id, :host=>Setting.host_course)%>' target='_blank' class='blue_n_btn fr mt20'>提交作品</a>");
|
||||
window.location.href= "http://"+"<%= Setting.host_name%>"+"/courses/" + "<%= course.id%>"
|
||||
$("#try_join_course_link").replaceWith("<a href='<%=url_for(:controller => 'homework_common', :action => 'index',:course=>@course.id, :host=>Setting.host_course)%>' target='_blank' class='blue_n_btn fr mt20'>提交作品</a>");
|
||||
window.location.href= "http://"+"<%= Setting.host_name%>"+"/courses/" + "<%= @course.id%>"
|
||||
<% elsif @state == 1 %>
|
||||
alert("密码错误");
|
||||
<% elsif @state == 2 %>
|
||||
alert("课程已过期\n请联系课程管理员重启课程。(在配置课程处)");
|
||||
<% elsif @state == 3 %>
|
||||
alert("您已经加入了课程");
|
||||
window.location.href= "http://"+"<%= Setting.host_name%>"+"/courses/" + "<%= course.id%>"
|
||||
window.location.href= "http://"+"<%= Setting.host_name%>"+"/courses/" + "<%= @course.id%>"
|
||||
<% elsif @state == 4 %>
|
||||
alert("您加入的课程不存在");
|
||||
<% elsif @state == 5 %>
|
||||
alert("您还未登录");
|
||||
<% elsif @state == 6 %>
|
||||
alert("申请成功,请等待审核")
|
||||
hideModal($("#popbox02"));
|
||||
<% elsif @state == 7%>
|
||||
alert("您已经发送过申请了,请耐心等待")
|
||||
hideModal($("#popbox02"));
|
||||
<% else %>
|
||||
alert("未知错误,请稍后再试");
|
||||
<% end %>
|
||||
|
|
Loading…
Reference in New Issue