Skip to content

Commit

Permalink
feat: Turnitin API workflow test with openedx XBlock (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
nandodev-net authored Jan 30, 2024
1 parent ae01187 commit db58663
Show file tree
Hide file tree
Showing 26 changed files with 1,915 additions and 13 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ test: clean ## run tests in the current virtualenv
pytest

format: ## Format code automatically
isort $(SOURCES)
black $(BLACK_OPTS)
isort $(SOURCES)

diff_cover: test ## find diff lines that need test coverage
diff-cover coverage.xml
Expand Down
9 changes: 9 additions & 0 deletions platform_plugin_turnitin/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,12 @@ class PlatformPluginTurnitinConfig(AppConfig):
},
},
}

def ready(self) -> None:
"""
Perform application initialization once the Django platform has been initialized.
"""
super().ready()
from platform_plugin_turnitin.turnitin import ( # no-qa pylint: disable=import-outside-toplevel,unused-import
TurnitinXBlock,
)
47 changes: 47 additions & 0 deletions platform_plugin_turnitin/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Generated by Django 3.2.21 on 2023-10-04 20:37

from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):
initial = True

dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]

operations = [
migrations.CreateModel(
name="TurnitinSubmission",
fields=[
(
"id",
models.AutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
(
"turnitin_submission_id",
models.CharField(blank=True, max_length=255, null=True),
),
(
"turnitin_submission_pdf_id",
models.CharField(blank=True, max_length=255, null=True),
),
("created_at", models.DateTimeField(auto_now_add=True)),
(
"user",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
related_name="submissions",
to=settings.AUTH_USER_MODEL,
),
),
],
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Generated by Django 3.2.20 on 2023-10-06 19:16

from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):
dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
("platform_plugin_turnitin", "0001_initial"),
]

operations = [
migrations.AlterField(
model_name="turnitinsubmission",
name="user",
field=models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
related_name="turnitin_submissions",
to=settings.AUTH_USER_MODEL,
),
),
]
Empty file.
26 changes: 26 additions & 0 deletions platform_plugin_turnitin/models.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,29 @@
"""
Database models for platform_plugin_turnitin.
"""

from django.contrib.auth import get_user_model
from django.db import models

User = get_user_model()


class TurnitinSubmission(models.Model):
"""
Represents a submission to Turnitin.
Attributes:
- user (User): The user who made the submission.
- turnitin_submission_id (str): The unique identifier for the submission in Turnitin.
- turnitin_submission_pdf_id (str): The unique identifier for the PDF version of the submission in Turnitin.
- created_at (datetime): The date and time when the submission was created.
.. no_pii:
"""

user = models.ForeignKey(
User, on_delete=models.CASCADE, related_name="turnitin_submissions"
)
turnitin_submission_id = models.CharField(max_length=255, blank=True, null=True)
turnitin_submission_pdf_id = models.CharField(max_length=255, blank=True, null=True)
created_at = models.DateTimeField(auto_now_add=True)
39 changes: 38 additions & 1 deletion platform_plugin_turnitin/settings/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,45 @@
USE_TZ = True


def plugin_settings(settings): # pylint: disable=unused-argument
def plugin_settings(settings):
"""
Set of plugin settings used by the Open Edx platform.
More info: https://github.com/edx/edx-platform/blob/master/openedx/core/djangoapps/plugins/README.rst
"""

# Configuration variables
settings.TURNITIN_TII_API_URL = None
settings.TURNITIN_TCA_INTEGRATION_FAMILY = None
settings.TURNITIN_TCA_INTEGRATION_VERSION = None
settings.TURNITIN_TCA_API_KEY = None
settings.TURNITIN_SIMILARY_REPORT_PAYLOAD = {
"indexing_settings": {"add_to_index": True},
"generation_settings": {
"search_repositories": [
"INTERNET",
"SUBMITTED_WORK",
"PUBLICATION",
"CROSSREF",
"CROSSREF_POSTED_CONTENT",
],
"submission_auto_excludes": [],
"auto_exclude_self_matching_scope": "ALL",
"priority": "HIGH",
},
"view_settings": {
"exclude_quotes": True,
"exclude_bibliography": True,
"exclude_citations": False,
"exclude_abstract": False,
"exclude_methods": False,
"exclude_custom_sections": False,
"exclude_preprints": False,
"exclude_small_matches": 8,
"exclude_internet": False,
"exclude_publications": False,
"exclude_crossref": False,
"exclude_crossref_posted_content": False,
"exclude_submitted_works": False,
},
}
settings.TURNITIN_API_TIMEOUT = 30
25 changes: 24 additions & 1 deletion platform_plugin_turnitin/settings/production.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,31 @@
"""


def plugin_settings(settings): # pylint: disable=unused-argument
def plugin_settings(settings):
"""
Set of plugin settings used by the Open Edx platform.
More info: https://github.com/edx/edx-platform/blob/master/openedx/core/djangoapps/plugins/README.rst
"""
settings.TURNITIN_TII_API_URL = getattr(settings, "ENV_TOKENS", {}).get(
"TURNITIN_TII_API_URL", settings.TURNITIN_TII_API_URL
)

settings.TURNITIN_TCA_INTEGRATION_FAMILY = getattr(settings, "ENV_TOKENS", {}).get(
"TURNITIN_TCA_INTEGRATION_FAMILY", settings.TURNITIN_TCA_INTEGRATION_FAMILY
)

settings.TURNITIN_TCA_INTEGRATION_VERSION = getattr(settings, "ENV_TOKENS", {}).get(
"TURNITIN_TCA_INTEGRATION_VERSION", settings.TURNITIN_TCA_INTEGRATION_VERSION
)

settings.TURNITIN_TCA_API_KEY = getattr(settings, "ENV_TOKENS", {}).get(
"TURNITIN_TCA_API_KEY", settings.TURNITIN_TCA_API_KEY
)

settings.TURNITIN_SIMILARY_REPORT_PAYLOAD = getattr(settings, "ENV_TOKENS", {}).get(
"TURNITIN_SIMILARY_REPORT_PAYLOAD", settings.TURNITIN_SIMILARY_REPORT_PAYLOAD
)

settings.TURNITIN_API_TIMEOUT = getattr(settings, "ENV_TOKENS", {}).get(
"TURNITIN_API_TIMEOUT", settings.TURNITIN_API_TIMEOUT
)
Loading

0 comments on commit db58663

Please sign in to comment.