Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F64244333
bamc_questions.sh
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Sat, May 25, 14:25
Size
2 KB
Mime Type
text/x-shellscript
Expires
Mon, May 27, 14:25 (2 d)
Engine
blob
Format
Raw Data
Handle
17872477
Attached To
R1066 amc-cape
bamc_questions.sh
View Options
#!/bin/bash
function
action_check-questions
()
{
assert_workspace;
if
[
$?
-eq 1
]
;
then return
1;
fi
perma
"Checking questions (LaTeX syntax)"
local
cwd
=
$(
pwd
)
local
TMP
=
"/tmp/bamc"
local
SRC
=
$DIR_WORKSPACE
/
$DIR_QUESTIONS
local
TEX
=
$TMP
/question.tex
local
rc
=
0
# Create tmp dir
mkdir -p
$TMP
# Import question resources (media file, etc.)
for
stuff in
$(
find
$SRC
-type f -not -name
'*.tex'
| grep -v
'\.ignore'
| sort
)
;
do
verbose
"Copying resource: $stuff ..."
cp
$stuff
$TMP
done
# Compile questions
for
q in
$(
find
$SRC
-type f -name
'*.tex'
| grep -v
'\.ignore'
| sort
)
;
do
q_short
=
$(
echo
$q
| sed
"s?$DIR_QUESTIONS/?|?"
| cut -d
'|'
-f 2
)
# Check EOL mode
verbose
"Checking EOL mode of question '$q_short'"
dos2unix <
$q
| cmp -s -
$q
if
[
$?
-ne 0
]
;
then
warn
"Some lines are in DOS mode."
;
fi
mac2unix <
$q
| cmp -s -
$q
if
[
$?
-ne 0
]
;
then
warn
"Some lines are in Mac mode."
;
fi
# Check encoding
verbose
"Checking encoding of question '$q_short'"
if
[
"$(get_file_encoding $q)"
!
=
"unicode"
]
;
then
warn
"Incorrect file encoding: $(get_file_encoding $q)"
fi
# Compile
rm -f
$TMP
/question.*
verbose
"Compiling question '$q_short'"
echo_header_part >
$TEX
cat
$q
>>
$TEX
echo_footer_part >>
$TEX
cd
$TMP
pdflatex -interaction
=
nonstopmode question.tex > /dev/null 2>&1
rc
=
$?
if
[
$rc
-ne 0
]
;
then
error
"Question '$q_short' does not compile :("
;
((
rc++
))
fi
cd
$cwd
done
# Done
rm -f
$TMP
/*
return
$rc
}
function
echo_header_part
()
{
cat
<< EOF
\documentclass[a4paper]{article}
\usepackage[utf8x]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{multicol}
\usepackage[francais,bloc,catalog]{automultiplechoice}
%% ===============
\usepackage{graphicx}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{fancyhdr}
\usepackage{tikz}
\newcommand{\fracpd}[2]{\frac{\partial #1}{\partial #2}} % partielle Ableitung
\newcommand{\dfracpd}[2]{\dfrac{\partial #1}{\partial #2}} % partielle Ableitung
%% ===============
\newcommand{\TRUE}{
\bareme{b=1,m=-1}
\begin{choiceshoriz}[o]
\bonne{VRAI}
\mauvaise{FAUX}
\end{choiceshoriz}
}
\newcommand{\FALSE}{
\bareme{b=1,m=-1}
\begin{choiceshoriz}[o]
\mauvaise{VRAI}
\bonne{FAUX}
\end{choiceshoriz}
}
\begin{document}
EOF
}
function
echo_footer_part
()
{
cat
<< EOF
\end{document}
EOF
}
# EOF
Event Timeline
Log In to Comment