forked from autolab/Autolab
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ModuleBase.rb
executable file
·112 lines (94 loc) · 2.6 KB
/
ModuleBase.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# This module, which is inherited by all modules, organizes how
# methods are overridden.
module ModuleBase
def updateModules
@allModules = [ "Autograde", "Scoreboard", "Partners", "Svn" ]
@modulesUsed = []
assign = @assessment.name.gsub(/\./,'')
modName = (assign + (@course.name).gsub(/[^A-Za-z0-9]/,"")).camelize
for mod in @allModules do
begin
modUsed = eval("#{modName}.include?(#{mod})")
if modUsed then
@modulesUsed << mod
end
rescue Exception
# do nothing
end
end
end
# This is easy to override, and no conflicts can occur
def listAdmin
super()
updateModules()
if @modulesUsed.include?("Autograde") then
autogradeListAdmin()
end
if @modulesUsed.include?("Scoreboard") then
scoreboardListAdmin()
end
if @modulesUsed.include?("Partners") then
partnersListAdmin()
end
if @modulesUsed.include?("Svn") then
svnListAdmin()
end
end
# We can only load *one* page. If other modules are created with custom
# submission pages, this needs to be dealt with
def loadHandinPage
updateModules()
super()
end
# Validations can be combined if done in a descending order- make sure to
# check for special module cases, like SVN!
def validateHandin()
updateModules()
# Partners stand alone, they don't affect others
if @modulesUsed.include?("Partners") then
if ! partnersValidateHandin() then
return false
end
end
# If we're validating for svn, we don't have a file to check
if @modulesUsed.include?("Svn") then
if ! svnValidateHandin() then
return false
end
else
if ! super() then
return false
end
end
return true
end
# Saving a file produces a file, so it can only be done once.
# If you need to combine two saves, write a new function
def saveHandin()
if @modulesUsed.include?("Svn") then
return svnSaveHandin()
else
return super()
end
end
# called when autograde is done
# creates a partner submission
def createPartnerSubmission(submission)
updateModules()
hasPartners = @modulesUsed.include?("Partners")
# return the submission created for partner
if hasPartners then
pSubmission = partnersAfterAutograde(submission)
unless pSubmission.nil?
pSubmission.save!
end
return pSubmission
end
end
# save a score on the partner submission
def saveAutogradeForPartner(score, pSubmission)
if pSubmission then
updatePartnerScore(score, pSubmission)
end
end
end