--- loncom/interface/lonparmset.pm 2006/11/29 22:02:47 1.349
+++ loncom/interface/lonparmset.pm 2007/03/20 00:08:09 1.364
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Handler to set parameters for assessments
#
-# $Id: lonparmset.pm,v 1.349 2006/11/29 22:02:47 www Exp $
+# $Id: lonparmset.pm,v 1.364 2007/03/20 00:08:09 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -65,7 +65,7 @@ use Apache::lonlocal;
use Apache::lonnavmaps;
use Apache::longroup;
use Apache::lonrss;
-use LONCAPA;
+use LONCAPA qw(:DEFAULT :match);
# --- Caches local to lonparmset
@@ -122,7 +122,10 @@ sub parmval_by_symb {
# load caches
&cacheparmhash();
- my $useropt=&Apache::lonnet::get_userresdata($uname,$udom);
+ my $useropt;
+ if ($uname ne '' && $udom ne '') {
+ $useropt = &Apache::lonnet::get_userresdata($uname,$udom);
+ }
my $result='';
my @outpar=();
@@ -173,7 +176,7 @@ sub parmval_by_symb {
}
# ------------------------------------------------------ fourth, back to course
- if (defined($csec)) {
+ if ($csec ne '') {
if (defined($$courseopt{$seclevel})) {
$outpar[9]=$$courseopt{$seclevel};
$result=9;
@@ -189,7 +192,7 @@ sub parmval_by_symb {
}
}
# ------------------------------------------------------ fifth, check course group
- if (defined($cgroup)) {
+ if ($cgroup ne '') {
if (defined($$courseopt{$grplevel})) {
$outpar[6]=$$courseopt{$grplevel};
$result=6;
@@ -206,7 +209,7 @@ sub parmval_by_symb {
# ---------------------------------------------------------- fifth, check user
- if (defined($uname)) {
+ if ($uname ne '') {
if (defined($$useropt{$courselevel})) {
$outpar[3]=$$useropt{$courselevel};
$result=3;
@@ -269,10 +272,8 @@ sub resetrulescache {
sub rulescache {
my $id=shift;
- if ($rulesid ne $env{'request.course.id'}) {
- %rules=();
- }
- unless (defined($rules{$id})) {
+ if ($rulesid ne $env{'request.course.id'}
+ && !defined($rules{$id})) {
my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
%rules=&Apache::lonnet::dump('parmdefactions',$dom,$crs);
@@ -553,7 +554,8 @@ sub valout {
}
$result=~s/\s+$//;
} elsif (&isdateparm($type)) {
- $result = localtime($value).&date_sanity_info($value);
+ $result = &Apache::lonlocal::locallocaltime($value).
+ &date_sanity_info($value);
} else {
$result = $value;
}
@@ -933,57 +935,66 @@ sub extractResourceInformation {
$$typep{$id}=$1;
$$keyp{$id}='';
$$uris{$id}=$srcf;
- foreach (split(/\,/,&Apache::lonnet::metadata($srcf,'allpossiblekeys'))) {
- if ($_=~/^parameter\_(.*)/) {
- my $key=$_;
+ foreach my $key (split(/\,/,&Apache::lonnet::metadata($srcf,'allpossiblekeys'))) {
+ next if ($key!~/^parameter_/);
+
# Hidden parameters
- if (&Apache::lonnet::metadata($srcf,$key.'.hidden') eq 'parm') {
- next;
- }
- my $display= &Apache::lonnet::metadata($srcf,$key.'.display');
- my $name=&Apache::lonnet::metadata($srcf,$key.'.name');
- my $part= &Apache::lonnet::metadata($srcf,$key.'.part');
+ next if (&Apache::lonnet::metadata($srcf,$key.'.hidden') eq 'parm');
#
# allparms is a hash of parameter names
#
+ my $name=&Apache::lonnet::metadata($srcf,$key.'.name');
+ if (!exists($$allparms{$name})) {
+ my $display= &Apache::lonnet::metadata($srcf,$key.'.display');
my $parmdis = $display;
$parmdis =~ s/\[Part.*$//g;
- $$allparms{$name}=$parmdis;
- $$defkeytype{$name}=&Apache::lonnet::metadata($srcf,$key.'.type');
+ $$allparms{$name}=$parmdis;
+ if (ref($defkeytype)) {
+ $$defkeytype{$name}=
+ &Apache::lonnet::metadata($srcf,$key.'.type');
+ }
+ }
+
#
# allparts is a hash of all parts
#
- $$allparts{$part} = "Part: $part";
+ my $part= &Apache::lonnet::metadata($srcf,$key.'.part');
+ $$allparts{$part} = "Part: $part";
#
# Remember all keys going with this resource
#
- if ($$keyp{$id}) {
- $$keyp{$id}.=','.$key;
- } else {
- $$keyp{$id}=$key;
- }
+ if ($$keyp{$id}) {
+ $$keyp{$id}.=','.$key;
+ } else {
+ $$keyp{$id}=$key;
+ }
#
# Put in order
#
- unless ($$keyorder{$key}) {
- $$keyorder{$key}=$keyordercnt;
- $keyordercnt++;
- }
-
+ unless ($$keyorder{$key}) {
+ $$keyorder{$key}=$keyordercnt;
+ $keyordercnt++;
}
}
- $$mapp{$id}=
- &Apache::lonnet::declutter($resource->enclosing_map_src());
- $$mapp{$mapid}=$$mapp{$id};
- $$allmaps{$mapid}=$$mapp{$id};
- if ($mapid eq '1') {
- $$maptitles{$mapid}='Main Course Documents';
+
+
+ if (!exists($$mapp{$mapid})) {
+ $$mapp{$id}=
+ &Apache::lonnet::declutter($resource->enclosing_map_src());
+ $$mapp{$mapid}=$$mapp{$id};
+ $$allmaps{$mapid}=$$mapp{$id};
+ if ($mapid eq '1') {
+ $$maptitles{$mapid}='Main Course Documents';
+ } else {
+ $$maptitles{$mapid}=
+ &Apache::lonnet::gettitle($$mapp{$id});
+ }
+ $$maptitles{$$mapp{$id}}=$$maptitles{$mapid};
+ $$symbp{$mapid}=$$mapp{$id}.'___(all)';
} else {
- $$maptitles{$mapid}=&Apache::lonnet::gettitle(&Apache::lonnet::clutter($$mapp{$id}));
+ $$mapp{$id} = $$mapp{$mapid};
}
- $$maptitles{$$mapp{$id}}=$$maptitles{$mapid};
$$symbp{$id}=&Apache::lonnet::encode_symb($$mapp{$id},$resid,$srcf);
- $$symbp{$mapid}=$$mapp{$id}.'___(all)';
}
}
@@ -2033,6 +2044,22 @@ sub crsenv {
if ($name =~ /^default_enrollment_(start|end)_date$/) {
$value=&Apache::lonhtmlcommon::get_date_from_form($name.'_value');
}
+ #
+ # Deal with the emails
+ if ($name =~ /\.email$/) {
+ my ($user,$domain) = split(/:/,$value);
+ if (!defined($user) || !defined($domain)) {
+ $setoutput.= '
'.
+ &mt("Invalid email address specified, address must be of the form username:domain").
+ '';
+ undef($value);
+ } elsif (&Apache::lonnet::homeserver($user,$domain) eq 'no_host') {
+ $setoutput.= '
'.
+ &mt("Invalid email address specified, user [_1] is unknown.",$value).
+ '';
+ undef($value);
+ }
+ }
# Get existing cloners
my @oldcloner = ();
if ($name eq 'cloners') {
@@ -2120,10 +2147,16 @@ sub crsenv {
'question.email' => ''.&mt('Feedback Addresses for Resource Content Question').
'
(user:domain,'.
'user:domain(section;section;...;*;...),...)',
+ 'question.email.text' => ''.&mt('Custom Text for Resource Content Question Option in Feedback').
+ '',
'comment.email' => ''.&mt('Feedback Addresses for Course Content Comments').'
'.
'(user:domain,user:domain(section;section;...;*;...),...)',
+ 'comment.email.text' => ''.&mt('Custom Text for Course Content Option in Feedback').
+ '',
'policy.email' => ''.&mt('Feedback Addresses for Course Policy').''.
'
(user:domain,user:domain(section;section;...;*;...),...)',
+ 'policy.email.text' => ''.&mt('Custom Text for Course Policy Option in Feedback').
+ '',
'hideemptyrows' => ''.&mt('Hide Empty Rows in Spreadsheets').'
'.
'('.&mt('"[_1]" for default hiding','yes').')',
'pageseparators' => ''.&mt('Visibly Separate Items on Pages').'
'.
@@ -2206,7 +2239,7 @@ sub crsenv {
=> ''.&mt('Disable display of problem receipts').'
'.
' ('.&mt('"[_1]" to disable, anything else if not','yes').')',
'task_messages'
- => ''.&mt('Send message to student when clicking Done on Tasks. [_1] to send a message only to student, [_2] to send message to student and add record to user information page for instructors. Leave blank to disable.','only_student','student_and_user_notes_screen').'',
+ => ''.&mt('Send message to student when clicking Done on Tasks').'
('.&mt('[_1] to send a message only to student, [_2] to send message to student and add record to user information page for instructors. Leave blank to disable.','only_student','student_and_user_notes_screen').')',
'disablesigfigs'
=> ''.&mt('Disable checking of Significant Figures').'
'.
' ('.&mt('"[_1]" to disable, anything else if not','yes').')',
@@ -2221,7 +2254,7 @@ sub crsenv {
my @Display_Order = ('url','description','courseid','cloners','grading',
'externalsyllabus',
'default_xml_style','pageseparators',
- 'question.email','comment.email','policy.email',
+ 'question.email','question.email.text','comment.email','comment.email.text','policy.email','policy.email.text',
'student_classlist_view',
'plc.roles.denied','plc.users.denied',
'pch.roles.denied','pch.users.denied',
@@ -2363,8 +2396,7 @@ sub readdata {
my $classlist=&Apache::loncoursedata::get_classlist();
foreach (keys %$classlist) {
- # the following undefs are for 'domain', and 'username' respectively.
- if ($_=~/^(\w+)\:(\w+)$/) {
+ if ($_=~/^($match_username)\:($match_domain)$/) {
my ($tuname,$tudom)=($1,$2);
my $useropt=&Apache::lonnet::get_userresdata($tuname,$tudom);
foreach my $userkey (keys %{$useropt}) {
@@ -2486,7 +2518,7 @@ sub storedata {
sub extractuser {
my $key=shift;
- return ($key=~/^$env{'request.course.id'}.\[useropt\:(\w+)\:(\w+)\]\./);
+ return ($key=~/^$env{'request.course.id'}.\[useropt\:($match_username)\:($match_domain)\]\./);
}
sub listdata {
@@ -2544,7 +2576,7 @@ sub listdata {
my $section=&mt('All Students');
if ($middle=~/^\[(.*)\]/) {
my $issection=$1;
- if ($issection=~/^useropt\:(\w+)\:(\w+)/) {
+ if ($issection=~/^useropt\:($match_username)\:($match_domain)/) {
$section=&mt('User').": ".&Apache::loncommon::plainname($1,$2);
} else {
$section=&mt('Group/Section').': '.$issection;
@@ -2875,6 +2907,11 @@ ENDOVER
'