From ae218fa86caeeac6ca57cae314c5379dc25955eb Mon Sep 17 00:00:00 2001 From: cxt Date: Wed, 2 Dec 2015 11:14:46 +0800 Subject: [PATCH 01/17] =?UTF-8?q?=E5=8F=91=E5=B8=83=E4=BD=9C=E4=B8=9A?= =?UTF-8?q?=E6=97=B6=E6=B7=BB=E5=8A=A0=E5=88=86=E7=BB=84=E4=BD=9C=E4=B8=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/users/_user_group_attr.html.erb | 24 +++++++ .../users/_user_homework_attachment.html.erb | 10 +-- app/views/users/_user_homework_form.html.erb | 11 +++ public/images/course/hwork_icon.png | Bin 0 -> 4494 bytes public/javascripts/homework.js | 65 +++++++++++++++++- public/stylesheets/courses.css | 12 +++- public/stylesheets/new_user.css | 11 +++ 7 files changed, 126 insertions(+), 7 deletions(-) create mode 100644 app/views/users/_user_group_attr.html.erb create mode 100644 public/images/course/hwork_icon.png diff --git a/app/views/users/_user_group_attr.html.erb b/app/views/users/_user_group_attr.html.erb new file mode 100644 index 000000000..42d35c5d7 --- /dev/null +++ b/app/views/users/_user_group_attr.html.erb @@ -0,0 +1,24 @@ +分组设置 + +
+ 每组最小人数: + 人 +
+
+ 每组最大人数: + 人 +
+
+ +

提醒:勾选后各小组必须在Trustie平台创建项目,教师可随时观察平台对各小组最新进展的实时统计。

+
+
+ 确定 +
+
+ 取消 +
+
\ No newline at end of file diff --git a/app/views/users/_user_homework_attachment.html.erb b/app/views/users/_user_homework_attachment.html.erb index 24d37ae63..28dc35026 100644 --- a/app/views/users/_user_homework_attachment.html.erb +++ b/app/views/users/_user_homework_attachment.html.erb @@ -43,16 +43,18 @@ :lebel_file_uploding => l(:lebel_file_uploding), :delete_all_files => l(:text_are_you_sure_all) } %> +
- 上传附件 - <%= link_to "资源库",{:controller => 'users',:action=>'user_import_resource',:id=>User.current.id,:homework_id=>container.id},:class => "FilesBtn fl mt3 mr20",:remote => true%> + 上传附件 + <%= link_to "资源库",{:controller => 'users',:action=>'user_import_resource',:id=>User.current.id,:homework_id=>container.id},:class => "FilesBtn fl mt3 mr15",:title=>"请从资源库中选择文件作为作品的附件",:remote => true%> <% if defined?(has_program) && has_program %> - 编程 - + 编程 + + 分组 <% end %>
diff --git a/app/views/users/_user_homework_form.html.erb b/app/views/users/_user_homework_form.html.erb index efaed2d9d..5c4cd1734 100644 --- a/app/views/users/_user_homework_form.html.erb +++ b/app/views/users/_user_homework_form.html.erb @@ -97,7 +97,18 @@ + + + \ No newline at end of file diff --git a/public/images/course/hwork_icon.png b/public/images/course/hwork_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..82c78ac60defdaafaf7e2e8c55530e6939b5b86f GIT binary patch literal 4494 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 literal 0 HcmV?d00001 diff --git a/public/javascripts/homework.js b/public/javascripts/homework.js index f1b6e1814..39351cc6b 100644 --- a/public/javascripts/homework.js +++ b/public/javascripts/homework.js @@ -124,7 +124,6 @@ $(function(){ $('#textarea_input_test').focus(); }); - var saveProgramAnswers = function() { var test_numbers = 0; var valid = true; @@ -171,7 +170,7 @@ $(function(){ $("input[name=homework_type]").after(html); } return valid; - } + }; $("#BluePopupBox a.BlueCirBtn").live('click', function(){ if(saveProgramAnswers()){ @@ -198,6 +197,68 @@ $(function(){ $(this).parent('.mt10').remove(); }); + //分组作业 + $("#GroupPopupBox").dialog({ + modal: true, + autoOpen: false, + dialogClass: 'BluePopupBox', + minWidth: 290 + }); + + $('a.groupBtn').live('click', function(){ + $("#GroupPopupBox").dialog("open"); + $(".ui-dialog-titlebar").hide(); + $("a.popClose").on('click', function(){ + $("#GroupPopupBox" ).dialog("close"); + }); + $("#cancel_group").on('click', function(){ + $("#GroupPopupBox" ).dialog("close"); + }); + $('#min_num').focus(); + }); + + var saveGroupAttr = function() { + var valid = true; + var base_on_project = 0; + var min = $.trim($("#min_num").val()); + var max = $.trim($("#max_num").val()); + if(min.length <= 0) { + $("#min_num").focus(); + valid = false; + return false; + } + if(max.length <= 0) { + $("#max_num").focus(); + valid = false; + return false; + } + if ($("#base_on_project").is(":checked")) { + base_on_project = 1; + } + if (valid) { + $("input[name=homework_type]").val(3); + $('span.group_detail_info').text('分组人数:'+min+'-'+max+' 人'); + //保存js值 + var data = { + base_on_project: base_on_project, + min_num: min, + max_num: max + }; + //构建到form中 + $('.group-input').remove(); + var html=bt('t:group-input-list',data); + $("input[name=homework_type]").after(html); + } + return valid; + }; + + $("#GroupPopupBox a.group_btn").live('click', function(){ + if(saveGroupAttr()){ + if($( "#GroupPopupBox" ).dialog( "isOpen" )){ + $("#GroupPopupBox").dialog( "close" ); + } + } + }); //代码编辑器 if (typeof CodeMirror != "undefined") { diff --git a/public/stylesheets/courses.css b/public/stylesheets/courses.css index 2fb32e2d0..93594794e 100644 --- a/public/stylesheets/courses.css +++ b/public/stylesheets/courses.css @@ -1175,4 +1175,14 @@ a:hover.testEdit{ background:url(images/icons.png) -21px -272px no-repeat;} .rankList li p {width:100%; overflow:hidden; white-space:normal; text-overflow:ellipsis; color:#585858;word-wrap: normal; word-break: normal;} .rankPortrait {border-radius:50%; width:35px; height:35px;} .numIntro {position:absolute; text-align:left; z-index:999; box-shadow:0px 2px 8px rgba(146, 153, 169, 0.5); border:1px solid #eaeaea; background-color:#ffffff; padding:3px 5px; left:15px; color:#585858; white-space: nowrap;} -.font_cus {font-family: "微软雅黑","宋体"; font-size: 12px; line-height: 1.5;} +.font_cus {font-family: "微软雅黑","宋体"; font-size: 12px; line-height: 1.5;} +/*20151130课程项目集成Tim*/ +a.testBtn{background: url(/images/course/hwork_icon.png) -2px -5px no-repeat !important; height:20px; display:block; padding-left:20px; color:#888888; -moz-transition :all 0s linear 0s; -webkit-transition :all 0s linear 0s; -o-transition:all 0s linear 0s; transition:all 0s linear 0s;} +a:hover.testBtn{background: url(/images/course/hwork_icon.png) -81px -5px no-repeat !important; color:#3598db; -moz-transition :all 0s linear 0s; -webkit-transition :all 0s linear 0s; -o-transition:all 0s linear 0s; transition:all 0s linear 0s;} +a.groupBtn{ background: url(/images/course/hwork_icon.png) -2px -61px no-repeat !important; height:20px; display:block; padding-left:20px; color:#888888; -moz-transition :all 0s linear 0s; -webkit-transition :all 0s linear 0s; -o-transition:all 0s linear 0s; transition:all 0s linear 0s;} +a:hover.groupBtn{background: url(/images/course/hwork_icon.png) -80px -61px no-repeat !important; color:#3598db; -moz-transition :all 0s linear 0s; -webkit-transition :all 0s linear 0s; -o-transition:all 0s linear 0s; transition:all 0s linear 0s;} +.markInput { outline:none; border:1px solid #e6e6e6; height:30px; width:50px; color:#3d3c3c; margin-right:5px; text-align:center; padding-left:0px;} +.groupPopUp {width:290px; height:auto; padding:15px; background-color:#ffffff; z-index:1000; position:relative;} +.popClose {background:url(/images/resource_icon_list.png) 0px -40px no-repeat; width:20px; height:20px; display:inline-block; position: absolute; z-index: 1000; right:2px; top:3px;} +a.memberBtn{ background: url(/images/course/hwork_icon.png) -7px -90px no-repeat !important; height:20px; display:block; padding-left:20px; color:#888888; -moz-transition :all 0s linear 0s; -webkit-transition :all 0s linear 0s; -o-transition:all 0s linear 0s; transition:all 0s linear 0s;} +a:hover.memberBtn{background: url(/images/course/hwork_icon.png) -80px -90px no-repeat !important; color:#3598db; -moz-transition :all 0s linear 0s; -webkit-transition :all 0s linear 0s; -o-transition:all 0s linear 0s; transition:all 0s linear 0s;} diff --git a/public/stylesheets/new_user.css b/public/stylesheets/new_user.css index a08fd6f33..90ac82f2b 100644 --- a/public/stylesheets/new_user.css +++ b/public/stylesheets/new_user.css @@ -1349,3 +1349,14 @@ span.author { font-size: 0.9em; color: #888; } .pageCell:hover {border:1px solid #3498db; z-index:10;} .pageCellActive {background-color:#3498db; border:1px solid #3498db !important; position:relative; color:#ffffff;} +/*20151130课程项目集成Tim*/ +a.testBtn{background: url(/images/course/hwork_icon.png) -2px -5px no-repeat !important; height:20px; display:block; padding-left:20px; color:#888888; -moz-transition :all 0s linear 0s; -webkit-transition :all 0s linear 0s; -o-transition:all 0s linear 0s; transition:all 0s linear 0s;} +a:hover.testBtn{background: url(/images/course/hwork_icon.png) -81px -5px no-repeat !important; color:#3598db; -moz-transition :all 0s linear 0s; -webkit-transition :all 0s linear 0s; -o-transition:all 0s linear 0s; transition:all 0s linear 0s;} +a.groupBtn{ background: url(/images/course/hwork_icon.png) -2px -61px no-repeat !important; height:20px; display:block; padding-left:20px; color:#888888; -moz-transition :all 0s linear 0s; -webkit-transition :all 0s linear 0s; -o-transition:all 0s linear 0s; transition:all 0s linear 0s;} +a:hover.groupBtn{background: url(/images/course/hwork_icon.png) -80px -61px no-repeat !important; color:#3598db; -moz-transition :all 0s linear 0s; -webkit-transition :all 0s linear 0s; -o-transition:all 0s linear 0s; transition:all 0s linear 0s;} +.markInput { outline:none; border:1px solid #e6e6e6; height:30px; width:50px; color:#3d3c3c; margin-right:5px; text-align:center; padding-left:0px;} +.groupPopUp {width:290px; height:auto; padding:15px; background-color:#ffffff; z-index:1000; position:relative;} +.popClose {background:url(/images/resource_icon_list.png) 0px -40px no-repeat; width:20px; height:20px; display:inline-block; position: absolute; z-index: 1000; right:2px; top:3px;} +a.memberBtn{ background: url(/images/course/hwork_icon.png) -7px -90px no-repeat !important; height:20px; display:block; padding-left:20px; color:#888888; -moz-transition :all 0s linear 0s; -webkit-transition :all 0s linear 0s; -o-transition:all 0s linear 0s; transition:all 0s linear 0s;} +a:hover.memberBtn{background: url(/images/course/hwork_icon.png) -80px -90px no-repeat !important; color:#3598db; -moz-transition :all 0s linear 0s; -webkit-transition :all 0s linear 0s; -o-transition:all 0s linear 0s; transition:all 0s linear 0s;} + From f90ff781ab405ab473eb13ae2da2b715b347c816 Mon Sep 17 00:00:00 2001 From: cxt Date: Thu, 3 Dec 2015 09:17:36 +0800 Subject: [PATCH 02/17] =?UTF-8?q?=E5=AD=A6=E7=94=9F=E6=8F=90=E4=BA=A4?= =?UTF-8?q?=E4=BD=9C=E5=93=81=E9=A1=B5=E9=9D=A2=E7=9A=84=E5=90=88=E4=BD=9C?= =?UTF-8?q?=E6=88=90=E5=91=98=E5=BC=B9=E7=AA=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/users_controller.rb | 9 +++ app/models/homework_common.rb | 5 ++ app/models/homework_detail_group.rb | 4 ++ app/views/homework_common/index.html.erb | 2 +- .../_choose_group_member.html.erb | 41 +++++++++++++ .../student_work/_relate_project.html.erb | 30 ++++++++++ app/views/student_work/edit.html.erb | 2 +- app/views/student_work/new.html.erb | 30 ++++++++-- app/views/student_work/retry_work.js.erb | 2 +- app/views/users/_user_group_attr.html.erb | 15 +++-- .../users/_user_homework_attachment.html.erb | 8 ++- app/views/users/_user_homework_form.html.erb | 5 +- app/views/users/user_homeworks.html.erb | 2 +- app/views/users/user_select_homework.js.erb | 2 +- ...202064455_create_homework_detail_groups.rb | 14 +++++ db/schema.rb | 56 ++++++++++-------- public/images/course/right-arrow.png | Bin 0 -> 1325 bytes public/javascripts/homework.js | 2 +- public/javascripts/new_user.js | 13 ++++ public/stylesheets/courses.css | 6 ++ public/stylesheets/new_user.css | 7 ++- spec/factories/homework_detail_groups.rb | 11 ++++ spec/models/homework_detail_group_spec.rb | 5 ++ 23 files changed, 225 insertions(+), 46 deletions(-) create mode 100644 app/models/homework_detail_group.rb create mode 100644 app/views/student_work/_choose_group_member.html.erb create mode 100644 app/views/student_work/_relate_project.html.erb create mode 100644 db/migrate/20151202064455_create_homework_detail_groups.rb create mode 100644 public/images/course/right-arrow.png create mode 100644 spec/factories/homework_detail_groups.rb create mode 100644 spec/models/homework_detail_group_spec.rb diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 9ff833f48..9090a814c 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -551,12 +551,21 @@ class UsersController < ApplicationController ) end end + end + #分组作业 + if homework.homework_type == 3 + homework_detail_group = HomeworkDetailGroup.new + homework.homework_detail_group = homework_detail_group + homework_detail_group.min_num = params[:min_num].to_i + homework_detail_group.max_num = params[:max_num].to_i + homework_detail_group.base_on_project = params[:base_on_project].to_i end if homework.save homework_detail_manual.save if homework_detail_manual homework_detail_programing.save if homework_detail_programing + homework_detail_group.save if homework_detail_group if params[:is_in_course] == "1" redirect_to homework_common_index_path(:course => homework.course_id) diff --git a/app/models/homework_common.rb b/app/models/homework_common.rb index 8d421a98f..461c7d35b 100644 --- a/app/models/homework_common.rb +++ b/app/models/homework_common.rb @@ -9,6 +9,7 @@ class HomeworkCommon < ActiveRecord::Base belongs_to :user has_one :homework_detail_manual, :dependent => :destroy has_one :homework_detail_programing, :dependent => :destroy + has_one :homework_detail_group, :dependent => :destroy has_many :homework_tests, :dependent => :destroy has_many :student_works, :dependent => :destroy, :conditions => "is_test=0" has_many :student_works_evaluation_distributions, :through => :student_works #一个作业的分配的匿评列表 @@ -74,6 +75,10 @@ class HomeworkCommon < ActiveRecord::Base self.homework_type == 2 && self.homework_detail_programing end + def is_group_homework? + self.homework_type == 3 && self.homework_detail_group + end + ###添加回复 def self.add_homework_jour(user, notes, id , options = {}) homework = HomeworkCommon.find(id) diff --git a/app/models/homework_detail_group.rb b/app/models/homework_detail_group.rb new file mode 100644 index 000000000..0a9cb5fe2 --- /dev/null +++ b/app/models/homework_detail_group.rb @@ -0,0 +1,4 @@ +class HomeworkDetailGroup < ActiveRecord::Base + belongs_to :homework_common + attr_accessible :base_on_project, :homework_common_id, :max_num, :min_num +end diff --git a/app/views/homework_common/index.html.erb b/app/views/homework_common/index.html.erb index 3b3877228..010bc8ec9 100644 --- a/app/views/homework_common/index.html.erb +++ b/app/views/homework_common/index.html.erb @@ -4,7 +4,7 @@ $("#homework_publish_time").val(""); $("#homework_end_time").val(""); $("#course_id").val($("#option_select").val()); - $("#homework_attachments").html("<%= escape_javascript(render :partial => 'users/user_homework_attachment', :locals => { :container => HomeworkCommon.new,:has_program => true })%>"); + $("#homework_attachments").html("<%= escape_javascript(render :partial => 'users/user_homework_attachment', :locals => { :container => HomeworkCommon.new,:has_program => true,:has_group => true})%>"); homework_description_editor.html(""); $("#homework_editor").toggle(); } diff --git a/app/views/student_work/_choose_group_member.html.erb b/app/views/student_work/_choose_group_member.html.erb new file mode 100644 index 000000000..c14e8a06e --- /dev/null +++ b/app/views/student_work/_choose_group_member.html.erb @@ -0,0 +1,41 @@ +
请添加小组成员
+ +
+
+
+ +
+
+
+
    +
  • + 同学一(061530301) +
  • +
  • + 同学二同学二(061530302) +
  • +
  • + 同学三(061530303) +
  • +
  • + 同学四同学四(061530304) +
  • +
  • + 同学五同学五(061530305) +
  • +
  • + 同学六同学六(061530306) +
  • +
  • + 同学七同学七(061530307) +
  • +
+
+
    +
  • TimTang(040930319)×
  • +
  • suntao(060930106)×
  • +
+
+ + +
\ No newline at end of file diff --git a/app/views/student_work/_relate_project.html.erb b/app/views/student_work/_relate_project.html.erb new file mode 100644 index 000000000..06649baba --- /dev/null +++ b/app/views/student_work/_relate_project.html.erb @@ -0,0 +1,30 @@ +
关联项目 +
+ +
+
    +
  • + +
  • +
  • + +
  • +
  • + +
  • +
  • + +
  • +
+ + +
+
\ No newline at end of file diff --git a/app/views/student_work/edit.html.erb b/app/views/student_work/edit.html.erb index d506b5542..bfdf8c316 100644 --- a/app/views/student_work/edit.html.erb +++ b/app/views/student_work/edit.html.erb @@ -48,7 +48,7 @@
- <%= render :partial => 'users/user_homework_attachment', :locals => {:container => @work, :has_program=>false} %> + <%= render :partial => 'users/user_homework_attachment', :locals => {:container => @work, :has_program=>false,:has_group=>false} %>
diff --git a/app/views/student_work/new.html.erb b/app/views/student_work/new.html.erb index 45c26654e..995126cb5 100644 --- a/app/views/student_work/new.html.erb +++ b/app/views/student_work/new.html.erb @@ -95,20 +95,32 @@
- <%= render :partial => 'users/user_homework_attachment', :locals => {:container => @student_work, :has_program=>false} %> + <%= render :partial => 'users/user_homework_attachment', :locals => {:container => @student_work, :has_program=>false,:has_group=>false} %>
+ <% if @homework.homework_type == 3 %> + + + <% end %> + +
-
- <%= select_tag :project_id, options_for_select(user_projects_option, @student_work.project_id), {:class => "InputBox W680 fl"} %> +
提交 @@ -120,6 +132,14 @@
\ No newline at end of file diff --git a/app/views/users/_user_homework_attachment.html.erb b/app/views/users/_user_homework_attachment.html.erb index 28dc35026..f1c0ae97e 100644 --- a/app/views/users/_user_homework_attachment.html.erb +++ b/app/views/users/_user_homework_attachment.html.erb @@ -52,9 +52,11 @@ 上传附件 <%= link_to "资源库",{:controller => 'users',:action=>'user_import_resource',:id=>User.current.id,:homework_id=>container.id},:class => "FilesBtn fl mt3 mr15",:title=>"请从资源库中选择文件作为作品的附件",:remote => true%> <% if defined?(has_program) && has_program %> - 编程 - - 分组 + 编程 + + <% end %> + <% if defined?(has_group) && has_group %> + 分组 <% end %> diff --git a/app/views/users/_user_homework_form.html.erb b/app/views/users/_user_homework_form.html.erb index 5c4cd1734..40c8ac5bd 100644 --- a/app/views/users/_user_homework_form.html.erb +++ b/app/views/users/_user_homework_form.html.erb @@ -4,6 +4,9 @@ <% end %> @@ -54,7 +57,7 @@
- <%= render :partial => 'users/user_homework_attachment', :locals => {:container => homework, :has_program=>!(edit_mode && homework.homework_type == 1)} %> + <%= render :partial => 'users/user_homework_attachment', :locals => {:container => homework, :has_program=>!(edit_mode && homework.homework_type != 2), :has_group=>!(edit_mode && homework.homework_type != 3)} %>
diff --git a/app/views/users/user_homeworks.html.erb b/app/views/users/user_homeworks.html.erb index 121450d4d..7be803720 100644 --- a/app/views/users/user_homeworks.html.erb +++ b/app/views/users/user_homeworks.html.erb @@ -4,7 +4,7 @@ $("#homework_publish_time").val(""); $("#homework_end_time").val(""); $("#course_id").val($("#option_select").val()); - $("#homework_attachments").html("<%= escape_javascript(render :partial => 'users/user_homework_attachment', :locals => { :container => HomeworkCommon.new,:has_program => true })%>"); + $("#homework_attachments").html("<%= escape_javascript(render :partial => 'users/user_homework_attachment', :locals => { :container => HomeworkCommon.new,:has_program => true,:has_group => true })%>"); homework_description_editor.html(""); $("#homework_editor").toggle(); } diff --git a/app/views/users/user_select_homework.js.erb b/app/views/users/user_select_homework.js.erb index 1d9cc8d70..cd94a6816 100644 --- a/app/views/users/user_select_homework.js.erb +++ b/app/views/users/user_select_homework.js.erb @@ -5,7 +5,7 @@ $("#homework_end_time").val("<%= @homework.end_time%>"); <% if @select_course == "0"%> $("#course_id").val("<%= @homework.course_id%>"); <% end%> -$("#homework_attachments").html("<%= escape_javascript(render :partial => 'users/user_homework_attachment', :locals => { :container => @homework,:has_program => true })%>"); +$("#homework_attachments").html("<%= escape_javascript(render :partial => 'users/user_homework_attachment', :locals => { :container => @homework,:has_program => true,:has_group => true })%>"); homework_description_editor.html("<%= escape_javascript(@homework.description.html_safe)%>"); $("#BluePopupBox").html("<%=escape_javascript( render :partial => 'users/user_programing_attr', :locals => {:edit_mode => true, :homework => @homework})%>"); //$("input[name='homework_type']").val("<%#= @homework.homework_type%>"); diff --git a/db/migrate/20151202064455_create_homework_detail_groups.rb b/db/migrate/20151202064455_create_homework_detail_groups.rb new file mode 100644 index 000000000..a77e50f01 --- /dev/null +++ b/db/migrate/20151202064455_create_homework_detail_groups.rb @@ -0,0 +1,14 @@ +class CreateHomeworkDetailGroups < ActiveRecord::Migration + def change + create_table :homework_detail_groups do |t| + t.integer :homework_common_id + t.integer :min_num + t.integer :max_num + t.integer :base_on_project + t.references :homework_common + + t.timestamps + end + add_index :homework_detail_groups, :homework_common_id + end +end diff --git a/db/schema.rb b/db/schema.rb index c6ca6a0ce..442ceaab9 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20151130033906) do +ActiveRecord::Schema.define(:version => 20151202064455) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false @@ -543,23 +543,26 @@ ActiveRecord::Schema.define(:version => 20151130033906) do add_index "documents", ["created_on"], :name => "index_documents_on_created_on" add_index "documents", ["project_id"], :name => "documents_project_id" - create_table "dts", :force => true do |t| - t.string "IPLineCode" - t.string "Description" - t.string "Num" - t.string "Variable" - t.string "TraceInfo" - t.string "Method" + create_table "dts", :primary_key => "Num", :force => true do |t| + t.string "Defect", :limit => 50 + t.string "Category", :limit => 50 t.string "File" - t.string "IPLine" - t.string "Review" - t.string "Category" - t.string "Defect" - t.string "PreConditions" - t.string "StartLine" + t.string "Method" + t.string "Module", :limit => 20 + t.string "Variable", :limit => 50 + t.integer "StartLine" + t.integer "IPLine" + t.string "IPLineCode", :limit => 200 + t.string "Judge", :limit => 15 + t.integer "Review", :limit => 1 + t.string "Description" + t.text "PreConditions", :limit => 2147483647 + t.text "TraceInfo", :limit => 2147483647 + t.text "Code", :limit => 2147483647 t.integer "project_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.datetime "created_at" + t.datetime "updated_at" + t.integer "id", :null => false end create_table "enabled_modules", :force => true do |t| @@ -735,6 +738,17 @@ ActiveRecord::Schema.define(:version => 20151130033906) do add_index "homework_commons", ["course_id", "id"], :name => "index_homework_commons_on_course_id_and_id" + create_table "homework_detail_groups", :force => true do |t| + t.integer "homework_common_id" + t.integer "min_num" + t.integer "max_num" + t.integer "base_on_project" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + add_index "homework_detail_groups", ["homework_common_id"], :name => "index_homework_detail_groups_on_homework_common_id" + create_table "homework_detail_manuals", :force => true do |t| t.float "ta_proportion" t.integer "comment_status" @@ -891,16 +905,6 @@ ActiveRecord::Schema.define(:version => 20151130033906) do add_index "journal_details", ["journal_id"], :name => "journal_details_journal_id" - create_table "journal_details_copy", :force => true do |t| - t.integer "journal_id", :default => 0, :null => false - t.string "property", :limit => 30, :default => "", :null => false - t.string "prop_key", :limit => 30, :default => "", :null => false - t.text "old_value" - t.text "value" - end - - add_index "journal_details_copy", ["journal_id"], :name => "journal_details_journal_id" - create_table "journal_replies", :id => false, :force => true do |t| t.integer "journal_id" t.integer "user_id" diff --git a/public/images/course/right-arrow.png b/public/images/course/right-arrow.png new file mode 100644 index 0000000000000000000000000000000000000000..b152e9ce9f65165d57377cb50087c2a5ede4f311 GIT binary patch literal 1325 zcmeAS@N?(olHy`uVBq!ia0vp^0zfRs!3HE%f6fyGQj#UE5hcO-X(i=}MX3yqDfvmM z3ZA)%>8U}fi7AzZCsS=07?=ezLn2Bde0{8v^Kf6`()~Xj@TAnpKdC8`Lf!&sHg;q@=(~U%$M( zT(8_%FTW^V-_X+15@d#vkuFe$ZgFK^Nn(X=Ua>OF1ees}t-3#_`hBq$Z(46Le)Ln;eW^@CE2 z^Gl18f$@>14ATq@JNy=b6armi<&vLVnwy$e;^|_m1QgLr$xN{_cXl-~GjTJuw6HWb zG;}q!Ff(&@c6KqcGGjMjE=kNwPKD{sMCdiatJli8C^fMpzbGU>KL-|j z0U7xv`NbLe1q#l=W(wh%c`5nj#h`$Nx-+#Xvn(~mttdZN0UR<`nMk&~S{j>}nz*=` z7`Pc5I~h1TyBfQhIGI?w8oC&onV7gKLG`2{`Iev_eW2y~plC#jR+tblt$>*DL<;1< zlX+?$Fl`qB6Y-fD5;+VEjGH}O978H@EtzWT&Fm=9_T7n#Q-hJUHR4#kg4v>04y79^ zT}g{rnmZB_pP%0#?DB~HQM$0SD@$NN&Xr3>Ym*kX%+U~YstJ3iBDcMGr^SbqzLfjr z<>}wmrsdxD_gd*aqxpN*)>S1D)0V#K?Pd)LL6QkIJ;0Vw8o9DLV^Ga-RJyqPAdvMA0kd`GcmEIn<>CbQS?3X*9 zJpHA}mXka?b*?OlzAqd$dyCf8uFL?wu!ScpS|*-wp2Gih-=TR+SN)H98W=GxE&XTt zk}3C1<(j`Xn17Pnv}V&2Q;FxNogDmkq<+)c`Q+{)lSjUuJs;X;EsZT)>&UlpU4@T8 z{A9HU7o(3vMoc_%L^Ng3Bl+ZAMKfq ew!is*#1a_(E}x^jPDLDCf_b|7xvX :model do + pending "add some examples to (or delete) #{__FILE__}" +end From ef2ef7111c9a2f2d0bf64a97efb273a7fe2a63c0 Mon Sep 17 00:00:00 2001 From: lizanle <491823689@qq.com> Date: Mon, 7 Dec 2015 14:31:05 +0800 Subject: [PATCH 03/17] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=AF=B9=E5=B8=96?= =?UTF-8?q?=E5=AD=90=E7=9A=84=E5=85=A8=E6=96=87=E6=90=9C=E7=B4=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/welcome_controller.rb | 27 +++++--- app/models/memo.rb | 68 +++++++++++++++++-- .../welcome/_search_all_results.html.erb | 16 +++++ .../welcome/_search_memo_results.html.erb | 24 +++++++ app/views/welcome/search.html.erb | 12 +++- app/views/welcome/search.js.erb | 2 + lib/tasks/elasticsearch_batch_op.rake | 7 ++ 7 files changed, 142 insertions(+), 14 deletions(-) create mode 100644 app/views/welcome/_search_memo_results.html.erb diff --git a/app/controllers/welcome_controller.rb b/app/controllers/welcome_controller.rb index 815a44839..1508fc871 100644 --- a/app/controllers/welcome_controller.rb +++ b/app/controllers/welcome_controller.rb @@ -161,7 +161,7 @@ class WelcomeController < ApplicationController query: @name, type:"most_fields", operator: "or", - fields: ['login', 'firstname','lastname','name','description^0.5','filename'] + fields: ['login', 'firstname','lastname','name','description^0.5','filename','subject','content^0.5'] } }, highlight: { @@ -173,10 +173,12 @@ class WelcomeController < ApplicationController lastname: {}, name:{}, description:{}, - filename:{} + filename:{}, + subject:{}, + content:{} } } - },[User,Course,Attachment,Project] ).page(params[:page] || 1).per(20).results + },[User,Course,Attachment,Project,Memo] ).page(params[:page] || 1).per(20).results when 'user' @users = User.search(@name).page(params[:page] || 1).per(20) when 'project' @@ -185,6 +187,8 @@ class WelcomeController < ApplicationController @courses = Course.search(@name).page(params[:page] || 1).per(20).results when 'attachment' @attachments = Attachment.search(@name).page(params[:page] || 1).per(20).results + when 'memo' + @memos = Memo.search(@name).page(params[:page] || 1).per(20).results else @alls = Elasticsearch::Model.search({ query: { @@ -192,7 +196,7 @@ class WelcomeController < ApplicationController query: @name, type:"most_fields", operator: "or", - fields: ['login', 'firstname','lastname','name','description^0.5','filename'] + fields: ['login', 'firstname','lastname','name','description^0.5','filename','subject','content^0.5'] } }, highlight: { @@ -204,10 +208,12 @@ class WelcomeController < ApplicationController lastname: {}, name:{}, description:{}, - filename:{} + filename:{}, + subject:{}, + content:{} } } - },[User,Course,Attachment,Project] ).page(params[:page] || 1).per(20).results + },[User,Course,Attachment,Project,Memo] ).page(params[:page] || 1).per(20).results end @@ -216,13 +222,14 @@ class WelcomeController < ApplicationController @course_count = Course.search(@name).results.total @attach_count = Attachment.search(@name).results.total @project_count = Project.search(@name).results.total + @memo_count = Memo.search(@name).results.total @total_count = Elasticsearch::Model.search({ query: { multi_match: { query: @name, type:"most_fields", operator: "or", - fields: ['login', 'firstname','lastname','name','description^0.5','filename'] + fields: ['login', 'firstname','lastname','name','description^0.5','filename','subject','content^0.5'] } }, highlight: { @@ -234,10 +241,12 @@ class WelcomeController < ApplicationController lastname: {}, name:{}, description:{}, - filename:{} + filename:{}, + subject:{}, + content:{} } } - },[User,Course,Attachment,Project] ).results.total + },[User,Course,Attachment,Project,Memo] ).results.total # search_type = params[:search_type].to_sym unless search_condition.blank? # search_by = params[:search_by] # diff --git a/app/models/memo.rb b/app/models/memo.rb index 7c4fbdcf1..5d590e228 100644 --- a/app/models/memo.rb +++ b/app/models/memo.rb @@ -1,7 +1,9 @@ +require 'elasticsearch/model' class Memo < ActiveRecord::Base include Redmine::SafeAttributes include UserScoreHelper include ApplicationHelper + include Elasticsearch::Model belongs_to :forum has_many_kindeditor_assets :assets, :dependent => :destroy belongs_to :author, :class_name => "User", :foreign_key => 'author_id' @@ -12,6 +14,18 @@ class Memo < ActiveRecord::Base validates_length_of :content, maximum: 30000 validate :cannot_reply_to_locked_topic, :on => :create + + #elasticsearch kaminari init + Kaminari::Hooks.init + Elasticsearch::Model::Response::Response.__send__ :include, Elasticsearch::Model::Response::Pagination::Kaminari + settings index: { number_of_shards: 5 } do + mappings dynamic: 'false' do + indexes :subject, analyzer: 'smartcn',index_options: 'offsets' + indexes :content, analyzer: 'smartcn',index_options: 'offsets' + indexes :updated_at, type:'date' + end + end + acts_as_tree :counter_cache => :replies_count, :order => "#{Memo.table_name}.created_at ASC" acts_as_attachable has_many :user_score_details, :class_name => 'UserScoreDetails',:as => :score_changeable_obj @@ -47,9 +61,9 @@ class Memo < ActiveRecord::Base "parent_id", "replies_count" - after_create :add_author_as_watcher, :reset_counters!, :send_mail, :send_message - # after_update :update_memos_forum - after_destroy :reset_counters!,:delete_kindeditor_assets#,:down_user_score -- 公共区发帖暂不计入得分 + after_create :add_author_as_watcher, :reset_counters!, :send_mail, :send_message,:create_memo_ealasticsearch_index + after_update :update_memo_ealasticsearch_index + after_destroy :reset_counters!,:delete_kindeditor_assets,:delete_memo_ealasticsearch_index#,:down_user_score -- 公共区发帖暂不计入得分, # after_create :send_notification # after_save :plusParentAndForum # after_destroy :minusParentAndForum @@ -57,6 +71,36 @@ class Memo < ActiveRecord::Base # scope :visible, lambda { |*args| # includes(:forum => ).where() # } + scope :indexable,lambda { + where('parent_id is null') + } + + def self.search(query) + __elasticsearch__.search( + { + query: { + multi_match: { + query: query, + type:"most_fields", + operator: "or", + fields: ['subject','content^0.5'] + } + }, + sort: { + _score:{order: "desc" }, + updated_at:{order: "desc" } + }, + highlight: { + pre_tags: [''], + post_tags: [''], + fields: { + subject: {}, + content: {} + } + } + } + ) + end def send_mail Mailer.run.forum_message_added(self) if Setting.notified_events.include?('forum_message_added') @@ -203,6 +247,22 @@ class Memo < ActiveRecord::Base # Author lizanle # Description 从硬盘上删除资源 def delete_kindeditor_assets - delete_kindeditor_assets_from_disk self.id,OwnerTypeHelper::MEMO + delete_kindeditor_assets_from_disk self.id,OwnerTypeHelper::MEMO + end + + def create_memo_ealasticsearch_index + if self.parent_id.nil? + self.__elasticsearch__.index_document + end + end + def update_memo_ealasticsearch_index + if self.parent_id.nil? + self.__elasticsearch__.update_document + end + end + def delete_memo_ealasticsearch_index + if self.parent_id.nil? + self.__elasticsearch__.delete_document + end end end diff --git a/app/views/welcome/_search_all_results.html.erb b/app/views/welcome/_search_all_results.html.erb index 014c6b487..34ef9a8eb 100644 --- a/app/views/welcome/_search_all_results.html.erb +++ b/app/views/welcome/_search_all_results.html.erb @@ -72,6 +72,22 @@
+ <% when 'memo'%> + <%end %> <% end %>
diff --git a/app/views/welcome/_search_memo_results.html.erb b/app/views/welcome/_search_memo_results.html.erb new file mode 100644 index 000000000..c5fe9cc72 --- /dev/null +++ b/app/views/welcome/_search_memo_results.html.erb @@ -0,0 +1,24 @@ +<% unless memos.nil? || memos.empty?%> + <% memos.each do |memo|%> +
    +
  • + + <%= link_to image_tag(url_to_avatar(User.find(memo.author_id)), :width => "75", :height => "75",:class=>'searchCourseImage'), forum_memo_path(:forum_id=>memo.forum_id,:id=>memo.id), :alt => "贴吧图片" %> +
  • +
  • + +
  • +
    +
+ <% end %> +
+ <%= paginate memos,:params => {:controller => 'welcome', :action => 'search',:search_type=>'memo'}%> +
+<% end %> \ No newline at end of file diff --git a/app/views/welcome/search.html.erb b/app/views/welcome/search.html.erb index c25d7bfb1..ca26ba8c3 100644 --- a/app/views/welcome/search.html.erb +++ b/app/views/welcome/search.html.erb @@ -3,7 +3,7 @@ function g(o){return document.getElementById(o);} function HoverLi(n){ //如果有N个标签,就将i<=N; - for(var i=1;i<=5;i++){ + for(var i=1;i<=6;i++){ g('searchBaner_'+i).className='searchBannerNormal'; g('searchContent_'+i).className='undis';g('searchNum_'+i).className="numRed"; g('searchType_'+i).className="fontGrey2 f14"; @@ -28,6 +28,8 @@ search('attachment') }else if(n == 5){ search('project') + }else if(n == 6){ + search('memo') } } @@ -56,6 +58,10 @@ }else if('<%= @search_type%>' == 'project'){ HoverLi(5) $("#searchContent_5").html('<%= escape_javascript(render :partial => 'search_project_results',:locals => {:projects=>@projects})%>'); + }else if('<%= @search_type%>' == 'memo') + { + HoverLi(6) + $("#searchContent_6").html('<%= escape_javascript(render :partial => 'search_memo_results',:locals => {:memos=>@memos})%>'); } }) //如果要做成点击后再转到请将
  • 中的onmouseover 改成 onclick; @@ -76,6 +82,7 @@
  • 课程(<%=@course_count%>)
  • 资源(<%= @attach_count%>)
  • 项目(<%= @project_count%>)
  • +
  • 帖子(<%= @memo_count%>)
  • +
    +
    +
    diff --git a/app/views/welcome/search.js.erb b/app/views/welcome/search.js.erb index c53c5d219..5cb446896 100644 --- a/app/views/welcome/search.js.erb +++ b/app/views/welcome/search.js.erb @@ -9,5 +9,7 @@ $("#searchContent_3").html('<%= escape_javascript(render :partial => 'search_cou $("#searchContent_5").html('<%= escape_javascript(render :partial => 'search_project_results',:locals => {:projects=>@projects})%>'); <% when 'attachment'%> $("#searchContent_4").html('<%= escape_javascript(render :partial => 'search_attachment_results',:locals => {:attachments=>@attachments})%>'); +<% when 'memo'%> +$("#searchContent_6").html('<%= escape_javascript(render :partial => 'search_memo_results',:locals => {:memos=>@memos})%>'); <%else%> <%end %> \ No newline at end of file diff --git a/lib/tasks/elasticsearch_batch_op.rake b/lib/tasks/elasticsearch_batch_op.rake index fb2c638bc..91c2ddff9 100644 --- a/lib/tasks/elasticsearch_batch_op.rake +++ b/lib/tasks/elasticsearch_batch_op.rake @@ -28,4 +28,11 @@ namespace :importer do ENV['BATCH']='1000' Rake::Task["elasticsearch:import:model"].invoke end + task :importmemo do + ENV['CLASS']='Memo' + ENV['SCOPE']='indexable' + ENV['FORCE']='y' + ENV['BATCH']='1000' + Rake::Task["elasticsearch:import:model"].invoke + end end \ No newline at end of file From ad2d9fa374bfd1d4e348de8bdf3f3fda6a1849d7 Mon Sep 17 00:00:00 2001 From: lizanle <491823689@qq.com> Date: Mon, 7 Dec 2015 15:32:57 +0800 Subject: [PATCH 04/17] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=AF=B9=E5=B8=96?= =?UTF-8?q?=E5=AD=90=E7=9A=84=E5=85=A8=E6=96=87=E6=90=9C=E7=B4=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/users/_user_message_course.html.erb | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/app/views/users/_user_message_course.html.erb b/app/views/users/_user_message_course.html.erb index 640f98b1f..cc6415c14 100644 --- a/app/views/users/_user_message_course.html.erb +++ b/app/views/users/_user_message_course.html.erb @@ -173,19 +173,25 @@ <%=link_to ma.course_message.user.lastname + ma.course_message.user.firstname + "老师", user_path(ma.course_message.user), :class => "newsBlue homepageNewsPublisher" %>">关闭了作业匿评:
  • - <%= link_to "作业题目:" + ma.course_message.name, student_work_index_path(:homework => ma.course_message.id), :class =>"#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}", + <%= link_to "作业标题:" + ma.course_message.name, student_work_index_path(:homework => ma.course_message.id), :class =>"#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}", :onmouseover =>"message_titile_show($(this),event)", :onmouseout => "message_titile_hide($(this))"%>
  • <%= time_tag(ma.created_at).html_safe %>
  • From 9e01f02a661890fe6700192da1dd8873d4d8fcae Mon Sep 17 00:00:00 2001 From: lizanle <491823689@qq.com> Date: Mon, 7 Dec 2015 15:52:22 +0800 Subject: [PATCH 05/17] =?UTF-8?q?=E4=BD=9C=E4=B8=9A=E9=A2=98=E7=9B=AE?= =?UTF-8?q?=E7=BB=9F=E4=B8=80=E6=94=B9=E4=B8=BA=E4=BD=9C=E4=B8=9A=E6=A0=87?= =?UTF-8?q?=E9=A2=98=20=20=E4=BD=9C=E4=B8=9A=E5=8C=BF=E8=AF=84=E6=88=AA?= =?UTF-8?q?=E6=AD=A2=E6=B6=88=E6=81=AF=E6=94=B9=E9=80=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/users/_user_message_course.html.erb | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/app/views/users/_user_message_course.html.erb b/app/views/users/_user_message_course.html.erb index cc6415c14..4d838d4d1 100644 --- a/app/views/users/_user_message_course.html.erb +++ b/app/views/users/_user_message_course.html.erb @@ -45,12 +45,12 @@
  • <% if !User.current.allowed_to?(:as_teacher, ma.course_message.course) && cur_user_works_for_homework(ma.course_message).nil? %> - <%= link_to "作业题目:" + ma.course_message.name, new_student_work_path(:homework => ma.course_message.id), + <%= link_to "作业标题:" + ma.course_message.name, new_student_work_path(:homework => ma.course_message.id), :class =>"#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}", :onmouseover =>"message_titile_show($(this),event)", :onmouseout => "message_titile_hide($(this))" %> <% else %> - <%= link_to "作业题目:" + ma.course_message.name, student_work_index_path(:homework => ma.course_message.id), + <%= link_to "作业标题:" + ma.course_message.name, student_work_index_path(:homework => ma.course_message.id), :class => "#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}", :onmouseover => "message_titile_show($(this),event)", :onmouseout => "message_titile_hide($(this))" %> @@ -103,7 +103,7 @@ user_path(ma.course_message.user), :class => "newsBlue homepageNewsPublisher", :title => "#{ma.course_message.user.lastname + ma.course_message.user.firstname}老师" %> ">发布的作业:
  • - <%= link_to "作业题目:" + ma.course_message.name, student_work_index_path(:homework => ma.course_message.id), + <%= link_to "作业标题:" + ma.course_message.name, student_work_index_path(:homework => ma.course_message.id), :class => "#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}", :onmouseover => "message_titile_show($(this),event)", :onmouseout => "message_titile_hide($(this))" %> @@ -142,7 +142,7 @@ ">启动了作业匿评:
  • - <%= link_to "作业题目:" + ma.course_message.name, student_work_index_path(:homework => ma.course_message.id), :class => "#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}", + <%= link_to "作业标题:" + ma.course_message.name, student_work_index_path(:homework => ma.course_message.id), :class => "#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}", :onmouseover => "message_titile_show($(this),event)", :onmouseout => "message_titile_hide($(this))" %>
  • @@ -180,14 +180,14 @@
  • -
      -
    • - <%= student_work.user.show_name%> -
    • -
    • - <%= student_work.user.user_extensions.nil? ? "--" : student_work.user.user_extensions.student_id%> -
    • -
    + <% if @homework.homework_type != 3 %> +
      +
    • + <%= student_work.user.show_name%> +
    • +
    • + <%= student_work.user.user_extensions.nil? ? "--" : student_work.user.user_extensions.student_id%> +
    • +
    + <% elsif @homework.homework_type == 3 && @homework.homework_detail_group.base_on_project == 1 %> +
      +
    • + <%= student_work.project.name %> +
    • +
    + <% end %>
  • diff --git a/app/views/student_work/_evaluation_work.html.erb b/app/views/student_work/_evaluation_work.html.erb index e336b0282..58f611b55 100644 --- a/app/views/student_work/_evaluation_work.html.erb +++ b/app/views/student_work/_evaluation_work.html.erb @@ -1,6 +1,11 @@
      - <% is_my_work = student_work.user == User.current%> + <% if @homework.homework_type != 3 %> + <% is_my_work = student_work.user == User.current%> + <% else %> + <% pro = @homework.student_work_projects.where(:user_id => User.current.id).first %> + <% is_my_work = pro && pro.student_work_id == student_work.id%> + <% end %>
      • <% if is_my_work%> @@ -14,14 +19,22 @@
      • -
          -
        • - <%= student_work.user.show_name%> -
        • -
        • - <%= student_work.user.user_extensions.nil? ? "--" : student_work.user.user_extensions.student_id%> -
        • -
        + <% if @homework.homework_type != 3 %> +
          +
        • + <%= student_work.user.show_name%> +
        • +
        • + <%= student_work.user.user_extensions.nil? ? "--" : student_work.user.user_extensions.student_id%> +
        • +
        + <% elsif @homework.homework_type == 3 && @homework.homework_detail_group.base_on_project == 1 %> +
          +
        • + <%= student_work.project.name %> +
        • +
        + <% end %>
      • <% else%>
      • @@ -33,14 +46,22 @@
      • -
          -
        • - 匿名 -
        • -
        • - -- -
        • -
        + <% if @homework.homework_type != 3 %> +
          +
        • + 匿名 +
        • +
        • + -- +
        • +
        + <% elsif @homework.homework_type == 3 && @homework.homework_detail_group.base_on_project == 1 %> +
          +
        • + 匿名 +
        • +
        + <% end %>
      • <% end%> diff --git a/app/views/student_work/_relate_project.html.erb b/app/views/student_work/_relate_project.html.erb index bcfd9eb8e..43f59c9c9 100644 --- a/app/views/student_work/_relate_project.html.erb +++ b/app/views/student_work/_relate_project.html.erb @@ -7,28 +7,6 @@

          -
          @@ -56,7 +34,7 @@ },500); } - //查询组织 + //查询项目 $("input[name='project']").on('input', function (e) { throttle(search_pros,window,e); }); diff --git a/app/views/student_work/_show.html.erb b/app/views/student_work/_show.html.erb index 993b0f2aa..801c252cb 100644 --- a/app/views/student_work/_show.html.erb +++ b/app/views/student_work/_show.html.erb @@ -1,5 +1,12 @@
          + <% is_teacher = User.current.allowed_to?(:as_teacher, @homework.course) || User.current.admin? %> + <% if @homework.homework_type != 3 %> + <% is_my_work = work.user == User.current%> + <% else %> + <% pro = @homework.student_work_projects.where(:user_id => User.current.id).first %> + <% is_my_work = pro && pro.student_work_id == work.id%> + <% end %>
          • 上交时间: @@ -15,7 +22,7 @@ <%= link_to "",edit_student_work_path(work),:class => "pic_edit",:title => "修改"%>
          • <% end%> - <% if @homework.homework_detail_manual.comment_status == 3 && work.user != User.current%> + <% if @homework.homework_detail_manual.comment_status == 3 && !is_my_work %>
          • <%= render :partial => 'student_work_praise' %> @@ -25,11 +32,24 @@ - <% if work.project%> -
          • - 关联项目: - <%= link_to( work.project.name, project_path(work.project.id), :class => "linkBlue" )%> + <% if @homework.homework_type == 3 && work.student_work_projects && (@homework.homework_detail_manual.comment_status != 2 || is_my_work || is_teacher ) %> +
            +
          • + 参与人员: + <%= link_to(work.user.show_name+"(组长)", user_path(work.user.id), :class => "linkBlue" )%> + <% members = work.student_work_projects.where("is_leader = 0") %> + <% members.each do |member| if !members.empty? %> + 、<%=link_to((User.find member.user_id).show_name, user_path(member.user.id), :class => "linkBlue" ) %> + <% end %> + <% end %>
          • + <% if @homework.homework_detail_group.base_on_project == 1 %> +
          • + 关联项目: + <%= link_to( work.project.name, project_path(work.project.id), :class => "linkBlue" )%> + (综合评分:<%=work.project.project_score.score.to_i %>) +
          • + <% end %> <% end%>
          • @@ -52,7 +72,7 @@
          • - <% if @is_teacher || (@homework.homework_detail_manual.comment_status == 2 && work.user != User.current)%> + <% if @is_teacher || (@homework.homework_detail_manual.comment_status == 2 && !is_my_work)%>
            <%= render :partial => 'add_score',:locals => {:work => work,:score => score}%> diff --git a/app/views/student_work/_student_work_list.html.erb b/app/views/student_work/_student_work_list.html.erb index e9b056c84..5598092e9 100644 --- a/app/views/student_work/_student_work_list.html.erb +++ b/app/views/student_work/_student_work_list.html.erb @@ -40,12 +40,17 @@ <% end%>
            - <% if student_work.user == User.current && !@is_evaluation %> + <% if @homework.homework_type != 3 && student_work.user == User.current && !@is_evaluation %> <% if @homework.homework_type == 2%> <%=render :partial => 'programing_work_show', :locals=> {:work => student_work, :score =>student_work_score(student_work,User.current),:student_work_scores => student_work.student_works_scores.order("updated_at desc")} %> <% else %> <%=render :partial => 'show' , :locals=> {:work => student_work, :score =>student_work_score(student_work,User.current),:student_work_scores => student_work.student_works_scores.order("updated_at desc")} %> <% end %> + <% elsif @homework.homework_type == 3 %> + <% pro = @homework.student_work_projects.where(:user_id => User.current.id).first %> + <% if pro && pro.student_work_id == student_work.id && !@is_evaluation %> + <%=render :partial => 'show' , :locals=> {:work => student_work, :score =>student_work_score(student_work,User.current),:student_work_scores => student_work.student_works_scores.order("updated_at desc")} %> + <% end %> <% end %>
            diff --git a/app/views/student_work/new.html.erb b/app/views/student_work/new.html.erb index d14da5fa2..c3a61d4c8 100644 --- a/app/views/student_work/new.html.erb +++ b/app/views/student_work/new.html.erb @@ -54,11 +54,21 @@ function popupRegex(){ if(regexStudentWorkName()&®exStudentWorkDescription()) { - $('#ajax-modal').html("

            作品信息完整性校验中,请稍等...

            "); - showModal('ajax-modal', '500px'); - $('#ajax-modal').siblings().remove(); - $('#ajax-modal').parent().css("top","").css("left",""); - $('#ajax-modal').parent().addClass("anonymos"); + if($("#group_member_ids").length > 0) { + if(regexStudentWorkMember(parseInt($.trim($("#min_num_member").html())),parseInt($.trim($("#max_num_member").html())))) { + $('#ajax-modal').html("

            作品信息完整性校验中,请稍等...

            "); + showModal('ajax-modal', '500px'); + $('#ajax-modal').siblings().remove(); + $('#ajax-modal').parent().css("top","").css("left",""); + $('#ajax-modal').parent().addClass("anonymos"); + } + } else { + $('#ajax-modal').html("

            作品信息完整性校验中,请稍等...

            "); + showModal('ajax-modal', '500px'); + $('#ajax-modal').siblings().remove(); + $('#ajax-modal').parent().css("top","").css("left",""); + $('#ajax-modal').parent().addClass("anonymos"); + } } } @@ -106,7 +116,11 @@ 提示:作品名称和描述中不要出现真实的姓名信息
            - + <% if @homework.homework_type == 3 %> + + + <%=hidden_field_tag 'group_member_ids', params[:group_member_ids], :value=>User.current.id %> + <% end %>
            <%= f.text_field "name", :required => true, :size => 60, :class => "InputBox W700", :maxlength => 200, :placeholder => "请简洁的概括作品的功能或特性", :onkeyup => "regexStudentWorkName();" %>
            @@ -125,12 +139,16 @@
            <%= render :partial => 'users/user_homework_attachment', :locals => {:container => @student_work, :has_program=>false,:has_group=>false} %>
            +
            +
            +
            +
            - <%# if @homework.homework_type == 3 %> - - <%# end %> +
            + <% end %> + 已关联项目:
          - <% activity.student_work_projects.each do |pro| %> + <% activity.student_work_projects.where("is_leader = 1").each do |pro| %>
          - <% project = Project.find pro.project_id %> + <% project = Project.find pro.project_id || User.current.member_of?(project) || User.current.admin? %> <% if project.is_public || project.user_id == User.current.id %> <%= link_to image_tag(url_to_avatar(project),:width=>"40",:height => "40",:class => "borderRadius"),project_path(project.id,:host=>Setting.host_name),:alt =>"项目头像" %> <% else %> diff --git a/app/views/users/_user_homework_attachment.html.erb b/app/views/users/_user_homework_attachment.html.erb index f1c0ae97e..7aefbd0b0 100644 --- a/app/views/users/_user_homework_attachment.html.erb +++ b/app/views/users/_user_homework_attachment.html.erb @@ -43,7 +43,25 @@ :lebel_file_uploding => l(:lebel_file_uploding), :delete_all_files => l(:text_are_you_sure_all) } %> - + +
          + +
          + <% if @homework && @homework.homework_type == 3 %> + + 合作成员:<%=User.current.show_name %>(组长) + + + <% end %> +
          + + <% if @homework %> + <% unless @homework.student_work_projects.where("user_id = #{User.current.id}").empty? %> + <% project = Project.find @homework.student_work_projects.where("user_id = #{User.current.id}").first.project_id %> + 关联项目:<%=project.name %> + <% end %> + <% end %> +
          diff --git a/app/views/users/_user_homework_detail.html.erb b/app/views/users/_user_homework_detail.html.erb index 8e01ee908..57fe57c07 100644 --- a/app/views/users/_user_homework_detail.html.erb +++ b/app/views/users/_user_homework_detail.html.erb @@ -49,10 +49,19 @@ 系统提示:该作业要求各组长<%=link_to "创建项目", new_project_path(:host=>Setting.host_name),:class=>"c_red",:title=>"新建项目",:style=>"text-decoration:underline;"%>,组成员加入项目,然后由组长关联项目。谢谢配合! <% end %>
          - <% if homework_common.homework_type == 3%> -
          - <%= relate_project(homework_common,is_teacher,is_in_course,-1,-1) %> -
          + <% if homework_common.homework_type == 3 && !is_teacher && homework_common.homework_detail_group.base_on_project == 1%> + <% projects = cur_user_projects_for_homework homework_common %> + <% works = cur_user_works_for_homework homework_common %> + <% if works.nil? && projects.nil? %> +
          + <%=link_to "关联项目",new_student_work_project_student_work_index_path(:homework => homework_common.id,:is_in_course=>is_in_course,:user_activity_id=>-1,:course_activity=>-1),remote: true,:class=> 'c_blue', :title=> '请选择分组作业关联的项目' %> + <%#= relate_project(activity,is_teacher,-1,user_activity_id,course_activity) %> +
          + <% elsif works.nil? %> +
          + <%=link_to "取消关联",cancel_relate_project_student_work_index_path(:homework => homework_common.id,:is_in_course=>is_in_course,:user_activity_id=>-1,:course_activity=>-1), :confirm => "您确定要取消关联吗?", remote: true,:class => "c_blue", :title=> '取消关联项目' %> +
          + <% end %> <% end %>
          <%= user_for_homework_common homework_common,is_teacher %> @@ -90,15 +99,16 @@ <%= render :partial => 'student_work/work_attachments', :locals => {:attachments => homework_common.attachments} %>
          - <% if homework_common.homework_type == 3 && !homework_common.student_work_projects.empty? %> + <% if homework_common.homework_type == 3 && !homework_common.student_work_projects.empty? && homework_common.homework_detail_group.base_on_project == 1 %>
          -
          - +
          + + 已关联项目:
          - <% homework_common.student_work_projects.each do |pro| %> + <% homework_common.student_work_projects.where("is_leader = 1").each do |pro| %>
          <% project = Project.find pro.project_id %> - <% if project.is_public == 1 %> + <% if project.is_public == 1 || User.current.member_of?(project) || User.current.admin? %> <%=link_to image_tag(url_to_avatar(project),:width=>"40",:height => "40",:class => "borderRadius"),project_path(project.id,:host=>Setting.host_name) %> <% else %> <%= image_tag(url_to_avatar(project),:width=>"40",:height => "40",:class => "borderRadius") %> diff --git a/config/routes.rb b/config/routes.rb index 2be4f7221..db63fe3ee 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -221,6 +221,7 @@ RedmineApp::Application.routes.draw do post 'student_work_project' get 'new_student_work_project' get 'search_user_projects' + get 'search_course_students' get 'cancel_relate_project' get 'delete_work' get 'destroy_score_reply' diff --git a/lib/tasks/homework_evaluation.rake b/lib/tasks/homework_evaluation.rake index 84082eb9b..585d91737 100644 --- a/lib/tasks/homework_evaluation.rake +++ b/lib/tasks/homework_evaluation.rake @@ -14,14 +14,33 @@ namespace :homework_evaluation do if homework_common.anonymous_comment == 0 && homework_detail_manual.comment_status == 1 #新建状态才可开启匿评 student_works = homework_common.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 + if homework_common.homework_type == 3 + student_work_projects = homework_common.student_work_projects.where("student_work_id is not null") + student_work_projects.each_with_index do |pro_work, pro_index| + n = homework_detail_manual.evaluation_num + n = n < student_works.size ? n : student_works.size - 1 + work_index = -1 + student_works.each_with_index do |stu_work, stu_index| + if stu_work.id.to_i == pro_work.student_work_id.to_i + work_index = stu_index + end + end + assigned_homeworks = get_assigned_homeworks(student_works, n, work_index) + assigned_homeworks.each do |h| + student_works_evaluation_distributions = StudentWorksEvaluationDistribution.new(user_id: pro_work.user_id, student_work_id: h.id) + student_works_evaluation_distributions.save + end + end + else + 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 end homework_detail_manual.update_column('comment_status', 2) diff --git a/public/images/course/proRelated.png b/public/images/course/proRelated.png new file mode 100644 index 0000000000000000000000000000000000000000..2cc1252cc0918a854d382c3bc6aebb1211f2a3b9 GIT binary patch literal 1249 zcmeAS@N?(olHy`uVBq!ia0vp^8X(NU1|)m_?Z^dEk|nMYCBgY=CFO}lsSJ)O`AMk? zp1FzXsX?iUDV2pMQ*9U+m<2LJB1$5BeXNr6bM+EIYV;~{3xK*A7;Nk-3KEmEQ%e+* zQqwc@Y?a>c-mj#PnPRIHZt82`Ti~3Uk?B!Ylp0*+7m{3+ootz+WN)WnQ(*-(AUCxn zQK2F?C$HG5!d3}vt`(3C64qBz04piUwpD^SD#ABF!8yMuRl!uxSU1_g&``n5OwZ87 z)XdCKN5ROz&`93^h|F{iO{`4Ktc=VRpg;*|TTx1yRgjAt)Gi>;Rw<*Tq`*pFzr4I$ zuiRKKzbIYb(9+TpWQLKEE>MMTab;dfVufyAu`kBtHuNWFoz#!AFNG#Ad)HBe}%?0@jth%@)C>7xhtg4GcDhpEegHnt0 zON)|$@sXws(+mtd{1$-}0$pR}lAm0fo0?bR>0+w{6wyn`OtEq^b#rwzaCEYCb~ZLN zbTxHyb2e~wGIcU?HaB*5bTNkM^~@_SNz6-5h3U;i=yk-a*UGslHL)bWC?r2W2Nrt) z8Tlpo#Toep3eLf13gMY~Df#8apn!$CGqotQEH%ZgC_h&L95Pm!NVYqfIXYT6ni!fG z8CV*cIU1Nd8JnBBS{j==n;1B`8kj3V^`s#AmY^Pepym3YXhe!um=G|nfSB+^3gp0( zd1@XoZ5II(@xN_dJq!$t>7Fi*Ar-gITu)rrtiZ$YVC$ljyZ@iubJjS}+HjYJ@|FvS zGB(L`UCuuU$yrBd9~dkS*MTK1eatgSYG3OtKT^*h>mFd(F1GN 0) { + if(regexStudentWorkMember(parseInt($.trim($("#min_num_member").html())),parseInt($.trim($("#max_num_member").html())))) { + $("#new_student_work").submit(); + $("#ajax-indicator").hide(); + } + } else { + $("#new_student_work").submit(); + $("#ajax-indicator").hide(); + } } } diff --git a/public/javascripts/new_user.js b/public/javascripts/new_user.js index dcd8a35ca..d375a90ee 100644 --- a/public/javascripts/new_user.js +++ b/public/javascripts/new_user.js @@ -251,8 +251,15 @@ function new_student_work() { if(regexStudentWorkName()&®exStudentWorkDescription()) { - $("#new_student_work").submit(); - $("#ajax-indicator").hide(); + if($("#group_member_ids").length > 0) { + if(regexStudentWorkMember(parseInt($.trim($("#min_num_member").html())),parseInt($.trim($("#max_num_member").html())))) { + $("#new_student_work").submit(); + $("#ajax-indicator").hide(); + } + } else { + $("#new_student_work").submit(); + $("#ajax-indicator").hide(); + } } } @@ -298,6 +305,17 @@ function regexStudentWorkDescription() } } +function regexStudentWorkMember(min, max) { + var members = $.trim($("#group_member_ids").val()).split(','); + if ( min <= members.length && members.length <= max ){ + $("#student_work_group_textarea").text(""); + return true; + } else { + $("#student_work_group_textarea").text("合作成员人数应为:"+min+"-"+max+"人"); + return false; + } +} + //学生作品 function show_project() {