Add `--create-assignment-evaulation` cli parameter
This commit is contained in:
parent
2430c02584
commit
428ac294e0
|
|
@ -1,6 +1,5 @@
|
||||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
import { devtoolsExchange } from "@urql/devtools";
|
|
||||||
import { cacheExchange } from "@urql/exchange-graphcache";
|
import { cacheExchange } from "@urql/exchange-graphcache";
|
||||||
import { Client, fetchExchange } from "@urql/vue";
|
import { Client, fetchExchange } from "@urql/vue";
|
||||||
import schema from "../gql/minifiedSchema.json";
|
import schema from "../gql/minifiedSchema.json";
|
||||||
|
|
@ -12,7 +11,6 @@ import {
|
||||||
export const graphqlClient = new Client({
|
export const graphqlClient = new Client({
|
||||||
url: import.meta.env.VITE_GRAPHQL_URL || "/server/graphql/",
|
url: import.meta.env.VITE_GRAPHQL_URL || "/server/graphql/",
|
||||||
exchanges: [
|
exchanges: [
|
||||||
devtoolsExchange,
|
|
||||||
cacheExchange({
|
cacheExchange({
|
||||||
schema: schema,
|
schema: schema,
|
||||||
keys: {
|
keys: {
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ import { login } from "../helpers";
|
||||||
|
|
||||||
describe("assignmentTrainer.cy.js", () => {
|
describe("assignmentTrainer.cy.js", () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
cy.manageCommand("cypress_reset --create-completion");
|
cy.manageCommand("cypress_reset --create-assignment-completion");
|
||||||
login("test-trainer1@example.com", "test");
|
login("test-trainer1@example.com", "test");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,10 +4,12 @@ from vbv_lernwelt.assignment.models import Assignment, AssignmentCompletion
|
||||||
from vbv_lernwelt.core.constants import (
|
from vbv_lernwelt.core.constants import (
|
||||||
TEST_COURSE_SESSION_BERN_ID,
|
TEST_COURSE_SESSION_BERN_ID,
|
||||||
TEST_STUDENT1_USER_ID,
|
TEST_STUDENT1_USER_ID,
|
||||||
|
TEST_TRAINER1_USER_ID,
|
||||||
)
|
)
|
||||||
from vbv_lernwelt.core.models import User
|
from vbv_lernwelt.core.models import User
|
||||||
from vbv_lernwelt.course.creators.test_course import (
|
from vbv_lernwelt.course.creators.test_course import (
|
||||||
create_test_assignment_submitted_data,
|
create_test_assignment_submitted_data,
|
||||||
|
create_test_assignment_evaulation_data,
|
||||||
)
|
)
|
||||||
from vbv_lernwelt.course.models import CourseCompletion, CourseSession
|
from vbv_lernwelt.course.models import CourseCompletion, CourseSession
|
||||||
from vbv_lernwelt.notify.models import Notification
|
from vbv_lernwelt.notify.models import Notification
|
||||||
|
|
@ -15,11 +17,16 @@ from vbv_lernwelt.notify.models import Notification
|
||||||
|
|
||||||
@click.command()
|
@click.command()
|
||||||
@click.option(
|
@click.option(
|
||||||
"--create-completion/--no-create-completion",
|
"--create-assignment-completion/--no-create-assignment-completion",
|
||||||
default=False,
|
default=False,
|
||||||
help="will create completion data for some users",
|
help="will create assignment completion data for test-student1@example.com",
|
||||||
)
|
)
|
||||||
def command(create_completion):
|
@click.option(
|
||||||
|
"--create-assignment-evaluation/--no-create-assignment-evaluation",
|
||||||
|
default=False,
|
||||||
|
help="will create assignment evaluation data for test-student1@example.com",
|
||||||
|
)
|
||||||
|
def command(create_assignment_completion, create_assignment_evaluation):
|
||||||
print("cypress reset data")
|
print("cypress reset data")
|
||||||
CourseCompletion.objects.all().delete()
|
CourseCompletion.objects.all().delete()
|
||||||
Notification.objects.all().delete()
|
Notification.objects.all().delete()
|
||||||
|
|
@ -27,8 +34,8 @@ def command(create_completion):
|
||||||
User.objects.all().update(language="de")
|
User.objects.all().update(language="de")
|
||||||
User.objects.all().update(additional_json_data={})
|
User.objects.all().update(additional_json_data={})
|
||||||
|
|
||||||
if create_completion:
|
if create_assignment_completion or create_assignment_evaluation:
|
||||||
print("create completion data for test course")
|
print("create assignment completion data for test course")
|
||||||
create_test_assignment_submitted_data(
|
create_test_assignment_submitted_data(
|
||||||
assignment=Assignment.objects.get(
|
assignment=Assignment.objects.get(
|
||||||
slug="test-lehrgang-assignment-überprüfen-einer-motorfahrzeugs-versicherungspolice"
|
slug="test-lehrgang-assignment-überprüfen-einer-motorfahrzeugs-versicherungspolice"
|
||||||
|
|
@ -36,3 +43,13 @@ def command(create_completion):
|
||||||
course_session=CourseSession.objects.get(id=TEST_COURSE_SESSION_BERN_ID),
|
course_session=CourseSession.objects.get(id=TEST_COURSE_SESSION_BERN_ID),
|
||||||
user=User.objects.get(id=TEST_STUDENT1_USER_ID),
|
user=User.objects.get(id=TEST_STUDENT1_USER_ID),
|
||||||
)
|
)
|
||||||
|
if create_assignment_evaluation:
|
||||||
|
print("create assignment evaulation data for test course")
|
||||||
|
create_test_assignment_evaulation_data(
|
||||||
|
assignment=Assignment.objects.get(
|
||||||
|
slug="test-lehrgang-assignment-überprüfen-einer-motorfahrzeugs-versicherungspolice"
|
||||||
|
),
|
||||||
|
course_session=CourseSession.objects.get(id=TEST_COURSE_SESSION_BERN_ID),
|
||||||
|
assignment_user=User.objects.get(id=TEST_STUDENT1_USER_ID),
|
||||||
|
evaluation_user=User.objects.get(id=TEST_TRAINER1_USER_ID),
|
||||||
|
)
|
||||||
|
|
|
||||||
|
|
@ -229,6 +229,46 @@ def create_test_assignment_submitted_data(assignment, course_session, user):
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def create_test_assignment_evaulation_data(
|
||||||
|
assignment, course_session, assignment_user, evaluation_user
|
||||||
|
):
|
||||||
|
if assignment and course_session and assignment_user and evaluation_user:
|
||||||
|
subtasks = assignment.get_evaluation_tasks()
|
||||||
|
evaluation_points = 0
|
||||||
|
|
||||||
|
for index, evaluation_task in enumerate(subtasks):
|
||||||
|
evaluation_points += 2
|
||||||
|
|
||||||
|
update_assignment_completion(
|
||||||
|
assignment_user=assignment_user,
|
||||||
|
assignment=assignment,
|
||||||
|
course_session=course_session,
|
||||||
|
learning_content_page=assignment.learningcontentassignment_set.first(),
|
||||||
|
completion_data={
|
||||||
|
evaluation_task["id"]: {
|
||||||
|
"expert_data": {
|
||||||
|
"points": evaluation_task["value"]["max_points"],
|
||||||
|
"text": "Gut gemacht!",
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
completion_status=AssignmentCompletionStatus.EVALUATION_IN_PROGRESS,
|
||||||
|
evaluation_user=evaluation_user,
|
||||||
|
)
|
||||||
|
|
||||||
|
update_assignment_completion(
|
||||||
|
assignment_user=assignment_user,
|
||||||
|
assignment=assignment,
|
||||||
|
course_session=course_session,
|
||||||
|
learning_content_page=assignment.learningcontentassignment_set.first(),
|
||||||
|
completion_data={},
|
||||||
|
completion_status=AssignmentCompletionStatus.EVALUATION_SUBMITTED,
|
||||||
|
evaluation_user=evaluation_user,
|
||||||
|
evaluation_grade=6,
|
||||||
|
evaluation_points=evaluation_points,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def create_test_course_with_categories(apps=None, schema_editor=None):
|
def create_test_course_with_categories(apps=None, schema_editor=None):
|
||||||
if apps is not None:
|
if apps is not None:
|
||||||
Course = apps.get_model("course", "Course")
|
Course = apps.get_model("course", "Course")
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue