[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>
<problem><br>
<script type=3D"loncapa/perl"><br>
$DesiredNumProblems =3D 3;<br>
<br>
push @DirectoryArr,"2006JanLib/question=5F001.library"; push @PartId,=
100;<br>
push @DirectoryArr,"2006JanLib/question=5F002.library"; push @PartId,=
200;<br>
<br>
push @DirectoryArr,"2003JunLib/question=5F001.library"; push @PartId,=
1000;<br>
push @DirectoryArr,"2003JunLib/question=5F002.library"; push @PartId,=
1100;<br>
<br>
$probCount =3D $#DirectoryArr;<br>
<br>
# build array of random problem numbers<br>
$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); <=
br>
do <br>
{<br>
$a =3D &random (1,$probCount,1);<br>
$found =3D "false";<br>
for ($j=3D0; $j < $i; $j++)<br>
{<br>
if ($NumList[$j] =3D=3D $a)<br>
{<br>
$found=3D"true";<br>
}<br>
}<br>
if ($found eq "false")<br>
{<br>
$NumList[$i]=3D$a;<br>
$i++;<br>
}<br>
}<br>
while ($i < $DesiredNumProblems);<br>
</script><br>
<br>
<br>
<part id=3D"$PartId[0]"><br>
<import id=3D"11">$DirectoryArr[$NumList[0]]</import><br>
</part><br>
<br>
<part id=3D"$PartId[1]"><br>
<import id=3D"12">$DirectoryArr[$NumList[1]]</import><br>
</part><br>
<br>
<part id=3D"$PartId[2]"><br>
<import id=3D"13">$DirectoryArr[$NumList[2]]</import><br>
</part><br>
</problem><br>
<br>
<br>
<br>
</font>=