in intellij-plugin/educational-core/src/com/jetbrains/edu/learning/update/elements/FrameworkTaskUpdateInfo.kt [31:74]
override suspend fun update(project: Project) {
val flManager = FrameworkLessonManager.getInstance(project)
val localLesson = localItem.parent as FrameworkLesson
val taskIsCurrent = localLesson.currentTaskIndex == localItem.index - 1
if (localItem.status != CheckStatus.Solved) {
remoteItem.status = CheckStatus.Unchecked
}
else {
remoteItem.status = CheckStatus.Solved
}
try {
updateTaskDirectory(project, localLesson)
}
catch (e: Exception) {
thisLogger().error("Failed to update task directory", e)
return
}
remoteItem.record = localItem.record
flManager.updateUserChanges(localItem, remoteItem.taskFiles.mapValues { it.value.contents })
localLesson.replaceItem(localItem, remoteItem)
remoteItem.init(localLesson, false)
if (taskIsCurrent) {
val taskDir = remoteItem.getDir(project.courseDir) ?: return
for ((fileName, fileHistory) in taskHistory.taskFileHistories) {
val fileContents = fileHistory.evaluateContents(localLesson.currentTaskIndex)
if (fileContents == null) {
removeFile(taskDir, fileName)
}
else {
val isEditable = remoteItem.taskFiles[fileName]?.isEditable != false
updateFile(project, taskDir, fileName, fileContents, isEditable)
}
}
}
YamlFormatSynchronizer.saveItemWithRemoteInfo(remoteItem)
}