[LON-CAPA-cvs] cvs: loncom /homework optionresponse.pm

raeburn raeburn at source.lon-capa.org
Sun Jan 26 12:49:32 EST 2025


raeburn		Sun Jan 26 17:49:32 2025 EDT

  Modified files:              
    /loncom/homework	optionresponse.pm 
  Log:
  - WCAG 2 compliance
  
  
Index: loncom/homework/optionresponse.pm
diff -u loncom/homework/optionresponse.pm:1.201 loncom/homework/optionresponse.pm:1.202
--- loncom/homework/optionresponse.pm:1.201	Wed Feb 28 13:20:50 2018
+++ loncom/homework/optionresponse.pm	Sun Jan 26 17:49:32 2025
@@ -1,7 +1,7 @@
 # LearningOnline Network with CAPA
 # option list style responses
 #
-# $Id: optionresponse.pm,v 1.201 2018/02/28 13:20:50 raeburn Exp $
+# $Id: optionresponse.pm,v 1.202 2025/01/26 17:49:32 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -106,7 +106,7 @@
   $Apache::optionresponse::conceptgroup=0;
   &Apache::response::pushrandomnumber(undef,$target);
   if ($target eq 'edit') {
-    my $optionlist="<option></option>\n";
+    my $optionlist="<option value=\"\"></option>\n";
     my $option;
     my @opt;
     my @raw_options = &Apache::lonxml::get_param('options', $parstack, $safeeval, 0,  0, 1);
@@ -745,7 +745,7 @@
 	  }
       }
       my $lastopt=$lastresponse{$name};
-      my $optionlist="<option></option>\n";
+      my $optionlist="<option value=\"\"></option>\n";
 
       if($target eq 'tex' and $env{'form.pdfFormFields'} eq 'yes'
          && $Apache::inputtags::status[-1] eq 'CAN_ANSWER') {
@@ -793,14 +793,20 @@
 # lastopt is what the user submitted before
 # defopt is what the field is going to start out with: either previous choice or altopt
 # fieldname is this input field's name after HWVAL_
-                  $optionlist='<input type="hidden" name="HWVAL_'.$fieldname.'" value="'.$escdefopt.'" />'.
+                  $optionlist='<input type="hidden" name="HWVAL_'.$fieldname.'" value="'.$escdefopt.'" /><label>'.
                   '<input type="checkbox" name="HWCHK_'.$fieldname.'" onclick="javascript:if (this.form.elements[\'HWCHK_'.
                   $fieldname.'\'].checked) { this.form.elements[\'HWVAL_'.$fieldname.'\'].value=\''.$esccheckboxopt.'\'; } else { this.form.elements[\'HWVAL_'.$fieldname.'\'].value=\''.$escaltopt.'\'; };javascript:setSubmittedPart(\''.$part.'\');"'.($defopt eq $checkboxopt?' checked="checked"':'')." />\n";
               } else {
 # classic selection list
+                  my $labeltext;
+                  if ($Apache::lonhomework::type ne 'exam') {
+                      $labeltext = $text;
+                      $labeltext =~s|<drawoptionlist\s*/>|$optionlist|;
+                  }
+                  $labeltext = &HTML::Entities::encode($labeltext,'\'"&<>');
 	          $optionlist='<select onchange="javascript:setSubmittedPart(\''.
 		  $part.'\');" name="HWVAL_'.
-		  $Apache::inputtags::response['-1'].':'.$temp.'">'.
+		  $Apache::inputtags::response['-1'].':'.$temp.'" aria-label="'.$labeltext.'">'.
 		  $optionlist."</select>\n";
               }
 	  } else {
@@ -820,6 +826,8 @@
 	  $result.=$break.$text."\n";
 	  if ($Apache::lonhomework::type eq 'exam') {
 	      $result.=&webbubbles(\@opt,\@alphabet,$temp,$lastopt);
+	  } elsif ($checkboxopt) {
+	      $result.= '</label>';
 	  }
 	  $temp++;
       } else {




More information about the LON-CAPA-cvs mailing list