[LON-CAPA-cvs] cvs: loncom /interface londropadd.pm /localize/localize newphrases.txt

matthew lon-capa-cvs@mail.lon-capa.org
Thu, 06 Nov 2003 22:49:59 -0000


This is a MIME encoded message

--matthew1068158999
Content-Type: text/plain

matthew		Thu Nov  6 17:49:59 2003 EDT

  Modified files:              
    /loncom/interface	londropadd.pm 
    /loncom/localize/localize	newphrases.txt 
  Log:
  Further londropadd.pm localization.  This time, localizing the javascript
  which alerts the user of missing fields.
  
  
--matthew1068158999
Content-Type: text/plain
Content-Disposition: attachment; filename="matthew-20031106174959.txt"

Index: loncom/interface/londropadd.pm
diff -u loncom/interface/londropadd.pm:1.88 loncom/interface/londropadd.pm:1.89
--- loncom/interface/londropadd.pm:1.88	Thu Nov  6 15:04:06 2003
+++ loncom/interface/londropadd.pm	Thu Nov  6 17:49:59 2003
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Handler to drop and add students in courses 
 #
-# $Id: londropadd.pm,v 1.88 2003/11/06 20:04:06 matthew Exp $
+# $Id: londropadd.pm,v 1.89 2003/11/06 22:49:59 matthew Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -175,6 +175,11 @@
 
 ###############################################################
 ###############################################################
+sub hidden_input {
+    my ($name,$value) = @_;
+    return '<input type="hidden" name="'.$name.'" value="'.$value.'" />'."\n";
+}
+
 sub print_upload_manager_header {
     my ($r,$datatoken,$distotal,$krbdefdom)=@_;
     my $javascript;
@@ -193,7 +198,7 @@
     } else {
 	$javascript=&upload_manager_javascript_forward_associate();
     }
-    my $javascript_validations=&javascript_validations($krbdefdom);
+    my $javascript_validations=&javascript_validations('auth',$krbdefdom);
     my $checked=(($ENV{'form.noFirstLine'})?' checked="1"':'');
     $r->print('<h3>'.&mt('Uploading Class List')."</h3>\n".
               "<hr>\n".
@@ -202,47 +207,63 @@
               &mt('Total number of records found in file: [_1].',$distotal).
               "\n".
               "</p><hr>\n");
-    $r->print(<<ENDPICK);
-Enter as many fields as you can. The system will inform you and bring you back
-to this page if the data selected is insufficient to run your class.<hr />
-<input type="button" value="Reverse Association" onClick="javascript:this.form.associate.value='Reverse Association';submit(this.form);" />
-<input type="hidden" name="action"     value="upload" />
-<input type="hidden" name="state"      value="got_file" />
-<input type="hidden" name="associate"  value="" />
-<input type="hidden" name="datatoken"  value="$datatoken" />
-<input type="hidden" name="fileupload" value="$ENV{'form.fileupload'}" />
-<input type="checkbox" name="noFirstLine" $checked />Ignore First Line
-<input type="hidden" name="upfiletype" value="$ENV{'form.upfiletype'}" />
-<input type="hidden" name="upfile_associate" 
-                                       value="$ENV{'form.upfile_associate'}" />
-<hr />
-<script type="text/javascript" language="Javascript">
-$javascript
-$javascript_validations
-</script>
-ENDPICK
+    $r->print(&mt('Enter as many fields as you can. '.
+                  'The system will inform you and bring you back to '.
+                  'this page if the data selected is insufficient to '.
+                  'enroll students in your class.')."<hr>\n");
+    $r->print(&hidden_input('action','upload').
+              &hidden_input('state','got_file').
+              &hidden_input('associate','').
+              &hidden_input('datatoken',$datatoken).
+              &hidden_input('fileupload',$ENV{'form.fileupload'}).
+              &hidden_input('upfiletype',$ENV{'form.upfiletype'}).
+              &hidden_input('upfile_associate',$ENV{'form.upfile_associate'}));
+    $r->print('<input type="button" value="Reverse Association" '.
+              'name="'.&mt('Reverse Association').'" '.
+              'onClick="javascript:this.form.associate.value=\'Reverse Association\';submit(this.form);" />');
+    $r->print('<input type="checkbox" name="noFirstLine" $checked />'.
+              &mt('Ignore First Line'));
+    $r->print("<hr />\n".
+              '<script type="text/javascript" language="Javascript">'."\n".
+              $javascript."\n".$javascript_validations.'</script>');
 }
 
 ###############################################################
 ###############################################################
 sub javascript_validations {
-    my ($krbdefdom)=@_;
-    my %param = ( formname => 'studentform',
-                  kerb_def_dom => $krbdefdom );
-    my $authheader = &Apache::loncommon::authform_header(%param);
-    my $pjump_def = &Apache::lonhtmlcommon::pjump_javascript_definition();
-    return (<<ENDPICK);
+    my ($mode,$krbdefdom)=@_;
+    my $authheader;
+    if ($mode eq 'auth') {
+        my %param = ( formname => 'studentform',
+                      kerb_def_dom => $krbdefdom );
+        $authheader = &Apache::loncommon::authform_header(%param);
+    }
+    my %alert = &Apache::lonlocal::texthash
+        (username => 'You need to specify the username field.',
+         authen   => 'You must choose an authentication type.',
+         krb      => 'You need to specify the Kerberos domain.',
+         ipass    => 'You need to specify the initial password.',
+         name     => 'The optional name field was not specified.',
+         snum     => 'The optional student number field was not specified.',
+         section  => 'The optional section or group field was not specified.', 
+         email    => 'The optional email address field was not specified.',
+         continue => 'Continue enrollment?',
+         );
+    
+#    my $pjump_def = &Apache::lonhtmlcommon::pjump_javascript_definition();
+    my $function_name =(<<END);
 function verify_message (vf,founduname,foundpwd,foundname,foundid,foundsec,foundemail) {
+END
+    my $auth_checks = (<<END);
     var foundatype=0;
-    var message='';
     if (founduname==0) {
-	alert('You need to specify the username field');
+	alert('$alert{'username'}');
         return;
     }
     // alert('current.radiovalue = '+current.radiovalue);
     if (current.radiovalue == null || current.radiovalue == 'nochange') {
         // They did not check any of the login radiobuttons.
-        alert('You must choose an authentication type');
+        alert('$alert{'authen'}');
         return;
     }
     foundatype=1;
@@ -250,11 +271,11 @@
         var alertmsg = '';
         switch (current.value) {
             case 'krb': 
-                alertmsg = 'You need to specify the Kerberos domain';
+                alertmsg = '$alert{'krb'}';
                 break;
             case 'loc':
             case 'fsys':
-                alertmsg = 'You need to specify the initial password';
+                alertmsg = '$alert{'ipass'}';
                 break;
             case 'fsys':
                 alertmsg = '';
@@ -267,56 +288,52 @@
             return;
         }
     }
-
-    if (foundname==0) { message='name fields'; }
-    if (foundid==0) { if (message!='') { message+=', '; } message+='student number field'; }
-    if (foundsec==0) {  if (message!='') { message+=', '; } message+='section or group field'; }
-    if (foundemail==0) {  if (message!='') { message+=', '; } message+='email address field'; }
-    if (message!='') {
-       message='Not specified (optional): '+message+'.  Continue enrollment?';
-       if (confirm(message)) {
-          vf.state.value='enrolling';
-	  vf.submit();
-       }
-    } else {
-      vf.state.value='enrolling';
-      vf.submit();
-    }
-}
-
-$authheader
-ENDPICK
-
-}
-
-sub javascript_validations_without_auth {
-    my $pjump_def = &Apache::lonhtmlcommon::pjump_javascript_definition();
-    return (<<ENDPICK);
-function verify_message (vf,founduname,foundpwd,foundname,foundid,foundsec,foundemail) {
-    var foundatype=0;
+END
+    my $optional_checks = (<<END);
     var message='';
-    if (founduname==0) {
-	alert('You need to specify the username field');
-        return;
+    if (foundname==0) { 
+        message='$alert{'name'}';
+    }
+    if (foundid==0) { 
+        if (message!='') { 
+            message+='\\n'; 
+        }
+        message+='$alert{'snum'}';
+    }
+    if (foundsec==0) {
+        if (message!='') {
+            message+='\\n';
+        } 
+        message+='$alert{'section'}';
+    }
+    if (foundemail==0) {
+        if (message!='') {
+            message+='\\n';
+        }
+        message+='$alert{'email'}';
     }
-    if (foundname==0) { message='name fields'; }
-    if (foundid==0) { if (message!='') { message+=', '; } message+='student number field'; }
-    if (foundsec==0) {  if (message!='') { message+=', '; } message+='section or group field'; }
-    if (foundemail==0) {  if (message!='') { message+=', '; } message+='email address field'; }
     if (message!='') {
-       message='Not specified (optional): '+message+'.  Continue enrollment?';
-       if (confirm(message)) {
-          vf.state.value='enrolling';
-	  vf.submit();
-       }
+        message+= '\\n$alert{'continue'}';
+        if (confirm(message)) {
+            vf.state.value='enrolling';
+            vf.submit();
+        }
     } else {
-      vf.state.value='enrolling';
-      vf.submit();
+        vf.state.value='enrolling';
+        vf.submit();
     }
 }
 
-ENDPICK
-
+END
+    my $result = $function_name;
+    if ($mode eq 'auth') {
+        $result .= $auth_checks;
+    }
+    $result .= $optional_checks;
+    if ($mode eq 'auth') {
+        $result .= $authheader;
+    }
+    return $result;
 }
 
 ###############################################################
@@ -774,7 +791,7 @@
         # Set up authentication forms
         my ($krbdef,$krbdefdom) =
             &Apache::loncommon::get_kerberos_defaults($domain);
-        $javascript_validations=&javascript_validations($krbdefdom);
+        $javascript_validations=&javascript_validations('auth',$krbdefdom);
         my %param = ( formname => 'document.studentform',
                       kerb_def_dom => $krbdefdom,
                       kerb_def_auth => $krbdef
@@ -823,7 +840,7 @@
     } else {
         # User already exists.  Do not worry about authentication
         my %uenv = &Apache::lonnet::dump('environment',$domain,$username);
-        $javascript_validations = &javascript_validations_without_auth();
+        $javascript_validations = &javascript_validations('noauth');
         $user_data_html = <<END;
 <h3>User Data for $username\@$domain</h3>
 <input type="hidden" name="lcserver" value="default" />
Index: loncom/localize/localize/newphrases.txt
diff -u loncom/localize/localize/newphrases.txt:1.17 loncom/localize/localize/newphrases.txt:1.18
--- loncom/localize/localize/newphrases.txt:1.17	Thu Nov  6 15:04:06 2003
+++ loncom/localize/localize/newphrases.txt	Thu Nov  6 17:49:59 2003
@@ -32,6 +32,17 @@
 Dropped [_1] student(s).
 Re-enrollment will re-activate data.
 
+You need to specify the username field.
+You must choose an authentication type.
+You need to specify the Kerberos domain.
+You need to specify the initial password.
+The optional name field was not specified.
+The optional student number field was not specified.
+The optional section or group field was not specified.
+The optional email address field was not specified.
+Continue enrollment?
+
+
 You must choose at least one student to continue.
 No changes were made to the current settings.
 Finish Course Initialization

--matthew1068158999--