diff --git a/app/controllers/at_controller.rb b/app/controllers/at_controller.rb index 25e731754..456306c64 100644 --- a/app/controllers/at_controller.rb +++ b/app/controllers/at_controller.rb @@ -34,6 +34,12 @@ class AtController < ApplicationController find_homework(id) when 'Topic' find_topic(id) + when 'JournalsForMessage' + find_journals_for_message(id) + when 'Principal' + find_principal(id) + when 'All' + nil else nil end @@ -120,7 +126,11 @@ class AtController < ApplicationController #JournalsForMessage def find_journals_for_message(id) jounrnal = JournalsForMessage.find(id) - find_at_users(jounrnal.jour_type, jounrnal.jour_id) + if jounrnal.jour_type == 'Principal' + [jounrnal.user] + (JournalsForMessage.where(m_reply_id: id).map(&:user) || []) + else + find_at_users(jounrnal.jour_type, jounrnal.jour_id) + end end #Poll @@ -129,8 +139,6 @@ class AtController < ApplicationController #Journal def find_journal(id) - journal = Journal.find(id) - find_at_users(journal.journalized_type, journal.journalized_id) end #Document @@ -145,7 +153,6 @@ class AtController < ApplicationController #Principal def find_principal(id) - end #BlogComment diff --git a/app/controllers/blog_comments_controller.rb b/app/controllers/blog_comments_controller.rb index 87bbcb2f3..f5e3314bb 100644 --- a/app/controllers/blog_comments_controller.rb +++ b/app/controllers/blog_comments_controller.rb @@ -55,8 +55,8 @@ class BlogCommentsController < ApplicationController if params[:in_act] redirect_to user_path(params[:user_id]) else - if params[:is_homepage] - redirect_to user_blogs_path(params[:user_id]) + if @article.id.eql?(User.find(params[:user_id]).blog.homepage_id) + redirect_to user_path(params[:user_id]) else redirect_to user_blog_blog_comment_path(:user_id=>params[:user_id],:blog_id=>params[:blog_id],:id=>params[:id]) end diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index 43a49c7d9..97dacb178 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -321,11 +321,12 @@ class CoursesController < ApplicationController def export_course_member_excel @all_members = student_homework_score(0,0,0,"desc") + @homeworks = @course.homework_commons.order("created_at desc") filename="#{@course.teacher.lastname.to_s + @course.teacher.firstname.to_s }_#{@course.name}_#{@course.time.to_s + @course.term}#{l(:excel_member_list)}"; respond_to do |format| format.xls { - send_data(member_to_xls(@all_members,@course.course_groups), :type => "text/excel;charset=utf-8; header=present", + send_data(member_to_xls(@homeworks,@course,@all_members,@course.course_groups), :type => "text/excel;charset=utf-8; header=present", :filename => filename_for_content_disposition("#{filename}.xls")) } end @@ -441,7 +442,10 @@ class CoursesController < ApplicationController @course = cs.create_course(params,User.current)[:course] if params[:copy_course] copy_course = Course.find params[:copy_course].to_i - @course.update_attributes(:open_student => copy_course.open_student, :publish_resource => copy_course.publish_resource) + @course.is_copy = 1 + @course.open_student = copy_course.open_student + @course.publish_resource = copy_course.publish_resource + @course.save if params[:checkAll] attachments = copy_course.attachments attachments.each do |attachment| @@ -903,6 +907,17 @@ class CoursesController < ApplicationController return 404 end end + #搜索作业 + def homework_search + @search = "%#{params[:search].strip.downcase}%" + @is_teacher = User.current.logged? && (User.current.admin? || User.current.allowed_to?(:as_teacher,@course)) + @page = params[:page] ? params[:page].to_i + 1 : 0 + if @is_teacher + @homeworks = @course.homework_commons.where("name like '%#{@search}%'").order("created_at desc").limit(10).offset(@page * 10) + else + @homeworks = @course.homework_commons.where("name like '%#{@search}%' and publish_time <= '#{Date.today}'").order("created_at desc").limit(10).offset(@page * 10) + end + end private def update_quotes attachment @@ -960,7 +975,7 @@ class CoursesController < ApplicationController sql_select = "" if groupid == 0 sql_select = "SELECT members.*,( - SELECT SUM(student_works.final_score) + SELECT SUM(IF(student_works.final_score is null,null,student_works.final_score - student_works.absence_penalty - student_works.late_penalty)) FROM student_works,homework_commons WHERE student_works.homework_common_id = homework_commons.id AND homework_commons.course_id = #{@course.id} @@ -972,7 +987,7 @@ class CoursesController < ApplicationController WHERE members.course_id = #{@course.id} ORDER BY score #{score_sort_by}" else sql_select = "SELECT members.*,( - SELECT SUM(student_works.final_score) + SELECT SUM(IF(student_works.final_score is null,null,student_works.final_score - student_works.absence_penalty - student_works.late_penalty)) FROM student_works,homework_commons WHERE student_works.homework_common_id = homework_commons.id AND homework_commons.course_id = #{@course.id} @@ -1006,16 +1021,54 @@ class CoursesController < ApplicationController end - def member_to_xls members,groups + def member_to_xls homeworks, course, members,groups xls_report = StringIO.new book = Spreadsheet::Workbook.new sheet1 = book.create_worksheet :name => "student" - blue = Spreadsheet::Format.new :color => :blue, :weight => :bold, :size => 10 - sheet1.row(0).default_format = blue + #sheet1.row(0).default_format = blue + #sheet1.row(0).concat([l(:excel_user_id),l(:excel_user_name),l(:excel_nickname),l(:excel_student_id),l(:excel_mail),l(:excel_class),l(:excel_f_score),l(:excel_commit_time)]) + sheet1[0,0] = "课程编号" + sheet1[0,1] = course.id + sheet1[1,0] = "课程学期" + sheet1[1,1] = course.time.to_s+"年"+course.term + sheet1[2,0] = "课程名称" + sheet1[2,1] = course.name + sheet1[3,0] = "教师团队" + sheet1[3,1] = (searchTeacherAndAssistant course).map{|member| member.user.show_name}.join('、') + sheet1[4,0] = "主讲教师" + sheet1[4,1] = course.teacher.show_name + sheet1[5,0] = "排名" + sheet1[5,1] = "学生姓名" + sheet1[5,2] = "昵称" + sheet1[5,3] = "学号" + for i in 0 ... homeworks.count + sheet1[5,i+4] = "第"+(i+1).to_s+"次" + end + sheet1[5,homeworks.count+4] = "总成绩" + sheet1[5,0] = "排名" + sheet1[5,0] = "排名" + count_row = 6 + members.each_with_index do |member, i| + sheet1[count_row,0]= i+1 + sheet1[count_row,1] = member.user.lastname.to_s + member.user.firstname.to_s + sheet1[count_row,2] = member.user.login + sheet1[count_row,3] = member.user.user_extensions.student_id + homeworks.each_with_index do |homework, j| + student_works = homework.student_works.where("user_id = #{member.user.id}") + if student_works.empty? + sheet1[count_row,j+4] = format("%0.2f",0) + else + final_score = student_works.first.final_score.nil? ? 0 : student_works.first.final_score + score = final_score - student_works.first.absence_penalty - student_works.first.late_penalty + sheet1[count_row,j+4] = format("%0.2f",score <0 ? 0:score) + end + end + sheet1[count_row,homeworks.count+4] = format("%0.2f",member.score.nil? ? 0:member.score.to_s) + count_row += 1 + end - sheet1.row(0).concat([l(:excel_user_id),l(:excel_user_name),l(:excel_nickname),l(:excel_student_id),l(:excel_mail),l(:excel_homework_score)]) - count_row = 1 +=begin group0 = CourseGroup.new(); group0.id = 0; group0.name = l(:excel_member_with_out_class) @@ -1037,6 +1090,7 @@ class CoursesController < ApplicationController end end end +=end book.write xls_report xls_report.string end diff --git a/app/controllers/homework_common_controller.rb b/app/controllers/homework_common_controller.rb index d345fba5f..398b385a4 100644 --- a/app/controllers/homework_common_controller.rb +++ b/app/controllers/homework_common_controller.rb @@ -15,8 +15,12 @@ class HomeworkCommonController < ApplicationController @new_homework.homework_detail_manual = HomeworkDetailManual.new @new_homework.course = @course @page = params[:page] ? params[:page].to_i + 1 : 0 - @homeworks = @course.homework_commons.order("created_at desc").limit(10).offset(@page * 10) @is_teacher = User.current.logged? && (User.current.admin? || User.current.allowed_to?(:as_teacher,@course)) + if @is_teacher + @homeworks = @course.homework_commons.order("created_at desc").limit(10).offset(@page * 10) + else + @homeworks = @course.homework_commons.where("publish_time <= '#{Date.today}'").order("created_at desc").limit(10).offset(@page * 10) + end @is_student = User.current.logged? && (User.current.admin? || (User.current.member_of_course?(@course) && !@is_teacher)) @is_new = params[:is_new] diff --git a/app/controllers/org_subfields_controller.rb b/app/controllers/org_subfields_controller.rb index d051a91f7..bae0232a5 100644 --- a/app/controllers/org_subfields_controller.rb +++ b/app/controllers/org_subfields_controller.rb @@ -109,7 +109,8 @@ class OrgSubfieldsController < ApplicationController if SubfieldSubdomainDir.find_by_sql(sql).count == 0 if @org_subfield.subfield_subdomain_dir @sub_dir = @org_subfield.subfield_subdomain_dir - @sub_dir.update_attribute(:name, params[:sub_dir_name]) + @sub_dir = SubfieldSubdomainDir.update(@sub_dir.id, :name => params[:sub_dir_name]) + #@sub_dir.update_attribute(:name, params[:sub_dir_name]) else @sub_dir = SubfieldSubdomainDir.create(:org_subfield_id => @org_subfield.id, :name => params[:sub_dir_name]) end diff --git a/app/controllers/organizations_controller.rb b/app/controllers/organizations_controller.rb index 85fc42f66..6e2da311f 100644 --- a/app/controllers/organizations_controller.rb +++ b/app/controllers/organizations_controller.rb @@ -302,7 +302,7 @@ class OrganizationsController < ApplicationController def org_resources_subfield @org = Organization.find(params[:id]) - if params[:send_type].present? and params[:send_type] == 'news' + if params[:send_type].present? and (params[:send_type] == 'news' or params[:send_type] == 'message') @subfield = @org.org_subfields.where("field_type = 'Post'") else @subfield = @org.org_subfields.where('field_type = "Resource" ') diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index b155e9f90..22b58fe49 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -403,8 +403,47 @@ class UsersController < ApplicationController #导入作业 def user_import_homeworks + @user = User.current @select_course = params[:select_course] ? 1 : 0 - @user_homeworks = HomeworkCommon.where(:user_id => @user.id).order("created_at desc") + #@user_homeworks = HomeworkCommon.where(:user_id => @user.id).order("created_at desc") + visible_course = Course.where("is_public = 1 && is_delete = 0") + visible_course_ids = visible_course.empty? ? "(-1)" : "(" + visible_course.map{|course| course.id}.join(",") + ")" + @homeworks = HomeworkCommon.where("course_id in #{visible_course_ids} and publish_time <= '#{Date.today}'").order("created_at desc") + @type = params[:type] + @limit = 15 + @is_remote = true + @hw_count = @homeworks.count + @hw_pages = Paginator.new @hw_count, @limit, params['page'] || 1 + @offset ||= @hw_pages.offset + @homeworks = paginateHelper @homeworks,15 + respond_to do |format| + format.js + end + end + + def user_homework_type + @user = User.current + if(params[:type].blank? || params[:type] == "1") #公共题库 + visible_course = Course.where("is_public = 1 && is_delete = 0") + visible_course_ids = visible_course.empty? ? "(-1)" : "(" + visible_course.map{|course| course.id}.join(",") + ")" + @homeworks = HomeworkCommon.where("course_id in #{visible_course_ids} and publish_time <= '#{Date.today}'").order("created_at desc") + elsif params[:type] == "2" #我的题库 + @homeworks = HomeworkCommon.where("user_id = #{@user.id} and publish_time <= '#{Date.today}'").order("created_at desc") + end + @type = params[:type] + @limit = 15 + @is_remote = true + @hw_count = @homeworks.count + @hw_pages = Paginator.new @hw_count, @limit, params['page'] || 1 + @offset ||= @hw_pages.offset + @homeworks = paginateHelper @homeworks,15 + respond_to do |format| + format.js + end + end + + def show_homework_detail + @homework = HomeworkCommon.find params[:homework].to_i respond_to do |format| format.js end @@ -412,7 +451,22 @@ class UsersController < ApplicationController #用户主页过滤作业 def user_search_homeworks - @user_homeworks = HomeworkCommon.where("user_id = '#{@user.id}' and lower(name) like '%#{params[:name].to_s.downcase}%'").order("created_at desc") + @user = User.current + search = params[:name].to_s.strip.downcase + if(params[:type].blank? || params[:type] == "1") #全部 + visible_course = Course.where("is_public = 1 && is_delete = 0") + visible_course_ids = visible_course.empty? ? "(-1)" : "(" + visible_course.map{|course| course.id}.join(",") + ")" + @homeworks = HomeworkCommon.where("course_id in #{visible_course_ids} and publish_time <= '#{Date.today}'} and (name like '%#{search}%')").order("created_at desc") + elsif params[:type] == "2" #课程资源 + @homeworks = HomeworkCommon.where("user_id = #{@user.id} and publish_time <= '#{Date.today}'").order("created_at desc") + end + @type = params[:type] + @limit = 15 + @is_remote = true + @hw_count = @homeworks.count + @hw_pages = Paginator.new @hw_count, @limit, params['page'] || 1 + @offset ||= @hw_pages.offset + @homeworks = paginateHelper @homeworks,15 respond_to do |format| format.js end @@ -426,6 +480,7 @@ class UsersController < ApplicationController @homework = HomeworkCommon.new @select_course = params[:select_course] || 0 if homework + @ref_homework = homework @homework.name = homework.name @homework.description = homework.description @homework.end_time = homework.end_time @@ -583,13 +638,15 @@ class UsersController < ApplicationController homework_detail_manual.save if homework_detail_manual homework_detail_programing.save if homework_detail_programing homework_detail_group.save if homework_detail_group - + if params[:quotes] && !params[:quotes].blank? + homework = HomeworkCommon.find params[:quotes].to_i + homework.update_attribute(:quotes, homework.quotes+1) + end if params[:is_in_course] == "1" redirect_to homework_common_index_path(:course => homework.course_id) else redirect_to user_homeworks_user_path(User.current.id) end - end end else @@ -755,23 +812,17 @@ class UsersController < ApplicationController if params[:type].present? case params[:type] when "public" - jours = @user.journals_for_messages.where('m_parent_id IS NULL and private = 0').order('created_on DESC') - @jour_count = jours.count - @jour = jours.limit(10).offset(@page * 10) + jours = @user.journals_for_messages.where('m_parent_id IS NULL and private = 0').order('updated_on DESC') when "private" - jours = @user.journals_for_messages.where('m_parent_id IS NULL and private = 1').order('created_on DESC') - @jour_count = jours.count - @jour = jours.limit(10).offset(@page * 10) + jours = @user.journals_for_messages.where('m_parent_id IS NULL and private = 1').order('updated_on DESC') else - jours = @user.journals_for_messages.where('m_parent_id IS NULL').order('created_on DESC') - @jour_count = jours.count - @jour = jours.limit(10).offset(@page * 10) + jours = @user.journals_for_messages.where('m_parent_id IS NULL').order('updated_on DESC') end else - jours = @user.journals_for_messages.where('m_parent_id IS NULL').order('created_on DESC') - @jour_count = jours.count - @jour = jours.limit(10).offset(@page * 10) + jours = @user.journals_for_messages.where('m_parent_id IS NULL').order('updated_on DESC') end + @jour_count = jours.count + @jour = jours.limit(10).offset(@page * 10) @type = params[:type] if User.current == @user jours.update_all(:is_readed => true, :status => false) @@ -1633,6 +1684,10 @@ class UsersController < ApplicationController attach_copied_obj.attachtype = 1 end attach_copied_obj.save + unless Project.find(project_id).project_score.nil? + Project.find(project_id).project_score.update_attribute(:attach_num, + Project.find(project_id).project_score.attach_num + 1) + end end end elsif params[:send_ids].present? @@ -1668,6 +1723,9 @@ class UsersController < ApplicationController attach_copied_obj.attachtype = 1 end attach_copied_obj.save + unless Project.find(project_id).project_score.nil? + Project.find(project_id).project_score.update_attribute(:attach_num, Project.find(project_id).project_score.attach_num + 1) + end end end end @@ -1796,16 +1854,6 @@ class UsersController < ApplicationController def share_news_to_project news = News.find(params[:send_id]) project_ids = params[:project_ids] - # project_ids.each do |project_id| - # if Project.find(project_id).news.map(&:id).exclude?(news.id) - # project_news = News.create(:project_id => project_id.to_i, :title => news.title, :summary => news.summary, :description => news.description,:author_id => User.current.id, :created_on => Time.now) - # news.attachments.each do |attach| - # project_news.attachments << Attachment.new(:filename => attach.filename, :disk_filename => attach.disk_filename, :filesize => attach.filesize, :content_type => attach.content_type, :digest => attach.digest, - # :downloads => 0, :author_id => User.current.id, :created_on => Time.now, :description => attach.description, :disk_directory => attach.disk_directory, :attachtype => attach.attachtype, - # :is_public => attach.is_public, :quotes => 0) - # end - # end - # end project_ids.each do |project_id| project = Project.find(project_id) if project.news.map(&:id).exclude?(news.id) @@ -1831,6 +1879,53 @@ class UsersController < ApplicationController OrgActivity.create(:container_type => 'OrgSubfield', :container_id => field_id.to_i, :org_act_type=>'News', :org_act_id => org_news.id, :user_id => User.current.id) end + def share_message_to_course + @message = Message.find(params[:send_id]) + course_ids = params[:course_ids] + course_ids.each do |course_id| + course = Course.find(course_id) + if course.news.map(&:id).exclude?(@message.id) + message = Message.create(:board_id => course.boards.first.id, :subject => @message.subject, :content => @message.content, :author_id => User.current.id) + @message.attachments.each do |attach| + message.attachments << Attachment.new(:filename => attach.filename, :disk_filename => attach.disk_filename, :filesize => attach.filesize, :content_type => attach.content_type, :digest => attach.digest, + :downloads => 0, :author_id => User.current.id, :created_on => Time.now, :description => attach.description, :disk_directory => attach.disk_directory, :attachtype => attach.attachtype, + :is_public => attach.is_public, :quotes => 0) + end + end + end + end + + def share_message_to_project + @message = Message.find(params[:send_id]) + project_ids = params[:project_ids] + project_ids.each do |project_id| + project = Project.find(project_id) + if project.news.map(&:id).exclude?(@message.id) + message = Message.create(:board_id => project.boards.first.id, :subject => @message.subject, :content => @message.content, :author_id => User.current.id) + @message.attachments.each do |attach| + message.attachments << Attachment.new(:filename => attach.filename, :disk_filename => attach.disk_filename, :filesize => attach.filesize, :content_type => attach.content_type, :digest => attach.digest, + :downloads => 0, :author_id => User.current.id, :created_on => Time.now, :description => attach.description, :disk_directory => attach.disk_directory, :attachtype => attach.attachtype, + :is_public => attach.is_public, :quotes => 0) + end + end + end + end + + def share_message_to_org + field_id = params[:subfield] + @message = Message.find(params[:send_id]) + @message.quotes = @message.quotes.nil? ? 1 : (@message.quotes + 1) + @message.save + board = OrgSubfield.find(field_id).boards.first + mes = Message.create(:board_id => board.id, :subject => @message.subject, :content => @message.content, :author_id => User.current.id) + @message.attachments.each do |attach| + mes.attachments << Attachment.new(:filename => attach.filename, :disk_filename => attach.disk_filename, :filesize => attach.filesize, :content_type => attach.content_type, :digest => attach.digest, + :downloads => 0, :author_id => User.current.id, :created_on => Time.now, :description => attach.description, :disk_directory => attach.disk_directory, :attachtype => attach.attachtype, + :is_public => attach.is_public, :quotes => 0) + end + OrgActivity.create(:container_type => 'OrgSubfield', :container_id => field_id.to_i, :org_act_type=>'Message', :org_act_id => mes.id, :user_id => User.current.id) + end + def change_org_subfield end @@ -2072,9 +2167,9 @@ class UsersController < ApplicationController end elsif params[:type] == "4" #附件 if User.current.id.to_i == params[:id].to_i - @attachments = Attachment.where("author_id = #{params[:id]} and container_type in('Issue','Document','Message','News','StudentWorkScore','HomewCommon')").order("created_on desc") + @attachments = Attachment.where("author_id = #{params[:id]} and container_type in('Issue','Document','Message','News','StudentWorkScore','HomewCommon','OrgSubfield','Principal')").order("created_on desc") else - @attachments = Attachment.where("author_id = #{params[:id]} and is_public = 1 and container_type in('Issue','Document','Message','News','StudentWorkScore','HomewCommon')").order("created_on desc") + @attachments = Attachment.where("author_id = #{params[:id]} and is_public = 1 and container_type in('Issue','Document','Message','News','StudentWorkScore','HomewCommon','OrgSubfield','Principal')").order("created_on desc") end elsif params[:type] == "5" #用户资源 if User.current.id.to_i == params[:id].to_i @@ -2180,7 +2275,7 @@ class UsersController < ApplicationController @user = User.current if !params[:search].nil? #发送到有栏目类型为资源的组织中 search = "%#{params[:search].to_s.strip.downcase}%" - if params[:send_type].present? and params[:send_type] == 'news' + if params[:send_type].present? and (params[:send_type] == 'news' or params[:send_type] == 'message') @orgs = @user.organizations.where("name like ?", search).select{|org| OrgSubfield.where("organization_id = #{org.id} and field_type='Post'").count > 0} else @orgs = @user.organizations.where("name like ?", search).select{|org| OrgSubfield.where("organization_id = #{org.id} and field_type='Resource'").count > 0} diff --git a/app/controllers/words_controller.rb b/app/controllers/words_controller.rb index d24427a9d..351be4e64 100644 --- a/app/controllers/words_controller.rb +++ b/app/controllers/words_controller.rb @@ -62,6 +62,7 @@ class WordsController < ApplicationController update_forge_activity('JournalsForMessage',parent_id) update_org_activity('JournalsForMessage',parent_id) update_principal_activity('JournalsForMessage',parent_id) + (JournalsForMessage.find parent_id).update_attribute(:updated_on,Time.now) end respond_to do |format| # format.html { @@ -73,7 +74,6 @@ class WordsController < ApplicationController # render 'test/index' # } format.js { - @reply_type = params[:reply_type] @user_activity_id = params[:user_activity_id] @activity = JournalsForMessage.find(parent_id) @is_activity = params[:is_activity] @@ -95,6 +95,9 @@ class WordsController < ApplicationController @user = User.find(@journal_destroyed.jour_id) @jours_count = @user.journals_for_messages.where('m_parent_id IS NULL').count @is_user = true + @user_activity_id = params[:user_activity_id] if params[:user_activity_id] + @is_activity = params[:is_activity].to_i if params[:is_activity] + @activity = @journal_destroyed.parent if @journal_destroyed.parent elsif @journal_destroyed.jour_type == 'HomeworkCommon' @homework = HomeworkCommon.find @journal_destroyed.jour_id if params[:user_activity_id] diff --git a/app/helpers/courses_helper.rb b/app/helpers/courses_helper.rb index 4e90fc106..1e4cedf14 100644 --- a/app/helpers/courses_helper.rb +++ b/app/helpers/courses_helper.rb @@ -697,17 +697,16 @@ module CoursesHelper def join_in_course_header(course, user, options=[]) if user.logged? joined = course.members.map{|member| member.user_id}.include? user.id - text = joined ? ("".html_safe + l(:label_course_exit_student)) : ("".html_safe + l(:label_course_join_student)) + text = joined ? l(:label_course_exit_student) : l(:label_course_join_student) url = joined ? join_path(:object_id => course.id) : try_join_path(:object_id => course.id) method = joined ? 'delete' : 'post' if joined - link = "#{l(:label_course_join_student)}" + link_to(text, url, :remote => true, :method => method, :class => "pr_join_a", :id => "#{course.id}", :confirm => l(:text_are_you_sure_out)) + link = link_to(text, url, :remote => true, :method => method, :class => "pr_join_a", :id => "#{course.id}", :confirm => l(:text_are_you_sure_out)) else - link = link_to(text, url, :remote => true, :method => method, :id => "#{course.id}", :class => "pr_join_a") + "#{l(:label_course_exit_student)}".html_safe + link = link_to(text, url, :remote => true, :method => method, :id => "#{course.id}", :class => "pr_join_a") end else - link = "#{l(:label_course_join_student)}" + - "#{l(:label_course_exit_student)}" + link = "#{l(:label_course_join_student)}" end link.html_safe end @@ -796,7 +795,7 @@ module CoursesHelper # 学生按作业总分排序,取前8个 def hero_homework_score(course, score_sort_by) sql_select = "SELECT members.*,( - SELECT SUM(student_works.final_score) + SELECT SUM(IF(student_works.final_score is null,null,student_works.final_score - student_works.absence_penalty - student_works.late_penalty)) FROM student_works,homework_commons WHERE student_works.homework_common_id = homework_commons.id AND homework_commons.course_id = #{course.id} diff --git a/app/models/at_message.rb b/app/models/at_message.rb index 3d20ffafb..bca2c7ba4 100644 --- a/app/models/at_message.rb +++ b/app/models/at_message.rb @@ -47,7 +47,11 @@ class AtMessage < ActiveRecord::Base "回复帖子: " end + at_message.subject when 'JournalsForMessage' - "作业: #{at_message.jour.name} 中留言" + if at_message.jour_type == 'Principal' + "留言: 在#{at_message.at_user.show_name}主页中留言" + else + "作业: #{at_message.jour.name} 中留言" + end else logger.error "error type: #{at_message_type}" end @@ -92,7 +96,12 @@ class AtMessage < ActiveRecord::Base when 'Message' {controller: :boards, action: :show, project_id: at_message.board.project, id: at_message.board} when 'JournalsForMessage' - {controller: :homework_common, action: :index, course: at_message.jour.course_id} + if at_message.jour_type == 'Principal' + {controller: :users, action: :user_messages, id: at_message.at_user} + else + {controller: :homework_common, action: :index, course: at_message.jour.course_id} + end + else logger.error "error type: #{at_message_type}" end diff --git a/app/models/journals_for_message.rb b/app/models/journals_for_message.rb index 9e0ce2dd2..cdcf9d19e 100644 --- a/app/models/journals_for_message.rb +++ b/app/models/journals_for_message.rb @@ -70,7 +70,7 @@ class JournalsForMessage < ActiveRecord::Base validates :notes, presence: true, if: :is_homework_jour? after_create :act_as_activity, :act_as_course_activity, :act_as_course_message, :act_as_at_message, :act_as_user_feedback_message, :act_as_principal_activity, :act_as_student_score after_create :reset_counters! - after_update :update_ativity + #after_update :update_activity after_destroy :reset_counters! after_save :be_user_score after_destroy :down_user_score diff --git a/app/models/subfield_subdomain_dir.rb b/app/models/subfield_subdomain_dir.rb index 9897e19ac..2ec93fe05 100644 --- a/app/models/subfield_subdomain_dir.rb +++ b/app/models/subfield_subdomain_dir.rb @@ -1,4 +1,5 @@ class SubfieldSubdomainDir < ActiveRecord::Base # attr_accessible :title, :body belongs_to :org_subfield + validates_exclusion_of :name, :in => %w(setting members org_document_comments) end diff --git a/app/views/courses/_user_homework_search_list.html.erb b/app/views/courses/_user_homework_search_list.html.erb new file mode 100644 index 000000000..585d8761a --- /dev/null +++ b/app/views/courses/_user_homework_search_list.html.erb @@ -0,0 +1,46 @@ +<%= content_for(:header_tags) do %> + <%= import_ke(enable_at: true, prettify: false, init_activity: true) %> +<% end %> + + +
- 第<%= work.student_work_tests.count - index%>次测试 -
- - <%= test.created_at.to_s(:db) %> - - -+ 第<%= work.student_work_tests.count - index%>次测试 +
+ + <%= test.created_at.to_s(:db) %> + + +<%=x["result"]%>+ 正确输出: +
<%=x["output"]%>+ + <% else %> + 测试正确! + + <% end %> +
状态 :
- - <%= select( :issue,:status, [["新增",1],["正在解决",2],["已解决",3],["反馈",4],["关闭",5],["拒绝",6]].unshift(["状态",0]), - {:include_blank => false, :selected => @status_id ? @status_id : 0 }, - {:onchange=>"remote_function('#issue_query_form_#{activity.id}');",:id=>"status_id",:name=>"status_id",:class=>"w70 undis issueEdit"} - ) - %> -指派 :
- - <%= link_to activity.try(:assigned_to), user_path(activity.assigned_to_id), :class => "linkBlue hidden", :style => "max-width:50px; display:inline-block;" %> - - <%= select( :issue, :user_id, principals_options_for_isuue_list(activity.project), - { :include_blank => false,:selected => @assign_to_id ? @assign_to_id : 0}, - {:onchange=>"remote_function('#issue_query_assign_form_#{activity.id}');", :id =>"assigned_to_id", :name => "assigned_to_id",:class=>"w70 undis issueEdit"}) %> -优先级 :
- <%= activity.priority.name %> - <%= select( :issue,:prior, [["低",1],["正常",2],["高",3],["紧急",4],["立刻",5]].unshift(["优先级",0]), - {:include_blank => false,:selected=>@priority_id ? @priority_id : 0}, - {:onchange=>"remote_function('#issue_query_prior_form_#{activity.id}');",:id=>"priority_id",:name=>"priority_id",:class=>"w70 undis issueEdit"}) %> -完成度 :
- <%= activity.done_ratio %>% - <%= select( :issue,:done_ratio, ((0..10).to_a.collect { |r| ["#{r*10} %", r*10] }), - {:include_blank => false, :selected => @done_ratio ? @done_ratio : 0}, - {:onchange=>"remote_function('#issue_query_done_form_#{activity.id}');",:id=>"done_ratio",:name=>"done_ratio",:class=>"w70 undis issueEdit"}) %> - <% end %> -开始 :
-<%= format_date(activity.start_date) %>
-周期 :
- <%= l_hours(activity.estimated_hours) %>计划完成 :
- <%= format_date(activity.due_date)? format_date(activity.due_date) : "--" %>目标版本 :
- <%= (activity.fixed_version ? link_to_user_version(activity.fixed_version) : "--") %>状态 :
+ + <%= select( :issue,:status, [["新增",1],["正在解决",2],["已解决",3],["反馈",4],["关闭",5],["拒绝",6]].unshift(["状态",0]), + {:include_blank => false, :selected => @status_id ? @status_id : 0 }, + {:onchange=>"remote_function('#issue_query_form_#{activity.id}');",:id=>"status_id",:name=>"status_id",:class=>"w70 undis issueEdit",:style=>"white-space:nowrap; overflow:hidden;"} + ) + %> +指派 :
+ + <%= link_to activity.try(:assigned_to), user_path(activity.assigned_to_id), :class => "linkBlue hidden", :style => "max-width:100px; display:inline-block;" %> + + <%= select( :issue, :user_id, principals_options_for_isuue_list(activity.project), + { :include_blank => false,:selected => @assign_to_id ? @assign_to_id : 0}, + {:onchange=>"remote_function('#issue_query_assign_form_#{activity.id}');", :id =>"assigned_to_id", :name => "assigned_to_id",:class=>"undis issueEdit", :style => "width:130px;"}) %> +优先级 :
+ <%= activity.priority.name %> + <%= select( :issue,:prior, [["低",1],["正常",2],["高",3],["紧急",4],["立刻",5]].unshift(["优先级",0]), + {:include_blank => false,:selected=>@priority_id ? @priority_id : 0}, + {:onchange=>"remote_function('#issue_query_prior_form_#{activity.id}');",:id=>"priority_id",:name=>"priority_id",:class=>"w70 undis issueEdit"}) %> +完成度 :
+ <%= activity.done_ratio %>% + <%= select( :issue,:done_ratio, ((0..10).to_a.collect { |r| ["#{r*10} %", r*10] }), + {:include_blank => false, :selected => @done_ratio ? @done_ratio : 0}, + {:onchange=>"remote_function('#issue_query_done_form_#{activity.id}');",:id=>"done_ratio",:name=>"done_ratio",:class=>"w70 undis issueEdit"}) %> + <% end %> +开始 :
+<%= format_date(activity.start_date) %>
+周期 :
+ <%= l_hours(activity.estimated_hours) %>计划完成 :
+ <%= format_date(activity.due_date)? format_date(activity.due_date) : "--" %>目标版本 :
+ <%= (activity.fixed_version ? link_to_user_version(activity.fixed_version) : "--") %>- <%= user.user_extensions.technical_title %> + <% if user.user_extensions && user.user_extensions.identity %> + <%= get_user_roll(user) %> + <% end %>