From 53f9141cf1490db365b422f876850f2c864bba69 Mon Sep 17 00:00:00 2001 From: cxt Date: Wed, 9 Dec 2015 10:29:54 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=86=E7=BB=84=E4=BD=9C=E4=B8=9A=E5=8A=A8?= =?UTF-8?q?=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/student_work_controller.rb | 30 ++++++----- app/helpers/application_helper.rb | 6 +-- .../student_work/_relate_project.html.erb | 51 +++++++++---------- .../student_work/search_user_projects.js.erb | 9 ++++ .../student_work/student_work_project.js.erb | 8 +++ app/views/users/_course_homework.html.erb | 4 ++ config/routes.rb | 1 + public/stylesheets/courses.css | 11 ++++ public/stylesheets/new_user.css | 15 ++++++ 9 files changed, 91 insertions(+), 44 deletions(-) create mode 100644 app/views/student_work/search_user_projects.js.erb diff --git a/app/controllers/student_work_controller.rb b/app/controllers/student_work_controller.rb index 6b5573026..2ee357f82 100644 --- a/app/controllers/student_work_controller.rb +++ b/app/controllers/student_work_controller.rb @@ -551,21 +551,19 @@ class StudentWorkController < ApplicationController #创建作业的关联项目 def student_work_project - projects = cur_user_projects_for_homework @homework - if projects.nil? - @project = StudentWorkProject.new - @project.homework_common_id = @homework.id - @project.project_id = (Project.find params[:project_id]).id - @project.user_id = User.current.id - if @project.save - @user_activity_id = params[:user_activity_id].to_i - @is_in_course = params[:is_in_course].to_i - @course_activity = params[:course_activity].to_i - respond_to do |format| - format.js - end + @project = StudentWorkProject.new + @project.homework_common_id = @homework.id + @project.project_id = (Project.find params[:projectName].to_i).id + @project.user_id = User.current.id + if @project.save + @user_activity_id = params[:user_activity_id].to_i + @is_in_course = params[:is_in_course].to_i + @course_activity = params[:course_activity].to_i + respond_to do |format| + format.js end end + end #查找学生创建的项目列表 @@ -574,7 +572,11 @@ class StudentWorkController < ApplicationController if !params[:name].nil? condition = "%#{params[:name].strip}%".gsub(" ","") end - project_ids = Project.where("user_id = #{User.current.id} and ") + @project_ids = Project.where("user_id = #{User.current.id} and name like '#{condition}'") + @first = params[:first].to_i + respond_to do |format| + format.js + end end private diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 174d33f40..cb90947df 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -2462,13 +2462,13 @@ module ApplicationHelper def relate_project homework,is_teacher,is_in_course,user_activity_id,course_activity if User.current.member_of_course?(homework.course) if is_teacher - link_to "项目(#{homework.student_work_projects.count})",student_work_index_path(:homework => homework.id),:class => "c_blue" + link_to "已关联(#{homework.student_work_projects.count})",student_work_index_path(:homework => homework.id),:class => "c_blue" else projects = cur_user_projects_for_homework homework if projects.nil? - link_to "关联项目(#{homework.student_work_projects.count})", new_student_work_project_student_work_index_path(:homework => homework.id,:is_in_course=>is_in_course,:user_activity_id=>user_activity_id,:course_activity=>course_activity),remote: true,:class=> 'c_blue', :title=> '请选择分组作业关联的项目' + link_to "关联项目",new_student_work_project_student_work_index_path(:homework => homework.id,:is_in_course=>is_in_course,:user_activity_id=>user_activity_id,:course_activity=>course_activity),remote: true,:class=> 'c_blue', :title=> '请选择分组作业关联的项目' else - link_to "已关联项目(#{homework.student_work_projects.count})",student_work_index_path(:homework => homework.id),:class => "c_blue" + link_to "取消关联",cancel_relate_project_student_work_index_path(:homework => homework.id,:is_in_course=>is_in_course,:user_activity_id=>user_activity_id,:course_activity=>course_activity),remote: true,:class => "c_blue", :title=> '取消关联项目' end end end diff --git a/app/views/student_work/_relate_project.html.erb b/app/views/student_work/_relate_project.html.erb index 2db43ec59..bcfd9eb8e 100644 --- a/app/views/student_work/_relate_project.html.erb +++ b/app/views/student_work/_relate_project.html.erb @@ -1,11 +1,13 @@
关联项目 - <%=form_tag url_for(:controller=>'student_work',:action=>'student_work_project',:course_id=>@course_id,:user_activity_id=>@user_activity_id,:is_in_course=>@is_in_course),:id =>'student_work_relate_project',:class=>'resourcesSearchBox',:remote => true do %> - - -
-
\ No newline at end of file diff --git a/app/views/student_work/search_user_projects.js.erb b/app/views/student_work/search_user_projects.js.erb new file mode 100644 index 000000000..7751821a5 --- /dev/null +++ b/app/views/student_work/search_user_projects.js.erb @@ -0,0 +1,9 @@ +<% if @first == 1 && @project_ids.empty? %> + $("#no_search_result").show(); +<% else %> + $("#search_project_list").html(""); + <% @project_ids.each do |project|%> + link = "
  • "; + $("#search_project_list").append(link ); + <% end %> +<% end %> \ No newline at end of file diff --git a/app/views/student_work/student_work_project.js.erb b/app/views/student_work/student_work_project.js.erb index e69de29bb..dbf66acd3 100644 --- a/app/views/student_work/student_work_project.js.erb +++ b/app/views/student_work/student_work_project.js.erb @@ -0,0 +1,8 @@ +hideModal("#popbox02"); +<% if @user_activity_id != -1 %> + $("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'users/course_homework', :locals => {:activity => @homework,:user_activity_id =>@user_activity_id,:course_activity => @course_activity}) %>"); + init_activity_KindEditor_data(<%= @user_activity_id%>,"","87%"); +<% else%> + $("#homework_common_<%= @homework_common_id %>").replaceWith("<%= escape_javascript(render :partial => 'users/user_homework_detail', :locals => {:homework_common => @homework,:is_in_course => @is_in_course}) %>"); + init_activity_KindEditor_data(<%= @homework_common_id%>,"","87%"); +<% end %> \ No newline at end of file diff --git a/app/views/users/_course_homework.html.erb b/app/views/users/_course_homework.html.erb index 9f2beedd0..ef4bf8a22 100644 --- a/app/views/users/_course_homework.html.erb +++ b/app/views/users/_course_homework.html.erb @@ -44,6 +44,10 @@ 教师评阅中 <% end%> <% end%> +
    + <% if activity.homework_type == 3%> + 系统提示:该作业要求各组长<%=link_to "创建项目", new_project_path(:host=>Setting.host_name),:class=>"c_red",:title=>"新建项目",:style=>"text-decoration:underline;"%>,组成员加入项目,然后由组长关联项目。谢谢配合! + <% end %>
    <% if activity.homework_type == 3%>
    diff --git a/config/routes.rb b/config/routes.rb index b375053fd..62ed2eae1 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -220,6 +220,7 @@ RedmineApp::Application.routes.draw do post 'add_score_reply' post 'student_work_project' get 'new_student_work_project' + get 'search_user_projects' get 'delete_work' get 'destroy_score_reply' get 'student_work_absence_penalty' diff --git a/public/stylesheets/courses.css b/public/stylesheets/courses.css index 0373f24bc..f13e6ef84 100644 --- a/public/stylesheets/courses.css +++ b/public/stylesheets/courses.css @@ -1197,6 +1197,17 @@ a:hover.memberBtn{background: url(/images/course/hwork_icon.png) -80px -90px no- .resubTitle {position:absolute; top:-10px; left:5px; background-color:#ffffff; display:block; font-weight:bold; padding:0px 2px;} a.blueCir{ display:inline-block; padding:2px 5px; background-color:#ffffff;border:1px solid #3598db; color:#3598db; -moz-border-radius:5px; -webkit-border-radius:5px; border-radius:5px;} a:hover.blueCir{ background:#3598db; color:#fff;} +.proList {background-color:#eaeaea; padding:5px 10px; display:block; max-width:655px; float:left;} + +.borderRadius {border-radius:5px;} +.maxHeight100 {max-height:100px; overflow-x:hidden; overflow-y:auto;} +.proRelateWrap {width:38px; height:38px; border:1px solid #cecece; border-radius:3px; background-color:#f1f1f1;} +.mt7 {margin-top:7px;} +.ml7 {margin-left:7px;} +.tac {text-align:center;} +.proHelp {background:url(/images/course/hwork_icon.png) -5px -124px no-repeat; display:inline-block; width:15px; height:15px; display:inline-block;} +.hworkPrName {width:110px; max-width:110px; overflow:hidden; white-space: nowrap; text-overflow:ellipsis; float:left; height:18px; line-height:18px; font-size:12px; color:#888888; text-align:center;} +.mr150 {margin-right:150px;} /*上传资源弹窗*/ .resourceUploadPopup {width:400px; height:auto; border:3px solid #269ac9 !important; padding-left:16px; padding-bottom:16px; background-color:#ffffff; position:absolute; top:50%; left:50%; margin-left:-200px; z-index:1000;} diff --git a/public/stylesheets/new_user.css b/public/stylesheets/new_user.css index 199b38305..0ed4df627 100644 --- a/public/stylesheets/new_user.css +++ b/public/stylesheets/new_user.css @@ -1366,3 +1366,18 @@ a:hover.memberBtn{background: url(/images/course/hwork_icon.png) -80px -90px no- .rightArrow {margin:50px 15px 0px 15px; float:left;} .relateText {font-size:16px; color:#269ac9; line-height:16px; padding-top:20px; display:inline-block; font-weight: bold;} .maxHeight100 {max-height:100px; overflow-x:hidden; overflow-y:auto;} +.resubAtt {border-top:1px solid #dddddd; position:relative; margin-top:15px;} +.resubTitle {position:absolute; top:-10px; left:5px; background-color:#ffffff; display:block; font-weight:bold; padding:0px 2px;} +a.blueCir{ display:inline-block; padding:2px 5px; background-color:#ffffff;border:1px solid #3598db; color:#3598db; -moz-border-radius:5px; -webkit-border-radius:5px; border-radius:5px;} +a:hover.blueCir{ background:#3598db; color:#fff;} +.proList {background-color:#eaeaea; padding:5px 10px; display:block; max-width:655px; float:left;} + +.borderRadius {border-radius:5px;} +.maxHeight100 {max-height:100px; overflow-x:hidden; overflow-y:auto;} +.proRelateWrap {width:38px; height:38px; border:1px solid #cecece; border-radius:3px; background-color:#f1f1f1;} +.mt7 {margin-top:7px;} +.ml7 {margin-left:7px;} +.tac {text-align:center;} +.proHelp {background:url(/images/course/hwork_icon.png) -5px -124px no-repeat; display:inline-block; width:15px; height:15px; display:inline-block;} +.hworkPrName {width:110px; max-width:110px; overflow:hidden; white-space: nowrap; text-overflow:ellipsis; float:left; height:18px; line-height:18px; font-size:12px; color:#888888; text-align:center;} +.mr150 {margin-right:150px;}