From 18466876754ffef214ad18ed6a586e58ee4ab3a8 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Wed, 17 Apr 2019 16:23:33 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/exercise_controller.rb | 7 ++- app/helpers/exercise_helper.rb | 4 +- .../_new_shixun_exercise_list.html.erb | 59 +++++++++++++++++-- public/javascripts/edu/course.js | 3 +- 4 files changed, 63 insertions(+), 10 deletions(-) diff --git a/app/controllers/exercise_controller.rb b/app/controllers/exercise_controller.rb index 2dfc2601..15998dbf 100644 --- a/app/controllers/exercise_controller.rb +++ b/app/controllers/exercise_controller.rb @@ -149,11 +149,14 @@ class ExerciseController < ApplicationController end @shixuns = Shixun.where("status = 2 and challenges_count = 1 and id not in (#{none_shixun_ids.join(",")})"). where("name like ?", "%#{search}%").select{|shixun| shixun.challenges.where(:st => 1).count == 0} - @limit = 8 + @limit = 10 + @total_pages = (@shixuns.count / 10.0).ceil @shixuns = paginateHelper @shixuns, @limit respond_to do |format| format.js - render json: exercise_shixun_json_data(@shixuns) + format.json { + render json: exercise_shixun_json_data(@shixuns) + } end end diff --git a/app/helpers/exercise_helper.rb b/app/helpers/exercise_helper.rb index cdea7b88..b0ebedcf 100644 --- a/app/helpers/exercise_helper.rb +++ b/app/helpers/exercise_helper.rb @@ -5,11 +5,13 @@ module ExerciseHelper shixun_owner = shixun.owner.try(:show_name) shixun_path = shixun_path(shixun) shixun_level = shixun.shixun_level + owner_path = user_path(shixun.owner) shixun.attributes.dup.except("gpid", "identifier", "major_id", "webssh", "homepage_show", "fork_from", "git_url", "mirror_script_id", "repo_name", "pod_life").merge({ shixun_owner: shixun_owner, shixun_level: shixun_level, - shixun_path: shixun_path + shixun_path: shixun_path, + owner_path: owner_path }) end end diff --git a/app/views/exercise/_new_shixun_exercise_list.html.erb b/app/views/exercise/_new_shixun_exercise_list.html.erb index a397a0f6..84887695 100644 --- a/app/views/exercise/_new_shixun_exercise_list.html.erb +++ b/app/views/exercise/_new_shixun_exercise_list.html.erb @@ -4,19 +4,19 @@