mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
moved course initialization back
This commit is contained in:
+1
-1
@@ -173,7 +173,7 @@ public class CCProjectService implements PersistentStateComponent<CCProjectServi
|
||||
@Override
|
||||
public void loadState(CCProjectService state) {
|
||||
XmlSerializerUtil.copyBean(state, this);
|
||||
EduUtils.initCourse(myCourse, true);
|
||||
myCourse.initCourse(true);
|
||||
}
|
||||
|
||||
public static CCProjectService getInstance(@NotNull Project project) {
|
||||
|
||||
+1
-1
@@ -302,7 +302,7 @@ public class StudyProjectComponent implements ProjectComponent {
|
||||
if (StudyUtils.indexIsValid(taskIndex, tasks)) {
|
||||
final Task task = tasks.get(taskIndex);
|
||||
final TaskFile taskFile = new TaskFile();
|
||||
EduUtils.initTaskFile(taskFile, task, false);
|
||||
taskFile.initTaskFile(task, false);
|
||||
taskFile.setUserCreated(true);
|
||||
task.getTaskFiles().put(createdFile.getName(), taskFile);
|
||||
}
|
||||
|
||||
+1
-2
@@ -12,7 +12,6 @@ import com.intellij.openapi.project.Project;
|
||||
import com.intellij.ui.JBColor;
|
||||
import com.intellij.util.containers.hash.HashMap;
|
||||
import com.intellij.util.xmlb.XmlSerializerUtil;
|
||||
import com.jetbrains.edu.EduUtils;
|
||||
import com.jetbrains.edu.courseFormat.*;
|
||||
import com.jetbrains.edu.learning.courseFormat.StudyStatus;
|
||||
import com.jetbrains.edu.learning.courseFormat.UserTest;
|
||||
@@ -172,7 +171,7 @@ public class StudyTaskManager implements PersistentStateComponent<StudyTaskManag
|
||||
public void loadState(StudyTaskManager state) {
|
||||
XmlSerializerUtil.copyBean(state, this);
|
||||
if (myCourse != null) {
|
||||
EduUtils.initCourse(myCourse, true);
|
||||
myCourse.initCourse(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-2
@@ -20,7 +20,6 @@ import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.PsiManager;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.jetbrains.edu.EduNames;
|
||||
import com.jetbrains.edu.EduUtils;
|
||||
import com.jetbrains.edu.courseFormat.Course;
|
||||
import com.jetbrains.edu.courseFormat.Lesson;
|
||||
import com.jetbrains.edu.courseFormat.Task;
|
||||
@@ -65,7 +64,7 @@ public class StudyProjectGenerator {
|
||||
ApplicationManager.getApplication().runWriteAction(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
EduUtils.initCourse(course, false);
|
||||
course.initCourse(false);
|
||||
final File courseDirectory = new File(myCoursesDir, course.getName());
|
||||
StudyGenerator.createCourse(course, baseDir, courseDirectory, project);
|
||||
course.setCourseDirectory(new File(myCoursesDir, mySelectedCourseInfo.getName()).getAbsolutePath());
|
||||
|
||||
@@ -18,7 +18,8 @@ import com.intellij.openapi.roots.ModuleRootManager;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.vfs.VirtualFileManager;
|
||||
import com.jetbrains.edu.courseFormat.*;
|
||||
import com.jetbrains.edu.courseFormat.AnswerPlaceholder;
|
||||
import com.jetbrains.edu.courseFormat.TaskFile;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -26,8 +27,6 @@ import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class EduUtils {
|
||||
@@ -222,55 +221,4 @@ public class EduUtils {
|
||||
}
|
||||
}, "Replace Answer Placeholders", "Replace Answer Placeholders");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Initializes state of course
|
||||
*/
|
||||
public static void initCourse(@NotNull final Course course, boolean isRestarted) {
|
||||
for (Lesson lesson : course.getLessons()) {
|
||||
initLesson(lesson, course, isRestarted);
|
||||
}
|
||||
}
|
||||
|
||||
public static void initLesson(@NotNull final Lesson lesson, final Course course, boolean isRestarted) {
|
||||
lesson.setCourse(course);
|
||||
final List<Task> taskList = lesson.getTaskList();
|
||||
for (Task task : taskList) {
|
||||
initTask(task, lesson, isRestarted);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes state of task file
|
||||
*
|
||||
* @param lesson lesson which task belongs to
|
||||
*/
|
||||
public static void initTask(@NotNull final Task task, final Lesson lesson, boolean isRestarted) {
|
||||
task.setLesson(lesson);
|
||||
for (TaskFile taskFile : task.getTaskFiles().values()) {
|
||||
initTaskFile(taskFile, task, isRestarted);
|
||||
}
|
||||
}
|
||||
|
||||
public static void initTaskFile(@NotNull final TaskFile taskFile, final Task task, boolean isRestarted) {
|
||||
taskFile.setTask(task);
|
||||
final List<AnswerPlaceholder> answerPlaceholders = taskFile.getAnswerPlaceholders();
|
||||
for (AnswerPlaceholder answerPlaceholder : answerPlaceholders) {
|
||||
initAnswerPlaceholder(answerPlaceholder, taskFile, isRestarted);
|
||||
}
|
||||
Collections.sort(answerPlaceholders, new AnswerPlaceholderComparator());
|
||||
for (int i = 0; i < answerPlaceholders.size(); i++) {
|
||||
answerPlaceholders.get(i).setIndex(i);
|
||||
}
|
||||
}
|
||||
|
||||
public static void initAnswerPlaceholder(@NotNull final AnswerPlaceholder placeholder, final TaskFile file, boolean isRestarted) {
|
||||
if (!isRestarted) {
|
||||
placeholder.setInitialState(new AnswerPlaceholder.MyInitialState(placeholder.getLine(), placeholder.getLength(),
|
||||
placeholder.getStart()));
|
||||
}
|
||||
placeholder.setTaskFile(file);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -26,6 +26,13 @@ public class AnswerPlaceholder {
|
||||
|
||||
@Transient private TaskFile myTaskFile;
|
||||
|
||||
public void initAnswerPlaceholder(final TaskFile file, boolean isRestarted) {
|
||||
if (!isRestarted) {
|
||||
setInitialState(new MyInitialState(getLine(), getLength(), getStart()));
|
||||
}
|
||||
setTaskFile(file);
|
||||
}
|
||||
|
||||
public int getIndex() {
|
||||
return myIndex;
|
||||
}
|
||||
|
||||
@@ -23,6 +23,15 @@ public class Course {
|
||||
@Expose @SerializedName("language")
|
||||
private String myLanguage;
|
||||
|
||||
/**
|
||||
* Initializes state of course
|
||||
*/
|
||||
public void initCourse(boolean isRestarted) {
|
||||
for (Lesson lesson : getLessons()) {
|
||||
lesson.initLesson(this, isRestarted);
|
||||
}
|
||||
}
|
||||
|
||||
public List<Lesson> getLessons() {
|
||||
return lessons;
|
||||
}
|
||||
|
||||
@@ -30,6 +30,13 @@ public class Lesson {
|
||||
private Course myCourse = null;
|
||||
private int myIndex = -1;
|
||||
|
||||
public void initLesson(final Course course, boolean isRestarted) {
|
||||
setCourse(course);
|
||||
for (Task task : getTaskList()) {
|
||||
task.initTask(this, isRestarted);
|
||||
}
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@@ -36,6 +36,18 @@ public class Task {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes state of task file
|
||||
*
|
||||
* @param lesson lesson which task belongs to
|
||||
*/
|
||||
public void initTask(final Lesson lesson, boolean isRestarted) {
|
||||
setLesson(lesson);
|
||||
for (TaskFile taskFile : getTaskFiles().values()) {
|
||||
taskFile.initTaskFile(this, isRestarted);
|
||||
}
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@@ -34,6 +34,18 @@ public class TaskFile {
|
||||
private boolean myTrackChanges = true;
|
||||
private boolean myHighlightErrors = false;
|
||||
|
||||
public void initTaskFile(final Task task, boolean isRestarted) {
|
||||
setTask(task);
|
||||
final List<AnswerPlaceholder> answerPlaceholders = getAnswerPlaceholders();
|
||||
for (AnswerPlaceholder answerPlaceholder : answerPlaceholders) {
|
||||
answerPlaceholder.initAnswerPlaceholder(this, isRestarted);
|
||||
}
|
||||
Collections.sort(answerPlaceholders, new AnswerPlaceholderComparator());
|
||||
for (int i = 0; i < answerPlaceholders.size(); i++) {
|
||||
answerPlaceholders.get(i).setIndex(i);
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Transient
|
||||
public AnswerPlaceholder getSelectedAnswerPlaceholder() {
|
||||
|
||||
Reference in New Issue
Block a user