Which switch would you use with the echo command to enable the "backslash" options? ------ -e
Which switch would you use with the find utility to cause another command to run without prompting you? ------ -exec
#shell script
#!/bin/sh
converted="converted.xml"
sep="------"
if [[ $# -ne 1 ]]
then
echo "$0 file_to_convert"
exit 1
fi
echo "starting conversion to moodle xml"
if [[ -f $converted ]]
then
echo "$converted already exists"
rm $converted
fi
echo '<?xml version="1.0" ?>' > $converted
echo "<quiz>" >> $converted
i=1
cat $1 | while read line
do
q=`echo $line | awk -F"$sep" '{ print $1 }'`
a=`echo $line | awk -F"$sep" '{ print $2 }'`
echo '<question type="shortanswer">' >> $converted
echo '<name>' >> $converted
echo "<text>Question $i</text>" >> $converted
echo '</name>' >> $converted
echo '<questiontext format="html">' >> $converted
echo "<text>$q</text>" >> $converted
echo '</questiontext>' >> $converted
echo '<answer fraction = "100">' >> $converted
echo "<text>$a</text>" >> $converted
echo '<feedback><text>Correct!</text></feedback>' >>$converted
echo '</answer>' >> $converted
echo '</question>' >> $converted
((i=i+1))
done
echo '</quiz>' >> $converted
No comments:
Post a Comment