[LON-CAPA-cvs] cvs: loncom /homework chemresponse.pm
raeburn
raeburn at source.lon-capa.org
Mon Jan 27 13:43:23 EST 2025
raeburn Mon Jan 27 18:43:23 2025 EDT
Modified files:
/loncom/homework chemresponse.pm
Log:
- WCAG 2 compliance
Alt attribute in <img> tag for JME image created for <organicstructure>
Index: loncom/homework/chemresponse.pm
diff -u loncom/homework/chemresponse.pm:1.102 loncom/homework/chemresponse.pm:1.103
--- loncom/homework/chemresponse.pm:1.102 Mon Jun 26 14:24:15 2023
+++ loncom/homework/chemresponse.pm Mon Jan 27 18:43:23 2025
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# chemical equation style response
#
-# $Id: chemresponse.pm,v 1.102 2023/06/26 14:24:15 raeburn Exp $
+# $Id: chemresponse.pm,v 1.103 2025/01/27 18:43:23 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -558,10 +558,15 @@
my $width=&Apache::lonxml::get_param('width',$parstack,$safeeval);
my $molecule=&Apache::lonxml::get_param('molecule',$parstack,$safeeval);
my $options=&Apache::lonxml::get_param('options',$parstack,$safeeval);
+ my $alttext=&Apache::lonxml::get_param('alt',$parstack,$safeeval);
+ if ($alttext eq '') {
+ $alttext = &mt('Organic structure');
+ }
+ $alttext = &HTML::Entities::encode($alttext,'<>&"');
my $id=&Apache::loncommon::get_cgi_id();
$result="<img src='/cgi-bin/convertjme.pl?$id'";
if ($options =~ /border/) { $result.= ' border="1"'; }
- $result.=' />';
+ $result.=' alt="'.$alttext.'" />';
&Apache::lonnet::appenv(
{'cgi.'.$id.'.JME' => &escape($molecule),
'cgi.'.$id.'.PNG' => 1,
@@ -610,12 +615,14 @@
[ ['reaction','Is a reaction'],
['border','Draw a border'] ],
$token);
+ $result .= '<br />'.&Apache::edit::text_arg('Alt text in JME img tag:','alt',$token,30).
+ ' ('.&mt('student-viewable in HTML source').')';
$result .=&Apache::edit::end_row();
} elsif ($target eq 'modified') {
my $constructtag=&Apache::edit::get_new_args($token,$parstack,
$safeeval,'molecule',
'width','texwidth',
- 'options');
+ 'options','alt');
if ($constructtag) { $result = &Apache::edit::rebuild_tag($token); }
}
return $result;
More information about the LON-CAPA-cvs
mailing list