Miscellaneous
Prev |  |

## Miscellaneous

### AMC and TeXLive «vanilla» (ubuntu et debian)

#### AMC and TeXLive are not installed

- Install TeXLive on line.

    wget http://mirror.ctan.org/systems/texlive/tlnet/install-tl-unx.tar.gz
    tar -xzf install-tl-unx.tar.gz
    cd install-tl-20xxxx
    sudo ./install-tl

| Note
Replace xxxx with the digits or type TABULATION.

- Select O then L and enter 3 times.

  Select R then I.

| Note
TexLive-full is the setting default. If you don't want all the packages, press C then select your packages then R and finally I.

    sudo apt install equivs --no-install-recommends
    mkdir -p /tmp/tl-equivs && cd /tmp/tl-equivs
    equivs-control texlive-local

- Open the web link and note the version number:

  https://www.tug.org/texlive/files/debian-equivs-20xx-ex.txt.

    wget -O texlive-local http://www.tug.org/texlive/files/debian-equivs-20xx-ex.txt
    equivs-build texlive-local
    sudo dpkg -i texlive-local_20xx-x_all.deb
    sudo apt install -f

- Install AMC.

    sudo add-apt-repository ppa:alexis.bienvenue/stable && sudo apt-get update
    sudo apt-get install auto-multiple-choice && sudo apt-get install msmtp

- Create a symbolic link.

    sudo ln -s /usr/share/texmf/tex/latex/AMC /usr/local/texlive/texmf-local/tex/latex/AMC
    sudo mktexlsr
    sudo tlmgr update --self --all

#### AMC is not installed and TeXLive is(/usr/local/)

- Create a symbolic link.

    sudo ln -s /usr/share/texmf/tex/latex/AMC /usr/local/texlive/texmf-local/tex/latex/AMC
    sudo mktexlsr

### Cut the `DOC-sujet.pdf` file in several files

Preferences → Main → Printing → Printing with method → to files

Preferences → Main → Printing → Extracting method → pdftk / gs (ghostscipt) / qpdf (default) / sejda-console (not installed).

### processing chain : 2 pages per sheet (2 A5 on 1 A4)

You may print the `DOC-sujet.pdf` file on 2 pages per 1 sheet with any pdf reader but AMC will not be able to analyse automatic data capture from scans, you have to “crop” it.

- convert pdf scans to pbm images.

      pdfimages yourfile.pdf foo

- “Crop” each image into two pages.

      mogrify -rotate -90 -crop 50%x100% *.pbm

  | Note
  Noneeded to do after the previous command:
      mogrify -rotate +90 -crop 50%x100% *.pbm
  all pages will be treated and automatically renamed with ImageMagick. You can force ImageMagick to apply simultaneous black/white threshold to the image to make box checking easier (here 80%).
      mogrify -rotate -90 -crop 50%x100% -threshold 80% *.pbm

- Let’s move to the Data capture tab of the graphical interface and select this set of `pbm` images.

### pythontex

From https://project.auto-multiple-choice.net/attachments/450/Wiki_AMC_et_PythonTex.pdf and https://project.auto-multiple-choice.net/projects/auto-multiple-choice/wiki/Calcul_formel_avec_Python_dans_AMC

- You need to add a script nammed prePythonTex4AMC and make it executable.

    #! /bin/sh
    SRC=$1
    echo "***** JOBNAME=$AMC_JOBNAME"
    echo "***** CMD=$AMC_CMD"
    rm -rf ./pythontex-files-*
    rm -f $AMC_JOBNAME.pytxcode
    $AMC_CMD
    echo "***** PYTHON"
    python /path/to/file/pythontex.py $AMC_JOBNAME.pytxcode
    echo "***** END FILTER"

| Note
python3 works too.
    python3 /path/to/file/pythontex3.py

- Add the following three lines to the beginning of the LaTex file.

    %%AMC:preprocess_command=/path/to/file/prePythonTex4AMC
    %%AMC:jobspecific=1
    %%AMC:latex_engine=pdflatex --shell-escape

| Warning
Some python modules need to be installed (sympy, pygments)

#### An french example with python (from José OUIN : http://www.joseouin.fr)

    %%AMC:preprocess_command=/path/to/file/prePythonTex4AMC
    %%AMC:jobspecific=1
    %%AMC:latex_engine=pdflatex --shell-escape

    \documentclass[a4paper]{article}
    \usepackage[T1]{fontenc}

    \usepackage[english,bloc,completemulti]{automultiplechoice}
    \usepackage{fancyhdr,amssymb,amsmath}

    % ---------- Utilisation de codes Python -----
    \usepackage{pythontex}
    %----------------------------------------------

    \begin{pycode}
    import numpy as np
    from sympy import *

    np.random.seed(12345)
    # IMPORTANT : ramdom seed

    def polyv2(b,p,d,q) :
      x=Symbol('x')
      myp = expand((x-b)**p*(x-d)**q)
      return latex(myp)

    def dp1x(a,b,c) :
        x=Symbol('x')
        y=Symbol('y')
        f=(a*y-1)/(b*x-1)**c

        g=diff(f,x,1)
        g2=g/b
        g3=g*(-1)
        g4=g2*(-1)

        gl = latex(g)
        g2l = latex(g2)
        g3l = latex(g3)
        g4l = latex(g4)

        return np.array([gl,g2l,g3l,g4l])

    \end{pycode}

    \begin{document}

    \element{Questions}{%
    \begin{question}{QA}The value of $\pi$ is
    \begin{choices}
    \correctchoice{\py{np.pi}}
    \wrongchoice{\py{100+200}}
    \wrongchoice{\py{np.random.randint(10)+3.15}}
    \end{choices}
    \end{question}

    \begin{question}{QB}
    \pyc{a=np.random.randint(10)}
    \pyc{b=np.random.randint(10)}
    \pyc{z=np.complex(a,b)}

     Let the complex number $\underline{Z}= py{a}+i. py{b}$, what is the value of
    $\underline{Z} 2$~?

    \begin{choices}
    \correctchoice{\py{z**2}}
    \wrongchoice{\py{np.conj(z**2)}}
    \wrongchoice{\py{1/z}}
    \end{choices}
    \end{question}
    }%

    \onecopy{5}{

    %%% beginning of the test sheet header:

    \noindent{\bf QCM  \hfill TEST}

    \vspace*{.5cm}
    \begin{minipage}{.4\linewidth}
      \centering\large\bf Test\\ Examination on Jan. 1st, 2008
    \end{minipage}
    %-------------------------------------

    \begin{center}\em

    Duration : 10 minutes.

      No documents allowed. The use of electronic calculators is forbidden.

      Questions using the sign \multiSymbole{} may have
      zero, one or several correct answers.  Other questions have a single correct answer.

      Negative points may be attributed to \emph{very bad} answers.

    \end{center}

      \end{minipage}\hspace*{\fill}
      }

    \vspace{5ex}

    \begin{question}{deriv-px-1}

          \pyc{a=np.random.randint(2,7)} %
          \pyc{b=np.random.randint(2,5)} %
          \pyc{c=np.random.randint(2,5)} %
          \pyc{drvx=dp1x(a,b,c)}

    Let the following function: $f(x,y)= \dfrac{\py{a} y-1}{(\py{b} x-1)^{\py{c}}}$

    What is the partial derivative $ \dfrac{\partial f(x,y)}{\partial x}$ ?

    \begin{choiceshoriz}
    \correctchoice{$\py{drvx[0]}$}
    \wrongchoice{$\py{drvx[1]}$}
    \wrongchoice{$\py{drvx[2]}$}
    \wrongchoice{$\py{drvx[3]}$}
    \end{choiceshoriz}

    \end{question}
    %---------------
    % POLYNOME
    %--------------

    \begin{question}{polynome-v2}

          \pyc{b=np.random.randint(2,7)} % racine r = b
          \pyc{p=np.random.randint(2,4)} % p : ordre de mult de b
          \pyc{d=np.random.randint(2,5)} % racine r = d
          \pyc{q=np.random.randint(2,3)}  % q : ordre de mult de d
          \pyc{mypoly=polyv2(b,p,d,q)}    % construction de mypolyv2

    Let the polynomial: $\py{mypoly}$

    What is the root multiplicity order $r = \py{b}$ ?

    \begin{choiceshoriz}
    \correctchoice{$\py{p}$}
    \wrongchoice{$\py{p+1}$}
    \wrongchoice{$\py{p-1}$}
    \wrongchoice{$\py{p+2}$}
    \end{choiceshoriz}

    \end{question}

    \restituegroupe{Questions}

    }

    \end{document}

### AMC and moodle

https://github.com/nennigb/amc2moodle

### Configure AMC to use GMAIL

Login to your gmail account then enable the option : Allowing less secure apps to access your account.

#### Linux users (Ubuntu,Xubuntu,Lubuntu etc.)

Type in a terminal :

    sudo apt-get install msmtp

    sudo gedit /etc/msmtprc

add the following content to msmtprc file and save it.

    account gmail
    host smtp.gmail.com
    tls on
    tls_certcheck off
    port 587
    auth login
    from your_user_name@gmail.com
    user your_user_name@gmail.com
    password your_password

Set up AMC : Edit → Preferences → Email → Mail delivery method, select sendmail and type the path :

    /usr/bin/msmtp

#### Macintosh users

Type in a terminal :

    sudo port install msmtp

    sudo pico ~/.msmtprc

add the following content to msmtprc file and save it.

    account default
    host smtp.gmail.com
    tls on
    tls_certcheck off
    port 587
    auth login
    from your_user_name@gmail.com
    user your_user_name@gmail.com
    password your_password

Modify the access rights:

    sudo chown user_name:user_name/Users/user_name/.msmtprc
    chmod 0600 /Users/user_name/.msmtprc

Set up AMC : Edit → Preferences → Email → Mail delivery method, select sendmail and type the path :

    /opt/local/bin/msmtp

Prev |  |
auto-multiple-choice-mailing | Home |