forked from openwebwork/pg
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPGinfo.pl
113 lines (70 loc) · 2.22 KB
/
PGinfo.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
####################################################################
# Copyright @ 1995-2007 University of Rochester
# All Rights Reserved
####################################################################
=head1 NAME
PGinfo.pl
Provides macros for determining the values of the current context in which the problem
is being written.
=cut
loadMacros("MathObjects.pl");
=head3 listVariables
Usage: listVariables();
Prints all variables submitted in the problem form and all variables in the
the Problem environment and all of the flag variables in Context().
This is used for debugging and to determine the current
context for the problem.
=cut
sub listVariables {
TEXT($HR,"Form variables",$BR );
listFormVariables();
TEXT($HR,"Environment variables",$BR );
listEnvironmentVariables();
TEXT($HR,"Context flags",$BR );
listContextFlags();
}
=head4 listFormVariables()
Called by listVariables to print out the input form variables.
=cut
sub listFormVariables {
# Lists all of the variables filled out on the input form
# Useful for debugging
TEXT(pretty_print($inputs_ref));
}
=head4 listEnvironmentVariables()
Called by listVariables to print out the environment variables (in %envir).
=cut
sub listEnvironmentVariables {
# list the environment variables
TEXT(pretty_print(\%envir));
}
=head4 listContextFlags()
Called by listVariables to print out context flags for Math Objects.
=cut
sub listContextFlags {
my $context = $$Value::context->{flags};
TEXT(pretty_print($context));
}
=head3 listContext()
Usage: listContext(Context())
Prints out the contents of the current context hash -- includes flags and much more
=cut
sub listContext { # include
my $context = shift;
return TEXT("$PAR Error in listContext: usage: listContext(Context()); # must specify a context to list $BR") unless defined $context;
foreach $key (keys %$context) {
next if $key =~/^_/; # skip if it begins with
TEXT($HR, $key, $BR);
TEXT( pretty_print($context->{$key}) );
}
}
=head3 pp()
Usage: pp(Hash );
pp(Object);
Prints out the contents of Hash or the instance variables of Object
=cut
sub pp {
my $hash = shift;
"printing |". ref($hash)."|$BR". pretty_print($hash);
}
1;