--- loncom/interface/lonparmset.pm 2016/07/15 18:03:52 1.561 +++ loncom/interface/lonparmset.pm 2017/07/10 12:48:41 1.574 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Handler to set parameters for assessments # -# $Id: lonparmset.pm,v 1.561 2016/07/15 18:03:52 damieng Exp $ +# $Id: lonparmset.pm,v 1.574 2017/07/10 12:48:41 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -367,14 +367,14 @@ sub endSettingsScreen { ################################################## -# TABLE MODE +# (mostly) TABLE MODE # (parmval is also used for the log of parameter changes) ################################################## -# Calls parmval_by_symb, getting the symb from $id (the big hash resource id) with &symbcache. +# Calls parmval_by_symb, getting the symb from $id with &symbcache. # # @param {string} $what - part info and parameter name separated by a dot, e.g. '0.weight' -# @param {string} $id - big hash resource id +# @param {string} $id - resource id or map pc # @param {string} $def - the resource's default value for this parameter # @param {string} $uname - user name # @param {string} $udom - user domain @@ -394,7 +394,7 @@ sub parmval { # (level 1 is the most specific and will have precedence) # # @param {string} $what - part info and parameter name separated by a dot, e.g. '0.weight' -# @param {string} $symb - resource symb +# @param {string} $symb - resource symb or map src # @param {string} $def - the resource's default value for this parameter # @param {string} $uname - user name # @param {string} $udom - user domain @@ -597,7 +597,7 @@ sub reset_caches { } } -# cache big hash id -> symb, using lonnavmaps to find association +# cache resource id or map pc -> resource symb or map src, using lonnavmaps to find association { my $symbsid; # course identifier, to initialize the cache only once for a course my %symbs; # hash id->symb @@ -607,7 +607,8 @@ sub reset_caches { undef(%symbs); } - # returns the symb corresponding to a big hash id (using lonnavmaps and a cache) + # returns the resource symb or map src corresponding to a resource id or map pc + # (using lonnavmaps and a cache) sub symbcache { my $id=shift; if ($symbsid ne $env{'request.course.id'}) { @@ -718,8 +719,8 @@ sub date_sanity_info { # Store a parameter value and type by ID, also triggering more parameter changes based on parameter default actions. # -# @param {string} $sresid - resource big hash id -# @param {string} $spnam - part info and parameter name separated by a dot, e.g. '0.weight' +# @param {string} $sresid - resource id or map pc +# @param {string} $spnam - part info and parameter name separated by a dot or underscore, e.g. '0.weight' # @param {integer} $snum - level # @param {string} $nval - new value # @param {string} $ntype - new type @@ -737,8 +738,8 @@ my %recstack; # hash parameter name -> 1 # Store a parameter value and type by symb, also triggering more parameter changes based on parameter default actions. # Uses storeparm_by_symb_inner to actually store the parameter, ignoring any returned error. # -# @param {string} $symb - resource symb -# @param {string} $spnam - part info and parameter name separated by a dot, e.g. '0.weight' +# @param {string} $symb - resource symb or map src +# @param {string} $spnam - part info and parameter name separated by a dot or underscore, e.g. '0.weight' # @param {integer} $snum - level # @param {string} $nval - new value # @param {string} $ntype - new type @@ -776,8 +777,7 @@ sub storeparm_by_symb { # are there restrictions? if (&rulescache($triggered.'_triggervalue')=~/\w/) { $active=0; - foreach my $possiblevalue (split(/\s*\, - \s*/,&rulescache($triggered.'_triggervalue'))) { + foreach my $possiblevalue (split(/\s*\,\s*/,&rulescache($triggered.'_triggervalue'))) { if (lc($possiblevalue) eq lc($nval)) { $active=1; } } } @@ -808,7 +808,7 @@ sub log_parmset { # Store a parameter value and type by symb, without using the parameter default actions. # Expire related sheets. # -# @param {string} $symb - resource symb +# @param {string} $symb - resource symb or map src # @param {string} $spnam - part info and parameter name separated by a dot, e.g. '0.weight' # @param {integer} $snum - level # @param {string} $nval - new value @@ -1065,16 +1065,16 @@ sub page_js { document.parmform.action+='#'+document.parmform.pres_marker.value; var typedef=new Array(); typedef=document.parmform.pres_type.value.split('_'); - if (document.parmform.pres_type.value!='') { - if (typedef[0]=='date') { - eval('document.parmform.recent_'+ - document.parmform.pres_type.value+ - '.value=document.parmform.pres_value.value;'); - } else { - eval('document.parmform.recent_'+typedef[0]+ - '.value=document.parmform.pres_value.value;'); + if (document.parmform.pres_type.value!='') { + if (typedef[0]=='date') { + eval('document.parmform.recent_'+ + document.parmform.pres_type.value+ + '.value=document.parmform.pres_value.value;'); + } else { + eval('document.parmform.recent_'+typedef[0]+ + '.value=document.parmform.pres_value.value;'); + } } - } document.parmform.submit(); } else { document.parmform.pres_value.value=''; @@ -1365,7 +1365,7 @@ ENDHEAD # @param {string} $which - parameter key ('parameter_'.part.'_'.name) # @param {hash reference} $part - parameter key -> parameter part (can be problem part.'_'.response id for response parameters) # @param {hash reference} $name - parameter key -> parameter name -# @param {hash reference} $symbp - resource id -> symb +# @param {hash reference} $symbp - map pc or resource/map id -> map src.'___(all)' or resource symb # @param {string} $rid - resource id # @param {hash reference} $default - parameter key -> resource parameter default value # @param {hash reference} $defaulttype - parameter key -> resource parameter default type @@ -1380,9 +1380,11 @@ ENDHEAD # @param {string} $cgroup - group name # @param {array reference} $usersgroups - list of groups the user belongs to, if any # @param {boolean} $noeditgrp - true if no edit is allowed for group level parameters +# @param {boolean} $readonly - true if no editing allowed. sub print_row { my ($r,$which,$part,$name,$symbp,$rid,$default,$defaulttype,$display,$defbgone, - $defbgtwo,$defbgthree,$parmlev,$uname,$udom,$csec,$cgroup,$usersgroups,$noeditgrp)=@_; + $defbgtwo,$defbgthree,$parmlev,$uname,$udom,$csec,$cgroup,$usersgroups,$noeditgrp, + $readonly)=@_; my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; my $courseopt=&Apache::lonnet::get_courseresdata($cnum,$cdom); @@ -1427,27 +1429,27 @@ sub print_row { if ($parmlev eq 'general') { if ($uname) { - &print_td($r,4,$defbgone,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display); + &print_td($r,4,$defbgone,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,'',$readonly); } elsif ($cgroup) { - &print_td($r,8,$defbgthree,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,$noeditgrp); + &print_td($r,8,$defbgthree,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,$noeditgrp,$readonly); } elsif ($csec) { - &print_td($r,12,$defbgtwo,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display); + &print_td($r,12,$defbgtwo,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,'',$readonly); } else { - &print_td($r,18,$defbgone,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display); + &print_td($r,18,$defbgone,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,'',$readonly); } } elsif ($parmlev eq 'map') { if ($uname) { - &print_td($r,3,$defbgone,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display); - &print_td($r,2,$defbgone,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display); + &print_td($r,3,$defbgone,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,'',$readonly); + &print_td($r,2,$defbgone,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,'',$readonly); } elsif ($cgroup) { - &print_td($r,7,$defbgthree,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,$noeditgrp); - &print_td($r,6,$defbgthree,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,$noeditgrp); + &print_td($r,7,$defbgthree,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,$noeditgrp,$readonly); + &print_td($r,6,$defbgthree,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,$noeditgrp,$readonly); } elsif ($csec) { - &print_td($r,11,$defbgtwo,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display); - &print_td($r,10,$defbgtwo,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display); + &print_td($r,11,$defbgtwo,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,'',$readonly); + &print_td($r,10,$defbgtwo,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,'',$readonly); } else { - &print_td($r,17,$defbgone,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display); - &print_td($r,16,$defbgone,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display); + &print_td($r,17,$defbgone,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,'',$readonly); + &print_td($r,16,$defbgone,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,'',$readonly); } } else { if ($uname) { @@ -1467,35 +1469,35 @@ sub print_row { } } - &print_td($r,18,$defbgone,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display); - &print_td($r,17,$defbgone,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display); - &print_td($r,16,$defbgone,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display); - &print_td($r,15,'#FFDDDD',$result,\@outpar,$mprefix,$which,\@typeoutpar,$display); - &print_td($r,14,'#FFDDDD',$result,\@outpar,$mprefix,$which,\@typeoutpar,$display); - &print_td($r,13,$defbgone,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display); + &print_td($r,18,$defbgone,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,'',$readonly); + &print_td($r,17,$defbgone,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,'',$readonly); + &print_td($r,16,$defbgone,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,'',$readonly); + &print_td($r,15,'#FFDDDD',$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,'',$readonly); + &print_td($r,14,'#FFDDDD',$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,'',$readonly); + &print_td($r,13,$defbgone,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,'',$readonly); if ($csec) { - &print_td($r,12,$defbgtwo,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display); - &print_td($r,11,$defbgtwo,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display); - &print_td($r,10,$defbgtwo,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display); - &print_td($r,9,$defbgtwo,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display); + &print_td($r,12,$defbgtwo,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,'',$readonly); + &print_td($r,11,$defbgtwo,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,'',$readonly); + &print_td($r,10,$defbgtwo,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,'',$readonly); + &print_td($r,9,$defbgtwo,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,'',$readonly); } if ($cgroup) { - &print_td($r,8,$defbgthree,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,$noeditgrp); - &print_td($r,7,$defbgthree,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,$noeditgrp); - &print_td($r,6,$defbgthree,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,$noeditgrp); - &print_td($r,5,$defbgthree,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,$noeditgrp); + &print_td($r,8,$defbgthree,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,$noeditgrp,$readonly); + &print_td($r,7,$defbgthree,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,$noeditgrp,$readonly); + &print_td($r,6,$defbgthree,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,$noeditgrp,$readonly); + &print_td($r,5,$defbgthree,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,$noeditgrp.$readonly); } if ($uname) { if ($othergrp) { $r->print($othergrp); } - &print_td($r,4,$defbgone,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display); - &print_td($r,3,$defbgone,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display); - &print_td($r,2,$defbgone,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display); - &print_td($r,1,$defbgone,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display); + &print_td($r,4,$defbgone,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,'',$readonly); + &print_td($r,3,$defbgone,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,'',$readonly); + &print_td($r,2,$defbgone,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,'',$readonly); + &print_td($r,1,$defbgone,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,'',$readonly); } } # end of $parmlev if/else @@ -1532,26 +1534,35 @@ sub print_row { # @param {array reference} $typeoutpar - array level -> parameter type (when defined) # @param {hash reference} $display - parameter key -> full title for the parameter # @param {boolean} $noeditgrp - true if no edit is allowed for group level parameters +# @param {boolean} $readonly -true if editing not allowed. sub print_td { - my ($r,$which,$defbg,$result,$outpar,$mprefix,$value,$typeoutpar,$display,$noeditgrp)=@_; + my ($r,$which,$defbg,$result,$outpar,$mprefix,$value,$typeoutpar,$display,$noeditgrp,$readonly)=@_; $r->print(''); my $nolink = 0; - if ($which == 14 || $which == 15) { - $nolink = 1; - } elsif (($env{'request.course.sec'} ne '') && ($which > 12)) { + if ($readonly) { $nolink = 1; - } elsif ($which == 5 || $which == 6 || $which == 7 || $which == 8) { - if ($noeditgrp) { - $nolink = 1; - } - } elsif ($mprefix =~ /availablestudent\&$/) { - if ($which > 4) { + } else { + if ($which == 14 || $which == 15 || $mprefix =~ /mapalias\&/) { $nolink = 1; - } - } elsif ($mprefix =~ /examcode\&$/) { - unless ($which == 2) { + } elsif (($env{'request.course.sec'} ne '') && ($which > 12)) { $nolink = 1; + } elsif ($which == 5 || $which == 6 || $which == 7 || $which == 8) { + if ($noeditgrp) { + $nolink = 1; + } + } elsif ($mprefix =~ /availablestudent\&$/) { + if ($which > 4) { + $nolink = 1; + } + } elsif ($mprefix =~ /examcode\&$/) { + unless ($which == 2) { + $nolink = 1; + } + } elsif ($mprefix =~ /(encrypturl|hiddenresource)/) { + if ($which == 16 || $which == 10 || $which == 6 || $which == 2) { + $nolink = 1; + } } } if ($nolink) { @@ -1648,7 +1659,21 @@ sub parm_control_group { -# extracts lots of information about all of the the course's resources into a variety of hashes. +# Extracts lots of information about all of the the course's resources into a variety of hashes, using lonnavmaps and lonnet::metadata. +# All the parameters are references and are filled by the sub. +# +# @param {array reference} $ids - resource and map ids +# @param {hash reference} $typep - hash resource/map id -> resource type (file extension) +# @param {hash reference} $keyp - hash resource/map id -> comma-separated list of parameter keys from lonnet::metadata +# @param {hash reference} $allparms - hash parameter name -> parameter title +# @param {hash reference} $allparts - hash parameter part -> part title (a parameter part can be problem part.'_'.response id for response parameters) +# @param {hash reference} $allmaps - hash map pc -> map src +# @param {hash reference} $mapp - hash map pc or resource/map id -> enclosing map src +# @param {hash reference} $symbp - hash map pc or resource/map id -> map src.'___(all)' for a map or resource symb for a resource +# @param {hash reference} $maptitles - hash map pc or src -> map title (this should really be two separate hashes) +# @param {hash reference} $uris - hash resource/map id -> resource src +# @param {hash reference} $keyorder - hash parameter key -> appearance rank for this parameter when looking through every resource and every parameter, starting at 100 (integer) +# @param {hash reference} $defkeytype - hash parameter name -> parameter type sub extractResourceInformation { my $ids = shift; my $typep = shift; @@ -1749,17 +1774,22 @@ sub extractResourceInformation { } - +# Tells if a parameter type is a date. +# +# @param {string} type - parameter type +# @returns{boolean} - true if it is a date sub isdateparm { my $type=shift; return (($type=~/^date/) && (!($type eq 'date_interval'))); } +# Prints the HTML and Javascript to select parameters, with various shortcuts. +# FIXME: remove unused parameters # -# parmmenu displays a list of the selected parameters. -# It also offers a link to show/hide the complete parameter list -# from which you can select all desired parameters. -# +# @param {Apache2::RequestRec} $r - the Apache request (unused) +# @param {hash reference} $allparms - hash parameter name -> parameter title +# @param {array reference} $pscat - list of selected parameter names (unused) +# @param {hash reference} $keyorder - hash parameter key -> appearance rank (unused) sub parmmenu { my ($r,$allparms,$pscat,$keyorder)=@_; my $tempkey; @@ -1775,7 +1805,7 @@ sub parmmenu { displayOverview = "none" } - for (i=0; i @@ -1844,7 +1872,10 @@ ENDSCRIPT &shortCuts($r,$allparms,$pscat,$keyorder); $r->print('
'); } -# return a hash + +# Returns parameter categories. +# +# @returns {hash} - category name -> title in English sub categories { return ('time_settings' => 'Time Settings', 'grading' => 'Grading', @@ -1858,7 +1889,9 @@ sub categories { 'misc' => 'Miscellaneous' ); } -# return a hash. Like a look-up table +# Returns the category for each parameter. +# +# @returns {hash} - parameter name -> category name sub lookUpTableParameter { return ( @@ -1909,6 +1942,10 @@ sub lookUpTableParameter { ); } +# Adds the given parameter name to an array of arrays listing all parameters for each category. +# +# @param {string} $name - parameter name +# @param {array reference} $catList - array reference category name -> array reference of parameter names sub whatIsMyCategory { my $name = shift; my $catList = shift; @@ -1932,6 +1969,11 @@ sub whatIsMyCategory { } } +# Sorts parameter names based on appearance order. +# +# @param {array reference} name - array reference of parameter names +# @param {hash reference} $keyorder - hash parameter key -> appearance rank +# @returns {Array} - array of parameter names sub keysindisplayorderCategory { my ($name,$keyorder)=@_; return sort { @@ -1939,6 +1981,9 @@ sub keysindisplayorderCategory { } ( @{$name}); } +# Returns a hash category name -> order, starting at 1 (integer) +# +# @returns {hash} sub category_order { return ( 'time_settings' => 1, @@ -1955,6 +2000,12 @@ sub category_order { } +# Prints HTML to let the user select parameters, from a list of all parameters organized by category. +# +# @param {Apache2::RequestRec} $r - the Apache request +# @param {hash reference} $allparms - hash parameter name -> parameter title +# @param {array reference} $pscat - list of selected parameter names +# @param {hash reference} $keyorder - hash parameter key -> appearance rank sub parmboxes { my ($r,$allparms,$pscat,$keyorder)=@_; my %categories = &categories(); @@ -1996,9 +2047,14 @@ sub parmboxes { } $r->print("\n"); } + +# Prints HTML with shortcuts to select groups of parameters in one click, or deselect all. +# FIXME: remove unused parameters # -# This function offers some links on the parameter section to get with one click a group a parameters -# +# @param {Apache2::RequestRec} $r - the Apache request +# @param {hash reference} $allparms - hash parameter name -> parameter title (unused) +# @param {array reference} $pscat - list of selected parameter names (unused) +# @param {hash reference} $keyorder - hash parameter key -> appearance rank (unused) sub shortCuts { my ($r,$allparms,$pscat,$keyorder)=@_; @@ -2031,6 +2087,12 @@ sub shortCuts { ); } +# Prints HTML to select parts to view (except for the title). +# Used by table and overview modes. +# +# @param {Apache2::RequestRec} $r - the Apache request +# @param {hash reference} $allparts - hash parameter part -> part title +# @param {array reference} $psprt - list of selected parameter parts sub partmenu { my ($r,$allparts,$psprt)=@_; my $selsize = 1+scalar(keys(%{$allparts})); @@ -2040,7 +2102,7 @@ sub partmenu { $r->print(''); } +# Prints HTML to select a user and/or a group. +# Used by table mode. +# +# @param {Apache2::RequestRec} $r - the Apache request +# @param {string} $uname - selected user name +# @param {string} $id - selected Student/Employee ID +# @param {string} $udom - selected user domain +# @param {string} $csec - selected section name +# @param {string} $cgroup - selected group name +# @param {string} $parmlev - parameter level (Resource:'full', Map:'map', Course:'general') +# @param {array reference} $usersgroups - list of groups the user belongs to, if any +# @param {string} $pssymb - resource symb (when a single resource is selected) sub usermenu { my ($r,$uname,$id,$udom,$csec,$cgroup,$parmlev,$usersgroups,$pssymb)=@_; my $chooseopt=&Apache::loncommon::select_dom_form($udom,'udom').' '. @@ -2168,16 +2242,23 @@ function group_or_section(caller) { ,$chooseopt)); } +# Prints HTML to select parameters from a list of all parameters. +# Uses parmmenu and parmboxes. +# Used by table and overview modes. # -# This function shows on table Mode the available Parameters for the selected Resources -# +# @param {Apache2::RequestRec} $r - the Apache request +# @param {hash reference} $allparms - hash parameter name -> parameter title +# @param {array reference} $pscat - list of selected parameter names +# @param {array reference} $psprt - list of selected parameter parts (unused) +# @param {hash reference} $keyorder - hash parameter key -> appearance rank +# @param {string} [$divid] - name used to give an id to the HTML element for the scroll box sub displaymenu { my ($r,$allparms,$pscat,$psprt,$keyorder,$divid)=@_; $r->print(&Apache::lonhtmlcommon::start_pick_box()); $r->print(&Apache::lonhtmlcommon::row_title(&mt('Select Parameters to View'))); - &parmmenu($r,$allparms,$pscat,$keyorder); + &parmmenu($r,$allparms,$pscat,$keyorder); # only $allparms is used by parmmenu $r->print(&Apache::loncommon::start_scrollbox('480px','440px','200px',$divid)); &parmboxes($r,$allparms,$pscat,$keyorder); $r->print(&Apache::loncommon::end_scrollbox()); @@ -2187,6 +2268,14 @@ sub displaymenu { } +# Prints HTML to select a map. +# Used by table mode and overview mode. +# +# @param {Apache2::RequestRec} $r - the Apache request +# @param {hash reference} $allmaps - hash map pc -> map src +# @param {string} $pschp - selected map pc, or 'all' +# @param {hash reference} $maptitles - hash map id or src -> map title +# @param {hash reference} $symbp - hash map pc or resource/map id -> map src.'___(all)' or resource symb sub mapmenu { my ($r,$allmaps,$pschp,$maptitles,$symbp)=@_; my %allmaps_inverted = reverse %$allmaps; @@ -2338,8 +2427,12 @@ sub mapmenu { } } -# Build up the select Box to choose if your parameter specification should work for the resource, map/folder or the course level -# The value of default selection in the select box is set by the value that is given by the argument in $parmlev. +# Prints HTML to select the parameter level (resource, map/folder or course). +# Used by table and overview modes. +# +# @param {Apache2::RequestRec} $r - the Apache request +# @param {hash reference} $alllevs - all parameter levels, hash English title -> value +# @param {string} $parmlev - selected level value (full|map|general), or '' sub levelmenu { my ($r,$alllevs,$parmlev)=@_; @@ -2357,6 +2450,11 @@ sub levelmenu { } +# Returns HTML to select a section (with a select HTML element). +# Used by overview mode. +# +# @param {array reference} $selectedsections - list of selected section ids +# @returns {string} sub sectionmenu { my ($selectedsections)=@_; my %sectionhash = &Apache::loncommon::get_sections(); @@ -2382,6 +2480,11 @@ sub sectionmenu { return $output; } +# Returns HTML to select a group (with a select HTML element). +# Used by overview mode. +# +# @param {array reference} $selectedgroups - list of selected group names +# @returns {string} sub groupmenu { my ($selectedgroups)=@_; my %grouphash; @@ -2404,11 +2507,23 @@ sub groupmenu { return $output; } +# Returns an array with the given parameter split by comma. +# Used by assessparms (table mode). +# +# @param {string} $keyp - the string to split +# @returns {Array} sub keysplit { my $keyp=shift; return (split(/\,/,$keyp)); } +# Returns the keys in $name, sorted using $keyorder. +# Parameters are sorted by key, which means they are sorted by part first, then by name. +# Used by assessparms (table mode) for resource level. +# +# @param {hash reference} $name - parameter key -> parameter name +# @param {hash reference} $keyorder - hash parameter key -> appearance rank +# @returns {Array} sub keysinorder { my ($name,$keyorder)=@_; return sort { @@ -2416,10 +2531,16 @@ sub keysinorder { } (keys(%{$name})); } +# Returns the keys in $name, sorted using $keyorder to sort parameters by name first, then by part. +# Used by assessparms (table mode) for map and general levels. +# +# @param {hash reference} $name - parameter key -> parameter name +# @param {hash reference} $keyorder - hash parameter key -> appearance rank +# @returns {Array} sub keysinorder_bytype { my ($name,$keyorder)=@_; return sort { - my $ta=(split('_',$a))[-1]; + my $ta=(split('_',$a))[-1]; # parameter name my $tb=(split('_',$b))[-1]; if ($$keyorder{'parameter_0_'.$ta} == $$keyorder{'parameter_0_'.$tb}) { return ($a cmp $b); @@ -2428,6 +2549,12 @@ sub keysinorder_bytype { } (keys(%{$name})); } +# Returns the keys in $name, sorted using $keyorder to sort parameters by name. +# Used by defaultsetter (parameter settings default actions). +# +# @param {hash reference} $name - hash parameter name -> parameter title +# @param {hash reference} $keyorder - hash parameter key -> appearance rank +# @returns {Array} sub keysindisplayorder { my ($name,$keyorder)=@_; return sort { @@ -2435,6 +2562,11 @@ sub keysindisplayorder { } (keys(%{$name})); } +# Prints HTML with a choice to sort results by realm or student first. +# Used by overview mode. +# +# @param {Apache2::RequestRec} $r - the Apache request +# @param {string} $sortorder - realmstudent|studentrealm sub sortmenu { my ($r,$sortorder)=@_; $r->print('