{"ScriptPreparationCode":"var currentDraft = {\r\n id: \u00223fa85f64-5717-4562-b3fc-2c963f66afa6\u0022,\r\n user: {\r\n \tid: \u0022userID\u0022,\r\n firstname: \u0022firstname\u0022,\r\n lastname: \u0022lastname\u0022,\r\n email: \u0022email\u0022\r\n },\r\n languages: [{\r\n id: \u0022language1Id\u0022,\r\n draftId: \u00223fa85f64-5717-4562-b3fc-2c963f66afa6\u0022,\r\n name: \u0022fi\u0022,\r\n highlight: \u0022new highlight\u0022,\r\n skills: [\r\n {\r\n skillType: \u0022INTERACTION\u0022,\r\n skillLevel: 1\r\n },\r\n {\r\n skillType: \u0022VERBAL\u0022,\r\n skillLevel: 2\r\n },\r\n {\r\n skillType: \u0022LISTENING\u0022,\r\n skillLevel: 3\r\n },\r\n {\r\n skillType: \u0022READING\u0022,\r\n skillLevel: 4\r\n },\r\n {\r\n skillType: \u0022WRITING\u0022,\r\n skillLevel: 5\r\n }\r\n ]\r\n},\r\n{\r\n id: \u0022language2Id\u0022,\r\n draftId: \u00223fa85f64-5717-4562-b3fc-2c963f66afa6\u0022,\r\n name: \u0022se\u0022,\r\n highlight: \u0022new highlight\u0022,\r\n skills: [\r\n {\r\n skillType: \u0022INTERACTION\u0022,\r\n skillLevel: 1\r\n },\r\n {\r\n skillType: \u0022VERBAL\u0022,\r\n skillLevel: 2\r\n },\r\n {\r\n skillType: \u0022LISTENING\u0022,\r\n skillLevel: 3\r\n },\r\n {\r\n skillType: \u0022READING\u0022,\r\n skillLevel: 4\r\n },\r\n {\r\n skillType: \u0022WRITING\u0022,\r\n skillLevel: 5\r\n }\r\n ]\r\n}],\r\n generalSections: {\r\n introduction: \u0022string\u0022,\r\n culturalCompetence: \u0022string\u0022,\r\n languageSkillsDescription: \u0022string\u0022\r\n }\r\n}\r\n\r\nfunction updateDraft(id, draft) {\r\n\treturn new Promise(draft);\r\n}\r\n\r\nfunction setCurrentDraft(draft) {\r\n console.log(draft);\r\n}","TestCases":[{"Name":"own","Code":" const createNewLanguage = async () =\u003E {\r\n const updatedDraft = {\r\n ...currentDraft,\r\n languages: currentDraft.languages.concat(createNewLanguageObject(language, currentDraft.id))\r\n }\r\n const updatedDraftWithId = await updateDraft(\r\n currentDraft.id,\r\n updatedDraft\r\n );\r\n setCurrentDraft(updatedDraftWithId);\r\n };","IsDeferred":false},{"Name":"other","Code":"const createNewLanguage = async () =\u003E {\r\n const createUpdatedDraft = _.flow(\r\n getUpdatedLanguagesArray(currentDraft.languages)(currentDraft.id),\r\n getUpdatedDraft(currentDraft)\r\n );\r\n const updatedDraftWithId = await updateDraft(\r\n currentDraft.id,\r\n createUpdatedDraft(language)\r\n );\r\n setCurrentDraft(updatedDraftWithId);\r\n };\r\n \r\n function getUpdatedLanguagesArray(languages) {\r\n return function forDraftWithId(draftId) {\r\n return function withNewLanguage(language) {\r\n const updatedLanguages = languages.slice();\r\n const newLanguage = createNewLanguageObject(language, draftId);\r\n updatedLanguages.push(newLanguage);\r\n return updatedLanguages;\r\n };\r\n };\r\n}\r\n\r\nfunction createNewLanguageObject(language, currentDraftId) {\r\n return {\r\n id: \u0022\u0022,\r\n draftId: currentDraftId,\r\n name: language.title,\r\n highlight: \u0022\u0022,\r\n samples: [],\r\n attachments: [],\r\n };\r\n}\r\n\r\nfunction getUpdatedDraft(currentDraft) {\r\n return function withLanguages(updatedLanguages) {\r\n const updatedDraft = _.cloneDeep(currentDraft);\r\n updatedDraft.languages = updatedLanguages;\r\n return updatedDraft;\r\n };\r\n}","IsDeferred":false}]}