import com.jetbrains.edu.learning.core.EduNames;
import com.jetbrains.edu.learning.core.EduUtils;
import com.jetbrains.edu.learning.courseFormat.AnswerPlaceholder;
+import com.jetbrains.edu.learning.courseFormat.AnswerPlaceholderSubtaskInfo;
import com.jetbrains.edu.learning.courseFormat.TaskFile;
import com.jetbrains.edu.learning.ui.CCCreateAnswerPlaceholderDialog;
import org.jetbrains.annotations.NotNull;
FileDocumentManager.getInstance().saveDocument(document);
final SelectionModel model = editor.getSelectionModel();
final int offset = model.hasSelection() ? model.getSelectionStart() : editor.getCaretModel().getOffset();
+ int stepIndex = state.getTaskFile().getTask().getActiveStepIndex();
final AnswerPlaceholder answerPlaceholder = new AnswerPlaceholder();
-
+ answerPlaceholder.getSubtaskInfos().put(stepIndex, new AnswerPlaceholderSubtaskInfo());
+ TaskFile taskFile = state.getTaskFile();
+ int index = taskFile.getAnswerPlaceholders().size();
+ answerPlaceholder.setIndex(index);
+ answerPlaceholder.setTaskFile(taskFile);
+ taskFile.sortAnswerPlaceholders();
answerPlaceholder.setOffset(offset);
answerPlaceholder.setUseLength(false);
String defaultPlaceholderText = "type here";
- answerPlaceholder.setPossibleAnswer(model.hasSelection() ? model.getSelectedText() : defaultPlaceholderText);
-
CCCreateAnswerPlaceholderDialog dlg = createDialog(project, answerPlaceholder);
if (!dlg.showAndGet()) {
return;
}
String answerPlaceholderText = dlg.getTaskText();
+ answerPlaceholder.setPossibleAnswer(model.hasSelection() ? model.getSelectedText() : defaultPlaceholderText);
answerPlaceholder.setTaskText(StringUtil.notNullize(answerPlaceholderText));
answerPlaceholder.setLength(StringUtil.notNullize(answerPlaceholderText).length());
answerPlaceholder.setHints(dlg.getHints());
DocumentUtil.writeInRunUndoTransparentAction(() -> document.insertString(offset, defaultPlaceholderText));
}
- TaskFile taskFile = state.getTaskFile();
- int index = taskFile.getAnswerPlaceholders().size();
- answerPlaceholder.setIndex(index);
- answerPlaceholder.setTaskFile(taskFile);
- taskFile.sortAnswerPlaceholders();
+
answerPlaceholder.setPossibleAnswer(model.hasSelection() ? model.getSelectedText() : defaultPlaceholderText);
AddAction action = new AddAction(answerPlaceholder, taskFile, editor);
EduUtils.runUndoableAction(project, "Add Answer Placeholder", action);
EduDocumentListener listener = new EduDocumentListener(taskFile, false);
document.addDocumentListener(listener);
taskFile.sortAnswerPlaceholders();
- for (int i = taskFile.getAnswerPlaceholders().size() - 1; i >= 0; i--) {
+ for (int i = taskFile.getActivePlaceholders().size() - 1; i >= 0; i--) {
final AnswerPlaceholder answerPlaceholder = taskFile.getAnswerPlaceholders().get(i);
replaceAnswerPlaceholder(project, document, answerPlaceholder);
}
}
- if (taskFile.getAnswerPlaceholders().isEmpty()) {
+ if (taskFile.getActivePlaceholders().isEmpty()) {
Messages.showInfoMessage("Preview is available for task files with answer placeholders only", "No Preview for This File");
return;
}
factory.releaseEditor(createdEditor);
}
});
- for (AnswerPlaceholder answerPlaceholder : taskFile.getAnswerPlaceholders()) {
+ for (AnswerPlaceholder answerPlaceholder : taskFile.getActivePlaceholders()) {
answerPlaceholder.setUseLength(true);
EduAnswerPlaceholderPainter.drawAnswerPlaceholder(createdEditor, answerPlaceholder, JBColor.BLUE);
}
import java.io.IOException;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
}
protected static void checkHighlighters(TaskFile taskFile, MarkupModel markupModel) {
- for (AnswerPlaceholder answerPlaceholder : taskFile.getAnswerPlaceholders()) {
+ for (AnswerPlaceholder answerPlaceholder : taskFile.getActivePlaceholders()) {
if (getHighlighter(markupModel, answerPlaceholder) == null) {
throw new AssertionError("No highlighter for placeholder: " + CCTestsUtil.getPlaceholderPresentation(answerPlaceholder));
}
public void checkByFile(TaskFile taskFile, String fileName, boolean useLength) {
Pair<Document, List<AnswerPlaceholder>> placeholders = getPlaceholders(fileName, useLength, true);
String message = "Placeholders don't match";
- if (taskFile.getAnswerPlaceholders().size() != placeholders.second.size()) {
+ if (taskFile.getActivePlaceholders().size() != placeholders.second.size()) {
throw new ComparisonFailure(message,
- CCTestsUtil.getPlaceholdersPresentation(taskFile.getAnswerPlaceholders()),
+ CCTestsUtil.getPlaceholdersPresentation(taskFile.getActivePlaceholders()),
CCTestsUtil.getPlaceholdersPresentation(placeholders.second));
}
for (AnswerPlaceholder answerPlaceholder : placeholders.getSecond()) {
AnswerPlaceholder placeholder = taskFile.getAnswerPlaceholder(answerPlaceholder.getOffset());
if (!CCTestsUtil.comparePlaceholders(placeholder, answerPlaceholder)) {
throw new ComparisonFailure(message,
- CCTestsUtil.getPlaceholdersPresentation(taskFile.getAnswerPlaceholders()),
+ CCTestsUtil.getPlaceholdersPresentation(taskFile.getActivePlaceholders()),
CCTestsUtil.getPlaceholdersPresentation(placeholders.second));
}
}
int pos = 0;
while (openingMatcher.find(pos)) {
AnswerPlaceholder answerPlaceholder = new AnswerPlaceholder();
+ AnswerPlaceholderSubtaskInfo subtaskInfo = new AnswerPlaceholderSubtaskInfo();
+ answerPlaceholder.getSubtaskInfos().put(0, subtaskInfo);
answerPlaceholder.setUseLength(useLength);
String taskText = openingMatcher.group(2);
if (taskText != null) {
}
String hint = openingMatcher.group(6);
if (hint != null) {
- answerPlaceholder.setHint(hint);
+ answerPlaceholder.setHints(Collections.singletonList(hint));
}
answerPlaceholder.setOffset(openingMatcher.start());
if (!closingMatcher.find(openingMatcher.end())) {
}
public boolean hasFailedAnswerPlaceholders(@NotNull final TaskFile taskFile) {
- return taskFile.getAnswerPlaceholders().size() > 0 && taskFile.hasFailedPlaceholders();
+ return taskFile.getActivePlaceholders().size() > 0 && taskFile.hasFailedPlaceholders();
}
@Nullable
final Project project = editor.getProject();
if (project == null) return;
final StudyTaskManager taskManager = StudyTaskManager.getInstance(project);
- for (AnswerPlaceholder answerPlaceholder : taskFile.getAnswerPlaceholders()) {
+ for (AnswerPlaceholder answerPlaceholder : taskFile.getActivePlaceholders()) {
final JBColor color = taskManager.getColor(answerPlaceholder);
EduAnswerPlaceholderPainter.drawAnswerPlaceholder(editor, answerPlaceholder, color);
}
if (studyEditor == null) return;
final Editor editor = studyEditor.getEditor();
IdeFocusManager.getInstance(project).requestFocus(editor.getContentComponent(), true);
- final List<AnswerPlaceholder> placeholders = studyEditor.getTaskFile().getAnswerPlaceholders();
+ final List<AnswerPlaceholder> placeholders = studyEditor.getTaskFile().getActivePlaceholders();
if (placeholders.isEmpty()) return;
final AnswerPlaceholder placeholder = placeholders.get(0);
int startOffset = placeholder.getOffset();
final Document document = studyState.getEditor().getDocument();
final TaskFile realTaskFile = taskFile;
CommandProcessor.getInstance().runUndoTransparentAction(() -> ApplicationManager.getApplication().runWriteAction(() -> {
- for (AnswerPlaceholder placeholder : realTaskFile.getAnswerPlaceholders()) {
+ for (AnswerPlaceholder placeholder : realTaskFile.getActivePlaceholders()) {
String answer = placeholder.getPossibleAnswer();
if (answer == null) {
continue;
return;
}
TaskFile taskFile = studyState.getTaskFile();
- if (taskFile.getAnswerPlaceholders().isEmpty()) {
+ if (taskFile.getActivePlaceholders().isEmpty()) {
presentation.setEnabledAndVisible(false);
}
}
@Override
protected AnswerPlaceholder getTargetPlaceholder(@NotNull final TaskFile taskFile, int offset) {
final AnswerPlaceholder selectedAnswerPlaceholder = taskFile.getAnswerPlaceholder(offset);
- final List<AnswerPlaceholder> placeholders = taskFile.getAnswerPlaceholders();
+ final List<AnswerPlaceholder> placeholders = taskFile.getActivePlaceholders();
if (selectedAnswerPlaceholder == null) {
for (AnswerPlaceholder placeholder : placeholders) {
if (placeholder.getOffset() > offset) {
@Override
protected AnswerPlaceholder getTargetPlaceholder(@NotNull final TaskFile taskFile, int offset) {
final AnswerPlaceholder selectedAnswerPlaceholder = taskFile.getAnswerPlaceholder(offset);
- final List<AnswerPlaceholder> placeholders = taskFile.getAnswerPlaceholders();
+ final List<AnswerPlaceholder> placeholders = taskFile.getActivePlaceholders();
if (selectedAnswerPlaceholder == null) {
for (int i = placeholders.size() - 1; i >= 0; i--) {
final AnswerPlaceholder placeholder = placeholders.get(i);
private static void resetAnswerPlaceholders(TaskFile selectedTaskFile, Project project) {
final StudyTaskManager taskManager = StudyTaskManager.getInstance(project);
- for (AnswerPlaceholder answerPlaceholder : selectedTaskFile.getAnswerPlaceholders()) {
+ for (AnswerPlaceholder answerPlaceholder : selectedTaskFile.getActivePlaceholders()) {
answerPlaceholder.reset();
taskManager.setStatus(answerPlaceholder, StudyStatus.Unchecked);
}
return;
}
final VirtualFile answerFile = getCopyWithAnswers(taskDir, virtualFile, taskFile, answerTaskFile);
- for (final AnswerPlaceholder answerPlaceholder : answerTaskFile.getAnswerPlaceholders()) {
+ for (final AnswerPlaceholder answerPlaceholder : answerTaskFile.getActivePlaceholders()) {
final Document document = FileDocumentManager.getInstance().getDocument(virtualFile);
if (document == null) {
continue;
TaskFile.copy(source, target);
EduDocumentListener listener = new EduDocumentListener(target);
document.addDocumentListener(listener);
- for (AnswerPlaceholder answerPlaceholder : target.getAnswerPlaceholders()) {
+ for (AnswerPlaceholder answerPlaceholder : target.getActivePlaceholders()) {
final int start = answerPlaceholder.getOffset();
final int end = start + answerPlaceholder.getRealLength();
final String text = answerPlaceholder.getPossibleAnswer();
windowDocument.addDocumentListener(listener);
int start = placeholder.getOffset();
int end = start + placeholder.getRealLength();
- final AnswerPlaceholder userAnswerPlaceholder = usersTaskFile.getAnswerPlaceholders().get(placeholder.getIndex());
+ final AnswerPlaceholder userAnswerPlaceholder = usersTaskFile.getActivePlaceholders().get(placeholder.getIndex());
int userStart = userAnswerPlaceholder.getOffset();
int userEnd = userStart + userAnswerPlaceholder.getRealLength();
String text = usersDocument.getText(new TextRange(userStart, userEnd));
public static void createGuardedBlocks(@NotNull final Editor editor, TaskFile taskFile) {
- for (AnswerPlaceholder answerPlaceholder : taskFile.getAnswerPlaceholders()) {
+ for (AnswerPlaceholder answerPlaceholder : taskFile.getActivePlaceholders()) {
createGuardedBlocks(editor, answerPlaceholder);
}
}
try {
fileWindows = taskDir.createChildData(taskFile, name);
printWriter = new PrintWriter(new FileOutputStream(fileWindows.getPath()));
- for (AnswerPlaceholder answerPlaceholder : taskFile.getAnswerPlaceholders()) {
+ for (AnswerPlaceholder answerPlaceholder : taskFile.getActivePlaceholders()) {
int length = answerPlaceholder.getRealLength();
int start = answerPlaceholder.getOffset();
final String windowDescription = document.getText(new TextRange(start, start + length));
EduDocumentListener listener = new EduDocumentListener(taskFile, false);
studentDocument.addDocumentListener(listener);
- for (AnswerPlaceholder placeholder : taskFile.getAnswerPlaceholders()) {
+ for (AnswerPlaceholder placeholder : taskFile.getActivePlaceholders()) {
replaceAnswerPlaceholder(project, studentDocument, placeholder);
}
studentDocument.removeDocumentListener(listener);
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
-import com.intellij.openapi.diagnostic.Logger;
+import com.intellij.util.containers.HashMap;
import com.intellij.util.xmlb.annotations.Transient;
import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-import java.util.ArrayList;
-import java.util.Collections;
import java.util.List;
+import java.util.Map;
/**
* Implementation of windows which user should type in
*/
public class AnswerPlaceholder {
- private static final Logger LOG = Logger.getInstance(AnswerPlaceholder.class);
-
- @SerializedName("hint")
- @Expose private String myHint = "";
-
- @SerializedName("additional_hints")
- @Expose private List<String> myAdditionalHints = new ArrayList<>();
-
- @SerializedName("possible_answer")
- @Expose private String possibleAnswer = "";
@SerializedName("offset")
@Expose private int myOffset = -1;
@Expose private int length = -1;
private int myIndex = -1;
- private String myTaskText;
private MyInitialState myInitialState;
private StudyStatus myStatus = StudyStatus.Unchecked;
private boolean mySelected = false;
private boolean myUseLength = true;
-
@Transient private TaskFile myTaskFile;
+ @Expose private Map<Integer, AnswerPlaceholderSubtaskInfo> mySubtaskInfos = new HashMap<>();
public AnswerPlaceholder() {
}
this.length = length;
}
- @NotNull
- public List<String> getAdditionalHints() {
- return myAdditionalHints;
- }
-
- public void setAdditionalHints(@Nullable final List<String> additionalHints) {
- myAdditionalHints = additionalHints;
- }
-
+ @Transient
public String getPossibleAnswer() {
- return possibleAnswer;
+ return getActiveSubtaskInfo().getPossibleAnswer();
}
+ @Transient
public void setPossibleAnswer(String possibleAnswer) {
- this.possibleAnswer = possibleAnswer;
+ getActiveSubtaskInfo().setPossibleAnswer(possibleAnswer);
}
public MyInitialState getInitialState() {
myInitialState = initialState;
}
+ @Transient
public String getTaskText() {
- return myTaskText;
+ return getActiveSubtaskInfo().getPlaceholderText();
}
+ @Transient
public void setTaskText(String taskText) {
- myTaskText = taskText;
+ getActiveSubtaskInfo().setPlaceholderText(taskText);
}
@Transient
}
public int getPossibleAnswerLength() {
- return possibleAnswer.length();
+ return getPossibleAnswer().length();
}
/**
public void reset() {
myOffset = myInitialState.getOffset();
length = myInitialState.getLength();
- if (!myUseLength) {
- possibleAnswer = myTaskText;
- }
}
public StudyStatus getStatus() {
}
public void init() {
- setInitialState(new MyInitialState(myOffset, myTaskText.length()));
+ setInitialState(new MyInitialState(myOffset, getTaskText().length()));
}
public boolean getUseLength() {
myOffset = offset;
}
- public String getHint() {
- return myHint;
- }
-
- public void setHint(String hint) {
- myHint = hint;
- }
-
@Transient
public List<String> getHints() {
- if (myHint.isEmpty() && myAdditionalHints.isEmpty()) return Collections.emptyList();
- final ArrayList<String> result = new ArrayList<>();
- result.add(myHint);
- result.addAll(myAdditionalHints);
- return result;
+ return getActiveSubtaskInfo().getHints();
}
@Transient
public void setHints(@NotNull final List<String> hints) {
- if (hints.isEmpty()) {
- myHint = "";
- myAdditionalHints.clear();
- }
- else {
- myHint = hints.get(0);
- myAdditionalHints = hints.subList(1, hints.size());
- }
- }
-
- public void setHintByIndex(int i, @NotNull final String text) {
- if (i == 0) {
- myHint = text;
- }
- else {
- myAdditionalHints.set(i - 1, text);
- }
+ getActiveSubtaskInfo().setHints(hints);
}
public void addHint(@NotNull final String text) {
- if (myHint.isEmpty() && myAdditionalHints.isEmpty()) {
- myHint = text;
- }
- else {
- myAdditionalHints.add(text);
- }
+ getActiveSubtaskInfo().addHint(text);
}
public void removeHint(int i) {
- if (i == 0) {
- myHint = "";
- }
- else {
- if (i - 1 <myAdditionalHints.size()) {
- myAdditionalHints.remove(i - 1);
- }
- else {
- LOG.warn("Trying to remove nonexistent hint. Hint to remove number: " + (i - 1) + "number of hints: " + getHints().size());
- }
- }
+ getActiveSubtaskInfo().removeHint(i);
+ }
+
+ public Map<Integer, AnswerPlaceholderSubtaskInfo> getSubtaskInfos() {
+ return mySubtaskInfos;
+ }
+
+ public void setSubtaskInfos(Map<Integer, AnswerPlaceholderSubtaskInfo> subtaskInfos) {
+ mySubtaskInfos = subtaskInfos;
}
public static class MyInitialState {
this.offset = offset;
}
}
+
+ public AnswerPlaceholderSubtaskInfo getActiveSubtaskInfo() {
+ if (myTaskFile == null || myTaskFile.getTask() == null) {
+ return mySubtaskInfos.get(0);
+ }
+ int activeStepIndex = myTaskFile.getTask().getActiveStepIndex();
+ return mySubtaskInfos.get(activeStepIndex);
+ }
}
--- /dev/null
+package com.jetbrains.edu.learning.courseFormat;
+
+import com.google.gson.annotations.Expose;
+import com.google.gson.annotations.SerializedName;
+import com.intellij.openapi.diagnostic.Logger;
+import com.intellij.util.xmlb.annotations.Transient;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+public class AnswerPlaceholderSubtaskInfo {
+ private static final Logger LOG = Logger.getInstance(AnswerPlaceholderSubtaskInfo.class);
+ @SerializedName("hint")
+ @Expose private String myHint = "";
+
+ @SerializedName("additional_hints")
+ @Expose private List<String> myAdditionalHints = new ArrayList<>();
+
+ @SerializedName("possible_answer")
+ @Expose private String possibleAnswer = "";
+
+ @Expose private String myPlaceholderText;
+ private boolean mySelected = false;
+ private StudyStatus myStatus = StudyStatus.Unchecked;
+ @Expose private boolean myHasFrame = true;
+
+ public StudyStatus getStatus() {
+ return myStatus;
+ }
+
+ public void setStatus(StudyStatus status) {
+ myStatus = status;
+ }
+
+ @Transient
+ public List<String> getHints() {
+ if (myHint.isEmpty() && myAdditionalHints.isEmpty()) return Collections.emptyList();
+ final ArrayList<String> result = new ArrayList<>();
+ result.add(myHint);
+ result.addAll(myAdditionalHints);
+ return result;
+ }
+
+ @Transient
+ public void setHints(@NotNull final List<String> hints) {
+ if (hints.isEmpty()) {
+ myHint = "";
+ myAdditionalHints.clear();
+ }
+ else {
+ myHint = hints.get(0);
+ myAdditionalHints = hints.subList(1, hints.size());
+ }
+ }
+
+ public void addHint(@NotNull final String text) {
+ if (myHint.isEmpty() && myAdditionalHints.isEmpty()) {
+ myHint = text;
+ }
+ else {
+ myAdditionalHints.add(text);
+ }
+ }
+
+ public void removeHint(int i) {
+ if (i == 0) {
+ myHint = "";
+ }
+ else {
+ if (i - 1 <myAdditionalHints.size()) {
+ myAdditionalHints.remove(i - 1);
+ }
+ else {
+ LOG.warn("Trying to remove nonexistent hint. Hint to remove number: " + (i - 1) + "number of hints: " + getHints().size());
+ }
+ }
+ }
+
+ @NotNull
+ public List<String> getAdditionalHints() {
+ return myAdditionalHints;
+ }
+
+ public void setAdditionalHints(@Nullable final List<String> additionalHints) {
+ myAdditionalHints = additionalHints;
+ }
+
+ public String getPossibleAnswer() {
+ return possibleAnswer;
+ }
+
+ public void setPossibleAnswer(String possibleAnswer) {
+ this.possibleAnswer = possibleAnswer;
+ }
+
+ public String getPlaceholderText() {
+ return myPlaceholderText;
+ }
+
+ public void setPlaceholderText(String placeholderText) {
+ myPlaceholderText = placeholderText;
+ }
+
+ public String getHint() {
+ return myHint;
+ }
+
+ public void setHint(String hint) {
+ myHint = hint;
+ }
+
+ public boolean getSelected() {
+ return mySelected;
+ }
+
+ public void setSelected(boolean selected) {
+ mySelected = selected;
+ }
+
+ public boolean isHasFrame() {
+ return myHasFrame;
+ }
+
+ public void setHasFrame(boolean hasFrame) {
+ myHasFrame = hasFrame;
+ }
+}
@Transient private Lesson myLesson;
@Expose @SerializedName("update_date") private Date myUpdateDate;
+ private int myActiveStepIndex = 0;
+
public Task() {}
public Task(@NotNull final String name) {
public void setStatus(StudyStatus status) {
myStatus = status;
for (TaskFile taskFile : taskFiles.values()) {
- for (AnswerPlaceholder placeholder : taskFile.getAnswerPlaceholders()) {
+ for (AnswerPlaceholder placeholder : taskFile.getActivePlaceholders()) {
placeholder.setStatus(status);
}
}
if (myUpdateDate == null) return false;
return !date.after(myUpdateDate);
}
+
+ public int getActiveStepIndex() {
+ return myActiveStepIndex;
+ }
+
+ public void setActiveStepIndex(int activeStepIndex) {
+ myActiveStepIndex = activeStepIndex;
+ }
}
return myAnswerPlaceholders;
}
+ public List<AnswerPlaceholder> getActivePlaceholders() {
+ List<AnswerPlaceholder> result = new ArrayList<>();
+ for (AnswerPlaceholder placeholder : myAnswerPlaceholders) {
+ if (placeholder.getActiveSubtaskInfo() != null) {
+ result.add(placeholder);
+ }
+ }
+ return result;
+ }
+
public void setAnswerPlaceholders(List<AnswerPlaceholder> answerPlaceholders) {
this.myAnswerPlaceholders = answerPlaceholders;
}
public static void copy(@NotNull final TaskFile source, @NotNull final TaskFile target) {
- List<AnswerPlaceholder> sourceAnswerPlaceholders = source.getAnswerPlaceholders();
+ List<AnswerPlaceholder> sourceAnswerPlaceholders = source.getActivePlaceholders();
List<AnswerPlaceholder> answerPlaceholdersCopy = new ArrayList<>(sourceAnswerPlaceholders.size());
for (AnswerPlaceholder answerPlaceholder : sourceAnswerPlaceholders) {
AnswerPlaceholder answerPlaceholderCopy = new AnswerPlaceholder();
final VirtualFile virtualFile = ((VirtualDirectoryImpl)taskDir).refreshAndFindChild(name);
if (virtualFile != null) {
FileEditorManager.getInstance(project).openFile(virtualFile, true);
- if (!taskFile.getAnswerPlaceholders().isEmpty()) {
+ if (!taskFile.getActivePlaceholders().isEmpty()) {
activeVirtualFile = virtualFile;
}
}
public static void navigateToFirstFailedAnswerPlaceholder(@NotNull final Editor editor, @NotNull final TaskFile taskFile) {
final Project project = editor.getProject();
if (project == null) return;
- for (AnswerPlaceholder answerPlaceholder : taskFile.getAnswerPlaceholders()) {
+ for (AnswerPlaceholder answerPlaceholder : taskFile.getActivePlaceholders()) {
if (answerPlaceholder.getStatus() != StudyStatus.Failed) {
continue;
}
public static void navigateToFirstAnswerPlaceholder(@NotNull final Editor editor, @NotNull final TaskFile taskFile) {
- if (!taskFile.getAnswerPlaceholders().isEmpty()) {
- AnswerPlaceholder firstAnswerPlaceholder = StudyUtils.getFirst(taskFile.getAnswerPlaceholders());
+ if (!taskFile.getActivePlaceholders().isEmpty()) {
+ AnswerPlaceholder firstAnswerPlaceholder = StudyUtils.getFirst(taskFile.getActivePlaceholders());
if (firstAnswerPlaceholder == null) return;
navigateToAnswerPlaceholder(editor, firstAnswerPlaceholder);
}
if (shouldBeActive != null) {
FileEditorManager.getInstance(project).openFile(vf, true);
}
- if (shouldBeActive == null && !taskFile.getAnswerPlaceholders().isEmpty()) {
+ if (shouldBeActive == null && !taskFile.getActivePlaceholders().isEmpty()) {
shouldBeActive = vf;
}
}
if (file != null) {
FileEditorManager.getInstance(myProject).openFile(file, true);
}
- if (!entry.getValue().getAnswerPlaceholders().isEmpty()) {
+ if (!entry.getValue().getActivePlaceholders().isEmpty()) {
child = file;
}
}
private String getFirstTaskFilePath() {
for (Map.Entry<String, TaskFile> entry : myTask.getTaskFiles().entrySet()) {
String path = getTaskFilePath(entry.getKey());
- if (!entry.getValue().getAnswerPlaceholders().isEmpty()) {
+ if (!entry.getValue().getActivePlaceholders().isEmpty()) {
return path;
}
VirtualFile virtualFile = LocalFileSystem.getInstance().findFileByPath(path);
for (Map.Entry<String, TaskFile> entry : myTask.getTaskFiles().entrySet()) {
final String name = entry.getKey();
final TaskFile taskFile = entry.getValue();
- if (taskFile.getAnswerPlaceholders().size() < 2) {
+ if (taskFile.getActivePlaceholders().size() < 2) {
continue;
}
final Course course = myTaskManger.getCourse();
TaskFile taskFile = entry.getValue();
VirtualFile virtualFile = taskDir.findChild(name);
if (virtualFile != null) {
- if (!taskFile.getAnswerPlaceholders().isEmpty()) {
+ if (!taskFile.getActivePlaceholders().isEmpty()) {
taskVirtualFile = virtualFile;
}
}