version 1.287, 2006/04/14 16:38:43
|
version 1.295, 2006/04/22 15:39:22
|
Line 394 sub storeparm_by_symb {
|
Line 394 sub storeparm_by_symb {
|
return ''; |
return ''; |
} |
} |
|
|
{ |
sub log_parmset { |
my $logid; |
return &Apache::lonnet::instructor_log('parameterlog',@_); |
sub log_parmset { |
|
my ($symb,$spnam,$snum,$nval,$ntype,$uname,$udom,$csec,$cgroup)=@_; |
|
$logid++; |
|
my $id=time().'00000'.$$.'00000'.$logid; |
|
&Apache::lonnet::put('nohist_parameterlog', |
|
{ |
|
$id.'_exe_uname' => $env{'user.name'}, |
|
$id.'_exe_udom' => $env{'user.domain'}, |
|
$id.'_exe_time' => time(), |
|
$id.'_exe_ip' => $ENV{'REMOTE_ADDR'}, |
|
$id.'_symb' => $symb, |
|
$id.'_spnam' => $spnam, |
|
$id.'_snum' => $snum, |
|
$id.'_nval' => $nval, |
|
$id.'_ntype' => $ntype, |
|
$id.'_uname' => $uname, |
|
$id.'_udom' => $udom, |
|
$id.'_csec' => $csec, |
|
$id.'_cgroup' => $cgroup |
|
}, |
|
$env{'course.'.$env{'request.course.id'}.'.domain'}, |
|
$env{'course.'.$env{'request.course.id'}.'.num'} |
|
); |
|
} |
|
} |
} |
|
|
sub storeparm_by_symb_inner { |
sub storeparm_by_symb_inner { |
# ---------------------------------------------------------- Get symb, map, etc |
# ---------------------------------------------------------- Get symb, map, etc |
my ($symb,$spnam,$snum,$nval,$ntype,$uname,$udom,$csec,$cgroup)=@_; |
my ($symb,$spnam,$snum,$nval,$ntype,$uname,$udom,$csec,$cgroup)=@_; |
&log_parmset(@_); |
|
# ---------------------------------------------------------- Construct prefixes |
# ---------------------------------------------------------- Construct prefixes |
$spnam=~s/\_([^\_]+)$/\.$1/; |
$spnam=~s/\_([^\_]+)$/\.$1/; |
my $map=(&Apache::lonnet::decode_symb($symb))[0]; |
my $map=(&Apache::lonnet::decode_symb($symb))[0]; |
Line 479 sub storeparm_by_symb_inner {
|
Line 454 sub storeparm_by_symb_inner {
|
if ($delete) { |
if ($delete) { |
$reply=&Apache::lonnet::del |
$reply=&Apache::lonnet::del |
('resourcedata',[keys(%storecontent)],$cdom,$cnum); |
('resourcedata',[keys(%storecontent)],$cdom,$cnum); |
|
&log_parmset(\%storecontent,1); |
} else { |
} else { |
$reply=&Apache::lonnet::cput |
$reply=&Apache::lonnet::cput |
('resourcedata',\%storecontent,$cdom,$cnum); |
('resourcedata',\%storecontent,$cdom,$cnum); |
|
&log_parmset(\%storecontent); |
} |
} |
&Apache::lonnet::devalidatecourseresdata($cnum,$cdom); |
&Apache::lonnet::devalidatecourseresdata($cnum,$cdom); |
} else { |
} else { |
Line 502 sub storeparm_by_symb_inner {
|
Line 479 sub storeparm_by_symb_inner {
|
if ($delete) { |
if ($delete) { |
$reply=&Apache::lonnet::del |
$reply=&Apache::lonnet::del |
('resourcedata',[keys(%storecontent)],$udom,$uname); |
('resourcedata',[keys(%storecontent)],$udom,$uname); |
|
&log_parmset(\%storecontent,1,$uname,$udom); |
} else { |
} else { |
$reply=&Apache::lonnet::cput |
$reply=&Apache::lonnet::cput |
('resourcedata',\%storecontent,$udom,$uname); |
('resourcedata',\%storecontent,$udom,$uname); |
|
&log_parmset(\%storecontent,0,$uname,$udom); |
} |
} |
&Apache::lonnet::devalidateuserresdata($uname,$udom); |
&Apache::lonnet::devalidateuserresdata($uname,$udom); |
} |
} |
Line 2354 sub tablestart {
|
Line 2333 sub tablestart {
|
return ''; |
return ''; |
} else { |
} else { |
$tableopen=1; |
$tableopen=1; |
return '<table border="2"><tr><th>'.&mt('Parameter').'</th><th>'. |
return &Apache::loncommon::start_data_table().'<tr><th>'.&mt('Parameter').'</th><th>'. |
&mt('Delete').'</th><th>'.&mt('Set to ...').'</th></tr>'; |
&mt('Delete').'</th><th>'.&mt('Set to ...').'</th></tr>'; |
} |
} |
} |
} |
Line 2362 sub tablestart {
|
Line 2341 sub tablestart {
|
sub tableend { |
sub tableend { |
if ($tableopen) { |
if ($tableopen) { |
$tableopen=0; |
$tableopen=0; |
return '</table>'; |
return &Apache::loncommon::end_data_table(); |
} else { |
} else { |
return''; |
return''; |
} |
} |
Line 2421 sub storedata {
|
Line 2400 sub storedata {
|
if (&Apache::lonnet::put('resourcedata',{$tkey=>$data, |
if (&Apache::lonnet::put('resourcedata',{$tkey=>$data, |
$tkey.'.type' => $typeof}, |
$tkey.'.type' => $typeof}, |
$tudom,$tuname) eq 'ok') { |
$tudom,$tuname) eq 'ok') { |
|
&log_parmset({$tkey=>$data,$tkey.'.type' => $typeof},0,$tuname,$tudom); |
$r->print('<br />'.&mt('Stored modified parameter for').' '. |
$r->print('<br />'.&mt('Stored modified parameter for').' '. |
&Apache::loncommon::plainname($tuname,$tudom)); |
&Apache::loncommon::plainname($tuname,$tudom)); |
} else { |
} else { |
Line 2436 sub storedata {
|
Line 2416 sub storedata {
|
} elsif ($cmd eq 'del') { |
} elsif ($cmd eq 'del') { |
if ($tuname) { |
if ($tuname) { |
if (&Apache::lonnet::del('resourcedata',[$tkey],$tudom,$tuname) eq 'ok') { |
if (&Apache::lonnet::del('resourcedata',[$tkey],$tudom,$tuname) eq 'ok') { |
|
&log_parmset({$tkey=>''},1,$tuname,$tudom); |
$r->print('<br />'.&mt('Deleted parameter for').' '.&Apache::loncommon::plainname($tuname,$tudom)); |
$r->print('<br />'.&mt('Deleted parameter for').' '.&Apache::loncommon::plainname($tuname,$tudom)); |
} else { |
} else { |
$r->print('<h2><font color="red">'. |
$r->print('<h2><font color="red">'. |
Line 2453 sub storedata {
|
Line 2434 sub storedata {
|
if (&Apache::lonnet::put('resourcedata',{$tkey=>$data, |
if (&Apache::lonnet::put('resourcedata',{$tkey=>$data, |
$tkey.'.type' => $typeof}, |
$tkey.'.type' => $typeof}, |
$tudom,$tuname) eq 'ok') { |
$tudom,$tuname) eq 'ok') { |
|
&log_parmset({$tkey=>$data,$tkey.'.type' => $typeof},0,$tuname,$tudom); |
$r->print('<br />'.&mt('Stored modified date for').' '.&Apache::loncommon::plainname($tuname,$tudom)); |
$r->print('<br />'.&mt('Stored modified date for').' '.&Apache::loncommon::plainname($tuname,$tudom)); |
} else { |
} else { |
$r->print('<h2><font color="red">'. |
$r->print('<h2><font color="red">'. |
Line 2473 sub storedata {
|
Line 2455 sub storedata {
|
my $putentries=$#newdatakeys+1; |
my $putentries=$#newdatakeys+1; |
if ($delentries) { |
if ($delentries) { |
if (&Apache::lonnet::del('resourcedata',\@deldata,$dom,$crs) eq 'ok') { |
if (&Apache::lonnet::del('resourcedata',\@deldata,$dom,$crs) eq 'ok') { |
|
my %loghash=map { $_ => '' } @deldata; |
|
&log_parmset(\%loghash,1); |
$r->print('<h2>'.&mt('Deleted [_1] parameter(s)</h2>',$delentries)); |
$r->print('<h2>'.&mt('Deleted [_1] parameter(s)</h2>',$delentries)); |
} else { |
} else { |
$r->print('<h2><font color="red">'. |
$r->print('<h2><font color="red">'. |
Line 2482 sub storedata {
|
Line 2466 sub storedata {
|
} |
} |
if ($putentries) { |
if ($putentries) { |
if (&Apache::lonnet::put('resourcedata',\%newdata,$dom,$crs) eq 'ok') { |
if (&Apache::lonnet::put('resourcedata',\%newdata,$dom,$crs) eq 'ok') { |
|
&log_parmset(\%newdata,0); |
$r->print('<h3>'.&mt('Stored [_1] parameter(s)',$putentries/2).'</h3>'); |
$r->print('<h3>'.&mt('Stored [_1] parameter(s)',$putentries/2).'</h3>'); |
} else { |
} else { |
$r->print('<h2><font color="red">'. |
$r->print('<h2><font color="red">'. |
Line 2607 sub listdata {
|
Line 2592 sub listdata {
|
# |
# |
# Ready to print |
# Ready to print |
# |
# |
$r->print(&tablestart().'<tr><td><b>'.$name. |
$r->print(&tablestart(). |
':</b></td><td><input type="checkbox" name="del_'. |
&Apache::loncommon::start_data_table_row(). |
|
'<td><b>'.&standard_parameter_names($name). |
|
'</b></td><td><input type="checkbox" name="del_'. |
$thiskey.'" /></td><td>'); |
$thiskey.'" /></td><td>'); |
$foundkeys++; |
$foundkeys++; |
if (&isdateparm($thistype)) { |
if (&isdateparm($thistype)) { |
Line 2653 sub listdata {
|
Line 2640 sub listdata {
|
} |
} |
$r->print('<input type="hidden" name="typeof_'.$thiskey.'" value="'. |
$r->print('<input type="hidden" name="typeof_'.$thiskey.'" value="'. |
$thistype.'">'); |
$thistype.'">'); |
$r->print('</td></tr>'); |
$r->print('</td>'.&Apache::loncommon::end_data_table_row()); |
} |
} |
} |
} |
return $foundkeys; |
return $foundkeys; |
Line 3046 ENDMAINFORMHEAD
|
Line 3033 ENDMAINFORMHEAD
|
action => 'setdefaults', |
action => 'setdefaults', |
permission => $parm_permission, |
permission => $parm_permission, |
}, |
}, |
{ text => 'Parameter Change Log and Course Blog Posting', |
{ text => 'Parameter Change Log and Course Blog Posting/User Notification', |
action => 'parameterchangelog', |
action => 'parameterchangelog', |
permission => $parm_permission, |
permission => $parm_permission, |
}, |
}, |
Line 3316 ENDYESNO
|
Line 3303 ENDYESNO
|
return; |
return; |
} |
} |
|
|
|
sub components { |
|
my ($key,$uname,$udom,$exeuser,$exedomain)=@_; |
|
my $typeflag=0; |
|
if ($key=~/\.type$/) { |
|
$key=~s/\.type$//; |
|
$typeflag=1; |
|
} |
|
my $issection; |
|
my ($middle,$part,$name)=($key=~/^$env{'request.course.id'}\.(?:(.+)\.)*([\w\s]+)\.(\w+)$/); |
|
my $section=&mt('All Students'); |
|
if ($middle=~/^\[(.*)\]/) { |
|
$issection=$1; |
|
$section=&mt('Group/Section').': '.$issection; |
|
$middle=~s/^\[(.*)\]//; |
|
} |
|
$middle=~s/\.+$//; |
|
$middle=~s/^\.+//; |
|
if ($uname) { |
|
$section=&mt('User').": ".&Apache::loncommon::plainname($uname,$udom); |
|
$issection=''; |
|
} |
|
my $realm='<font color="red">'.&mt('All Resources').'</font>'; |
|
if ($middle=~/^(.+)\_\_\_\(all\)$/) { |
|
$realm='<font color="green">'.&mt('Folder/Map').': '.&Apache::lonnet::gettitle($1).' <br /><font color="#aaaaaa" size="-2">('.$1.')</font></font>'; |
|
} elsif ($middle) { |
|
my ($map,$id,$url)=&Apache::lonnet::decode_symb($middle); |
|
$realm='<font color="orange">'.&mt('Resource').': '.&Apache::lonnet::gettitle($middle).' <br /><font color="#aaaaaa" size="-2">('.$url.' in '.$map.' id: '.$id.')</font></font>'; |
|
} |
|
my $what=$part.'.'.$name; |
|
return ($realm,$section,$name,$part,$typeflag, |
|
$what,$middle,$uname,$udom,$issection); |
|
} |
|
|
|
sub standard_parameter_names { |
|
my ($name)=@_; |
|
my %standard_parms=&Apache::lonlocal::texthash('duedate' => 'Due Date', |
|
'answerdate' => 'Answer Date', |
|
'opendate' => 'Open Date', |
|
'maxtries' => 'Max. Number of Tries', |
|
'weight' => 'Weight', |
|
'date_start' => 'Starting Date', |
|
'date_end' => 'Ending Date', |
|
'int_pos' => 'Positive Integer', |
|
'int_zero_pos' => 'Positive Integer or Zero', |
|
'hinttries' => 'Number of Tries till Hints appear'); |
|
if ($standard_parms{$name}) { |
|
return $standard_parms{$name}; |
|
} else { |
|
return $name; |
|
} |
|
} |
|
|
sub parm_change_log { |
sub parm_change_log { |
my ($r)=@_; |
my ($r)=@_; |
&startpage($r); |
&startpage($r); |
|
|
my @ids=(); |
|
my %symbp=(); |
|
my %mapp=(); |
|
my %typep=(); |
|
my %keyp=(); |
|
my %uris=(); |
|
my %maptitles=(); |
|
|
|
# -------------------------------------------------------- Variable declaration |
|
|
|
my %allmaps=(); |
|
my %alllevs=(); |
|
|
|
my $uname; |
|
my $udom; |
|
my $uhome; |
|
my $csec; |
|
my $cgroup; |
|
my $grouplist; |
|
my @usersgroups = (); |
|
|
|
my $coursename=$env{'course.'.$env{'request.course.id'}.'.description'}; |
|
|
|
$alllevs{'Resource Level'}='full'; |
|
$alllevs{'Map/Folder Level'}='map'; |
|
$alllevs{'Course Level'}='general'; |
|
|
|
my %allparms; |
|
my %allparts; |
|
my %keyorder; |
|
# --------------------------------------------------------- Get all assessments |
|
&extractResourceInformation(\@ids, \%typep,\%keyp, \%allparms, \%allparts, \%allmaps, |
|
\%mapp, \%symbp,\%maptitles,\%uris, |
|
\%keyorder); |
|
|
|
$mapp{'0.0'} = ''; |
|
$symbp{'0.0'} = ''; |
|
|
|
my %level=&Apache::lonlocal::texthash('parmlevel_14' => 'General Course', |
|
'parmlevel_13' => 'Map or Folder level in course', |
|
'parmlevel_12' => 'Resource default', |
|
'parmlevel_11' => 'Map default', |
|
'parmlevel_10' => 'Resource level in course', |
|
'parmlevel_9' => 'General for section', |
|
'parmlevel_8' => 'Map or Folder level for section', |
|
'parmlevel_7' => 'Resource level in section', |
|
'parmlevel_6' => 'General for group', |
|
'parmlevel_5' => 'Map or Folder level for group', |
|
'parmlevel_4' => 'Resource level in group', |
|
'parmlevel_3' => 'General for specific student', |
|
'parmlevel_2' => 'Map or Folder level for specific student', |
|
'parmlevel_1' => 'Resource level for specific student'); |
|
|
|
# $id.'_exe_uname' => $env{'user.name'}, |
|
# $id.'_exe_udom' => $env{'user.domain'}, |
|
# $id.'_exe_time' => time(), |
|
# $id.'_exe_ip' => $ENV{'REMOTE_ADDR'}, |
|
# $id.'_symb' => $symb, |
|
# $id.'_spnam' => $spnam, |
|
# $id.'_snum' => $snum, |
|
# $id.'_nval' => $nval, |
|
# $id.'_ntype' => $ntype, |
|
# $id.'_uname' => $uname, |
|
# $id.'_udom' => $udom, |
|
# $id.'_csec' => $csec, |
|
# $id.'_cgroup' => $cgroup |
|
my %parmlog=&Apache::lonnet::dump('nohist_parameterlog', |
my %parmlog=&Apache::lonnet::dump('nohist_parameterlog', |
$env{'course.'.$env{'request.course.id'}.'.domain'}, |
$env{'course.'.$env{'request.course.id'}.'.domain'}, |
$env{'course.'.$env{'request.course.id'}.'.num'}); |
$env{'course.'.$env{'request.course.id'}.'.num'}); |
my %exetime=(); |
my $courseopt=&Apache::lonnet::get_courseresdata($env{'course.'.$env{'request.course.id'}.'.num'}, |
foreach my $key (keys(%parmlog)) { |
$env{'course.'.$env{'request.course.id'}.'.domain'}); |
if ($key=~/^(.+)\_exe\_time$/) { |
|
$exetime{$1}=$parmlog{$key}; |
|
} |
|
} |
|
$r->print('<table border="2">'); |
$r->print('<table border="2">'); |
foreach my $id (sort { $exetime{$a}<=>$exetime{$b} } (keys(%exetime))) { |
my $bgcolor='#EEEEEE'; |
my ($part,$name)=($parmlog{$id.'_spnam'}=~/^(.*)[\_\.]([^\_\.]+)$/); |
foreach my $id (sort { $parmlog{$b}{'exe_time'}<=>$parmlog{$a}{'exe_time'} } (keys(%parmlog))) { |
my $spnam=$part.'_'.$name; |
if ($bgcolor eq '#EEEEEE') { $bgcolor='#FFFFCC'; } else { $bgcolor='#EEEEEE'; } |
$r->print('<tr><td>'. |
my @changes=keys(%{$parmlog{$id}{'logentry'}}); |
&Apache::lonlocal::locallocaltime($parmlog{$id.'_exe_time'}). |
my $count=$#changes+1; |
'</td><td>'. |
my $time = |
&Apache::loncommon::aboutmewrapper( |
&Apache::lonlocal::locallocaltime($parmlog{$id}{'exe_time'}); |
&Apache::loncommon::plainname($parmlog{$id.'_exe_uname'}, |
my $plainname = |
$parmlog{$id.'_exe_udom'}), |
&Apache::loncommon::plainname($parmlog{$id}{'exe_uname'}, |
$parmlog{$id.'_exe_uname'}, |
$parmlog{$id}{'exe_udom'}); |
$parmlog{$id.'_exe_udom'}).'<br /><tt>'. |
my $about_me_link = |
$parmlog{$id.'_exe_uname'}.':'.$parmlog{$id.'_exe_udom'}.'</tt>'. |
&Apache::loncommon::aboutmewrapper($plainname, |
((($parmlog{$id.'_exe_uname'} ne $env{'user.name'}) || |
$parmlog{$id}{'exe_uname'}, |
($parmlog{$id.'_exe_udom'} ne $env{'user.domain'}))? |
$parmlog{$id}{'exe_udom'}); |
'<br />'.&Apache::loncommon::messagewrapper(&mt('Send message'), |
my $send_msg_link=''; |
$parmlog{$id.'_exe_uname'}, |
if ((($parmlog{$id}{'exe_uname'} ne $env{'user.name'}) |
$parmlog{$id.'_exe_udom'}):''). |
|| ($parmlog{$id}{'exe_udom'} ne $env{'user.domain'}))) { |
'</td><td>'. |
$send_msg_link ='<br />'. |
$level{'parmlevel_'.$parmlog{$id.'_snum'}}. |
&Apache::loncommon::messagewrapper(&mt('Send message'), |
'</td><td>'. |
$parmlog{$id}{'exe_uname'}, |
&mt($allparms{$name}).'<br /><tt>'.$name.'</tt>'. |
$parmlog{$id}{'exe_udom'}); |
'</td><td>'. |
} |
($part?&mt('Part: [_1]',$part):&mt('All parts')). |
$r->print('<tr bgcolor="'.$bgcolor.'"><td rowspan="'.$count.'">'.$time.'</td> |
'</td><td>'. |
<td rowspan="'.$count.'">'.$about_me_link. |
$parmlog{$id.'_symb'}. |
'<br /><tt>'.$parmlog{$id}{'exe_uname'}. |
'</td><td>'. |
':'.$parmlog{$id}{'exe_udom'}.'</tt>'. |
($parmlog{$id.'_nval'}? |
$send_msg_link.'</td>'); |
(&isdateparm($spnam)?&Apache::lonlocal::locallocaltime($parmlog{$id.'_nval'}):$parmlog{$id.'_nval'}) |
my $makenewrow=0; |
:&mt('Deleted Parameter')). |
my %istype=(); |
'</td></tr>'); |
foreach my $changed (reverse(sort(@changes))) { |
|
my $value=$parmlog{$id}{'logentry'}->{$changed}; |
|
my ($realm,$section,$parmname,$part,$typeflag,$what,$middle,$uname,$udom,$issection)= |
|
&components($changed,$parmlog{$id}{'uname'},$parmlog{$id}{'udom'}); |
|
if ($typeflag) { $istype{$parmname}=$value; } |
|
if ($makenewrow) { $r->print('<tr bgcolor="'.$bgcolor.'">'); } else { $makenewrow=1; } |
|
$r->print('<td>'.$realm.'</td><td>'.$section.'</td><td>'. |
|
&standard_parameter_names($parmname).'</td><td>'. |
|
($part?&mt('Part: [_1]',$part):&mt('All Parts')).'</td><td>'); |
|
my $stillactive=0; |
|
if ($parmlog{$id}{'deleteflag'}) { |
|
$r->print(&mt('Deleted')); |
|
} else { |
|
if ($typeflag) { |
|
$r->print(&mt('Type: [_1]',&standard_parameter_names($value))); |
|
} else { |
|
my ($level,@all)=&parmval_by_symb($what,$middle,&Apache::lonnet::metadata($middle,$what), |
|
$uname,$udom,$issection,$issection,$courseopt); |
|
if (&isdateparm($istype{$parmname})) { |
|
$r->print(&Apache::lonlocal::locallocaltime($value)); |
|
} else { |
|
$r->print($value); |
|
} |
|
if ($value ne $all[$level]) { |
|
$r->print('<br /><font color="red">'.&mt('Not active anymore').'</font>'); |
|
} else { |
|
$stillactive=1; |
|
} |
|
} |
|
} |
|
$r->print('</td>'); |
|
if ($stillactive) { |
|
if (($uname) && ($udom)) { |
|
$r->print('<td>Notify Link</td>'); |
|
} else { |
|
$r->print('<td>Blog Link</td>'); |
|
} |
|
} else { |
|
$r->print('<td> </td>'); |
|
} |
|
$r->print('</tr>'); |
|
} |
} |
} |
$r->print('</table>'); |
$r->print('</table>'); |
$r->print(&Apache::loncommon::end_page()); |
$r->print(&Apache::loncommon::end_page()); |
Line 3525 sub handler {
|
Line 3534 sub handler {
|
&assessparms($r); |
&assessparms($r); |
} elsif ($env{'form.action'} eq 'parameterchangelog' && $parm_permission) { |
} elsif ($env{'form.action'} eq 'parameterchangelog' && $parm_permission) { |
&Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=settable', |
&Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=settable', |
text=>"Parameter Change Log and Course Blog Posting"}); |
text=>"Parameter Change Log"}); |
&parm_change_log($r); |
&parm_change_log($r); |
} |
} |
} else { |
} else { |