version 1.295, 2008/07/07 11:02:25
|
version 1.311, 2009/05/19 22:52:19
|
Line 173 sub setup_vars {
|
Line 173 sub setup_vars {
|
sub createmenu { |
sub createmenu { |
my ($which,$request)=@_; |
my ($which,$request)=@_; |
if ($which eq 'grade') { |
if ($which eq 'grade') { |
$request->print('<script language="JavaScript"> |
$request->print('<script type="text/javascript" language="JavaScript"> |
hwkmenu=window.open("/res/adm/pages/homeworkmenu.html","homeworkremote", |
hwkmenu=window.open("/res/adm/pages/homeworkmenu.html","homeworkremote", |
"height=350,width=150,menubar=no"); |
"height=350,width=150,menubar=no"); |
</script>'); |
</script>'); |
Line 209 sub proctor_checked_in {
|
Line 209 sub proctor_checked_in {
|
return 0; |
return 0; |
} |
} |
|
|
sub check_ip_acc { |
|
my ($acc)=@_; |
|
&Apache::lonxml::debug("acc is $acc"); |
|
if (!defined($acc) || $acc =~ /^\s*$/ || $acc =~/^\s*no\s*$/i) { |
|
return 1; |
|
} |
|
my $allowed=0; |
|
my $ip=$env{'request.host'} || $ENV{'REMOTE_ADDR'}; |
|
|
|
my $name; |
|
foreach my $pattern (split(',',$acc)) { |
|
$pattern =~ s/^\s*//; |
|
$pattern =~ s/\s*$//; |
|
if ($pattern =~ /\*$/) { |
|
#35.8.* |
|
$pattern=~s/\*//; |
|
if ($ip =~ /^\Q$pattern\E/) { $allowed=1; } |
|
} elsif ($pattern =~ /(\d+\.\d+\.\d+)\.\[(\d+)-(\d+)\]$/) { |
|
#35.8.3.[34-56] |
|
my $low=$2; |
|
my $high=$3; |
|
$pattern=$1; |
|
if ($ip =~ /^\Q$pattern\E/) { |
|
my $last=(split(/\./,$ip))[3]; |
|
if ($last <=$high && $last >=$low) { $allowed=1; } |
|
} |
|
} elsif ($pattern =~ /^\*/) { |
|
#*.msu.edu |
|
$pattern=~s/\*//; |
|
if (!defined($name)) { |
|
use Socket; |
|
my $netaddr=inet_aton($ip); |
|
($name)=gethostbyaddr($netaddr,AF_INET); |
|
} |
|
if ($name =~ /\Q$pattern\E$/i) { $allowed=1; } |
|
} elsif ($pattern =~ /\d+\.\d+\.\d+\.\d+/) { |
|
#127.0.0.1 |
|
if ($ip =~ /^\Q$pattern\E/) { $allowed=1; } |
|
} else { |
|
#some.name.com |
|
if (!defined($name)) { |
|
use Socket; |
|
my $netaddr=inet_aton($ip); |
|
($name)=gethostbyaddr($netaddr,AF_INET); |
|
} |
|
if ($name =~ /\Q$pattern\E$/i) { $allowed=1; } |
|
} |
|
if ($allowed) { last; } |
|
} |
|
return $allowed; |
|
} |
|
|
|
sub check_slot_access { |
sub check_slot_access { |
my ($id,$type)=@_; |
my ($id,$type)=@_; |
|
|
Line 307 sub check_slot_access {
|
Line 255 sub check_slot_access {
|
&Apache::lonhomework::showhash(%slot); |
&Apache::lonhomework::showhash(%slot); |
if ($slot{'starttime'} < time && |
if ($slot{'starttime'} < time && |
$slot{'endtime'} > time && |
$slot{'endtime'} > time && |
&check_ip_acc($slot{'ip'})) { |
&Apache::loncommon::check_ip_acc($slot{'ip'})) { |
&Apache::lonxml::debug("$slot is good"); |
&Apache::lonxml::debug("$slot is good"); |
$slotstatus='NEEDS_CHECKIN'; |
$slotstatus='NEEDS_CHECKIN'; |
$returned_slot=\%slot; |
$returned_slot=\%slot; |
Line 349 sub check_slot_access {
|
Line 297 sub check_slot_access {
|
return ('WAITING_FOR_GRADE'); |
return ('WAITING_FOR_GRADE'); |
} |
} |
|
|
# no slot is currently open, and has been checked in for this version |
# Previously used slot is no longer open, and has been checked in for this version. |
# previous slot is therefore CLOSED, so therefore the problem is |
# However, the problem is not closed, and potentially, another slot might be |
|
# used to gain access to it to work on it, until the due date is reached, and the |
|
# problem then becomes CLOSED. Therefore return the slotstatus - |
|
# (which will be NOT_IN_SLOT). |
if (!defined($slot_name) |
if (!defined($slot_name) |
&& $checkedin |
&& $checkedin |
&& $type eq 'problem') { |
&& $type eq 'problem') { |
return ('CLOSED',$datemsg); |
return ($slotstatus); |
} |
} |
|
|
if ($slotstatus eq 'NOT_IN_A_SLOT' |
if ($slotstatus eq 'NOT_IN_A_SLOT' |
Line 421 sub check_access {
|
Line 372 sub check_access {
|
#if ($env{'request.state'} ne "construct" && $symb ne '') { |
#if ($env{'request.state'} ne "construct" && $symb ne '') { |
if ($env{'request.state'} ne "construct") { |
if ($env{'request.state'} ne "construct") { |
my $idacc = &Apache::lonnet::EXT("resource.$id.acc"); |
my $idacc = &Apache::lonnet::EXT("resource.$id.acc"); |
my $allowed=&check_ip_acc($idacc); |
my $allowed=&Apache::loncommon::check_ip_acc($idacc); |
if (!$allowed && ($Apache::lonhomework::browse ne 'F')) { |
if (!$allowed && ($Apache::lonhomework::browse ne 'F')) { |
$status='INVALID_ACCESS'; |
$status='INVALID_ACCESS'; |
$date=&mt("can not be accessed from your location."); |
$date=&mt("can not be accessed from your location."); |
Line 738 sub analyze_header {
|
Line 689 sub analyze_header {
|
my ($request) = @_; |
my ($request) = @_; |
my $js = &Apache::structuretags::setmode_javascript(); |
my $js = &Apache::structuretags::setmode_javascript(); |
my $result = |
my $result = |
&Apache::loncommon::start_page('Analyzing a problem',$js); |
&Apache::loncommon::start_page('Analyzing a problem',$js) |
|
.&Apache::lonhtmlcommon::breadcrumbs() # FIXME add breadcrumbs |
|
.&Apache::loncommon::head_subbox( |
|
&Apache::loncommon::CSTR_pageheader()); |
$result .= |
$result .= |
&Apache::lonxml::message_location().' |
&Apache::lonxml::message_location().' |
<form name="lonhomework" method="POST" action="'. |
<form name="lonhomework" method="post" action="'. |
&HTML::Entities::encode($env{'request.uri'},'<>&"').'">'. |
&HTML::Entities::encode($env{'request.uri'},'<>&"').'">'. |
'<input type="hidden" name="problemmode" value="'. |
'<input type="hidden" name="problemmode" value="'. |
$env{'form.problemmode'}.'" />'. |
$env{'form.problemmode'}.'" />'. |
Line 829 sub analyze {
|
Line 782 sub analyze {
|
} |
} |
&Apache::lonhtmlcommon::Update_PrgWin($request,\%prog_state, |
&Apache::lonhtmlcommon::Update_PrgWin($request,\%prog_state, |
&mt('Analyzing Results')); |
&mt('Analyzing Results')); |
$request->print('<hr class="LC_edit_problem_divide" />'.&mt('List of possible answers').': '); |
$request->print('<hr class="LC_edit_problem_divide" />' |
|
.'<h3>' |
|
.&mt('List of possible answers') |
|
.'</h3>' |
|
); |
foreach my $part (sort(keys(%allparts))) { |
foreach my $part (sort(keys(%allparts))) { |
if (defined(@{ $overall{$part.'.answer'} })) { |
if (defined(@{ $overall{$part.'.answer'} })) { |
for (my $i=0;$i<scalar(@{ $overall{$part.'.answer'} });$i++) { |
for (my $i=0;$i<scalar(@{ $overall{$part.'.answer'} });$i++) { |
my $num_cols=scalar(@{ $overall{$part.'.answer'}[$i][0] }); |
my $num_cols=scalar(@{ $overall{$part.'.answer'}[$i][0] }); |
$request->print('<table class="thinborder"><tr><th colspan="'.($num_cols+1).'">'.&mt('Part').' '.$part); |
$request->print(&Apache::loncommon::start_data_table() |
|
.&Apache::loncommon::start_data_table_header_row() |
|
.'<th colspan="'.($num_cols+1).'">' |
|
.&mt('Part').' '.$part |
|
); |
if (scalar(@{ $overall{$part.'.answer'} }) > 1) { |
if (scalar(@{ $overall{$part.'.answer'} }) > 1) { |
$request->print(&mt(' Answer [_1]',$i+1)); |
$request->print(' '.&mt('Answer [_1]',$i+1)); |
} |
} |
$request->print('</th></tr>'); |
$request->print('</th>' |
|
.&Apache::loncommon::end_data_table_header_row() |
|
); |
my %frequency; |
my %frequency; |
foreach my $answer (sort {$a->[0] <=> $b->[0]} (@{ $overall{$part.'.answer'}[$i] })) { |
foreach my $answer (sort {$a->[0] <=> $b->[0]} (@{ $overall{$part.'.answer'}[$i] })) { |
$frequency{join("\0",@{ $answer })}++; |
$frequency{join("\0",@{ $answer })}++; |
} |
} |
$request->print('<tr><th colspan="'.($num_cols).'">'.&mt('Answer').'</th><th>'.&mt('Frequency').'<br />(' |
$request->print(&Apache::loncommon::start_data_table_header_row() |
.&mt('click for example').')</th></tr>'); |
.'<th colspan="'.($num_cols).'">'.&mt('Answer').'</th>' |
|
.'<th>'.&mt('Frequency').'<br />' |
|
.'('.&mt('click for example').')</th>' |
|
.&Apache::loncommon::end_data_table_header_row() |
|
); |
foreach my $answer (sort {(split("\0",$a))[0] <=> (split("\0",$b))[0]} (keys(%frequency))) { |
foreach my $answer (sort {(split("\0",$a))[0] <=> (split("\0",$b))[0]} (keys(%frequency))) { |
$request->print('<tr><td class="center">'. |
$request->print(&Apache::loncommon::start_data_table_row() |
join('</td><td class="center">',split("\0",$answer)). |
.'<td>' |
'</td><td class="center"><a href="'.$request->uri.'?rndseed='.$seedexample{join("\0",$part,$i,$answer)}.'">'.$frequency{$answer}. |
.join('</td><td>',split("\0",$answer)) |
'</a></td></tr>'); |
.'</td>' |
|
.'<td>' |
|
.'<a href="'.$request->uri.'?rndseed='.$seedexample{join("\0",$part,$i,$answer)}.'">'.$frequency{$answer}.'</a>' |
|
.'</td>' |
|
.&Apache::loncommon::end_data_table_row() |
|
); |
} |
} |
$request->print('</table>'); |
$request->print(&Apache::loncommon::end_data_table()); |
} |
} |
} else { |
} else { |
$request->print('<p>'.&mt('Response').' '.$part.' '. |
$request->print('<p class="LC_warning">' |
&mt('is not analyzable at this time').'</p>'); |
.&mt('Response [_1] is not analyzable at this time.',$part) |
|
.'</p>' |
|
); |
} |
} |
} |
} |
if (scalar(keys(%allparts)) == 0 ) { |
if (scalar(keys(%allparts)) == 0 ) { |
$request->print('<p>'.&mt('Found no analyzable responses in this problem, currently only Numerical, Formula and String response styles are supported.').'</p>'); |
$request->print('<p class="LC_warning">' |
|
.&mt('Found no analyzable responses in this problem.' |
|
.' Currently only Numerical, Formula and String response styles are supported.') |
|
.'</p>' |
|
); |
} |
} |
&Apache::lonhtmlcommon::Close_PrgWin($request,\%prog_state); |
&Apache::lonhtmlcommon::Close_PrgWin($request,\%prog_state); |
&analyze_footer($request); |
&analyze_footer($request); |
Line 907 sub editxmlmode {
|
Line 885 sub editxmlmode {
|
my $result; |
my $result; |
my $problem=&Apache::lonnet::getfile($file); |
my $problem=&Apache::lonnet::getfile($file); |
if ($problem eq -1) { |
if ($problem eq -1) { |
&Apache::lonxml::error("<b> ".&mt('Unable to find'). |
&Apache::lonxml::error( |
" <i>$file</i></b>"); |
'<b> ' |
|
.&mt('Unable to find [_1]', |
|
'<span class="LC_filename">'.$file.'</span>') |
|
.'</b>'); |
|
|
$problem=''; |
$problem=''; |
} |
} |
if (defined($env{'form.editxmltext'}) || defined($env{'form.Undo'})) { |
if (defined($env{'form.editxmltext'}) || defined($env{'form.Undo'})) { |
Line 923 sub editxmlmode {
|
Line 905 sub editxmlmode {
|
&renderpage($request,$file); |
&renderpage($request,$file); |
} else { |
} else { |
my ($rows,$cols) = &Apache::edit::textarea_sizes(\$problem); |
my ($rows,$cols) = &Apache::edit::textarea_sizes(\$problem); |
my $xml_help = '<table><tr><td>'. |
|
&Apache::loncommon::helpLatexCheatsheet("Problem_Editor_XML_Index", |
|
"Problem Editing Help"). |
|
'</td><td>'. |
|
&Apache::loncommon::help_open_menu(undef,undef,5,'Authoring'). |
|
'</td></tr></table>'; |
|
if ($cols > 80) { $cols = 80; } |
if ($cols > 80) { $cols = 80; } |
if ($cols < 70) { $cols = 70; } |
if ($cols < 70) { $cols = 70; } |
if ($rows < 20) { $rows = 20; } |
if ($rows < 20) { $rows = 20; } |
my $js = |
my $js = |
&Apache::edit::js_change_detection(). |
&Apache::edit::js_change_detection(). |
&Apache::loncommon::resize_textarea_js(). |
&Apache::loncommon::resize_textarea_js(). |
&Apache::structuretags::setmode_javascript(); |
&Apache::structuretags::setmode_javascript(). |
|
&Apache::lonhtmlcommon::dragmath_js("EditMathPopup"); |
my $only_body = ($env{'environment.remote'} eq 'off')? 0 : 1; |
my $only_body = ($env{'environment.remote'} eq 'off')? 0 : 1; |
my $dragmath = &Apache::lonhtmlcommon::dragmath("LC_editxmltext"); |
my $dragmath_button = |
|
&Apache::lonhtmlcommon::dragmath_button("LC_editxmltext",1); |
my $start_page = |
my $start_page = |
&Apache::loncommon::start_page(&mt("EditXML [_1]",$file),$js, |
&Apache::loncommon::start_page(&mt("EditXML [_1]",$file),$js, |
{'no_auto_mt_title' => 1, |
{'no_auto_mt_title' => 1, |
Line 946 sub editxmlmode {
|
Line 924 sub editxmlmode {
|
'onresize' => q[resize_textarea('LC_editxmltext','LC_aftertextarea')], |
'onresize' => q[resize_textarea('LC_editxmltext','LC_aftertextarea')], |
'onload' => q[resize_textarea('LC_editxmltext','LC_aftertextarea')], |
'onload' => q[resize_textarea('LC_editxmltext','LC_aftertextarea')], |
}}); |
}}); |
$result.=$start_page. |
|
&renderpage($request,$file,['no_output_web'],1). |
$result=$start_page |
'<form '.&Apache::edit::form_change_detection().' name="lonhomework" method="POST" action="'. |
.&Apache::lonhtmlcommon::breadcrumbs() # FIXME add breadcrumbs |
|
.&Apache::loncommon::head_subbox( |
|
&Apache::loncommon::CSTR_pageheader()); |
|
$result.=&renderpage($request,$file,['no_output_web'],1). |
|
'<form '.&Apache::edit::form_change_detection().' name="lonhomework" method="post" action="'. |
&HTML::Entities::encode($env{'request.uri'},'<>&"').'">'. |
&HTML::Entities::encode($env{'request.uri'},'<>&"').'">'. |
&Apache::structuretags::remember_problem_state().' |
&Apache::structuretags::remember_problem_state().' |
<div class="LC_edit_problem_editxml_header"> |
<div class="LC_edit_problem_editxml_header"> |
<table class="LC_edit_problem_header_title"><tr><td> |
<table class="LC_edit_problem_header_title"><tr><td> |
'.&mt('Problem Editing').&Apache::loncommon::help_open_topic('Problem_Editor_XML_Index').' |
'.&mt('Problem Editing').&Apache::loncommon::help_open_topic('Problem_Editor_XML_Index').' |
</td><td align="right"> |
</td><td align="right"> |
'.&Apache::loncommon::helpLatexCheatsheet().' |
'.&Apache::loncommon::helpLatexCheatsheet('Problem_LON-CAPA_Functions','Script Functions').' |
</td></tr> |
</td></tr> |
</table> |
</table> |
<div class="LC_edit_problem_discards"> |
<div class="LC_edit_problem_discards"> |
Line 965 sub editxmlmode {
|
Line 947 sub editxmlmode {
|
'onclick="javascript:setmode(this.form,'."'discard'".')" /> |
'onclick="javascript:setmode(this.form,'."'discard'".')" /> |
<input type="button" '.&Apache::edit::submit_ask_anyway('setmode(this.form,'."'edit'".')').'name="submitmode" accesskey="e" value="'.&mt('Edit').'" /> |
<input type="button" '.&Apache::edit::submit_ask_anyway('setmode(this.form,'."'edit'".')').'name="submitmode" accesskey="e" value="'.&mt('Edit').'" /> |
<input type="submit" name="Undo" accesskey="u" value="'.&mt('undo').'" /> |
<input type="submit" name="Undo" accesskey="u" value="'.&mt('undo').'" /> |
|
'.$dragmath_button.' |
</div> |
</div> |
<div class="LC_edit_problem_saves"> |
<div class="LC_edit_problem_saves"> |
<input type="submit" name="submitbutton" accesskey="s" value="'.&mt('Save').'" /> |
<input type="submit" name="submitbutton" accesskey="s" value="'.&mt('Save').'" /> |
<input type="submit" name="submitbutton" accesskey="v" value="'.&mt('Save and View').'" />' |
<input type="submit" name="submitbutton" accesskey="v" value="'.&mt('Save and View').'" /> |
.$dragmath.' |
|
</div> |
</div> |
<hr class="LC_edit_problem_divide" /> |
<hr class="LC_edit_problem_divide" /> |
'.&Apache::lonxml::message_location().' |
'.&Apache::lonxml::message_location().' |
Line 1019 sub renderpage {
|
Line 1001 sub renderpage {
|
my $filename=(split('/',$file))[-1]; |
my $filename=(split('/',$file))[-1]; |
my $error = |
my $error = |
"<b> ".&mt('Unable to find [_1]', |
"<b> ".&mt('Unable to find [_1]', |
' <span class="LC_filename">'.$filename.'</span>') |
'<span class="LC_filename">'.$filename.'</span>') |
."</b>"; |
."</b>"; |
$result.= |
$result.= |
&Apache::loncommon::simple_error_page($request,'Not available', |
&Apache::loncommon::simple_error_page($request,'Not available', |
Line 1160 sub newproblem {
|
Line 1142 sub newproblem {
|
my $instructions; |
my $instructions; |
my $start_page = |
my $start_page = |
&Apache::loncommon::start_page("Create New $extension"); |
&Apache::loncommon::start_page("Create New $extension"); |
$request->print(" |
|
$start_page |
$request->print( |
<h1>".&mt("Creating a new $extension resource.")."</h1> |
$start_page |
|
.&Apache::lonhtmlcommon::breadcrumbs() # FIXME add breadcrumbs |
|
.&Apache::loncommon::head_subbox( |
|
&Apache::loncommon::CSTR_pageheader()) |
|
.'<h1>'.&mt("Creating a new $extension resource.")."</h1> |
$errormsg |
$errormsg |
".&mt("The requested file [_1] currently does not exist.", |
".&mt("The requested file [_1] currently does not exist.", |
"<tt>$shownurl</tt>")." |
'<span class="LC_filename">'.$shownurl.'</span>')." |
<p> |
<p> |
<b> |
<b> |
".&mt("To create a new $extension, select a template from the". |
".&mt("To create a new $extension, select a template from the". |
" list below. Then click on the \"Create $extension\" button.")."</b> |
" list below. Then click on the \"Create $extension\" button.").'</b> |
</p><form action=\"$url\" method=\"POST\">"); |
</p><form action="'.$url.'" method="post">'); |
|
|
if (defined($templatelist)) { |
if (defined($templatelist)) { |
$request->print($templatelist); |
$request->print($templatelist); |
Line 1190 sub update_construct_style {
|
Line 1176 sub update_construct_style {
|
&& !defined($env{'form.newrandomization'})) { |
&& !defined($env{'form.newrandomization'})) { |
if ((!$env{'form.style_file'} && $env{'construct.style'}) |
if ((!$env{'form.style_file'} && $env{'construct.style'}) |
||$env{'form.clear_style_file'}) { |
||$env{'form.clear_style_file'}) { |
&Apache::lonnet::delenv('construct\\.style'); |
&Apache::lonnet::delenv('construct.style'); |
} elsif ($env{'form.style_file'} |
} elsif ($env{'form.style_file'} |
&& $env{'construct.style'} ne $env{'form.style_file'}) { |
&& $env{'construct.style'} ne $env{'form.style_file'}) { |
&Apache::lonnet::appenv({'construct.style' => |
&Apache::lonnet::appenv({'construct.style' => |