[LON-CAPA-cvs] cvs: loncom /interface lonparmset.pm
www
lon-capa-cvs@mail.lon-capa.org
Mon, 06 Jun 2005 02:25:12 -0000
This is a MIME encoded message
--www1118024712
Content-Type: text/plain
www Sun Jun 5 22:25:12 2005 EDT
Modified files:
/loncom/interface lonparmset.pm
Log:
Saving this wonderful piece of work.
--www1118024712
Content-Type: text/plain
Content-Disposition: attachment; filename="www-20050605222512.txt"
Index: loncom/interface/lonparmset.pm
diff -u loncom/interface/lonparmset.pm:1.210 loncom/interface/lonparmset.pm:1.211
--- loncom/interface/lonparmset.pm:1.210 Sun Jun 5 13:24:04 2005
+++ loncom/interface/lonparmset.pm Sun Jun 5 22:25:09 2005
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Handler to set parameters for assessments
#
-# $Id: lonparmset.pm,v 1.210 2005/06/05 17:24:04 www Exp $
+# $Id: lonparmset.pm,v 1.211 2005/06/06 02:25:09 www Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -668,6 +668,7 @@
my $maptitles=shift;
my $uris=shift;
my $keyorder=shift;
+ my $defkeytype=shift;
my $keyordercnt=100;
@@ -699,6 +700,7 @@
my $parmdis = $display;
$parmdis =~ s/\[Part.*$//g;
$$allparms{$name}=$parmdis;
+ $$defkeytype{$name}=&Apache::lonnet::metadata($srcf,$key.'.type');
#
# allparts is a hash of all parts
#
@@ -741,7 +743,7 @@
##################################################
sub parmmenu {
- my ($r,$allparms,$pscat)=@_;
+ my ($r,$allparms,$pscat,$keyorder)=@_;
my $tempkey;
$r->print(<<ENDSCRIPT);
<script type="text/javascript">
@@ -798,8 +800,7 @@
$r->print();
$r->print("\n<table><tr>");
my $cnt=0;
- foreach $tempkey (sort { $$allparms{$a} cmp $$allparms{$b} }
- keys %{$allparms} ) {
+ foreach $tempkey (&keysindisplayorder($allparms,$keyorder)) {
$r->print("\n<td><font size='-1'><input type='checkbox' name='pscat' ");
$r->print('value="'.$tempkey.'"');
if ($$pscat[0] eq "all" || grep $_ eq $tempkey, @{$pscat}) {
@@ -829,7 +830,7 @@
sub partmenu {
my ($r,$allparts,$psprt)=@_;
- $r->print('<select multiple name="psprt" size="5">');
+ $r->print('<select multiple name="psprt" size="8">');
$r->print('<option value="all"');
$r->print(' selected') unless (@{$psprt});
$r->print('>'.&mt('All Parts').'</option>');
@@ -886,10 +887,10 @@
}
sub displaymenu {
- my ($r,$allparms,$allparts,$pscat,$psprt)=@_;
+ my ($r,$allparms,$allparts,$pscat,$psprt,$keyorder)=@_;
$r->print('<table border="1"><tr><th>'.&mt('Select Parameters to View').'</th><th>'.
&mt('Select Parts to View').'</th></tr><tr><td>');
- &parmmenu($r,$allparms,$pscat);
+ &parmmenu($r,$allparms,$pscat,$keyorder);
$r->print('</td><td>');
&partmenu($r,$allparts,$psprt);
$r->print('</td></tr></table>');
@@ -923,6 +924,48 @@
$r->print("</select>");
}
+
+sub sectionmenu {
+ my ($r,$selectedsections)=@_;
+
+ my ($classlist,$field_names) =
+ &Apache::loncoursedata::get_classlist(
+ $env{'request.course.id'},
+ $env{'course.'.$env{'request.course.id'}.'.domain'},
+ $env{'course.'.$env{'request.course.id'}.'.num'});
+ my %Sections=();
+ while (my ($student,$student_data) = each (%$classlist)) {
+ my $studenthash = ();
+ for (my $i=0; $i< scalar(@$field_names);$i++) {
+ my $field = $field_names->[$i];
+ # Store the data
+ $studenthash->{$field}=$student_data->[$i];
+ }
+ my $section = $studenthash->{'section'};
+ if (! defined($section) || $section =~/^\s*$/ || $section == -1) {
+ $studenthash->{'section'} = 'none';
+ $section = $studenthash->{'section'};
+ }
+ $Sections{$section}++;
+ }
+ my @Sections = sort {$a cmp $b} keys(%Sections);
+ unshift(@Sections,'all');
+
+ $r->print('<select name="Section" multiple="true" size="8" >');
+
+ foreach my $s (@Sections) {
+ $r->print(' <option value="'.$s.'"');
+ foreach (@{$selectedsections}) {
+ if ($s eq $_) {
+ $r->print(' selected');
+ last;
+ }
+ }
+ $r->print('>'.$s."</option>\n");
+ }
+ $r->print("</select>\n");
+}
+
sub keysplit {
my $keyp=shift;
return (split(/\,/,$keyp));
@@ -935,6 +978,34 @@
} (keys %{$name});
}
+sub keysindisplayorder {
+ my ($name,$keyorder)=@_;
+ return sort {
+ $$keyorder{'parameter_0_'.$a} <=> $$keyorder{'parameter_0_'.$b};
+ } (keys %{$name});
+}
+
+sub standardkeyorder {
+ return ('parameter_0_opendate' => 1,
+ 'parameter_0_duedate' => 2,
+ 'parameter_0_answerdate' => 3,
+ 'parameter_0_interval' => 4,
+ 'parameter_0_weight' => 5,
+ 'parameter_0_maxtries' => 6,
+ 'parameter_0_hinttries' => 7,
+ 'parameter_0_contentopen' => 8,
+ 'parameter_0_contentclose' => 9,
+ 'parameter_0_type' => 10,
+ 'parameter_0_problemstatus' => 11,
+ 'parameter_0_hiddenresource' => 12,
+ 'parameter_0_hiddenparts' => 13,
+ 'parameter_0_display' => 14,
+ 'parameter_0_ordered' => 15,
+ 'parameter_0_tol' => 16,
+ 'parameter_0_sig' => 17,
+ 'parameter_0_turnoffunit' => 18);
+}
+
##################################################
##################################################
@@ -998,24 +1069,8 @@
#
# Order in which these parameters will be displayed
#
- my %keyorder=('parameter_0_opendate' => 1,
- 'parameter_0_duedate' => 2,
- 'parameter_0_answerdate' => 3,
- 'parameter_0_interval' => 4,
- 'parameter_0_weight' => 5,
- 'parameter_0_maxtries' => 6,
- 'parameter_0_hinttries' => 7,
- 'parameter_0_contentopen' => 8,
- 'parameter_0_contentclose' => 9,
- 'parameter_0_type' => 10,
- 'parameter_0_problemstatus' => 11,
- 'parameter_0_hiddenresource' => 12,
- 'parameter_0_hiddenparts' => 13,
- 'parameter_0_display' => 14,
- 'parameter_0_ordered' => 15,
- 'parameter_0_tol' => 16,
- 'parameter_0_sig' => 17,
- 'parameter_0_turnoffunit' => 18);
+ my %keyorder=&standardkeyorder();
+
@ids=();
%symbp=();
%typep=();
@@ -1153,7 +1208,7 @@
$r->print('</td>');
}
$r->print('</td></tr></table>');
- &displaymenu($r,\%allparms,\%allparts,\@pscat,\@psprt);
+ &displaymenu($r,\%allparms,\%allparts,\@pscat,\@psprt,\%keyorder);
} else {
my ($map,$id,$resource)=&Apache::lonnet::decode_symb($pssymb);
$r->print(&mt('Specific Resource').": ".$resource.
@@ -1996,7 +2051,11 @@
$tableopen=0;
my $foundkeys=0;
foreach my $thiskey (sort keys %{$listdata}) {
- if ($$resourcedata{$thiskey.'.type'}) {
+ if ($$listdata{$thiskey.'.type'}) {
+ my $thistype=$$listdata{$thiskey.'.type'};
+ if ($$resourcedata{$thiskey.'.type'}) {
+ $thistype=$$resourcedata{$thiskey.'.type'};
+ }
my ($middle,$part,$name)=
($thiskey=~/^$env{'request.course.id'}\.(?:(.+)\.)*([\w\s]+)\.(\w+)$/);
my $section=&mt('All Students');
@@ -2040,7 +2099,7 @@
':</b></td><td><input type="checkbox" name="del_'.
$thiskey.'" /></td><td>');
$foundkeys++;
- if ($$resourcedata{$thiskey.'.type'}=~/^date/) {
+ if ($thistype=~/^date/) {
my $jskey='key_'.$pointer;
$pointer++;
$r->print(
@@ -2050,10 +2109,11 @@
'<input type="hidden" name="datepointer_'.$thiskey.'" value="'.$jskey.'" />'
);
} else {
- $r->print(
- '<input type="text" name="set_'.$thiskey.'" value="'.
+ $r->print('<input type="text" name="set_'.$thiskey.'" value="'.
$$resourcedata{$thiskey}.'">');
}
+ $r->print('<input type="hidden" name="typeof_'.$thiskey.'" value="'.
+ $thistype.'">');
$r->print('</td></tr>');
}
}
@@ -2075,10 +2135,123 @@
</head>
$bodytag
$breadcrumbs
-<form method="post" action="/adm/parmset?action=newoverview" name="overviewform">
+<form method="post" action="/adm/parmset?action=newoverview" name="parmform">
ENDOVER
- $r->print(&tableend().
- '<p><input type="submit" value="'.&mt('Submit').'" /></p></form></body></html>');
+ my @ids=();
+ my %typep=();
+ my %keyp=();
+ my %allparms=();
+ my %allparts=();
+ my %allmaps=();
+ my %mapp=();
+ my %symbp=();
+ my %maptitles=();
+ my %uris=();
+ my %keyorder=&standardkeyorder();
+ my %defkeytype=();
+
+ my %alllevs=();
+ $alllevs{'Resource Level'}='full';
+ $alllevs{'Map Level'}='map';
+ $alllevs{'Course Level'}='general';
+
+ my $csec=$env{'form.csec'};
+
+ my @pscat=&Apache::loncommon::get_env_multiple('form.pscat');
+ my $pschp=$env{'form.pschp'};
+ my @psprt=&Apache::loncommon::get_env_multiple('form.psprt');
+ if (!@psprt) { $psprt[0]='0'; }
+
+ my @selected_sections =
+ &Apache::loncommon::get_env_multiple('form.Section');
+ @selected_sections = ('all') if (! @selected_sections);
+ foreach (@selected_sections) {
+ if ($_ eq 'all') {
+ @selected_sections = ('all');
+ }
+ }
+
+ my $pssymb='';
+ my $parmlev='';
+
+ unless ($env{'form.parmlev'}) {
+ $parmlev = 'map';
+ } else {
+ $parmlev = $env{'form.parmlev'};
+ }
+
+ &extractResourceInformation(\@ids, \%typep,\%keyp, \%allparms, \%allparts, \%allmaps,
+ \%mapp, \%symbp,\%maptitles,\%uris,
+ \%keyorder,\%defkeytype);
+
+# Menu to select levels, etc
+
+ $r->print('<table border="1"><tr><td>');
+ &levelmenu($r,\%alllevs,$parmlev);
+ if ($parmlev ne 'general') {
+ $r->print('<td>');
+ &mapmenu($r,\%allmaps,$pschp,\%maptitles);
+ $r->print('</td>');
+ }
+ $r->print('</td></tr></table>');
+
+ $r->print('<table border="1"><tr><td>');
+ &parmmenu($r,\%allparms,\@pscat,\%keyorder);
+ $r->print('</td><td>');
+ &partmenu($r,\%allparts,\@psprt);
+ $r->print('</td><td>');
+ §ionmenu($r,\@selected_sections);
+ $r->print('</td></tr></table>');
+
+
+# Build the list data hash from the specified parms
+
+ my $listdata;
+ %{$listdata}=();
+
+ foreach my $cat (@pscat) {
+ foreach my $section (@selected_sections) {
+ foreach my $part (@psprt) {
+ my $newparmkey=$env{'request.course.id'};
+ if (($section ne 'all') && ($section ne 'none') && ($section)) {
+ $newparmkey.='.['.$section.']';
+ }
+ if ($parmlev eq 'general') {
+# course-level parameter
+ } elsif ($parmlev eq 'map') {
+ foreach my $map (keys %allmaps) {
+ if (($pschp ne 'all') && ($pschp ne $map)) { next; }
+ $newparmkey.='.'.$allmaps{$map}.'.'.$part.'.'.$cat;
+ $$listdata{$newparmkey}=1;
+ $$listdata{$newparmkey.'.type'}=$defkeytype{$cat};
+ }
+# map-level parameter
+ } else {
+# resource-level parameter
+
+ }
+ }
+ }
+ }
+
+
+
+ $r->print(join("\n<br />",keys %{$listdata}));
+
+ if ($env{'form.dis'}) {
+
+ &storedata($r,$crs,$dom);
+
+# Read modified data
+
+ my $resourcedata=&readdata($crs,$dom);
+
+# List data
+
+ &listdata($r,$resourcedata,$listdata);
+ }
+ $r->print(&tableend().
+ '<p><input type="submit" name="dis" value="'.&mt('Submit').'" /></p></form></body></html>');
}
sub overview {
--www1118024712--