[LON-CAPA-users] Using PartId

lon-capa-users@mail.lon-capa.org lon-capa-users@mail.lon-capa.org
Wed, 31 May 2006 22:45:08 -0400


<font size=3D"2">I am trying to write a little code to generate random
problems from a pool of problems. The current code is shown below.
Basically, this problem generates a set of 3 problem parts from a pool
of 4.<br>
<br>
I create a sequence, which imports 4 copies of the same Master.problem
shown below. The Master.problem pieces are renamed Sheet1, Sheet2,
Sheet3, and Sheet4. That sequence is then put in the student's folders
(as Course Coordinator).<br>
<br>
Everything works great: each student sees a different set of problems
on each sheet. Sheet3 may have the same problem as on Sheet1, but with
re-randomized parameters.<br>
<br>
The only problem: as Course Coordinator, the CHRT routine does not
report any scores for students that have answered questions. I assume
this is because I do not understand part ids at all. I assigned each
part an arbitrary id, hoping the system would track the questions using
these ids as some hash key. Gosh, my ignorant approach didn't seem to
work.<br>
<br>
Is there a better/correct way of assigning part ids so the system can corre=
ctly keep score?<br>
<br>
Thanks,<br>
brew<br>
<br>
<br>
Master.problem-----------------------------------------------------------<b=
r>
<br>
&lt;problem&gt;<br>
&lt;script type=3D"loncapa/perl"&gt;<br>
&nbsp;$DesiredNumProblems =3D 3;<br>
<br>
&nbsp;push @DirectoryArr,"2006JanLib/question=5F001.library"; push @PartId,=
100;<br>
&nbsp;push @DirectoryArr,"2006JanLib/question=5F002.library"; push @PartId,=
200;<br>
<br>
&nbsp;push @DirectoryArr,"2003JunLib/question=5F001.library"; push @PartId,=
1000;<br>
&nbsp;push @DirectoryArr,"2003JunLib/question=5F002.library"; push @PartId,=
1100;<br>
<br>
&nbsp;$probCount =3D $#DirectoryArr;<br>
<br>
&nbsp;# build array of random problem numbers<br>
&nbsp;$i=3D0;<br>
</font><font size=3D"2"># indices into DirectoryArr for the 15 problems we =
wish to generate<br>
</font><font size=3D"2">@NumList=3D(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);&nbsp; <=
br>
&nbsp;do&nbsp; <br>
&nbsp;&nbsp;&nbsp; {<br>
&nbsp;&nbsp;&nbsp; $a =3D &amp;random (1,$probCount,1);<br>
&nbsp;&nbsp;&nbsp; $found =3D "false";<br>
&nbsp;&nbsp;&nbsp; for ($j=3D0; $j &lt; $i; $j++)<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if ($NumList[$j] =3D=3D $a)<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $found=3D"true";<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>
&nbsp;&nbsp;&nbsp; if ($found eq "false")<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $NumList[$i]=3D$a;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $i++;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>
&nbsp;&nbsp;&nbsp; }<br>
while ($i &lt; $DesiredNumProblems);<br>
&lt;/script&gt;<br>
<br>
<br>
&lt;part id=3D"$PartId[0]"&gt;<br>
&lt;import id=3D"11"&gt;$DirectoryArr[$NumList[0]]&lt;/import&gt;<br>
&lt;/part&gt;<br>
<br>
&lt;part id=3D"$PartId[1]"&gt;<br>
&lt;import id=3D"12"&gt;$DirectoryArr[$NumList[1]]&lt;/import&gt;<br>
&lt;/part&gt;<br>
<br>
&lt;part id=3D"$PartId[2]"&gt;<br>
&lt;import id=3D"13"&gt;$DirectoryArr[$NumList[2]]&lt;/import&gt;<br>
&lt;/part&gt;<br>
&lt;/problem&gt;<br>
<br>
<br>
<br>
</font>=