[system] / trunk / pg / lib / PGcore.pm Repository:
ViewVC logotype

Diff of /trunk/pg/lib/PGcore.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 6292 Revision 6346
28use PGrandom; 28use PGrandom;
29use PGalias; 29use PGalias;
30use PGloadfiles; 30use PGloadfiles;
31use WeBWorK::PG::IO(); # don't important any command directly 31use WeBWorK::PG::IO(); # don't important any command directly
32use Tie::IxHash; 32use Tie::IxHash;
33 33use MIME::Base64;
34################################## 34##################################
35# Utility macro 35# Utility macro
36################################## 36##################################
37 37
38=head2 Utility Macros 38=head2 Utility Macros
352 my @in = @_; 352 my @in = @_;
353 while (@in ) { 353 while (@in ) {
354 my $label = shift @in; 354 my $label = shift @in;
355 #$label = join("", $self->{QUIZ_PREFIX}, $self->{SECTION_PREFIX}, $label); 355 #$label = join("", $self->{QUIZ_PREFIX}, $self->{SECTION_PREFIX}, $label);
356 my $ans_eval = shift @in; 356 my $ans_eval = shift @in;
357 $self->WARN("<BR><B>Error in LABELED_ANS:|$label|</B> 357 $self->warning_message("<BR><B>Error in LABELED_ANS:|$label|</B>
358 -- inputs must be references to AnswerEvaluator objects or subroutines<BR>") 358 -- inputs must be references to AnswerEvaluator objects or subroutines<BR>")
359 unless ref($ans_eval) =~ /CODE/ or ref($ans_eval) =~ /AnswerEvaluator/ ; 359 unless ref($ans_eval) =~ /CODE/ or ref($ans_eval) =~ /AnswerEvaluator/ ;
360 if (defined($self->{PG_ANSWERS_HASH}->{$label}) ){ 360 if (defined($self->{PG_ANSWERS_HASH}->{$label}) ){
361 $self->{PG_ANSWERS_HASH}->{$label}->insert(ans_label => $label, ans_eval => $ans_eval, active=>$self->{PG_ACTIVE}); 361 $self->{PG_ANSWERS_HASH}->{$label}->insert(ans_label => $label, ans_eval => $ans_eval, active=>$self->{PG_ACTIVE});
362 } else { 362 } else {
509 my @response_list = @_; 509 my @response_list = @_;
510 my $answer_group = $self->{PG_ANSWERS_HASH}->{$label}; 510 my $answer_group = $self->{PG_ANSWERS_HASH}->{$label};
511 if (ref($answer_group) =~/PGanswergroup/) { 511 if (ref($answer_group) =~/PGanswergroup/) {
512 $answer_group->append_responses(@response_list); 512 $answer_group->append_responses(@response_list);
513 } else { 513 } else {
514 $self->WARN("The answer |$label| has not yet been defined, you cannot extend it.",caller() ); 514 $self->warning_message("The answer |$label| has not yet been defined, you cannot extend it.",caller() );
515 515
516 } 516 }
517 $label; 517 $label;
518} 518}
519sub record_unlabeled_ans_name { 519sub record_unlabeled_ans_name {
576# return $self->($name); #if no parameters just return the value 576# return $self->($name); #if no parameters just return the value
577# } 577# }
578# } 578# }
579 579
580 580
581# Sometimes a question author needs to code or decode base64 directly
582sub decode_base64 ($) {
583 my $self = shift;
584 my $str = shift;
585 MIME::Base64::decode_base64($str);
586}
581 587
588sub encode_base64 ($;$) {
589 my $self = shift;
590 my $str = shift;
591 my $option = shift;
592 MIME::Base64::encode_base64($str);
593}
582sub debug_message { 594sub debug_message {
583 my $self = shift; 595 my $self = shift;
584 my @str = @_; 596 my @str = @_;
585 push @{$self->{flags}->{DEBUG_messages}}, @str; 597 push @{$self->{flags}->{DEBUG_messages}}, @str;
586} 598}
587sub get_debug_messages { 599sub get_debug_messages {
588 my $self = shift; 600 my $self = shift;
589 $self->{flags}->{DEBUG_messages}; 601 $self->{flags}->{DEBUG_messages};
590} 602}
603sub warning_message {
604 my $self = shift;
605 my @str = @_;
606 push @{$self->{flags}->{WARNING_messages}}, @str;
607}
608sub get_warning_messages {
609 my $self = shift;
610 $self->{flags}->{WARNING_messages};
611}
591 612
592sub internal_debug_message { 613sub internal_debug_message {
593 my $self = shift; 614 my $self = shift;
594 my @str = @_; 615 my @str = @_;
595 push @{$internal_debug_messages}, @str; 616 push @{$internal_debug_messages}, @str;
605 626
606sub DESTROY { 627sub DESTROY {
607 # doing nothing about destruction, hope that isn't dangerous 628 # doing nothing about destruction, hope that isn't dangerous
608} 629}
609 630
610sub WARN { 631# sub WARN {
611 warn(@_); 632# warn(@_);
612} 633# }
613 634
614 635
615# This creates on the fly graphs 636# This creates on the fly graphs
616 637
617=head2 insertGraph 638=head2 insertGraph

Legend:
Removed from v.6292  
changed lines
  Added in v.6346

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9