[LON-CAPA-cvs] cvs: loncom /interface lonnavmaps.pm
damieng
damieng at source.lon-capa.org
Fri Jun 19 11:36:53 EDT 2015
damieng Fri Jun 19 15:36:53 2015 EDT
Modified files:
/loncom/interface lonnavmaps.pm
Log:
speed optimization for lonnavmaps: pre-calculating symb() when a resource object is created
Index: loncom/interface/lonnavmaps.pm
diff -u loncom/interface/lonnavmaps.pm:1.507 loncom/interface/lonnavmaps.pm:1.508
--- loncom/interface/lonnavmaps.pm:1.507 Wed Apr 15 18:56:15 2015
+++ loncom/interface/lonnavmaps.pm Fri Jun 19 15:36:53 2015
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Navigate Maps Handler
#
-# $Id: lonnavmaps.pm,v 1.507 2015/04/15 18:56:15 raeburn Exp $
+# $Id: lonnavmaps.pm,v 1.508 2015/06/19 15:36:53 damieng Exp $
#
# Copyright Michigan State University Board of Trustees
@@ -3860,9 +3860,12 @@
# about this resource in. Not used by the resource object
# directly.
$self->{DATA} = {};
-
+
bless($self);
+ # This is a speed optimization, to avoid calling symb() too often.
+ $self->{SYMB} = $self->symb();
+
return $self;
}
@@ -3974,8 +3977,8 @@
}
sub shown_symb {
my $self=shift;
- if ($self->encrypted()) {return &Apache::lonenc::encrypted($self->symb());}
- return $self->symb();
+ if ($self->encrypted()) {return &Apache::lonenc::encrypted($self->{SYMB});}
+ return $self->{SYMB};
}
sub id {
my $self=shift;
@@ -3996,7 +3999,7 @@
}
sub wrap_symb {
my $self = shift;
- return $self->{NAV_MAP}->wrap_symb($self->symb());
+ return $self->{NAV_MAP}->wrap_symb($self->{SYMB});
}
sub title {
my $self=shift;
@@ -4219,7 +4222,7 @@
if (!defined($part)) {
$part = '0';
}
- return $self->{NAV_MAP}->parmval($part.'.'.$what, $self->symb());
+ return $self->{NAV_MAP}->parmval($part.'.'.$what, $self->{SYMB});
}
=pod
@@ -4472,25 +4475,25 @@
my $self = shift; my $part = shift;
$self->{NAV_MAP}->get_user_data();
if (!defined($part)) { $part = '0'; }
- return $self->{NAV_MAP}->{STUDENT_DATA}->{$self->symb()}->{'resource.'.$part.'.awarded'};
+ return $self->{NAV_MAP}->{STUDENT_DATA}->{$self->{SYMB}}->{'resource.'.$part.'.awarded'};
}
sub taskversion {
my $self = shift; my $part = shift;
$self->{NAV_MAP}->get_user_data();
if (!defined($part)) { $part = '0'; }
- return $self->{NAV_MAP}->{STUDENT_DATA}->{$self->symb()}->{'resource.'.$part.'.version'};
+ return $self->{NAV_MAP}->{STUDENT_DATA}->{$self->{SYMB}}->{'resource.'.$part.'.version'};
}
sub taskstatus {
my $self = shift; my $part = shift;
$self->{NAV_MAP}->get_user_data();
if (!defined($part)) { $part = '0'; }
- return $self->{NAV_MAP}->{STUDENT_DATA}->{$self->symb()}->{'resource.'.$self->taskversion($part).'.'.$part.'.status'};
+ return $self->{NAV_MAP}->{STUDENT_DATA}->{$self->{SYMB}}->{'resource.'.$self->taskversion($part).'.'.$part.'.status'};
}
sub solved {
my $self = shift; my $part = shift;
$self->{NAV_MAP}->get_user_data();
if (!defined($part)) { $part = '0'; }
- return $self->{NAV_MAP}->{STUDENT_DATA}->{$self->symb()}->{'resource.'.$part.'.solved'};
+ return $self->{NAV_MAP}->{STUDENT_DATA}->{$self->{SYMB}}->{'resource.'.$part.'.solved'};
}
sub checkedin {
my $self = shift; my $part = shift;
@@ -4498,9 +4501,9 @@
if (!defined($part)) { $part = '0'; }
if ($self->is_task()) {
my $version = $self->taskversion($part);
- return ($self->{NAV_MAP}->{STUDENT_DATA}->{$self->symb()}->{'resource.'.$version .'.'.$part.'.checkedin'},$self->{NAV_MAP}->{STUDENT_DATA}->{$self->symb()}->{'resource.'.$version .'.'.$part.'.checkedin.slot'});
+ return ($self->{NAV_MAP}->{STUDENT_DATA}->{$self->{SYMB}}->{'resource.'.$version .'.'.$part.'.checkedin'},$self->{NAV_MAP}->{STUDENT_DATA}->{$self->{SYMB}}->{'resource.'.$version .'.'.$part.'.checkedin.slot'});
} else {
- return ($self->{NAV_MAP}->{STUDENT_DATA}->{$self->symb()}->{'resource.'.$part.'.checkedin'},$self->{NAV_MAP}->{STUDENT_DATA}->{$self->symb()}->{'resource.'.$part.'.checkedin.slot'});
+ return ($self->{NAV_MAP}->{STUDENT_DATA}->{$self->{SYMB}}->{'resource.'.$part.'.checkedin'},$self->{NAV_MAP}->{STUDENT_DATA}->{$self->{SYMB}}->{'resource.'.$part.'.checkedin.slot'});
}
}
# this should work exactly like the copy in lonhomework.pm
@@ -4592,7 +4595,7 @@
my $self = shift; my $part = shift;
if (!defined($part)) { $part = '0'; }
my $weight = &Apache::lonnet::EXT('resource.'.$part.'.weight',
- $self->symb(), $self->{DOMAIN},
+ $self->{SYMB}, $self->{DOMAIN},
$self->{USERNAME},
$env{'request.course.sec'});
return $weight;
@@ -4621,7 +4624,7 @@
my $self = shift;
if (!defined($self->{RETURN_HASH})) {
- my %tmpHash = &Apache::lonnet::restore($self->symb(),undef,$self->{DOMAIN},$self->{USERNAME});
+ my %tmpHash = &Apache::lonnet::restore($self->{SYMB},undef,$self->{DOMAIN},$self->{USERNAME});
$self->{RETURN_HASH} = \%tmpHash;
}
}
@@ -4686,23 +4689,23 @@
sub hasDiscussion {
my $self = shift;
- return $self->{NAV_MAP}->hasDiscussion($self->symb());
+ return $self->{NAV_MAP}->hasDiscussion($self->{SYMB});
}
sub last_post_time {
my $self = shift;
- return $self->{NAV_MAP}->last_post_time($self->symb());
+ return $self->{NAV_MAP}->last_post_time($self->{SYMB});
}
sub discussion_info {
my ($self,$filter) = @_;
- return $self->{NAV_MAP}->discussion_info($self->symb(),$filter);
+ return $self->{NAV_MAP}->discussion_info($self->{SYMB},$filter);
}
sub getFeedback {
my $self = shift;
my $source = $self->src();
- my $symb = $self->symb();
+ my $symb = $self->{SYMB};
if ($source =~ /^\/res\//) { $source = substr $source, 5; }
return $self->{NAV_MAP}->getFeedback($symb,$source);
}
@@ -4710,7 +4713,7 @@
sub getErrors {
my $self = shift;
my $source = $self->src();
- my $symb = $self->symb();
+ my $symb = $self->{SYMB};
if ($source =~ /^\/res\//) { $source = substr $source, 5; }
return $self->{NAV_MAP}->getErrors($symb,$source);
}
@@ -4860,7 +4863,7 @@
if ($partorder) {
my @parts;
for my $part (split (/,/,$partorder)) {
- if (!Apache::loncommon::check_if_partid_hidden($part, $self->symb())) {
+ if (!Apache::loncommon::check_if_partid_hidden($part, $self->{SYMB})) {
push @parts, $part;
$parts{$part} = 1;
}
@@ -4878,12 +4881,12 @@
my $part = $1;
# This floods the logs if it blows up
if (defined($parts{$part})) {
- &Apache::lonnet::logthis("$part multiply defined in metadata for " . $self->symb());
+ &Apache::lonnet::logthis("$part multiply defined in metadata for " . $self->{SYMB});
}
# check to see if part is turned off.
- if (!Apache::loncommon::check_if_partid_hidden($part, $self->symb())) {
+ if (!Apache::loncommon::check_if_partid_hidden($part, $self->{SYMB})) {
$parts{$part} = 1;
}
}
@@ -5388,7 +5391,7 @@
sub check_for_slot {
my $self = shift;
my $part = shift;
- my $symb = $self->symb();
+ my $symb = $self->{SYMB};
my ($use_slots,$available,$availablestudent) = $self->slot_control($part);
if (($use_slots ne '') && ($use_slots !~ /^\s*no\s*$/i)) {
my @slots = (split(/:/,$availablestudent),split(/:/,$available));
@@ -5710,7 +5713,7 @@
}
$self->{BROWSE_PRIV} = &Apache::lonnet::allowed('bre',$self->src(),
- $self->symb(),undef,
+ $self->{SYMB},undef,
undef,$noblockcheck);
}
More information about the LON-CAPA-cvs
mailing list