mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Add ability to disable local testing from samples in adaptive courses
This commit is contained in:
@@ -46,6 +46,7 @@ public class StudyTaskManager implements PersistentStateComponent<Element>, Dumb
|
||||
public boolean myShouldUseJavaFx = StudyUtils.hasJavaFx();
|
||||
private StudyToolWindow.StudyToolWindowMode myToolWindowMode = StudyToolWindow.StudyToolWindowMode.TEXT;
|
||||
private boolean myTurnEditingMode = false;
|
||||
private boolean myEnableTestingFromSamples = true;
|
||||
|
||||
@Transient private final Project myProject;
|
||||
|
||||
@@ -202,4 +203,12 @@ public class StudyTaskManager implements PersistentStateComponent<Element>, Dumb
|
||||
public void setUser(@NotNull final StepicUser user) {
|
||||
myUser = user;
|
||||
}
|
||||
|
||||
public boolean isEnableTestingFromSamples() {
|
||||
return myEnableTestingFromSamples;
|
||||
}
|
||||
|
||||
public void setEnableTestingFromSamples(boolean enableTestingFromSamples) {
|
||||
myEnableTestingFromSamples = enableTestingFromSamples;
|
||||
}
|
||||
}
|
||||
|
||||
+6
-4
@@ -130,7 +130,12 @@ public class StudyCheckTask extends com.intellij.openapi.progress.Task.Backgroun
|
||||
private void checkForAdaptiveCourse(ProgressIndicator indicator) {
|
||||
final StudyTestsOutputParser.TestsOutput testOutput = getTestOutput(indicator);
|
||||
if (testOutput != null) {
|
||||
if (testOutput.isSuccess()) {
|
||||
// As tests in adaptive courses are created from
|
||||
// samples and stored in task, to disable it we should ignore local testing results
|
||||
if (StudyTaskManager.getInstance(myProject).isEnableTestingFromSamples() && !testOutput.isSuccess()) {
|
||||
onTaskFailed(testOutput.getMessage());
|
||||
}
|
||||
else {
|
||||
final Pair<Boolean, String> pair = EduAdaptiveStepicConnector.checkTask(myProject, myTask);
|
||||
if (pair != null && !(!pair.getFirst() && pair.getSecond().isEmpty())) {
|
||||
if (pair.getFirst()) {
|
||||
@@ -152,9 +157,6 @@ public class StudyCheckTask extends com.intellij.openapi.progress.Task.Backgroun
|
||||
myProject));
|
||||
}
|
||||
}
|
||||
else {
|
||||
onTaskFailed(testOutput.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+35
-4
@@ -1,9 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.jetbrains.edu.learning.stepic.StepicStudyOptions">
|
||||
<grid id="27dc6" binding="myPane" layout-manager="GridLayoutManager" row-count="2" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<grid id="27dc6" binding="myPane" layout-manager="GridLayoutManager" row-count="3" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<xy x="20" y="20" width="646" height="400"/>
|
||||
<xy x="20" y="20" width="706" height="400"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<clientProperties>
|
||||
@@ -16,13 +16,13 @@
|
||||
<children>
|
||||
<vspacer id="6ace">
|
||||
<constraints>
|
||||
<grid row="1" column="0" row-span="1" col-span="2" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
|
||||
<grid row="2" column="1" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
</vspacer>
|
||||
<grid id="e4354" layout-manager="GridLayoutManager" row-count="2" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="7" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
<grid row="0" column="0" row-span="1" col-span="2" vsize-policy="3" hsize-policy="7" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
@@ -64,6 +64,37 @@
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
<grid id="a8a02" layout-manager="GridLayoutManager" row-count="1" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="3" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<grid row="1" column="0" row-span="1" col-span="2" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<component id="78d63" class="com.intellij.ui.components.JBLabel">
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="Testing from samples in adaptive courses"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="4b6cb" class="com.intellij.ui.components.JBCheckBox" binding="myEnableTestingFromSamples">
|
||||
<constraints>
|
||||
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<selected value="true"/>
|
||||
</properties>
|
||||
</component>
|
||||
<hspacer id="976b3">
|
||||
<constraints>
|
||||
<grid row="0" column="2" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
</hspacer>
|
||||
</children>
|
||||
</grid>
|
||||
</children>
|
||||
</grid>
|
||||
</form>
|
||||
|
||||
+17
-2
@@ -19,6 +19,7 @@ import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.ui.DocumentAdapter;
|
||||
import com.intellij.ui.components.JBCheckBox;
|
||||
import com.jetbrains.edu.learning.StudyTaskManager;
|
||||
import com.jetbrains.edu.learning.StudyUtils;
|
||||
import com.jetbrains.edu.learning.settings.StudyOptionsProvider;
|
||||
@@ -26,6 +27,8 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.ChangeEvent;
|
||||
import javax.swing.event.ChangeListener;
|
||||
import javax.swing.event.DocumentEvent;
|
||||
import javax.swing.event.DocumentListener;
|
||||
import javax.swing.text.Document;
|
||||
@@ -39,6 +42,7 @@ public class StepicStudyOptions implements StudyOptionsProvider {
|
||||
private JTextField myLoginTextField;
|
||||
private JPasswordField myPasswordField;
|
||||
private JPanel myPane;
|
||||
private JBCheckBox myEnableTestingFromSamples;
|
||||
|
||||
private boolean myCredentialsModified;
|
||||
|
||||
@@ -72,6 +76,13 @@ public class StepicStudyOptions implements StudyOptionsProvider {
|
||||
public void focusLost(FocusEvent e) {
|
||||
}
|
||||
});
|
||||
|
||||
myEnableTestingFromSamples.addChangeListener(new ChangeListener() {
|
||||
@Override
|
||||
public void stateChanged(ChangeEvent e) {
|
||||
myCredentialsModified = true;
|
||||
}
|
||||
});
|
||||
reset();
|
||||
}
|
||||
|
||||
@@ -107,11 +118,13 @@ public class StepicStudyOptions implements StudyOptionsProvider {
|
||||
public void reset() {
|
||||
Project project = StudyUtils.getStudyProject();
|
||||
if (project != null) {
|
||||
final StepicUser user = StudyTaskManager.getInstance(project).getUser();
|
||||
StudyTaskManager taskManager = StudyTaskManager.getInstance(project);
|
||||
final StepicUser user = taskManager.getUser();
|
||||
if (user != null) {
|
||||
setLogin(user.getEmail());
|
||||
setPassword(DEFAULT_PASSWORD_TEXT);
|
||||
}
|
||||
myEnableTestingFromSamples.setSelected(taskManager.isEnableTestingFromSamples());
|
||||
resetCredentialsModification();
|
||||
}
|
||||
else {
|
||||
@@ -129,7 +142,9 @@ public class StepicStudyOptions implements StudyOptionsProvider {
|
||||
if (myCredentialsModified) {
|
||||
final Project project = StudyUtils.getStudyProject();
|
||||
if (project != null) {
|
||||
final StepicUser user = StudyTaskManager.getInstance(project).getUser();
|
||||
StudyTaskManager taskManager = StudyTaskManager.getInstance(project);
|
||||
taskManager.setEnableTestingFromSamples(myEnableTestingFromSamples.isSelected());
|
||||
final StepicUser user = taskManager.getUser();
|
||||
user.setEmail(getLogin());
|
||||
user.setPassword(getPassword());
|
||||
if (!StringUtil.isEmptyOrSpaces(getLogin()) && !StringUtil.isEmptyOrSpaces(getPassword())) {
|
||||
|
||||
Reference in New Issue
Block a user