[LON-CAPA-users] Hints for first LON-CAPA question

Peter Dencker dencker at math.uni-luebeck.de
Thu Jun 13 16:33:32 EDT 2013


Hi.

> 1. How can a student submit each part of the question separately?
>

Use  separated parts, <part id='someid'> ... </part>. And try to set the
default for the parameter 'ordered' to 'yes', see below.

> 2. I'm building the header with $row1 .= "<td>$i+1</td>",
> but the $i+1 isn't evaluated and 0+1, 1+1, etc. is shown.
>

take "<td>  @{[$i + 1]} </td>"

> 3. How can \bar{x} be displayed?
>

\overline{x} ?

>
>

some remarks:

    for ($i=0; $i<$n; $i++)
    {
    ...
    }

is ugly C-style

    for $i (0 .. $n - 1) {
    ...
    }

is perl :-)

Furthermore, in your case using join and map is a good alternative to
the loop. Example:

$row2 = '<tr><td>'
  . join('</td><td>', 'A', (map { &roundto($a[$_],2) } (0 .. $n - 1)))
  . '</td></tr>';


- Peter


<problem>
<parameter name="maxtries" id="11" type="int_pos" default="1"
description="Maximum Number of Tries" />
<parameter name="ordered" id="12" type="string_yesno" default="yes"
description="Show Parts One-at-a-Time" />

<script type="loncapa/perl">

$n = &random(8,16,1);

$mu_a = &random(4,16,.01);
$sd_a = &random(1,5,.01);
@a=&random_normal($n,55,$mu_a,$sd_a);

$mu_b = &random(4,16,.01);
$sd_b = &random(1,5,.01);
@b=&random_normal($n,55,$mu_b,$sd_b);

$table = '<table border=1>';
$row1 = '<tr><td></td>';
$row3 = '<tr><td>B</td>';
for $i (0 .. $n - 1) {
    $row1 .=  "<td>  @{[$i + 1]} </td>";
    $row3 .= "<td>&roundto($b[$i],2)</td>";
}

$row2 = '<tr><td>'
  . join('</td><td>', 'A', (map { &roundto($a[$_],2) } (0 .. $n - 1)))
  . '</td></tr>';

$row1 .= '</tr>';
$row3 .= '</tr>';
$table .= $row1;
$table .= $row2;
$table .= "$row3</table>";

$test_statistic = 0; ## compute


</script>

<startouttext />
<p>
Super Sneaker Company is evaluating two different materials, A and B, to
be used to construct the soles of their new active shoe targeted to city
high school students in Canada. While material B costs less than
material A, the company suspects that mean wear for material B is
greater than mean wear for material A. Two study designs were initially
developed to test this suspicion. In both designs, Halifax was chosen as
a representative city of the targeted market. In Study Design 1, 10 high
school students were drawn at random from the Halifax School District
database. After obtaining their shoe sizes, the company manufactured 10
pairs of shoes, each pair with one shoe having a sole constructed from
material A and the other shoe, a sole constructed from material B.
</p>
The researcher in charge of this design asked the company to randomly
assign material A to the right shoe or to the left shoe, for each of the
ten pairs. Why?
<endouttext />

<part id ='p0'>
<radiobuttonresponse direction="vertical" max="3" id="12" randomize="yes">
    <foilgroup>
        <foil location="random" value='true' name="foil1">
            <startouttext />Right shoe wear is generally different than
left shoe wear.<endouttext />
        </foil>
        <foil location="random" value='false' name="foil2">
            <startouttext />Right shoe wear is always less than left
shoe wear.<endouttext />
        </foil>
        <foil location="random" value='false' name="foil3">
            <startouttext />Right shoe wear is always greater than left
shoe wear.<endouttext />
        </foil>
        <foil location="random" value='false' name="foil4">
            <startouttext />Left shoe wear is always less than right
shoe wear.<endouttext />
        </foil>
        <foil location="random" value='false' name="foil5">
            <startouttext />Left shoe wear is always greater than right
shoe wear.<endouttext />
        </foil>
    </foilgroup>
</radiobuttonresponse>
</part>
<part id ='p1'>
<parameter name="maxtries" type="int_pos" description="Maximum Number of
Tries" default="1" />
<startouttext />
<p>
After 3 months, the amount of wear in each shoe was recorded in
standardized units as follows:
<parse>$table</parse>
</p>
The null hypothesis for the test is:
<endouttext />

<radiobuttonresponse max="4" randomize="yes" direction="vertical">
    <foilgroup>
      <foil location="random" value='true' name="foil1">
         <startouttext /><m>$\mu_a - \mu_b = 0$</m><endouttext />
      </foil>
      <foil location="random" value='true' name="foil2">
         <startouttext /><m>$\mu_b - \mu_a = 0$</m><endouttext />
      </foil>
      <foil location="random" value='false' name="foil3">
         <startouttext /><m>$\overline{x}_a <
\overline{X}_b$</m><endouttext />
      </foil>
      <foil location="random" value='false' name="foil4">
         <startouttext /><m>$\overline{x}_a - \overline{x}_b =
0$</m><endouttext />
      </foil>
      <foil location="random" value='false' name="foil5">
         <startouttext /><m>$\overline{x}_b - \overline{x}_a =
0$</m><endouttext />
      </foil>
    </foilgroup>
</radiobuttonresponse>
</part>
<part id = 'p2'>
<parameter name="maxtries" type="int_pos" description="Maximum Number of
Tries" default="1" />
<startouttext />
The alternative hypothesis is:
<endouttext />

<radiobuttonresponse max="4" randomize="yes" direction="vertical">
    <foilgroup>
      <foil location="random" value='true' name="foil1">
         <startouttext /><m>$\mu_a - \mu_b \ne 0$</m><endouttext />
      </foil>
      <foil location="random" value='true' name="foil2">
         <startouttext /><m>$\mu_b - \mu_a > 0$</m><endouttext />
      </foil>
      <foil location="random" value='false' name="foil3">
         <startouttext /><m>$\mu_b - \mu_a > 0$</m><endouttext />
      </foil>
      <foil location="random" value='false' name="foil4">
         <startouttext /><m>$\mu_a - \mu_b > 0$</m><endouttext />
      </foil>
      <foil location="random" value='false' name="foil5">
         <startouttext /><m>$\overline{x} < $</m><endouttext />
      </foil>
      <foil location="random" value='false' name="foil6">
         <startouttext /><m>$\overline{x}_a - \overline{x}_b <
0$</m><endouttext />
      </foil>
      <foil location="random" value='false' name="foil7">
         <startouttext /><m>$\overline{x}_b - \overline{x}_a <
0$</m><endouttext />
      </foil>
    </foilgroup>
</radiobuttonresponse>
</part>
<part id ='p3'>
<parameter name="maxtries" type="int_pos" description="Maximum Number of
Tries" default="3" />
<startouttext />To test the hypothesis that mean wear for material B is
greater than mean wear for material A, calculate the test
statistic.<endouttext />
<numericalresponse answer="$test_statistic">
  <responseparam type="tolerance" default="5%" name="tol"
description="Numerical Tolerance" />
  <responseparam name="sig" type="int_range,0-16" default="0,15"
description="Significant Figures" />
  <textline readonly="no" />
</numericalresponse>
</part>

<part id ='p4'>
<startouttext />Which of the statistical tables should you use?  You
only have one try!<endouttext />
<radiobuttonresponse max="3" randomize="yes" direction="vertical">
  <foilgroup>
    <foil name="t" value="true" location="random">
      <startouttext />t-distribution<endouttext />
    </foil>
    <foil name="z" value="unused" location="random">
      <startouttext />z-distribution<endouttext />
    </foil>
    <foil name="chi" value="unused" location="random">
      <startouttext /><m>$\chi^2$</m><endouttext />
    </foil>
  </foilgroup>
</radiobuttonresponse>
</part>

</problem>

-- 
Dr. Peter Dencker
    wissenschaftl. Mitarbeiter

UNIVERSITÄT ZU LÜBECK
    INSTITUT FÜR MATHEMATIK

    Ratzeburger Allee 160
    23562 Lübeck

    Tel +49 451 500 4254
    Fax +49 451 500 3373
    dencker at math.uni-luebeck.de

    www.math.uni-luebeck.de


More information about the LON-CAPA-users mailing list