[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 6404
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 {
482 } 482 }
483 $self->{answer_blank_count}++; 483 $self->{answer_blank_count}++;
484 $label; 484 $label;
485} 485}
486 486
487sub record_array_name { # currently the same as record ans group 487sub record_array_name { # currently the same as record ans name
488 my $self = shift; 488 my $self = shift;
489 my $label = shift; 489 my $label = shift;
490 my $value = shift; 490 my $value = shift;
491 my $response_group = new PGresponsegroup($label,$label,$value); 491 my $response_group = new PGresponsegroup($label,$label,$value);
492 if (defined($self->{PG_ANSWERS_HASH}->{$label}) ) { 492 if (defined($self->{PG_ANSWERS_HASH}->{$label}) ) {
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 # this error message is correct but misleading for the original way
516 # in which matrix blanks and their response evaluators are matched up
517 # we should restore the warning message once the new matrix evaluation method is in place
515 518
516 } 519 }
517 $label; 520 $label;
518} 521}
519sub record_unlabeled_ans_name { 522sub record_unlabeled_ans_name {
576# return $self->($name); #if no parameters just return the value 579# return $self->($name); #if no parameters just return the value
577# } 580# }
578# } 581# }
579 582
580 583
584# Sometimes a question author needs to code or decode base64 directly
585sub decode_base64 ($) {
586 my $self = shift;
587 my $str = shift;
588 MIME::Base64::decode_base64($str);
589}
581 590
591sub encode_base64 ($;$) {
592 my $self = shift;
593 my $str = shift;
594 my $option = shift;
595 MIME::Base64::encode_base64($str);
596}
582sub debug_message { 597sub debug_message {
583 my $self = shift; 598 my $self = shift;
584 my @str = @_; 599 my @str = @_;
585 push @{$self->{flags}->{DEBUG_messages}}, @str; 600 push @{$self->{flags}->{DEBUG_messages}}, @str;
586} 601}
587sub get_debug_messages { 602sub get_debug_messages {
588 my $self = shift; 603 my $self = shift;
589 $self->{flags}->{DEBUG_messages}; 604 $self->{flags}->{DEBUG_messages};
590} 605}
606sub warning_message {
607 my $self = shift;
608 my @str = @_;
609 push @{$self->{flags}->{WARNING_messages}}, @str;
610}
611sub get_warning_messages {
612 my $self = shift;
613 $self->{flags}->{WARNING_messages};
614}
591 615
592sub internal_debug_message { 616sub internal_debug_message {
593 my $self = shift; 617 my $self = shift;
594 my @str = @_; 618 my @str = @_;
595 push @{$internal_debug_messages}, @str; 619 push @{$internal_debug_messages}, @str;
605 629
606sub DESTROY { 630sub DESTROY {
607 # doing nothing about destruction, hope that isn't dangerous 631 # doing nothing about destruction, hope that isn't dangerous
608} 632}
609 633
610sub WARN { 634# sub WARN {
611 warn(@_); 635# warn(@_);
612} 636# }
613 637
614 638
615# This creates on the fly graphs 639# This creates on the fly graphs
616 640
617=head2 insertGraph 641=head2 insertGraph

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

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9