-
Notifications
You must be signed in to change notification settings - Fork 479
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
command line script to add teachers' csd sections to ai-rubrics experiment #57848
Merged
Merged
Changes from 5 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
f4287cf
ruby script to add teachers csd sections to ai-rubrics experiment
davidsbailey bf9e7aa
print success message
davidsbailey d6fae00
make filename match experiment name
davidsbailey 962bec5
add script to clear experiments for all of a teachers sections
davidsbailey ee9e285
remove useless requires
davidsbailey 5ace0b7
speed up i18n load
davidsbailey File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#!/usr/bin/env ruby | ||
|
||
$experiment_name = 'ai-rubrics' | ||
|
||
$teacher_emails = ARGV[0].split(',').compact.map(&:strip) | ||
raise "Please provide a comma-separated list of teacher emails" if $teacher_emails.empty? | ||
|
||
$teacher_emails.each do |email| | ||
raise "Invalid email: #{email.dump}" unless email.include?('@') | ||
end | ||
|
||
# this can take up to 60 seconds | ||
require_relative '../../dashboard/config/environment' | ||
|
||
def main | ||
num_disabled = 0 | ||
$teacher_emails.each do |email| | ||
teacher = User.find_by_email(email) | ||
unless teacher | ||
puts "could not find user with email #{email.dump}" | ||
next | ||
end | ||
|
||
sections = teacher.sections_instructed | ||
|
||
experiments = SingleSectionExperiment.where(name: $experiment_name, section: sections) | ||
if experiments.empty? | ||
puts "no experiments found for teacher #{email}" | ||
next | ||
end | ||
experiments.destroy_all | ||
num_disabled += 1 | ||
end | ||
puts "successfully disabled experiment for #{num_disabled} teachers" if num_disabled > 0 | ||
end | ||
|
||
main |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
#!/usr/bin/env ruby | ||
|
||
$experiment_name = 'ai-rubrics' | ||
|
||
# map from CSD course to that course's unit which supports the experiment | ||
$csd_course_unit_map = { | ||
'csd-2023' => 'csd3-2023', | ||
'focus-on-creativity-2023' => 'focus-on-creativity3-2023', | ||
'focus-on-coding-2023' => 'focus-on-coding3-2023', | ||
} | ||
|
||
# standalone units that support the experiment | ||
$csd_standalone_units = ['interactive-games-animations-2023'] | ||
|
||
$teacher_emails = ARGV[0].split(',').compact.map(&:strip) | ||
raise "Please provide a comma-separated list of teacher emails" if $teacher_emails.empty? | ||
|
||
$teacher_emails.each do |email| | ||
raise "Invalid email: #{email.dump}" unless email.include?('@') | ||
end | ||
|
||
# this can take up to 60 seconds | ||
require_relative '../../dashboard/config/environment' | ||
|
||
# given the course and unit a section is assigned to, assign the unit for which | ||
# the experiment should be enabled | ||
def get_experiment_unit_name(section) | ||
assigned_course = section.unit_group&.name | ||
assigned_unit = section.script&.name | ||
return $csd_course_unit_map[assigned_course] if assigned_course | ||
return assigned_unit if $csd_standalone_units.include?(assigned_unit) | ||
end | ||
|
||
def main | ||
num_enabled = 0 | ||
$teacher_emails.each do |email| | ||
teacher = User.find_by_email(email) | ||
unless teacher | ||
puts "could not find user with email #{email.dump}" | ||
next | ||
end | ||
|
||
sections = teacher.sections_instructed.reject(&:hidden) | ||
already_found_csd_section = false | ||
sections.each do |section| | ||
unit_name = get_experiment_unit_name(section) | ||
next unless unit_name | ||
num_enabled += 1 unless already_found_csd_section | ||
already_found_csd_section = true | ||
unit = Unit.find_by_name!(unit_name) | ||
SingleSectionExperiment.find_or_create_by!(name: $experiment_name, section: section, script: unit) | ||
end | ||
puts "no CSD sections found for teacher #{email}" unless already_found_csd_section | ||
end | ||
puts "successfully enabled experiment for #{num_enabled} teachers" if num_enabled > 0 | ||
end | ||
|
||
main |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here is a trick. Add:
Before this require. Cuts the time in half roughly in environments with localization enabled like production:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
great idea! thanks for this!
updated and retested both scripts in the simple case.