version 1.494, 2011/07/28 02:53:38
|
version 1.499, 2011/12/20 22:46:40
|
Line 172 function setmode(form,probmode) {
|
Line 172 function setmode(form,probmode) {
|
ENDSCRIPT |
ENDSCRIPT |
} |
} |
|
|
sub file_delchk_js { |
|
my $delfilewarn = &mt('You have indicated you wish to remove some files previously included in your submission.').'\\n'. |
|
&mt('Continue submission with these files removed?'); |
|
return <<"ENDSCRIPT"; |
|
<script type="text/javascript"> |
|
// <![CDATA[ |
|
function file_deletion_check(formname,uploadid) { |
|
var elemnum = formname.elements.length; |
|
if (elemnum == 0) { |
|
return true; |
|
} |
|
var alluploads = new Array(); |
|
if ((uploadid != '') && (uploadid != undefined)) { |
|
alluploads.push(uploadid); |
|
} else { |
|
var uploadstr = /^HWFILE.+\$/; |
|
for (var i=0; i<formname.elements.length; i++) { |
|
var id = formname.elements[i].id; |
|
if (id != '') { |
|
if (uploadstr.test(id)) { |
|
if (formname.elements[i].type == 'file') { |
|
alluploads.push(id); |
|
} |
|
} |
|
} |
|
} |
|
} |
|
for (var i=0; i<alluploads.length; i++) { |
|
var delstr = new RegExp('^'+alluploads[i]+'_\\\\d+_delete\$'); |
|
var delboxes = new Array(); |
|
for (var j=0; j<formname.elements.length; j++) { |
|
var id = formname.elements[j].id; |
|
if (id != '') { |
|
if (delstr.test(id)) { |
|
if (formname.elements[j].type == 'checkbox') { |
|
if (formname.elements[j].checked) { |
|
delboxes.push(id); |
|
} |
|
} |
|
} |
|
} |
|
} |
|
if (delboxes.length > 0) { |
|
if (!confirm("$delfilewarn")) { |
|
for (var j=0; j<delboxes.length; j++) { |
|
formname.elements[delboxes[j]].checked = false; |
|
} |
|
return false; |
|
} |
|
} |
|
} |
|
return true; |
|
} |
|
// ]]> |
|
</script> |
|
ENDSCRIPT |
|
} |
|
|
|
sub file_overwritechk_js { |
|
my $overwritewarn = &mt('File(s) you uploaded for your submission will overwrite existing file(s) submitted for this item').'\\n'. |
|
&mt('Continue submission and overwrite the file(s)?'); |
|
return <<"ENDSCRIPT"; |
|
<script type="text/javascript"> |
|
// <![CDATA[ |
|
function file_overwrite_check(formname,path,multiresp) { |
|
var elemnum = formname.elements.length; |
|
if (elemnum == 0) { |
|
return true; |
|
} |
|
var alluploads = new Array(); |
|
var uploaded = new Array(); |
|
var uploadstr = /^HWFILE.+\$/; |
|
var fnametrim = /[^\\/\\\\]+\$/; |
|
for (var i=0; i<formname.elements.length; i++) { |
|
var id = formname.elements[i].id; |
|
if (id != '') { |
|
if (uploadstr.test(id)) { |
|
if (formname.elements[i].type == 'file') { |
|
alluploads.push(id); |
|
if ((formname.elements[i].value != undefined) && |
|
(formname.elements[i].value != '')) { |
|
uploaded.push(id); |
|
} |
|
} |
|
} |
|
} |
|
} |
|
for (var i=0; i<alluploads.length; i++) { |
|
var delstr = new RegExp("^"+alluploads[i]+"_\\\\d+_delete\$"); |
|
var delboxes = new Array(); |
|
for (var j=0; j<formname.elements.length; j++) { |
|
var id = formname.elements[j].id; |
|
if (id != '') { |
|
if (delstr.test(id)) { |
|
if (formname.elements[j].type == 'checkbox') { |
|
delboxes.push(id); |
|
} |
|
} |
|
} |
|
} |
|
var overwrites = new Array(); |
|
if (delboxes.length > 0) { |
|
if ((formname.elements[alluploads[i]].value != undefined) && |
|
(formname.elements[alluploads[i]].value != '')) { |
|
var filepath = formname.elements[alluploads[i]].value; |
|
var newfilename = fnametrim.exec(filepath); |
|
if (newfilename != null) { |
|
var filename = String(newfilename); |
|
var nospaces = filename.replace(/\\s+/g,'_'); |
|
var nospecials = nospaces.replace(/[^\\/\\w\\.\\-]/g,''); |
|
var cleanfilename = nospecials.replace(/\\.(\\d+\\.)/g,"_\$1"); |
|
if (cleanfilename != '') { |
|
var fullpath = path+"/"+cleanfilename; |
|
if (multiresp == 1) { |
|
var partid = String(alluploads[i]); |
|
var subdir = partid.replace(/^HWFILE/,''); |
|
if (subdir != "" && subdir != undefined) { |
|
fullpath = path+"/"+subdir+"/"+cleanfilename; |
|
} |
|
} |
|
for (var k=0; k<delboxes.length; k++) { |
|
if (fullpath == formname.elements[delboxes[k]].value) { |
|
var id = formname.elements[delboxes[k]].id; |
|
if (id != '') { |
|
if (!formname.elements[delboxes[k]].checked) { |
|
overwrites.push(id); |
|
} |
|
} |
|
} |
|
} |
|
} |
|
} |
|
} |
|
if (overwrites.length > 0) { |
|
if (confirm("$overwritewarn")) { |
|
var delcheck = file_deletion_check(formname,alluploads[i]); |
|
if (delcheck == false) { |
|
return false; |
|
} |
|
} else { |
|
for (var n=0; n<overwrites.length; n++) { |
|
formname.elements[overwrites[n]].value = ""; |
|
} |
|
return false; |
|
} |
|
} else { |
|
var delcheck = file_deletion_check(formname); |
|
if (delcheck == false) { |
|
return false; |
|
} |
|
} |
|
} |
|
} |
|
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 358 sub page_start {
|
Line 198 sub page_start {
|
} |
} |
my $is_task = ($env{'request.uri'} =~ /\.task$/); |
my $is_task = ($env{'request.uri'} =~ /\.task$/); |
my $needs_upload; |
my $needs_upload; |
|
my ($symb)= &Apache::lonnet::whichuser(); |
|
my ($map,$resid,$resurl)=&Apache::lonnet::decode_symb($symb); |
if ($is_task) { |
if ($is_task) { |
$extra_head .= &file_delchk_js(); |
$extra_head .= &Apache::lonhtmlcommon::file_submissionchk_js(); |
} else { |
} else { |
if (&Apache::lonnet::EXT("resource.$Apache::inputtags::part.uploadedfiletypes") ne '') { |
if (&Apache::lonnet::EXT("resource.$Apache::inputtags::part.uploadedfiletypes") ne '') { |
$needs_upload = 1; |
unless ($env{'request.state'} eq 'construct') { |
|
my $navmap = Apache::lonnavmaps::navmap->new(); |
|
if (ref($navmap)) { |
|
my $mapres = $navmap->getResourceByUrl($map); |
|
my $is_page; |
|
if (ref($mapres)) { |
|
$is_page = $mapres->is_page(); |
|
} |
|
unless ($is_page) { |
|
$needs_upload = 1; |
|
} |
|
} |
|
} |
} else { |
} else { |
unless ($env{'request.state'} eq 'construct') { |
unless ($env{'request.state'} eq 'construct') { |
my ($symb)= &Apache::lonnet::whichuser(); |
|
my $navmap = Apache::lonnavmaps::navmap->new(); |
my $navmap = Apache::lonnavmaps::navmap->new(); |
if (ref($navmap)) { |
if (ref($navmap)) { |
my $res = $navmap->getBySymb($symb); |
my $mapres = $navmap->getResourceByUrl($map); |
if (ref($res)) { |
my $is_page; |
my $partlist = $res->parts(); |
if (ref($mapres)) { |
if (ref($partlist) eq 'ARRAY') { |
$is_page = $mapres->is_page(); |
foreach my $part (@{$partlist}) { |
} |
my @types = $res->responseType($part); |
unless ($is_page) { |
my @ids = $res->responseIds($part); |
my $res = $navmap->getBySymb($symb); |
for (my $i=0; $i < scalar(@ids); $i++) { |
if (ref($res)) { |
if ($types[$i] eq 'essay') { |
my $partlist = $res->parts(); |
my $partid = $part.'_'.$ids[$i]; |
if (ref($partlist) eq 'ARRAY') { |
if (&Apache::lonnet::EXT("resource.$partid.uploadedfiletypes") ne '') { |
foreach my $part (@{$partlist}) { |
$needs_upload = 1; |
my @types = $res->responseType($part); |
last; |
my @ids = $res->responseIds($part); |
|
for (my $i=0; $i < scalar(@ids); $i++) { |
|
if ($types[$i] eq 'essay') { |
|
my $partid = $part.'_'.$ids[$i]; |
|
if (&Apache::lonnet::EXT("resource.$partid.uploadedfiletypes") ne '') { |
|
$needs_upload = 1; |
|
last; |
|
} |
} |
} |
} |
} |
} |
} |
} |
} |
} |
} |
} |
} |
} |
} |
} |
} |
} |
} |
} |
if ($needs_upload) { |
if ($needs_upload) { |
$extra_head .= &Apache::lonhtmlcommon::file_submissionchk_js(); |
$extra_head .= &file_overwritechk_js()."\n". |
} |
&file_delchk_js(); |
|
} |
} |
|
|
my %body_args; |
my %body_args; |
Line 424 sub page_start {
|
Line 283 sub page_start {
|
&Apache::lonhtmlcommon::clear_breadcrumbs(); |
&Apache::lonhtmlcommon::clear_breadcrumbs(); |
&Apache::lonhtmlcommon::add_breadcrumb({ |
&Apache::lonhtmlcommon::add_breadcrumb({ |
'text' => 'Construction Space', |
'text' => 'Construction Space', |
'href' => &Apache::loncommon::authorspace(), |
'href' => &Apache::loncommon::authorspace($env{'request.uri'}), |
}); |
}); |
# breadcrumbs (and tools) will be created |
# breadcrumbs (and tools) will be created |
# in start_page->bodytag->innerregister |
# in start_page->bodytag->innerregister |
Line 489 sub page_start {
|
Line 348 sub page_start {
|
my ($symb,$courseid,$udom,$uname)=&Apache::lonnet::whichuser(); |
my ($symb,$courseid,$udom,$uname)=&Apache::lonnet::whichuser(); |
my ($path,$multiresp) = |
my ($path,$multiresp) = |
&Apache::loncommon::get_turnedin_filepath($symb,$uname,$udom); |
&Apache::loncommon::get_turnedin_filepath($symb,$uname,$udom); |
if ($is_task) { |
if (($is_task) || ($needs_upload)) { |
$form_tag_start .= ' onsubmit="return file_deletion_check(this);"'; |
$form_tag_start .= ' onsubmit="return file_submission_check(this,'."'$path','$multiresp'".');"'; |
} elsif ($needs_upload) { |
|
$form_tag_start .= ' onsubmit="return file_overwrite_check(this,'."'$path','$multiresp'".');"'; |
|
} |
} |
$form_tag_start.='>'."\n"; |
$form_tag_start.='>'."\n"; |
|
|
Line 1103 sub reset_problem_globals {
|
Line 960 sub reset_problem_globals {
|
undef(%Apache::lonhomework::history); |
undef(%Apache::lonhomework::history); |
undef(%Apache::lonhomework::results); |
undef(%Apache::lonhomework::results); |
undef($Apache::inputtags::part); |
undef($Apache::inputtags::part); |
|
if ($type eq 'Task') { |
|
undef($Apache::inputtags::slot_name); |
|
} |
#don't undef this, lonhomework.pm takes care of this, we use this to |
#don't undef this, lonhomework.pm takes care of this, we use this to |
#detect if we try to do 2 problems in one file |
#detect if we try to do 2 problems in one file |
# undef($Apache::lonhomework::parsing_a_problem); |
# undef($Apache::lonhomework::parsing_a_problem); |
Line 1272 sub start_problem {
|
Line 1132 sub start_problem {
|
( $status eq 'BANNED') || |
( $status eq 'BANNED') || |
( $status eq 'UNAVAILABLE') || |
( $status eq 'UNAVAILABLE') || |
( $status eq 'NOT_IN_A_SLOT') || |
( $status eq 'NOT_IN_A_SLOT') || |
|
( $status eq 'NOTRESERVABLE') || |
|
( $status eq 'RESERVABLE') || |
|
( $status eq 'RESERVABLE_LATER') || |
( $status eq 'INVALID_ACCESS')) { |
( $status eq 'INVALID_ACCESS')) { |
my $bodytext=&Apache::lonxml::get_all_text("/problem",$parser, |
my $bodytext=&Apache::lonxml::get_all_text("/problem",$parser, |
$style); |
$style); |
Line 1281 sub start_problem {
|
Line 1144 sub start_problem {
|
$msg.='<h1>'.&mt('Unable to determine if this resource is open due to network problems. Please try again later.').'</h1>'; |
$msg.='<h1>'.&mt('Unable to determine if this resource is open due to network problems. Please try again later.').'</h1>'; |
} elsif ($status eq 'NOT_IN_A_SLOT') { |
} elsif ($status eq 'NOT_IN_A_SLOT') { |
$msg.='<h1>'.&mt('You are not currently signed up to work at this time and/or place.').'</h1>'; |
$msg.='<h1>'.&mt('You are not currently signed up to work at this time and/or place.').'</h1>'; |
|
} elsif (($status eq 'RESERVABLE') || ($status eq 'RESERVABLE_LATER') || |
|
($status eq 'NOTRESERVABLE')) { |
|
$msg.='<h1>'.&mt('Access requires reservation to work at specific time/place.').'</h1>'; |
} elsif ($status ne 'NOT_YET_VIEWED') { |
} elsif ($status ne 'NOT_YET_VIEWED') { |
$msg.='<h1>'.&mt('Not open to be viewed').'</h1>'; |
$msg.='<h1>'.&mt('Not open to be viewed').'</h1>'; |
} |
} |
if ($status eq 'CLOSED' || $status eq 'INVALID_ACCESS') { |
if ($status eq 'CLOSED' || $status eq 'INVALID_ACCESS') { |
$msg.=&mt('The problem ').$accessmsg; |
$msg.=&mt('The problem ').$accessmsg; |
} elsif ($status eq 'UNCHECKEDOUT') { |
} elsif ($status eq 'UNCHECKEDOUT') { |
Line 1292 sub start_problem {
|
Line 1158 sub start_problem {
|
$msg.=&firstaccess_msg($accessmsg,$symb); |
$msg.=&firstaccess_msg($accessmsg,$symb); |
} elsif ($status eq 'NOT_IN_A_SLOT') { |
} elsif ($status eq 'NOT_IN_A_SLOT') { |
$msg.=&Apache::bridgetask::add_request_another_attempt_button("Sign up for time to work"); |
$msg.=&Apache::bridgetask::add_request_another_attempt_button("Sign up for time to work"); |
|
} elsif ($status eq 'RESERVABLE') { |
|
$msg.=&mt('Available to make a reservation.').' '.&mt('Reservation window closes [_1].', |
|
&Apache::lonnavmaps::timeToHumanString($accessmsg,'end')). |
|
'<br />'. |
|
&Apache::bridgetask::add_request_another_attempt_button("Sign up for time to work"); |
|
} elsif ($status eq 'RESERVABLE_LATER') { |
|
$msg.=&mt('Window to make a reservation will open [_1].', |
|
&Apache::lonnavmaps::timeToHumanString($accessmsg,'start')); |
|
} elsif ($status eq 'NOTRESERVABLE') { |
|
$msg.=&mt('Not available to make a reservation.'); |
} |
} |
$result.=$msg.'<br />'; |
$result.=$msg.'<br />'; |
} elsif ($target eq 'tex') { |
} elsif ($target eq 'tex') { |