version 1.474, 2010/08/08 02:00:50
|
version 1.482, 2010/12/31 00:58:10
|
Line 161 function setmode(form,probmode) {
|
Line 161 function setmode(form,probmode) {
|
ENDSCRIPT |
ENDSCRIPT |
} |
} |
|
|
|
sub file_delchk_js { |
|
my $delfilewarn = &mt('You have indicated you wish to delete some files previously included for submission.').'\\n'. |
|
&mt('Deleted files will not be graded.').' '. |
|
&mt('Submit Answer?'); |
|
return <<"ENDSCRIPT"; |
|
<script type="text/javascript"> |
|
function file_deletion_check(formname) { |
|
var elemnum = formname.elements.length; |
|
if (elemnum == 0) { |
|
return true; |
|
} |
|
var str = new RegExp("^HWFILE.+_delete\$"); |
|
var delboxes = new Array(); |
|
for (var i=0; i<formname.elements.length; i++) { |
|
var id = formname.elements[i].id; |
|
if (id != '') { |
|
if (str.test(id)) { |
|
if (formname.elements[i].type == 'checkbox') { |
|
if (formname.elements[i].checked) { |
|
delboxes.push(id); |
|
} |
|
} |
|
} |
|
} |
|
} |
|
if (delboxes.length > 0) { |
|
if (confirm("$delfilewarn")) { |
|
return true; |
|
} else { |
|
for (var j=0; j<delboxes.length; j++) { |
|
formname.elements[delboxes[j]].checked = false; |
|
} |
|
return false; |
|
} |
|
} else { |
|
return true; |
|
} |
|
} |
|
</script> |
|
ENDSCRIPT |
|
} |
|
|
sub page_start { |
sub page_start { |
my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$name, |
my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$name, |
$extra_head)=@_; |
$extra_head)=@_; |
Line 185 sub page_start {
|
Line 227 sub page_start {
|
); |
); |
$extra_head .= &Apache::lonhtmlcommon::htmlareaselectactive(\%textarea_args); |
$extra_head .= &Apache::lonhtmlcommon::htmlareaselectactive(\%textarea_args); |
} |
} |
|
my $is_task = ($env{'request.uri'} =~ /\.task$/); |
|
if ($is_task) { |
|
$extra_head .= &file_delchk_js(); |
|
} |
|
|
my %body_args; |
my %body_args; |
if (defined($found{'html'})) { |
if (defined($found{'html'})) { |
Line 277 sub page_start {
|
Line 323 sub page_start {
|
if ($target eq 'edit') { |
if ($target eq 'edit') { |
$form_tag_start.=&Apache::edit::form_change_detection(); |
$form_tag_start.=&Apache::edit::form_change_detection(); |
} |
} |
|
if ($is_task) { |
|
$form_tag_start .= ' onsubmit="return file_deletion_check(this);"'; |
|
} |
$form_tag_start.='>'."\n"; |
$form_tag_start.='>'."\n"; |
|
|
my $symb=&Apache::lonnet::symbread(); |
my $symb=&Apache::lonnet::symbread(); |
Line 318 sub get_resource_name {
|
Line 367 sub get_resource_name {
|
} |
} |
|
|
sub setup_rndseed { |
sub setup_rndseed { |
my ($safeeval)=@_; |
my ($safeeval,$target)=@_; |
my $rndseed; |
|
my ($symb)=&Apache::lonnet::whichuser(); |
my ($symb)=&Apache::lonnet::whichuser(); |
|
my ($questiontype,$set_safespace,$rndseed); |
|
if ($target eq 'analyze') { |
|
$questiontype = $env{'form.grade_questiontype'}; |
|
} |
|
unless (defined($questiontype)) { |
|
$questiontype = $Apache::lonhomework::type; |
|
} |
if ($env{'request.state'} eq "construct" |
if ($env{'request.state'} eq "construct" |
|| $symb eq '' |
|| $symb eq '' |
|| $Apache::lonhomework::type eq 'practice' |
|| $Apache::lonhomework::type eq 'practice' |
Line 335 sub setup_rndseed {
|
Line 390 sub setup_rndseed {
|
} |
} |
$env{'form.rndseed'}=$rndseed; |
$env{'form.rndseed'}=$rndseed; |
} |
} |
|
if (($env{'request.state'} eq "construct") && |
|
($Apache::lonhomework::type eq 'randomizetry')) { |
|
my $tries = $Apache::lonhomework::history{"resource.$Apache::inputtags::part.tries"}; |
|
if ($tries) { |
|
$rndseed += $tries; |
|
} |
|
$env{'form.'.$Apache::inputtags::part.'.rndseed'}=$rndseed; |
|
} |
if ( ($env{'form.resetdata'} eq &mt('New Problem Variation') |
if ( ($env{'form.resetdata'} eq &mt('New Problem Variation') |
&& $env{'form.submitted'} eq 'yes') || |
&& $env{'form.submitted'} eq 'yes') || |
$env{'form.newrandomization'} eq &mt('New Randomization')) { |
$env{'form.newrandomization'} eq &mt('New Randomization')) { |
Line 350 sub setup_rndseed {
|
Line 413 sub setup_rndseed {
|
if ($Apache::lonhomework::history{'resource.CODE'}) { |
if ($Apache::lonhomework::history{'resource.CODE'}) { |
$rndseed=&Apache::lonnet::rndseed(); |
$rndseed=&Apache::lonnet::rndseed(); |
} |
} |
if ($safeeval) { |
$set_safespace = 1; |
&Apache::lonxml::debug("Setting rndseed to $rndseed"); |
} elsif ($questiontype eq 'randomizetry') { |
&Apache::run::run('$external::randomseed="'.$rndseed.'";',$safeeval); |
if ($target eq 'analyze') { |
} |
if (defined($env{'form.grade_rndseed'})) { |
|
$rndseed = $env{'form.grade_rndseed'}; |
|
} |
|
} |
|
unless (($target eq 'analyze') && (defined($rndseed))) { |
|
$rndseed=&Apache::lonnet::rndseed(); |
|
my $curr_try = $Apache::lonhomework::history{"resource.$Apache::inputtags::part.tries"}; |
|
if ($Apache::inputtags::status[-1] eq 'CAN_ANSWER') { |
|
$curr_try ++; |
|
} |
|
if ($rndseed =~/^(\d+)[,:](\d+)$/) { |
|
$rndseed = $1; |
|
} |
|
if ($curr_try) { |
|
my $reqtries = &Apache::lonnet::EXT("resource.$Apache::inputtags::part.randomizeontries"); |
|
if (($reqtries =~ /^\d+$/) && ($reqtries > 1)) { |
|
my $inc = int(($curr_try-1)/$reqtries); |
|
$rndseed += $inc; |
|
} else { |
|
$rndseed += $curr_try; |
|
} |
|
} |
|
} |
|
$set_safespace = 1; |
|
} |
|
if ($set_safespace) { |
|
if ($safeeval) { |
|
&Apache::lonxml::debug("Setting rndseed to $rndseed"); |
|
&Apache::run::run('$external::randomseed="'.$rndseed.'";',$safeeval); |
|
} |
|
} |
|
unless (($env{'request.state'} eq "construct") || ($symb eq '')) { |
|
$env{'form.'.$Apache::inputtags::part.'.rndseed'}=$rndseed; |
} |
} |
return $rndseed; |
return $rndseed; |
} |
} |
Line 471 sub problem_web_to_edit_header {
|
Line 566 sub problem_web_to_edit_header {
|
".&option('anonsurvey' ,'problemtype').&mt("Anonymous Survey Question")."</option> |
".&option('anonsurvey' ,'problemtype').&mt("Anonymous Survey Question")."</option> |
".&option('anonsurveycred' ,'problemtype').&mt("Anonymous Survey Question (with credit)")."</option> |
".&option('anonsurveycred' ,'problemtype').&mt("Anonymous Survey Question (with credit)")."</option> |
".&option('practice' ,'problemtype').&mt("Practice Problem")."</option> |
".&option('practice' ,'problemtype').&mt("Practice Problem")."</option> |
|
".&option('randomizetry' ,'problemtype').&mt("New Randomization Each Try")."</option> |
</select> |
</select> |
</span> |
</span> |
$show_all |
$show_all |
Line 648 item store_aggregates()
|
Line 744 item store_aggregates()
|
|
|
sub store_aggregates { |
sub store_aggregates { |
my ($symb,$courseid) = @_; |
my ($symb,$courseid) = @_; |
my (%aggregate,%anoncounter); |
my (%aggregate,%anoncounter,%randtrycounter); |
my @parts; |
my @parts; |
my $cdomain = $env{'course.'.$env{'request.course.id'}.'.domain'}; |
my $cdomain = $env{'course.'.$env{'request.course.id'}.'.domain'}; |
my $cname = $env{'course.'.$env{'request.course.id'}.'.num'}; |
my $cname = $env{'course.'.$env{'request.course.id'}.'.num'}; |
Line 678 sub store_aggregates {
|
Line 774 sub store_aggregates {
|
$aggregate{$symb."\0".$part."\0attempts"} = 1; |
$aggregate{$symb."\0".$part."\0attempts"} = 1; |
} |
} |
if (($Apache::lonhomework::results{'resource.'.$part.'.type'} eq 'anonsurvey') || |
if (($Apache::lonhomework::results{'resource.'.$part.'.type'} eq 'anonsurvey') || |
($Apache::lonhomework::results{'resource.'.$part.'.type'} eq 'anonsurveycred')) { |
($Apache::lonhomework::results{'resource.'.$part.'.type'} eq 'anonsurveycred') || |
$anoncounter{$symb."\0".$part} = 1; |
($Apache::lonhomework::results{'resource.'.$part.'.type'} eq 'randomizetry')) { |
|
if ($Apache::lonhomework::results{'resource.'.$part.'.type'} eq 'randomizetry') { |
|
$randtrycounter{$symb."\0".$part} = 1; |
|
} else { |
|
$anoncounter{$symb."\0".$part} = 1; |
|
} |
my $needsrelease = $Apache::lonnet::needsrelease{'parameter:type:'.$Apache::lonhomework::results{'resource.'.$part.'.type'}}; |
my $needsrelease = $Apache::lonnet::needsrelease{'parameter:type:'.$Apache::lonhomework::results{'resource.'.$part.'.type'}}; |
if ($needsrelease) { |
if ($needsrelease) { |
my $curr_required = $env{'course.'.$env{'request.course.id'}.'.internal.releaserequired'}; |
my $curr_required = $env{'course.'.$env{'request.course.id'}.'.internal.releaserequired'}; |
Line 700 sub store_aggregates {
|
Line 801 sub store_aggregates {
|
$cdomain,$cname); |
$cdomain,$cname); |
} |
} |
if (keys(%anoncounter) > 0) { |
if (keys(%anoncounter) > 0) { |
&Apache::lonnet::cinc('nohist_anonsurveys',\%anoncounter, |
&Apache::lonnet::cput('nohist_anonsurveys',\%anoncounter, |
$cdomain,$cname); |
$cdomain,$cname); |
|
} |
|
if (keys(%randtrycounter) > 0) { |
|
&Apache::lonnet::cput('nohist_randomizetry',\%randtrycounter, |
|
$cdomain,$cname); |
} |
} |
} |
} |
|
|
Line 783 sub init_problem_globals {
|
Line 888 sub init_problem_globals {
|
&Apache::lonhomework::reset_show_problem_status(); |
&Apache::lonhomework::reset_show_problem_status(); |
$Apache::lonhomework::ignore_response_errors=1; |
$Apache::lonhomework::ignore_response_errors=1; |
} |
} |
|
@Apache::functionplotresponse::callscripts=(); |
@Apache::inputtags::responselist = (); |
@Apache::inputtags::responselist = (); |
@Apache::inputtags::importlist = (); |
@Apache::inputtags::importlist = (); |
@Apache::inputtags::previous=(); |
@Apache::inputtags::previous=(); |
Line 810 sub reset_problem_globals {
|
Line 916 sub reset_problem_globals {
|
undef($Apache::lonhomework::type); |
undef($Apache::lonhomework::type); |
undef($Apache::lonhomework::scantronmode); |
undef($Apache::lonhomework::scantronmode); |
undef($Apache::lonhomework::ignore_response_errors); |
undef($Apache::lonhomework::ignore_response_errors); |
|
undef(@Apache::functionplotresponse::callscripts); |
&Apache::lonhomework::reset_show_problem_status(); |
&Apache::lonhomework::reset_show_problem_status(); |
} |
} |
|
|
Line 910 sub start_problem {
|
Line 1017 sub start_problem {
|
|
|
if ($target eq 'tex' and $env{'request.symb'} =~ m/\.page_/) {$result='';} |
if ($target eq 'tex' and $env{'request.symb'} =~ m/\.page_/) {$result='';} |
|
|
if ($target eq 'analyze') { my $rndseed=&setup_rndseed($safeeval); } |
if ($target eq 'analyze') { my $rndseed=&setup_rndseed($safeeval,$target); } |
if ($target eq 'web' || $target eq 'grade' || $target eq 'answer' || |
if ($target eq 'web' || $target eq 'grade' || $target eq 'answer' || |
$target eq 'tex') { |
$target eq 'tex') { |
if ($env{'form.markaccess'}) { |
if ($env{'form.markaccess'}) { |
my @interval=&Apache::lonnet::EXT("resource.0.interval"); |
my @interval=&Apache::lonnet::EXT("resource.0.interval"); |
&Apache::lonnet::set_first_access($interval[1]); |
&Apache::lonnet::set_first_access($interval[1]); |
} |
} |
|
|
|
($status,$accessmsg,my $slot_name,my $slot) = |
|
&Apache::lonhomework::check_slot_access('0','problem'); |
|
push (@Apache::inputtags::status,$status); |
|
|
#handle rand seed in construction space |
#handle rand seed in construction space |
my $rndseed=&setup_rndseed($safeeval); |
my $rndseed=&setup_rndseed($safeeval,$target); |
my ($symb)=&Apache::lonnet::whichuser(); |
my ($symb)=&Apache::lonnet::whichuser(); |
|
|
if ($env{'request.state'} ne "construct" && |
if ($env{'request.state'} ne "construct" && |
($symb eq '' || $Apache::lonhomework::type eq 'practice')) { |
($symb eq '' || $Apache::lonhomework::type eq 'practice')) { |
$form_tag_start.='<input type="hidden" name="rndseed" value="'. |
$form_tag_start.='<input type="hidden" name="rndseed" value="'. |
Line 945 sub start_problem {
|
Line 1058 sub start_problem {
|
$form_tag_start.=&practice_problem_header(); |
$form_tag_start.=&practice_problem_header(); |
} |
} |
$form_tag_start.='<hr />'; |
$form_tag_start.='<hr />'; |
} |
} elsif (($env{'request.state'} ne "construct") && |
|
($Apache::lonhomework::type eq 'randomizetry') && |
($status,$accessmsg,my $slot_name,my $slot) = |
($status eq 'CAN_ANSWER')) { |
&Apache::lonhomework::check_slot_access('0','problem'); |
my $reqtries = &Apache::lonnet::EXT("resource.$Apache::inputtags::part.randomizeontries"); |
push (@Apache::inputtags::status,$status); |
my $problemstatus = &get_problem_status($Apache::inputtags::part); |
|
$form_tag_start.=&randomizetry_problem_header($problemstatus,$reqtries); |
|
} |
|
|
my $expression='$external::datestatus="'.$status.'";'; |
my $expression='$external::datestatus="'.$status.'";'; |
$expression.='$external::gradestatus="'.$Apache::lonhomework::history{"resource.0.solved"}.'";'; |
$expression.='$external::gradestatus="'.$Apache::lonhomework::history{"resource.0.solved"}.'";'; |
Line 1030 sub start_problem {
|
Line 1145 sub start_problem {
|
$result .= '<input type="hidden" name="grade_'.$field. |
$result .= '<input type="hidden" name="grade_'.$field. |
'" value="'.$env{"form.grade_$field"}.'" />'."\n"; |
'" value="'.$env{"form.grade_$field"}.'" />'."\n"; |
} |
} |
|
foreach my $field ('trial','questiontype') { |
|
if ($env{"form.grade_$field"} ne '') { |
|
$result .= '<input type="hidden" name="grade_'.$field. |
|
'" value="'.$env{"form.grade_$field"}.'" />'."\n"; |
|
} |
|
} |
} |
} |
} elsif ($target eq 'tex') { |
} elsif ($target eq 'tex') { |
$result .= 'INSERTTEXFRONTMATTERHERE'; |
$result .= 'INSERTTEXFRONTMATTERHERE'; |
Line 1202 sub end_problem {
|
Line 1323 sub end_problem {
|
} |
} |
} |
} |
} |
} |
|
if ($target eq 'web') { |
|
$result.=&Apache::functionplotresponse::init_script(); |
|
} |
if ($target eq 'grade') { |
if ($target eq 'grade') { |
&Apache::lonhomework::showhash(%Apache::lonhomework::results); |
&Apache::lonhomework::showhash(%Apache::lonhomework::results); |
&finalize_storage(); |
&finalize_storage(); |
Line 1259 sub start_library {
|
Line 1383 sub start_library {
|
($result,$form_tag_start)= |
($result,$form_tag_start)= |
&page_start($target,$token,$tagstack,$parstack,$parser,$safeeval, |
&page_start($target,$token,$tagstack,$parstack,$parser,$safeeval, |
$name); |
$name); |
my $rndseed=&setup_rndseed($safeeval); |
my $rndseed=&setup_rndseed($safeeval,$target); |
$result.=" \n $form_tag_start". |
$result.=" \n $form_tag_start". |
'<input type="hidden" name="submitted" value="yes" />'; |
'<input type="hidden" name="submitted" value="yes" />'; |
$result.=&problem_web_to_edit_header($rndseed); |
$result.=&problem_web_to_edit_header($rndseed); |
Line 1835 sub start_part {
|
Line 1959 sub start_part {
|
|
|
} |
} |
} elsif ($target eq 'web') { |
} elsif ($target eq 'web') { |
$result.='<a name="'.&escape($Apache::inputtags::part).'" />'; |
if ($status eq 'CAN_ANSWER') { |
|
my $problemstatus = &get_problem_status($Apache::inputtags::part); |
|
my $probrandomize = &Apache::lonnet::EXT("resource.$Apache::inputtags::partlist[0].type"); |
|
my $probrandtries = &Apache::lonnet::EXT("resource.$Apache::inputtags::partlist[0].randomizeontries"); |
|
my $num = scalar(@Apache::inputtags::partlist)-1; |
|
if ($probrandomize eq 'randomizetry') { |
|
if (&Apache::lonnet::EXT("resource.$Apache::inputtags::part.type") ne 'randomizetry') { |
|
$result .= &randomizetry_part_header($problemstatus,'none',$num); |
|
} else { |
|
my $reqtries = &Apache::lonnet::EXT("resource.$Apache::inputtags::part.randomizeontries"); |
|
if ($probrandtries ne $reqtries) { |
|
$result .= &randomizetry_part_header($problemstatus,$reqtries,$num); |
|
} |
|
} |
|
} elsif (&Apache::lonnet::EXT("resource.$Apache::inputtags::part.type") eq 'randomizetry') { |
|
my $reqtries = &Apache::lonnet::EXT("resource.$Apache::inputtags::part.randomizeontries"); |
|
$result .= &randomizetry_part_header($problemstatus,$reqtries,$num); |
|
} |
|
} |
|
$result.='<a name="'.&escape($Apache::inputtags::part).'" ></a>'; |
} |
} |
} |
} |
} |
} |
Line 2006 sub start_problemtype {
|
Line 2149 sub start_problemtype {
|
['anonsurvey','Anonymous Survey'], |
['anonsurvey','Anonymous Survey'], |
['anonsurveycred','Anonymous Survey (with credit)'], |
['anonsurveycred','Anonymous Survey (with credit)'], |
['problem','Homework Problem'], |
['problem','Homework Problem'], |
['practice','Practice Problem'] ] |
['practice','Practice Problem'], |
|
['randomizetry','New Randomization Each Try'] ] |
,$token); |
,$token); |
$result .=&Apache::edit::end_row().&Apache::edit::start_spanning_row(); |
$result .=&Apache::edit::end_row().&Apache::edit::start_spanning_row(); |
} elsif ($target eq 'modified') { |
} elsif ($target eq 'modified') { |
Line 2141 sub practice_problem_header {
|
Line 2285 sub practice_problem_header {
|
'</span>'; |
'</span>'; |
} |
} |
|
|
|
sub randomizetry_problem_header { |
|
my ($problemstatus,$reqtries) = @_; |
|
my ($header,$text); |
|
if ($reqtries > 1) { |
|
$header = &mt('New Problem Variation After Every [quant,_1,Try,Tries]',$reqtries); |
|
if (($problemstatus eq 'no') || |
|
($problemstatus eq 'no_feedback_ever')) { |
|
$text = &mt('A new variation will be generated after every [quant,_1,try,tries], until the tries limit is reached.',$reqtries); |
|
} else { |
|
$text = &mt('A new variation will be generated after every [quant,_1,try,tries], until correct or tries limit is reached.',$reqtries); |
|
} |
|
} else { |
|
$header = &mt('New Problem Variation Each Try'); |
|
if (($problemstatus eq 'no') || |
|
($problemstatus eq 'no_feedback_ever')) { |
|
$text = &mt('A new variation will be generated after each try until the tries limit is reached.'); |
|
|
|
} else { |
|
$text = &mt('A new variation will be generated after each try until correct or tries limit is reached.'); |
|
} |
|
} |
|
return '<span class="LC_info"><h3>'.$header.'</h3></span>'. |
|
'<span class="LC_info">'.$text.'</span><hr />'; |
|
} |
|
|
|
sub randomizetry_part_header { |
|
my ($problemstatus,$reqtries,$num) = @_; |
|
my ($header,$text); |
|
if ($reqtries eq 'none') { |
|
$header = &mt('No Question Variation'); |
|
$text = &mt('For this question there will no new variation after a try.'); |
|
} elsif ($reqtries > 1) { |
|
$header = &mt('New Question Variation After Every [quant,_1,Try,Tries]',$reqtries); |
|
if (($problemstatus eq 'no') || |
|
($problemstatus eq 'no_feedback_ever')) { |
|
$text = &mt('For this question a new variation will be generated after every [quant,_1,try,tries], until the tries limit is reached.',$reqtries); |
|
} else { |
|
$text = &mt('For this question a new variation will be generated after every [quant,_1,try,tries], until correct or tries limit is reached.',$reqtries); |
|
} |
|
} else { |
|
$header = &mt('New Question Variation For Each Try'); |
|
if (($problemstatus eq 'no') || |
|
($problemstatus eq 'no_feedback_ever')) { |
|
$text = &mt('For this question a new variation will be generated after each try until the tries limit is reached.'); |
|
} else { |
|
$text = &mt('For this question a new variation will be generated after each try until correct or tries limit is reached.'); |
|
} |
|
} |
|
my $output; |
|
if ($num > 1) { |
|
$output .= '<hr />'; |
|
} |
|
$output .= '<span class="LC_info"><h4>'.$header.'</h4></span>'. |
|
'<span class="LC_info">'.$text.'</span><br /><br />'; |
|
return $output; |
|
} |
|
|
1; |
1; |
__END__ |
__END__ |
|
|