copy file in archive if it doesn't contain answer placeholders dbe/142.4250 webstorm/142.4251
authorliana.bakradze <liana.bakradze@jetbrains.com>
Tue, 25 Aug 2015 07:27:44 +0000 (10:27 +0300)
committerliana.bakradze <liana.bakradze@jetbrains.com>
Tue, 25 Aug 2015 07:30:00 +0000 (10:30 +0300)
python/educational/src/com/jetbrains/edu/EduUtils.java

index cd4a0f8f3a10fabccd888e8efb64506ba1606dd4..353226deb71413ea93db72932f6408102521e63e 100644 (file)
@@ -10,6 +10,7 @@ import com.intellij.openapi.editor.Document;
 import com.intellij.openapi.fileEditor.FileDocumentManager;
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.util.TextRange;
+import com.intellij.openapi.util.io.FileUtilRt;
 import com.intellij.openapi.vfs.VirtualFile;
 import com.intellij.openapi.vfs.VirtualFileManager;
 import com.intellij.psi.PsiDirectory;
@@ -132,6 +133,21 @@ public class EduUtils {
         LOG.error(e);
       }
     }
+
+    if (taskFile.getAnswerPlaceholders().isEmpty()) {
+      String extension = FileUtilRt.getExtension(taskFileName);
+      String nameWithoutExtension = FileUtilRt.getNameWithoutExtension(taskFileName);
+      VirtualFile answerFile = answerFileDir.findChild(nameWithoutExtension + ".answer." + extension);
+      if (answerFile != null) {
+        try {
+          answerFile.copy(answerFileDir, userFileDir, taskFileName);
+        }
+        catch (IOException e) {
+          LOG.error(e);
+        }
+      }
+      return;
+    }
     try {
       userFileDir.createChildData(project, taskFileName);
     }