Skip to content

Commit

Permalink
Forward auto-grading settings to DL assignments
Browse files Browse the repository at this point in the history
  • Loading branch information
marcospri committed Sep 3, 2024
1 parent 3839c43 commit 5a91150
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
25 changes: 25 additions & 0 deletions lms/views/lti/deep_linking.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
import uuid
from datetime import datetime, timedelta

from marshmallow import Schema, validate
from pyramid.view import view_config, view_defaults
from webargs import fields

Expand Down Expand Up @@ -85,12 +86,32 @@ def deep_linking_launch(context, request):
return {}


class _AutoGradingConfig(Schema):
grading_type = fields.Str(
required=True, validate=validate.OneOf(["all_or_nothing", "scaled"])
)
activity_calculation = fields.Str(
required=True, validate=validate.OneOf(["cumulative", "separately"])
)

required_annotations = fields.Int(
required=False, allow_none=True, validate=validate.Range(min=0)
)
required_replies = fields.Int(
required=False, allow_none=True, validate=validate.Range(min=0)
)


class DeepLinkingFieldsRequestSchema(JSONPyramidRequestSchema):
content_item_return_url = fields.Str(required=True)
content = fields.Dict(required=True)
group_set = fields.Str(required=False, allow_none=True)
title = fields.Str(required=False, allow_none=True)

auto_grading_config = fields.Nested(
_AutoGradingConfig, required=False, allow_none=True
)


class LTI11DeepLinkingFieldsRequestSchema(DeepLinkingFieldsRequestSchema):
opaque_data_lti11 = fields.Str(required=False, allow_none=True)
Expand Down Expand Up @@ -254,6 +275,10 @@ def _get_assignment_configuration(request) -> dict:
if title := request.parsed_params.get("title"):
params["title"] = title

if auto_grading_config := request.parsed_params.get("auto_grading_config"):
# Custom params must be str, encode these settings as JSON
params["auto_grading_config"] = json.dumps(auto_grading_config)

if content["type"] == "url":
params["url"] = content["url"]
else:
Expand Down
4 changes: 4 additions & 0 deletions tests/unit/lms/views/lti/deep_linking_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,10 @@ def test_it_for_v11(
{"group_set": "1", "title": "title"},
{"group_set": "1", "title": "title"},
),
(
{"auto_grading_config": {"key": "value"}},
{"auto_grading_config": '{"key": "value"}'},
),
],
)
def test_get_assignment_configuration(
Expand Down

0 comments on commit 5a91150

Please sign in to comment.