-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakeAssignment.php
More file actions
37 lines (31 loc) · 960 Bytes
/
MakeAssignment.php
File metadata and controls
37 lines (31 loc) · 960 Bytes
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
<?php
function MakeAssignment($SubjectId) {
$Assignment = array();
// Get the SubjectInt
$SubjectId = strtolower($SubjectId);
$SubjectInt = intval($SubjectId, 36);
// Set the Seed
srand($SubjectInt % 4294967295);
// Choose a group
$Groups = array(
'Ani','Art','Fac',
'Foo','Lin','Obj',
'Pla','Spa','Tex');
$GroupId = $Groups[rand(0, 8)];
$Assignment['GroupId'] = $GroupId;
// Construct an (un-shuffled) array of ImgNames
$ImgNames = array();
for ($ii = 0; $ii < 6; $ii++) {
$ImgNames[$ii] = sprintf("%s%01d", $GroupId, $ii);
}
// Construct a shuffled image permutation
shuffle($ImgNames);
$ImgPerm['A'] = $ImgNames[0];
$ImgPerm['B'] = $ImgNames[1];
$ImgPerm['C'] = $ImgNames[2];
$ImgPerm['D'] = $ImgNames[3];
$ImgPerm['E'] = $ImgNames[4];
$ImgPerm['F'] = $ImgNames[5];
$Assignment['ImgPerm'] = $ImgPerm;
return $Assignment;
}