-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathfind-in-scorm.ps1
174 lines (148 loc) · 5.03 KB
/
find-in-scorm.ps1
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
# *******************************************************************************
# Flash Query
#
# This is a PowerShell script intended to locate zipped SCORM content packaged
# with a traditional imsmanifest.xml file.
#
# This script can accept a few arguments. By default, the script will check
# the execution path and then every sub-folder recursively. The results will
# be printed to a CSV file in the execution directory.
# *******************************************************************************
param (
# The "path" var is the directory in which to search all subdirs, each respresenting a course.
[string]$path = ".\*",
# The "outputfile" var is the full path to the CSV file to which the script will write its results.
[string]$out = ".\scorm-breakdown.csv",
# Regex filter, check the README or find.ps1 for more information
[string]$filter = ".*"
)
# Add the wildcard if necessary
if ($false -eq $path.Contains("*")) {
$path = $path + "*"
}
# We're dealing with zip files, so we'll need to unzip and dispose of them
Add-Type -assembly "System.IO.Compression.FileSystem"
Write-Host "`nChecking for SWF files within zipped SCORM modules..."
# Filter for every SWF file in the given path, including sub-folders
$allFolders = New-Object System.Collections.Generic.List[System.Object]
$subFolders = Get-ChildItem $path -Recurse -Attributes d | Sort-Object -Property name -Descending
# Check if they only specified one folder
if (Test-Path $path -PathType Container) {
$current = Get-Item $path
$allFolders.Add($current);
}
ForEach ($sub in $subFolders) {
$allFolders.add($sub)
}
$Result = ForEach($folder in $allFolders) {
# Make sure we only search in the designated folders
if ($folder.FullName -notmatch $filter) {
continue
}
if ($folder.Name -match "CD_ROM") {
continue
}
$zipPaths = Get-ChildItem $folder.FullName -Filter *.zip
# Skip if we didn't find anything
if ($zipPaths.count -eq 0) {
continue
}
# Find which iteration of course material this is. This will assume the
# original directory structure and may not be even be applicable for your
# situation, but we wanted to provide it regardless
#
$iterPath = $folder
$iteration = $null
while ($null -ne $iterPath) {
if ("Courseware" -eq $iterPath.Name) {
$iteration = $iterPath.parent
break
}
$iterPath = $iterPath.parent
}
if ($null -eq $iteration) {
$iteration = "Unknown"
}
Write-Host "`n$($folder.FullName)"
# Open each zip
ForEach($zipPath in $zipPaths) {
# Check if this is an assessment
if( $zipPath.Name.ToLower().Contains("assessment") `
-or $zipPath.Name.ToLower().Contains("pretest") `
-or $zipPath.Name.ToLower().Contains("posttest") `
-or $zipPath.Name.ToLower().Contains("postest") `
-or $zipPath.Name.ToLower().Contains("exam") `
-or $zipPath.Name.ToLower().Contains("test") `
-or $zipPath.Name.ToLower().Contains("assess_") `
-or $zipPath.Name.ToLower().Contains("pre_") `
-or $zipPath.Name.ToLower().Contains("post_") )
{
$contentType = "Assessment"
} else {
$contentType = "Lesson"
}
# Make sure this is a valid archive
try {
$zip = [IO.Compression.ZipFile]::OpenRead($zipPath.FullName)
} catch {
Write-Host " -[failed]: $($zipPath.Name)"
continue
}
$flash = $false
# Make sure we find a manifest indicating that this is a Flash project
ForEach($thing in $zip.Entries) {
if ($thing.Name -eq "imsmanifest.xml") {
$flash = $true
break
}
}
if ($flash -eq $false) {
Write-Host " -[ignore]: $($zipPath.Name)"
continue
}
# count number of .swf files and detect authoring tools
$swfCount = 0
$tool = "Other"
$fileList = $zip.Entries
foreach($file in $fileList) {
if($file.FullName -match "\.swf$") {
$swfCount++
}
# Detect authoring tool through unique files
switch -regex ($file.FullName) {
"captivate.css" { $tool = "Captivate"; break }
"CPM.js" { $tool = "Captivate"; break }
"SCORM_API_DIF.js" { $tool = "ECDC"; break }
"isplayer.js" { $tool = "iSpring"; break }
"trivantis.css" { $tool = "Lectora"; break }
"story_content" { $tool = "Storyline"; break }
"quizmaker" { $tool = "Presenter"; break }
"saba_scorm.js" { $tool = "Saba"; break }
}
if($swfCount -gt 0) {
$flashPercent = ($swfCount / $fileList.Count).ToString("P")
} else {
$flashPercent = "0 %"
}
}
$zip.Dispose()
# * Per-PIF CSV: CourseName, CourseIteration, Authoring Tool, Total Files, Total Flash, Percentage Flash
[pscustomobject]@{
CourseName = $folder.Name.Replace(",", "")
CourseIteration = $iteration
PackageName = $zipPath.Name.Replace(",", "")
AuthoringTool = $tool
ContentType = $contentType
TotalFiles = $fileList.Count
TotalFlash = $swfCount
FlashPercent = $flashPercent
CreationTime = $zipPath.CreationTime
LastWrite = $zipPath.LastWriteTime
FullPath = $zipPath.FullName
}
Write-Host " -[adding]: $($zipPath.Name)"
}
}
#Export everything
Write-Host "`nExporting results to $($outscorm)`n"
$Result | Export-Csv $out