Rev 16249 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
11189 | bpr | 1 | #!/bin/sh |
2 | |||
3 | ######################################################################## |
||
4 | ######################################################################## |
||
5 | # script pour reperer des erreurs html dans les modules pedagogiques |
||
6 | ######################################################################## |
||
16239 | reyssat | 7 | #tidy=/usr/local/bin/tidy # not used any more ? |
11189 | bpr | 8 | OUTDIR=result |
16239 | reyssat | 9 | ## Execute from $wimshome/wimstest/validation |
10 | ## The validator w3c-validator.py should be in this directory |
||
11 | ## as well as the cleaning script validator_clean.pl if needed (C=1 below) |
||
11189 | bpr | 12 | ## |
16239 | reyssat | 13 | ## usage (results will be in validation/result ) : |
14 | ##./checkhtmlwims C XXX |
||
15 | ## where C is 0 (no cleaning) or 1 (erases uninteresting errors) |
||
16 | ## and XXX may be a module (ex. U1/analysis/oefderint.fr) |
||
17 | ## or a category of modules (ex. U1/analysis) |
||
18 | ## or a comma-separated list of zones (ex. U1,E5,Lang,devel) |
||
19 | ## or empty : in this case all "level"-zones (E1..U4) and Lang are treated. |
||
20 | ## |
||
21 | ## Example : ./checkhtmlwims 1 U1/analysis/oefderint.fr |
||
22 | ## |
||
23 | ## ATTENTION = etre en mode non debug (sinon la recuperation des sessions ne fonctionne pas) |
||
11189 | bpr | 24 | ## il faudrait faire autrement pour les detruire. |
25 | |||
11198 | bpr | 26 | wimsdir=`pwd` |
27 | ### modify if one prefer to launch from wims directory |
||
28 | moddir="$wimsdir/../../public_html/modules" |
||
29 | configdir=. |
||
11502 | bpr | 30 | zone=$2 |
31 | if [ $zone ]; then |
||
32 | echo $zone; |
||
33 | else |
||
34 | zone='E1 E2 E3 E4 E5 E6 H1 H2 H3 H4 H5 H6 U1 U2 U3 U4 Lang' |
||
35 | fi; |
||
16239 | reyssat | 36 | |
16249 | reyssat | 37 | ## level of second argument under the directory public_html/modules = number of non terminal "/" characters |
38 | ## used to know if argument is a zone, a category or a module. |
||
16239 | reyssat | 39 | level=`echo $2 | grep -o '/.' | wc -l` |
16249 | reyssat | 40 | |
11502 | bpr | 41 | clean=$1; |
11189 | bpr | 42 | wordtosearch="missing" |
43 | searchmathml="ERROR" |
||
44 | searchmathml2="Unknown" |
||
45 | |||
46 | #tidy=$tidy -qe --doctype html5 -latin1 -config $config/config.txt |
||
47 | ##https://github.com/srackham/w3c-validator/blob/master/w3c-validator.py |
||
11198 | bpr | 48 | validator="$configdir/w3c-validator.py" |
11502 | bpr | 49 | cleanup="$configdir/validator_clean.pl --option=$clean" |
11189 | bpr | 50 | mkdir -p $OUTDIR |
51 | #rm -f html.log;rm -f scorelog ;rm -f htmldoclog ;rm -f pari.log;rm -f maxima.log;rm -f gap.log;rm -f octave.log;rm -r mathml.log |
||
52 | |||
16249 | reyssat | 53 | ## chain to look for in Exindex : here is the list of oef exercises of the module |
11189 | bpr | 54 | mot='!set exolist =!char 1 to -2 of' |
55 | forsession='The server is under debug mode. Your session: ' |
||
56 | ### chercher la liste des exos |
||
57 | ###!set exolist =!char 1 to -2 of mult1,mult2,mult3,mult4,mult5,mult6,mult7,mult8,division1,division2,division3, |
||
58 | ###dans Exindex |
||
59 | check ( ) { |
||
11502 | bpr | 60 | mod=$2 |
61 | outputdir=$OUTDIR/$3/$4$5 |
||
62 | clean=$1 |
||
11189 | bpr | 63 | mkdir -p $outputdir |
11502 | bpr | 64 | rm -f $outputdir/html.log $outputdir/scorelog $outputdir/pari.log $outputdir/maxima.log $outputdir/gap.log $outputdir/octave.log $output/mathml.log $output/htmlintro.log |
11189 | bpr | 65 | |
11535 | bpr | 66 | author=`grep "author" $moddir/$mod/INDEX | sed -e "s/author=//g"` |
67 | email=`grep "\baddress" $moddir/$mod/INDEX | sed -e "s/address=//g"` |
||
11189 | bpr | 68 | category=`grep category $moddir/$mod/INDEX | sed -e "s/category=//g"` |
13457 | obado | 69 | message=`wget "http://127.0.0.1/wims/wims.cgi?module=$mod" -nv -O test_intro.html ; $validator test_intro.html 2>&1; ` |
11189 | bpr | 70 | if [ "$message" ] ; then |
16352 | bpr | 71 | echo -e "BEGIN $author\t$email\tmodule=$mod\tintro\n$message END\n" > $outputdir/html.log ; |
11189 | bpr | 72 | fi |
73 | if [ "$category" = "document" ] ; then |
||
74 | lblock=`ls $moddir/$mod/doc/1/*.def` ; |
||
75 | for bl in $lblock ; do |
||
76 | #####doc=1 |
||
77 | block=`basename $bl .def` |
||
78 | message=`wget "http://127.0.0.1/wims/wims.cgi?module=$mod&doc=1&block=$block&job=read" -nv -O test.html ; $validator test.html 2>&1; ` |
||
79 | # session=`grep -e "$forsession\s*[[:alnum:]]" test.html | sed -e "s/The server is under debug mode. Your session: //g" | sed -e "s|. <br />||g" sed -e "s| ||g"` ; |
||
80 | if [ "$message" ] ; then |
||
16352 | bpr | 81 | echo -e "BEGIN $author\t$email\tmodule=$mod block=$block\n$message END\n" >> $outputdir/html.log ; |
11189 | bpr | 82 | fi ; |
83 | mathml=`grep "$searchmathml" test.html` ; |
||
84 | if [ "$mathml" ] ; then |
||
11535 | bpr | 85 | echo -e "$author\t$email\tmodule=$mod block=$block\t$mathml\n" >> $outputdir/mathml.log |
11189 | bpr | 86 | fi |
87 | mathml=`grep "$searchmathml2" test.html` ; |
||
88 | if [ "$mathml" ] ; then |
||
11535 | bpr | 89 | echo -e "$author\t$email\tmodule=$mod block=$block\t$mathml\n" >> $outputdir/mathml.log |
11189 | bpr | 90 | fi |
91 | pari=`grep -A4 'ERROR from pari' test.html` |
||
92 | if [ "$pari" ] ; then |
||
11535 | bpr | 93 | echo -e "$author\t$email\tmodule=$mod&block=$block\t$pari\n" >> $outputdir/pari.log ; |
11189 | bpr | 94 | fi ; |
95 | maxima=`grep -A4 'ERROR from maxima' test.html` |
||
96 | if [ "$maxima" ] ; then |
||
11535 | bpr | 97 | echo -e "$author\t$email\tmodule=$mod&block=$block\t$maxima\n" >> $outputdir/maxima.log ; |
11189 | bpr | 98 | fi ; |
99 | octave=`grep -A4 'ERROR from octave' test.html` |
||
100 | if [ "$octave" ] ; then |
||
11535 | bpr | 101 | echo -e "$author\t$email\tmodule=$mod&block=$block\t$octave\n" >> $outputdir/octave.log ; |
11189 | bpr | 102 | fi ; |
103 | gap=`grep -A4 'ERROR from gap' test.html` |
||
104 | if [ "$gap" ] ; then |
||
11535 | bpr | 105 | echo -e "$author\t$email\tmodule=$mod&block=$block\t$gap\n" >> $outputdir/gap.log ; |
11189 | bpr | 106 | fi ; |
107 | if [ "$session" ] ; then |
||
108 | # rm -rf $wimsdir/tmp/sessions/$session |
||
109 | # rm -rf $wimsdir/sessions/$session |
||
110 | echo $session |
||
111 | fi ; |
||
112 | done ; |
||
11502 | bpr | 113 | |
114 | $cleanup --dir=$outputdir |
||
11189 | bpr | 115 | else |
12450 | bpr | 116 | if [ -f $moddir/$mod/Exindex ]; then |
117 | lexo=`grep "$mot" "$moddir/$mod/Exindex" | sed -e "s/$mot//g"| sed -e "s/,/ /g" 2>&1` ; |
||
118 | fi; |
||
119 | if [ "$lexo" ]; then motexo="exo"; |
||
120 | else |
||
16249 | reyssat | 121 | ## Here no Exindex was found. If module by Joke Evers, there is usually an "exos" subdirectory |
122 | ## in which the exercises files are named exoxxx and the url is wims.cgi?module=...&subject=xxx |
||
123 | ## This case is treated by the following. Others (some modules by Xiao) just generate an error message. |
||
12450 | bpr | 124 | lexo=`ls "$moddir/$mod/exos" | grep exo | sed -e "s/exo//g"`; |
125 | motexo="subject"; |
||
126 | fi; |
||
127 | |||
11189 | bpr | 128 | scoring=`grep scoring $moddir/$mod/INDEX` |
129 | pari='' ; |
||
130 | for exo in $lexo ; do |
||
12450 | bpr | 131 | message=`wget "http://127.0.0.1/wims/wims.cgi?module=$mod&$motexo=$exo&cmd=new" -nv -O test.html ; $validator test.html 2>&1 ;` |
11189 | bpr | 132 | session=`grep -e "$forsession\s*[[:alnum:]]" test.html | sed -e "s/The server is under debug mode. Your session: //g" | sed -e "s|. <br />||g" | sed -e "s| ||g"` ; |
133 | |||
134 | if [ "$message" ] ; then |
||
16352 | bpr | 135 | echo -e "BEGIN $author\t$email\tmodule=$mod&$motexo=$exo\n$message END\n" >> $outputdir/html.log ; |
11189 | bpr | 136 | fi ; |
137 | ## inutile d'utiliser tidy |
||
138 | mathml=`grep "$searchmathml" test.html` ; |
||
139 | if [ "$mathml" ] ; then |
||
12450 | bpr | 140 | echo -e "$author\t$email\tmodule=$mod&$motexo=$exo\t$mathml\n" >> $outputdir/mathml.log |
11189 | bpr | 141 | fi |
142 | mathml=`grep "$searchmathml2" test.html` ; |
||
143 | if [ "$mathml" ] ; then |
||
12450 | bpr | 144 | echo -e "$author\t$email\tmodule=$mod&$motexo=$exo\t$mathml\n" >> $outputdir/mathml.log |
11189 | bpr | 145 | fi |
146 | pari=`grep -A4 'ERROR from pari' test.html` |
||
147 | if [ "$pari" ] ; then |
||
12450 | bpr | 148 | echo -e "$author\t$email\tmodule=$mod&$motexo=$exo\t$pari\n" >> $outputdir/pari.log ; |
11189 | bpr | 149 | fi ; |
150 | maxima=`grep -A4 'ERROR from maxima' test.html` |
||
151 | if [ "$maxima" ] ; then |
||
12450 | bpr | 152 | echo -e "$author\t$email\tmodule=$mod&$motexo=$exo\t$maxima" >> $outputdir/maxima.log ; |
11189 | bpr | 153 | fi ; |
154 | octave=`grep -A4 'ERROR from octave' test.html` |
||
155 | if [ "$octave" ] ; then |
||
12450 | bpr | 156 | echo -e "$author\t$email\tmodule=$mod&$motexo=$exo\t$octave" >> $outputdir/octave.log ; |
11189 | bpr | 157 | fi ; |
158 | gap=`grep -A4 'ERROR from gap' test.html` |
||
159 | if [ "$gap" ] ; then |
||
12450 | bpr | 160 | echo -e "$author\t$email\tmodule=$mod&$motexo=$exo\t$gap" >> $outputdir/gap.log ; |
11189 | bpr | 161 | fi ; |
162 | if [ "$session" ] ; then |
||
163 | # rm -rf $wimsdir/tmp/sessions/$session |
||
164 | # rm -rf $wimsdir/sessions/$session |
||
165 | echo $session |
||
166 | fi; |
||
167 | done ; |
||
11502 | bpr | 168 | #echo "$scoring\t$author\t$email\tmodule=$mod" >> $outputdir/scorelog ; |
169 | $cleanup --dir=$outputdir ; |
||
11559 | bpr | 170 | fi |
171 | find $OUTDIR -type d -exec rmdir -p '{}' \; 2> /dev/null |
||
11189 | bpr | 172 | } |
16239 | reyssat | 173 | |
11502 | bpr | 174 | if [ $2 ] ; then |
16239 | reyssat | 175 | if [ $level == 2 ] ; then # ex. E5/francais/oeflecture.fr |
176 | check $clean "$2" one |
||
177 | elif [ $level == 1 ] ; then # ex. E5/francais |
||
178 | z=`echo $2 | sed -e 's!\/.*!!g'` |
||
179 | c=`echo $2 | sed -e 's!.*\/!!g'` |
||
180 | for a in `ls "$moddir/$z/$c"` ; do |
||
181 | check $clean $z/$c/$a $z $c $a |
||
182 | done ; |
||
183 | else # ex. Lang,E5 |
||
184 | zone=`echo $2 | sed -e 's!,! !g'` |
||
185 | for z in $zone; do |
||
186 | for c in `ls "$moddir/$z"` ; do |
||
187 | for a in `ls "$moddir/$z/$c"` ; do |
||
188 | check $clean $z/$c/$a $z $c $a |
||
189 | done ; |
||
190 | done ; |
||
191 | done ; |
||
192 | fi |
||
193 | else # no argument |
||
11189 | bpr | 194 | for z in $zone; do |
195 | for c in `ls "$moddir/$z"` ; do |
||
196 | for a in `ls "$moddir/$z/$c"` ; do |
||
11502 | bpr | 197 | check $clean $z/$c/$a $z $c $a |
11189 | bpr | 198 | done ; |
199 | done ; |
||
200 | done; |
||
201 | fi |