diff --git a/app/controllers/statistics_controller.rb b/app/controllers/statistics_controller.rb index 2de38c25b..c26719056 100644 --- a/app/controllers/statistics_controller.rb +++ b/app/controllers/statistics_controller.rb @@ -48,6 +48,7 @@ class StatisticsController < ApplicationController # POST /statistics.json def create @statistic = Statistic.new(params[:statistic]) + @statistic.user_id = User.current.id @statistic.save_attachments_containers(params[:attachments], User.current, true) respond_to do |format| if @statistic.save diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index c1fb7da58..1fc455bd7 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -2110,7 +2110,7 @@ class UsersController < ApplicationController exercise_users = ExerciseUser.where(:user_id => @user.id, :exercise_id => exercises.map{|ex| ex.id}) @unfinished_test_count = exercises.count - exercise_users.count # 用户待完成的问卷 - polls = Poll.where("polls_type = 'Course' and polls_group_id in #{my_course_ids} and polls_status = 2") + polls = Poll.where("polls_type = 'Course' and course_id in #{my_course_ids} and polls_status = 2") poll_users = PollUser.where(:user_id => @user.id, :poll_id => polls.map{|poll| poll.id}) @unfinished_poll_count = polls.count - poll_users.count # 用户待匿评的作品 diff --git a/app/models/statistic.rb b/app/models/statistic.rb index e375f3230..136944c09 100644 --- a/app/models/statistic.rb +++ b/app/models/statistic.rb @@ -1,4 +1,8 @@ class Statistic < ActiveRecord::Base - attr_accessible :description, :name, :status, :user_id + attr_accessible :description, :name, :status, :user_id, :main_category_id, :sub_category_id acts_as_attachable + + def creator + User.find self.user_id + end end diff --git a/app/views/statistics/_form.html.erb b/app/views/statistics/_form.html.erb index f26aed35b..3c5b11c3f 100644 --- a/app/views/statistics/_form.html.erb +++ b/app/views/statistics/_form.html.erb @@ -85,7 +85,6 @@ } // 获取子类别 function getSubCategory(id){ - alert(id); $.ajax({ url: '<%= get_sub_category_statistics_path %>', type: 'get', diff --git a/app/views/statistics/_sub_categories_list.html.erb b/app/views/statistics/_sub_categories_list.html.erb new file mode 100644 index 000000000..50506cd54 --- /dev/null +++ b/app/views/statistics/_sub_categories_list.html.erb @@ -0,0 +1,4 @@ +不限 +<% @sub_categories.each do |mc| %> + <%= mc.name %> +<% end %> \ No newline at end of file diff --git a/app/views/statistics/get_sub_category.js.erb b/app/views/statistics/get_sub_category.js.erb index 9e99b073e..4f9eb6ec4 100644 --- a/app/views/statistics/get_sub_category.js.erb +++ b/app/views/statistics/get_sub_category.js.erb @@ -1,5 +1,7 @@ <% if @sub_categories.blank? %> -$("#statistic_sub_category_id").hide(); + $("#statistic_sub_category_id").hide(); +<% elsif params[:come_from] == "statistics_index" %> + $("#sub_categories_list").html('<%= j(render :partial => "sub_categories_list") %>'); <% else %> -$("#statistic_sub_category_id").html('<%= escape_javascript( render :partial => 'statistics/sub_category') %>'); + $("#statistic_sub_category_id").html('<%= escape_javascript( render :partial => 'statistics/sub_category') %>'); <% end %> diff --git a/app/views/statistics/index.html.erb b/app/views/statistics/index.html.erb index d2cff8adf..11ccb2299 100644 --- a/app/views/statistics/index.html.erb +++ b/app/views/statistics/index.html.erb @@ -5,17 +5,14 @@
不限 <% @main_categories.each do |mc| %> - <%= mc.name %> + <%= mc.name %> <% end %>
子类型 -
- 不限 - <% @sub_categories.each do |mc| %> - <%= mc.name %> - <% end %> +
+ <%= render :partial => "sub_categories_list" %>
@@ -37,35 +34,37 @@ 122个检索结果 <%= link_to '+ 发布'.html_safe, new_statistic_path ,:class=>"fr send_statistic mr2" %>
-
-
- -
-
    -
  • -
      -
    • 编辑
    • -
    • 删除
    • -
    -
  • -
-
-
- 数据名称1标签1标签2 -

数据名称1的介绍数据名称1的介绍数据名称1的介绍数据名称1的介绍数据名称1的介绍数据名称1的介绍数据名称1的介绍数据名称1的介绍数据名称1的介绍数据名称1的介绍数据名称1的介绍

-
-

附件1.docx96KB

-

附件1.docx96KB

-
-
- 蔡世 - 2018-02-06 15:51 - 开发数据 - 代码数据 -
-
-
+
+ + <% @statistics.each do |statistic| %> +
+ +
+
    +
  • +
      +
    • <%= link_to '编辑', edit_statistic_path(statistic) %>
    • +
    • <%= link_to '删除', statistic, method: :delete, data: { confirm: 'Are you sure?' } %>
    • +
    +
  • +
+
+
+ <%= link_to "#{statistic.name}", statistic %> +

<%= statistic.description %>

+
+ <%= render :partial => 'attachments',:locals => {:attachments => statistic.try(:attachments)} %> +
+
+ <%= statistic.creator.show_name %> + <%= statistic.created_at %> + 开发数据 + 代码数据 +
+
+
+ <% end %>
@@ -93,6 +92,7 @@
+
@@ -120,9 +120,14 @@
- -