<< Part 12 - Part 14 >>

Part 13: TruthTableAnswer

with the answer type input.truth-table you can let the user select the truth values of one or multiple logical terms.

1: specify the variables used in the terms

First you need to specify the usedVariables (semicolon separated). The generic framework will generate the values for all variables.

...
\begin{answer}
  \type{input.truth-table}
  \usedVars{a;b}
\end{answer}
...

Defining the order of the generated value

As you can see in the picture above the values generated for the variables starts with false for every variable. If you rather it to start with true instead, you can use the command \top{true}.

...
\begin{answer}
  \type{input.truth-table}
  \usedVars{a;b}
  \top{true}
\end{answer}
...

2: define the logical terms to be evaluated

Then, you can define the terms (again semicolon separated) that should be displayed as tasks.

...
\begin{answer}
  \type{input.truth-table}
  \usedVars{a;b}
  \tasks{$(a \wedge c) \vee b$;$\neg(a \wedge b)$;$(b \wedge c) \rightarrow a$}
\end{answer}
...

3: Specify the solutions

At last, you need to specify the solutions. Note that the solution has to be hard coded (1 for true, or 0 for false). The length of the solution depends on the length of usedVars and you need semicolon separated solution for each term.

...
\begin{answer}
  \type{input.truth-table}
  \usedVars{a;b}
  \tasks{$(a \wedge c) \vee b$;$\neg(a \wedge b)$;$(b \wedge c) \rightarrow a$}
  \solution{00110111;11111100;11101111}
\end{answer}
...

Using variables

Instead of passing the arguments directly, you can also pass in string variables for the \usedVars, \tasks and \solution commands (see example below):

...
\begin{question}
  \begin{variables}
    \string{vars}{p;q}
    \string{task}{$p \wedge q$;$p \vee q$}
    \string{solu}{0001;0111}
  \end{variables}
  \begin{answer}
    \type{input.truth-table}
    \usedVars{vars}
    \tasks{task}
    \solution{solu}
  \end{answer}
\end{question}
...

Using variable pool to create variations of the tasks

In order to show random questions and create personalized user data, you can use variables defined in a pool.


\begin{question}
  \begin{pool}
    \begin{variables}
      \string{vars}{p;q}
      \string{task}{$p \wedge q$;$p \vee q$}
      \string{solu}{0001;0111}
    \end{variables}

    \begin{variables}
      \string{vars}{a;b}
      \string{task}{$a \wedge b$;$\neg(a \vee b)$}
      \string{solu}{0001;1000}
    \end{variables}

    \begin{variables}
      \string{vars}{s;t}
      \string{task}{$\neg t$;$s \vee \neg t$}
      \string{solu}{1010;1011}
    \end{variables}

    ... more ...
  \end{pool}
  \text{\textbf{fill in the truth table}}
  \type{input.generic}

  \begin{answer}
    \type{input.truth-table}
    \usedVars{vars}
    \tasks{task}
    \solution{solu}
  \end{answer}

Complete example

This is a complete example of a generic problem with one question containing 2 truth table answers:

\usepackage{mumie.genericproblem}

\lang{de}{
    \title{Der Titel}
}

\begin{problem}
    \begin{question}
         \begin{pool}
            \begin{variables}
                \string{vars}{p;q}
                \string{task}{$p \wedge q$;$p \vee q$}
                \string{solu}{0001;0111}

                \string{vars2}{a;b;c}
                \string{task2}{$\neg a$;$\neg(a \wedge b)$;$ (a \wedge b) \rightarrow c$}
                \string{solu2}{11110000;11111100;11111101}
            \end{variables}

            \begin{variables}
                \string{vars}{a;b}
                \string{task}{$a \wedge b$;$\neg(a \vee b)$}
                \string{solu}{0001;1000}

                \string{vars2}{a;b;c}
                \string{task2}{$(a \wedge c) \vee b$;$\neg(a \wedge b)$;$ (b \wedge c) \rightarrow a$}
                \string{solu2}{00110111;11111100;11101111}
            \end{variables}

            \begin{variables}
                \string{vars}{s;t}
                \string{task}{$\neg t$;$s \vee \neg t$}
                \string{solu}{1010;1011}

                \string{vars2}{p;q;r}
                \string{task2}{$(p \vee r)$;$\neg(p \rightarrow q)$;$ (p \vee r) \leftrightarrow \neg(p \rightarrow q)$}
                \string{solu2}{01011111;00001100;10101100}
            \end{variables}

            \begin{variables}
                \string{vars}{a;b}
                \string{task}{$a \vee b$;$a \oplus b$}
                \string{solu}{0111;0110}

                \string{vars2}{a;b;c}
                \string{task2}{$a \oplus (b \wedge c)$; $\neg((a \wedge b) \vee c)$; $(a \vee b) \wedge (b \vee c)$}
                \string{solu2}{00011110;10101000;00110111}
            \end{variables}
          \end{pool}
        \lang{de}{
            \text{\textbf{fill in the truth table}}
        }
        \type{input.generic}
        \field{real}
        \displayprecision{3}
        \correctorprecision{1}

        \begin{answer}
            \type{input.truth-table}
            \usedVars{vars}
            \tasks{task}
            \solution{solu}
        \end{answer}

        \begin{answer}
            \type{input.truth-table}
            \usedVars{vars2}
            \tasks{task2}
            \solution{solu2}
        \end{answer}

    \end{question}

\end{problem}

\embedmathlet{applet}

truth-table.jpg (40.1 KB) Petrus Tan, 07/06/2016 03:39 PM

Truth-table
Add picture from clipboard (Maximum size: 500 MB)