Friday, September 30, 2016

ASA notes - add randomize flag to instructor quiz


##################################################
# add randomize flag to instructor quiz
##################################################

very similar to the active flag.
same UI, table column in the instructor quizzes table (instructor tools)



rails g migration add_randomize_flag_to_instructor_quiz randomize:boolean

add default: true

class AddRandomizeFlagToInstructorQuiz < ActiveRecord::Migration
  def change
    add_column :instructor_quizzes, :randomize, :boolean, default: true
  end
end


we want default to be randomized, but don't want to convert all existing instructor quizzes to be randomized, so after the migration (which sets the randomize flag to 1 for existing quizzes) manually set the randomize flag to 0 for all existing instructor_quizzes:

update `instructor_quizzes` set randomize=0


Wednesday, September 28, 2016

ASA Notes - add pvt/ins to grs corses

add quizzes and study material

tweaks to:
books_products
products_quiz_definitions

  # products for which the user has active subscriptions
  def activated_quiz_products
    seen = {}
    self.subscriptions.each do |s| 
      if s.active_expiry_subscription?
        # don't include groundschool products here
        # removed this restriction for GRS-58
        # if s.product.name !~ /Ground School/
          seen[s.product] = true        
        # end
      elsif s.active_token_subscription?
        seen[Product.find_by_name("Practice Tests")] = true
      end
    end
    return seen.keys.sort_by {|product| product.name}
  end




Thursday, September 1, 2016

pwo/grs - cloudfront invalidation for S3 video; mysql REPLACE



cloudfront invalidation is sort of a pain in the ass.
easier to just use a new name.
even though that means doing a replace in mysql for the video content id

http://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/Invalidation.html#Invalidation_Requests

UPDATE grs_requirements
SET content_id = REPLACE(content_id, 'vtpp/', 'vtpp4/')
WHERE req_type = 'video'