[LON-CAPA-cvs] cvs: loncom /homework structuretags.pm /interface resetpw.pm

raeburn raeburn at source.lon-capa.org
Tue Nov 5 13:08:09 EST 2019


raeburn		Tue Nov  5 18:08:09 2019 EDT

  Modified files:              
    /loncom/interface	resetpw.pm 
    /loncom/homework	structuretags.pm 
  Log:
  - Question type set to: "randomizetry" ...
    - Add code comment to document behavior of single part problems.
    - Get partorder from metadata when browsing resource not in a course or
      when viewing in Authoring Space to get list of parts.
  
  
Index: loncom/interface/resetpw.pm
diff -u loncom/interface/resetpw.pm:1.21 loncom/interface/resetpw.pm:1.22
--- loncom/interface/resetpw.pm:1.21	Thu Oct  8 22:59:18 2009
+++ loncom/interface/resetpw.pm	Fri Oct  9 00:26:40 2009
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Allow access to password changing via a token sent to user's e-mail. 
 #
-# $Id: resetpw.pm,v 1.21 2009/10/08 22:59:18 raeburn Exp $
+# $Id: resetpw.pm,v 1.22 2009/10/09 00:26:40 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -31,7 +31,7 @@
 
 =head1 NAME
 
-Apache::resetpw - pile of common routines
+Apache::resetpw: reset user password.
 
 =head1 SYNOPSIS
 
@@ -43,9 +43,8 @@
 =head1 OVERVIEW
 
 A user with an e-mail address associated with his/her LON-CAPA username
-can reset a forgotten password, using a link sent to the e-mail address   
+can reset a forgotten password, using a link sent to the e-mail address
 if the authentication type for the account is "internal".
-account is "internal".
 
 =cut
 
@@ -277,6 +276,10 @@
         my $reqtime = &Apache::lonlocal::locallocaltime($data{'time'});
         if ($now - $data{'time'} < 7200) {
             if ($env{'form.action'} eq 'verify_and_change_pass') {
+                unless (($env{'form.uname'} eq $data{'username'}) && ($env{'form.udom'} eq $data{'domain'}) && ($env{'form.email'} eq $data{'email'})) {
+                    $msg = &generic_failure_msg($contact_name,$contact_email);
+                    return $msg;
+                }
                 my $change_failed = 
 		    &Apache::lonpreferences::verify_and_change_password($r,'reset_by_email',$token);
                 if (!$change_failed) {
Index: loncom/homework/structuretags.pm
diff -u loncom/homework/structuretags.pm:1.567 loncom/homework/structuretags.pm:1.568
--- loncom/homework/structuretags.pm:1.567	Mon Nov  4 20:47:18 2019
+++ loncom/homework/structuretags.pm	Tue Nov  5 18:08:09 2019
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA 
 # definition of tags that give a structure to a document
 #
-# $Id: structuretags.pm,v 1.567 2019/11/04 20:47:18 raeburn Exp $
+# $Id: structuretags.pm,v 1.568 2019/11/05 18:08:09 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -678,10 +678,18 @@
     }
     if ($Apache::lonhomework::type eq 'randomizetry') {
         my $partfortries = $Apache::inputtags::part;
+#
+# Where question type is "randomizetry" for a problem containing
+# a single part (and unless type is explicitly set to not be
+# "randomizetry" for that part), the number of tries used to
+# determine randomization will be for that part, and randomization
+# from calls to &random() in a perl script block before the part tag,
+# will change based on the number of tries, and value of the
+# "randomizeontries" parameter in effect for the single part.
+#
         if (ref($probpartlist) eq 'ARRAY') {
-            if ((@{$probpartlist} == 1) && ($probpartlist->[0] ne $Apache::inputtags::part)) {
-                $partfortries = $probpartlist->[0];
-                if (&Apache::lonnet::EXT("resource.$partfortries.questiontype") eq 'randomizetry') {
+            if ((@{$probpartlist} == 1) && ($probpartlist->[0] ne $partfortries)) {
+                if (&Apache::lonnet::EXT('resource.'.$probpartlist->[0].'.type') eq 'randomizetry') {
                     $partfortries = $probpartlist->[0];
                 } else {
                     $partfortries = '';
@@ -1814,11 +1822,13 @@
     } elsif ((($target eq 'grade') && ($Apache::lonhomework::type eq 'randomizetry')) ||
              ($target eq 'answer')) {
         my ($symb)= &Apache::lonnet::whichuser();
-        my $navmap = Apache::lonnavmaps::navmap->new();
-        if (ref($navmap)) {
-            my $res = $navmap->getBySymb($symb);
-            if (ref($res)) {
-                $probpartlist = $res->parts();
+        if ($symb ne '') {
+            my $navmap = Apache::lonnavmaps::navmap->new();
+            if (ref($navmap)) {
+                my $res = $navmap->getBySymb($symb);
+                if (ref($res)) {
+                    $probpartlist = $res->parts();
+                }
             }
         }
     }
@@ -1838,7 +1848,14 @@
     if ($target eq 'web' || $target eq 'grade' || $target eq 'answer' ||
 	$target eq 'tex') {
 
+        my ($symb) = &Apache::lonnet::whichuser();
 	#handle rand seed in construction space
+        if (($env{'request.state'} eq 'construct') || ($symb eq '')) {
+            my $partorder=&Apache::lonnet::metadata($env{'request.uri'},'partorder');
+            if ($partorder ne '') {
+                @{$probpartlist} = split(/,/,$partorder);
+            }
+        }
 	my $rndseed=&setup_rndseed($safeeval,$target,$probpartlist);
         if (($target eq 'grade') && &Apache::response::submitted()) {
             if ($Apache::lonhomework::type eq 'randomizetry') {
@@ -1853,7 +1870,6 @@
                 }
             }
         }
-	my ($symb)=&Apache::lonnet::whichuser();
 
 	if ($env{'request.state'} ne "construct" && 
 	    ($symb eq '' || $Apache::lonhomework::type eq 'practice')) {




More information about the LON-CAPA-cvs mailing list