diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index 2e8aebce5..43b488e96 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -74,7 +74,7 @@ class CoursesController < ApplicationController else @state = 5 #未登录 end - @object_id = params[:object_id] + @object_id = @course.id if @course respond_to do |format| format.js #{ render :partial => 'set_join', :locals => {:user => @user, :course => @course, :object_id => params[:object_id]} } end @@ -1305,12 +1305,12 @@ class CoursesController < ApplicationController sheet[count_row,7] = stu.teaching_asistant_score.nil? ? l(:label_without_score) : stu.teaching_asistant_score.round(2) if home.anonymous_comment ==0 sheet[count_row,8] = stu.student_score.nil? ? l(:label_without_score) : stu.student_score.round(2) - sheet[count_row,9] = stu.absence_penalty - sheet[count_row,10] = stu.late_penalty + sheet[count_row,9] = home.teacher_priority == 1 ? 0 : stu.absence_penalty + sheet[count_row,10] = home.teacher_priority == 1 ? 0 : stu.late_penalty sheet[count_row,11] = stu.work_score.nil? ? l(:label_without_score) : stu.work_score.round(2) sheet[count_row,12] = format_time(stu.created_at) else - sheet[count_row,8] = stu.late_penalty + sheet[count_row,8] = home.teacher_priority == 1 ? 0 : stu.late_penalty sheet[count_row,9] = stu.work_score.nil? ? l(:label_without_score) : stu.work_score.round(2) sheet[count_row,10] = format_time(stu.created_at) end @@ -1338,12 +1338,12 @@ class CoursesController < ApplicationController sheet[count_row,8] = stu.system_score.nil? ? l(:label_without_score) : stu.system_score.round(2) if home.anonymous_comment ==0 sheet[count_row,9] = stu.student_score.nil? ? l(:label_without_score) : stu.student_score.round(2) - sheet[count_row,10] = stu.absence_penalty - sheet[count_row,11] = stu.late_penalty + sheet[count_row,10] = home.teacher_priority == 1 ? 0 : stu.absence_penalty + sheet[count_row,11] = home.teacher_priority == 1 ? 0 : stu.late_penalty sheet[count_row,12] = stu.work_score.nil? ? l(:label_without_score) : stu.work_score.round(2) sheet[count_row,13] = format_time(stu.created_at) else - sheet[count_row,9] = stu.late_penalty + sheet[count_row,9] = home.teacher_priority == 1 ? 0 : stu.late_penalty sheet[count_row,10] = stu.work_score.nil? ? l(:label_without_score) : stu.work_score.round(2) sheet[count_row,11] = format_time(stu.created_at) end @@ -1369,12 +1369,12 @@ class CoursesController < ApplicationController sheet[count_row,6] = stu.teaching_asistant_score.nil? ? l(:label_without_score) : stu.teaching_asistant_score.round(2) if home.anonymous_comment ==0 sheet[count_row,7] = stu.student_score.nil? ? l(:label_without_score) : stu.student_score.round(2) - sheet[count_row,8] = stu.absence_penalty - sheet[count_row,9] = stu.late_penalty + sheet[count_row,8] = home.teacher_priority == 1 ? 0 : stu.absence_penalty + sheet[count_row,9] = home.teacher_priority == 1 ? 0 : stu.late_penalty sheet[count_row,10] = stu.work_score.nil? ? l(:label_without_score) : stu.work_score.round(2) sheet[count_row,11] = format_time(stu.created_at) else - sheet[count_row,7] = stu.late_penalty + sheet[count_row,7] = home.teacher_priority == 1 ? 0 : stu.late_penalty sheet[count_row,8] = stu.work_score.nil? ? l(:label_without_score) : stu.work_score.round(2) sheet[count_row,9] = format_time(stu.created_at) end diff --git a/app/controllers/student_work_controller.rb b/app/controllers/student_work_controller.rb index b92dbb935..3a72ba55e 100644 --- a/app/controllers/student_work_controller.rb +++ b/app/controllers/student_work_controller.rb @@ -1230,12 +1230,12 @@ class StudentWorkController < ApplicationController sheet1[count_row,8] = homework.teaching_asistant_score.nil? ? l(:label_without_score) : homework.teaching_asistant_score.round(2) if @homework.anonymous_comment ==0 sheet1[count_row,9] = homework.student_score.nil? ? l(:label_without_score) : homework.student_score.round(2) - sheet1[count_row,10] = homework.absence_penalty - sheet1[count_row,11] = homework.late_penalty + sheet1[count_row,10] = @homework.teacher_priority == 1 ? 0 : homework.absence_penalty + sheet1[count_row,11] = @homework.teacher_priority == 1 ? 0 : homework.late_penalty sheet1[count_row,12] = homework.respond_to?("score") ? homework.score.nil? ? l(:label_without_score) : homework.score.round(2) : l(:label_without_score) sheet1[count_row,13] = format_time(homework.created_at) else - sheet1[count_row,9] = homework.late_penalty + sheet1[count_row,9] = @homework.teacher_priority == 1 ? 0 : homework.late_penalty sheet1[count_row,10] = homework.respond_to?("score") ? homework.score.nil? ? l(:label_without_score) : homework.score.round(2) : l(:label_without_score) sheet1[count_row,11] = format_time(homework.created_at) end @@ -1263,12 +1263,12 @@ class StudentWorkController < ApplicationController sheet1[count_row,9] = homework.system_score.nil? ? l(:label_without_score) : homework.system_score.round(2) if @homework.anonymous_comment ==0 sheet1[count_row,10] = homework.student_score.nil? ? l(:label_without_score) : homework.student_score.round(2) - sheet1[count_row,11] = homework.absence_penalty - sheet1[count_row,12] = homework.late_penalty + sheet1[count_row,11] = @homework.teacher_priority == 1 ? 0 : homework.absence_penalty + sheet1[count_row,12] = @homework.teacher_priority == 1 ? 0 : homework.late_penalty sheet1[count_row,13] = homework.respond_to?("score") ? homework.score.nil? ? l(:label_without_score) : homework.score.round(2) : l(:label_without_score) sheet1[count_row,14] = format_time(homework.created_at) else - sheet1[count_row,10] = homework.late_penalty + sheet1[count_row,10] = @homework.teacher_priority == 1 ? 0 : homework.late_penalty sheet1[count_row,11] = homework.respond_to?("score") ? homework.score.nil? ? l(:label_without_score) : homework.score.round(2) : l(:label_without_score) sheet1[count_row,12] = format_time(homework.created_at) end @@ -1292,12 +1292,12 @@ class StudentWorkController < ApplicationController sheet1[count_row,5] = homework.teaching_asistant_score.nil? ? l(:label_without_score) : homework.teaching_asistant_score.round(2) if @homework.anonymous_comment ==0 sheet1[count_row,6] = homework.student_score.nil? ? l(:label_without_score) : homework.student_score.round(2) - sheet1[count_row,7] = homework.absence_penalty - sheet1[count_row,8] = homework.late_penalty + sheet1[count_row,7] = @homework.teacher_priority == 1 ? 0 : homework.absence_penalty + sheet1[count_row,8] = @homework.teacher_priority == 1 ? 0 : homework.late_penalty sheet1[count_row,9] = homework.respond_to?("score") ? homework.score.nil? ? l(:label_without_score) : homework.score.round(2) : l(:label_without_score) sheet1[count_row,10] = format_time(homework.created_at) else - sheet1[count_row,6] = homework.late_penalty + sheet1[count_row,6] = @homework.teacher_priority == 1 ? 0 : homework.late_penalty sheet1[count_row,7] = homework.respond_to?("score") ? homework.score.nil? ? l(:label_without_score) : homework.score.round(2) : l(:label_without_score) sheet1[count_row,8] = format_time(homework.created_at) end diff --git a/app/models/course.rb b/app/models/course.rb index 5186a4754..195e7cf9f 100644 --- a/app/models/course.rb +++ b/app/models/course.rb @@ -67,7 +67,7 @@ class Course < ActiveRecord::Base acts_as_attachable :view_permission => :view_course_files, :delete_permission => :manage_files - validates_presence_of :password, :term,:name + validates_presence_of :term,:name validates_format_of :class_period, :with =>/^[1-9]\d*$/ validates_format_of :name,:with =>/^[^ ]+[a-zA-Z0-9_\u4e00-\u9fa5\s\S]+$/ validates_length_of :description, :maximum => 10000 diff --git a/app/services/courses_service.rb b/app/services/courses_service.rb index bdd6564ae..60c053997 100644 --- a/app/services/courses_service.rb +++ b/app/services/courses_service.rb @@ -199,7 +199,7 @@ class CoursesService @course.extra = 'course' + DateTime.parse(Time.now.to_s).strftime('%Y-%m-%d_%H-%M-%S').to_s @course.send(:safe_attributes=, params[:course], current_user) #@course.safe_attributes(current_user,params[:course]) - @course.password = params[:course][:password] + #@course.password = params[:course][:password] @course.tea_id = current_user.id @course.term = params[:term] @course.time = params[:time] @@ -258,7 +258,7 @@ class CoursesService def edit_course(params,course,current_user) course.send(:safe_attributes=, params[:course], current_user) #course.safe_attributes = params[:course] - course.password = params[:course][:password] + #course.password = params[:course][:password] course.time = params[:time] course.term = params[:term] course.end_time = params[:end_time] @@ -326,11 +326,7 @@ class CoursesService #object_id:课程id #course_password :加入课程的密码 def join_course params,current_user - course = if params[:invite_code] - Course.find_by_invite_code(params[:invite_code]) - else - Course.find_by_id params[:object_id] - end + course = Course.find_by_invite_code(params[:invite_code]) if params[:invite_code] @state = 10 if course @@ -340,7 +336,7 @@ class CoursesService if current_user.member_of_course?(course) #如果已经是成员 member = course.members.where("user_id=#{current_user.id} and course_id=#{course.id}")[0] roleName = member.roles[0].name if member - if params[:course_password] == course.password || params[:invite_code].present? + if params[:invite_code].present? #如果加入角色为学生 并且当前是学生 if params[:role] == "10" && roleName == "Student" @state = 3 @@ -366,19 +362,19 @@ class CoursesService elsif params[:role] == "10" && roleName != "Student" member.role_ids = [params[:role]] member.save - StudentsForCourse.create(:student_id => current_user.id, :course_id => params[:object_id]) + StudentsForCourse.create(:student_id => current_user.id, :course_id => course.id) @state = 0 end else @state = 1 end else - if params[:course_password] == course.password || params[:invite_code].present? + if params[:invite_code].present? if params[:role] == "10" || params[:role] == nil members = [] members << Member.new(:role_ids => [10], :user_id => current_user.id) course.members << members - StudentsForCourse.create(:student_id => current_user.id, :course_id => params[:object_id]) + StudentsForCourse.create(:student_id => current_user.id, :course_id => course.id) @state = 0 else #如果已经发送过消息了,那么就要给个提示 diff --git a/app/views/courses/_copy_course.html.erb b/app/views/courses/_copy_course.html.erb index 3b6d55d96..dbe03d67f 100644 --- a/app/views/courses/_copy_course.html.erb +++ b/app/views/courses/_copy_course.html.erb @@ -1,6 +1,6 @@