# Step 1: Writing a problem tex¶

## Generals¶

The problem tex normally consists of the following:
• Definition of Personalized Problem Data(PPD)
• Problem description
• Reference to Applet and Corrector

### 1. Define the personalized problem data¶

A personalized problem data can be defined with the following syntax:

\ppdrandint{<datasheet path>}{<minimum value>}{<maximum value>}


The above code will generate a random integer between <minimum value> and <maximum value>, and write it into the datasheet tree on the path defined as <datasheet path>. To avoid a zero value we can use the following syntax:

\ppdrandint[Z]{<datasheet path>}{<minimum value>}{<maximum value>}


The definition of the personalized data should be wrapped in a hidden environment so that the results are not printed directly in the generated xhtml. Furhter, because the \ppdrandint command only available within a math environment, we should write the definition within a math environment.

According to our example we can define the variable a,b,c and d as follows:

\begin{hidden}
$\ppdrandint[Z]{user/problem/a}{-4}{4} \ppdrandint{user/problem/b}{-4}{4} \ppdrandint{user/problem/c}{-9}{9} \ppdrandint[Z]{user/problem/d}{-5}{5}$
\end{hidden}


### 2. Write the problem Description¶

After all personalized data are defined, we can finally write the problem description.
To display the generated data we use the following syntax:

\ppdcopy{<datasheet path>}


For our example, the problem description should look like the following code:

...

Consider the quadratic function:
\begin{displaymath}
f(x) := \ppdcopy{user/problem/a}x|_.2+\ppdcopy{user/problem/b}x+\ppdcopy{user/problem/c}
\end{displaymath}
...


A Problem may have several subtasks. To write the description of each subtask, we open a subtasks* environment and use the \subtask command at the beginning of each subtask description.

\begin{subtasks*}
\subtask List all real roots of $f(x)$ (if any)
\subtask Calculate $f(x)$ for x = $\ppdcopy{user/problem/d}$


To include the referenced applet into the problem, we go back to the Content Block tab and add the following code:

\begin{execute}
\begin{applet}{applet1} %applet1 is the local ID
%set parameters for the applet
\param{appletWidth}{500}
\param{appletHeight}{500}
\end{applet}
\end{execute}


Add picture from clipboard (Maximum size: 500 MB)