diff --git a/app/controllers/attachments_controller.rb b/app/controllers/attachments_controller.rb index f7adf802b..662a85fe1 100644 --- a/app/controllers/attachments_controller.rb +++ b/app/controllers/attachments_controller.rb @@ -65,11 +65,11 @@ class AttachmentsController < ApplicationController def download # modify by nwb # 下载添加权限设置 - candown = attachment_candown @attachment + candown = attachment_candown @attachment if candown || User.current.admin? || User.current.id == @attachment.author_id @attachment.increment_download if stale?(:etag => @attachment.digest) - convered_file = File.join(Rails.root, "files", "convered_office", a.disk_filename + ".html") + convered_file = File.join(Rails.root, "files", "convered_office", @attachment.disk_filename + ".html") if File.exist?(convered_file) render :text => File.open(convered_file).read else @@ -78,11 +78,9 @@ class AttachmentsController < ApplicationController :disposition => 'attachment' #inline can open in browser end end - else render_403 :message => :notice_not_authorized end - rescue => e redirect_to "http: //" + (Setting.host_name.to_s) +"/file_not_found.html" end @@ -433,7 +431,7 @@ private @attachment.container.board.course) @course = @attachment.container.board.course else - unless @attachment.container_type == 'Bid' || @attachment.container_type == 'HomeworkAttach' || @attachment.container_type == 'Memo' || @attachment.container_type == 'Softapplication' || @attachment.container_type == 'PhoneAppVersion' + unless @attachment.container_type == 'Bid' || @attachment.container_type == 'HomeworkAttach' || @attachment.container_type == 'Memo' || @attachment.container_type == 'Softapplication' || @attachment.container_type == 'PhoneAppVersion' || @attachment.container_type == 'StudentWorksScore'|| @attachment.container_type == 'StudentWorks' @project = @attachment.project end end diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index be69b1777..333ad77b1 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -298,7 +298,6 @@ class CoursesController < ApplicationController else page_from = params[:page].nil? ? 0 : (params[:page].to_i - 1) @results = student_homework_score(0,page_from, 10,"desc") - @results = paginateHelper_for_members @results, 10 end end @@ -317,14 +316,11 @@ class CoursesController < ApplicationController when '1' @subPage_title = l :label_teacher_list @all_members = searchTeacherAndAssistant(@course) - #@members = paginateHelper @all_members, 10 @members = @all_members when '2' @subPage_title = l :label_student_list page = params[:page].nil? ? 0 : (params['page'].to_i - 1) @all_members = student_homework_score(0,page, 10,"desc") - # @all_members = @course.members - # @members = paginateHelper_for_members @all_members, 10 @members = @all_members end respond_to do |format| @@ -379,11 +375,9 @@ class CoursesController < ApplicationController if group_id == '0' page = params[:page].nil? ? 0 : (params['page'].to_i - 1) @results = student_homework_score(0,page, 10,@score_sort_by) - @results = paginateHelper_for_members @results, 10 else @group = CourseGroup.find(group_id) @results = student_homework_score(group_id, 0, 0,@score_sort_by) - @results = paginateHelper @results, 10 end end end @@ -612,32 +606,6 @@ class CoursesController < ApplicationController end end - def homework - if @course.is_public != 0 || User.current.member_of_course?(@course) || User.current.admin? - bids = @course.homeworks.order('created_on DESC') - bids = bids.like(params[:name]) if params[:name].present? - @bids = paginateHelper bids,10 - @is_teacher = User.current.logged? && (User.current.admin? || User.current.allowed_to?(:as_teacher,@course)) - @is_student = User.current.logged? && (User.current.admin? || (User.current.member_of_course?(@course) && !@is_teacher)) - render :layout => 'base_courses' - else - render_403 - end - end - - # 新建作业 - def new_homework - @homework = Bid.new - @homework.safe_attributes = params[:bid] - @homework.open_anonymous_evaluation = 1 - @homework.deadline = (Time.now + 3600 * 24).strftime('%Y-%m-%d') - if (User.current.logged? && User.current.member_of_course?(Course.find params[:id] )) - render :layout => 'base_courses' - else - render_403 - end - end - def toggleCourse @course_prefs = Course.find_by_extra(@course.extra) unless (@course_prefs.teacher == User.current || User.current.admin?) @@ -712,8 +680,8 @@ class CoursesController < ApplicationController "show_course_news" => true, "show_course_messages" => true, #"show_course_journals_for_messages" => true, - "show_bids" => true, - "show_homeworks" => true, + # "show_bids" => true, + # "show_homeworks" => true, "show_polls" => true } @date_to ||= Date.today + 1 @@ -863,44 +831,32 @@ class CoursesController < ApplicationController end def student_homework_score(groupid,start_from, nums, score_sort_by) - #teachers = find_course_teachers(@course) start_from = start_from * nums sql_select = "" if groupid == 0 - if nums == 0 - sql_select = "SELECT members.*, SUM(homework_attaches.score) as score FROM members, homework_attaches - WHERE members.course_id = #{@course.id} AND members.user_id in (SELECT students_for_courses.student_id FROM students_for_courses WHERE course_id = #{@course.id}) AND members.user_id = homework_attaches.user_id - AND homework_attaches.bid_id in (SELECT bid_id FROM homework_for_courses WHERE course_id = #{@course.id}) GROUP BY members.user_id - UNION all - SELECT members.*, 0 as score FROM members,homework_attaches,students_for_courses WHERE members.course_id = #{@course.id} AND - students_for_courses.course_id = #{@course.id} and members.user_id = students_for_courses.student_id AND - members.user_id NOT IN (SELECT homework_attaches.user_id FROM homework_attaches WHERE homework_attaches.bid_id in (SELECT bid_id FROM homework_for_courses WHERE course_id = #{@course.id} ) - ) - GROUP BY members.user_id ORDER BY score #{score_sort_by}" - else - sql_select = "SELECT members.*, SUM(homework_attaches.score) as score FROM members, homework_attaches - WHERE members.course_id = #{@course.id} AND members.user_id in (SELECT students_for_courses.student_id FROM students_for_courses WHERE course_id = #{@course.id}) AND members.user_id = homework_attaches.user_id - AND homework_attaches.bid_id in (SELECT bid_id FROM homework_for_courses WHERE course_id = #{@course.id}) GROUP BY members.user_id - UNION all - SELECT members.*, 0 as score FROM members,homework_attaches,students_for_courses WHERE members.course_id = #{@course.id} AND - students_for_courses.course_id = #{@course.id} and members.user_id = students_for_courses.student_id AND - members.user_id NOT IN (SELECT homework_attaches.user_id FROM homework_attaches WHERE homework_attaches.bid_id in (SELECT bid_id FROM homework_for_courses WHERE course_id = #{@course.id} ) - ) - GROUP BY members.user_id ORDER BY score #{score_sort_by} " #limit #{start_from}, #{nums}" - - end + sql_select = "SELECT members.*,( + SELECT SUM(student_works.final_score) + FROM student_works,homework_commons + WHERE student_works.homework_common_id = homework_commons.id + AND homework_commons.course_id = #{@course.id} + AND student_works.user_id = members.user_id + ) AS score + FROM members + JOIN students_for_courses + ON students_for_courses.student_id = members.user_id AND students_for_courses.course_id = members.course_id + WHERE members.course_id = #{@course.id} ORDER BY score #{score_sort_by}" else - sql_select = "SELECT members.*, SUM(homework_attaches.score) as score FROM members, homework_attaches - WHERE members.course_id = #{@course.id} AND members.user_id in (SELECT students_for_courses.student_id FROM students_for_courses WHERE course_id = #{@course.id}) AND members.user_id = homework_attaches.user_id - and members.course_group_id = #{groupid} AND homework_attaches.bid_id in (SELECT bid_id FROM homework_for_courses WHERE course_id = #{@course.id}) - GROUP BY members.user_id - UNION all - SELECT members.*, 0 as score FROM members,homework_attaches,students_for_courses WHERE members.course_id = #{@course.id} - and members.course_group_id = #{groupid} AND - students_for_courses.course_id = #{@course.id} and members.user_id = students_for_courses.student_id AND - members.user_id NOT IN (SELECT homework_attaches.user_id FROM homework_attaches WHERE homework_attaches.bid_id in (SELECT bid_id FROM homework_for_courses WHERE course_id = #{@course.id} ) - ) - GROUP BY members.user_id ORDER BY score #{score_sort_by}" + sql_select = "SELECT members.*,( + SELECT SUM(student_works.final_score) + FROM student_works,homework_commons + WHERE student_works.homework_common_id = homework_commons.id + AND homework_commons.course_id = #{@course.id} + AND student_works.user_id = members.user_id + ) AS score + FROM members + JOIN students_for_courses + ON students_for_courses.student_id = members.user_id AND students_for_courses.course_id = members.course_id + WHERE members.course_id = #{@course.id} AND members.course_group_id = #{groupid} ORDER BY score #{score_sort_by}" end sql = ActiveRecord::Base.connection() homework_scores = Member.find_by_sql(sql_select) @@ -922,7 +878,6 @@ class CoursesController < ApplicationController @score_sort_by = "desc" page_from = params[:page].nil? ? 0 : (params[:page].to_i - 1) @results = student_homework_score(group.id,0,0, "desc") - @results = paginateHelper @results, 10 end diff --git a/app/controllers/homework_common_controller.rb b/app/controllers/homework_common_controller.rb new file mode 100644 index 000000000..58c959512 --- /dev/null +++ b/app/controllers/homework_common_controller.rb @@ -0,0 +1,207 @@ +class HomeworkCommonController < ApplicationController + layout "base_courses" + before_filter :find_course, :only => [:index,:new,:create] + before_filter :find_homework, :only => [:edit,:update,:alert_anonymous_comment,:start_anonymous_comment,:stop_anonymous_comment,:destroy] + before_filter :teacher_of_course, :only => [:new, :create, :edit, :update, :destroy, :start_anonymous_comment, :stop_anonymous_comment, :alert_anonymous_comment] + + def index + homeworks = @course.homework_commons + @is_teacher = User.current.logged? && (User.current.admin? || User.current.allowed_to?(:as_teacher,@course)) + @is_student = User.current.logged? && (User.current.admin? || (User.current.member_of_course?(@course) && !@is_teacher)) + @homeworks = paginateHelper homeworks,20 + respond_to do |format| + format.html + end + end + + def new + @homework = HomeworkCommon.new + @homework.safe_attributes = params[:homework_common] + @homework.late_penalty = 2 + @homework.end_time = (Time.now + 3600 * 24).strftime('%Y-%m-%d') + @homework.publish_time = Time.now.strftime('%Y-%m-%d') + + #匿评作业相关属性 + @homework_detail_manual = HomeworkDetailManual.new + @homework_detail_manual.ta_proportion = 0.6 + @homework_detail_manual.absence_penalty = 2 + @homework_detail_manual.evaluation_num = 3 + @homework_detail_manual.evaluation_start = Time.now.strftime('%Y-%m-%d') + @homework_detail_manual.evaluation_end = (Time.now + 3600 * 24).strftime('%Y-%m-%d') + @homework.homework_detail_manual = @homework_detail_manual + respond_to do |format| + format.html + end + end + + def create + if params[:homework_common] + homework = HomeworkCommon.new + homework.name = params[:homework_common][:name] + homework.description = params[:homework_common][:description] + homework.end_time = params[:homework_common][:end_time] + homework.publish_time = params[:homework_common][:publish_time] + homework.homework_type = params[:homework_common][:homework_type] + homework.late_penalty = params[:late_penalty] + homework.user_id = User.current.id + homework.course_id = @course.id + + homework.save_attachments(params[:attachments]) + render_attachment_warning_if_needed(homework) + + #匿评作业相关属性 + homework_detail_manual = HomeworkDetailManual.new + homework_detail_manual.ta_proportion = params[:ta_proportion] || 0.6 + homework_detail_manual.comment_status = 1 + homework_detail_manual.evaluation_start = params[:evaluation_start] + homework_detail_manual.evaluation_end = params[:evaluation_end] + homework_detail_manual.evaluation_num = params[:evaluation_num] + homework_detail_manual.absence_penalty = params[:absence_penalty] + homework.homework_detail_manual = homework_detail_manual + + if homework.save + respond_to do |format| + format.html { + flash[:notice] = l(:notice_successful_create) + redirect_to homework_common_index_path(:course => @course.id) + } + end + return + end + end + + respond_to do |format| + format.html { + flash[:notice] = l(:notice_failed_create) + redirect_to new_homework_common_path(:course => @course.id) + } + end + end + + def edit + respond_to do |format| + format.html + end + end + + def update + @homework.name = params[:homework_common][:name] + @homework.description = params[:homework_common][:description] + @homework.end_time = params[:homework_common][:end_time] + @homework.publish_time = params[:homework_common][:publish_time] + @homework.homework_type = params[:homework_common][:homework_type] + @homework.late_penalty = params[:late_penalty] + @homework.user_id = User.current.id + @homework.course_id = @course.id + + #匿评作业相关属性 + @homework_detail_manual.ta_proportion = params[:ta_proportion] || 0.6 + @homework_detail_manual.evaluation_start = params[:evaluation_start] + @homework_detail_manual.evaluation_end = params[:evaluation_end] + @homework_detail_manual.evaluation_num = params[:evaluation_num] + @homework_detail_manual.absence_penalty = params[:absence_penalty] + + if @homework.save && @homework_detail_manual.save + respond_to do |format| + format.html { + flash[:notice] = l(:notice_successful_edit) + redirect_to homework_common_index_path(:course => @course.id) + } + end + return + else + respond_to do |format| + format.html { + flash[:notice] = l(:notice_failed_edit) + redirect_to edit_homework_common_path(@homework) + } + end + end + end + + def destroy + if @homework.destroy + respond_to do |format| + format.html {redirect_to homework_common_index_path(:course => @course.id)} + end + end + end + + #开启匿评 + #statue 1:启动成功,2:启动失败,作业总数大于等于2份时才能启动匿评,3:已开启匿评,请务重复开启,4:没有开启匿评的权限 + def start_anonymous_comment + @statue =4 and return unless User.current.admin? || User.current.allowed_to?(:as_teacher,@course) + if @homework_detail_manual.comment_status == 1 + student_works = @homework.student_works + if student_works && student_works.size >=2 + student_works.each_with_index do |work, index| + user = work.user + n = @homework_detail_manual.evaluation_num + n = n < student_works.size ? n : student_works.size - 1 + assigned_homeworks = get_assigned_homeworks(student_works, n, index) + assigned_homeworks.each do |h| + student_works_evaluation_distributions = StudentWorksEvaluationDistribution.new(user_id: user.id, student_work_id: h.id) + student_works_evaluation_distributions.save + end + end + @homework_detail_manual.update_column('comment_status', 2) + @statue = 1 + else + @statue = 2 + end + else + @statue = 3 + end + end + + #关闭匿评 + def stop_anonymous_comment + @homework_detail_manual.update_column('comment_status', 3) + respond_to do |format| + format.js + end + end + + #提示 + def alert_anonymous_comment + @cur_size = 0 + @totle_size = 0 + if @homework_detail_manual.comment_status == 1 + @totle_size = @course.student.count + @cur_size = @homework.student_works.size + elsif @homework_detail_manual.comment_status == 2 + @homework.student_works.map { |work| @totle_size += work.student_works_evaluation_distributions.count} + @cur_size = 0 + @homework.student_works.map { |work| @cur_size += work.student_works_scores.where(:reviewer_role => 3).count} + end + @percent = format("%.2f",(@cur_size.to_f / ( @totle_size == 0 ? 1 : @totle_size)) * 100) + respond_to do |format| + format.js + end + end + + private + #获取课程 + def find_course + @course = Course.find params[:course] + rescue + render_404 + end + #获取作业 + def find_homework + @homework = HomeworkCommon.find params[:id] + @homework_detail_manual = @homework.homework_detail_manual + @course = @homework.course + rescue + render_404 + end + #是不是课程的老师 + def teacher_of_course + render_403 unless User.current.allowed_to?(:as_teacher,@course) + end + + def get_assigned_homeworks(student_works, n, index) + student_works += student_works + student_works[index + 1 .. index + n] + end +end \ No newline at end of file diff --git a/app/controllers/student_work_controller.rb b/app/controllers/student_work_controller.rb new file mode 100644 index 000000000..8c5561d74 --- /dev/null +++ b/app/controllers/student_work_controller.rb @@ -0,0 +1,300 @@ +class StudentWorkController < ApplicationController + layout "base_courses" + include StudentWorkHelper + require 'bigdecimal' + before_filter :find_homework, :only => [:new, :index, :create] + before_filter :find_work, :only => [:edit, :update, :show, :destroy, :add_score, :praise_student_work] + before_filter :member_of_course, :only => [:index, :new, :create, :show, :add_score, :praise_student_work] + before_filter :author_of_work, :only => [:edit, :update, :destroy] + + def index + @order,@b_sort,@name = params[:order] || "final_score",params[:sort] || "desc",params[:name] || "" + @is_teacher = User.current.allowed_to?(:as_teacher,@course) + #老师 || 非匿评作业 || 匿评结束 显示所有的作品 + @show_all = @is_teacher || @homework.homework_type != 1 || @homework.homework_detail_manual.comment_status == 3 + if @show_all + if @homework.homework_type == 1 || @is_teacher || User.current.admin? + @stundet_works = search_homework_member @homework.student_works.order("#{@order} #{@b_sort}"),@name + else + my_work = @homework.student_works.where(:user_id => User.current.id) + if my_work.empty? + @stundet_works = [] + else + @stundet_works = search_homework_member @homework.student_works.order("#{@order} #{@b_sort}"),@name + end + end + else #学生 + if @homework.homework_detail_manual.comment_status == 1 #未开启匿评,只显示我的作品 + @stundet_works = @homework.student_works.where(:user_id => User.current.id) + elsif @homework.homework_detail_manual.comment_status == 2 #匿评列表,显示匿评作品和我的作品 + @is_evaluation = true + my_work = @homework.student_works.where(:user_id => User.current.id) + @stundet_works = my_work + User.current.student_works_evaluation_distributions.map(&:student_work).select { |work| work.homework_common_id == @homework.id} + end + end + @homework_commons = @course.homework_commons.order("created_at desc") + @score = @b_sort == "desc" ? "asc" : "desc" + respond_to do |format| + format.html + format.xls { + send_data(homework_to_xls(@stundet_works), :type => "text/excel;charset=utf-8; header=present", + :filename => "#{@course.teacher.lastname.to_s + @course.teacher.firstname}_#{@course.name}_#{@course.time.to_s + @course.term}_#{@homework.name}#{l(:excel_homework_list)}.xls") + } + end + end + + def new + student_work = @homework.student_works.where("user_id = ?",User.current.id).first + if student_work.nil? + @stundet_work = StudentWork.new + respond_to do |format| + format.html + end + else + render_403 + end + end + + def create + if params[:student_work] + stundet_work = StudentWork.new + stundet_work.name = params[:student_work][:name] + stundet_work.description = params[:student_work][:description] + stundet_work.project_id = params[:student_work][:project_id] + stundet_work.homework_common_id = @homework.id + stundet_work.user_id = User.current.id + stundet_work.save_attachments(params[:attachments]) + render_attachment_warning_if_needed(stundet_work) + if stundet_work.save + respond_to do |format| + format.html { + flash[:notice] = l(:notice_successful_create) + redirect_to student_work_index_url(:homework => @homework.id) + } + end + return + end + end + respond_to do |format| + format.html { + flash[:notice] = l(:notice_failed_create) + redirect_to new_student_work_url(:homework => @homework.id) + } + end + end + + def edit + respond_to do |format| + format.html + end + end + + def update + if params[:student_work] + @work.name = params[:student_work][:name] + @work.description = params[:student_work][:description] + @work.project_id = params[:student_work][:project] + @work.save_attachments(params[:attachments]) + render_attachment_warning_if_needed(@work) + if @work.save + respond_to do |format| + format.html { + flash[:notice] = l(:notice_successful_edit) + redirect_to student_work_index_url(:homework => @homework.id) + } + end + return + end + end + respond_to do |format| + format.html{redirect_to edit_student_work_url(@work)} + end + end + + def show + @score = student_work_score @work,User.current + @is_teacher = User.current.allowed_to?(:as_teacher,@course) + respond_to do |format| + format.js + end + end + + def destroy + if @work.destroy + respond_to do |format| + format.html { + redirect_to student_work_index_url(:homework => @homework.id) + } + end + end + end + + #添加评分,已评分则为修改评分 + def add_score + render_403 and return if User.current == @work.user #不可以匿评自己的作品 + @is_teacher = User.current.allowed_to?(:as_teacher,@course) + #老师、教辅可以随时评分,学生只能在匿评作业的匿评阶段进行评分 + render_403 and return unless @is_teacher || (@homework.homework_type == 1 && @homework.homework_detail_manual.comment_status == 2) + @score = student_work_score @work,User.current + if @score + @score.comment = params[:new_form][:user_message] if params[:new_form] && params[:new_form][:user_message] && params[:new_form][:user_message] != "" + @score.score = params[:score] if params[:score] + @is_new = false + else + @score = StudentWorksScore.new + @score.score = params[:score] if params[:score] + @score.comment = params[:new_form][:user_message] if params[:new_form] && params[:new_form][:user_message] && params[:new_form][:user_message] != "" + @score.user_id = User.current.id + @score.student_work_id = @work.id + role = User.current.members.where("course_id = ?",@course.id).first.roles.first.name + User.current.admin? ? @score.reviewer_role = 1 : @score.reviewer_role = get_role_by_name(role) + @is_new = true + end + + @score.save_attachments(params[:attachments]) + render_attachment_warning_if_needed(@score) + + if @score.save + case @score.reviewer_role + when 1 #教师评分:最后一个教师评分为最终评分 + @work.teacher_score = @score.score + @work.final_score = @score.score + when 2 #教辅评分 教辅评分显示平均分 + @work.teaching_asistant_score = @work.student_works_scores.where(:reviewer_role => 2).average(:score).try(:round, 2).to_f + if @work.teacher_score.nil? + if @work.student_score.nil? + @work.final_score = @work.teaching_asistant_score + else + final_ta_score = BigDecimal.new("#{@work.teaching_asistant_score}") * BigDecimal.new("#{@homework.homework_detail_manual.ta_proportion}") + final_s_score = BigDecimal.new("#{@work.student_score}") * (BigDecimal.new('1.0') - BigDecimal.new("#{@homework.homework_detail_manual.ta_proportion}")) + final_score = final_ta_score + final_s_score + @work.final_score = format("%.2f",final_score.to_f) + end + end + when 3 #学生评分 学生评分显示平均分 + @work.student_score = @work.student_works_scores.where(:reviewer_role => 3).average(:score).try(:round, 2).to_f + if @work.teacher_score.nil? + if @work.teaching_asistant_score.nil? + @work.final_score = @work.student_score + else + final_ta_score = BigDecimal.new("#{@work.teaching_asistant_score}") * BigDecimal.new("#{@homework.homework_detail_manual.ta_proportion}") + final_s_score = BigDecimal.new("#{@work.student_score}") * (BigDecimal.new('1.0') - BigDecimal.new("#{@homework.homework_detail_manual.ta_proportion}")) + final_score = final_ta_score + final_s_score + @work.final_score = format("%.2f",final_score.to_f) + end + end + end + + if @work.save + respond_to do |format| + format.js + end + end + end + end + + #添加评分的回复 + def add_score_reply + @score = StudentWorksScore.find params[:score_id] + @jour = @score.journals_for_messages.new(:user_id => User.current.id,:notes =>params[:message], :reply_id => 0) + if @jour.save + @status = 1 + else + @status = 2 + end + respond_to do |format| + format.js + end + end + + #删除评分的回复 + def destroy_score_reply + @jour = JournalsForMessage.find params[:jour_id] + if @jour.destroy + respond_to do |format| + format.js + end + end + end + + #为作品点赞 + def praise_student_work + pt = PraiseTread.new + pt.user_id = User.current.id + pt.praise_tread_object_id = @work.id + pt.praise_tread_object_type = "StudentWork" + pt.praise_or_tread = 1 + if pt.save + respond_to do |format| + format.js + end + else + render_404 + end + end + + private + #获取作业 + def find_homework + @homework = HomeworkCommon.find params[:homework] + @course = @homework.course + rescue + render_404 + end + #获取作品 + def find_work + @work = StudentWork.find params[:id] + @homework = @work.homework_common + @course = @homework.course + rescue + render_404 + end + + #是不是当前课程的成员 + #当前课程成员才可以看到作品列表 + def member_of_course + render_403 unless User.current.member_of_course? @course + end + + #判断是不是当前作品的提交者 + #提交者 && (非匿评作业 || 未开启匿评) 可以编辑作品 + def author_of_work + render_403 unless User.current.id == @work.user_id && (@homework.homework_type != 1 || @homework.homework_detail_manual.comment_status == 1 ) + end + + #根据条件过滤作业结果 + def search_homework_member homeworks,name + name = name.downcase + select_homework = homeworks.select{ |homework| + homework.user[:login].to_s.downcase.include?(name) || homework.user.user_extensions[:student_id].to_s.downcase.include?(name) || (homework.user[:lastname].to_s.downcase + homework.user[:firstname].to_s.downcase).include?(name) + } + select_homework + end + + def homework_to_xls items + xls_report = StringIO.new + book = Spreadsheet::Workbook.new + sheet1 = book.create_worksheet :name => "homework" + blue = Spreadsheet::Format.new :color => :blue, :weight => :bold, :size => 10 + 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_homework_name), + l(:excel_t_score),l(:excel_ta_score),l(:excel_n_score),l(:excel_f_score),l(:excel_commit_time)]) + count_row = 1 + items.each do |homework| + sheet1[count_row,0]=homework.user.id + sheet1[count_row,1] = homework.user.lastname.to_s + homework.user.firstname.to_s + sheet1[count_row,2] = homework.user.login + sheet1[count_row,3] = homework.user.user_extensions.student_id + sheet1[count_row,4] = homework.user.mail + sheet1[count_row,5] = homework.name + sheet1[count_row,6] = homework.teacher_score.nil? ? l(:label_without_score) : format("%.2f",homework.teacher_score) + sheet1[count_row,7] = homework.teaching_asistant_score.nil? ? l(:label_without_score) : format("%.2f",homework.teaching_asistant_score) + sheet1[count_row,8] = homework.student_score.nil? ? l(:label_without_score) : format("%.2f",homework.student_score) + sheet1[count_row,9] = homework.final_score.nil? ? l(:label_without_score) : format("%.2f",homework.final_score) + sheet1[count_row,10] = format_time(homework.created_at) + count_row += 1 + end + book.write xls_report + xls_report.string + end +end \ No newline at end of file diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index ace4ae903..0382e7be0 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -462,14 +462,14 @@ class UsersController < ApplicationController ids = [] ids << Issue.where(id: act_ids, project_id: p_ids).map{|x| x.id} - #Bid - act_ids = activity.where(act_type: 'Bid').select('act_id').map{|x| x.act_id} - course_ids = HomeworkForCourse.where(bid_id: act_ids).select('distinct course_id').map{|x| x.course_id} + #HomeworkCommon + act_ids = activity.where(act_type: 'HomeworkCommon').select('act_id').map{|x| x.act_id} + course_ids = HomeworkCommon.where(id: act_ids).select('distinct course_id').map{|x| x.course_id} c_ids = [] Course.where(id: course_ids).each do |x| c_ids << x.id unless x.is_public !=0 && User.current.member_of_course?(x) end - ids << HomeworkForCourse.where(bid_id: act_ids, course_id: c_ids).map{|x| x.id} + ids << HomeworkCommon.where(id: act_ids, course_id: c_ids).map{|x| x.id} #Journal act_ids = activity.where(act_type: 'Journal').select('act_id').map{|x| x.act_id} diff --git a/app/controllers/zipdown_controller.rb b/app/controllers/zipdown_controller.rb index d9b900833..043552872 100644 --- a/app/controllers/zipdown_controller.rb +++ b/app/controllers/zipdown_controller.rb @@ -33,26 +33,25 @@ class ZipdownController < ApplicationController render file: 'public/no_file_found.html' return end + elsif params[:obj_class] == "HomeworkCommon" + homework = HomeworkCommon.find params[:obj_id] + render_403 if User.current.allowed_to?(:as_teacher,homework.course) + file_count = 0 + homework.student_works.map { |work| file_count += work.attachments.count} + if file_count > 0 + zipfile = zip_homework_common homework + else + render file: 'public/no_file_found.html' + return + end else logger.error "[ZipDown#assort] ===> #{params[:obj_class]} unKown !!" end - - # if zipfile - # if zipfile.length > 1 - # @mut_down_files = zipfile #zipfile.each{|x| File.basename(x)} - # else - # send_file zipfile.first[:real_file], :filename => bid.name + ".zip", :type => detect_content_type(zipfile.first[:real_file]) - # return - # end - # end - respond_to do |format| format.json { render json: zipfile.to_json } end - #rescue Exception => e - # render file: 'public/no_file_found.html' end #下载某一学生的作业的所有文件 @@ -102,29 +101,34 @@ class ZipdownController < ApplicationController digests << out_file.file_digest end end - homework_id = bid.id user_id = bid.author_id - - out_file = find_or_pack(homework_id, user_id, digests.sort){ zipping("#{Time.now.to_i}_#{bid.name}.zip", bid_homework_path, OUTPUT_FOLDER) } + [{files:[out_file.file_path], count: 1, index: 1, + real_file: out_file.file_path, file: File.basename(out_file.file_path), + size:(out_file.pack_size / 1024.0 / 1024.0).round(2) + }] + end - - # zips = split_pack_files(bid_homework_path, Setting.pack_attachment_max_size.to_i*1024) - # x = 0 - # - # - # zips.each { |o| - # x += 1 - # file = zipping "#{Time.now.to_i}_#{bid.name}_#{x}.zip", o[:files], OUTPUT_FOLDER - # o[:real_file] = file - # o[:file] = File.basename(file) - # o[:size] = (File.size(file) / 1024.0 / 1024.0).round(2) - # } - + def zip_homework_common homework_common + bid_homework_path = [] + digests = [] + homework_common.student_works.each do |work| + unless work.attachments.empty? + out_file = zip_student_work_by_user(work) + bid_homework_path << out_file.file_path + digests << out_file.file_digest + end + end + homework_id = homework_common.id + user_id = homework_common.user_id + out_file = find_or_pack(homework_id, user_id, digests.sort){ + zipping("#{Time.now.to_i}_#{homework_common.name}.zip", + bid_homework_path, OUTPUT_FOLDER) + } [{files:[out_file.file_path], count: 1, index: 1, real_file: out_file.file_path, file: File.basename(out_file.file_path), size:(out_file.pack_size / 1024.0 / 1024.0).round(2) @@ -135,8 +139,6 @@ class ZipdownController < ApplicationController homeworks_attach_path = [] not_exist_file = [] # 需要将所有homework.attachments遍历加入zip - - digests = [] homework_attach.attachments.each do |attach| if File.exist?(attach.diskfile) @@ -147,12 +149,30 @@ class ZipdownController < ApplicationController digests << 'not_exist_file' end end - out_file = find_or_pack(homework_attach.bid_id, homework_attach.user_id, digests.sort){ zipping("#{homework_attach.user.lastname}#{homework_attach.user.firstname}_#{((homework_attach.user.user_extensions.nil? || homework_attach.user.user_extensions.student_id.nil?) ? "" : homework_attach.user.user_extensions.student_id)}_#{Time.now.to_i.to_s}.zip", homeworks_attach_path, OUTPUT_FOLDER, true, not_exist_file) } + end + def zip_student_work_by_user work + homeworks_attach_path = [] + not_exist_file = [] + # 需要将所有homework.attachments遍历加入zip + digests = [] + work.attachments.each do |attach| + if File.exist?(attach.diskfile) + homeworks_attach_path << attach.diskfile + digests << attach.digest + else + not_exist_file << attach.filename + digests << 'not_exist_file' + end + end + out_file = find_or_pack(work.homework_common_id, work.user_id, digests.sort){ + zipping("#{work.user.lastname}#{work.user.firstname}_#{((work.user.user_extensions.nil? || work.user.user_extensions.student_id.nil?) ? "" : work.user.user_extensions.student_id)}_#{Time.now.to_i.to_s}.zip", + homeworks_attach_path, OUTPUT_FOLDER, true, not_exist_file) + } end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index a07ff320d..5ae70fd7c 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1824,7 +1824,7 @@ module ApplicationHelper def attachment_candown attachment candown = false if attachment.container - if attachment.container.class.to_s != "HomeworkAttach" && (attachment.container.has_attribute?(:project) || attachment.container.has_attribute?(:project_id)) && attachment.container.project + if attachment.container.class.to_s != "HomeworkAttach" && attachment.container.class.to_s != "StudentWork" && (attachment.container.has_attribute?(:project) || attachment.container.has_attribute?(:project_id)) && attachment.container.project project = attachment.container.project candown= User.current.member_of?(project) || (project.is_public && attachment.is_public == 1) elsif attachment.container.is_a?(Project) @@ -1844,7 +1844,11 @@ module ApplicationHelper attachment.container.board.course course = attachment.container.board.course candown= User.current.member_of_course?(course) || (course.is_public==1 && attachment.is_public == 1) - elsif attachment.container.class.to_s=="HomeworkAttach" && attachment.container.bid.reward_type == 3 + elsif attachment.container.class.to_s=="HomeworkAttach" + candown = true + elsif attachment.container.class.to_s=="StudentWorksScore" + candown = true + elsif attachment.container.class.to_s=="StudentWork" candown = true elsif attachment.container_type == "Bid" && attachment.container && attachment.container.courses course = attachment.container.courses.first @@ -2110,7 +2114,7 @@ module ApplicationHelper # courses_link = link_to l(:label_course_practice), {:controller => 'courses', :action => 'index'} #users_link = link_to l(:label_software_user), {:controller => 'users', :action => 'index', :host => Setting.host_user} # contest_link = link_to l(:label_contest_innovate), {:controller => 'contests', :action => 'index'} - bids_link = link_to l(:label_requirement_enterprise), {:controller => 'bids', :action => 'index'} + # bids_link = link_to l(:label_requirement_enterprise), {:controller => 'bids', :action => 'index'} forum_link = link_to l(:label_forum_all), {:controller => "forums", :action => "index"} stores_link = link_to l(:label_stores_index), {:controller => 'stores', :action=> 'index'} school_all_school_link = link_to l(:label_school_all), {:controller => 'school', :action => 'index'} @@ -2270,4 +2274,60 @@ module ApplicationHelper tag_list = attachment_tag_list all_attachments tag_list end + + #获取匿评相关连接代码 + def homework_anonymous_comment homework + if homework.homework_type == 1 && homework.homework_detail_manual #匿评作业 + if homework.student_works.count >= 2 #作业份数大于2 + case homework.homework_detail_manual.comment_status + when 1 + link = link_to '启动匿评', alert_anonymous_comment_homework_common_path(homework), id: "#{homework.id}_start_anonymous_comment", remote: true, disable_with: '加载中...',:class => 'fr mr10 work_edit' + when 2 + link = link_to '关闭匿评', alert_anonymous_comment_homework_common_path(homework), id: "#{homework.id}_stop_anonymous_comment", remote: true,:class => 'fr mr10 work_edit' + when 3 + link = "匿评结束".html_safe + end + else + link = "启动匿评".html_safe + end + else + link = "启动匿评".html_safe + end + link + end + #学生根据传入作业确定显示为编辑作品还是新建作品 + def student_new_homework homework + work = cur_user_works_for_homework homework + if work.nil? + link_to l(:label_commit_homework), new_student_work_path(:homework => homework.id),:class => 'fr mr10 work_edit' + else + if homework.homework_type == 1 && homework.homework_detail_manual && homework.homework_detail_manual.comment_status != 1 #匿评作业,且作业状态不是在开启匿评之前 + "#{l(:label_edit_homework)}".html_safe + else + link_to l(:label_edit_homework), edit_student_work_path(work.id),:class => 'fr mr10 work_edit' + end + end + end + + def student_anonymous_comment homework + if homework.homework_type == 1 && homework.homework_detail_manual + case homework.homework_detail_manual.comment_status + when 1 + "未开启匿评".html_safe + when 2 + "正在匿评中".html_safe + when 3 + "匿评已结束".html_safe + end + elsif homework.homework_type == 0 + "未启用匿评".html_safe + elsif homework.homework_type == 2 + "编程作业".html_safe + end + end + + #获取当前用户在指定作业下提交的作业的集合 + def cur_user_works_for_homework homework + homework.student_works.where("user_id = ?",User.current).first + end end diff --git a/app/helpers/courses_helper.rb b/app/helpers/courses_helper.rb index babd8cb12..13012a70c 100644 --- a/app/helpers/courses_helper.rb +++ b/app/helpers/courses_helper.rb @@ -201,14 +201,13 @@ module CoursesHelper end members end + def searchStudent project #searchPeopleByRoles(project, StudentRoles) members = [] - project.members.each do |m| if m && m.user && m.user.allowed_to?(:as_student,project) members << m - end end members @@ -428,40 +427,19 @@ module CoursesHelper 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.logged? && User.current.member_of_course?(course) && !(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 @@ -479,61 +457,6 @@ module CoursesHelper 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 score_for_homework_new homework - if teacher_score_for_homework(homework) != 0 - return teacher_score_for_homework homework - else - return student_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) - 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 > 0 ? teacher_stars_count/teacher_stars.count : 0) - end - #获取指定项目的得分 def project_score project issue_count = project.issues.count @@ -647,11 +570,6 @@ module CoursesHelper end end - #message_count - #Board.where(course_id: @course_ids).each do |board| - # activities[board.course_id]+=board.messages.where("updated_on>?", date_from).count - #end - #message_count Board.where(course_id: @course_ids).each do |board| countmessage = 0 @@ -671,24 +589,15 @@ module CoursesHelper end end - #feedback_count 留言目前有问题留待下一步处理 - #JournalsForMessage.where(jour_id: @course_ids, jour_type: Course).each do |jourformess| - # activities[jourformess.jour_id]+=1 - #end - #homework_count - HomeworkForCourse.where(course_id: @course_ids).each do |homework| - countbid=0 - # @bid_ids<?",date_from).each do |bid| - countbid+=1 - end - activities[homework.course_id]+=countbid - end - - #@bid_ids.each do |bid_id| - # activities[] +=Bid.where(id: bid_id ).where("created_on>?",date_from).count - #end + # HomeworkForCourse.where(course_id: @course_ids).each do |homework| + # countbid=0 + # # @bid_ids<?",date_from).each do |bid| + # countbid+=1 + # end + # activities[homework.course_id]+=countbid + # end #poll_count # 动态目前只统计发布的问卷,关闭的问卷不在动态内显示 @@ -739,54 +648,6 @@ module CoursesHelper link.html_safe end - def bid_anonymous_comment bid - if bid.open_anonymous_evaluation == 1 - if bid.homeworks.count >= 2 - case bid.comment_status - when 0 - link = link_to '启动匿评', alert_anonymous_comment_bid_path(bid), id: "#{bid.id}_start_anonymous_comment", remote: true, disable_with: '加载中...',:class => 'fr mr10 work_edit' - when 1 - link = link_to '关闭匿评', alert_anonymous_comment_bid_path(bid), id: "#{bid.id}_stop_anonymous_comment", remote: true,:class => 'fr mr10 work_edit' - when 2 - link = "匿评结束".html_safe - end - else - link = "启动匿评".html_safe - end - else - link = "启动匿评".html_safe - end - link - end - - def student_new_homework bid - user_homework = cur_user_homework_for_bid bid - if user_homework && user_homework.empty? - link_to l(:label_commit_homework), new_exercise_book_path(bid),:class => 'fr mr10 work_edit' - else - if bid.comment_status == 1 && bid.open_anonymous_evaluation == 1 - "#{l(:label_edit_homework)}".html_safe - else - link_to l(:label_edit_homework), edit_homework_attach_path(user_homework.first.id),:class => 'fr mr10 work_edit' - end - end - end - - def student_anonymous_comment bid - if bid.open_anonymous_evaluation == 1 - case bid.comment_status - when 0 - "未开启匿评".html_safe - when 1 - "正在匿评中".html_safe - when 2 - "匿评已结束".html_safe - end - else - "未启用匿评".html_safe - end - end - def visable_attachemnts_incourse course return[] unless course result = [] diff --git a/app/helpers/homework_common_helper.rb b/app/helpers/homework_common_helper.rb new file mode 100644 index 000000000..5399fd5bf --- /dev/null +++ b/app/helpers/homework_common_helper.rb @@ -0,0 +1,53 @@ +# encoding: utf-8 +module HomeworkCommonHelper + #迟交扣分下拉框 + def late_penalty_option + type = [] + for i in (1..5) + option = [] + option << i + option << i + type << option + end + type + end + + #教辅评分比例下拉框 + def ta_proportion_option + type = [] + i = 10 + while i <= 100 + option = [] + option << i.to_s + "%" + option << i.to_f / 100 + type << option + i += 10 + end + type + end + + #缺评扣分 + def absence_penalty_option + type = [] + i = 1 + while i <= 5 + option = [] + option << i + option << i + type << option + i += 1 + end + type + end + + #根据传入作业确定跳转到开启匿评还是关闭匿评功能 + def alert_anonyoms_path homework,homework_detail_manual + link = "" + if homework_detail_manual.comment_status == 1 + link = start_anonymous_comment_homework_common_url homework.id + elsif homework_detail_manual.comment_status == 2 + link = stop_anonymous_comment_homework_common_url homework.id + end + link + end +end \ No newline at end of file diff --git a/app/helpers/owner_type_helper.rb b/app/helpers/owner_type_helper.rb index dd5dbbbac..c03f2d19e 100644 --- a/app/helpers/owner_type_helper.rb +++ b/app/helpers/owner_type_helper.rb @@ -6,4 +6,5 @@ module OwnerTypeHelper COMMENT = 5 BID = 6 JOURNALSFORMESSAGE = 7 + HOMEWORKCOMMON = 8 end \ No newline at end of file diff --git a/app/helpers/student_work_helper.rb b/app/helpers/student_work_helper.rb new file mode 100644 index 000000000..990a563c4 --- /dev/null +++ b/app/helpers/student_work_helper.rb @@ -0,0 +1,63 @@ +# encoding: utf-8 +module StudentWorkHelper + def user_projects_option + cond = Project.visible_condition(User.current) + " AND projects.project_type <> 1" + memberships = User.current.memberships.all(:conditions => cond) + projects = memberships.map(&:project) + not_have_project = [] + not_have_project << Setting.please_chose + not_have_project << 0 + type = [] + type << not_have_project + projects.each do |project| + if project != nil + option = [] + option << project.name + option << project.id + type << option + end + end + type + end + + #获取指定用户对某一作业的评分结果 + def student_work_score work,user + StudentWorksScore.where(:user_id => user.id,:student_work_id => work.id).first + end + + #获取指定评分的角色 + def student_work_score_role score + case score.reviewer_role + when 1 + role = "教师" + when 2 + role = "助教" + when 3 + role = "学生" + end + end + + def get_role_by_name role + case role + when "Teacher" + result = 1 + when "Manager" + result = 1 + when "TeachingAsistant" + result = 2 + when "Student" + result = 3 + end + result + end + + #获取赞的总数 + def praise_homework_count obj_id + PraiseTread.where("praise_tread_object_id = #{obj_id} AND praise_tread_object_type = 'StudentWork'").count + end + + #判断指定用户是不是已经赞过该作业 + def is_praise_homework user_id, obj_id + PraiseTread.where("user_id = #{user_id} AND praise_tread_object_id = #{obj_id} AND praise_tread_object_type = 'StudentWork'").empty? + end +end \ No newline at end of file diff --git a/app/models/course.rb b/app/models/course.rb index 610f52f71..6d71ad967 100644 --- a/app/models/course.rb +++ b/app/models/course.rb @@ -10,7 +10,7 @@ class Course < ActiveRecord::Base #belongs_to :project, :class_name => 'Course', :foreign_key => :extra, primary_key: :identifier belongs_to :teacher, :class_name => 'User', :foreign_key => :tea_id # 定义一个方法teacher,该方法通过tea_id来调用User表 belongs_to :school, :class_name => 'School', :foreign_key => :school_id #定义一个方法school,该方法通过school_id来调用School表 - has_many :bid + # has_many :bid has_many :members, :include => [:principal, :roles], :conditions => "#{Principal.table_name}.type='User' AND #{Principal.table_name}.status=#{Principal::STATUS_ACTIVE}" has_many :memberships, :class_name => 'Member' has_many :member_principals, :class_name => 'Member', @@ -18,9 +18,9 @@ class Course < ActiveRecord::Base :conditions => "#{Principal.table_name}.type='Group' OR (#{Principal.table_name}.type='User' AND #{Principal.table_name}.status=#{Principal::STATUS_ACTIVE})" has_many :principals, :through => :member_principals, :source => :principal has_many :users, :through => :members - has_many :homeworks, :through => :homework_for_courses, :source => :bid, :dependent => :destroy + # has_many :homeworks, :through => :homework_for_courses, :source => :bid, :dependent => :destroy has_many :journals_for_messages, :as => :jour, :dependent => :destroy - has_many :homework_for_courses, :dependent => :destroy + # has_many :homework_for_courses, :dependent => :destroy has_many :student, :class_name => 'StudentsForCourse', :source => :user has_many :course_infos, :class_name => 'CourseInfos',:dependent => :destroy has_many :enabled_modules, :dependent => :delete_all @@ -29,6 +29,9 @@ class Course < ActiveRecord::Base has_many :news, :dependent => :destroy, :include => :author has_one :course_status, :class_name => "CourseStatus", :dependent => :destroy + has_many :homework_commons, :dependent => :destroy + has_many :student_works, :through => :homework_commons, :dependent => :destroy + has_many :course_groups, :dependent => :destroy acts_as_taggable diff --git a/app/models/homework_common.rb b/app/models/homework_common.rb new file mode 100644 index 000000000..ac10b2516 --- /dev/null +++ b/app/models/homework_common.rb @@ -0,0 +1,31 @@ +#老师布置的作业表 +#homework_type: 0:普通作业;1:匿评作业;2:编程作业 +class HomeworkCommon < ActiveRecord::Base + # attr_accessible :name, :user_id, :description, :publish_time, :end_time, :homework_type, :late_penalty, :course_id + include Redmine::SafeAttributes + include ApplicationHelper + + belongs_to :course + belongs_to :user + has_one :homework_detail_manual, :dependent => :destroy + has_one :homework_detail_programing, :dependent => :destroy + has_many :homework_tests, :dependent => :destroy + has_many :student_works, :dependent => :destroy + has_many :student_works_evaluation_distributions, :through => :student_works #一个作业的分配的匿评列表 + has_many :acts, :class_name => 'Activity', :as => :act, :dependent => :destroy #用户活动 + acts_as_attachable + acts_as_event :title => Proc.new {|o| "#{l(:label_course_homework)} ##{o.id}: #{o.name}" }, + :description => :description, + :author => :author, + :url => Proc.new {|o| {:controller => 'student_work', :action => 'index', :homework => o.id}} + after_create :act_as_activity + after_destroy :delete_kindeditor_assets + + def act_as_activity + self.acts << Activity.new(:user_id => self.user_id) + end + #删除对应的图片 + def delete_kindeditor_assets + delete_kindeditor_assets_from_disk self.id,OwnerTypeHelper::HOMEWORKCOMMON + end +end diff --git a/app/models/homework_detail_manual.rb b/app/models/homework_detail_manual.rb new file mode 100644 index 000000000..e0c4dcdcb --- /dev/null +++ b/app/models/homework_detail_manual.rb @@ -0,0 +1,7 @@ +#手动评分作业表 +#comment_status: 1:未开启匿评,2:开启匿评,3:匿评结束 +class HomeworkDetailManual < ActiveRecord::Base + attr_accessible :ta_proportion, :comment_status, :evaluation_start, :evaluation_end, :evaluation_num, :absence_penalty, :homework_common_id + + belongs_to :homework_common +end diff --git a/app/models/homework_detail_programing.rb b/app/models/homework_detail_programing.rb new file mode 100644 index 000000000..4c7134806 --- /dev/null +++ b/app/models/homework_detail_programing.rb @@ -0,0 +1,5 @@ +class HomeworkDetailPrograming < ActiveRecord::Base + attr_accessible :language, :standard_code, :homework_common_id + + belongs_to :homework_common +end diff --git a/app/models/homework_test.rb b/app/models/homework_test.rb new file mode 100644 index 000000000..f7d9b20bc --- /dev/null +++ b/app/models/homework_test.rb @@ -0,0 +1,5 @@ +class HomeworkTest < ActiveRecord::Base + attr_accessible :input, :output, :homework_common_id + + belongs_to :homework_common +end diff --git a/app/models/journals_for_message.rb b/app/models/journals_for_message.rb index 239a15881..b15c9b2d1 100644 --- a/app/models/journals_for_message.rb +++ b/app/models/journals_for_message.rb @@ -29,6 +29,7 @@ class JournalsForMessage < ActiveRecord::Base belongs_to :jour, :polymorphic => true belongs_to :user belongs_to :homework_attach + belongs_to :student_works_score belongs_to :at_user, :class_name => "User", :foreign_key => 'reply_id' acts_as_event :title => Proc.new {|o| "#{l(:label_my_message)}"}, diff --git a/app/models/member.rb b/app/models/member.rb index f1a139f74..2936392ab 100644 --- a/app/models/member.rb +++ b/app/models/member.rb @@ -117,10 +117,11 @@ class Member < ActiveRecord::Base # 查找每个学生每个作业的评分 def student_homework_score score_count = 0 - homework_score = HomeworkAttach.find_by_sql("SELECT bids.name, homework_attaches.score as score - FROM homework_attaches, bids where homework_attaches.user_id = #{self.user_id} - and homework_attaches.bid_id IN (SELECT bid_id FROM homework_for_courses where course_id = #{self.course_id}) - AND homework_attaches.bid_id = bids.id ") + homework_score = StudentWork.find_by_sql("SELECT homework_commons.name,student_works.final_score as score + FROM student_works,homework_commons + WHERE student_works.homework_common_id = homework_commons.id + AND homework_commons.course_id = #{self.course_id} + AND student_works.user_id = #{self.user_id}") homework_score.each do |homework| mem_score = 0 if homework[:score] diff --git a/app/models/project.rb b/app/models/project.rb index bf94df248..4a546a430 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -30,7 +30,7 @@ class Project < ActiveRecord::Base # Specific overidden Activities - belongs_to :homework_attach + has_many :student_works has_many :time_entry_activities has_many :members, :include => [:principal, :roles], :conditions => "#{Principal.table_name}.type='User' AND #{Principal.table_name}.status=#{Principal::STATUS_ACTIVE}" has_many :memberships, :class_name => 'Member' diff --git a/app/models/student_work.rb b/app/models/student_work.rb new file mode 100644 index 000000000..e2be18423 --- /dev/null +++ b/app/models/student_work.rb @@ -0,0 +1,12 @@ +#学生提交作品表 +class StudentWork < ActiveRecord::Base + attr_accessible :name, :description, :homework_common_id, :user_id, :final_score, :teacher_score, :student_score, :teaching_asistant_score, :project_id + + belongs_to :homework_common + belongs_to :user + has_many :student_works_evaluation_distributions, :dependent => :destroy + has_many :student_works_scores, :dependent => :destroy + belongs_to :project + + acts_as_attachable +end diff --git a/app/models/student_works_evaluation_distribution.rb b/app/models/student_works_evaluation_distribution.rb new file mode 100644 index 000000000..60f786af8 --- /dev/null +++ b/app/models/student_works_evaluation_distribution.rb @@ -0,0 +1,7 @@ +#学生作品匿评分配表 +class StudentWorksEvaluationDistribution < ActiveRecord::Base + attr_accessible :student_work_id, :user_id + + belongs_to :student_work + belongs_to :user +end diff --git a/app/models/student_works_score.rb b/app/models/student_works_score.rb new file mode 100644 index 000000000..8fa14f8de --- /dev/null +++ b/app/models/student_works_score.rb @@ -0,0 +1,10 @@ +class StudentWorksScore < ActiveRecord::Base + #reviewer_role: 1:教师评分;2:教辅评分;3:学生匿评 + attr_accessible :student_work_id, :user_id, :score, :comment, :reviewer_role + + belongs_to :user + belongs_to :student_work + has_many :journals_for_messages, :as => :jour, :dependent => :destroy + + acts_as_attachable +end diff --git a/app/models/user.rb b/app/models/user.rb index 4c30012d7..a1f00a234 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -75,13 +75,18 @@ class User < Principal has_many :homework_users has_many :homework_attaches, :through => :homework_users has_many :homework_evaluations - #问卷相关关关系 has_many :poll_users, :dependent => :destroy has_many :poll_votes, :dependent => :destroy has_many :poll, :dependent => :destroy #用户创建的问卷 has_many :answers, :source => :poll, :through => :poll_users, :dependent => :destroy #用户已经完成问答的问卷 # end + #作业相关关系 + has_many :homework_commons, :dependent => :destroy + has_many :student_works, :dependent => :destroy + has_many :student_works_evaluation_distributions, :dependent => :destroy + has_many :student_works_scores, :dependent => :destroy + #end has_and_belongs_to_many :groups, :after_add => Proc.new {|user, group| group.user_added(user)}, :after_remove => Proc.new {|user, group| group.user_removed(user)} @@ -92,7 +97,7 @@ class User < Principal belongs_to :auth_source belongs_to :ucourse, :class_name => 'Course', :foreign_key => :id #huang ## added by xianbo for delete - has_many :biding_projects, :dependent => :destroy + # has_many :biding_projects, :dependent => :destroy has_many :contesting_projects, :dependent => :destroy belongs_to :softapplication, :foreign_key => 'id', :dependent => :destroy ##ended by xianbo @@ -100,7 +105,7 @@ class User < Principal #####fq has_many :jours, :class_name => 'JournalsForMessage', :dependent => :destroy has_many :journals_messages, :class_name => 'JournalsForMessage', :foreign_key => "user_id", :dependent => :destroy - has_many :bids, :foreign_key => 'author_id', :dependent => :destroy + # has_many :bids, :foreign_key => 'author_id', :dependent => :destroy has_many :contests, :foreign_key => 'author_id', :dependent => :destroy has_many :softapplications, :foreign_key => 'user_id', :dependent => :destroy has_many :journals_for_messages, :as => :jour, :dependent => :destroy @@ -261,16 +266,6 @@ class User < Principal end end - # 判断用户是否加入了竞赛中 fq - def join_in_contest?(bid) - joined = JoinInContest.where('user_id = ? and bid_id =?', self.id, bid.id) - if joined.size > 0 - true - else - false - end - end - ### fq def join_in?(course) joined = StudentsForCourse.where('student_id = ? and course_id = ?', self.id, course.id) diff --git a/app/views/attachments/upload.js.erb b/app/views/attachments/upload.js.erb index c3e7fc3ff..970c5b22d 100644 --- a/app/views/attachments/upload.js.erb +++ b/app/views/attachments/upload.js.erb @@ -11,7 +11,4 @@ fileSpan.find('a.remove-upload') }) .off('click'); $('', { type: 'hidden', name: 'attachments[<%= j params[:attachment_id] %>][token]' } ).val('<%= j @attachment.token %>').appendTo(fileSpan); - -//var divattach = fileSpan.find('div.div_attachments'); -//divattach.html('<%= j(render :partial => 'tags/tagEx', :locals => {:obj => @attachment, :object_flag => "6"})%>'); <% end %> diff --git a/app/views/courses/_course.html.erb b/app/views/courses/_course.html.erb index 420a22f8a..f2972df44 100644 --- a/app/views/courses/_course.html.erb +++ b/app/views/courses/_course.html.erb @@ -46,8 +46,8 @@

- <%= content_tag('span', link_to("#{@course.homeworks.count}", homework_course_path(@course)), :class => "info") %> - <%= content_tag('span', l(:label_x_task, :count => @course.homeworks.count)) %> + <%= content_tag('span', link_to("#{@course.homework_commons.count}", homework_common_index_path(:course => @course.id)), :class => "info") %> + <%= content_tag('span', l(:label_x_task, :count => @course.homework_commons.count)) %>

<% files_count = @course.attachments.count %> diff --git a/app/views/courses/homework.html.erb b/app/views/courses/homework.html.erb deleted file mode 100644 index 32728adf0..000000000 --- a/app/views/courses/homework.html.erb +++ /dev/null @@ -1,65 +0,0 @@ -

-

- <%= l(:label_homework)%> -

-
-
-

- <%= l(:label_totle)%><%= @obj_count%><%= l(:label_homework_count)%> -

- <%= link_to( l(:label_course_homework_new), new_homework_course_path(@course), :class => 'problem_new_btn fl c_dorange') if @is_teacher %> -
-
-<% @bids.each do |bid|%> -
- <%= link_to(image_tag(url_to_avatar(bid.author), :width => "42", :height => "42"), user_path(bid.author), :class => "problem_pic fl") %> -
- <%= link_to(bid.author.lastname+bid.author.firstname, user_path(bid.author),:class => 'problem_name fl') %> - <%= l(:label_user_create_project_homework) %>: - <%= link_to(bid.name, course_for_bid_path(bid), :class => 'problem_tit fl fb c_dblue') %> -
-

<%= l(:lebel_homework_commit)%> ( <%= link_to bid.homeworks.count, course_for_bid_path(bid.id), :class => 'c_red'%> )

- <% if @is_teacher%> - <%= bid_anonymous_comment(bid)%> - <% if bid.homeworks.empty? %> - <%= link_to(l(:button_delete),bids_homework_path(:id => bid.id), :method => :delete, :confirm => l(:label_delete_confirm), :class => "fr mr10 work_edit") %> - <% end %> - <%= link_to(l(:button_edit),edit_bid_path(:course_id =>@course.id, :bid_id => bid.id), :class => "fr mr10 work_edit") %> - <% elsif @is_student%> - <%= student_anonymous_comment bid %> - <%= student_new_homework bid %> - <% end %> -
- -
-
- <%= bid.description.html_safe %> -
-
- - <%= l(:label_end_time)%>:<%= bid.deadline%> - <% if betweentime(bid.deadline) < 0 %> - - <%= l(:label_commit_limit)%> - - <% else %> - -
-
- <% end %> -
-
-
-<% end%> - -
    - <%= pagination_links_full @obj_pages, @obj_count, :per_page_links => false, :remote => false, :flag => true%> -
-
diff --git a/app/views/courses/new_homework.html.erb b/app/views/courses/new_homework.html.erb deleted file mode 100644 index 9ec73d519..000000000 --- a/app/views/courses/new_homework.html.erb +++ /dev/null @@ -1,4 +0,0 @@ -<%= javascript_include_tag "/assets/kindeditor/kindeditor" %> -<%= labelled_form_for @homework, :html => { :multipart => true }, :url => {:controller => 'bids', :action => 'create_homework',:course_id => "#{params[:id] || params[:course_id]}"} do |f| %> - <%= render :partial => 'bids/new_homework_form', :locals => { :bid => @homework,:bid_id => "new_bid",:f => f,:edit_mode => false } %> -<% end %> \ No newline at end of file diff --git a/app/views/courses/show_member_score.js.erb b/app/views/courses/show_member_score.js.erb index 87e728901..083f070c2 100644 --- a/app/views/courses/show_member_score.js.erb +++ b/app/views/courses/show_member_score.js.erb @@ -7,7 +7,7 @@ showModal('ajax-modal', '400px'); //$('#ajax-modal').css('height','569px'); $('#ajax-modal').siblings().remove(); $('#ajax-modal').before("" + -""); +""); //$('#ajax-modal').parent().removeClass(); $('#ajax-modal').parent().css("top","30%").css("left","40%").css("position","fixed"); $('#ajax-modal').parent().addClass("new-watcher"); diff --git a/app/views/homework_common/_alert_anonyoms.html.erb b/app/views/homework_common/_alert_anonyoms.html.erb new file mode 100644 index 000000000..3b199e0d8 --- /dev/null +++ b/app/views/homework_common/_alert_anonyoms.html.erb @@ -0,0 +1,42 @@ +
+
+ <% if @homework_detail_manual.comment_status == 1%> +

开启匿评功能

+

+ 开启匿评后学生将不能对作品进行 + 修改、删除 + 等操作,目前有 + <%= @totle_size%>个 + 学生,共提交了 + <%= @cur_size %> + 份作品,占 + <%= @percent %>%, + 是否确定开启匿评? +

+ <% elsif @homework_detail_manual.comment_status == 2 %> +

关闭匿评功能

+

+ 关闭匿评后学生将不能对作品进行 + 匿评 + ,且作品列表将会 + 公开, + 目前分配了 + <%= @totle_size%>份 + 匿评作品,已评了 + <%= @cur_size %> + 份作品,占 + <%= @percent %>%, + 是否确定关闭匿评? +

+ <% end %> + +
+
+ diff --git a/app/views/homework_common/_homework_common_form.html.erb b/app/views/homework_common/_homework_common_form.html.erb new file mode 100644 index 000000000..cbe054335 --- /dev/null +++ b/app/views/homework_common/_homework_common_form.html.erb @@ -0,0 +1,108 @@ +
    +
  • + + +

    +
  • +
    +
  • + + + <% if edit_mode %> + <%= f.kindeditor :description,:width=>'83%',:editor_id => 'homework_description_editor',:owner_id => homework.id,:owner_type =>OwnerTypeHelper::HOMEWORKCOMMON %> + <% else %> + <%= hidden_field_tag :asset_id,params[:asset_id],:required => false,:style => 'display:none' %> + <%= f.kindeditor :description,:width=>'83%',:editor_id => 'homework_description_editor' %> + <% end %> +
  • +
    +
  • + + <%= render :partial => 'attachments/new_form', :locals => {:container => homework} %> +
  • +
    +
  • + + + <%= calendar_for('homework_end_time')%> +
    +
  • +
  • + + + <%= calendar_for('homework_publish_time')%> +
    +
  • +
    +
+
+

基本规则设置(总分为100分)

+
+
    +
  • + + <%= select_tag :late_penalty,options_for_select(late_penalty_option,homework.late_penalty), {:class => "fl mb10 h26 w70"} %> +  分 +
    +
  • +
  • + + <%= f.check_box :homework_type, :class => "mb10 mt5 fl" %> +
    +
  • +
  • + + <%= select_tag :ta_proportion,options_for_select(ta_proportion_option,homework.homework_detail_manual.ta_proportion), {:class => "fl mb10 h26 w70"} %> + × 教辅评分 +   +   + + × 匿评得分 + = 学生得分 +
    +
  • +
  • + + 如果教师对学生作品进行了评分,则教师评分为学生最终得分。 +
    +
  • +
+
+ +
+

学生互评设置

+
+
    +
  • + + + <%= calendar_for('evaluation_start_time')%> +
    +
  • +
  • + + + <%= calendar_for('evaluation_end_time')%> +
    +
  • +
  • + + +

    每个学生将收到 3 份待匿评作品

    +
    +
  • + +
  • + + <%= select_tag :absence_penalty,options_for_select(absence_penalty_option,homework.homework_detail_manual.absence_penalty), {:class => "fl mb10 h26 w70"} %> +  分 +

    学生漏评1个作品将扣 2 

    +
    +
  • +
+
\ No newline at end of file diff --git a/app/views/homework_common/alert_anonymous_comment.js.erb b/app/views/homework_common/alert_anonymous_comment.js.erb new file mode 100644 index 000000000..2b3248dc2 --- /dev/null +++ b/app/views/homework_common/alert_anonymous_comment.js.erb @@ -0,0 +1,7 @@ +$('#ajax-modal').html('<%= escape_javascript(render :partial => 'alert_anonyoms') %>'); +showModal('ajax-modal', '500px'); +$('#ajax-modal').siblings().remove(); +$('#ajax-modal').before("" + +""); +$('#ajax-modal').parent().css("top","").css("left",""); +$('#ajax-modal').parent().addClass("anonymos"); \ No newline at end of file diff --git a/app/views/homework_common/edit.html.erb b/app/views/homework_common/edit.html.erb new file mode 100644 index 000000000..f9d3f8b70 --- /dev/null +++ b/app/views/homework_common/edit.html.erb @@ -0,0 +1,16 @@ +<%= javascript_include_tag "/assets/kindeditor/kindeditor" %> +<%= error_messages_for 'homework_common' %> + +
+

+ <%= l(:label_course_homework_edit)%> +

+
+
+ <%= form_for @homework do |f| %> + <%= render :partial => 'homework_common/homework_common_form', :locals => { :homework => @homework,:f => f,:edit_mode => true } %> + 提交 + <%= link_to '取消',homework_common_index_path(:course => @course.id),:class => 'grey_btn fl'%> + <% end%> +
+
\ No newline at end of file diff --git a/app/views/homework_common/index.html.erb b/app/views/homework_common/index.html.erb new file mode 100644 index 000000000..87bf37f04 --- /dev/null +++ b/app/views/homework_common/index.html.erb @@ -0,0 +1,81 @@ +
+

+ <%= l(:label_homework)%> +

+
+
+

+ <%= l(:label_totle)%> + <%= @obj_count%> + <%= l(:label_homework_count)%> +

+ <%= link_to( l(:label_course_homework_new), new_homework_common_path(:course => @course.id), :class => 'problem_new_btn fl c_dorange') if @is_teacher %> +
+
+<% @homeworks.each do |homework|%> +
+ <%= link_to(image_tag(url_to_avatar(homework.user), :width => "42", :height => "42"), user_path(homework.user), :class => "problem_pic fl") %> +
+ <%= link_to(homework.user.lastname+homework.user.firstname, user_path(homework.user),:class => 'problem_name fl') %> + <%= l(:label_user_create_project_homework) %>: + <%= link_to(homework.name, student_work_index_path(:homework => homework.id), :class => 'problem_tit fl fb c_dblue') %> +
+

+ <%= l(:lebel_homework_commit)%> + ( <%= link_to homework.student_works.count, student_work_index_path(:homework => homework.id), :class => 'c_red'%> ) +

+ <% if @is_teacher%> + <%= homework_anonymous_comment(homework)%> + <%= link_to(l(:label_bid_respond_delete), homework_common_path(homework),:method => 'delete', :confirm => l(:text_are_you_sure), :class => "fr mr10 work_edit") %> + <%= link_to(l(:button_edit),edit_homework_common_path(homework), :class => "fr mr10 work_edit") %> + <% elsif @is_student%> + <%= student_anonymous_comment homework %> + <%= student_new_homework homework %> + <% end %> +
+ +
+
+ <%= homework.description.html_safe %> +
+
+ + +
+
+ <% unless homework.attachments.empty?%> + 附件: +
+ <%= render :partial => 'student_work/work_attachments', :locals => {:attachments => homework.attachments} %> +
+ <% end%> +
+ +
+ + <%= l(:label_end_time)%>:<%= homework.end_time%> + <% if betweentime(homework.end_time) < 0 %> + + <%= l(:label_commit_limit)%> + + <% else %> + +
+
+ <% end %> +
+
+
+<% end%> + +
    + <%= pagination_links_full @obj_pages, @obj_count, :per_page_links => false, :remote => false, :flag => true%> +
+
\ No newline at end of file diff --git a/app/views/homework_common/new.html.erb b/app/views/homework_common/new.html.erb new file mode 100644 index 000000000..b0fdc5299 --- /dev/null +++ b/app/views/homework_common/new.html.erb @@ -0,0 +1,17 @@ +<%= javascript_include_tag "/assets/kindeditor/kindeditor" %> +<%= error_messages_for 'homework_common' %> + +
+

+ <%= l(:label_course_homework_new)%> +

+
+
+ <%= labelled_form_for @homework,:url => {:controller => 'homework_common',:action => 'create'} do |f| %> + <%= hidden_field_tag "course",@course.id%> + <%= render :partial => 'homework_common/homework_common_form', :locals => { :homework => @homework,:f => f,:edit_mode => false } %> + 提交 + <%= link_to '取消',homework_common_index_path(:course => @course.id),:class => 'grey_btn fl'%> + <% end%> +
+
\ No newline at end of file diff --git a/app/views/homework_common/start_anonymous_comment.js.erb b/app/views/homework_common/start_anonymous_comment.js.erb new file mode 100644 index 000000000..cd4dafde8 --- /dev/null +++ b/app/views/homework_common/start_anonymous_comment.js.erb @@ -0,0 +1,10 @@ +<% if @statue == 1%> +alert('启动成功'); +$("#<%= @homework.id %>_start_anonymous_comment").replaceWith('<%= escape_javascript(link_to "关闭匿评", alert_anonymous_comment_homework_common_path(@homework), remote: true, id:"#{@homework.id}_stop_anonymous_comment",:class => "fr mr10 work_edit")%>'); +<% elsif @statue == 2 %> +alert('启动失败\n作业总数大于等于2份时才能启动匿评'); +<% elsif @statue == 3%> +alert("已开启匿评,请务重复开启"); +<% elsif @statue == 3%> +alert("您没有权限开启匿评"); +<% end %> \ No newline at end of file diff --git a/app/views/homework_common/stop_anonymous_comment.js.erb b/app/views/homework_common/stop_anonymous_comment.js.erb new file mode 100644 index 000000000..9a6131c64 --- /dev/null +++ b/app/views/homework_common/stop_anonymous_comment.js.erb @@ -0,0 +1,2 @@ +$("#<%= @homework.id %>_stop_anonymous_comment").replaceWith('匿评结束'); +alert('关闭成功'); \ No newline at end of file diff --git a/app/views/layouts/_user_homework_list.html.erb b/app/views/layouts/_user_homework_list.html.erb index 446222bd3..12f37e04d 100644 --- a/app/views/layouts/_user_homework_list.html.erb +++ b/app/views/layouts/_user_homework_list.html.erb @@ -1,12 +1,5 @@ <% if course %>
  • <%= link_to course.name, course_path(course.id, host: Setting.host_course) %> -
      - <% course.homework_for_courses.map(&:bid).each do |bid| %> -
    • - <%= link_to bid.name, course_for_bid_path(bid, host: Setting.host_course), :target => "_blank" %> -
    • - <% end %> -
  • <% end %> \ No newline at end of file diff --git a/app/views/layouts/base_courses.html.erb b/app/views/layouts/base_courses.html.erb index 070a99d08..382bcf590 100644 --- a/app/views/layouts/base_courses.html.erb +++ b/app/views/layouts/base_courses.html.erb @@ -17,8 +17,8 @@ <%= javascript_heads %> <%= heads_for_theme %> <%= call_hook :view_layouts_base_html_head %> - <%= stylesheet_link_tag 'public', 'leftside', 'courses'%> - <%= javascript_include_tag "course","header" %> + <%= stylesheet_link_tag 'public', 'leftside', 'jquery/jquery-ui-1.9.2', 'courses'%> + <%= javascript_include_tag "course","header","attachments" %> <%= yield :header_tags -%> @@ -116,9 +116,9 @@ <%= link_to "(#{course_activity_count @course})", course_path(@course), :class => "subnav_num c_orange"%>