Skip to content

Commit

Permalink
New release with plagiarism APIs added.
Browse files Browse the repository at this point in the history
  • Loading branch information
krulis-martin committed Feb 14, 2023
1 parent 732cac9 commit 0f6a758
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 5 deletions.
6 changes: 3 additions & 3 deletions recodex/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,13 +291,13 @@ def delete_shadow_assignment_points(self, points_id):
# Plagiarisms

def create_plagiarism_batch(self, tool, tool_params=None):
self.post('/plagiarism', data={"detectionTool": tool, "detectionToolParams": tool_params})
return self.post('/plagiarism', data={"detectionTool": tool, "detectionToolParams": tool_params})

def update_plagiarism_batch(self, id, upload_completed):
self.post('/plagiarism/{}'.format(id), data={"uploadCompleted": upload_completed})
return self.post('/plagiarism/{}'.format(id), data={"uploadCompleted": upload_completed})

def add_plagiarism_detected_similarity(self, id, solution_id, data):
self.post('/plagiarism/{}/{}'.format(id, solution_id), data=data)
return self.post('/plagiarism/{}/{}'.format(id, solution_id), data=data)

# Misc

Expand Down
Empty file.
55 changes: 55 additions & 0 deletions recodex/plugins/plagiarisms/cli.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import sys
import click
import json
from ruamel import yaml

from recodex.api import ApiClient
from recodex.decorators import pass_api_client


@click.group()
def cli():
"""
API related to plagiarism detection and suspected solution similarities
"""


@cli.command()
@click.argument("tool")
@click.argument("tool_params")
@pass_api_client
def create_batch(api: ApiClient, tool, tool_params):
"""
Create a new plagiarism detection batch
"""
batch = api.create_plagiarism_batch(tool, tool_params)
click.echo(batch["id"])


@cli.command()
@click.argument("id")
@click.option("--upload-completed/--upload-reopen", "completed", default=True)
@pass_api_client
def update_batch(api: ApiClient, id, completed):
"""
Update a plagiarism detection batch (whether its upload has been completed)
"""
api.update_plagiarism_batch(id, completed)


@cli.command()
@click.argument("id")
@click.argument("solution_id")
@click.option("--json/--yaml", "useJson", default=True)
@pass_api_client
def add_similarity(api: ApiClient, id, solution_id, useJson):
"""
Add detected similarity record to open plagiarism detection batch
"""

if useJson:
data = json.load(sys.stdin)
else:
data = yaml.safe_load(sys.stdin)
print(data)
api.add_plagiarism_detected_similarity(id, solution_id, data)
5 changes: 3 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

setup(
name='recodex-cli',
version='0.0.18',
version='0.0.19',
description='ReCodEx CLI',
long_description='A command line frontend to the ReCodEx programmer evaluation system',
classifiers=[
Expand Down Expand Up @@ -34,11 +34,12 @@
'groups = recodex.plugins.groups.cli:cli',
'caslogin = recodex.plugins.caslogin.cli:caslogin',
'login = recodex.plugins.login.cli:login',
'set_token = recodex.plugins.login.cli:set_token',
'plagiarisms = recodex.plugins.plagiarisms.cli:cli',
'shadow_assignments = recodex.plugins.shadow_assignments.cli:cli',
'solutions = recodex.plugins.solutions.cli:cli',
'takeover = recodex.plugins.takeover.cli:takeover',
'users = recodex.plugins.users.cli:cli',
'plagiarisms = recodex.plugins.plagiarisms.cli:cli',
]
}
)

0 comments on commit 0f6a758

Please sign in to comment.