<helper title="Course Parameter Helper" requiredpriv='opa&S'>
<exec>
# 'dateTypeHash' should really be renamed now that we have tries...
my %dateTypeHash = ('open_date' => "opening date",
'due_date' => "due date",
'answer_date' => "answer open date",
'tries' => 'number of tries',
'weight' => 'problem weight'
);
my %levelTypeHash = ('whole_course' => "all problems in the course",
'map' => 'the selected folder',
'resource' => 'the selected problem');
$helper->{DATA}->{'dateTypeHash'} = \%dateTypeHash;
$helper->{DATA}->{'levelTypeHash'} = \%levelTypeHash;
$helper->{DATA}->{'levelType'} = sub {
return $helper->{DATA}->{'levelTypeHash'}->{$helper->{VARS}->{GRANULARITY}};
};
$helper->{DATA}->{'dateType'} = sub {
return $helper->{DATA}->{'dateTypeHash'}->{$helper->{VARS}->{ACTION_TYPE}};
};
</exec>
<state name="START" title="Welcome to the Assignment Parameter Helper">
<message nextstate="CHOOSE_LEVEL">
<p>This helper will assist you in <b>setting the open, due,
and answer dates</b> for problems, <b>setting the problem
weights</b>, or in <b>setting the number of tries</b> for
problems.</p>
<p>You will be asked to <b>select which problems</b> you wish to
set the parameters for, then <b>what parameter</b> you
wish to set, then you will select <b>whom the setting
affects</b>.</p>
<p>After the helper is done, you will be shown where in
the advanced interface you would have gone to set
the parameter you have chosen, so in the future you
can do it directly.</p>
<p>Press <b>Next -></b> to begin, or select <b><-
Previous</b> to go back to the previous screen.</p>
</message>
</state>
<state name="CHOOSE_LEVEL" title="Which Problem or Problems?">
<message>Which problems do you wish to set a parameter for?</message>
<choices variable="GRANULARITY">
<choice computer="whole_course" nextstate="CHOOSE_ACTION">
Course default for all problems
</choice>
<condition>
<clause>return 1 if (&Apache::lonnet::get_server_loncaparev($env{'course.'.$env{'request.course.id'}.'.home'}) >= 2.12)</clause>
<choice computer="maprecurse" nextstate="CHOOSE_FOLDER">
Every problem in a particular folder and (recursively) for sub-folders
(overrides course default)
</choice>
<condition>
<choice computer="map" nextstate="CHOOSE_FOLDER">
Every problem in a particular folder (overrides course default)
</choice>
<choice computer="resource" nextstate="CHOOSE_RESOURCE">
One particular problem (overrides folder and course defaults)
</choice>
</choices>
</state>
<state name="CHOOSE_FOLDER" title="Select Folder">
<message>Select the folder you wish to set the parameter for:</message>
<resource variable="RESOURCE_ID">
<nextstate>CHOOSE_ACTION</nextstate>
<filterfunc>return $res->is_map()</filterfunc>
<valuefunc>return $res->map_pc();</valuefunc>
</resource>
</state>
<state name="CHOOSE_RESOURCE" title="Select Problem">
<message>Select the problem you wish to set the parameter for:</message>
<resource variable="RESOURCE_ID" nextstate="CHOOSE_ACTION" addparts="true">
<nextstate>CHOOSE_ACTION</nextstate>
<filterfunc>return $res->is_map || $res->is_problem()</filterfunc>
<choicefunc>return $res->is_problem()</choicefunc>
</resource>
</state>
<state name="CHOOSE_ACTION" title="Parameter Type">
<eval>return &mt('What parameter do you want to set for ' .
&{$helper->{DATA}->{'levelType'}}()
. '?');
</eval>
<choices variable="ACTION_TYPE">
<nextstate>CHOOSE_DATE</nextstate>
<choice computer="open_date" nextstate="CHOOSE_DATE">Set an <b>open date</b></choice>
<choice computer="due_date" nextstate="CHOOSE_DATE">Set a <b>due date</b></choice>
<choice computer="answer_date" nextstate="CHOOSE_DATE">Set an <b>answer open date</b></choice>
<choice computer="tries" nextstate="CHOOSE_TRIES">Set the <b>number of tries</b></choice>
<choice computer="weight" nextstate="CHOOSE_WEIGHT">Set the <b>problem weight</b></choice>
</choices>
</state>
<state name="CHOOSE_WEIGHT" title="Set Problem Weight">
<eval>return &mt('What weight should be set for ' .
&{$helper->{DATA}->{'levelType'}}()
. '?').'<br />';
</eval>
<string nextstate="CHOOSE_STUDENT_LEVEL" variable="WEIGHT">
<validator>if ($val !~ /^[1234567890]+(\.[1234567890]+)?$/) {
return &mt('[_1] is not an acceptable weight. Weight must be a positive number.','"'.$element->getValue().'"');
}
return undef;
</validator>
</string>
</state>
<state name="CHOOSE_TRIES" title="Set Problem Tries">
<eval>return &mt('How many tries should be set for ' .
&{$helper->{DATA}->{'levelType'}}()
. '?').'<br />';
</eval>
<string nextstate="CHOOSE_STUDENT_LEVEL" variable="TRIES">
<validator>if ($val !~ /^[1234567890]+$/) {
return &mt('[_1] is not an acceptable number of tries. Tries must be a positive number with no decimal point.','"'.$element->getValue().'"');}
return undef;
</validator>
</string>
</state>
<state name="CHOOSE_DATE" title="Set Date">
<eval>
return &mt('What should the ' .
&{$helper->{DATA}->{'dateType'}}() .
' be set to?').'<br /><br />';
</eval>
<date variable="PARM_DATE" hoursminutes='1'>
<nextstate>CHOOSE_STUDENT_LEVEL</nextstate>
</date>
</state>
<state name="CHOOSE_STUDENT_LEVEL" title="Students Affected">
<eval>
return &mt('Set ' .
&{$helper->{DATA}->{'dateType'}}() .
' for ' .
&{$helper->{DATA}->{'levelType'}}() .
' for ...');
</eval>
<choices variable="TARGETS">
<condition>
<clause>return 1 if ($env{'request.course.sec'} eq '')</clause>
<choice computer="course" nextstate="FINISH">
. . . for <b>all students</b> in the course</choice>
</condition>
<choice computer="section" nextstate="CHOOSE_SECTION">
. . . for a particular <b>section</b></choice>
<condition>
<clause>return 1 if (($env{'request.course.groups'} ne '') || (&Apache::lonnet::allowed('mdg',$env{'request.course.id'}) && (&Apache::longroup::coursegroups())))</clause>
<choice computer="group" nextstate="CHOOSE_GROUP">
. . . for a particular <b>group</b></choice>
</condition>
<choice computer="student" nextstate="CHOOSE_STUDENT">
. . . for an individual <b>student</b> or <b>user</b></choice>
</choices>
</state>
<state name="CHOOSE_SECTION" title="Select Section">
<eval>
return &mt('Please select the section you wish to set the ' .
&{$helper->{DATA}->{'dateType'}}() .
' for:').'<br />';</eval>
<section variable="SECTION_NAME" nextstate="FINISH" onlysections="1" />
</state>
<state name="CHOOSE_GROUP" title="Select Group">
<eval>
return &mt('Please select the group you wish to set the ' .
&{$helper->{DATA}->{'dateType'}}() .
' for:').'<br />';</eval>
<group variable="GROUP_NAME" nextstate="FINISH" grouponly="1" />
</state>
<state name="CHOOSE_STUDENT" title="Select User">
<eval>
return &mt('Please select the person you wish to set the ' .
&{$helper->{DATA}->{'dateType'}}() .
' for:').'<br />';</eval>
<student variable="USER_NAME" nextstate="FINISH" coursepersonnel="1" sectiononly="1" />
</state>
<state name="FINISH" title="Verify Selection">
<parmwizfinal />
</state>
</helper>
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>