Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
U
unitgrade_private
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
tuhe
unitgrade_private
Commits
169d0a29
Commit
169d0a29
authored
1 year ago
by
tuhe
Browse files
Options
Downloads
Patches
Plain Diff
project evaluation statistics
parent
c8692015
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/unitgrade_private/pipelines/dtulearn.py
+79
-53
79 additions, 53 deletions
src/unitgrade_private/pipelines/dtulearn.py
src/unitgrade_private/plagiarism/mossit.py
+31
-18
31 additions, 18 deletions
src/unitgrade_private/plagiarism/mossit.py
with
110 additions
and
71 deletions
src/unitgrade_private/pipelines/dtulearn.py
+
79
−
53
View file @
169d0a29
...
@@ -139,6 +139,8 @@ def docker_stagewise_evaluation(base_directory, Dockerfile=None, instructor_grad
...
@@ -139,6 +139,8 @@ def docker_stagewise_evaluation(base_directory, Dockerfile=None, instructor_grad
unmute_docker
=
True
,
unmute_docker
=
True
,
plagiarism_check
=
False
,
plagiarism_check
=
False
,
accept_problems
=
False
,
# No!
accept_problems
=
False
,
# No!
copydetect_check
=
False
,
slim_rs
=
False
,
# Slim the rs data structure that is returned.
):
):
"""
"""
This is the main verification scripts. It is the main entry point for project verifications as downloaded from DTU Learn.
This is the main verification scripts. It is the main entry point for project verifications as downloaded from DTU Learn.
...
@@ -708,6 +710,8 @@ def docker_stagewise_evaluation(base_directory, Dockerfile=None, instructor_grad
...
@@ -708,6 +710,8 @@ def docker_stagewise_evaluation(base_directory, Dockerfile=None, instructor_grad
else
:
else
:
t
,
_
=
load_token
(
tkns
[
0
])
t
,
_
=
load_token
(
tkns
[
0
])
rs
[
id
]
=
{
**
rs
[
id
],
**
t
}
rs
[
id
]
=
{
**
rs
[
id
],
**
t
}
if
slim_rs
and
'
sources
'
in
rs
[
id
]:
rs
[
id
][
'
sources
'
]
=
"
Sources have been removed from this token because slim_rs=True (see dtulearn.py).
"
return
rs
return
rs
rs
=
_stage_report
()
rs
=
_stage_report
()
...
@@ -730,65 +734,87 @@ def docker_stagewise_evaluation(base_directory, Dockerfile=None, instructor_grad
...
@@ -730,65 +734,87 @@ def docker_stagewise_evaluation(base_directory, Dockerfile=None, instructor_grad
with
open
(
base_directory
+
"
/log.txt
"
,
"
w
"
)
as
f
:
with
open
(
base_directory
+
"
/log.txt
"
,
"
w
"
)
as
f
:
f
.
write
(
"
\n
"
.
join
(
all_msgs
))
f
.
write
(
"
\n
"
.
join
(
all_msgs
))
# rs['messages'] = messages
if
plagiarism_check
or
copydetect_check
:
# with open()
if
plagiarism_check
and
True
:
from
unitgrade_private.plagiarism.mossit
import
moss_it2023
from
unitgrade_private.plagiarism.mossit
import
moss_it2023
moss_it2023
(
submissions_base_dir
=
stage4_dir
,
submissions_pattern
=
"
*-token
"
,
instructor_grade_script
=
instructor_grade_script
,
moss_it2023
(
submissions_base_dir
=
stage4_dir
,
submissions_pattern
=
"
*-token
"
,
instructor_grade_script
=
instructor_grade_script
,
student_files_dir
=
student_handout_folder
)
student_files_dir
=
student_handout_folder
,
submit_to_server
=
not
copydetect_check
)
# Write the moss files.
if
plagiarism_check
and
False
:
# This check is based on detector and is deprecated. I don't like detector.
if
plagiarism_check
and
copydetect_check
:
# This check is based on detector and is deprecated. I don't like detector.
from
coursebox.core.info_paths
import
get_paths
from
coursebox.core.info_paths
import
get_paths
paths
=
get_paths
()
paths
=
get_paths
()
from
copydetect
import
CopyDetector
from
copydetect
import
CopyDetector
detector
=
CopyDetector
(
extensions
=
[
"
py
"
],
display_t
=
0.7
)
working_dir
=
os
.
path
.
dirname
(
stage4_dir
)
+
"
/moss
"
# rs['Group10']['sources'][0]['report_relative_location']
relatives
=
[]
# Use the plagiarism checker.
for
id
in
rs
:
def
read_all_chunk
(
bdir
)
:
v
=
[
int
(
s
.
split
(
"
_
"
)[
-
3
])
for
s
in
rs
[
id
][
'
token_produced
'
]
]
py_file
=
[
]
token
=
rs
[
id
][
'
token_produced
'
][
v
.
index
(
max
(
v
))
]
for
f
in
sorted
(
glob
.
glob
(
bdir
+
"
/*.py
"
))
:
tk
,
_
=
load_token
(
token
)
with
open
(
f
,
"
r
"
)
as
f
:
rl
=
tk
[
'
sources
'
][
0
][
'
report_relative_location
'
]
py_file
.
append
(
f
.
read
())
bd
=
f
"
{
stage3_dir
}
/
{
os
.
path
.
basename
(
os
.
path
.
dirname
(
token
))
}
/
{
os
.
path
.
dirname
(
rl
)
}
"
return
"
\n\n
"
.
join
(
py_file
)
chk_files
=
[]
for
q
in
tk
[
'
details
'
]:
copydetect_submissions_dir
=
working_dir
+
"
/copydetect_submissions
"
# print(q)
if
os
.
path
.
isdir
(
copydetect_submissions_dir
):
with
open
(
f
"
{
bd
}
/unitgrade_data/
{
tk
[
'
details
'
][
q
][
'
name
'
]
}
.pkl
"
,
'
rb
'
)
as
f
:
shutil
.
rmtree
(
copydetect_submissions_dir
)
pk
=
pickle
.
load
(
f
)
os
.
makedirs
(
copydetect_submissions_dir
)
for
item
in
tk
[
'
details
'
][
q
][
'
items
'
]
:
for
bdir
in
glob
.
glob
(
working_dir
+
"
/moss_submissions/*
"
)
:
key
=
(
item
,
'
coverage
'
)
os
.
makedirs
(
odir
:
=
copydetect_submissions_dir
+
"
/
"
+
os
.
path
.
basename
(
bdir
)
)
if
key
in
pk
:
with
open
(
odir
+
"
/student_code.py
"
,
"
w
"
)
as
f
:
for
f
in
pk
[
key
]:
f
.
write
(
read_all_chunk
(
bdir
))
relatives
.
append
(
f
)
chk_files
.
append
(
f
"
{
stage3_dir
}
/
{
os
.
path
.
basename
(
os
.
path
.
dirname
(
token
))
}
/
{
f
}
"
)
copydetect_handout_dir
=
working_dir
+
"
/copydetect_handout
"
# print(chk_files)
if
os
.
path
.
isdir
(
copydetect_handout_dir
):
chk_files
=
list
(
set
(
chk_files
)
)
shutil
.
rmtree
(
copydetect_handout_dir
)
os
.
makedirs
(
copydetect_handout_dir
)
for
f
in
chk_files
:
with
open
(
copydetect_handout_dir
+
"
/student_code.py
"
,
"
w
"
)
as
f
:
detector
.
add_file
(
f
)
f
.
write
(
read_all_chunk
(
working_dir
+
"
/handouts
"
)
)
# Fuck this shit just add the solutions.
for
f
in
set
(
relatives
):
test_dir_list
=
list
(
glob
.
glob
(
copydetect_submissions_dir
+
"
/*
"
))
ff
=
paths
[
'
02450private
'
]
+
"
/Exam/exam2023spring/handout/
"
+
f
detector
.
add_file
(
ff
,
type
=
"
boilerplate
"
)
detector
=
CopyDetector
(
extensions
=
[
"
py
"
],
display_t
=
0.7
,
boilerplate_dirs
=
[
copydetect_handout_dir
],
test_dirs
=
test_dir_list
,
same_name_only
=
True
)
detector
.
out_file
=
working_dir
+
"
/copydetect_report.html
"
detector
.
run
()
detector
.
run
()
detector
.
generate_html_report
()
detector
.
generate_html_report
()
# """
# file:///home/tuhe/Documents/02002instructors/project_evaluations_2023fall/project1/moss/handouts
# file:///home/tuhe/Documents/02002instructors/project_evaluations_2023fall/project1/moss/moss_submissions
#
# """
#
#
# detector = CopyDetector(same_name_only=True, extensions=["py"], display_t=0.7)
# 799171 89568609
#
# _stage_plagiarism()
# relatives = []
# for id in rs:
pass
# v = [int(s.split("_")[-3]) for s in rs[id]['token_produced']]
# token = rs[id]['token_produced'][v.index(max(v))]
# tk, _ = load_token(token)
# rl = tk['sources'][0]['report_relative_location']
# bd = f"{stage3_dir}/{os.path.basename(os.path.dirname(token))}/{os.path.dirname(rl)}"
# chk_files = []
# for q in tk['details']:
# # print(q)
# with open(f"{bd}/unitgrade_data/{tk['details'][q]['name']}.pkl", 'rb') as f:
# pk = pickle.load(f)
#
# for item in tk['details'][q]['items']:
# key = (item, 'coverage')
# if key in pk:
# for f in pk[key]:
# relatives.append(f)
# chk_files.append( f"{stage3_dir}/{os.path.basename(os.path.dirname(token))}/{f}")
#
# chk_files = list(set(chk_files))
# for f in chk_files:
# detector.add_file(f)
# for f in set(relatives):
# ff = paths['02450private']+"/Exam/exam2023spring/handout/" + f
# detector.add_file(ff, type="boilerplate")
#
# detector.run()
# detector.generate_html_report()
return
rs
return
rs
...
...
This diff is collapsed.
Click to expand it.
src/unitgrade_private/plagiarism/mossit.py
+
31
−
18
View file @
169d0a29
...
@@ -57,7 +57,7 @@ def get_id(moss_pl):
...
@@ -57,7 +57,7 @@ def get_id(moss_pl):
return
pl
.
split
(
"
=
"
)[
1
][:
-
1
]
return
pl
.
split
(
"
=
"
)[
1
][:
-
1
]
def
moss_it2023
(
submissions_base_dir
=
None
,
submissions_pattern
=
"
*-token
"
,
whitelisted_tokens
=
""
,
instructor_grade_script
=
None
,
moss_id
=
None
,
def
moss_it2023
(
submissions_base_dir
=
None
,
submissions_pattern
=
"
*-token
"
,
whitelisted_tokens
=
""
,
instructor_grade_script
=
None
,
moss_id
=
None
,
student_files_dir
=
None
):
student_files_dir
=
None
,
submit_to_server
=
True
):
a
=
234
a
=
234
...
@@ -101,6 +101,8 @@ def moss_it2023(submissions_base_dir=None, submissions_pattern="*-token", whitel
...
@@ -101,6 +101,8 @@ def moss_it2023(submissions_base_dir=None, submissions_pattern="*-token", whitel
for
g
in
i
:
for
g
in
i
:
if
os
.
path
.
isfile
(
student_file
:
=
f
"
{
tmpdirname
}
/
{
g
}
"
):
if
os
.
path
.
isfile
(
student_file
:
=
f
"
{
tmpdirname
}
/
{
g
}
"
):
shutil
.
copy
(
student_file
,
f
"
{
sdir
}
/
{
os
.
path
.
basename
(
g
)
}
"
)
shutil
.
copy
(
student_file
,
f
"
{
sdir
}
/
{
os
.
path
.
basename
(
g
)
}
"
)
if
cov_files
is
None
:
return
if
student_files_dir
is
not
None
:
if
student_files_dir
is
not
None
:
for
q
in
cov_files
:
for
q
in
cov_files
:
...
@@ -128,14 +130,25 @@ def moss_it2023(submissions_base_dir=None, submissions_pattern="*-token", whitel
...
@@ -128,14 +130,25 @@ def moss_it2023(submissions_base_dir=None, submissions_pattern="*-token", whitel
print
(
"
You need to specify a moss id. You can do that by putting the moss.pl script at:
"
,
os
.
path
.
expanduser
(
'
~
'
)
+
"
/Documents/moss.pl
"
)
print
(
"
You need to specify a moss id. You can do that by putting the moss.pl script at:
"
,
os
.
path
.
expanduser
(
'
~
'
)
+
"
/Documents/moss.pl
"
)
return
return
if
submit_to_server
:
m
=
mosspy
.
Moss
(
moss_id
,
"
python
"
)
m
=
mosspy
.
Moss
(
moss_id
,
"
python
"
)
for
f
in
glob
.
glob
(
working_dir
+
"
/handouts/**/*.py
"
,
recursive
=
True
):
for
f
in
glob
.
glob
(
working_dir
+
"
/handouts/**/*.py
"
,
recursive
=
True
):
print
(
f
)
print
(
"
Moss adding base file>
"
,
f
)
m
.
addBaseFile
(
f
)
m
.
addBaseFile
(
f
)
m
.
addFilesByWildcard
(
working_dir
+
"
/moss_submissions/*/*.py
"
)
m
.
addFilesByWildcard
(
working_dir
+
"
/moss_submissions/*/*.py
"
)
print
(
"
> Calling moss with id
"
,
moss_id
)
print
(
"
> Calling moss with id
"
,
moss_id
)
url
=
m
.
send
(
lambda
file_path
,
display_name
:
print
(
'
*
'
,
end
=
''
,
flush
=
True
))
d
=
dict
()
d
[
'
count
'
]
=
0
def
gcount
():
d
[
'
count
'
]
=
d
[
'
count
'
]
+
1
return
d
[
'
count
'
]
verbose
=
False
if
verbose
:
status_fun
=
lambda
file_path
,
display_name
:
print
(
"
moss>
"
+
str
(
gcount
())
+
"
:
"
+
file_path
+
"
-
"
+
display_name
,
flush
=
True
)
else
:
status_fun
=
lambda
file_path
,
display_name
:
print
(
"
*
"
,
end
=
''
,
flush
=
True
)
url
=
m
.
send
(
status_fun
)
print
()
print
()
print
(
"
Report Url:
"
+
url
)
print
(
"
Report Url:
"
+
url
)
r
=
working_dir
+
"
/report/report.html
"
r
=
working_dir
+
"
/report/report.html
"
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment