Skip to content
Snippets Groups Projects
Commit ae599247 authored by tuhe's avatar tuhe
Browse files

Moss integration and Hinting

parent 96b2b41b
No related branches found
No related tags found
No related merge requests found
Showing
with 939 additions and 3 deletions
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
# C extensions
*.so
# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST
# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/
# Translations
*.mo
*.pot
# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal
# Flask stuff:
instance/
.webassets-cache
# Scrapy stuff:
.scrapy
# Sphinx documentation
docs/_build/
# PyBuilder
.pybuilder/
target/
# Jupyter Notebook
.ipynb_checkpoints
# IPython
profile_default/
ipython_config.py
# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version
# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
__pypackages__/
# Celery stuff
celerybeat-schedule
celerybeat.pid
# SageMath parsed files
*.sage.py
# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/
# Spyder project settings
.spyderproject
.spyproject
# Rope project settings
.ropeproject
# mkdocs documentation
/site
# mypy
.mypy_cache/
.dmypy.json
dmypy.json
# Pyre type checker
.pyre/
# pytype static type analyzer
.pytype/
# Cython debug symbols
cython_debug/
\ No newline at end of file
......@@ -299,7 +299,18 @@ The last lines load the result and compare the score -- in this case both will r
- Docker prevents students from doing mailicious things to your computer and allows the results to be reproducible by TAs.
# Moss plagiarism detection
You can easily apply Moss to the students token files.
You can easily apply Moss to the students token files. First get moss from https://theory.stanford.edu/~aiken/moss/ and create two directories:
```terminal
whitelist/ # Whitelisted files. Code from these files are part of the handouts to students
submissions/ # Where you dump student submissions.
```
The whitelist directory is optional, and the submissions directory contains student submissions (one folder per student):
```terminal
/submissions/<student-id-1>/..
/submissions/<student-id-2>/..
```
The files in the whitelist/student directory can be either `.token` files (which are unpacked) or python files, and they may contain subdirectories: Everything will be unpacked and flattened. The simplest way to set it up is simply to download all files from DTU learn as a zip-file and unzip it somewhere.
When done just call moss as follows:
```python
from unitgrade_private2.plagiarism.mossit import moss_it, get_id
......@@ -311,6 +322,11 @@ if __name__ == "__main__":
moss_it(whitelist_dir="whitelist", submissions_dir="student_submissions", moss_id=id)
```
This will generate a report. You can view the example including the report here: https://lab.compute.dtu.dk/tuhe/unitgrade_private/-/tree/master/examples/example_moss
# Smart hinting
![alt text|small](https://gitlab.compute.dtu.dk/tuhe/slider/-/raw/main/docs/hints.png)
# Citing
```bibtex
......
......@@ -299,10 +299,26 @@ The last lines load the result and compare the score -- in this case both will r
- Docker prevents students from doing mailicious things to your computer and allows the results to be reproducible by TAs.
# Moss plagiarism detection
You can easily apply Moss to the students token files.
You can easily apply Moss to the students token files. First get moss from https://theory.stanford.edu/~aiken/moss/ and create two directories:
```terminal
whitelist/ # Whitelisted files. Code from these files are part of the handouts to students
submissions/ # Where you dump student submissions.
```
The whitelist directory is optional, and the submissions directory contains student submissions (one folder per student):
```terminal
/submissions/<student-id-1>/..
/submissions/<student-id-2>/..
```
The files in the whitelist/student directory can be either `.token` files (which are unpacked) or python files, and they may contain subdirectories: Everything will be unpacked and flattened. The simplest way to set it up is simply to download all files from DTU learn as a zip-file and unzip it somewhere.
When done just call moss as follows:
```python
{{example_moss_moss_example_py}}
```
This will generate a report. You can view the example including the report here: https://lab.compute.dtu.dk/tuhe/unitgrade_private/-/tree/master/examples/example_moss
# Smart hinting
![alt text|small]({{resources}}/docs/hints.png)
# Citing
```bibtex
......
......@@ -14,7 +14,7 @@ if __name__ == "__main__":
k = os.path.relpath(file, "../examples").replace(os.sep, "_").replace(".", "_")
data[k] = f.read()
data['resources'] = "https://gitlab.compute.dtu.dk/tuhe/slider/-/raw/main"
with open("README.jinja.md", 'r') as f:
s = jinja2.Environment(loader=jinja2.FileSystemLoader([".", "../example"])).from_string(f.read()).render(data)
......
docs/hints.png

140 KiB

from report1hints import Report1Hints
from unitgrade_private2.hidden_create_files import setup_grade_file_report
from snipper import snip_dir
if __name__ == "__main__":
setup_grade_file_report(Report1Hints)
# Deploy the files using snipper: https://gitlab.compute.dtu.dk/tuhe/snipper
snip_dir.snip_dir("./", "../../students/cs106", clean_destination_dir=True, exclude=['__pycache__', '*.token', 'deploy.py'])
def find_primes(n): #!f
"""
Return a list of all primes up to (and including) n
Hints:
* Remember to return a *list* (and not a tuple or numpy ndarray)
* Remember to include n if n is a prime
* The first few primes are 2, 3, 5, ...
"""
primes = [p for p in range(2, n+1) if is_prime(n) ]
return primes
def is_prime(n): #!f
"""
Return true iff n is a prime
Hints:
* A number if a prime if it has no divisors
* You can check if k divides n using the modulo-operator. I.e. n % k == True if k divides n.
"""
for k in range(2, n):
if k % n == 0:
return False
return True
from unitgrade2 import Report, UTestCase, evaluate_report_student
from homework1 import find_primes
import homework1
class Week1(UTestCase):
def test_find_all_primes(self):
"""
Hints:
* Insert a breakpoint and check what your function find_primes(4) actually outputs
"""
self.assertEqual(find_primes(4), [2,3])
class Report1Hints(Report):
title = "CS 106 Report 1"
questions = [(Week1, 10)] # Include a single question for 10 credits.
pack_imports = [homework1] # Unitgrade will recursively include all .py files from "cs101flat"
if __name__ == "__main__":
evaluate_report_student(Report1Hints())
This diff is collapsed.
File added
def find_primes(n):
"""
Return a list of all primes up to (and including) n
Hints:
* Remember to return a *list* (and not a tuple or numpy ndarray)
* Remember to include n if n is a prime
* The first few primes are 2, 3, 5, ...
"""
# TODO: 2 lines missing.
raise NotImplementedError("Implement function body")
def is_prime(n):
"""
Return true iff n is a prime
Hints:
* A number if a prime if it has no divisors
* You can check if k divides n using the modulo-operator. I.e. n % k == True if k divides n.
"""
# TODO: 3 lines missing.
raise NotImplementedError("Implement function body")
return True
from unitgrade2 import Report, UTestCase, evaluate_report_student
from homework1 import find_primes
import homework1
class Week1(UTestCase):
def test_find_all_primes(self):
"""
Hints:
* Insert a breakpoint and check what your function find_primes(4) actually outputs
"""
self.assertEqual(find_primes(4), [2,3])
class Report1Hints(Report):
title = "CS 106 Report 1"
questions = [(Week1, 10)] # Include a single question for 10 credits.
pack_imports = [homework1] # Unitgrade will recursively include all .py files from "cs101flat"
if __name__ == "__main__":
evaluate_report_student(Report1Hints())
This diff is collapsed.
File added
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment