diff --git a/conf/bamc.conf b/conf/bamc.conf index 8c0a7b2..017e65d 100644 --- a/conf/bamc.conf +++ b/conf/bamc.conf @@ -1,57 +1,58 @@ #!/bin/bash # Workspace DIR_CONFIG='conf' DIR_QUESTIONS='questions' DIR_EXAMS='exams' DIR_PROJECTS='projects' +DIR_COMMON='common' FILE_WORKSPACE_ROOT=".workspace_root" # Configuration dirs DIR_DATA=$(realpath $SPATH/../data) DIR_WORKSPACE_TEMPLATE=$DIR_DATA/workspace DIR_EXAM_TEMPLATES=$DIR_DATA/templates # Template DEFAULT_EXAM_TEMPLATE="default" FILE_PROJECT_BUILD="project_build_script.sh" # Configuration files FILE_AMC_OPTIONS='options.xml' # Output dirs DIR_PROJECTS='projects' DIR_SAMPLES='pdf-samples' DIR_CATALOGS='pdf-catalogs' DIR_BLANKS='pdf-blanks' DIR_PDFS='pdf-exams' DIR_STUDENTS='pdf-students' # Intput files FILE_SECTIONS='sections.conf' FILE_EXAM='exam.conf' FILE_STUDENTS='students.csv' # Variables EXTRA_STUDENTS=9 PDFLATEX_RUNS=1 return 0 FILE_SAMPLE_CSV='sample.csv' FILE_EXTRA_CSV='extra.csv' FILE_BLANK_CSV='blank.csv' FILE_AMC_MAILING='mailing.xml' FILE_LIST_MAIN='list.tex' FILE_LIST_TSTART='start_tab.tex' FILE_LIST_TEND='end_tab.tex' # OUTPUT FILES FILE_RESULTS='raw' FILE_EMAILS_SCRIPT='send_emails.sh' FILE_LIST_ROWS='rows.tex' # VARIABLES DEFAULT_EMAIL='pierre-olivier.valles@epfl.ch' LIST_ROWS_PER_PAGE=50 LIST_MAX_CHAR=30 diff --git a/data/templates/maths/base/style_professor.tex b/data/templates/maths/base/style_professor.tex index f8f3295..de543ed 100644 --- a/data/templates/maths/base/style_professor.tex +++ b/data/templates/maths/base/style_professor.tex @@ -1,53 +1,6 @@ %% New commands, professor specific -\newcommand\RR{\mathbb{R}} -\newcommand\PP{\mathbb{P}} -\newcommand{\Col}{\mathop{\rm Col}\nolimits} -\newcommand{\Nul}{\mathop{\rm Ker}\nolimits} -\newcommand{\Lign}{\mathop{\rm Lig}\nolimits} - -\newcommand{\Span}{\mathop{\rm Vect}\nolimits} -\renewcommand{\vec}[1]{\mathbf{#1}} -\newcommand{\Poly}[1]{\mathbb{P}_#1} - -\newcommand{\Base}[1]{\left\{#1\right\}} - -\newcommand{\Vector}[1]{\left[ - \begin{array}{c} - #1 - \end{array} -\right] -} - -\newenvironment{Matrix}[1]{\left[ - \begin{array}[r]{#1}}{ - \end{array} -\right] -} - -% Some namenclature used: -\newcommand{\dimension}{taille} % used for size of a matrix. usually dimension ou taille - %% Questions %%% \baremeDefautS{b=3,m=-1} \baremeDefautM{b=2,m=0} -\newcommand{\VERO}{ - \bareme{b=1,m=-1} - \begin{choiceshoriz}[o] - \bonne{VRAI} - \mauvaise{FAUX} - \end{choiceshoriz} - -\medskip -} - -\newcommand{\FALSO}{ - \bareme{b=1,m=-1} - \begin{choiceshoriz}[o] - \mauvaise{VRAI} - \bonne{FAUX} - \end{choiceshoriz} - -\medskip -} diff --git a/data/templates/maths/de/true-false.tex b/data/templates/maths/de/true-false.tex index c06d683..ffe6ddb 100644 --- a/data/templates/maths/de/true-false.tex +++ b/data/templates/maths/de/true-false.tex @@ -1,23 +1,43 @@ %% TRUE / FALSE commands - GERMAN \AMCtext{draft}{ENTWURF} \newcommand{\TRUE}{ \bareme{b=1,m=-1} \begin{choiceshoriz}[o] \bonne{WAHR} \mauvaise{FALSCH} \end{choiceshoriz} \medskip } \newcommand{\FALSE}{ \bareme{b=1,m=-1} \begin{choiceshoriz}[o] \mauvaise{WAHR} \bonne{FALSCH} \end{choiceshoriz} \medskip } -%% End of file \ No newline at end of file +% For compat. reasons... + +\newcommand{\VERO}{ + \bareme{b=1,m=-1} + \begin{choiceshoriz}[o] + \bonne{WAHR} + \mauvaise{FALSCH} + \end{choiceshoriz} +\medskip +} + +\newcommand{\FALSO}{ + \bareme{b=1,m=-1} + \begin{choiceshoriz}[o] + \mauvaise{WAHR} + \bonne{FALSCH} + \end{choiceshoriz} +\medskip +} + +%% End of file diff --git a/data/templates/maths/en/true-false.tex b/data/templates/maths/en/true-false.tex index 9dbb04a..32a9677 100644 --- a/data/templates/maths/en/true-false.tex +++ b/data/templates/maths/en/true-false.tex @@ -1,21 +1,41 @@ %% TRUE / FALSE commands - ENGLISH \newcommand{\TRUE}{ \bareme{b=1,m=-1} \begin{choiceshoriz}[o] \bonne{TRUE} \mauvaise{FALSE} \end{choiceshoriz} \medskip } \newcommand{\FALSE}{ \bareme{b=1,m=-1} \begin{choiceshoriz}[o] \mauvaise{TRUE} \bonne{FALSE} \end{choiceshoriz} \medskip } -%% End of file \ No newline at end of file +% For compat. reasons... + +\newcommand{\VERO}{ + \bareme{b=1,m=-1} + \begin{choiceshoriz}[o] + \bonne{TRUE} + \mauvaise{FALSE} + \end{choiceshoriz} +\medskip +} + +\newcommand{\FALSO}{ + \bareme{b=1,m=-1} + \begin{choiceshoriz}[o] + \mauvaise{TRUE} + \bonne{FALSE} + \end{choiceshoriz} +\medskip +} + +%% End of file diff --git a/data/templates/maths/fr/true-false.tex b/data/templates/maths/fr/true-false.tex index 753487d..0bd11b2 100644 --- a/data/templates/maths/fr/true-false.tex +++ b/data/templates/maths/fr/true-false.tex @@ -1,21 +1,41 @@ %% TRUE / FALSE commands - FRENCH \newcommand{\TRUE}{ \bareme{b=1,m=-1} \begin{choiceshoriz}[o] \bonne{VRAI} \mauvaise{FAUX} \end{choiceshoriz} \medskip } \newcommand{\FALSE}{ \bareme{b=1,m=-1} \begin{choiceshoriz}[o] \mauvaise{VRAI} \bonne{FAUX} \end{choiceshoriz} \medskip } -%% End of file \ No newline at end of file +% For compat. reasons... + +\newcommand{\VERO}{ + \bareme{b=1,m=-1} + \begin{choiceshoriz}[o] + \bonne{VRAI} + \mauvaise{FAUX} + \end{choiceshoriz} +\medskip +} + +\newcommand{\FALSO}{ + \bareme{b=1,m=-1} + \begin{choiceshoriz}[o] + \mauvaise{VRAI} + \bonne{FAUX} + \end{choiceshoriz} +\medskip +} + +%% End of file diff --git a/data/templates/maths/project_build_script.sh b/data/templates/maths/project_build_script.sh index 082bfce..fc6082c 100644 --- a/data/templates/maths/project_build_script.sh +++ b/data/templates/maths/project_build_script.sh @@ -1,214 +1,234 @@ #!/bin/bash # This part is specific to the template. # Entry point from bamc: build_project $exam # $exam: name of the exam to build # # Useful variable # --------------- # DIR_WORKSPACE [current workspace dir (absolute)] # DIR_PROJECTS [projects target directory] # DIR_EXAMS [exams'directory in workspace] e.g. $DIR_WORKSPACE/$DIR_EXAMS/$exam # DIR_PROJECTS [projects's directory in workspace] # DIR_EXAM_TEMPLATE [directory of the exam template in use] # FILE_STUDENTS # ... # see 'conf/bamc.conf' for full reference # # Useful functions # ---------------- # verbose "text" # debug "text" # get_lang $exam # ... # see 'lib/bash/*.sh' files for full reference function build_project() { local exam=$1 lang=$(get_lang $exam) assert_exam $exam verbose "Project '$exam' uses '$lang' language" if [ $? -eq 1 ]; then return 1; fi verbose "Building AMC project for '$exam' in workspace '$DIR_WORKSPACE'..." # Project structure build_amc_project $exam if [ $? -ne 0 ]; then error "Could not build AMC project :("; return 1; fi # Build LaTeX sections build_sections $exam $lang if [ $? -ne 0 ]; then error "Could not build project sections :("; return 1; fi # Import LaTeX files import_tex_files $exam $lang if [ $? -ne 0 ]; then error "Could not import LaTeX files :("; return 1; fi # Import local LaTeX files override_tex_files $exam if [ $? -ne 0 ]; then error "Could not override LaTeX files :("; return 1; fi # Customize LaTeX file customize_tex_files $exam $lang if [ $? -ne 0 ]; then error "Could not customize LaTeX files :("; return 1; fi # Import media files add_media_files $exam if [ $? -ne 0 ]; then error "Could not import media files :("; return 1; fi # Build student list file import_student_file $exam if [ $? -ne 0 ]; then error "Could not create student list :("; return 1; fi return 0 } function import_student_file() { verbose "Customizing student files" local project=$DIR_WORKSPACE/$DIR_PROJECTS/$1 local exam=$DIR_WORKSPACE/$DIR_EXAMS/$1 local lang=$2 local FILE=$exam/$FILE_STUDENTS check_file_exists $FILE if [ $? -ne 0 ]; then return 1; fi cp $FILE $project/$FILE_STUDENTS # Add extra students local nb IFS=$'\n' local id=$(tail -n 1 $project/$FILE_STUDENTS | cut -d ',' -f 1) local sample=$(head -n 1 $DIR_EXAM_TEMPLATE/csv/extra.csv) nb=0 while [ $nb -lt $EXTRA_STUDENTS ]; do ((nb++)) ((id++)) echo $sample |\ sed "s/#NB#/$nb/g" |\ sed "s/#ID#/$id/g" |\ sed "s/#SCIPER#/FAKE-$nb/g" |\ sed "s/#EMAIL#/$DEFAULT_EMAIL/g" |\ sed "s/#SEMESTER#/$SEMESTER/g" >> $project/$FILE_STUDENTS done return 0 } function add_media_files() { verbose "Importing media files" local project=$DIR_WORKSPACE/$DIR_PROJECTS/$1 cp $DIR_EXAM_TEMPLATE/media/* $project/media/ } function customize_tex_files() { verbose "Customizing LaTeX files" local project=$DIR_WORKSPACE/$DIR_PROJECTS/$1 local exam=$DIR_WORKSPACE/$DIR_EXAMS/$1 local lang=$2 local replace IFS=$'\n' local FILE=$exam/$FILE_EXAM check_file_exists $FILE if [ $? -ne 0 ]; then return 1; fi # professor.tex local prof_file=$project/professor.tex check_file_exists $prof_file if [ $? -ne 0 ]; then return 1; fi for replace in $(cat $FILE); do replace_in_file "#$(echo $replace | cut -d ':' -f 1)#" "$(echo $replace | cut -d ':' -f 2-)" $prof_file done # exam.tex replace_in_file "#LANG#" $(echo $lang | tr '[a-z]' '[A-Z]') $project/exam.tex - + + # Add extra_packages.tex file + if [ -r $project/common_packages.tex ]; then + replace_in_file '% #COMMON_PACKAGES#' '\\input{./common_packages.tex}' $project/exam.tex + fi + # Add extra_packages.tex file + if [ -r $project/common_commands.tex ]; then + replace_in_file '% #COMMON_COMMANDS#' '\\input{./common_commands.tex}' $project/exam.tex + fi + # Add extra_section.tex file - if [ -r $exam/extra_section.tex ]; then + if [ -r $project/extra_section.tex ]; then replace_in_file '% #EXTRA_SECTION#' '\\input{./extra_section.tex}' $project/exam.tex fi # Add extra_packages.tex file - if [ -r $exam/extra_packages.tex ]; then + if [ -r $project/extra_packages.tex ]; then replace_in_file '% #EXTRA_PACKAGES#' '\\input{./extra_packages.tex}' $project/exam.tex fi # Add extra_packages.tex file - if [ -r $exam/extra_commands.tex ]; then + if [ -r $project/extra_commands.tex ]; then replace_in_file '% #EXTRA_COMMANDS#' '\\input{./extra_commands.tex}' $project/exam.tex fi return 0 } function override_tex_files() { - verbose "Overriding LaTeX files (if needed)" + verbose "Importing supplementary LaTeX files" + local common=$DIR_WORKSPACE/$DIR_COMMON/ local exam=$DIR_WORKSPACE/$DIR_EXAMS/$1 local project=$DIR_WORKSPACE/$DIR_PROJECTS/$1 local f + + # Common + for f in $(find $common/ -type f -name '*.tex'); do + verbose "- Common LaTeX file found: $f" + done + find $common/ -type f -name '*.tex' -exec cp {} $project/ \; + + # Extra for f in $(find $exam/ -type f -name '*.tex'); do - verbose "- LaTeX override file found: $f" + verbose "- Extra LaTeX file found: $f" done find $exam/ -type f -name '*.tex' -exec cp {} $project/ \; + + return 0 } function import_tex_files() { verbose "Importing LaTeX files" local project=$DIR_WORKSPACE/$DIR_PROJECTS/$1 local lang=$2 cp $DIR_EXAM_TEMPLATE/base/* $project/ cp $DIR_EXAM_TEMPLATE/$lang/* $project/ return 0 } function build_amc_project() { local project=$DIR_WORKSPACE/$DIR_PROJECTS/$1 verbose "Creating AMC project structure" mkdir -p $project/cr/corrections/jpg mkdir -p $project/cr/corrections/pdf mkdir -p $project/cr/diagnostic mkdir -p $project/cr/zooms mkdir -p $project/data mkdir -p $project/exports mkdir -p $project/scans mkdir -p $project/copies mkdir -p $project/media cp $DIR_EXAM_TEMPLATE/config/$FILE_AMC_OPTIONS $project/$FILE_AMC_OPTIONS return $? } function build_sections() { local project=$DIR_WORKSPACE/$DIR_PROJECTS/$1 local exam=$DIR_WORKSPACE/$DIR_EXAMS/$1 local lang=$2 local question_file question section_file section local IFS=$'\n' FILE=$exam/$FILE_SECTIONS verbose "Importing questions" check_file_exists $FILE if [ $? -ne 0 ]; then return 1; fi local section_num=0 rm -f $project/sections.tex $project/random-sections.tex for section in $(cat $FILE); do ((section_num++)) section_file=$project/section_${section_num}.tex rm -f $section_file for question in $(echo $section | tr ',' '\n'); do verbose "Adding $question to section $section_file..."; question_file=$DIR_WORKSPACE/$DIR_QUESTIONS/$lang/$question check_file_exists $question_file if [ $? -ne 0 ]; then return 1; fi echo "%% From $lang/$question =======================================" >> $section_file echo '\element{section'$section_num'}{' >> $section_file cat $question_file >> $section_file echo '}' >> $section_file done echo "\input{./section_${section_num}.tex}" >> $project/sections.tex echo "\input{./header_${section_num}.tex} \melangegroupe{section${section_num}} \restituegroupe{section${section_num}} " >> $project/random-sections.tex done return 0 } # EOF diff --git a/data/workspace/common/common_commands.tex.sample b/data/workspace/common/common_commands.tex.sample new file mode 100644 index 0000000..a35fd38 --- /dev/null +++ b/data/workspace/common/common_commands.tex.sample @@ -0,0 +1,6 @@ +%% Specific commands for Skel teacher (EXAMPLE) + +\newcommand{\R}{\mathbb{R}} +\newcommand{\Q}{\mathbb{Q}} +\newcommand{\N}{\mathbb{N}} +\newcommand{\Z}{\mathbb{Z}} diff --git a/data/workspace/common/common_packages.tex.sample b/data/workspace/common/common_packages.tex.sample new file mode 100644 index 0000000..4b96955 --- /dev/null +++ b/data/workspace/common/common_packages.tex.sample @@ -0,0 +1,4 @@ +%% Extra packages for all exams + +% none +