mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
fixed push course to stepic for multiple answer placeholders in one line
This commit is contained in:
+3
-1
@@ -86,7 +86,9 @@ public class CCCreateCourseArchive extends DumbAwareAction {
|
||||
ApplicationManager.getApplication().runWriteAction(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
EduUtils.createStudentFileFromAnswer(project, taskDir, taskDir, entry);
|
||||
TaskFile taskFile = new TaskFile();
|
||||
TaskFile.copy(entry.getValue(), taskFile);
|
||||
EduUtils.createStudentFileFromAnswer(project, taskDir, taskDir, entry.getKey(), taskFile);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
+3
-5
@@ -44,7 +44,6 @@ import com.jetbrains.edu.coursecreator.CCUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.AbstractMap;
|
||||
import java.util.Map;
|
||||
|
||||
public abstract class CCRunTestsAction extends AnAction {
|
||||
@@ -246,10 +245,9 @@ public abstract class CCRunTestsAction extends AnAction {
|
||||
if (EduUtils.indexIsValid(index, lesson.getTaskList())) {
|
||||
Task task = lesson.getTaskList().get(index);
|
||||
for (Map.Entry<String, TaskFile> entry : task.getTaskFiles().entrySet()) {
|
||||
TaskFile taskFileCopy = new TaskFile();
|
||||
TaskFile.copy(entry.getValue(), taskFileCopy);
|
||||
EduUtils.createStudentFileFromAnswer(project, taskResourceDir, taskDir,
|
||||
new AbstractMap.SimpleEntry<String, TaskFile>(entry.getKey(), taskFileCopy));
|
||||
TaskFile taskFile = new TaskFile();
|
||||
TaskFile.copy(entry.getValue(), taskFile);
|
||||
EduUtils.createStudentFileFromAnswer(project, taskResourceDir, taskDir, entry.getKey(), taskFile);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-3
@@ -48,7 +48,6 @@ import javax.swing.*;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
import java.awt.*;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.AbstractMap;
|
||||
import java.util.Calendar;
|
||||
|
||||
public class CCShowPreview extends DumbAwareAction {
|
||||
@@ -106,8 +105,7 @@ public class CCShowPreview extends DumbAwareAction {
|
||||
ApplicationManager.getApplication().runWriteAction(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
EduUtils.createStudentFileFromAnswer(project, taskDir.getVirtualFile(), taskDir.getVirtualFile(),
|
||||
new AbstractMap.SimpleEntry<String, TaskFile>(taskFileName, taskFileCopy));
|
||||
EduUtils.createStudentFileFromAnswer(project, taskDir.getVirtualFile(), taskDir.getVirtualFile(), taskFileName, taskFileCopy);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -122,10 +122,8 @@ public class EduUtils {
|
||||
public static void createStudentFileFromAnswer(@NotNull final Project project,
|
||||
@NotNull final VirtualFile userFileDir,
|
||||
@NotNull final VirtualFile answerFileDir,
|
||||
@NotNull final Map.Entry<String, TaskFile> taskFileEntry) {
|
||||
final String name = taskFileEntry.getKey();
|
||||
final TaskFile taskFile = taskFileEntry.getValue();
|
||||
VirtualFile file = userFileDir.findChild(name);
|
||||
@NotNull final String taskFileName, @NotNull final TaskFile taskFile) {
|
||||
VirtualFile file = userFileDir.findChild(taskFileName);
|
||||
if (file != null) {
|
||||
try {
|
||||
file.delete(project);
|
||||
@@ -135,13 +133,13 @@ public class EduUtils {
|
||||
}
|
||||
}
|
||||
try {
|
||||
userFileDir.createChildData(project, name);
|
||||
userFileDir.createChildData(project, taskFileName);
|
||||
}
|
||||
catch (IOException e) {
|
||||
LOG.error(e);
|
||||
}
|
||||
|
||||
file = userFileDir.findChild(name);
|
||||
file = userFileDir.findChild(taskFileName);
|
||||
assert file != null;
|
||||
String answerFileName = file.getNameWithoutExtension() + ".answer." + file.getExtension();
|
||||
VirtualFile answerFile = answerFileDir.findChild(answerFileName);
|
||||
@@ -162,6 +160,7 @@ public class EduUtils {
|
||||
@Override
|
||||
public void run() {
|
||||
document.replaceString(0, document.getTextLength(), answerDocument.getCharsSequence());
|
||||
FileDocumentManager.getInstance().saveDocument(document);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.openapi.fileEditor.FileDocumentManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.DialogWrapper;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.VfsUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
@@ -272,14 +273,15 @@ public class EduStepicConnector {
|
||||
}
|
||||
|
||||
|
||||
public static void showLoginDialog() {
|
||||
public static boolean showLoginDialog() {
|
||||
final LoginDialog dialog = new LoginDialog();
|
||||
ApplicationManager.getApplication().invokeAndWait(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
final LoginDialog dialog = new LoginDialog();
|
||||
dialog.show();
|
||||
}
|
||||
}, ModalityState.defaultModalityState());
|
||||
return dialog.getExitCode() == DialogWrapper.OK_EXIT_CODE;
|
||||
}
|
||||
|
||||
public static void postAttempt(@NotNull final Task task, boolean passed, @Nullable String login, @Nullable String password) {
|
||||
@@ -342,7 +344,10 @@ public class EduStepicConnector {
|
||||
if (ourClient == null) {
|
||||
final String login = StudySettings.getInstance().getLogin();
|
||||
if (StringUtil.isEmptyOrSpaces(login)) {
|
||||
showLoginDialog();
|
||||
final boolean success = showLoginDialog();
|
||||
if (!success) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
else {
|
||||
final boolean success = login(login, StudySettings.getInstance().getPassword());
|
||||
@@ -553,15 +558,16 @@ public class EduStepicConnector {
|
||||
source.files = new ArrayList<TaskFile>();
|
||||
source.title = task.getName();
|
||||
for (final Map.Entry<String, TaskFile> entry : task.getTaskFiles().entrySet()) {
|
||||
final TaskFile taskFile = new TaskFile();
|
||||
TaskFile.copy(entry.getValue(), taskFile);
|
||||
ApplicationManager.getApplication().runWriteAction(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
final VirtualFile taskDir = task.getTaskDir(project);
|
||||
assert taskDir != null;
|
||||
EduUtils.createStudentFileFromAnswer(project, taskDir, taskDir, entry);
|
||||
EduUtils.createStudentFileFromAnswer(project, taskDir, taskDir, entry.getKey(), taskFile);
|
||||
}
|
||||
});
|
||||
final TaskFile taskFile = entry.getValue();
|
||||
taskFile.name = entry.getKey();
|
||||
final Document document = task.getDocument(project, taskFile.name);
|
||||
if (document != null) {
|
||||
|
||||
Reference in New Issue
Block a user