从题库选择毕设任务时,创建时间应为当前时间

dev_course
cxt 6 years ago
commit c22b3395e6

@ -994,6 +994,20 @@ class CoursesController < ApplicationController
end
end
def search_slim
courses = current_user.manage_courses.not_deleted.processing
keyword = params[:keyword].to_s.strip
if keyword.present?
courses = courses.where('name LIKE ?', "%#{keyword}%")
end
count = courses.count
courses = paginate(courses)
render_ok(count: count, courses: courses.select(:id, :name).as_json)
end
private
# Use callbacks to share common setup or constraints between actions.

@ -33,8 +33,7 @@ class PollVotesController < ApplicationController
current_user_answer = user_votes.first
if current_user_answer&.poll_answer_id != question_answer_id #如果说更换了答案,则以前的答案删除,并新建记录
current_user_answer.destroy
user_votes = PollVote.new(vote_answer_params)
user_votes.save!
PollVote.create(vote_answer_params)
else
if question_answer_text.present?
@ -43,8 +42,7 @@ class PollVotesController < ApplicationController
end
end
else
user_votes = PollVote.new(vote_answer_params)
user_votes.save!
PollVote.create(vote_answer_params)
end
elsif question_type == 2 #多选题的话答案应该是1个以上
question_answer_ids = params[:poll_answer_id] ? params[:poll_answer_id] : [] #该答案的id
@ -102,10 +100,10 @@ class PollVotesController < ApplicationController
@current_question_necessary = @poll_question.is_necessary
#问答记录存在,且有值,才会有返回值。
@current_question_status = 0
if user_votes.present?
vote_answer_id = user_votes.pluck(:poll_answer_id).reject(&:blank?).size
vote_text_count = user_votes.pluck(:vote_text).reject(&:blank?).size
new_user_votes = question_votes.where(user_id: current_user.id)
if new_user_votes.present?
vote_answer_id = new_user_votes.pluck(:poll_answer_id).reject(&:blank?).size
vote_text_count = new_user_votes.pluck(:vote_text).reject(&:blank?).size
if vote_text_count > 0 || vote_answer_id > 0
@current_question_status = 1
end

@ -61,6 +61,8 @@ class Course < ApplicationRecord
scope :hidden, ->(is_hidden = true) { where(is_hidden: is_hidden) }
scope :ended, ->(is_end = true) { where(is_end: is_end) }
scope :processing, -> { where(is_end: false) }
scope :not_deleted, -> { where(is_delete: false) }
scope :deleted, ->(is_delete = 1) { where(is_delete: is_delete) }
scope :by_user, ->(user) { joins(:course_members).where('course_members.user_id = ?', user.id).order(updated_at: :desc) }
scope :by_keywords, lambda { |keywords|

@ -303,6 +303,7 @@ Rails.application.routes.draw do
post 'search_course_list'
get 'board_list'
get 'mine'
get 'search_slim'
end
resources :polls, only:[:index,:new,:create] do

Loading…
Cancel
Save