Diff for /loncom/interface/loncommon.pm between versions 1.370 and 1.375

version 1.370, 2006/05/12 02:17:50 version 1.375, 2006/05/18 01:08:50
Line 2608  sub timehash { Line 2608  sub timehash {
   
 sub utc_string {  sub utc_string {
     my ($date)=@_;      my ($date)=@_;
     my @utctime=gmtime($date);      return strftime("%Y%m%dT%H%M%SZ",gmtime($date));
     my $year=$utctime[5]+1900;  
     my $month=$utctime[4]+1;  
     return "$year$month$utctime[3]T$utctime[2]$utctime[1]$utctime[0]Z";  
 }  }
   
 sub maketime {  sub maketime {
Line 3131  table#LC_title_bar { Line 3128  table#LC_title_bar {
   padding: 0px 2px 0px 2px;    padding: 0px 2px 0px 2px;
   background: $pgbg;    background: $pgbg;
   font-family: $sans;    font-family: $sans;
   border-collapse: collapse;    border-collapse: separate;
 }  }
 table#LC_title_bar.LC_with_remote {  table#LC_title_bar.LC_with_remote {
   width: 100%;    width: 100%;
Line 3168  table#LC_menubuttons_mainmenu { Line 3165  table#LC_menubuttons_mainmenu {
   background: $pgbg;    background: $pgbg;
   border: 0px;    border: 0px;
   border-spacing: 1px;    border-spacing: 1px;
   padding: 0px;    padding: 0px 1px;
   margin: 0px;    margin: 0px;
   border-collapse: separate;    border-collapse: separate;
 }  }
Line 3557  Inputs:         $args - additional optio Line 3554  Inputs:         $args - additional optio
   
 sub end_page {  sub end_page {
     my ($args) = @_;      my ($args) = @_;
     #&Apache::lonnet::logthis("end_page ".join(':',caller(0)));  
     $env{'internal.end_page'}++;      $env{'internal.end_page'}++;
     my $result;      my $result;
     if ($args->{'discussion'}) {      if ($args->{'discussion'}) {
Line 3600  sub js_ready { Line 3596  sub js_ready {
     $result =~ s/[\n\r]/ /xmsg;      $result =~ s/[\n\r]/ /xmsg;
     $result =~ s/\\/\\\\/xmsg;      $result =~ s/\\/\\\\/xmsg;
     $result =~ s/'/\\'/xmsg;      $result =~ s/'/\\'/xmsg;
     $result =~ s{</script>}{</scrip'+'t>}xmsg;      $result =~ s{</}{<\\/}xmsg;
           
     return $result;      return $result;
 }  }
Line 3713  specific user. Roles can be active, prev Line 3709  specific user. Roles can be active, prev
   
 Inputs:   Inputs: 
 user's domain, user's username, course's domain,  user's domain, user's username, course's domain,
 course's number, optional section/group.  course's number, optional section ID.
   
 Outputs:  Outputs:
 role status: active, previous or future.   role status: active, previous or future. 
Line 3764  sub check_user_status { Line 3760  sub check_user_status {
   
 Determines all the sections for a course including  Determines all the sections for a course including
 sections with students and sections containing other roles.  sections with students and sections containing other roles.
 Incoming parameters: domain, course number, reference to   Incoming parameters: domain, course number, 
 section hash (keys to be section/group IDs), reference to   reference to array containing roles for which sections should 
 array containing roles for which sections should be gathered  be gathered (optional). If the third argument is undefined,
 (optional). If the fourth argument is undefined, sections  sections are gathered for any role.
 are gathered for any role.  
     
 Returns number of sections.  Returns section hash (keys are section IDs, values are
   number of users in each section), subject to the
   optional roles filter.
   
 =cut  =cut
   
Line 3818  sub get_sections { Line 3815  sub get_sections {
 }  }
   
 ###############################################  ###############################################
                                                                                     
 =pod  
                                                                                     
 =item coursegroups  
   
 Retrieve information about groups in a course,  
   
 Input:  
 1. Reference to hash to populate with group information.   
 2. Optional course domain  
 3. Optional course number  
 4. Optional group name  
   
 Course domain and number will be taken from user's  
 environment if not supplied. Optional group name will'  
 be passed to lonnet::get_coursegroups() as a regexp to  
 use in the call to the dump function.  
   
 Output  
 Returns number of groups in the course (subject to the  
 optional group name filter).  
   
 Side effects:  
 Populates the referenced curr_groups hash, with key,  
 value pairs. Keys are group names, corresponding values  
 are scalars containing group information in XML. This  
 can be sent to &get_group_settings() to be parsed.       
   
 =cut   
   
 ###############################################  
   
 sub coursegroups {  
     my ($cdom,$cnum,$group) = @_;  
     if (!defined($cdom) || !defined($cnum)) {  
         my $cid =  $env{'request.course.id'};  
   
  return if (!defined($cid));  
   
         $cdom = $env{'course.'.$cid.'.domain'};  
         $cnum = $env{'course.'.$cid.'.num'};  
     }  
     my %curr_groups = &Apache::lonnet::get_coursegroups($cdom,$cnum,$group);  
     my ($tmp) = keys(%curr_groups);  
     if ($tmp=~/^(con_lost|no_such_host|error: [^2] )/) {  
  undef(%curr_groups);  
  &logthis('Error retrieving groups: '.$tmp.' in '.$cnum.':'.$cdom);  
     } elsif ($tmp=~/^error: 2 /) {  
  undef(%curr_groups);  
     }  
     return %curr_groups;  
 }  
   
 ###############################################  
   
 =pod  
   
 =item get_group_settings  
   
 Uses TokeParser to extract group information from the  
 XML used to describe course groups.  
   
 Input:  
 Scalar containing XML  - as retrieved from &coursegroups().  
   
 Output:  
 Hash containing group information as key=values for (a), and  
 hash of hashes for (b)  
   
 Keys (in two categories):  
 (a) groupname, creator, creation, modified, startdate,enddate.  
 Corresponding values are name of the group, creator of the group  
 (username:domain), UNIX time for date group was created, and  
 settings were last modified, and default start and end access  
 times for group members.  
   
 (b) functions returned in hash of hashes.  
 Outer hash key is functions.  
 Inner hash keys are chat,discussion,email,files,homepage,roster.  
 Corresponding values are either on or off, depending on  
 whether this type of functionality is available for the group.  
   
 =cut  
                                                                                    
 ###############################################  
   
 sub get_group_settings {  
     my ($groupinfo)=@_;  
     my $parser=HTML::TokeParser->new(\$groupinfo);  
     my $token;  
     my $tool = '';  
     my $role = '';  
     my %content=();  
     while ($token=$parser->get_token) {  
         if ($token->[0] eq 'S')  {  
             my $entry=$token->[1];  
             if ($entry eq 'functions' || $entry eq 'autosec') {  
                 %{$content{$entry}} = ();  
                 $tool = $entry;  
             } elsif ($entry eq 'role') {  
                 if ($tool eq 'autosec') {  
                     $role = $token->[2]{id};  
                 }  
             } else {  
                 my $value=$parser->get_text('/'.$entry);  
                 if ($entry eq 'name') {  
                     if ($tool eq 'functions') {  
                         my $function = $token->[2]{id};  
                         $content{$tool}{$function} = $value;  
                     }  
                 } elsif ($entry eq 'groupname') {  
                     $content{$entry}=&unescape($value);  
                 } elsif (($entry eq 'roles') || ($entry eq 'types') ||  
                          ($entry eq 'sectionpick') || ($entry eq 'defpriv')) {  
                     push(@{$content{$entry}},$value);  
                 } elsif ($entry eq 'section') {  
                     if ($tool eq 'autosec'  && $role ne '') {  
                         push(@{$content{$tool}{$role}},$value);  
                     }  
                 } else {  
                     $content{$entry}=$value;  
                 }  
             }  
         } elsif ($token->[0] eq 'E') {  
             if ($token->[1] eq 'functions' || $token->[1] eq 'autosec') {  
                 $tool = '';  
             } elsif ($token->[1] eq 'role') {  
                 $role = '';  
             }  
   
         }  
     }  
     return %content;  
 }  
   
 sub check_group_access {  
     my ($group) = @_;  
     my $access = 1;  
     my $now = time;  
     my ($start,$end) = split(/\./,$env{'user.role.gr/'.$env{'request.course,id'}.'/'.$group});  
     if (($end!=0) && ($end<$now)) { $access = 0; }  
     if (($start!=0) && ($start>$now)) { $access=0; }  
     return $access;  
 }  
   
 ###############################################  
   
 =pod  =pod
                                                                                                                                                                   
Line 5028  a hash ref describing the data to be sto Line 4879  a hash ref describing the data to be sto
     'chartoutputmode' => 'scalar',      'chartoutputmode' => 'scalar',
     'chartoutputdata' => 'scalar',      'chartoutputdata' => 'scalar',
     'Section' => 'array',      'Section' => 'array',
       'Group' => 'array',
     'StudentData' => 'array',      'StudentData' => 'array',
     'Maps' => 'array');      'Maps' => 'array');
   

Removed from v.1.370  
changed lines
  Added in v.1.375


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>