forked from autolab/Autolab
-
Notifications
You must be signed in to change notification settings - Fork 0
/
module_base.rb
executable file
·70 lines (60 loc) · 1.83 KB
/
module_base.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
##
# This module, which is inherited by all modules, organizes how methods are overridden.
# I'm pretty sure this is obsolete.
#
module ModuleBase
def updateModules
@allModules = %w(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})")
@modulesUsed << mod if modUsed
rescue Exception
# do nothing
end
end
end
# This is easy to override, and no conflicts can occur
def listAdmin
super()
updateModules
autogradeListAdmin if @modulesUsed.include?("Autograde")
scoreboardListAdmin if @modulesUsed.include?("Scoreboard")
partnersListAdmin if @modulesUsed.include?("Partners")
svnListAdmin if @modulesUsed.include?("Svn")
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")
return false unless partnersValidateHandin
end
# If we're validating for svn, we don't have a file to check
if @modulesUsed.include?("Svn")
return false unless svn_validate_handin
else
return false unless super()
end
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")
return svn_save_handin
else
return super()
end
end
end