Skip to content

Instantly share code, notes, and snippets.

View scytacki's full-sized avatar

Scott Cytacki scytacki

  • Concord Consortium
  • Medford, MA
View GitHub Profile
def swap_image_question_prompts
mis_processed = 0
managed_interactives = ManagedInteractive.where(library_interactive_id: 41).where("legacy_ref_id is not null").where("updated_at < '2022-08-04'")
mis_to_process = managed_interactives.count
managed_interactives.find_in_batches(batch_size: 1000) { |batch|
ActiveRecord::Base.transaction {
batch.each { |mi|
authored_state = JSON.parse(mi.authored_state)
prompt = authored_state["prompt"]
answerPrompt = authored_state["answerPrompt"]
@scytacki
scytacki / copy-half-width-setting.rb
Last active August 6, 2022 14:18
copy-half-width-setting.rb
ManagedInteractive.where("legacy_ref_id is not null").where("updated_at < '2022-08-04'").count
Embeddable::OpenResponse.joins(:converted_interactive).where(is_half_width: true).count +
Embeddable::MultipleChoice.joins(:converted_interactive).where(is_half_width: true).count +
Embeddable::ImageQuestion.joins(:converted_interactive).where(is_half_width: true).count +
VideoInteractive.joins(:converted_interactive).where(is_half_width: true).count +
ImageInteractive.joins(:converted_interactive).where(is_half_width: true).count
def author_modified_count
ManagedInteractive.where("legacy_ref_id is not null").where("updated_at > '2022-08-04'").count
ManagedInteractive.where(library_interactive_id: 41).where("authored_state like '%\"answerPrompt\":null%' or authored_state like '%\"answerPrompt\":\"\"%'").where("legacy_ref_id is null").count
def add_describe_the_drawing
mis_processed = 0
managed_interactives = ManagedInteractive.where(library_interactive_id: 41).where("authored_state like '%\"answerPrompt\":null%' or authored_state like '%\"answerPrompt\":\"\"%'").where("legacy_ref_id is null")
mis_to_process = managed_interactives.count
managed_interactives.find_in_batches(batch_size: 100) { |batch|
ActiveRecord::Base.transaction {
batch.each { |mi|
authored_state = JSON.parse(mi.authored_state)
Embeddable::ImageQuestion.joins(:converted_interactive).where("drawing_prompt like '%<img%' or prompt like '%<img%'").count
=> 60
Embeddable::OpenResponse.joins(:converted_interactive).where("prompt like '%<img%'").count
=> 1525
Embeddable::MultipleChoice.joins(:converted_interactive).where("prompt like '%<img%'").count
=> 622
ManagedInteractive.where("legacy_ref_id is not null").where("authored_state like '%\\u003Cimg%'").count
=> 2218
-- This is the log when I exported an activity with a single page and
-- single open resp question
app_1 | Started GET "/api/v1/activities/24/report_structure.json" for 172.22.0.4 at 2022-07-28 01:49:47 +0000
app_1 | Processing by Api::V1::LightweightActivitiesController#report_structure as JSON
app_1 | Parameters: {"id"=>"24"}
app_1 | session before:{"session_id"=>"26ee56a0ca00470ff11786176e766ab6", "warden.user.user.key"=>[[1], "$2a$10$u82W97eO7fS6esmPeMouAO"], "warden.user.user.session"=>{"last_request_at"=>2022-07-28 01:29:55 UTC}, "_csrf_token"=>"RJkLzKqiZrUbQkAPdsEDr32LdjeaqCmwOgFq+arVc4Q="}
app_1 | * Accept-Language: en-US,en;q=0.9,es-419;q=0.8,es;q=0.7
app_1 | * Locale set to 'en'
{
"background_image": "",
"description": "",
"editor_mode": 0,
"id": 21610,
"layout": 0,
"name": "Test Built in Open Response and TE",
"notes": "",
"related": "",
"runtime": "LARA",
@scytacki
scytacki / timesheet-updater.js
Last active October 16, 2025 14:54
Some scripts for updating cells in timesheet.
function updateReactInput(inp, value) {
Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype, 'value').set.call(inp, value);
inp.dispatchEvent(new Event('change', { bubbles: true}));
}
function updateReactSelect(inp, value) {
Object.getOwnPropertyDescriptor(window.HTMLSelectElement.prototype, 'value').set.call(inp, value);
inp.dispatchEvent(new Event('change', { bubbles: true}));
}
Admin::Project.where("landing_page_content LIKE '%renderMaterialsCollection(101%'")

Tools have:

  • tool_id
  • url
  • name

Usage of tool_id

API/ReportUsersController

#external_report_query

@scytacki
scytacki / create-cases.js
Created October 5, 2020 13:03
Google spreadsheet function to 'explode' a range based on a column that has a 'count' in it. Each row is duplicated 'count' times.
function CREATE_CASES(input_range, count_column) {
return input_range.map((row) => {
let rows = [];
for(let i=0; i<row[count_column]; i++){
rows.push(row);
}
return rows
}).flat();
}