[LON-CAPA-cvs] cvs: loncom /homework default_homework.lcpm /homework/templates DropBox.problem examupload.problem /html/adm/help/tex Problem_LON-CAPA_Functions.tex Script_Functions.tex
www
www@source.lon-capa.org
Sat, 21 May 2011 14:50:44 -0000
www Sat May 21 14:50:44 2011 EDT
Modified files:
/loncom/homework default_homework.lcpm
/loncom/homework/templates DropBox.problem examupload.problem
/loncom/html/adm/help/tex Problem_LON-CAPA_Functions.tex
Script_Functions.tex
Log:
Easier access to parameters and stored data.
Index: loncom/homework/default_homework.lcpm
diff -u loncom/homework/default_homework.lcpm:1.153 loncom/homework/default_homework.lcpm:1.154
--- loncom/homework/default_homework.lcpm:1.153 Sat May 21 14:08:06 2011
+++ loncom/homework/default_homework.lcpm Sat May 21 14:50:36 2011
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# used by lonxml::xmlparse() as input variable $safeinit to Apache::run::run()
#
-# $Id: default_homework.lcpm,v 1.153 2011/05/21 14:08:06 www Exp $
+# $Id: default_homework.lcpm,v 1.154 2011/05/21 14:50:36 www Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -1209,6 +1209,18 @@
return &EXT('resource.'.$partid.'.answerdate');
}
+sub parameter_setting {
+ my ($which,$partid)=@_;
+ unless ($partid) { $partid=0; }
+ return &EXT('resource.'.$partid.'.'.$which);
+}
+
+sub stored_data {
+ my ($which,$partid)=@_;
+ unless ($partid) { $partid=0; }
+ return &EXT('user.resource.resource.'.$partid.'.'.$which);
+}
+
sub array_moments {
my @input=@_;
my (@output,$N);
Index: loncom/homework/templates/DropBox.problem
diff -u loncom/homework/templates/DropBox.problem:1.17 loncom/homework/templates/DropBox.problem:1.18
--- loncom/homework/templates/DropBox.problem:1.17 Sun May 1 17:17:09 2011
+++ loncom/homework/templates/DropBox.problem Sat May 21 14:50:40 2011
@@ -5,13 +5,13 @@
<parameter name="maxfilesize" id="13" default="10.0" type="float_pos" description="Max. cumulative size (MB) for submitted file(s)" />
<script type="loncapa/perl">
-$weight=&EXT('resource.0.weight');
+$weight=¶meter_setting('weight');
if ((!defined($weight)) || ($weight eq '')) { $weight=1; }
-$awarded=&EXT('user.resource.resource.0.awarded');
-$scoreformat=&EXT('resource.0.scoreformat');
+$awarded=&stored_data('awarded');
+$scoreformat=¶meter_setting('scoreformat');
if (!defined($scoreformat) || $scoreformat eq '') { $scoreformat="2f"; }
$display='';
-if (&EXT('resource.0.problemstatus')!~/^no/) {
+if (¶meter_setting('problemstatus')!~/^no/) {
if (!defined($awarded)) {
$display=$weight.' possible points.';
} else {
@@ -19,13 +19,13 @@
$weight.' possible points.';
}
}
-$comment=&EXT('user.resource.resource.0.comment');
+$comment=&stored_data('comment');
if (!defined($comment) || $comment!~/\w/) {
$comment='';
} else {
$comment='<br /><table><tr><td bgcolor="#FFFFDD">'.$comment.'</td></tr></table>';
}
-$gradeinfo=&EXT('user.resource.resource.0.gradeinfo');
+$gradeinfo=&stored_data('gradeinfo');
if (!defined($gradeinfo) || $gradeinfo!~/\w/) {
$gradeinfo='';
} else {
Index: loncom/homework/templates/examupload.problem
diff -u loncom/homework/templates/examupload.problem:1.14 loncom/homework/templates/examupload.problem:1.15
--- loncom/homework/templates/examupload.problem:1.14 Sun May 1 17:17:09 2011
+++ loncom/homework/templates/examupload.problem Sat May 21 14:50:40 2011
@@ -6,14 +6,14 @@
<parameter name="handgrade" description="Hand Grade" default="yes" type="string_yesno" />
<script type="loncapa/perl">
-$weight=&EXT('resource.0.weight');
+$weight=¶meter_setting('weight');
if ((!defined($weight)) || ($weight eq '')) { $weight=1; }
-$awarded=&EXT('user.resource.resource.0.awarded');
+$awarded=&stored_data('awarded');
if (!defined($awarded)) { $awarded=0; }
-$scoreformat=&EXT('resource.0.scoreformat');
+$scoreformat=¶meter_setting('scoreformat');
if (!defined($scoreformat) || $scoreformat eq '') { $scoreformat="2f"; }
$display='';
-if (&EXT('resource.0.problemstatus')!~/^no/) {
+if (¶meter_setting('problemstatus')!~/^no/) {
if (!defined($awarded)) {
$display=$weight.' possible points.';
} else {
@@ -21,13 +21,13 @@
$weight.' possible points.';
}
}
-$comment=&EXT('user.resource.resource.0.comment');
+$comment=&stored_data('comment');
if (!defined($comment) || $comment!~/\w/) {
$comment='';
} else {
$comment='<br /><table><tr><td bgcolor="#FFFFDD">'.$comment.'</td></tr></table>';
}
-$gradeinfo=&EXT('user.resource.resource.0.gradeinfo');
+$gradeinfo=&stored_data('gradeinfo');
if (!defined($gradeinfo) || $gradeinfo!~/\w/) {
$gradeinfo='';
} else {
Index: loncom/html/adm/help/tex/Problem_LON-CAPA_Functions.tex
diff -u loncom/html/adm/help/tex/Problem_LON-CAPA_Functions.tex:1.20 loncom/html/adm/help/tex/Problem_LON-CAPA_Functions.tex:1.21
--- loncom/html/adm/help/tex/Problem_LON-CAPA_Functions.tex:1.20 Sat May 21 14:08:10 2011
+++ loncom/html/adm/help/tex/Problem_LON-CAPA_Functions.tex Sat May 21 14:50:44 2011
@@ -144,6 +144,12 @@
\&submission(\$partid,\$responseid,\$version) & Returns what the student submitted for response \$responseid in part \$partid. You can get these IDs from the XML-code of the problem. \$version is optional and returns the \$version-th submission of the student that was graded.\\
\hline
+\¶meter\_setting(\$name,\$partid) & Returns the parameter setting \$name. Partid is optional.\\
+\hline
+
+\&stored\_data(\$name,\$partid) & Returns the stored data \$name. Partid is optional.\\
+\hline
+
\¤tpart() &
Returns the ID of the current part.\\
\hline
Index: loncom/html/adm/help/tex/Script_Functions.tex
diff -u loncom/html/adm/help/tex/Script_Functions.tex:1.11 loncom/html/adm/help/tex/Script_Functions.tex:1.12
--- loncom/html/adm/help/tex/Script_Functions.tex:1.11 Sat May 21 14:08:10 2011
+++ loncom/html/adm/help/tex/Script_Functions.tex Sat May 21 14:50:44 2011
@@ -42,6 +42,8 @@
\item map(...)
\item caparesponse\_check
\item caparesponse\_check\_list
+\item parameter\_setting(name,partid)
+\item stored\_data(name,partid)
\end{itemize}