diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 10fec7c1b..3114ef5e0 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -26,6 +26,7 @@ class UsersController < ApplicationController menu_item :user_information, :only => :info menu_item :user_course, :only => :user_courses menu_item :user_homework, :only => :user_homeworks + menu_item :student_homework, :only => :student_homeworks menu_item :user_project, :only => [:user_projects, :watch_projects] menu_item :requirement_focus, :only => :watch_contests menu_item :user_newfeedback, :only => :user_newfeedback @@ -35,12 +36,12 @@ class UsersController < ApplicationController # before_filter :can_show_course, :only => [:user_courses,:user_homeworks] before_filter :find_user, :only => [:user_fanslist, :user_watchlist, :show, :edit, :update, :destroy, :edit_membership, :user_courses, - :user_homeworks, :destroy_membership, :user_activities, :user_projects, :user_newfeedback, :user_comments, + :user_homeworks,:student_homeworks, :destroy_membership, :user_activities, :user_projects, :user_newfeedback, :user_comments, :watch_contests, :info, :watch_projects, :show_score, :topic_score_index, :project_score_index, :activity_score_index, :influence_score_index, :score_index,:show_new_score, :topic_new_score_index, :project_new_score_index, :activity_new_score_index, :influence_new_score_index, :score_new_index,:user_projects_index,:user_resource, :user_courses4show,:user_projects4show,:user_course_activities,:user_project_activities,:user_feedback4show,:user_visitorlist,:user_messages,:edit_brief_introduction, - :user_import_homeworks,:user_search_homeworks,:user_import_resource, :user_system_messages] + :user_import_homeworks,:user_search_homeworks,:user_import_resource, :user_system_messages,:choose_user_course] before_filter :auth_user_extension, only: :show #before_filter :rest_user_score, only: :show #before_filter :select_entry, only: :user_projects @@ -374,32 +375,130 @@ class UsersController < ApplicationController #用户作业列表 def user_homeworks - if User.current == @user - @page = params[:page] ? params[:page].to_i + 1 : 0 - user_course_ids = @user.courses.empty? ? "(-1)" :"(" + @user.courses.visible.map{|course| course.id}.join(",") + ")" + @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 + format.html {render :layout => 'static_base'} + end + end - #判断当前用户在当前课程的身份 - visibleCourse = @user.courses.empty? ? [] : @user.courses.visible - homework_ids = [] - visibleCourse.each do |course| - if User.current.allowed_to?(:as_teacher,course) - homeworks = HomeworkCommon.where("course_id = #{course.id}") - homework_ids << homeworks.pluck(:id) unless homeworks.empty? - else - homeworks = HomeworkCommon.where("course_id = #{course.id} and publish_time <= '#{Date.today}'") - homework_ids << homeworks.pluck(:id) unless homeworks.empty? + def student_homeworks + if User.current == @user + @page = params[:page] ? params[:page].to_i + 1 : 0 + user_course_ids = @user.courses.empty? ? "(-1)" :"(" + @user.courses.visible.map{|course| course.id}.join(",") + ")" + + #判断当前用户在当前课程的身份 + visibleCourse = @user.courses.empty? ? [] : @user.courses.visible + homework_ids = [] + visibleCourse.each do |course| + homeworks = HomeworkCommon.where("course_id = #{course.id} and publish_time <= '#{Date.today}'") + homework_ids << homeworks.pluck(:id) unless homeworks.empty? + end + visible_homework_ids = homework_ids.size == 0 ? "(-1)" :"(" + homework_ids.join(",") + ")" + @homework_commons = HomeworkCommon.where("id in #{visible_homework_ids}").order("created_at desc").limit(10).offset(@page * 10) + @is_teacher = User.current.user_extensions && User.current.user_extensions.identity == 0 && User.current.allowed_to?(:add_course, nil, :global => true) + @is_in_course = params[:is_in_course].to_i || 0 + respond_to do |format| + format.js + format.html {render :layout => 'new_base_user'} + end + else + render_403 + end + end + + def choose_user_course + if !params[:search].nil? + search = "%#{params[:search].to_s.strip.downcase}%" + @course = @user.courses.where(" #{Course.table_name}.id = #{params[:search].to_i } or #{Course.table_name}.name like :p",:p=>search).select { |course| @user.allowed_to?(:as_teacher,course)} + else + @course = @user.courses.select { |course| @user.allowed_to?(:as_teacher,course)} + end + @search = params[:search] + #这里仅仅是传递需要发送的资源id + @send_id = params[:send_id] + respond_to do |format| + format.js + end + end + + def send_homework_to_course + homework = HomeworkCommon.find params[:send_id].to_i + course_ids = params[:course_ids] + course_ids.each do |course_id| + course = Course.find course_id.to_i + new_homework = HomeworkCommon.new + new_homework.name = homework.name + new_homework.user_id = User.current.id + new_homework.description = homework.description + new_homework.homework_type = homework.homework_type + new_homework.late_penalty = homework.late_penalty + new_homework.course_id = course.id + new_homework.teacher_priority = homework.teacher_priority + new_homework.anonymous_comment = homework.anonymous_comment + new_homework.quotes = 0 + new_homework.is_open = homework.is_open + homework.attachments.each do |attachment| + att = attachment.copy + att.container_id = nil + att.container_type = nil + att.copy_from = attachment.id + att.save + new_homework.attachments << att + end + homework_detail_manual = homework.homework_detail_manual + homework_detail_programing = homework.homework_detail_programing + homework_detail_group = homework.homework_detail_group + if homework_detail_manual + new_homework.homework_detail_manual = HomeworkDetailManual.new + new_homework_detail_manual = new_homework.homework_detail_manual + new_homework_detail_manual.ta_proportion = homework_detail_manual.ta_proportion + new_homework_detail_manual.comment_status = 0 + new_homework_detail_manual.evaluation_num = homework_detail_manual.evaluation_num + new_homework_detail_manual.absence_penalty = homework_detail_manual.absence_penalty + end + if homework_detail_programing + new_homework.homework_detail_programing = HomeworkDetailPrograming.new + new_homework.homework_detail_programing.ta_proportion = homework_detail_programing.ta_proportion + new_homework.homework_detail_programing.language = homework_detail_programing.language + homework.homework_tests.each_with_index do |homework_test| + new_homework.homework_tests << HomeworkTest.new( + input: homework_test.input, + output: homework_test.output + ) end end - visible_homework_ids = homework_ids.size == 0 ? "(-1)" :"(" + homework_ids.join(",") + ")" - @homework_commons = HomeworkCommon.where("id in #{visible_homework_ids}").order("created_at desc").limit(10).offset(@page * 10) - @is_teacher = User.current.user_extensions && User.current.user_extensions.identity == 0 && User.current.allowed_to?(:add_course, nil, :global => true) - @is_in_course = params[:is_in_course].to_i || 0 - respond_to do |format| - format.js - format.html {render :layout => 'new_base_user'} + + if homework_detail_group + new_homework.homework_detail_group = HomeworkDetailGroup.new + new_homework.homework_detail_group.min_num = homework_detail_group.min_num + new_homework.homework_detail_group.max_num = homework_detail_group.max_num + new_homework.homework_detail_group.base_on_project = homework_detail_group.base_on_project end - else - render_403 + if new_homework.save + new_homework_detail_manual.save if new_homework_detail_manual + new_homework.homework_detail_programing.save if new_homework.homework_detail_programing + new_homework.homework_detail_group.save if new_homework.homework_detail_group + end + homework.update_attribute(:quotes, homework.quotes+1) + end + @homework = homework + respond_to do |format| + format.js end end @@ -439,6 +538,7 @@ class UsersController < ApplicationController @hw_pages = Paginator.new @hw_count, @limit, params['page'] || 1 @offset ||= @hw_pages.offset @homeworks = paginateHelper @homeworks,15 + @is_import = params[:is_import] respond_to do |format| format.js end @@ -446,6 +546,7 @@ class UsersController < ApplicationController def show_homework_detail @homework = HomeworkCommon.find params[:homework].to_i + @is_import = params[:is_import] respond_to do |format| format.js end @@ -469,6 +570,7 @@ class UsersController < ApplicationController @hw_pages = Paginator.new @hw_count, @limit, params['page'] || 1 @offset ||= @hw_pages.offset @homeworks = paginateHelper @homeworks,15 + @is_import = params[:is_import] respond_to do |format| format.js end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 0995a6289..c37d3ad55 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -2521,7 +2521,7 @@ module ApplicationHelper #获取匿评相关连接代码 def homework_anonymous_comment (homework, is_in_course, user_activity_id = -1, course_activity = -1) - if Time.parse(homework.end_time.to_s).strftime("%Y-%m-%d") >= Time.now.strftime("%Y-%m-%d") + if homework.homework_detail_manual.comment_status == 0 ||Time.parse(homework.end_time.to_s).strftime("%Y-%m-%d") >= Time.now.strftime("%Y-%m-%d") link = link_to "启动匿评","javascript:void(0)", :class => "postOptionLink", :title => "作业截止日期之前不可以启动匿评" elsif homework.student_works.count >= 2 && homework.homework_detail_manual#作业份数大于2 case homework.homework_detail_manual.comment_status diff --git a/app/helpers/courses_helper.rb b/app/helpers/courses_helper.rb index 8db852abd..6fb9380e7 100644 --- a/app/helpers/courses_helper.rb +++ b/app/helpers/courses_helper.rb @@ -116,7 +116,7 @@ module CoursesHelper @course.journals_for_messages.where('m_parent_id IS NULL').count end - #当前学期 + #当前学期(2015春季学期) def current_time_and_term course str = "" term = cur_course_term @@ -144,6 +144,22 @@ module CoursesHelper val end + #当前学期(2015春) + def current_time_and_term_short course + str = "" + term = cur_course_term + if (course.time == course.end_time && course.term == course.end_term) || (course.end_term.nil? && course.end_time.nil?) || course.time > Time.now.year + str = course.time.to_s + course.term[0] + elsif course.time == Time.now.year && set_term_value(cur_course_term) <= set_term_value(course.term) + str = course.time.to_s + course.term[0] + elsif course.end_time < Time.now.year || (course.end_time == Time.now.year && set_term_value(cur_course_term) >= set_term_value(course.term)) + str = course.end_time.to_s + course.end_term[0] + else + str = Time.now.year.to_s + cur_course_term[0] + end + str + end + # 返回学生数量,即roles表中定义的Reporter #def studentCount project # searchStudent(project).count diff --git a/app/helpers/exercise_helper.rb b/app/helpers/exercise_helper.rb index aba2fb58e..5792c6487 100644 --- a/app/helpers/exercise_helper.rb +++ b/app/helpers/exercise_helper.rb @@ -86,6 +86,31 @@ module ExerciseHelper return result end + def convert_to_chi_num num + result = "" + case num.to_i + when 1 + result = '一' + when 2 + result = '二' + when 3 + result = '三' + when 4 + result = '四' + when 5 + result = '五' + when 6 + result = '六' + when 7 + result = '七' + when 8 + result = '八' + when 9 + result = '九' + end + return result + end + def get_current_score exercise score = 0 unless exercise.nil? diff --git a/app/views/admin/latest_login_teachers.html.erb b/app/views/admin/latest_login_teachers.html.erb index 06c0386f5..a42e84369 100644 --- a/app/views/admin/latest_login_teachers.html.erb +++ b/app/views/admin/latest_login_teachers.html.erb @@ -59,17 +59,17 @@ <%=format_time(teacher.last_login_on) %> - <%=teacher.id %> + <%=teacher.user_id %> <%= teacher.login%><% else %><%=teacher.try(:realname) %><% end %>'> <% if teacher.try(:realname) == ' '%> - <%= link_to(teacher.login, user_path(teacher)) %> + <%= link_to(teacher.login, user_path(teacher.user_id)) %> <% else %> - <%= link_to(teacher.try(:realname), user_path(teacher)) %> + <%= link_to(teacher.try(:realname), user_path(teacher.user_id)) %> <% end %> - <%=link_to(teacher.login, user_path(teacher)) %> + <%=link_to(teacher.login, user_path(teacher.user_id)) %> 老师 diff --git a/app/views/courses/_copy_course.html.erb b/app/views/courses/_copy_course.html.erb index 68184d352..402e00cf6 100644 --- a/app/views/courses/_copy_course.html.erb +++ b/app/views/courses/_copy_course.html.erb @@ -1,4 +1,11 @@ diff --git a/app/views/exercise/_new_MC.html.erb b/app/views/exercise/_new_MC.html.erb index 0d7350570..6fd6c201e 100644 --- a/app/views/exercise/_new_MC.html.erb +++ b/app/views/exercise/_new_MC.html.erb @@ -18,28 +18,28 @@
  • - +
  • - +
  • - +
  • - + diff --git a/app/views/exercise/_new_MCQ.html.erb b/app/views/exercise/_new_MCQ.html.erb index 3ea198d8f..a24835fc1 100644 --- a/app/views/exercise/_new_MCQ.html.erb +++ b/app/views/exercise/_new_MCQ.html.erb @@ -18,28 +18,28 @@
  • - +
  • - +
  • - +
  • - + diff --git a/app/views/exercise/_new_single.html.erb b/app/views/exercise/_new_single.html.erb index 061b053fd..3a65c072d 100644 --- a/app/views/exercise/_new_single.html.erb +++ b/app/views/exercise/_new_single.html.erb @@ -18,22 +18,22 @@
  • - - + +
  • - - + +
  • - - + +
  • diff --git a/app/views/exercise/_show_MC.html.erb b/app/views/exercise/_show_MC.html.erb index d052bd6da..eef7546e5 100644 --- a/app/views/exercise/_show_MC.html.erb +++ b/app/views/exercise/_show_MC.html.erb @@ -55,28 +55,28 @@ '分'+ '
    '+ '
  • '+ - ''+ + ''+ ''+ ''+ ''+ '
  • '+ '
    '+ '
  • '+ - ''+ + ''+ ''+ ''+ ''+ '
  • '+ '
    '+ '
  • '+ - ''+ + ''+ ''+ ''+ ''+ '
  • '+ '
    '+ '
  • '+ - ''+ + ''+ ''+ ''+ ''+ diff --git a/app/views/exercise/_show_MCQ.html.erb b/app/views/exercise/_show_MCQ.html.erb index a477303d7..9e66f17f9 100644 --- a/app/views/exercise/_show_MCQ.html.erb +++ b/app/views/exercise/_show_MCQ.html.erb @@ -54,28 +54,28 @@ '分'+ '
  • '+ '
  • '+ - ''+ + ''+ ''+ ''+ ''+ '
  • '+ '
    '+ '
  • '+ - ''+ + ''+ ''+ ''+ ''+ '
  • '+ '
    '+ '
  • '+ - ''+ + ''+ ''+ ''+ ''+ '
  • '+ '
    '+ '
  • '+ - ''+ + ''+ ''+ ''+ ''+ diff --git a/app/views/exercise/_show_single.html.erb b/app/views/exercise/_show_single.html.erb index 86203b8bb..90f604da1 100644 --- a/app/views/exercise/_show_single.html.erb +++ b/app/views/exercise/_show_single.html.erb @@ -9,7 +9,7 @@
    <% exercise_question.exercise_standard_answers.reorder("created_at").each_with_index do |exercise_choice,index| %> - 候选答案:<%= exercise_choice.answer_text%>
    + 候选答案<%= convert_to_chi_num(index+1) %>:<%= exercise_choice.answer_text%>
    <% end %>
  • @@ -42,22 +42,22 @@ '分'+ '
    '+ '
  • '+ - ''+ - ''+ + ''+ + ''+ ''+ ''+ '
  • '+ '
    '+ '
  • '+ - ''+ - ''+ + ''+ + ''+ ''+ ''+ '
  • '+ '
    '+ '
  • '+ - ''+ - ''+ + ''+ + ''+ ''+ ''+ '
  • '+ diff --git a/app/views/files/_org_subfield_list.html.erb b/app/views/files/_org_subfield_list.html.erb index 866cf6fd8..d249aede9 100644 --- a/app/views/files/_org_subfield_list.html.erb +++ b/app/views/files/_org_subfield_list.html.erb @@ -10,7 +10,7 @@
    <%= link_to truncate(file.filename,length: 35, omission: '...'), download_named_attachment_path(file.id, file.filename), - :title => file.filename+"\n"+file.description.to_s, :style => "overflow: hidden; white-space: nowrap;text-overflow: ellipsis;",:class => "c_dblue f_14 f_b f_l" %> + :title => file.filename+"\n"+file.description.to_s, :style => "overflow: hidden; white-space: nowrap;text-overflow: ellipsis;",:class => "linkGrey3 f_14 f_l" %> <%= file_preview_eye(file, class: 'preview') %> <% if file.is_public? == false%> diff --git a/app/views/files/_project_list.html.erb b/app/views/files/_project_list.html.erb index 391430126..81227529e 100644 --- a/app/views/files/_project_list.html.erb +++ b/app/views/files/_project_list.html.erb @@ -10,7 +10,7 @@
    <%= link_to truncate(file.filename,length: 35, omission: '...'), download_named_attachment_path(file.id, file.filename), - :title => file.filename+"\n"+file.description.to_s, :style => "overflow: hidden; white-space: nowrap;text-overflow: ellipsis;",:class => "linkBlue f_14 f_b" %> + :title => file.filename+"\n"+file.description.to_s, :style => "overflow: hidden; white-space: nowrap;text-overflow: ellipsis;",:class => "linkGrey3 f_14" %> <%= file_preview_eye(file, class: 'preview') %> <% if file.is_public? == false%> diff --git a/app/views/files/_resource_detail.html.erb b/app/views/files/_resource_detail.html.erb index fd0a165aa..6342e91f6 100644 --- a/app/views/files/_resource_detail.html.erb +++ b/app/views/files/_resource_detail.html.erb @@ -8,7 +8,7 @@
    <%= link_to truncate(file.filename,length: 35, omission: '...'), download_named_attachment_path(file.id, file.filename), - :title => file.filename+"\n"+file.description.to_s, :style => "overflow: hidden; white-space: nowrap;text-overflow: ellipsis;",:class => "linkBlue f_14 f_b" %> + :title => file.filename+"\n"+file.description.to_s, :style => "overflow: hidden; white-space: nowrap;text-overflow: ellipsis;",:class => "linkGrey3 f_14" %> <%= file_preview_eye(file, class: 'preview') %> <% if file.is_public? == false%> diff --git a/app/views/layouts/_logined_header.html.erb b/app/views/layouts/_logined_header.html.erb index be8c4bbba..f2de04ea1 100644 --- a/app/views/layouts/_logined_header.html.erb +++ b/app/views/layouts/_logined_header.html.erb @@ -9,9 +9,15 @@ + <% if User.current.user_extensions && User.current.user_extensions.identity == 0 && User.current.allowed_to?(:add_course, nil, :global => true)%> + <% else %> + + <% end %> diff --git a/app/views/layouts/static_base.html.erb b/app/views/layouts/static_base.html.erb index f73d1bc61..32436f23d 100644 --- a/app/views/layouts/static_base.html.erb +++ b/app/views/layouts/static_base.html.erb @@ -47,7 +47,10 @@
    <%= render :partial => 'layouts/footer' %>
    - + + <%= call_hook :view_layouts_base_body_bottom %> diff --git a/app/views/organizations/_org_course_homework.html.erb b/app/views/organizations/_org_course_homework.html.erb index 77ff5de13..4767e2ad2 100644 --- a/app/views/organizations/_org_course_homework.html.erb +++ b/app/views/organizations/_org_course_homework.html.erb @@ -89,7 +89,7 @@ <% end %> <% if activity.homework_detail_manual && activity.homework_detail_manual.comment_status < 2 %>
    提交截止时间:<%= activity.end_time.to_s %> 23:59
    - <% elsif activity.homework_detail_manual && activity.homework_detail_manual.comment_status >= 2 %> + <% elsif activity.homework_detail_manual && activity.homework_detail_manual.comment_status >= 2 && activity.anonymous_comment == 0%>
    匿评截止时间:<%= activity.homework_detail_manual.evaluation_end.to_s %> 23:59
    <% end %>
    diff --git a/app/views/users/_course_homework.html.erb b/app/views/users/_course_homework.html.erb index b43951c08..5e684ab15 100644 --- a/app/views/users/_course_homework.html.erb +++ b/app/views/users/_course_homework.html.erb @@ -89,7 +89,7 @@ <% end %> <% if activity.homework_detail_manual && activity.homework_detail_manual.comment_status < 2 %>
    提交截止时间:<%= activity.end_time.to_s %> 23:59
    - <% elsif activity.homework_detail_manual && activity.homework_detail_manual.comment_status >= 2 %> + <% elsif activity.homework_detail_manual && activity.homework_detail_manual.comment_status >= 2 && activity.anonymous_comment == 0%>
    匿评截止时间:<%= activity.homework_detail_manual.evaluation_end.to_s %> 23:59
    <% end %>
    diff --git a/app/views/users/_homework_detail_information.html.erb b/app/views/users/_homework_detail_information.html.erb index d650cd084..e43b5b6c7 100644 --- a/app/views/users/_homework_detail_information.html.erb +++ b/app/views/users/_homework_detail_information.html.erb @@ -1,9 +1,9 @@ -
    题目信息
    -
    +
    题目信息
    +
    <% if homework.nil? %> 请先在左侧选择作业 <% else %> -
    标题:<%=homework.name %>
    +
    标题:<%=homework.name %>
    来源:<%=homework.course.name %>
    <% if homework.homework_type == 2 && homework.homework_detail_programing %> 编程语言:<%=homework.language_name %>
    @@ -15,15 +15,15 @@
    描述如下:
    -
    +
    <%=homework.description.html_safe %>
    <% if homework.homework_type == 2 %> -
    +
    测试集:<%=homework.homework_tests.count %>组
    <% elsif homework.homework_type ==3 && homework.homework_detail_group %> -
    +
    分组人数:<%=homework.homework_detail_group.min_num %> - <%=homework.homework_detail_group.max_num %>人
    <% end %> diff --git a/app/views/users/_homework_repository.html.erb b/app/views/users/_homework_repository.html.erb new file mode 100644 index 000000000..d514f4b59 --- /dev/null +++ b/app/views/users/_homework_repository.html.erb @@ -0,0 +1,39 @@ + + +
    + <% homeworks.each do |homework| %> +
      + + +
    • + <% case homework.homework_type %> + <% when 1 %> + 普通 + <% when 2 %> + 编程 + <% when 3 %> + 分组 + <% end %> +
    • + +
    • <%= homework.quotes %>
    • +
    • <%=format_date homework.publish_time %>
    • +
    + <% end %> +
    \ No newline at end of file diff --git a/app/views/users/_homework_repository_detail.html.erb b/app/views/users/_homework_repository_detail.html.erb new file mode 100644 index 000000000..f9df9eee5 --- /dev/null +++ b/app/views/users/_homework_repository_detail.html.erb @@ -0,0 +1,33 @@ +
    +
    题目信息
    +
    + <% if homework.nil? %> + 请先在左侧选择作业 + <% else %> +
    标题:<%=homework.name %>
    + 来源:<%=homework.course.name %>
    + <% if homework.homework_type == 2 && homework.homework_detail_programing %> + 编程语言:<%=homework.language_name %>
    + <% end %> + 贡献者:<%=homework.user.show_name %> + <% if homework.user.user_extensions.occupation && homework.user.user_extensions.occupation!="" %> + ,<%=homework.user.user_extensions.occupation%> + <% end %> +
    + 描述如下: +
    +
    + <%=homework.description.html_safe %> +
    + <% if homework.homework_type == 2 %> +
    + 测试集:<%=homework.homework_tests.count %>组 +
    + <% elsif homework.homework_type ==3 && homework.homework_detail_group %> +
    + 分组人数:<%=homework.homework_detail_group.min_num %> - <%=homework.homework_detail_group.max_num %>人 +
    + <% end %> + <% end %> +
    +
    \ No newline at end of file diff --git a/app/views/users/_homework_search_input.html.erb b/app/views/users/_homework_search_input.html.erb index ba85f0d09..21d1b9625 100644 --- a/app/views/users/_homework_search_input.html.erb +++ b/app/views/users/_homework_search_input.html.erb @@ -1,4 +1,4 @@ - + \ No newline at end of file diff --git a/app/views/users/_show_user_homework_form.html.erb b/app/views/users/_show_user_homework_form.html.erb index 004c8fec4..fff44316b 100644 --- a/app/views/users/_show_user_homework_form.html.erb +++ b/app/views/users/_show_user_homework_form.html.erb @@ -1,12 +1,13 @@ <% homeworks.each do |homework| %> -
      -
    <% end %> - <% if homework_common.homework_detail_manual && homework_common.homework_detail_manual.comment_status < 2 %> + <% if homework_common.homework_detail_manual && homework_common.homework_detail_manual.comment_status < 2 && !homework_common.publish_time.nil? %>
    提交截止时间:<%= homework_common.end_time.to_s %> 23:59
    - <% elsif homework_common.homework_detail_manual && homework_common.homework_detail_manual.comment_status >= 2 %> + <% elsif homework_common.homework_detail_manual && homework_common.homework_detail_manual.comment_status >= 2 && !homework_common.publish_time.nil? && homework_common.anonymous_comment == 0 %>
    匿评截止时间:<%= homework_common.homework_detail_manual.evaluation_end.to_s %> 23:59
    <% end %> - <% if homework_common.homework_detail_manual.comment_status == 0 %> + <% if homework_common.homework_detail_manual.comment_status == 0 && !homework_common.publish_time.nil? %>
    <%= l(:label_publish_time)%>:<%= homework_common.publish_time%> 00:00
    @@ -107,7 +109,7 @@
    迟交扣分:<%= homework_common.late_penalty%>分
    - <% if homework_common.anonymous_comment == 0%> + <% if homework_common.anonymous_comment == 0 && !homework_common.publish_time.nil?%>
    匿评开启时间:<%= homework_common.homework_detail_manual.evaluation_start%> 00:00
    @@ -120,7 +122,7 @@ 缺评扣分:<%= homework_common.homework_detail_manual.absence_penalty%>分/作品
    <% end %> - <% if homework_common.anonymous_comment == 0%> + <% if homework_common.anonymous_comment == 0 && !homework_common.publish_time.nil?%>
    匿评关闭时间:<%= homework_common.homework_detail_manual.evaluation_end%> 23:59
    diff --git a/app/views/users/_user_homework_form.html.erb b/app/views/users/_user_homework_form.html.erb index 0d542882a..88e81827e 100644 --- a/app/views/users/_user_homework_form.html.erb +++ b/app/views/users/_user_homework_form.html.erb @@ -228,7 +228,9 @@ +
    +
    作业
    +
    +
    + +<% if @is_teacher%> + +
    + <% homework = HomeworkCommon.new %> + <% homework.homework_detail_manual = HomeworkDetailManual.new%> + <%= labelled_form_for homework,:url => user_new_homework_users_path,:method => "post" do |f| %> +
    + <%= render :partial => 'users/user_homework_form', :locals => { :homework => homework,:f => f,:edit_mode => false } %> +
    + <% end%> +
    +<% end%> + +<%= render :partial => 'users/user_homework_list', :locals => {:homework_commons => @homework_commons,:page => 0,:is_in_course => 0} %> diff --git a/app/views/users/_user_programing_attr.html.erb b/app/views/users/_user_programing_attr.html.erb index 71816689b..8657e5542 100644 --- a/app/views/users/_user_programing_attr.html.erb +++ b/app/views/users/_user_programing_attr.html.erb @@ -7,10 +7,11 @@ <%= options_for_select({"C语言"=>1, "C++"=>2, "Python"=>3, "Java"=>4}, (edit_mode && homework.is_program_homework?) ? homework.language : 1) %>
    -
    +
    <% if edit_mode && homework.is_program_homework? %> <% homework.homework_tests.each_with_index do |test, index| %>
    + @@ -22,6 +23,7 @@ <% end %> <% else %>
    + diff --git a/app/views/users/_user_resource_info.html.erb b/app/views/users/_user_resource_info.html.erb index e34f9d237..2d5415c4e 100644 --- a/app/views/users/_user_resource_info.html.erb +++ b/app/views/users/_user_resource_info.html.erb @@ -23,21 +23,22 @@ <%= render :partial => 'users/resources_list' , :locals => { :attachments => @attachments} %>
    + +
    - +
    - 全选 - 删除 -
    -
    选择 0 个资源
    -
    - 发送 -
    + 全选 删除
    +
    +
    + +
    选择 0 个资源
    + -
      <%= pagination_links_full @atta_pages, @atta_count, :per_page_links => false, :remote => @is_remote, :flag => true %> diff --git a/app/views/users/choose_user_course.js.erb b/app/views/users/choose_user_course.js.erb new file mode 100644 index 000000000..0be5990e9 --- /dev/null +++ b/app/views/users/choose_user_course.js.erb @@ -0,0 +1,7 @@ +$("#ajax-modal").html('<%= escape_javascript( render :partial => 'users/send_homework_to_course', :locals => {:courses => @course, :user => @user, :send_id => @send_id}) %>'); +showModal('ajax-modal', '452px'); +$('#ajax-modal').siblings().remove(); +$('#ajax-modal').before(""); +$('#ajax-modal').parent().css("top","50%").css("left","50%"); +$('#ajax-modal').parent().addClass("popbox").addClass("resourceUploadPopup"); +$('#ajax-modal').css("padding-left","16px").css("padding-bottom","16px"); \ No newline at end of file diff --git a/app/views/users/send_homework_to_course.js.erb b/app/views/users/send_homework_to_course.js.erb new file mode 100644 index 000000000..491156876 --- /dev/null +++ b/app/views/users/send_homework_to_course.js.erb @@ -0,0 +1 @@ +$("#subject_count_homework_<%=@homework.id %>").html(<%= @homework.quotes %>); \ No newline at end of file diff --git a/app/views/users/show_homework_detail.js.erb b/app/views/users/show_homework_detail.js.erb index 12be1b786..6652e5344 100644 --- a/app/views/users/show_homework_detail.js.erb +++ b/app/views/users/show_homework_detail.js.erb @@ -1 +1,5 @@ -$("#homework_detail_information").html("<%=escape_javascript(render :partial => 'users/homework_detail_information', :locals => {:homework=>@homework}) %>") \ No newline at end of file +<% if @is_import.to_i == 1 %> + $("#homework_detail_information").html("<%=escape_javascript(render :partial => 'users/homework_detail_information', :locals => {:homework=>@homework}) %>"); +<% else %> + $("#homework_repository_detail").html("<%=escape_javascript(render :partial => 'users/homework_repository_detail', :locals => {:homework=>@homework}) %>"); +<% end %> \ No newline at end of file diff --git a/app/views/users/student_homeworks.html.erb b/app/views/users/student_homeworks.html.erb new file mode 100644 index 000000000..fefea3e8c --- /dev/null +++ b/app/views/users/student_homeworks.html.erb @@ -0,0 +1,47 @@ + +
      +
      作业
      +
      +
      + +<% if @is_teacher%> + +
      + <% homework = HomeworkCommon.new %> + <% homework.homework_detail_manual = HomeworkDetailManual.new%> + <%= labelled_form_for homework,:url => user_new_homework_users_path,:method => "post" do |f| %> +
      + <%= render :partial => 'users/user_homework_form', :locals => { :homework => homework,:f => f,:edit_mode => false } %> +
      + <% end%> +
      +<% end%> + +<%= render :partial => 'users/user_homework_list', :locals => {:homework_commons => @homework_commons,:page => 0,:is_in_course => 0} %> diff --git a/app/views/users/student_homeworks.js.erb b/app/views/users/student_homeworks.js.erb new file mode 100644 index 000000000..c34be666c --- /dev/null +++ b/app/views/users/student_homeworks.js.erb @@ -0,0 +1 @@ +$("#user_show_more_homework").replaceWith("<%= escape_javascript( render :partial => 'users/user_homework_list',:locals => {:homework_commons => @homework_commons, :page => @page,:is_in_course => 0} )%>"); \ No newline at end of file diff --git a/app/views/users/user_homework_type.js.erb b/app/views/users/user_homework_type.js.erb index 691fdc72b..246a927b0 100644 --- a/app/views/users/user_homework_type.js.erb +++ b/app/views/users/user_homework_type.js.erb @@ -1,4 +1,11 @@ +<% if @is_import.to_i == 1 %> $("#homework_list_form_show").html('<%= escape_javascript(render :partial => 'users/show_user_homework_form', :locals => {:homeworks => @homeworks})%>'); $("#homewrok_ref_pages").html('<%= pagination_links_full @hw_pages, @hw_count, :per_page_links => false, :remote => @is_remote, :flag => true %>'); $("#homework_detail_information").html("<%=escape_javascript(render :partial => 'users/homework_detail_information', :locals => {:homework=>nil}) %>"); -$("#homework_search_input").html("<%=escape_javascript(render :partial=>'homework_search_input', :locals=>{:type=>@type}) %>"); \ No newline at end of file +$("#homework_search_input").html("<%=escape_javascript(render :partial=>'homework_search_input', :locals=>{:type=>@type,:is_import=>@is_import}) %>"); +<% else %> +$("#homework_repository").html('<%= escape_javascript(render :partial => 'users/homework_repository', :locals => {:homeworks => @homeworks})%>'); +$("#homework_pository_ref_pages").html('<%= pagination_links_full @hw_pages, @hw_count, :per_page_links => false, :remote => @is_remote, :flag => true %>'); +$("#homework_repository_detail").html("<%=escape_javascript(render :partial => 'users/homework_repository_detail', :locals => {:homework=>nil}) %>"); +$("#homework_search_input").html("<%=escape_javascript(render :partial=>'homework_search_input', :locals=>{:type=>@type,:is_import=>@is_import}) %>"); +<% end %> diff --git a/app/views/users/user_homeworks.html.erb b/app/views/users/user_homeworks.html.erb index d0adb291f..e48d51ec7 100644 --- a/app/views/users/user_homeworks.html.erb +++ b/app/views/users/user_homeworks.html.erb @@ -1,47 +1,96 @@ - -
      -
      作业
      -
      -
      -<% if @is_teacher%> - -
      - <% homework = HomeworkCommon.new %> - <% homework.homework_detail_manual = HomeworkDetailManual.new%> - <%= labelled_form_for homework,:url => user_new_homework_users_path,:method => "post" do |f| %> -
      - <%= render :partial => 'users/user_homework_form', :locals => { :homework => homework,:f => f,:edit_mode => false } %> -
      - <% end%> -
      -<% end%> - -<%= render :partial => 'users/user_homework_list', :locals => {:homework_commons => @homework_commons,:page => 0,:is_in_course => 0} %> +
      +
      +
      + +
      +
      + <%=render :partial=>'homework_search_input', :locals=>{:type => @type,:is_import => 0} %> +
      + +
      +
      +
        + +
      • 来源
      • +
      • 类别
      • +
      • 贡献者
      • +
      • 引用数
      • +
      • 发布时间
      • +
      +
      + <%=render :partial => 'homework_repository', :locals => {:homeworks => @homeworks} %> +
      +
      +
      + <%=render :partial => 'homework_repository_detail', :locals => {:homework => nil} %> +
      +
      +
      +
        + <%= pagination_links_full @hw_pages, @hw_count, :per_page_links => false, :remote => @is_remote, :flag => true%> +
      +
      +
      + 发送至 +
      + +
      +
      +
      +
    \ No newline at end of file diff --git a/app/views/users/user_homeworks.js.erb b/app/views/users/user_homeworks.js.erb index cc1bc051a..d5be28186 100644 --- a/app/views/users/user_homeworks.js.erb +++ b/app/views/users/user_homeworks.js.erb @@ -1,2 +1,5 @@ -$("#user_show_more_homework").replaceWith("<%= escape_javascript( render :partial => 'users/user_homework_list',:locals => {:homework_commons => @homework_commons, :page => @page,:is_in_course => 0} )%>"); +$("#homework_repository").html('<%= escape_javascript(render :partial => 'users/homework_repository', :locals => {:homeworks => @homeworks})%>'); +$("#homework_pository_ref_pages").html('<%= pagination_links_full @hw_pages, @hw_count, :per_page_links => false, :remote => @is_remote, :flag => true %>'); +$("#homework_repository_detail").html("<%=escape_javascript(render :partial => 'users/homework_repository_detail', :locals => {:homework=>nil}) %>"); +/*$("#user_show_more_homework").replaceWith("<%#= escape_javascript( render :partial => 'users/user_homework_list',:locals => {:homework_commons => @homework_commons, :page => @page,:is_in_course => 0} )%>");*/ diff --git a/app/views/users/user_resource.html.erb b/app/views/users/user_resource.html.erb index 88e8e7140..dac0e365f 100644 --- a/app/views/users/user_resource.html.erb +++ b/app/views/users/user_resource.html.erb @@ -70,7 +70,7 @@ } -
    +
    • 公共资源 diff --git a/app/views/users/user_search_homeworks.js.erb b/app/views/users/user_search_homeworks.js.erb index c8e3aab3e..d5955c43b 100644 --- a/app/views/users/user_search_homeworks.js.erb +++ b/app/views/users/user_search_homeworks.js.erb @@ -1,3 +1,9 @@ +<% if @is_import.to_i == 1 %> $("#homework_list_form_show").html('<%= escape_javascript(render :partial => 'users/show_user_homework_form', :locals => {:homeworks => @homeworks})%>'); $("#homewrok_ref_pages").html('<%= pagination_links_full @hw_pages, @hw_count, :per_page_links => false, :remote => @is_remote, :flag => true %>'); -$("#homework_detail_information").html("<%=escape_javascript(render :partial => 'users/homework_detail_information', :locals => {:homework=>nil}) %>"); \ No newline at end of file +$("#homework_detail_information").html("<%=escape_javascript(render :partial => 'users/homework_detail_information', :locals => {:homework=>nil}) %>"); +<% else %> +$("#homework_repository").html('<%= escape_javascript(render :partial => 'users/homework_repository', :locals => {:homeworks => @homeworks})%>'); +$("#homework_pository_ref_pages").html('<%= pagination_links_full @hw_pages, @hw_count, :per_page_links => false, :remote => @is_remote, :flag => true %>'); +$("#homework_repository_detail").html("<%=escape_javascript(render :partial => 'users/homework_repository_detail', :locals => {:homework=>nil}) %>"); +<% end %> \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index 1cb6df18e..ef9011cdc 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -505,8 +505,10 @@ RedmineApp::Application.routes.draw do match 'user_feedback4show', :to => 'users#user_feedback4show', :via => :get match 'user_visitorlist', :to => 'users#user_visitorlist', :via => :get match 'user_homeworks', :to => 'users#user_homeworks', :via => :get + match 'student_homeworks', :to => 'users#student_homeworks', :via => :get get 'user_import_homeworks' get 'user_search_homeworks' + get 'choose_user_course' get 'user_import_resource' match 'watch_projects', :to => 'users#watch_projects', :via => :get # @@ -541,6 +543,7 @@ RedmineApp::Application.routes.draw do post "user_resource_create" post "user_resource_delete" get "search_user_course" + post "send_homework_to_course" post "add_exist_file_to_course" post "add_exist_file_to_project" post 'add_exist_file_to_org' diff --git a/public/javascripts/homework.js b/public/javascripts/homework.js index f652d0ce8..337c5a9a0 100644 --- a/public/javascripts/homework.js +++ b/public/javascripts/homework.js @@ -151,7 +151,7 @@ $(function(){ modal: true, autoOpen: false, dialogClass: 'BluePopupBox', - minWidth: 753 + minWidth: 771 }); $('#BluePopupBox').parent().resizable("disable"); $('#BluePopupBox').parent().removeClass("ui-state-disabled"); @@ -243,6 +243,10 @@ $(function(){ $(this).parent('.mt10').after(html); var inputs = document.getElementsByName("program[input][]"); var outputs = document.getElementsByName("program[output][]"); + var inputs_labels = document.getElementsByName("inputs_label"); + for(var j= 0; j