Search in sources :

Example 1 with Instruction

use of org.stepik.api.objects.instructions.Instruction in project intellij-plugins by StepicOrg.

the class FreeAnswerQuizHelper method isFrozen.

private boolean isFrozen() {
    if (!needReview()) {
        return true;
    }
    Step data = getStepNode().getData();
    if (data == null) {
        return true;
    }
    int instructionId = data.getInstruction();
    if (instructionId == 0) {
        return true;
    }
    StepikApiClient stepikClient = authAndGetStepikApiClient();
    if (!isAuthenticated()) {
        return true;
    }
    try {
        Instructions instructions = stepikClient.instructions().get().id(instructionId).execute();
        if (!instructions.isEmpty()) {
            Instruction instruction = instructions.getFirst();
            return instruction.isFrozen();
        }
    } catch (StepikClientException e) {
        logger.warn(e);
    }
    return true;
}
Also used : StepikAuthManager.authAndGetStepikApiClient(org.stepik.core.stepik.StepikAuthManager.authAndGetStepikApiClient) StepikApiClient(org.stepik.api.client.StepikApiClient) Instructions(org.stepik.api.objects.instructions.Instructions) Step(org.stepik.api.objects.steps.Step) Instruction(org.stepik.api.objects.instructions.Instruction) StepikClientException(org.stepik.api.exceptions.StepikClientException)

Aggregations

StepikApiClient (org.stepik.api.client.StepikApiClient)1 StepikClientException (org.stepik.api.exceptions.StepikClientException)1 Instruction (org.stepik.api.objects.instructions.Instruction)1 Instructions (org.stepik.api.objects.instructions.Instructions)1 Step (org.stepik.api.objects.steps.Step)1 StepikAuthManager.authAndGetStepikApiClient (org.stepik.core.stepik.StepikAuthManager.authAndGetStepikApiClient)1