Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions dashboard/app/controllers/scripts_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def edit
has_course: @script&.unit_groups&.any?,
i18n: @script ? @script.summarize_i18n_for_edit : {},
levelKeyList: @script.is_migrated ? Level.key_list : {},
lessonLevelData: @script_file,
lessonLevelData: @script_dsl_text,
locales: options_for_locale_select,
script_families: ScriptConstants::FAMILY_NAMES,
version_year_options: Script.get_version_year_options,
Expand Down Expand Up @@ -190,7 +190,7 @@ def get_rollup_resources
private

def set_script_file
@script_file = ScriptDSL.serialize_lesson_groups(@script)
@script_dsl_text = ScriptDSL.serialize_lesson_groups(@script)
end

def rake
Expand Down
4 changes: 3 additions & 1 deletion dashboard/app/dsl/script_dsl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,9 @@ def self.serialize(script, filename)
end

def self.serialize_to_string(script)
# the serialized data for migrated scripts lives in the .script_json file
return "is_migrated true\n" if script.is_migrated

s = []
# Legacy script IDs
legacy_script_ids = {
Expand Down Expand Up @@ -361,7 +364,6 @@ def self.serialize_to_string(script)
s << 'deprecated true' if script.deprecated
s << 'is_course true' if script.is_course
s << "background '#{script.background}'" if script.background
s << 'is_migrated true' if script.is_migrated

s << '' unless s.empty?
s << serialize_lesson_groups(script)
Expand Down
10 changes: 6 additions & 4 deletions dashboard/app/models/script.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1261,12 +1261,14 @@ def update_text(script_params, script_text, metadata_i18n, general_params)
begin
if Rails.application.config.levelbuilder_mode
script = Script.find_by_name(script_name)
# Save in our custom Script DSL format. This is still what we're using currently to sync data
# across environments. The CPlat team is working on replacing it a new JSON-based approach.
# Save in our custom Script DSL format. This is how we currently sync
# data across environments for non-migrated scripts.
script.write_script_dsl

# Also save in JSON format for "new seeding". This has not been launched yet for most scripts, but as part of
# pre-launch testing, we'll start generating these files in addition to the old .script files.
# Also save in JSON format for "new seeding". This is how we currently
# sync data across environments for migrated scripts. As part of
# pre-launch testing, we also generate these files for legacy scripts in
# addition to the old .script files.
script.write_script_json
end
true
Expand Down
6 changes: 0 additions & 6 deletions dashboard/test/dsl/script_dsl_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -901,13 +901,7 @@ def setup
}
script_text = ScriptDSL.serialize_to_string(script)
expected = <<~SCRIPT
hidden false
new_name 'new name'
family_name 'family name'
version_year '2001'
is_course true
is_migrated true

SCRIPT
assert_equal expected, script_text
end
Expand Down