use of org.stepik.core.courseFormat.StepType in project intellij-plugins by StepicOrg.
the class Metrics method stepAction.
private static void stepAction(@NotNull String actionName, @NotNull Project project, @NotNull StepNode stepNode, @NotNull MetricsStatus status) {
Metric metric = new Metric();
metric.addTags("action", actionName);
metric.addData("step_id", stepNode.getId());
metric.addTags("step_programming_language", stepNode.getCurrentLang().getName());
StepType stepType = stepNode.getType();
metric.addTags("step_type", stepType.getName());
postMetrics(project, metric, status);
}
use of org.stepik.core.courseFormat.StepType in project intellij-plugins by StepicOrg.
the class StudyToolWindow method setText.
private void setText(@Nullable StepNode stepNode) {
if (stepNode == null) {
setEmptyText();
rightPanel.setVisible(false);
return;
}
browserWindow.showLoadAnimation();
StepType stepType = stepNode.getType();
if (stepType != VIDEO && stepType != CODE) {
SwingUtilities.invokeLater(() -> rightPanel.setVisible(false));
}
boolean isTheory = stepType == VIDEO || stepType == TEXT;
postView(stepNode, isTheory);
StepHelper stepHelper = null;
switch(stepType) {
case UNKNOWN:
stepHelper = new StepHelper(project, stepNode);
break;
case CODE:
stepHelper = new CodeQuizHelper(project, stepNode);
updateLanguageBox(stepNode);
break;
case TEXT:
stepHelper = new TextTheoryHelper(project, stepNode);
break;
case VIDEO:
stepHelper = new VideoTheoryHelper(project, stepNode);
break;
case CHOICE:
stepHelper = new ChoiceQuizHelper(project, stepNode);
break;
case STRING:
stepHelper = new StringQuizHelper(project, stepNode);
break;
case SORTING:
stepHelper = new SortingQuizHelper(project, stepNode);
break;
case MATCHING:
stepHelper = new MatchingQuizHelper(project, stepNode);
break;
case NUMBER:
stepHelper = new NumberQuizHelper(project, stepNode);
break;
case DATASET:
stepHelper = new DatasetQuizHelper(project, stepNode);
break;
case TABLE:
stepHelper = new TableQuizHelper(project, stepNode);
break;
case FILL_BLANKS:
stepHelper = new QuizHelper(project, stepNode);
break;
case MATH:
stepHelper = new QuizHelper(project, stepNode);
break;
case FREE_ANSWER:
stepHelper = new FreeAnswerQuizHelper(project, stepNode);
break;
}
HashMap<String, Object> params = new HashMap<>();
params.put("stepNode", stepHelper);
params.put("darcula", LafManager.getInstance().getCurrentLookAndFeel() instanceof DarculaLookAndFeelInfo);
browserWindow.loadContent("quiz/" + stepHelper.getType(), params);
}
use of org.stepik.core.courseFormat.StepType in project intellij-plugins by StepicOrg.
the class FormListener method handle.
static void handle(@NotNull Project project, @NotNull StudyBrowserWindow browser, @NotNull HTMLFormElement form) {
StudyNode root = StepikProjectManager.getProjectRoot(project);
if (root == null) {
return;
}
StudyNode node = StudyUtils.getStudyNode(root, form.getAction());
if (!(node instanceof StepNode)) {
return;
}
StepNode stepNode = (StepNode) node;
Elements elements = new Elements(form.getElements());
switch(elements.getAction()) {
case "get_first_attempt":
case "get_attempt":
if (!elements.isLocked()) {
getAttempt(project, stepNode);
}
break;
case "submit":
String typeStr = elements.getType();
StepType type = StepType.of(typeStr);
boolean isFromFile = elements.isFromFile();
String data = isFromFile ? getDataFromFile(stepNode, project) : null;
long attemptId = elements.getAttemptId();
sendStep(project, stepNode, elements, type, attemptId, data);
break;
case "save_reply":
typeStr = elements.getType();
type = StepType.of(typeStr);
getReply(stepNode, type, elements, null);
break;
case "login":
String email = elements.getInputValue("email");
String password = elements.getInputValue("password");
browser.showLoadAnimation();
StepikAuthManager.authentication(email, password).whenComplete((state, throwable) -> {
if (state != StepikAuthState.AUTH) {
browser.callFunction("setErrorMessage", "Wrong email or password");
}
browser.hideLoadAnimation();
});
break;
default:
browser.hideLoadAnimation();
}
}
use of org.stepik.core.courseFormat.StepType in project intellij-plugins by StepicOrg.
the class FormListener method sendStep.
private static void sendStep(@NotNull Project project, @NotNull StepNode stepNode, @NotNull Elements elements, @NotNull StepType type, long attemptId, @Nullable String data) {
StepikApiClient stepikApiClient = authAndGetStepikApiClient(true);
StepikSubmissionsPostQuery query = stepikApiClient.submissions().post().attempt(attemptId);
Reply reply = getReply(stepNode, type, elements, data);
if (reply == null) {
return;
}
query.reply(reply).executeAsync().whenComplete(((submissions, e) -> {
if (submissions == null) {
logger.warn("Failed send step from browser", e);
StepikProjectManager.updateSelection(project);
return;
}
if (submissions.isEmpty()) {
logger.warn("Failed send step from browser", e);
return;
}
Submission submission = submissions.getFirst();
SendAction.checkStepStatus(project, stepikApiClient, stepNode, submission.getId(), new EmptyProgressIndicator());
}));
}
Aggregations