diff --git a/.rspec b/.rspec index 8c18f1abd..83e16f804 100644 --- a/.rspec +++ b/.rspec @@ -1,2 +1,2 @@ ---format documentation --color +--require spec_helper diff --git a/Gemfile b/Gemfile index 0aa77ae99..fbe74f8dd 100644 --- a/Gemfile +++ b/Gemfile @@ -28,28 +28,21 @@ gem "rmagick", ">= 2.0.0" group :development do gem 'grape-swagger' - #gem 'grape-swagger-ui', git: 'https://github.com/guange2015/grape-swagger-ui.git' - gem 'puma' if RbConfig::CONFIG['host_os'] =~ /linux/ - gem 'pry-rails' - if RUBY_VERSION >= '2.0.0' - gem 'pry-byebug' - else - # gem 'pry-debugger' - end - gem 'pry-stack_explorer' gem 'better_errors', '~> 1.1.0' gem 'rack-mini-profiler', '~> 0.9.3' end -group :test do - gem "shoulda", "~> 3.5.0" - gem "mocha", "~> 1.1.0" - gem 'capybara', '~> 2.4.1' - gem 'nokogiri', '~> 1.6.3' - gem 'factory_girl', '~> 4.4.0' - gem 'selenium-webdriver', '~> 2.42.0' +group :development, :test do + unless RUBY_PLATFORM =~ /w32/ + gem 'pry-rails' + if RUBY_VERSION >= '2.0.0' + gem 'pry-byebug' + end + gem 'pry-stack_explorer' + end - gem "faker" + gem 'rspec-rails', '~> 3.0' + gem 'factory_girl_rails' end # Gems used only for assets and not required diff --git a/app/api/mobile/apis/courses.rb b/app/api/mobile/apis/courses.rb index b2a2532bc..0900f0446 100644 --- a/app/api/mobile/apis/courses.rb +++ b/app/api/mobile/apis/courses.rb @@ -170,10 +170,26 @@ module Mobile desc "设置教辅" params do - + requires :token,type:String + requires :user_id,type:Integer,desc: '用户id' + requires :course_id,type:Integer,desc:'课程id' + end + get 'set_user_as_assitant' do + cs = CoursesService.new + cs.set_as_assitant_teacher params + present :status, 0 end - post 'set_user_as_assitant' do + desc "删除教辅" + params do + requires :token,type:String + requires :user_id,type:Integer,desc: '用户id' + requires :course_id,type:Integer,desc:'课程id' + end + get 'del_user_as_assitant' do + cs = CoursesService.new + cs.del_assitant_teacher params + present :status, 0 end desc "返回单个课程" @@ -187,7 +203,7 @@ module Mobile course = cs.show_course(params,(current_user.nil? ? User.find(2):current_user)) #course = Course.find(params[:id]) present :data, course, with: Mobile::Entities::Course - present :status, 0 + { status: 0} end end diff --git a/app/api/mobile/apis/homeworks.rb b/app/api/mobile/apis/homeworks.rb index 7a8c87987..5bf454e32 100644 --- a/app/api/mobile/apis/homeworks.rb +++ b/app/api/mobile/apis/homeworks.rb @@ -96,6 +96,21 @@ module Mobile present :status, 0 end + desc '创建作业' + params do + requires :token,type:String + requires :work_name,type:String,desc:'作业名称' + requires :work_desc,type:String,desc:'作业描述' + requires :work_deadline,type:String,desc:'截止日期' + requires :is_blind_appr,type:Integer,desc:'是否匿评' + requires :blind_appr_num,type:Integer,desc:'匿评分配数' + requires :course_id,type:Integer,desc: '课程id' + end + post 'create_home_work' do + Homeworks.get_service.create_home_work params,current_user + present :status, 0 + end + end end diff --git a/app/api/mobile/apis/users.rb b/app/api/mobile/apis/users.rb index 3ef2c3237..62c9c3926 100644 --- a/app/api/mobile/apis/users.rb +++ b/app/api/mobile/apis/users.rb @@ -84,6 +84,7 @@ module Mobile requires :name, type: String, desc: '用户名关键字' requires :search_by, type: String,desc: '搜索依据:0 昵称,1 用户名,2 邮箱,3 昵称和姓名' optional :is_search_assitant,type:Integer,desc:'是否搜索注册用户来作为助教' + optional :course_id,type:Integer,desc: '课程id,搜索注册用户不为该课程教师的其他用户' end get 'search/search_user' do us = UsersService.new diff --git a/app/controllers/boards_controller.rb b/app/controllers/boards_controller.rb index 03581d0c2..7ccfb0e10 100644 --- a/app/controllers/boards_controller.rb +++ b/app/controllers/boards_controller.rb @@ -80,7 +80,7 @@ class BoardsController < ApplicationController includes(:last_reply). limit(@topic_pages.per_page). offset(@topic_pages.offset). - order(sort_clause). + order("last_replies_messages.created_on desc"). preload(:author, {:last_reply => :author}). all elsif @course @@ -88,7 +88,7 @@ class BoardsController < ApplicationController includes(:last_reply). # limit(@topic_pages.per_page). # offset(@topic_pages.offset). - order(sort_clause). + order("last_replies_messages.created_on desc"). preload(:author, {:last_reply => :author}). all : [] @topics = paginateHelper board_topics,10 diff --git a/app/services/courses_service.rb b/app/services/courses_service.rb index fd7ec55fb..36d542d58 100644 --- a/app/services/courses_service.rb +++ b/app/services/courses_service.rb @@ -473,6 +473,41 @@ class CoursesService result end + # 设置人员为课程教辅 + def set_as_assitant_teacher params + members = [] + #找到课程 + course = Course.find(params[:course_id]) + #新建课程人员 + + member = Member.new(:role_ids =>[7], :user_id => params[:user_id],:course_id=>params[:course_id]) + joined = StudentsForCourse.where('student_id = ? and course_id = ?', member.user_id,course.id) + joined.each do |join| + join.delete + end + member.course_group_id = 0 + members << member + course.members << members + #将课程人员设置为教辅 + end + + def del_assitant_teacher params + member = Member.where("user_id = ? and course_id = ?",params[:user_id],params[:course_id]) + member.each do |m| + m.destroy + end + user_admin = CourseInfos.where("user_id = ? and course_id = ?",params[:user_id], params[:course_id]) + if user_admin.size > 0 + user_admin.each do |user| + user.destroy + end + end + joined = StudentsForCourse.where('student_id = ? and course_id = ?', params[:user_id],params[:course_id]) + joined.each do |join| + join.delete + end + end + private def searchmember_by_name members, name #searchPeopleByRoles(project, StudentRoles) @@ -576,4 +611,6 @@ class CoursesService + + end \ No newline at end of file diff --git a/app/services/homework_service.rb b/app/services/homework_service.rb index d22c62a5a..2e7f59888 100644 --- a/app/services/homework_service.rb +++ b/app/services/homework_service.rb @@ -231,6 +231,29 @@ class HomeworkService anonymous_repy(jour) end end + + # 发布作业 + def create_home_work params,current_user + @bid = Bid.new + @bid.name = params[:work_name] + @bid.description = params[:work_desc] + # @bid.is_evaluation = params[:is_blind_appr] + @bid.evaluation_num = params[:blind_appr_num] + @bid.open_anonymous_evaluation = params[:is_blind_appr] + @bid.reward_type = 3 + @bid.deadline = params[:work_deadline] + @bid.budget = 0 + @bid.author_id = current_user.id + @bid.commit = 0 + @bid.homework_type = 1 + # @bid. + if @bid.save + HomeworkForCourse.create(:course_id => params[:course_id], :bid_id => @bid.id) + unless @bid.watched_by?(current_user) + @bid.add_watcher(current_user) + end + end + end # 学生匿评列表 def student_jour_list params diff --git a/app/services/users_service.rb b/app/services/users_service.rb index 17557872b..071820ba3 100644 --- a/app/services/users_service.rb +++ b/app/services/users_service.rb @@ -211,7 +211,8 @@ class UsersService search_by = params[:search_by] ? params[:search_by] : "0" scope = scope.where("id not in (?)",watcher).like(params[:name],search_by) if params[:name].present? else - scope = scope.like(params[:name],search_by) if params[:name].present? + teachers = searchTeacherAndAssistant(Course.find(params[:course_id])) + scope = scope.where("id not in (?)",teachers.map{|t| t.user_id}).like(params[:name],search_by) if params[:name].present? end scope end diff --git a/app/views/attachments/_form.html.erb b/app/views/attachments/_form.html.erb index 2e8800617..845e2b6a0 100644 --- a/app/views/attachments/_form.html.erb +++ b/app/views/attachments/_form.html.erb @@ -17,6 +17,7 @@ <%= hidden_field_tag "attachments[p#{i}][token]", "#{attachment.token}" %> +
<% end %> <% container.saved_attachments.each_with_index do |attachment, i| %> @@ -34,10 +35,12 @@ <%= hidden_field_tag "attachments[p#{i}][token]", "#{attachment.token}" %> +
<% end %> <% end %> <% project = project %> +
<%#= button_tag "浏览", :type=>"button", :onclick=>"CompatibleSend();" %> diff --git a/app/views/attachments/_form_project.html.erb b/app/views/attachments/_form_project.html.erb index 9778d3242..515e307f6 100644 --- a/app/views/attachments/_form_project.html.erb +++ b/app/views/attachments/_form_project.html.erb @@ -1,4 +1,72 @@ - +<% if defined?(container) %> + +<% if defined?(container) && container && container.saved_attachments %> + <% if isReply %> + <% container.saved_attachments.each_with_index do |attachment, i| %> + + + <%= text_field_tag("attachments[p#{i}][filename]", attachment.filename, :class => 'filename readonly', :readonly=>'readonly')%> + <%= text_field_tag("attachments[p#{i}][description]", attachment.description, :maxlength => 255, :placeholder => l(:label_optional_description), :class => 'description', :style=>"display: inline-block;") %> + <%= l(:field_is_public)%>: + <%= check_box_tag("attachments[p#{i}][is_public_checkbox]", attachment.is_public,attachment.is_public == 1 ? true : false, :class => 'is_public_checkbox')%> + + <%= link_to(' '.html_safe, attachment_path(attachment, :attachment_id => "p#{i}", :format => 'js'), :method => 'delete', :remote => true, :class => 'remove-upload') %> + <%#= render :partial => 'tags/tag', :locals => {:obj => attachment, :object_flag => "6"} %> + <%= hidden_field_tag "attachments[p#{i}][token]", "#{attachment.token}" %> + + <% end %> + <% else %> + <% container.attachments.each_with_index do |attachment, i| %> + + + <%= text_field_tag("attachments[p#{i}][filename]", attachment.filename, :class => 'filename readonly', :readonly=>'readonly')%> + <%= text_field_tag("attachments[p#{i}][description]", attachment.description, :maxlength => 255, :placeholder => l(:label_optional_description), :class => 'description', :style=>"display: inline-block;") %> + <%= l(:field_is_public)%>: + <%= check_box_tag("attachments[p#{i}][is_public_checkbox]", attachment.is_public,attachment.is_public == 1 ? true : false, :class => 'is_public_checkbox')%> + + <%= link_to(' '.html_safe, attachment_path(attachment, :attachment_id => "p#{i}", :format => 'js'), :method => 'delete', :remote => true, :class => 'remove-upload') %> + <%#= render :partial => 'tags/tag', :locals => {:obj => attachment, :object_flag => "6"} %> + + <%= hidden_field_tag "attachments[p#{i}][token]", "#{attachment.token}" %> + + <% end %> + <% end %> +<% end %> + + + +<%#= button_tag "浏览", :type=>"button", :onclick=>"CompatibleSend();" %> + + <%= button_tag "文件浏览", :type=>"button", :onclick=>"_file#{container.id}.click()", :class =>"sub_btn",:style => ie8? ? 'display:none' : '' %> + <%= file_field_tag 'attachments[dummy][file]', + :id => "_file#{container.id}", + :class => 'file_selector', + :multiple => true, + :onchange => "addInputFiles_board(this, '#{container.id}');", + :style => 'display:none', + :data => { + :max_file_size => Setting.attachment_max_size.to_i.kilobytes, + :max_file_size_message => l(:error_attachment_too_big, :max_size => number_to_human_size(Setting.attachment_max_size.to_i.kilobytes)), + :max_concurrent_uploads => Redmine::Configuration['max_concurrent_ajax_uploads'].to_i, + :upload_path => uploads_path(:format => 'js'), + :description_placeholder => l(:label_optional_description), + :field_is_public => l(:field_is_public), + :are_you_sure => l(:text_are_you_sure), + :file_count => l(:label_file_count), + :delete_all_files => l(:text_are_you_sure_all) + } %> + <%= l(:label_no_file_uploaded)%> +(<%= l(:label_max_size) %>: <%= number_to_human_size(Setting.attachment_max_size.to_i.kilobytes) %>) + +<% else %> + <% if defined?(container) && container && container.saved_attachments %> <% if isReply %> <% container.saved_attachments.each_with_index do |attachment, i| %> @@ -27,39 +95,40 @@ <% end %> <% end %> - - + + <%#= button_tag "浏览", :type=>"button", :onclick=>"CompatibleSend();" %> - - <%= button_tag "文件浏览", :type=>"button", :onclick=>"_file.click()", :class =>"sub_btn",:style => ie8? ? 'display:none' : '' %> - <%= file_field_tag 'attachments[dummy][file]', - :id => '_file', - :class => 'file_selector', - :multiple => true, - :onchange => 'addInputFiles(this);', - :style => 'display:none', - :data => { - :max_file_size => Setting.attachment_max_size.to_i.kilobytes, - :max_file_size_message => l(:error_attachment_too_big, :max_size => number_to_human_size(Setting.attachment_max_size.to_i.kilobytes)), - :max_concurrent_uploads => Redmine::Configuration['max_concurrent_ajax_uploads'].to_i, - :upload_path => uploads_path(:format => 'js'), - :description_placeholder => l(:label_optional_description), - :field_is_public => l(:field_is_public), - :are_you_sure => l(:text_are_you_sure), - :file_count => l(:label_file_count), - :delete_all_files => l(:text_are_you_sure_all) - } %> - <%= l(:label_no_file_uploaded)%> + + <%= button_tag "文件浏览", :type=>"button", :onclick=>"_file.click()", :class =>"sub_btn",:style => ie8? ? 'display:none' : '' %> + <%= file_field_tag 'attachments[dummy][file]', + :id => '_file', + :class => 'file_selector', + :multiple => true, + :onchange => 'addInputFiles(this);', + :style => 'display:none', + :data => { + :max_file_size => Setting.attachment_max_size.to_i.kilobytes, + :max_file_size_message => l(:error_attachment_too_big, :max_size => number_to_human_size(Setting.attachment_max_size.to_i.kilobytes)), + :max_concurrent_uploads => Redmine::Configuration['max_concurrent_ajax_uploads'].to_i, + :upload_path => uploads_path(:format => 'js'), + :description_placeholder => l(:label_optional_description), + :field_is_public => l(:field_is_public), + :are_you_sure => l(:text_are_you_sure), + :file_count => l(:label_file_count), + :delete_all_files => l(:text_are_you_sure_all) + } %> + <%= l(:label_no_file_uploaded)%> (<%= l(:label_max_size) %>: <%= number_to_human_size(Setting.attachment_max_size.to_i.kilobytes) %>) +<% end %> <% content_for :header_tags do %> <%= javascript_include_tag 'attachments' %> <% end %> diff --git a/app/views/attachments/_homework_jour_link.html.erb b/app/views/attachments/_homework_jour_link.html.erb index e0efa211c..8721d41ac 100644 --- a/app/views/attachments/_homework_jour_link.html.erb +++ b/app/views/attachments/_homework_jour_link.html.erb @@ -13,6 +13,6 @@ :target => "_blank"%> <% end %> -
+
<% end %> diff --git a/app/views/attachments/upload.js.erb b/app/views/attachments/upload.js.erb index 24256ccab..c3e7fc3ff 100644 --- a/app/views/attachments/upload.js.erb +++ b/app/views/attachments/upload.js.erb @@ -3,14 +3,15 @@ var fileSpan = $('#attachments_<%= j params[:attachment_id] %>'); fileSpan.hide(); alert("<%= escape_javascript @attachment.errors.full_messages.join(', ') %>"); <% else %> -$('', { type: 'hidden', name: 'attachments[<%= j params[:attachment_id] %>][token]' } ).val('<%= j @attachment.token %>').appendTo(fileSpan); fileSpan.find('a.remove-upload') - .attr({ - "data-remote": true, - "data-method": 'delete', - "href": '<%= j attachment_path(@attachment, :attachment_id => params[:attachment_id], :format => 'js') %>' - }) - .off('click'); + .attr({ + "data-remote": true, + "data-method": 'delete', + "href": '<%= j attachment_path(@attachment, :attachment_id => params[:attachment_id], :format => 'js') %>' + }) + .off('click'); +$('', { type: 'hidden', name: 'attachments[<%= j params[:attachment_id] %>][token]' } ).val('<%= j @attachment.token %>').appendTo(fileSpan); + //var divattach = fileSpan.find('div.div_attachments'); //divattach.html('<%= j(render :partial => 'tags/tagEx', :locals => {:obj => @attachment, :object_flag => "6"})%>'); <% end %> diff --git a/app/views/boards/_course_show.html.erb b/app/views/boards/_course_show.html.erb index 617b9428a..2d0bda162 100644 --- a/app/views/boards/_course_show.html.erb +++ b/app/views/boards/_course_show.html.erb @@ -100,7 +100,8 @@ <%= form_for reply, :as => :reply, :url => {:controller=>'messages',:action => 'reply', :id => topic.id, :board_id => topic.board_id, :is_board => 'true'}, :html => {:multipart => true, :id => 'message_form' + topic.id.to_s} do |f| %> <%= render :partial => 'form_project', :locals => {:f => f, :replying => true} %> - <%= l(:label_memo_create)%> + <%= toggle_link l(:button_cancel), "reply" + topic.id.to_s, :focus => 'message_content',:class => 'grey_btn fr ml10' %> + <%= l(:label_memo_create)%> <% end %>
diff --git a/app/views/boards/_edit.html.erb b/app/views/boards/_edit.html.erb index 46131ca51..0bb15b167 100644 --- a/app/views/boards/_edit.html.erb +++ b/app/views/boards/_edit.html.erb @@ -32,9 +32,9 @@ <%= render :partial => 'form_course', :locals => {:f => f, :replying => !topic.parent.nil?, :topic => topic} %> <%= l(:button_submit)%> - <%= link_to l(:button_cancel), board_message_url(topic.board,topic.root, :r => (topic.parent_id &&topic.id)), :class => "blue_btn grey_btn fl c_white" %> + <%= l(:button_cancel) %> - <% end %> + <% end %> <% end %> diff --git a/app/views/boards/_project_new_topic.html.erb b/app/views/boards/_project_new_topic.html.erb index 3f7c569e1..cab1bbb7b 100644 --- a/app/views/boards/_project_new_topic.html.erb +++ b/app/views/boards/_project_new_topic.html.erb @@ -4,7 +4,7 @@
  • <%= l(:button_cancel) %> - <%= l(:button_submit)%> + <%= l(:button_submit)%>
  • <% end %> \ No newline at end of file diff --git a/app/views/courses/show.html.erb b/app/views/courses/show.html.erb index 29e7f1097..cc3bb33f1 100644 --- a/app/views/courses/show.html.erb +++ b/app/views/courses/show.html.erb @@ -15,7 +15,7 @@   <%= l(:label_new_activity) %>: <%= link_to "#{eventToLanguageCourse(e.event_type, @course)} "<< format_activity_title(e.event_title), (e.event_type.eql?("attachment")&&e.container.kind_of?(Course)) ? course_files_path(e.container) : - (e.event_type.eql?("bid") ? homework_course_path(@course) : (e.event_type.eql?("message") ? course_boards_path(@course,:topic_id => e.id) : e.event_url)),:class => "problem_tit c_dblue fl fb"%> + (e.event_type.eql?("bid") ? homework_course_path(@course) : (e.event_type.eql?("message") || e.event_type.eql?("reply") ? course_boards_path(@course,:topic_id => e.id) : e.event_url)),:class => "problem_tit c_dblue fl fb"%>

    <%= e.event_description.html_safe %>
    diff --git a/app/views/forums/_forum_list.html.erb b/app/views/forums/_forum_list.html.erb index 59ed1092e..ac27235eb 100644 --- a/app/views/forums/_forum_list.html.erb +++ b/app/views/forums/_forum_list.html.erb @@ -48,8 +48,8 @@ - <% end %> -