diff --git a/Gemfile b/Gemfile index 12729f741..867c0fb75 100644 --- a/Gemfile +++ b/Gemfile @@ -1,5 +1,5 @@ -# source 'http://ruby.taobao.org' -source 'http://ruby.sdutlinux.org/' +source 'http://ruby.taobao.org' +#source 'http://ruby.sdutlinux.org/' unless RUBY_PLATFORM =~ /w32/ # unix-like only @@ -30,6 +30,7 @@ group :test do gem 'factory_girl', '~> 4.4.0' gem 'selenium-webdriver', '~> 2.42.0' + platforms :mri, :mingw do group :rmagick do # RMagick 2 supports ruby 1.9 @@ -48,6 +49,7 @@ group :development, :test do gem 'ruby-prof', '~> 0.15.1' unless RUBY_PLATFORM =~ /w32/ gem 'pry' gem 'pry-nav' + end diff --git a/Gemfile.lock b/Gemfile.lock index 00702d7c3..34314d845 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -19,7 +19,7 @@ PATH rails GEM - remote: http://ruby.sdutlinux.org/ + remote: http://ruby.taobao.org/ remote: https://rubygems.org/ specs: actionmailer (3.2.13) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 0b4309ef5..3ab894c69 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -258,11 +258,13 @@ class ApplicationController < ActionController::Base if @attachment.container_type == "Memo" allowed = User.current.allowed_to?(:memos_attachments_download,nil,:global => true) elsif @attachment.container_type == "Project" - + return true elsif @attachment.container_type == "course" - + return true elsif @attachment.container_type == "contest" - + return true + else + return true end if allowed diff --git a/app/controllers/attachments_controller.rb b/app/controllers/attachments_controller.rb index 7ce9646c6..215df8e10 100644 --- a/app/controllers/attachments_controller.rb +++ b/app/controllers/attachments_controller.rb @@ -193,12 +193,14 @@ class AttachmentsController < ApplicationController else format.html { redirect_to_referer_or course_path(@course) } end + elsif !@attachment.container.nil? && @attachment.container.is_a?(Softapplication) + format.html { redirect_to_referer_or softapplications_path(@attachment.container) } else - if @project.nil? - format.html { redirect_to_referer_or forum_memo_path(@attachment.container.forum, @attachment.container) } - else + if @project.nil? + format.html { redirect_to_referer_or forum_memo_path(@attachment.container.forum, @attachment.container) } + else format.html { redirect_to_referer_or project_path(@project) } - end + end end format.js diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index c73a1e0fc..9ae57db3d 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -641,7 +641,7 @@ class CoursesController < ApplicationController def isCourseTeacher(id,course) result = false user = User.find(id) - if user.nil? && user.allowed_to?(:as_teacher,course)#@teachers && @teachers.count != 0 && @teachers.find_by_user_id(id) != nil + if !user.nil? && user.allowed_to?(:as_teacher,course) result = true end result diff --git a/app/helpers/courses_helper.rb b/app/helpers/courses_helper.rb index 969fbceae..3a8b1b09a 100644 --- a/app/helpers/courses_helper.rb +++ b/app/helpers/courses_helper.rb @@ -1,524 +1,524 @@ -# encoding: utf-8 -## This helper be included in applicationHelper -module CoursesHelper -=begin -1. define TeacherRoles, StudentRoles -2. define count function -3. define search by roles -4. define search member function -=end - #TeacherRoles = [3, 4, 7, 9] - #StudentRoles = [5, 10] - #AllPeople = StudentRoles+TeacherRoles - ## return people count - - # 返回x项目成员数量,即roles表中定义的所有成员 - def projectCount project - #searchCountByRoles project, AllPeople - project.members.count - end - - # 返回教师数量,即roles表中定义的Manager - def teacherCount project - searchTeacherAndAssistant(project).count - # or - # searchTeacherAndAssistant(project).count - end - - # 返回学生数量,即roles表中定义的Reporter - #def studentCount project - # searchStudent(project).count - # or - # searchStudent(project).count - # end - - # 判断用户是否是课程的管理员 - # add by nwb - def is_course_manager?(user_id,course_id) - @result = false - @user_id = CourseInfo.find_by_course_id(course_id) - if @user_id == user.id - @result = true - end - return @result - end - - # 返回课程设置界面 - def course_settings_tabs - tabs = [{:name => 'info', :action => :edit_course, :partial => 'courses/edit', :label => :label_information_plural}, - {:name => 'members', :action => :manage_members, :partial => 'courses/settings/members', :label => :label_member_plural} - ] - tabs.select { |tab| User.current.allowed_to?(tab[:action], @course) } - - end - - #是否启动互评下拉框 - def is_evaluation_option - type = [] - option1 = [] - option2 = [] - option1 << l(:lable_start_mutual_evaluation) - option1 << 1 - option2 << l(:lable_close_mutual_evaluation) - option2 << 2 - type << option1 - type << option2 - end - - # garble count 混淆数量 - # alias projectCountOrigin projectCount - # def projectCount project - # count = projectCountOrigin project - # garble count - # end - - def homework_type_option - type = [] - option1 = [] - option2 = [] - option1 << l(:label_task_submit_form_accessory) - option1 << 1 - option2 << l(:label_task_submit_form_project) - option2 << 2 - type << option1 - type << option2 - end - - def proportion_option - type = [] - i = 0 - while i <= 100 - option = [] - option << i.to_s + "%" - option << i - type << option - i = i + 10 - end - type - end - - - #alias teacherCountOrigin teacherCount - #def teacherCount project - # count = teacherCountOrigin project - # garble count - #end - - # 注意:此方法有问题,速度慢且结果不准 - # alias studentCountOrigin studentCount - #def studentCount course - # count = studentCountOrigin course - #garble count - # end - - # 学生人数计算 - # add by nwb - def studentCount course - count = searchStudent(course).count#course.student.count - if count <= 5 - result = count.to_s - elsif count < 10 && count > 5 - result = "5+" - else - result = (count-count % 10).to_s + "+" - end - result - end - - #课程成员数计算 - def memberCount course - count = searchStudent(course).count + searchTeacherAndAssistant(course).count - if count <= 5 - result = count.to_s - elsif count < 10 && count > 5 - result = "5+" - else - result = (count-count % 10).to_s + "+" - end - result - end - - def eventToLanguageCourse event_type, course - case event_type - when "issue-note" - l :label_issue - when "issue" - l :label_issue - when "attachment" - l :label_attachment - when "news" - l :label_notification - else - "" - end - end - - def garble count - count = count.round( 1-count.to_s.size ).to_i - return count.to_s if count.to_s.size.eql?(1) - count.to_s << '+' - end - - # ===================================================================================== - # return people list - def searchTeacherAndAssistant project - #searchPeopleByRoles(project, TeacherRoles) - members = [] - project.members.each do |m| - members << m if m && m.user && m.user.allowed_to?(:as_teacher,project) - 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 - # members = searchPeopleByRoles project, roles_id - # members.count - #end - - #def searchPeopleByRoles project, roles_id - # members = [] - # begin - # members = project.members.joins(:member_roles).where("member_roles.role_id IN (:role_id)", {:role_id => roles_id}) - # rescue Exception => e - # logger.error "[CoursesHelper] ===> #{e}" - # end - # members - #end - - def sort_courses(state) - content = ''.html_safe - case state - when 0 - - content << content_tag('li', link_to(l(:label_sort_by_active), courses_path(:courses_sort_type => '1'))) - content << content_tag('li', link_to(l(:label_sort_by_influence), courses_path(:courses_sort_type => '2'))) - content << content_tag('li', link_to(l(:label_sort_by_time), courses_path(:courses_sort_type => '0'), :class=>"selected"), :class=>"selected") - when 1 - - content << content_tag('li', link_to(l(:label_sort_by_active), courses_path(:courses_sort_type => '1'), :class=>"selected"), :class=>"selected") - content << content_tag('li', link_to(l(:label_sort_by_influence), courses_path(:courses_sort_type => '2'))) - content << content_tag('li', link_to(l(:label_sort_by_time), courses_path(:courses_sort_type => '0'))) - when 2 - content << content_tag('li', link_to(l(:label_sort_by_active), courses_path(:courses_sort_type => '1'))) - content << content_tag('li', link_to(l(:label_sort_by_influence), courses_path(:courses_sort_type => '2'), :class=>"selected"), :class=>"selected") - content << content_tag('li', link_to(l(:label_sort_by_time), courses_path(:courses_sort_type => '0'))) - end - content = content_tag('ul', content) - content_tag('div', content, :class => "tabs") - end - - def render_course_hierarchy(courses) - render_course_nested_lists(courses) do |course| - s = link_to_course(course, {}, :class => "#{course.css_classes} #{User.current.member_of?(course) ? 'my-course' : nil}").html_safe - s - end - end - - #useless - #def searchMembersByRole project, role_id - # members = [] - # begin - # members = project.members.joins(:member_roles).where("member_roles.role_id = :role_id", {:role_id => role_id }) - # rescue Exception => e - # logger.error "[CoursesHelper] ===> #{e}" - # end - # members - #end - - def sort_course(state, school_id) - content = ''.html_safe - case state - when 0 - content << content_tag('li', link_to(l(:label_sort_by_time), courses_path(:course_sort_type => '0'), :school_id => school_id, :class=>"selected"), :class=>"selected") - content << content_tag('li', link_to(l(:label_sort_by_active), courses_path(:course_sort_type => '1', :school_id => school_id))) - content << content_tag('li', link_to(l(:label_sort_by_activity), courses_path(:course_sort_type => '3', :school_id => school_id))) - - when 1 - content << content_tag('li', link_to(l(:label_sort_by_time), courses_path(:course_sort_type => '0', :school_id => school_id))) - content << content_tag('li', link_to(l(:label_sort_by_active), courses_path(:course_sort_type => '1', :school_id => school_id), :class=>"selected"), :class=>"selected") - content << content_tag('li', link_to(l(:label_sort_by_activity), courses_path(:course_sort_type => '3', :school_id => school_id))) - - when 2 - content << content_tag('li', link_to(l(:label_sort_by_time), courses_path(:course_sort_type => '0', :school_id => school_id))) - content << content_tag('li', link_to(l(:label_sort_by_active), courses_path(:course_sort_type => '1', :school_id => school_id))) - content << content_tag('li', link_to(l(:label_sort_by_activity), courses_path(:course_sort_type => '3', :school_id => school_id))) - - #gcm - when 3 - content << content_tag('li', link_to(l(:label_sort_by_time), courses_path(:course_sort_type => '0', :school_id => school_id))) - content << content_tag('li', link_to(l(:label_sort_by_active), courses_path(:course_sort_type => '1', :school_id => school_id))) - content << content_tag('li', link_to(l(:label_sort_by_activity), courses_path(:course_sort_type => '3', :school_id => school_id), :class=>"selected"), :class=>"selected") - end - #gcmend - - content = content_tag('ul', content) - content_tag('div', content, :class => "tabs") - end - - def findCourseTime project - str = "" - begin - @course = Course.find_by_extra(@project.identifier) - date_format = l(:zh_date)[:formats][:default] - if @course - str = DateTime.parse(@course.setup_time.to_s).strftime("#{date_format}").to_s unless @course.setup_time.blank? - str << '-' unless @course.setup_time.blank? - str << DateTime.parse(@course.endup_time.to_s).strftime("#{date_format}").to_s unless @course.endup_time.blank? - end - rescue Exception => e - logger.error "[CoursesHelper] ===> #{e}" - end - str - end - - # added by nwb - def get_course_term course - str = ( course.try(:time).to_s << '.' << course.try(:term).to_s ) - str[0..-4] - end - - def members_to_user_ids members - people = [] - members.each { |member| - people << member.user_id - } - people - end - # 截至到2014-03-17 这个是最终的判断课程是否过期的方法 - def course_endTime_timeout? course - end_time_str = course.try(:endup_time) - begin - cTime = Time.parse(end_time_str.to_s) - rescue TypeError,ArgumentError - cTime = Time.parse("3000-01-01") - end - now = Time.now - - now > cTime - end - def find_by_extra_from_project extra - Course.find_by_extra(try(extra)) - end - #判断指定用户是不是当前课程的老师 - def is_course_teacher (user,course) - #course.members.joins(:member_roles).where("member_roles.role_id IN (:role_id) and members.user_id = #{user.id}", {:role_id => TeacherRoles}).count != 0 - user.allowed_to?(:as_teacher,course) - #修改为根据用户是否有发布任务的权限来判断用户是否是课程的老师 - #is_teacher = false - #@membership = user.memberships.all(:conditions => Project.visible_condition(User.current)) - #@membership.each do |membership| - # unless(membership.project.project_type==0) - # if user.allowed_to?({:controller => "projects", :action => "new_homework"}, membership.project, :global => false) - # is_teacher = true - # end - # end - #end - #is_teacher - end - #当前用户是不是指定课程的学生 - def is_cur_course_student course - #course.members.joins(:member_roles).where("member_roles.role_id IN (:role_id) and members.user_id = #{User.current.id}", {:role_id => StudentRoles}).count != 0 - !(User.current.allowed_to?(:as_teacher,course)) - #修改:能新建占位且不能新建任务的角色判定为学生 - #is_student = false - #@membership = User.current.memberships.all(:conditions => Project.visible_condition(User.current)) - #@membership.each do |membership| - # unless(membership.project.project_type==0) - # if !User.current.allowed_to?({:controller => "projects", :action => "new_homework"}, membership.project, :global => false) && User.current.allowed_to?({:controller => "homework_attach", :action => "new"}, membership.project, :global => false) - # is_student = true - # end - # end - #end - #is_student - end - #获取当前用户在指定作业下提交的作业的集合 - def cur_user_homework_for_bid bid - cur_user_homework = HomeworkAttach.where("user_id = ? and bid_id = ?",User.current,bid.id) - cur_user_homework - end - - #判断当前用户对指定作业是否已经评价过 - def has_evaluation? homework - seem_count = homework.rates(:quality).where("rater_id = ?",User.current).count - seem_count > 0 - end - - #获取指定作业的所有成员 - def users_for_homework homework - homework.nil? ? [] : (homework.users + [homework.user]) - end - - #获取指定作业的最终评分 - #最终评分 = 学生评分的平均分 * 0.4 +教师评分 * 0.6 - def score_for_homework homework - if homework.bid.is_evaluation == 1 || homework.bid.is_evaluation == nil - return format("%.2f",(homework.bid.proportion * 1.0 / 100) * (teacher_score_for_homework(homework).to_f) + (1 - homework.bid.proportion * 1.0 / 100) * (student_score_for_homework(homework).to_f)) - else - return teacher_score_for_homework homework - end - end - - #获取作业的互评得分 - def student_score_for_homework homework - #member = searchTeacherAndAssistant(homework.bid.courses.first).first#searchPeopleByRoles(homework.bid.courses.first,TeacherRoles).first - #if member.nil? - # return "0.00" - #end - #student_stars = homework.rates(:quality).where("rater_id <> #{member.user_id}").select("stars") - members = searchStudent(homework.bid.courses.first) - user_ids = [] - members.each do |user| - user_ids << user.user_id - end - student_stars = homework.rates(:quality).where("rater_id in (:user_ids)",{:user_ids => user_ids}).select("stars") - student_stars_count = 0 - student_stars.each do |star| - student_stars_count = student_stars_count + star.stars - end - return format("%.2f",student_stars_count / (student_stars.count == 0 ? 1 : student_stars.count)) - - - - end - - #获取作业的教师评分 - #多个教师只获取一份教师评分 - def teacher_score_for_homework homework - members = searchTeacherAndAssistant(homework.bid.courses.first)#searchPeopleByRoles(homework.bid.courses.first,TeacherRoles).first - #if member.nil? - # return "0.00" - #end - teacher_ids = [] - members.each do |user| - teacher_ids << user.user_id - end - teacher_stars = homework.rates(:quality).where("rater_id in (:teacher_ids)",{:teacher_ids => teacher_ids}).select("stars") - teacher_stars_count = 0 - teacher_stars.each do |star| - teacher_stars_count = teacher_stars_count + star.stars - end - return format("%.2f",teacher_stars_count) - end - - #获取指定项目的得分 - def project_score project - issue_count = project.issues.count - issue_journal_count = project.issue_changes.count - issue_score = issue_count * 0.2 - issue_journal_score = issue_journal_count * 0.1 - finall_issue_score = issue_score + issue_journal_score - new_count = project.news.count - new_score = new_count * 0.1 - finall_new_score = new_score - document_count = project.documents.count - file_score = document_count * 0.1 - finall_file_score = file_score - changeset_count = project.changesets.count - code_submit_score = changeset_count * 0.3 - finall_code_submit_score = code_submit_score - board_message_count = 0 - project.boards.each do |board| - board_message_count += board.messages_count - end - topic_score = board_message_count * 0.1 - #finall_topic_score = topic_score - finall_project_score = finall_issue_score + finall_new_score + finall_file_score + finall_code_submit_score + topic_score - format("%.2f",finall_project_score) - end - - #获取指定作业的参与人员 - #返回结果:张三、李四、王五 - def homework_user_of_homework homework,is_teacher - homework_users = "" - homework.users.each do |user| - homework_users = homework_users + (is_teacher ? (user.lastname + user.firstname) : user.login) - if user != homework.users.last - homework_users = homework_users + "、" - end - end - return homework_users - end - - def get_courses_by_tag(tag_name) - Course.tagged_with(tag_name).order('updated_at desc') - end - - #课程实践年份下拉框 - def course_time_option - type = [] - now_year = Time.now.year - for i in (now_year..now_year + 10) - option = [] - option << i - option << i - type << option - end - type - end - - #课程课时下拉框 - def course_term_option - type = [] - option1 = [] - option1 << l(:label_spring) - option1 << l(:label_spring) - option2 = [] - option2 << l(:label_autumn) - option2 << l(:label_autumn) - type << option1 - type << option2 - type - end - - #获取课程动态 - def get_course_activity courses, activities - @course_ids=activities.keys() - - days = Setting.activity_days_default.to_i - date_to ||= Date.today + 1 - date_from = date_to - days-1.years - - #file_count - Attachment.where(container_id: @course_ids, container_type: Course).where("created_on>?", date_from).each do |attachment| - activities[attachment.container_id]+=1 - end - - #message_count - Board.where(course_id: @course_ids).each do |board| -# activities[board.course_id]+=1 - activities[board.course_id]+=board.messages.where("updated_on>?", date_from).count - end - - #news - News.where(course_id: @course_ids).where("created_on>?",date_from).each do |news| - activities[news.course_id]+=1 - end - - #feedbackc_count - JournalsForMessage.where(jour_id: @course_ids, jour_type: Course).each do |jourformess| - activities[jourformess.jour_id]+=1 - end - - #activities!=0 - i=0; - courses.each do |course| - id=course.id - if activities[id]==0 - activities[id]=1 - end - end - - return activities - end - -end +# encoding: utf-8 +## This helper be included in applicationHelper +module CoursesHelper +=begin +1. define TeacherRoles, StudentRoles +2. define count function +3. define search by roles +4. define search member function +=end + #TeacherRoles = [3, 4, 7, 9] + #StudentRoles = [5, 10] + #AllPeople = StudentRoles+TeacherRoles + ## return people count + + # 返回x项目成员数量,即roles表中定义的所有成员 + def projectCount project + #searchCountByRoles project, AllPeople + project.members.count + end + + # 返回教师数量,即roles表中定义的Manager + def teacherCount project + searchTeacherAndAssistant(project).count + # or + # searchTeacherAndAssistant(project).count + end + + # 返回学生数量,即roles表中定义的Reporter + #def studentCount project + # searchStudent(project).count + # or + # searchStudent(project).count + # end + + # 判断用户是否是课程的管理员 + # add by nwb + def is_course_manager?(user_id,course_id) + @result = false + @user_id = CourseInfo.find_by_course_id(course_id) + if @user_id == user.id + @result = true + end + return @result + end + + # 返回课程设置界面 + def course_settings_tabs + tabs = [{:name => 'info', :action => :edit_course, :partial => 'courses/edit', :label => :label_information_plural}, + {:name => 'members', :action => :manage_members, :partial => 'courses/settings/members', :label => :label_member_plural} + ] + tabs.select { |tab| User.current.allowed_to?(tab[:action], @course) } + + end + + #是否启动互评下拉框 + def is_evaluation_option + type = [] + option1 = [] + option2 = [] + option1 << l(:lable_start_mutual_evaluation) + option1 << 1 + option2 << l(:lable_close_mutual_evaluation) + option2 << 2 + type << option1 + type << option2 + end + + # garble count 混淆数量 + # alias projectCountOrigin projectCount + # def projectCount project + # count = projectCountOrigin project + # garble count + # end + + def homework_type_option + type = [] + option1 = [] + option2 = [] + option1 << l(:label_task_submit_form_accessory) + option1 << 1 + option2 << l(:label_task_submit_form_project) + option2 << 2 + type << option1 + type << option2 + end + + def proportion_option + type = [] + i = 0 + while i <= 100 + option = [] + option << i.to_s + "%" + option << i + type << option + i = i + 10 + end + type + end + + + #alias teacherCountOrigin teacherCount + #def teacherCount project + # count = teacherCountOrigin project + # garble count + #end + + # 注意:此方法有问题,速度慢且结果不准 + # alias studentCountOrigin studentCount + #def studentCount course + # count = studentCountOrigin course + #garble count + # end + + # 学生人数计算 + # add by nwb + def studentCount course + count = searchStudent(course).count#course.student.count + if count <= 5 + result = count.to_s + elsif count < 10 && count > 5 + result = "5+" + else + result = (count-count % 10).to_s + "+" + end + result + end + + #课程成员数计算 + def memberCount course + count = searchStudent(course).count + searchTeacherAndAssistant(course).count + if count <= 5 + result = count.to_s + elsif count < 10 && count > 5 + result = "5+" + else + result = (count-count % 10).to_s + "+" + end + result + end + + def eventToLanguageCourse event_type, course + case event_type + when "issue-note" + l :label_issue + when "issue" + l :label_issue + when "attachment" + l :label_attachment + when "news" + l :label_notification + else + "" + end + end + + def garble count + count = count.round( 1-count.to_s.size ).to_i + return count.to_s if count.to_s.size.eql?(1) + count.to_s << '+' + end + + # ===================================================================================== + # return people list + def searchTeacherAndAssistant project + #searchPeopleByRoles(project, TeacherRoles) + members = [] + project.members.each do |m| + members << m if m && m.user && m.user.allowed_to?(:as_teacher,project) + 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 + # members = searchPeopleByRoles project, roles_id + # members.count + #end + + #def searchPeopleByRoles project, roles_id + # members = [] + # begin + # members = project.members.joins(:member_roles).where("member_roles.role_id IN (:role_id)", {:role_id => roles_id}) + # rescue Exception => e + # logger.error "[CoursesHelper] ===> #{e}" + # end + # members + #end + + def sort_courses(state) + content = ''.html_safe + case state + when 0 + + content << content_tag('li', link_to(l(:label_sort_by_active), courses_path(:courses_sort_type => '1'))) + content << content_tag('li', link_to(l(:label_sort_by_influence), courses_path(:courses_sort_type => '2'))) + content << content_tag('li', link_to(l(:label_sort_by_time), courses_path(:courses_sort_type => '0'), :class=>"selected"), :class=>"selected") + when 1 + + content << content_tag('li', link_to(l(:label_sort_by_active), courses_path(:courses_sort_type => '1'), :class=>"selected"), :class=>"selected") + content << content_tag('li', link_to(l(:label_sort_by_influence), courses_path(:courses_sort_type => '2'))) + content << content_tag('li', link_to(l(:label_sort_by_time), courses_path(:courses_sort_type => '0'))) + when 2 + content << content_tag('li', link_to(l(:label_sort_by_active), courses_path(:courses_sort_type => '1'))) + content << content_tag('li', link_to(l(:label_sort_by_influence), courses_path(:courses_sort_type => '2'), :class=>"selected"), :class=>"selected") + content << content_tag('li', link_to(l(:label_sort_by_time), courses_path(:courses_sort_type => '0'))) + end + content = content_tag('ul', content) + content_tag('div', content, :class => "tabs") + end + + def render_course_hierarchy(courses) + render_course_nested_lists(courses) do |course| + s = link_to_course(course, {}, :class => "#{course.css_classes} #{User.current.member_of?(course) ? 'my-course' : nil}").html_safe + s + end + end + + #useless + #def searchMembersByRole project, role_id + # members = [] + # begin + # members = project.members.joins(:member_roles).where("member_roles.role_id = :role_id", {:role_id => role_id }) + # rescue Exception => e + # logger.error "[CoursesHelper] ===> #{e}" + # end + # members + #end + + def sort_course(state, school_id) + content = ''.html_safe + case state + when 0 + content << content_tag('li', link_to(l(:label_sort_by_time), courses_path(:course_sort_type => '0'), :school_id => school_id, :class=>"selected"), :class=>"selected") + content << content_tag('li', link_to(l(:label_sort_by_active), courses_path(:course_sort_type => '1', :school_id => school_id))) + content << content_tag('li', link_to(l(:label_sort_by_activity), courses_path(:course_sort_type => '3', :school_id => school_id))) + + when 1 + content << content_tag('li', link_to(l(:label_sort_by_time), courses_path(:course_sort_type => '0', :school_id => school_id))) + content << content_tag('li', link_to(l(:label_sort_by_active), courses_path(:course_sort_type => '1', :school_id => school_id), :class=>"selected"), :class=>"selected") + content << content_tag('li', link_to(l(:label_sort_by_activity), courses_path(:course_sort_type => '3', :school_id => school_id))) + + when 2 + content << content_tag('li', link_to(l(:label_sort_by_time), courses_path(:course_sort_type => '0', :school_id => school_id))) + content << content_tag('li', link_to(l(:label_sort_by_active), courses_path(:course_sort_type => '1', :school_id => school_id))) + content << content_tag('li', link_to(l(:label_sort_by_activity), courses_path(:course_sort_type => '3', :school_id => school_id))) + + #gcm + when 3 + content << content_tag('li', link_to(l(:label_sort_by_time), courses_path(:course_sort_type => '0', :school_id => school_id))) + content << content_tag('li', link_to(l(:label_sort_by_active), courses_path(:course_sort_type => '1', :school_id => school_id))) + content << content_tag('li', link_to(l(:label_sort_by_activity), courses_path(:course_sort_type => '3', :school_id => school_id), :class=>"selected"), :class=>"selected") + end + #gcmend + + content = content_tag('ul', content) + content_tag('div', content, :class => "tabs") + end + + def findCourseTime project + str = "" + begin + @course = Course.find_by_extra(@project.identifier) + date_format = l(:zh_date)[:formats][:default] + if @course + str = DateTime.parse(@course.setup_time.to_s).strftime("#{date_format}").to_s unless @course.setup_time.blank? + str << '-' unless @course.setup_time.blank? + str << DateTime.parse(@course.endup_time.to_s).strftime("#{date_format}").to_s unless @course.endup_time.blank? + end + rescue Exception => e + logger.error "[CoursesHelper] ===> #{e}" + end + str + end + + # added by nwb + def get_course_term course + str = ( course.try(:time).to_s << '.' << course.try(:term).to_s ) + str[0..-4] + end + + def members_to_user_ids members + people = [] + members.each { |member| + people << member.user_id + } + people + end + # 截至到2014-03-17 这个是最终的判断课程是否过期的方法 + def course_endTime_timeout? course + end_time_str = course.try(:endup_time) + begin + cTime = Time.parse(end_time_str.to_s) + rescue TypeError,ArgumentError + cTime = Time.parse("3000-01-01") + end + now = Time.now + + now > cTime + end + def find_by_extra_from_project extra + Course.find_by_extra(try(extra)) + end + #判断指定用户是不是当前课程的老师 + def is_course_teacher (user,course) + #course.members.joins(:member_roles).where("member_roles.role_id IN (:role_id) and members.user_id = #{user.id}", {:role_id => TeacherRoles}).count != 0 + user.allowed_to?(:as_teacher,course) + #修改为根据用户是否有发布任务的权限来判断用户是否是课程的老师 + #is_teacher = false + #@membership = user.memberships.all(:conditions => Project.visible_condition(User.current)) + #@membership.each do |membership| + # unless(membership.project.project_type==0) + # if user.allowed_to?({:controller => "projects", :action => "new_homework"}, membership.project, :global => false) + # is_teacher = true + # end + # end + #end + #is_teacher + end + #当前用户是不是指定课程的学生 + def is_cur_course_student course + #course.members.joins(:member_roles).where("member_roles.role_id IN (:role_id) and members.user_id = #{User.current.id}", {:role_id => StudentRoles}).count != 0 + !(User.current.allowed_to?(:as_teacher,course)) + #修改:能新建占位且不能新建任务的角色判定为学生 + #is_student = false + #@membership = User.current.memberships.all(:conditions => Project.visible_condition(User.current)) + #@membership.each do |membership| + # unless(membership.project.project_type==0) + # if !User.current.allowed_to?({:controller => "projects", :action => "new_homework"}, membership.project, :global => false) && User.current.allowed_to?({:controller => "homework_attach", :action => "new"}, membership.project, :global => false) + # is_student = true + # end + # end + #end + #is_student + end + #获取当前用户在指定作业下提交的作业的集合 + def cur_user_homework_for_bid bid + cur_user_homework = HomeworkAttach.where("user_id = ? and bid_id = ?",User.current,bid.id) + cur_user_homework + end + + #判断当前用户对指定作业是否已经评价过 + def has_evaluation? homework + seem_count = homework.rates(:quality).where("rater_id = ?",User.current).count + seem_count > 0 + end + + #获取指定作业的所有成员 + def users_for_homework homework + homework.nil? ? [] : (homework.users + [homework.user]) + end + + #获取指定作业的最终评分 + #最终评分 = 学生评分的平均分 * 0.4 +教师评分 * 0.6 + def score_for_homework homework + if homework.bid.is_evaluation == 1 || homework.bid.is_evaluation == nil + return format("%.2f",(homework.bid.proportion * 1.0 / 100) * (teacher_score_for_homework(homework).to_f) + (1 - homework.bid.proportion * 1.0 / 100) * (student_score_for_homework(homework).to_f)) + else + return teacher_score_for_homework homework + end + end + + #获取作业的互评得分 + def student_score_for_homework homework + #member = searchTeacherAndAssistant(homework.bid.courses.first).first#searchPeopleByRoles(homework.bid.courses.first,TeacherRoles).first + #if member.nil? + # return "0.00" + #end + #student_stars = homework.rates(:quality).where("rater_id <> #{member.user_id}").select("stars") + members = searchStudent(homework.bid.courses.first) + user_ids = [] + members.each do |user| + user_ids << user.user_id + end + student_stars = homework.rates(:quality).where("rater_id in (:user_ids)",{:user_ids => user_ids}).select("stars") + student_stars_count = 0 + student_stars.each do |star| + student_stars_count = student_stars_count + star.stars + end + return format("%.2f",student_stars_count / (student_stars.count == 0 ? 1 : student_stars.count)) + + + + end + + #获取作业的教师评分 + #多个教师只获取一份教师评分 + def teacher_score_for_homework homework + members = searchTeacherAndAssistant(homework.bid.courses.first)#searchPeopleByRoles(homework.bid.courses.first,TeacherRoles).first + #if member.nil? + # return "0.00" + #end + teacher_ids = [] + members.each do |user| + teacher_ids << user.user_id + end + teacher_stars = homework.rates(:quality).where("rater_id in (:teacher_ids)",{:teacher_ids => teacher_ids}).select("stars") + teacher_stars_count = 0 + teacher_stars.each do |star| + teacher_stars_count = teacher_stars_count + star.stars + end + return format("%.2f",teacher_stars_count) + end + + #获取指定项目的得分 + def project_score project + issue_count = project.issues.count + issue_journal_count = project.issue_changes.count + issue_score = issue_count * 0.2 + issue_journal_score = issue_journal_count * 0.1 + finall_issue_score = issue_score + issue_journal_score + new_count = project.news.count + new_score = new_count * 0.1 + finall_new_score = new_score + document_count = project.documents.count + file_score = document_count * 0.1 + finall_file_score = file_score + changeset_count = project.changesets.count + code_submit_score = changeset_count * 0.3 + finall_code_submit_score = code_submit_score + board_message_count = 0 + project.boards.each do |board| + board_message_count += board.messages_count + end + topic_score = board_message_count * 0.1 + #finall_topic_score = topic_score + finall_project_score = finall_issue_score + finall_new_score + finall_file_score + finall_code_submit_score + topic_score + format("%.2f",finall_project_score) + end + + #获取指定作业的参与人员 + #返回结果:张三、李四、王五 + def homework_user_of_homework homework,is_teacher + homework_users = "" + homework.users.each do |user| + homework_users = homework_users + (is_teacher ? (user.lastname + user.firstname) : user.login) + if user != homework.users.last + homework_users = homework_users + "、" + end + end + return homework_users + end + + def get_courses_by_tag(tag_name) + Course.tagged_with(tag_name).order('updated_at desc') + end + + #课程实践年份下拉框 + def course_time_option + type = [] + now_year = Time.now.year + for i in (now_year..now_year + 10) + option = [] + option << i + option << i + type << option + end + type + end + + #课程课时下拉框 + def course_term_option + type = [] + option1 = [] + option1 << l(:label_spring) + option1 << l(:label_spring) + option2 = [] + option2 << l(:label_autumn) + option2 << l(:label_autumn) + type << option1 + type << option2 + type + end + + #获取课程动态 + def get_course_activity courses, activities + @course_ids=activities.keys() + + days = Setting.activity_days_default.to_i + date_to ||= Date.today + 1 + date_from = date_to - days-1.years + + #file_count + Attachment.where(container_id: @course_ids, container_type: Course).where("created_on>?", date_from).each do |attachment| + activities[attachment.container_id]+=1 + end + + #message_count + Board.where(course_id: @course_ids).each do |board| +# activities[board.course_id]+=1 + activities[board.course_id]+=board.messages.where("updated_on>?", date_from).count + end + + #news + News.where(course_id: @course_ids).where("created_on>?",date_from).each do |news| + activities[news.course_id]+=1 + end + + #feedbackc_count + JournalsForMessage.where(jour_id: @course_ids, jour_type: Course).each do |jourformess| + activities[jourformess.jour_id]+=1 + end + + #activities!=0 + i=0; + courses.each do |course| + id=course.id + if activities[id]==0 + activities[id]=1 + end + end + + return activities + end + +end diff --git a/app/helpers/watchers_helper.rb b/app/helpers/watchers_helper.rb index 793581664..56b2ec0f4 100644 --- a/app/helpers/watchers_helper.rb +++ b/app/helpers/watchers_helper.rb @@ -1,257 +1,257 @@ -# encoding: utf-8 -# -# Redmine - project management software -# Copyright (C) 2006-2013 Jean-Philippe Lang -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - -module WatchersHelper - - def watcher_tag(object, user, options={}) - ActiveSupport::Deprecation.warn "#watcher_tag is deprecated and will be removed in Redmine 3.0. Use #watcher_link instead." - watcher_link(object, user) - end - - ###################modified by liuping, nyan - def watcher_link(objects, user, options=[]) - return '' unless user && user.logged? - objects = Array.wrap(objects) - - watched = objects.any? {|object| object.watched_by?(user)} - @watch_flag = (objects.first.instance_of?(User) or objects.first.instance_of?(Project) or objects.first.instance_of?(Contest) or (objects.first.instance_of?(Bid))) - css = @watch_flag ? ([watcher_css(objects), watched ? 'icon ' : 'icon '].join(' ') << options[0].to_s) : - ([watcher_css(objects), watched ? 'icon icon-fav ' : 'icon icon-fav-off '].join(' ') << options[0].to_s) - - text = @watch_flag ? - (watched ? l(:button_unfollow) : l(:button_follow)) : (watched ? l(:button_unwatch) : l(:button_watch)) - - url = watch_path( - :object_type => objects.first.class.to_s.underscore, - :object_id => (objects.size == 1 ? objects.first.id : objects.map(&:id).sort) - ) - method = watched ? 'delete' : 'post' - - link_to text, url, :remote => true, :method => method, :class => css - end - - ############## added by linchun - def new_watcher_link(objects, user, options=[]) - return '' unless user && user.logged? - objects = Array.wrap(objects) - - watched = objects.any? {|object| object.watched_by?(user)} - @watch_flag = (objects.first.instance_of?(User) or objects.first.instance_of?(Project) or (objects.first.instance_of?(Contest))) - css = @watch_flag ? ([watcher_css(objects), watched ? 'icon ' : 'icon '].join(' ') << options[0].to_s) : - ([watcher_css(objects), watched ? 'icon icon-fav ' : 'icon icon-fav-off '].join(' ') << options[0].to_s) - - text = @watch_flag ? - (watched ? l(:button_unfollow) : l(:button_follow)) : (watched ? l(:button_unwatch) : l(:button_watch)) - - url = watch_path( - :object_type => objects.first.class.to_s.underscore, - :object_id => (objects.size == 1 ? objects.first.id : objects.map(&:id).sort) - ) - method = watched ? 'delete' : 'post' - - link_to text, url, :remote => true, :method => method, :class => css - end - - # add by nwb - # 关注课程 - def new_course_watcher_link(objects, user, options=[]) - return '' unless user && user.logged? - objects = Array.wrap(objects) - - watched = objects.any? {|object| object.watched_by?(user)} - @watch_flag = (objects.first.instance_of?(User) or objects.first.instance_of?(Project) or (objects.first.instance_of?(Contest))) - css = @watch_flag ? ([watcher_css(objects), watched ? 'icon ' : 'icon '].join(' ') << options[0].to_s) : - ([watcher_css(objects), watched ? 'icon icon-fav ' : 'icon icon-fav-off '].join(' ') << options[0].to_s) - - text = @watch_flag ? - (watched ? l(:button_unfollow) : l(:button_follow)) : (watched ? l(:button_unwatch) : l(:button_watch)) - - url = watch_path( - :object_type => objects.first.class.to_s.underscore, - :object_id => (objects.size == 1 ? objects.first.id : objects.map(&:id).sort) - ) - method = watched ? 'delete' : 'post' - - link_to text, url, :remote => true, :method => method, :class => css - end - - # added by fq, modify nyan - # Somebody may use option params - def join_in_course(course, user, options=[]) - return '' unless user && user.logged? - # modify by nwb - # 主讲教师不允许退出课程 - return '' if user.id == course.tea_id - joined = user.member_of_course?(course) - text = joined ? l(:label_exit_course) : l(:label_join_course) - url_t = join_path(:object_id => course.id) - url_f = try_join_path(:object_id => course.id) - method = joined ? 'delete' : 'post' - if joined - link_to text, url_t, :remote => true, :method => method, :id => "#{course.id}", :confirm => l(:text_are_you_sure_out), :class => []+options - else - link_to text, url_f, :remote => true, :method => method, :id => "#{course.id}", :class => []+options - end - end - - # 用户是否允许加入课程判断 - # add by nwb - def join_in_course_for_list(course, user, options=[]) - return '' unless user && user.logged? - # modify by nwb - # 主讲教师不允许退出课程 - return '' if user.id == course.tea_id - joined = user.member_of_course?(course) - text = joined ? l(:label_exit_course) : l(:label_join_course) - url_t = join_path(:object_id => course.id) - url_f = try_join_path(:object_id => course.id) - method = joined ? 'delete' : 'post' - if joined - link_to text, url_t, :remote => true, :method => method, :id => "#{course.id}", :confirm => l(:text_are_you_sure_out), :class => []+options - else - link_to text, url_f, :remote => true, :method => method, :id => "#{course.id}", :class => []+options - end - end - - #added by bai - def join_in_contest(bid, user, options=[]) - if bid.reward_type == 2 - return '' unless user && user.logged? - joined = user.join_in_contest?(bid) - text = joined ? l(:label_exit_contest) : l(:label_join_contest) - url_t = join_in_contest_path(:id => bid.id) - url_f = try_join_in_contest_path(:id => bid.id) - # url = join_in_contest_path(:id => bid.id) - method = joined ? 'delete' : 'post' - if joined - link_to text, url_t, :remote => true, :method => method, :id => "#{bid.id}", :confirm => l(:text_are_you_sure_out), :class => []+options - else - link_to text, url_f, :remote => true, :method => method, :id => "#{bid.id}", :class => []+options - end - end - end - ##new add by linchun - def join_in_contest(contest, user, options=[]) - return '' unless user && user.logged? - joined = user.join_in_contest?(contest) - text = joined ? l(:label_exit_contest) : l(:label_join_contest) - url_t = join_in_contest_path(:id => contest.id) - url_f = try_join_in_contest_path(:id => contest.id) - # url = join_in_contest_path(:id => contest.id) - method = joined ? 'delete' : 'post' - if joined - link_to text, url_t, :remote => true, :method => method, :id => "#{contest.id}", :confirm => l(:text_are_you_sure_out), :class => []+options - else - link_to text, url_f, :remote => true, :method => method, :id => "#{contest.id}", :class => []+options - end - end - - # liuwanwei 的需求, 新竞赛 - # 新路由命名为 competition - def join_in_competition(competition, user) - return '' unless user && user.logged? - joined = JoinInCompetition.where('competition_id = ? AND user_id = ?', competition.id, user.id).count>0 - text = joined ? l(:label_exit_contest) : l(:label_join_contest) - url_f = new_join_contests_path(:id => competition.id) - url_t = unjoin_in_contest_contests_path(:id => competition.id) - method = joined ? 'delete' : 'post' - if joined - # 退出竞赛用 - link_to text, url_t, :remote => true, :method => method, :id => "#{competition.id}", :confirm => l(:text_are_you_sure_out) - else - # 加入竞赛用 - link_to text, url_f, :remote => true, :method => method, :id => "#{competition.id}" - end - end - - # Returns the css class used to identify watch links for a given +object+ - def watcher_css(objects) - objects = Array.wrap(objects) - id = (objects.size == 1 ? objects.first.id : 'bulk') - "#{objects.first.class.to_s.underscore}-#{id}-watcher" - end - - # Returns a comma separated list of users watching the given object - def watchers_list(object) - remove_allowed = User.current.allowed_to?("delete_#{object.class.name.underscore}_watchers".to_sym, object.project) - content = ''.html_safe - lis = object.watcher_users.collect do |user| - s = ''.html_safe - s << avatar(user, :size => "16").to_s - s << link_to_user(user, :class => 'user') - if remove_allowed - url = {:controller => 'watchers', - :action => 'destroy', - :object_type => object.class.to_s.underscore, - :object_id => object.id, - :user_id => user} - s << ' ' - s << link_to(image_tag('delete.png'), url, - :remote => true, :method => 'delete', :class => "delete") - end - content << content_tag('li', s, :class => "user-#{user.id}") - end - content.present? ? content_tag('ul', content, :class => 'watchers') : content - end - - def watchers_checkboxes(object, users, checked=nil) - if users.nil? - - else - users.map do |user| - c = checked.nil? ? object.watched_by?(user) : checked - tag = check_box_tag 'issue[watcher_user_ids][]', user.id, c, :id => nil - content_tag 'label', "#{tag} #{h(user)}".html_safe, - :id => "issue_watcher_user_ids_#{user.id}", - :class => "floating" - end.join.html_safe - end - end - - def applied_css(project) - id = project.id - "#{project.class.to_s.underscore}-#{id}-applied" - end - - def applied_link(project, user, options=[]) - return '' unless user && user.logged? - applied = project.applied_projects.find_by_user_id(user.id) - text = applied ? l(:label_unapply_project) : l(:label_apply_project) - - @applied_flag = project.instance_of?(Project) - css = @applied_flag ? ([applied_css(project), applied ? 'icon ' : 'icon '].join(' ') << options[0].to_s) : - ([applied_css(project), applied ? 'icon icon-applied ' : 'icon icon-applied-off '].join(' ') << options[0].to_s) - if applied - appliedid = applied.id - end - url = appliedproject_path( - :id=>appliedid, - :user_id => user.id, - :project_id => project.id - ) - method = applied ? 'delete' : 'post' - - link_to text, url, :remote => true, :method => method ,:class=>css - end - - def exit_project_link(project) - link_to(l(:label_exit_project),exit_cur_project_path(project.id), - :remote => true, :confirm => l(:lable_sure_exit_project) ) - end - end +# encoding: utf-8 +# +# Redmine - project management software +# Copyright (C) 2006-2013 Jean-Philippe Lang +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + +module WatchersHelper + + def watcher_tag(object, user, options={}) + ActiveSupport::Deprecation.warn "#watcher_tag is deprecated and will be removed in Redmine 3.0. Use #watcher_link instead." + watcher_link(object, user) + end + + ###################modified by liuping, nyan + def watcher_link(objects, user, options=[]) + return '' unless user && user.logged? + objects = Array.wrap(objects) + + watched = objects.any? {|object| object.watched_by?(user)} + @watch_flag = (objects.first.instance_of?(User) or objects.first.instance_of?(Project) or objects.first.instance_of?(Contest) or (objects.first.instance_of?(Bid))) + css = @watch_flag ? ([watcher_css(objects), watched ? 'icon ' : 'icon '].join(' ') << options[0].to_s) : + ([watcher_css(objects), watched ? 'icon icon-fav ' : 'icon icon-fav-off '].join(' ') << options[0].to_s) + + text = @watch_flag ? + (watched ? l(:button_unfollow) : l(:button_follow)) : (watched ? l(:button_unwatch) : l(:button_watch)) + + url = watch_path( + :object_type => objects.first.class.to_s.underscore, + :object_id => (objects.size == 1 ? objects.first.id : objects.map(&:id).sort) + ) + method = watched ? 'delete' : 'post' + + link_to text, url, :remote => true, :method => method, :class => css + end + + ############## added by linchun + def new_watcher_link(objects, user, options=[]) + return '' unless user && user.logged? + objects = Array.wrap(objects) + + watched = objects.any? {|object| object.watched_by?(user)} + @watch_flag = (objects.first.instance_of?(User) or objects.first.instance_of?(Project) or (objects.first.instance_of?(Contest))) + css = @watch_flag ? ([watcher_css(objects), watched ? 'icon ' : 'icon '].join(' ') << options[0].to_s) : + ([watcher_css(objects), watched ? 'icon icon-fav ' : 'icon icon-fav-off '].join(' ') << options[0].to_s) + + text = @watch_flag ? + (watched ? l(:button_unfollow) : l(:button_follow)) : (watched ? l(:button_unwatch) : l(:button_watch)) + + url = watch_path( + :object_type => objects.first.class.to_s.underscore, + :object_id => (objects.size == 1 ? objects.first.id : objects.map(&:id).sort) + ) + method = watched ? 'delete' : 'post' + + link_to text, url, :remote => true, :method => method, :class => css + end + + # add by nwb + # 关注课程 + def new_course_watcher_link(objects, user, options=[]) + return '' unless user && user.logged? + objects = Array.wrap(objects) + + watched = objects.any? {|object| object.watched_by?(user)} + @watch_flag = (objects.first.instance_of?(User) or objects.first.instance_of?(Project) or (objects.first.instance_of?(Contest))) + css = @watch_flag ? ([watcher_css(objects), watched ? 'icon ' : 'icon '].join(' ') << options[0].to_s) : + ([watcher_css(objects), watched ? 'icon icon-fav ' : 'icon icon-fav-off '].join(' ') << options[0].to_s) + + text = @watch_flag ? + (watched ? l(:button_unfollow) : l(:button_follow)) : (watched ? l(:button_unwatch) : l(:button_watch)) + + url = watch_path( + :object_type => objects.first.class.to_s.underscore, + :object_id => (objects.size == 1 ? objects.first.id : objects.map(&:id).sort) + ) + method = watched ? 'delete' : 'post' + + link_to text, url, :remote => true, :method => method, :class => css + end + + # added by fq, modify nyan + # Somebody may use option params + def join_in_course(course, user, options=[]) + return '' unless user && user.logged? + # modify by nwb + # 主讲教师不允许退出课程 + return '' if user.id == course.tea_id + joined = user.member_of_course?(course) + text = joined ? l(:label_exit_course) : l(:label_join_course) + url_t = join_path(:object_id => course.id) + url_f = try_join_path(:object_id => course.id) + method = joined ? 'delete' : 'post' + if joined + link_to text, url_t, :remote => true, :method => method, :id => "#{course.id}", :confirm => l(:text_are_you_sure_out), :class => []+options + else + link_to text, url_f, :remote => true, :method => method, :id => "#{course.id}", :class => []+options + end + end + + # 用户是否允许加入课程判断 + # add by nwb + def join_in_course_for_list(course, user, options=[]) + return '' unless user && user.logged? + # modify by nwb + # 主讲教师不允许退出课程 + return '' if user.id == course.tea_id + joined = user.member_of_course?(course) + text = joined ? l(:label_exit_course) : l(:label_join_course) + url_t = join_path(:object_id => course.id) + url_f = try_join_path(:object_id => course.id) + method = joined ? 'delete' : 'post' + if joined + link_to text, url_t, :remote => true, :method => method, :id => "#{course.id}", :confirm => l(:text_are_you_sure_out), :class => []+options + else + link_to text, url_f, :remote => true, :method => method, :id => "#{course.id}", :class => []+options + end + end + + #added by bai + def join_in_contest(bid, user, options=[]) + if bid.reward_type == 2 + return '' unless user && user.logged? + joined = user.join_in_contest?(bid) + text = joined ? l(:label_exit_contest) : l(:label_join_contest) + url_t = join_in_contest_path(:id => bid.id) + url_f = try_join_in_contest_path(:id => bid.id) + # url = join_in_contest_path(:id => bid.id) + method = joined ? 'delete' : 'post' + if joined + link_to text, url_t, :remote => true, :method => method, :id => "#{bid.id}", :confirm => l(:text_are_you_sure_out), :class => []+options + else + link_to text, url_f, :remote => true, :method => method, :id => "#{bid.id}", :class => []+options + end + end + end + ##new add by linchun + def join_in_contest(contest, user, options=[]) + return '' unless user && user.logged? + joined = user.join_in_contest?(contest) + text = joined ? l(:label_exit_contest) : l(:label_join_contest) + url_t = join_in_contest_path(:id => contest.id) + url_f = try_join_in_contest_path(:id => contest.id) + # url = join_in_contest_path(:id => contest.id) + method = joined ? 'delete' : 'post' + if joined + link_to text, url_t, :remote => true, :method => method, :id => "#{contest.id}", :confirm => l(:text_are_you_sure_out), :class => []+options + else + link_to text, url_f, :remote => true, :method => method, :id => "#{contest.id}", :class => []+options + end + end + + # liuwanwei 的需求, 新竞赛 + # 新路由命名为 competition + def join_in_competition(competition, user) + return '' unless user && user.logged? + joined = JoinInCompetition.where('competition_id = ? AND user_id = ?', competition.id, user.id).count>0 + text = joined ? l(:label_exit_contest) : l(:label_join_contest) + url_f = new_join_contests_path(:id => competition.id) + url_t = unjoin_in_contest_contests_path(:id => competition.id) + method = joined ? 'delete' : 'post' + if joined + # 退出竞赛用 + link_to text, url_t, :remote => true, :method => method, :id => "#{competition.id}", :confirm => l(:text_are_you_sure_out) + else + # 加入竞赛用 + link_to text, url_f, :remote => true, :method => method, :id => "#{competition.id}" + end + end + + # Returns the css class used to identify watch links for a given +object+ + def watcher_css(objects) + objects = Array.wrap(objects) + id = (objects.size == 1 ? objects.first.id : 'bulk') + "#{objects.first.class.to_s.underscore}-#{id}-watcher" + end + + # Returns a comma separated list of users watching the given object + def watchers_list(object) + remove_allowed = User.current.allowed_to?("delete_#{object.class.name.underscore}_watchers".to_sym, object.project) + content = ''.html_safe + lis = object.watcher_users.collect do |user| + s = ''.html_safe + s << avatar(user, :size => "16").to_s + s << link_to_user(user, :class => 'user') + if remove_allowed + url = {:controller => 'watchers', + :action => 'destroy', + :object_type => object.class.to_s.underscore, + :object_id => object.id, + :user_id => user} + s << ' ' + s << link_to(image_tag('delete.png'), url, + :remote => true, :method => 'delete', :class => "delete") + end + content << content_tag('li', s, :class => "user-#{user.id}") + end + content.present? ? content_tag('ul', content, :class => 'watchers') : content + end + + def watchers_checkboxes(object, users, checked=nil) + if users.nil? + + else + users.map do |user| + c = checked.nil? ? object.watched_by?(user) : checked + tag = check_box_tag 'issue[watcher_user_ids][]', user.id, c, :id => nil + content_tag 'label', "#{tag} #{h(user)}".html_safe, + :id => "issue_watcher_user_ids_#{user.id}", + :class => "floating" + end.join.html_safe + end + end + + def applied_css(project) + id = project.id + "#{project.class.to_s.underscore}-#{id}-applied" + end + + def applied_link(project, user, options=[]) + return '' unless user && user.logged? + applied = project.applied_projects.find_by_user_id(user.id) + text = applied ? l(:label_unapply_project) : l(:label_apply_project) + + @applied_flag = project.instance_of?(Project) + css = @applied_flag ? ([applied_css(project), applied ? 'icon ' : 'icon '].join(' ') << options[0].to_s) : + ([applied_css(project), applied ? 'icon icon-applied ' : 'icon icon-applied-off '].join(' ') << options[0].to_s) + if applied + appliedid = applied.id + end + url = appliedproject_path( + :id=>appliedid, + :user_id => user.id, + :project_id => project.id + ) + method = applied ? 'delete' : 'post' + + link_to text, url, :remote => true, :method => method ,:class=>css + end + + def exit_project_link(project) + link_to(l(:label_exit_project),exit_cur_project_path(project.id), + :remote => true, :confirm => l(:lable_sure_exit_project) ) + end + end diff --git a/app/views/account/register.html.erb b/app/views/account/register.html.erb index 27732b549..f53f31f80 100644 --- a/app/views/account/register.html.erb +++ b/app/views/account/register.html.erb @@ -1,489 +1,489 @@ -<% @nav_dispaly_home_path_label = 1 - @nav_dispaly_main_course_label = 1 - @nav_dispaly_main_project_label = 1 - @nav_dispaly_main_contest_label = 1 %> -<% @nav_dispaly_forum_label = 1%> - - - - - - - -
-
- <%= l(:label_identity) %> * | -- - | -- | - - -
<%= f.text_field :login, :size => 25, :required => true %> - <%= l(:label_max_number) %> -
-<%= f.password_field :password, :size => 25, :required => true %> - <%= l(:text_caracters_minimum, :count => Setting.password_min_length) %> -
-<%= f.password_field :password_confirmation, :size => 25, :required => true %>
- <% end %> - - -- <%= f.text_field :mail, :required => true %> - -
-- <%= "#{l(:label_mail_attention)} " %> -
-<%= f.select :language, lang_options_for_select, :required => true %>
- - - --
- <%= l(:label_location) %> * - | -- - | -- - | -
-
<%= submit_tag l(:button_submit) %> | -
<%= f.text_field :identity_url %>
-<% end %> -<% @user.custom_field_values.select { |v| v.editable? || v.required? }.each do |value| %> -<%= custom_field_tag_with_label :user, value %>
-<% end %> - - + + + + + ++
+ <%= l(:label_identity) %> * | ++ + | ++ | + + +
<%= f.text_field :login, :size => 25, :required => true %> + <%= l(:label_max_number) %> +
+<%= f.password_field :password, :size => 25, :required => true %> + <%= l(:text_caracters_minimum, :count => Setting.password_min_length) %> +
+<%= f.password_field :password_confirmation, :size => 25, :required => true %>
+ <% end %> + + ++ <%= f.text_field :mail, :required => true %> + +
++ <%= "#{l(:label_mail_attention)} " %> +
+<%= f.select :language, lang_options_for_select, :required => true %>
+ + + ++
+ <%= l(:label_location) %> * + | ++ + | ++ + | +
+
<%= submit_tag l(:button_submit) %> | +
<%= f.text_field :identity_url %>
+<% end %> +<% @user.custom_field_values.select { |v| v.editable? || v.required? }.each do |value| %> +<%= custom_field_tag_with_label :user, value %>
+<% end %> + + \ No newline at end of file diff --git a/app/views/bids/_homework_list.html.erb b/app/views/bids/_homework_list.html.erb index aae4a63b8..9bf997cbe 100644 --- a/app/views/bids/_homework_list.html.erb +++ b/app/views/bids/_homework_list.html.erb @@ -1,155 +1,155 @@ - -<% is_student = is_cur_course_student(@bid.courses.first) %> -<% is_teacher = is_course_teacher(User.current,@bid.courses.first) %> - -<% is_evaluation = @bid.is_evaluation == 1 || @bid.is_evaluation == nil %> -<%= form_tag(:controller => 'bids', :action => "show_courseEx", :method => :get) do %> -<%= l(:label_task_plural)%>(<%= @homework_list.count%>) - <%= link_to "作业打包下载", zipdown_assort_path(obj_class: @bid.class, obj_id: @bid), class: "button_submit button_submit_font_white", style: "margin: 5px 10px;line-height: 20px;height: 20px;display: inline-block;" if(is_teacher && @bid.homeworks.count > 0) %> - | -
-
- <% if is_teacher %>
- <%= text_field_tag 'student_id', params[:student_id], :size => 30 %>
- <%= submit_tag l(:label_search_by_student_id), :class => "small", :name => nil %>
- <% end %>
-
- |
-
-
|
-
-
|
-
<%= l(:label_task_plural)%>(<%= @homework_list.count%>) + <%= link_to "作业打包下载", zipdown_assort_path(obj_class: @bid.class, obj_id: @bid), class: "button_submit button_submit_font_white", style: "margin: 5px 10px;line-height: 20px;height: 20px;display: inline-block;" if(is_teacher && @bid.homeworks.count > 0) %> + | +
+
+ <% if is_teacher %>
+ <%= text_field_tag 'student_id', params[:student_id], :size => 30 %>
+ <%= submit_tag l(:label_search_by_student_id), :class => "small", :name => nil %>
+ <% end %>
+
+ |
+
+
|
+
+
|
+
<%= render :partial => "avatar/avatar_form", :locals => {source: @course} %>
-<% end %> -- - -
- -<%= f.fields_for @course do |m| %> - <% unless @course.nil? %> --
- <%= l(:label_class_period) %> - * - <%= text_field_tag :class_period, @course.class_period, :placeholder => "在此输入课时", :maxlength => 5 %> - <%= l(:label_class_hour) %> - | -
-
- <%= l(:label_class_period) %> - * - <%= text_field_tag :class_period, nil, :placeholder => "在此输入课时", :maxlength => 5 %><%= l(:label_class_hour) %> - | -
-
- <% if @course != nil %>
-
|
-
- - -
- <%= l(:text_command) %> -<% end %> -- - - - -
-- - <%= f.check_box :is_public, :style => "margin-left:10px;" %> - <%= l(:label_course_public_info) %> - -
- -<%= wikitoolbar_for 'course_description' %> -<% @course.custom_field_values.each do |value| %> -<%= custom_field_tag_with_label :course, value %>
-<% end %> -<%= call_hook(:view_courses_form, :course => @course, :form => f) %> - - -<% unless @course.extra_frozen? %> - <% content_for :header_tags do %> - <%= javascript_include_tag 'course_identifier' %> - <% end %> -<% end %> - + +<% object = [] %> +<% object << 'course' %> +<%= error_messages_for object %> +<% unless @course.new_record? %> +<%= render :partial => "avatar/avatar_form", :locals => {source: @course} %>
+<% end %> ++ + +
+ +<%= f.fields_for @course do |m| %> + <% unless @course.nil? %> ++
+ <%= l(:label_class_period) %> + * + <%= text_field_tag :class_period, @course.class_period, :placeholder => "在此输入课时", :maxlength => 5 %> + <%= l(:label_class_hour) %> + | +
+
+ <%= l(:label_class_period) %> + * + <%= text_field_tag :class_period, nil, :placeholder => "在此输入课时", :maxlength => 5 %><%= l(:label_class_hour) %> + | +
+
+ <% if @course != nil %>
+
|
+
+ + +
+ <%= l(:text_command) %> +<% end %> ++ + + + +
++ + <%= f.check_box :is_public, :style => "margin-left:10px;" %> + <%= l(:label_course_public_info) %> + +
+ +<%= wikitoolbar_for 'course_description' %> +<% @course.custom_field_values.each do |value| %> +<%= custom_field_tag_with_label :course, value %>
+<% end %> +<%= call_hook(:view_courses_form, :course => @course, :form => f) %> + + +<% unless @course.extra_frozen? %> + <% content_for :header_tags do %> + <%= javascript_include_tag 'course_identifier' %> + <% end %> +<% end %> + diff --git a/app/views/courses/_member_list.html.erb b/app/views/courses/_member_list.html.erb index a8a9e8085..edd04bc97 100644 --- a/app/views/courses/_member_list.html.erb +++ b/app/views/courses/_member_list.html.erb @@ -13,11 +13,8 @@ <% end %> - <% unless member.user.user_extensions.identity ==0 %> - - <%if @canShowCode%> - <%= content_tag "p", "#{l(:label_bidding_user_studentcode)}#{' : '}#{member.user.user_extensions.student_id}", :class => "nomargin avatar_name" %> - <% end %> + <%if @canShowCode%> + <%= content_tag "p", "#{l(:label_bidding_user_studentcode)}#{' : '}#{member.user.user_extensions.student_id}", :class => "nomargin avatar_name" %> <% end %>diff --git a/app/views/courses/settings/_members.html.erb b/app/views/courses/settings/_members.html.erb index a62a9c613..f685e4543 100644 --- a/app/views/courses/settings/_members.html.erb +++ b/app/views/courses/settings/_members.html.erb @@ -1,105 +1,92 @@ -<%= error_messages_for 'member' %> -<% - roles = Role.givable.all - roles = roles[3..5] - members = @course.member_principals.includes(:roles, :principal).all.sort -%> - -
<%= l(:label_user) %> | -<%= l(:label_role_plural) %> | -- <%= call_hook(:view_projects_settings_members_table_header, :course => @course) %> - | |
---|---|---|---|
- <%= link_to_user member.principal %> - | -
-
- <%= h member.roles.sort.collect(&:to_s).join(', ') %>
-
- <%= form_for(member, {:as => :membership, :remote => true,
- :url => course_memberships_path(member),:method => :put,
- :html => {:id => "member-#{member.id}-roles-form",
- :class => 'hol'}}
- ) do |f| %>
-
- <% roles.each do |role| %>
-
- - <%= submit_tag l(:button_change), :class => "small" %> - <%= link_to_function l(:button_cancel), - "$('#member-#{member.id}-roles').show(); $('#member-#{member.id}-roles-form').hide(); return false;" - %> - - <% end %> - |
-
- <% if member.roles.first.to_s == "Manager" %>
- - <% else %> - | - <%= link_to_function l(:button_edit), - "$('#member-#{member.id}-roles').hide(); $('#member-#{member.id}-roles-form').show(); return false;", - :class => 'icon icon-edit' %> - <%= delete_link membership_path(member), - :remote => true, - :data => (!User.current.admin? && member.include?(User.current) ? {:confirm => l(:text_own_membership_delete_confirmation)} : {}) if member.deletable? %> - | - <% end %> - - <%= call_hook(:view_projects_settings_members_table_header, {:course => @course, :member => member}) %> -
<%= l(:label_no_data) %>
- <% end %> -<%= l(:label_user) %> | +<%= l(:label_role_plural) %> | ++ <%= call_hook(:view_projects_settings_members_table_header, :course => @course) %> + | |
---|---|---|---|
<%= link_to_user member.principal %> | +
+
+ <%= h member.roles.sort.collect(&:to_s).join(', ') %>
+
+ <%= form_for(member, {:as => :membership, :remote => true, :url => membership_path(member),
+ :method => :put,
+ :html => {:id => "member-#{member.id}-roles-form", :class => 'hol'}}
+ ) do |f| %>
+
+ <% roles.each do |role| %>
+ <%= submit_tag l(:button_change), :class => "small" %> + <%= link_to_function l(:button_cancel), + "$('#member-#{member.id}-roles').show(); $('#member-#{member.id}-roles-form').hide(); return false;" + %> + <% end %> + |
+
+ <% if member.roles.first.to_s == "Manager" %>
+ + <% else %> + | + <%= link_to_function l(:button_edit), + "$('#member-#{member.id}-roles').hide(); $('#member-#{member.id}-roles-form').show(); return false;", + :class => 'icon icon-edit' %> + <%= delete_link membership_path(member), + :remote => true, + :data => (!User.current.admin? && member.include?(User.current) ? {:confirm => l(:text_own_membership_delete_confirmation)} : {}) if member.deletable? %> + | + <% end %> + + <%= call_hook(:view_projects_settings_members_table_header, {:course => @course, :member => member}) %> +
<%= l(:label_no_data) %>
+ <% end %> +<%= f.text_area 'user_message', :rows => 3, :cols => 65, :value => "#{l(:label_leave_a_message)}", + | + <%= f.text_area 'user_message', :rows => 3, :cols => 65, + :value => "#{comprehensive_evaluation.nil? ? l(:label_leave_a_message) : comprehensive_evaluation}", :onfocus => "clearInfo('new_form_user_message','#{l(:label_leave_a_message)}')", :onblur => "showInfo('new_form_user_message','#{l(:label_leave_a_message)}')", - :style => "resize: none;", :class => 'noline'%> | + :style => "resize: none;", :class => 'noline'%> +
<%= notice %>
-<%= authoring @journal.created_on, @journal.user, :label => :label_updated_time_by %>
-<%= f.text_field :name, :required => true %>
-<%= f.check_box :assignable %>
-<% end %> -<%= f.select :issues_visibility, Role::ISSUES_VISIBILITY_OPTIONS.collect {|v| [l(v.last), v.first]} %>
-<% if @role.new_record? && @roles.any? %> --<%= select_tag(:copy_workflow_from, content_tag("option") + options_from_collection_for_select(@roles, :id, :name, params[:copy_workflow_from] || @copy_from.try(:id))) %>
-<% end %> -<%= f.text_field :name, :required => true %>
+<%= f.check_box :assignable %>
+<% end %> +<%= f.select :issues_visibility, Role::ISSUES_VISIBILITY_OPTIONS.collect {|v| [l(v.last), v.first]} %>
+<% if @role.new_record? && @roles.any? %> ++<%= select_tag(:copy_workflow_from, content_tag("option") + options_from_collection_for_select(@roles, :id, :name, params[:copy_workflow_from] || @copy_from.try(:id))) %>
+<% end %> +<%=l(:label_permissions)%> | - <% @roles.each do |role| %> -- <%= content_tag(role.builtin? ? 'em' : 'span', h(role.name)) %> - <%= link_to_function(image_tag('toggle_check.png'), "toggleCheckboxesBySelector('input.role-#{role.id}')", - :title => "#{l(:button_check_all)}/#{l(:button_uncheck_all)}") %> - | - <% end %> -
---|---|
- <%= link_to_function(image_tag('toggle_check.png'), "toggleCheckboxesBySelector('.permission-#{permission.name} input')", - :title => "#{l(:button_check_all)}/#{l(:button_uncheck_all)}") %> - <%= l_or_humanize(permission.name, :prefix => 'permission_') %> - | - <% @roles.each do |role| %> -- <% if role.setable_permissions.include? permission %> - <%= check_box_tag "permissions[#{role.id}][]", permission.name, (role.permissions.include? permission.name), :id => nil, :class => "role-#{role.id}" %> - <% end %> - | - <% end %> -
- | - <% @roles.each do |role| %> - - <%= l(:label_project) %> -<%= h(role.name) %> | - <% end %> -
- <%= link_to_function(image_tag('toggle_check.png'), "toggleCheckboxesBySelector('.permission-#{permission.name} input')", - :title => "#{l(:button_check_all)}/#{l(:button_uncheck_all)}") %> - <%= l_or_humanize(permission.name, :prefix => 'permission_') %> - | - <% @roles.each do |role| %> -- <% if role.setable_permissions.include? permission %> - <%= check_box_tag "permissions[#{role.id}][]", permission.name, (role.permissions.include? permission.name), :id => nil, :class => "role-#{role.id}" %> - <% end %> - | - <% end %> -
- | - <% @roles.each do |role| %> - - <%= l(:label_course) %> -<%= h(role.name) %> | - <% end %> -
- <%= link_to_function(image_tag('toggle_check.png'), "toggleCheckboxesBySelector('.permission-#{permission.name} input')", - :title => "#{l(:button_check_all)}/#{l(:button_uncheck_all)}") %> - <%= l_or_humanize(permission.name, :prefix => 'permission_') %> - | - <% @roles.each do |role| %> -- <% if role.setable_permissions.include? permission %> - <%= check_box_tag "permissions[#{role.id}][]", permission.name, (role.permissions.include? permission.name), :id => nil, :class => "role-#{role.id}" %> - <% end %> - | - <% end %> -
- | - <% @roles.each do |role| %> - - <%= l(:label_contest) %> -<%= h(role.name) %> | - <% end %> -
- <%= link_to_function(image_tag('toggle_check.png'), "toggleCheckboxesBySelector('.permission-#{permission.name} input')", - :title => "#{l(:button_check_all)}/#{l(:button_uncheck_all)}") %> - <%= l_or_humanize(permission.name, :prefix => 'permission_') %> - | - <% @roles.each do |role| %> -- <% if role.setable_permissions.include? permission %> - <%= check_box_tag "permissions[#{role.id}][]", permission.name, (role.permissions.include? permission.name), :id => nil, :class => "role-#{role.id}" %> - <% end %> - | - <% end %> -
- | - <% @roles.each do |role| %> - - <%= l_or_humanize(mod, :prefix => 'project_module_') %> -<%= h(role.name) %> | - <% end %> -
- <%= link_to_function(image_tag('toggle_check.png'), "toggleCheckboxesBySelector('.permission-#{permission.name} input')", - :title => "#{l(:button_check_all)}/#{l(:button_uncheck_all)}") %> - <%= l_or_humanize(permission.name, :prefix => 'permission_') %> - | - <% @roles.each do |role| %> -- <% if role.setable_permissions.include? permission %> - <%= check_box_tag "permissions[#{role.id}][]", permission.name, (role.permissions.include? permission.name), :id => nil, :class => "role-#{role.id}" %> - <% end %> - | - <% end %> -
<%= check_all_links 'permissions_form' %>
-<%= submit_tag l(:button_save) %>
-<% end %> +<%=l(:label_permissions)%> | + <% @roles.each do |role| %> ++ <%= content_tag(role.builtin? ? 'em' : 'span', h(role.name)) %> + <%= link_to_function(image_tag('toggle_check.png'), "toggleCheckboxesBySelector('input.role-#{role.id}')", + :title => "#{l(:button_check_all)}/#{l(:button_uncheck_all)}") %> + | + <% end %> +
---|---|
+ <%= link_to_function(image_tag('toggle_check.png'), "toggleCheckboxesBySelector('.permission-#{permission.name} input')", + :title => "#{l(:button_check_all)}/#{l(:button_uncheck_all)}") %> + <%= l_or_humanize(permission.name, :prefix => 'permission_') %> + | + <% @roles.each do |role| %> ++ <% if role.setable_permissions.include? permission %> + <%= check_box_tag "permissions[#{role.id}][]", permission.name, (role.permissions.include? permission.name), :id => nil, :class => "role-#{role.id}" %> + <% end %> + | + <% end %> +
+ | + <% @roles.each do |role| %> + + <%= l(:label_project) %> +<%= h(role.name) %> | + <% end %> +
+ <%= link_to_function(image_tag('toggle_check.png'), "toggleCheckboxesBySelector('.permission-#{permission.name} input')", + :title => "#{l(:button_check_all)}/#{l(:button_uncheck_all)}") %> + <%= l_or_humanize(permission.name, :prefix => 'permission_') %> + | + <% @roles.each do |role| %> ++ <% if role.setable_permissions.include? permission %> + <%= check_box_tag "permissions[#{role.id}][]", permission.name, (role.permissions.include? permission.name), :id => nil, :class => "role-#{role.id}" %> + <% end %> + | + <% end %> +
+ | + <% @roles.each do |role| %> + + <%= l(:label_course) %> +<%= h(role.name) %> | + <% end %> +
+ <%= link_to_function(image_tag('toggle_check.png'), "toggleCheckboxesBySelector('.permission-#{permission.name} input')", + :title => "#{l(:button_check_all)}/#{l(:button_uncheck_all)}") %> + <%= l_or_humanize(permission.name, :prefix => 'permission_') %> + | + <% @roles.each do |role| %> ++ <% if role.setable_permissions.include? permission %> + <%= check_box_tag "permissions[#{role.id}][]", permission.name, (role.permissions.include? permission.name), :id => nil, :class => "role-#{role.id}" %> + <% end %> + | + <% end %> +
+ | + <% @roles.each do |role| %> + + <%= l(:label_contest) %> +<%= h(role.name) %> | + <% end %> +
+ <%= link_to_function(image_tag('toggle_check.png'), "toggleCheckboxesBySelector('.permission-#{permission.name} input')", + :title => "#{l(:button_check_all)}/#{l(:button_uncheck_all)}") %> + <%= l_or_humanize(permission.name, :prefix => 'permission_') %> + | + <% @roles.each do |role| %> ++ <% if role.setable_permissions.include? permission %> + <%= check_box_tag "permissions[#{role.id}][]", permission.name, (role.permissions.include? permission.name), :id => nil, :class => "role-#{role.id}" %> + <% end %> + | + <% end %> +
+ | + <% @roles.each do |role| %> + + <%= l_or_humanize(mod, :prefix => 'project_module_') %> +<%= h(role.name) %> | + <% end %> +
+ <%= link_to_function(image_tag('toggle_check.png'), "toggleCheckboxesBySelector('.permission-#{permission.name} input')", + :title => "#{l(:button_check_all)}/#{l(:button_uncheck_all)}") %> + <%= l_or_humanize(permission.name, :prefix => 'permission_') %> + | + <% @roles.each do |role| %> ++ <% if role.setable_permissions.include? permission %> + <%= check_box_tag "permissions[#{role.id}][]", permission.name, (role.permissions.include? permission.name), :id => nil, :class => "role-#{role.id}" %> + <% end %> + | + <% end %> +
<%= check_all_links 'permissions_form' %>
+<%= submit_tag l(:button_save) %>
+<% end %> diff --git a/app/views/tags/_show_forums.html.erb b/app/views/tags/_show_forums.html.erb index c6dd8a2ed..3caba4903 100644 --- a/app/views/tags/_show_forums.html.erb +++ b/app/views/tags/_show_forums.html.erb @@ -6,7 +6,7 @@ <%= l(:label_tags_forum) %>:<%= link_to "#{forum.name}", :controller => "forums",:action => "show",:id => forum.id %>