-
Notifications
You must be signed in to change notification settings - Fork 229
/
Copy patha01.php
executable file
·112 lines (96 loc) · 2.68 KB
/
a01.php
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
<?php // do some grading
$possgrade = 0;
$grade = 0;
$titlematch = false;
$dom = new DOMDocument;
@$dom->loadHTML($data);
print("Checking title tag for correct string...\n");
$titlematch = titleCheck($dom);
if ( $titlematch ) {
echo("Found correct text in title tag\n");
} else {
echo("<span class=\"incorrect\">Did not find ... ".htmlentities(getTitleString())." ... in the title tag\n");
echo("Document will be checked, but the grade will not be recorded...</span>\n");
}
print("Checking Document Structure.\n");
$possgrade++;
if ( tagExists($dom, 'html') ) $grade++;
progressMessage($grade,$possgrade);
$possgrade++;
if ( tagExists($dom, 'head') ) $grade++;
progressMessage($grade,$possgrade);
$possgrade++;
if ( tagExists($dom, 'body') ) $grade++;
progressMessage($grade,$possgrade);
$possgrade++;
if ( tagExists($dom, 'h1') ) $grade++;
progressMessage($grade,$possgrade);
$possgrade++;
if ( tagExists($dom, 'div') ) $grade++;
progressMessage($grade,$possgrade);
$possgrade++;
$count = getTagCount($dom, 'strong');
if ( $count >= 1 ) {
goodmessage('Found at least one strong tag');
$grade++;
} else {
badmessage('Did not find any strong tags');
}
progressMessage($grade,$possgrade);
$possgrade++;
$count = getTagCount($dom, 'b');
if ( $count >= 1 ) {
badmessage('Found at least one b (bold) tag');
} else {
$grade++;
goodmessage('Did not find any b (bold) tags');
}
progressMessage($grade,$possgrade);
$possgrade++;
$count = getTagCount($dom, 'em');
if ( $count >= 1 ) {
goodmessage('Found at least one em (emphasis) tag');
$grade++;
} else {
badmessage('Did not find any em (emphasis) tags');
}
progressMessage($grade,$possgrade);
$possgrade++;
$count = getTagCount($dom, 'i');
if ( $count >= 1 ) {
badmessage('Found at least one i (italics) tag');
} else {
$grade++;
goodmessage('Did not find any i (italics) tags');
}
progressMessage($grade,$possgrade);
$possgrade++;
$count = getTagCount($dom, 'span');
if ( $count >= 1 ) {
$grade++;
goodmessage('Found at least one span tag');
} else {
badmessage('Wanted at least one span tag, found '.$count."\n");
}
progressMessage($grade,$possgrade);
$possgrade++;
if ( tagExists($dom, 'ul') ) $grade++;
progressMessage($grade,$possgrade);
$possgrade++;
$count = getTagCount($dom, 'li');
if ( $count == 3 ) {
$grade++;
goodmessage('Found three li tags');
} else {
badmessage('Wanted three li tags, found '.$count."\n");
}
progressMessage($grade,$possgrade);
$possgrade++;
$count = getTagCount($dom, 'a');
if ( $count == 3 ) {
$grade++;
goodmessage('Found three a (anchor) tags');
} else {
badmessage('Wanted three a (anchor) tags, found '.$count."\n");
}
progressMessage($grade,$possgrade);