[LON-CAPA-cvs] cvs: loncom /interface lonsource.pm
raeburn
raeburn at source.lon-capa.org
Sun Jan 4 17:31:40 EST 2026
raeburn Sun Jan 4 22:31:40 2026 EDT
Modified files:
/loncom/interface lonsource.pm
Log:
- WCAG compliance
- Include landmark for page's main content to support "Skip to main content"
- Include heading
- Include label for form element
Index: loncom/interface/lonsource.pm
diff -u loncom/interface/lonsource.pm:1.41 loncom/interface/lonsource.pm:1.42
--- loncom/interface/lonsource.pm:1.41 Wed Jul 30 03:07:55 2025
+++ loncom/interface/lonsource.pm Sun Jan 4 22:31:40 2026
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Source Code handler
#
-# $Id: lonsource.pm,v 1.41 2025/07/30 03:07:55 raeburn Exp $
+# $Id: lonsource.pm,v 1.42 2026/01/04 22:31:40 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -55,8 +55,11 @@
sub stage_2 {
my ($r, $filename, $listname) = @_;
my ($author)=($filename=~/\/res\/[^\/]+\/([^\/]+)\//);
+ my $labeltext = &mt('destination directory');
$r->print(&Apache::loncommon::start_page('Copy Problem Source Code to Authoring Space',undef,
{'only_body' => 1,})
+ .'<div class="LC_landmark" role="main" id="LC_main_content">'
+ .'<h1 class="LC_visually_hidden">'.&mt('Copy to Authoring Space').'</h1>'
.&mt('Please enter the directory that you would like the source code to go into.')
.'<p>'
.&mt('Note: the path is in reference to the root of your Authoring Space,'
@@ -66,9 +69,10 @@
<input type="hidden" name="filename" value="'.$filename.'" />
<input type="hidden" name="listname" value="'.$listname.'" />
<input type="hidden" name="action" value="copy_stage" />
- <input type="text" size="50" name="newpath" value="/'.&mt('shared_source').'/'.$author.'" />
+ <input type="text" size="50" name="newpath" value="/'.&mt('shared_source').'/'.$author.'" aria-label="'.$labeltext.'" />
<input type="submit" value="'.&mt('Copy').'" />
- </form>'.
+ </form>
+ </div>'.
&Apache::loncommon::end_page());
return OK;
}
@@ -95,7 +99,9 @@
#allowed
if ($path_to_new_file) {
- $r->print(&Apache::loncommon::start_page('Copying Source',undef,{'only_body' => 1}));
+ $r->print(&Apache::loncommon::start_page('Copying Source',undef,{'only_body' => 1})
+ .'<div class="LC_landmark" role="main" id="LC_main_content">'
+ .'<h1 class="LC_visually_hidden">'.&mt('Copying Result').'</h1>');
my $result = &Apache::loncfile::exists($uname, $udom, $path_to_new_file);
$r->print($result);
if (($result) && ($result =~ /published/)) {
@@ -105,7 +111,7 @@
} else {
©_file($r, $newpath, $filename, $path_to_new_file);
}
- $r->print(&Apache::loncommon::end_page());
+ $r->print('</div>'.&Apache::loncommon::end_page());
}
return;
}
@@ -137,18 +143,22 @@
.'</form></p>');
return;
} else {
- $r->print(&Apache::loncommon::start_page('Copying Source',undef,{'only_body' => 1}));
+ $r->print(&Apache::loncommon::start_page('Copying Source',undef,{'only_body' => 1})
+ .'<div class="LC_landmark" role="main" id="LC_main_content">'
+ .'<h1 class="LC_visually_hidden">'.&mt('Copying Result').'</h1>');
if (-e $path_to_new_file) {
unless (unlink($path_to_new_file)) {
- $r->print('<p class="LC_error"">'.&mt('Error:').' '.$!.'</p>');
+ $r->print('<p class="LC_error"">'.&mt('Error:').' '.$!.'</p>'
+ .'</div>'.&Apache::loncommon::end_page());
return 0;
}
} else {
- $r->print('<p class="LC_error">'.&mt('No such file').'</p>');
+ $r->print('<p class="LC_error">'.&mt('No such file').'</p>'
+ .'</div>'.&Apache::loncommon::end_page());
return 0;
}
©_file($r, $newpath, $filename, $path_to_new_file);
- $r->print(&Apache::loncommon::end_page());
+ $r->print('</div>'.&Apache::loncommon::end_page());
return;
}
}
@@ -209,10 +219,12 @@
$filename);
}
$r->print(&Apache::loncommon::start_page('View Source Code',undef,
- {'only_body' => 1}));
+ {'only_body' => 1})
+ .'<div class="LC_landmark" role="main" id="LC_main_content">'."\n");
if ($file_output ne '') {
my $access_to_cstr;
my $lonhost = $r->dir_config('lonHostID');
+ $r->print('<h1 class="LC_visually_hidden"><label for="editxmltext">'.&mt('Source code').'</label></h1>'."\n");
if ($context eq 'view') {
$r->print('<form name="view" action="" target="_parent" method="post"><span class="LC_info">'.
&mt('Source code is displayed below.').
@@ -274,15 +286,15 @@
my $rows = $count;
my $cols = $maxlength;
$r->print('<form name="showsrc" action="" method="post" onsubmit="return false">'."\n".
- '<textarea rows="'.$rows.'" cols="'.$cols.'" name="editxmltext">'.
+ '<textarea rows="'.$rows.'" cols="'.$cols.'" name="editxmltext" id="editxmltext">'.
&HTML::Entities::encode($file_output,'<>&"').'</textarea></form>');
} else {
- $r->print('<p class="LC_warning">'.
+ $r->print('<h1 class="LC_warning LC_heading_3">'.
&mt('Unable to retrieve file contents.').
- '</p><a href="javascript:window.close();">'.&mt('Close Window').'</a>'
+ '</h1><a href="javascript:window.close();">'.&mt('Close Window').'</a>'
);
}
- $r->print(&Apache::loncommon::end_page());
+ $r->print('</div>'.&Apache::loncommon::end_page());
return;
}
More information about the LON-CAPA-cvs
mailing list