[LON-CAPA-cvs] cvs: modules /albertel walk_course.pl

albertel lon-capa-cvs@mail.lon-capa.org
Thu, 05 Oct 2006 18:58:03 -0000


albertel		Thu Oct  5 14:58:03 2006 EDT

  Added files:                 
    /modules/albertel	walk_course.pl 
  Log:
  - logsin inits a course and walks navmaps
  
  

Index: modules/albertel/walk_course.pl
+++ modules/albertel/walk_course.pl
use Time::HiRes;
use lib '/home/httpd/lib/perl';
use LONCAPA;
use Apache::lonauthinternals();
use Apache::lonnet;
use Apache::lonuserstate();
use Apache::lonnavmaps();

my $course_id = 'annarbor_1225142ff293ef0annarborl1';
my $username  = 'albertel';
my $domain    = 'annarbor';

sub main {
    my $home = &Apache::lonnet::homeserver($username,$domain);
    my $cookie = 
	&Apache::lonauthinternals::success(undef, $username, $domain,
					   $home,'noredirect');
    print(" got cookie $cookie \n");
    print(" got seesion env?  (".scalar(keys(%env)).")\n");
    my ($furl,$ferr) = 
	&Apache::lonuserstate::readmap(join('/',split('_',$course_id)));
    print(" readmap? $furl and $ferr \n");
    my $nav = Apache::lonnavmaps::navmap->new();
    my $is_problem = sub {
	return $_[0]->is_problem;
    };
    my @resources = $nav->retrieveResources(undef,$is_problem);
    foreach my $res (@resources) {
	print($res->src." with ".(join(', ',@{$res->parts})).$/);
	foreach $part (@{$res->parts}) {
	    print("$part weight is ".$res->weight($part).$/);
	}
    }
}

my $t0=[&Time::HiRes::gettimeofday()];
&main();
print(" Took ".&Time::HiRes::tv_interval($t0)." to do\n");