Forums » Using AMC (english) »

## Same questions for all copies on a different funtion

Added by Paco Riviere 5 months ago

I wonder if somebody can help me with the following issue:

I would like to give each student a diferent text, in my case it is a logical function, and make nearly the same questions to all the students, but refering to each particular function.

So that the anssers would be dependant on the given text or function, so diferent for each student, but same for all questions of any student.

Hope I was clear enuoght.

### Replies (27)

#### RE: Same questions for all copies on a different funtion - Added by Luc Prik 5 months ago

Hi,

What kind of logical function do you want to put on the test?

Could you give an example?

#### RE: Same questions for all copies on a different funtion - Added by Paco Riviere 5 months ago

Yes, of course. My idea is to show some function, text or image and then ask several questions over the same item about its properties in order to evaluate each answer separately. Ot coul be a function like y=2*x*3+4, F=P^Q or whatever. It allows me to have a diferent answer for each student with the same questions. I used to to it before using AMC, and am crazy to find how to achieve it now.

#### RE: Same questions for all copies on a different funtion - Added by Paco Riviere 5 months ago

To show an explicit and simple example:

Imagine we show a diferent vehicle to each student, let's say. eg. a car, a motorcicle and a charriot.

Some same questions to all students, may be:

Is it a car?

How many wheels are there?

Is it mainly on wood?

In fact I think in tikzs or images taking quite paper space, cumbersome to repeat on every question.

#### RE: Same questions for all copies on a different funtion - Added by Luc Prik 5 months ago

For generating functions with random coefficients, I use pythontex.

For exemple: [[https://github.com/divingeek/sujets-AMC/blob/master/seconde/fonctions_generalites/DOC-sujet.pdf]]

Exercice 2: I wanted the student to write the answers, but it's easy to generate the random answers.

Exercice 3: I randomize x values using python arrays.

I created an exam last week, still not on my github, in which I generated random graphs using pythontex + tikz.

#### RE: Same questions for all copies on a different funtion - Added by Paco Riviere 5 months ago

Thanks for your answer, Luc. That's nearly what I was thinking about!

How do you do it?

Are you giving the **same function** for each exercise to every student?

I guess you are giving the **same function** and ask **diferent questions**.

Are you using a Question group for each exercise?

How do you print group headers? Just with text?

As I need to evaluate different aspects of the subject, I would like to give a **diferent logical function**, such as F=A'·C+A·B+C'·D' and the ask the **same questions** to all students:

1. The truth table

2. Minterms

3. Karnaugh table

4. Simplified function

5. Logic ports circuit

I have no idea on:

a) How to print group headings to show funtion F. Just with text?

b) How to obtain random logical functions such as F

c) How to keep track of each answer matches its own function F. I imagine with Question groups (doc 5.3).

The main goal is knowing where are students having trouble, in order to increase exercises there.

#### RE: Same questions for all copies on a different funtion - Added by Luc Prik 5 months ago

a) I would create a python function createLF(size) (LF for logical function in the name, and size for the number of varaibles for exemple) would return a randomly array which could look like this (to match with your function: ['COMPA','PROD','C','SUM','A','PROD'....] with COMPA for A', COMPB for B'....

And another function which prints the logical function (printLF(LF)) and return text after having parsed the LF array.

b) one list VARS=['A','B','C','D'.....] up to the letter you want.

Then, you create your LF list with while loop until size, with inside two other binary random to choose first if the var is complement or not and the next operation (+ or .)

c) you create a function for each question, which return the good answer and bad anwsers in an array.

######

Look at the code https://github.com/divingeek/sujets-AMC/blob/master/seconde/fonctions_generalites/source.tex in order to write the python code inside the Latex document.

Hoping my explanations were quite understdoodable... :-)

#### RE: Same questions for all copies on a different funtion - Added by Paco Riviere 5 months ago

Thanks, Luc. That looks very nice!

I'm quite new on LaTeX and never used python with it. I've been looking at it and tring to compile a simple file with embeded python code but do not even succed to configure TeXstudio to produce a file!

I'll take some time to study it as it seems really promising!

I have this error message:

Package csvsimple Error: File '../liste.csv' not existent, not readable, or empty!. ... to column names]{../liste.csv}{}{\sujet}

I put the file liste.csv on the same folder as source.tex

#### RE: Same questions for all copies on a different funtion - Added by Luc Prik 5 months ago

You need to set tex studio with thé command to compile (its written at thé beginning of the file.

For the csv file, its a relative path which seeks parent folder, not current folder.

Just write liste.csv if you have the file in the folder, or move your file to parent folder.

#### RE: Same questions for all copies on a different funtion - Added by Paco Riviere 5 months ago

I reproduced your exam, now I need to study it.

I have watched Jose Ouin's post https://project.auto-multiple-choice.net/boards/4/topics/8476 and video

That has also helped me.

Many thanks Luc.

#### RE: Same questions for all copies on a different funtion - Added by Paco Riviere 5 months ago

#### RE: Same questions for all copies on a different funtion - Added by Paco Riviere 5 months ago

Neither I succed to make a maco with this code in the way:

\truthtable{A}{B}{OR}

#### RE: Same questions for all copies on a different funtion - Added by Luc Prik 5 months ago

I think you can do like this with two variables:

`A=0`

B=1

if A and B:

return something

if A or B:

return somethingelse

if not A and B:

etc...

But I would think more in how to do it fully in python (just using LaTex to print), and so creating a data structure (as I said before using an array to create a random logical function) to implement that the most efficient way. I haven't enough skills in LaTex to anwser if it could be easier than in Python...

#### RE: Same questions for all copies on a different funtion - Added by Paco Riviere 5 months ago

In fact I try two play on both sides, as I don't know yet which to choose for each step. This was on the LaTeX side.

On the Python side I succed to do this:

% From Figure 2 on https://tug.org/TUGboat/tb34-3/tb108mertz.pdf %\usepackage{pythontex} % in preamble \begin{pycode} print(r"\begin{tabular}{c c|c}") print(r"$A$ & $B$ & $A or B$ \\ \hline") for m in range(0, 2): for n in range(0, 2): print(r"%d & %d & %d \\" % (m, n, m or n)) print(r"\end{tabular}") \end{pycode}

But when I try to use an arbitrary function instead of OR ii does not work:

% Figure 5 from: https://tug.org/TUGboat/tb34-3/tb108mertz.pdf %\usepackage{pythontex} % in preamble \begin{pythontexcustomcode}{py} def taulaveritat(lofu): print(r"\begin{tabular}{c c|c}") print(r"$A$ & $B$ & $A lofu B$ \\ \hline") for m in range(0, 2): for n in range(0, 2): print(r"%d & %d & %d \\" % (m, n, m lofu n)) print(r"\end{tabular}") \end{pythontexcustomcode} \pyc{taulaveritat(or)}

#### RE: Same questions for all copies on a different funtion - Added by Paco Riviere 5 months ago

Maybe this line`print(r"%d & %d & %d \\" % (m, n, m lofu n))`

should be:`print(r"%d & %d & %d \\" % (m, n, lofu(m,n)))`

But it neither works.

lofu is for logical function

#### RE: Same questions for all copies on a different funtion - Added by Luc Prik 5 months ago

try this.

I created two python functions, I think it will help you to create the others...

source.tex (4.3 kB)

DOC-sujet.pdf (122.9 kB)

#### RE: Same questions for all copies on a different funtion - Added by Luc Prik 5 months ago

Paco Riviere wrote:

Maybe this line

`print(r"%d & %d & %d \" % (m, n, m lofu n))`

should be:

`print(r"%d & %d & %d \" % (m, n, lofu(m,n)))`

But it neither works.

lofu is for logical function

It should work....

Do you manage to print lofu(m,n) outside ?

What's your lofu(m,n) code ? What does it return ?

#### RE: Same questions for all copies on a different funtion - Added by Paco Riviere 5 months ago

lofu is a parameter to be substitued by any logical function, eg. or, in:

4 def taulaveritat(lofu): ... 13 \pyc{taulaveritat(or)}

I try to do as in Figure 5 from: https://tug.org/TUGboat/tb34-3/tb108mertz.pdf

Outside pythontexcustomcode it works, as here in pycode: https://project.auto-multiple-choice.net/boards/2/topics/11192?r=11208#message-11208 (labeled "From Figure 2")

I guess your source.tex example takes the function out of the table, it's a good idea.

Anyway, I get this compilation message:

`pdfTeX error (font expansion): auto expansion is only possible with scalable fonts. ... to column names]{../liste.csv}{}{\sujet}`

#### RE: Same questions for all copies on a different funtion - Added by Paco Riviere 5 months ago

The subject I am on is building circuits from logical functions and use Karnaugh map to get a simpler version.

It involves exercices about base conversion, truth tables and karnaugh maps.

If it is of any help.

#### RE: Same questions for all copies on a different funtion - Added by Luc Prik 5 months ago

Paco Riviere wrote:

lofu is a parameter to be substitued by any logical function, eg. or, in:

[...]

I try to do as in Figure 5 from: https://tug.org/TUGboat/tb34-3/tb108mertz.pdf

Outside pythontexcustomcode it works, as here in pycode: https://project.auto-multiple-choice.net/boards/2/topics/11192?r=11208#message-11208 (labeled "From Figure 2")

I guess your source.tex example takes the function out of the table, it's a good idea.

Anyway, I get this compilation message:

`pdfTeX error (font expansion): auto expansion is only possible with scalable fonts. ... to column names]{../liste.csv}{}{sujet}`

OK, so if lofu is a parameter, you cannot call lofu(m,n)

You have to have def lofu() somewhere.

I guess your source.tex example takes the function out of the table, it's a good idea.

Doing this, you'll have to put the computed images of F(A,B) inside the table. So you need to create a fonction to compute.

- But do you want to show multiple karnaugh tables, and ask student which one is corect (so you need to generate the correct karnaugh table and many wrongs) ?
- Or ask just for a missing value in the table -> so there can be different questions, one per element in the table you want the students to compute. In this case you print the table before the question, and with the number of the question inside the cell the have to compute.
- Or another way ?

#### RE: Same questions for all copies on a different funtion - Added by Luc Prik 5 months ago

Luc Prik wrote:

Paco Riviere wrote:

lofu is a parameter to be substitued by any logical function, eg. or, in:

[...]

I try to do as in Figure 5 from: https://tug.org/TUGboat/tb34-3/tb108mertz.pdf

Outside pythontexcustomcode it works, as here in pycode: https://project.auto-multiple-choice.net/boards/2/topics/11192?r=11208#message-11208 (labeled "From Figure 2")

I guess your source.tex example takes the function out of the table, it's a good idea.

Anyway, I get this compilation message:

`pdfTeX error (font expansion): auto expansion is only possible with scalable fonts. ... to column names]{../liste.csv}{}{sujet}`

OK, so if lofu is a parameter, you cannot call lofu(m,n)

You have to have def lofu() somewhere.I guess your source.tex example takes the function out of the table, it's a good idea.

Doing this, you'll have to put the computed images of F(A,B) inside the table. So you need to create a fonction to compute.

- But do you want to show multiple karnaugh tables, and ask student which one is corect (so you need to generate the correct karnaugh table and many wrongs) ?
- Or ask just for a missing value in the table -> so there can be different questions, one per element in the table you want the students to compute. In this case you print the table before the question, and with the number of the question inside the cell the have to compute.
- Or another way ?

Sorry, I wrote nuts here, in fact you can pass a function as parameter...

#### RE: Same questions for all copies on a different funtion - Added by Luc Prik 5 months ago

it's in fact that "or" is an operator and not a function, so doing or(m,n) is not ok.

#### RE: Same questions for all copies on a different funtion - Added by Luc Prik 5 months ago

More randomization...

DOC-sujet.pdf (123.5 kB)

source.tex (4.6 kB)

#### RE: Same questions for all copies on a different funtion - Added by Paco Riviere 5 months ago

I get lost when to use latex and when Python! ;)

#### RE: Same questions for all copies on a different funtion - Added by Paco Riviere 5 months ago

Something like:?

\pyc{def lofu:or} \pyc{taulaveritat("$OR$")}

#### RE: Same questions for all copies on a different funtion - Added by Paco Riviere 5 months ago

Then this should work:

%\usepackage{pythontex} % in preamble \begin{pythontexcustomcode}{py} def taulaveritat(hd): print(r"\begin{tabular}{c c|c}") print(r"$A$ & $B$ & %s \\ \hline" % hd) for m in range(0, 2): for n in range(0, 2): print(r"%d & %d & %d \\" % (m, n, (m lofu n))) print(r"\end{tabular}") \end{pythontexcustomcode} \begin{pycode} def lofu: or \end{pycode} \pyc{taulaveritat("$OR$")}

But it does not.