Skip to content

Commit 76cf444

Browse files
authored
put a data-type attribute on knowl links, for example to identify whe… (#588)
put a data-type attribute on knowl links, for example to identify when the knowl contains a solution
1 parent 86e3c81 commit 76cf444

File tree

2 files changed

+19
-13
lines changed

2 files changed

+19
-13
lines changed

macros/PGbasicmacros.pl

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1237,7 +1237,7 @@ sub SOLUTION {
12371237

12381238
if ($displayMode =~/HTML/ and $envir->{use_knowls_for_solutions}) {
12391239
TEXT($PAR, knowlLink(SOLUTION_HEADING(), value => escapeSolutionHTML("$BR$solution_body$PAR"),
1240-
base64 => 1));
1240+
base64 => 1, type => 'solution'));
12411241
} elsif ($displayMode =~ /TeX/) {
12421242
TEXT(
12431243
"\n%%% BEGIN SOLUTION\n", #Marker used in PreTeXt LaTeX extraction; contact alex.jordan@pcc.edu before modifying
@@ -1299,7 +1299,7 @@ sub hint {
12991299
sub HINT {
13001300
if ($displayMode =~/HTML/ and $envir->{use_knowls_for_hints}) {
13011301
TEXT($PAR, knowlLink(HINT_HEADING(), value => escapeSolutionHTML($BR . hint(@_) . $PAR),
1302-
base64 => 1)) if hint(@_);
1302+
base64 => 1, type => 'hint')) if hint(@_);
13031303
} elsif ($displayMode =~ /TeX/) {
13041304
TEXT(
13051305
"\n%%% BEGIN HINT\n", #Marker used in PreTeXt LaTeX extraction; contact alex.jordan@pcc.edu before modifying
@@ -2391,12 +2391,12 @@ =head2 Formatting macros
23912391
OL(@array) # formats the array as an Ordered List ( <OL> </OL> ) enumerated by letters.
23922392
# See BeginList() and EndList in unionLists.pl for a more powerful version
23932393
# of this macro.
2394-
knowlLink($display_text, url => $url, value =>'' )
2394+
knowlLink($display_text, url => $url, value =>'', type =>'' )
23952395
# Places a reference to a knowl for the URL with the specified text in the problem.
2396-
# A common usage is \{ 'for help', url =>knowlLink(alias('prob1_help.html') \} )
2396+
# A common usage is \{ 'for help', url =>knowlLink(alias('prob1_help.html')) \} )
23972397
# where alias finds the full address of the prob1_help.html file in the same directory
23982398
# as the problem file
2399-
knowlLink($display_text, url => '', value = <<EOF ); # this starts a here document that ends at EOF (left justified)
2399+
knowlLink($display_text, url => '', type =>'', value = <<EOF ); # this starts a here document that ends at EOF (left justified)
24002400
help text goes here .....
24012401
EOF
24022402
# This version of the knowl reference facilitates immediate reference to a HERE document
@@ -2579,11 +2579,11 @@ sub htmlLink {
25792579

25802580
sub knowlLink {
25812581
# an new syntax for knowlLink that facilitates a local HERE document
2582-
# suggested usage knowlLink(text, [url => ..., value => ....])
2582+
# suggested usage knowlLink(text, [url => ..., value => ..., type => ...])
25832583
my $display_text = shift;
25842584
my @options = @_; # so we can check parity
25852585
my %options = @options;
2586-
WARN_MESSAGE('usage knowlLink($display_text, [url => $url, value => $helpMessage] );'.
2586+
WARN_MESSAGE('usage knowlLink($display_text, [url => $url, value => $helpMessage, type => "help/hint/solution/..."] );'.
25872587
qq!after the display_text the information requires key/value pairs.
25882588
Received @options !, scalar(@options)%2) if scalar(@options)%2;
25892589
# check that options has an even number of inputs
@@ -2596,7 +2596,10 @@ sub knowlLink {
25962596
$properties = qq! knowl = "$options{url}"!;
25972597
}
25982598
else {
2599-
WARN_MESSAGE('usage knowlLink($display_text, [url => $url, value => $helpMessage] );');
2599+
WARN_MESSAGE('usage knowlLink($display_text, [url => $url, value => $helpMessage, type => "help/hint/solution/..."] );');
2600+
}
2601+
if ($options{type}) {
2602+
$properties .= qq! data-type = "$options{type}"!;
26002603
}
26012604
#my $option_string = qq!url = "$options{url}" value = "$options{value}" !;
26022605
MODES(
@@ -2625,7 +2628,7 @@ sub helpLink {
26252628
my $helpurl = shift;
26262629
return "" if(not defined($envir{'localHelpURL'}));
26272630
if (defined $helpurl) {
2628-
return knowlLink($display_text, url => $envir{'localHelpURL'}.$helpurl);
2631+
return knowlLink($display_text, url => $envir{'localHelpURL'}.$helpurl, type => 'help');
26292632
}
26302633
my %typeHash = (
26312634
'angle' => 'Entering-Angles.html',
@@ -2662,7 +2665,7 @@ sub helpLink {
26622665

26632666
# If infoRef is still '', we give up and just print plain text
26642667
return $display_text unless ($infoRef);
2665-
return knowlLink($display_text, url => $envir{'localHelpURL'}.$infoRef);
2668+
return knowlLink($display_text, url => $envir{'localHelpURL'}.$infoRef, type => 'help');
26662669
# Old way of doing this:
26672670
# return htmlLink( $envir{'localHelpURL'}.$infoRef, $type1,
26682671
#'target="ww_help" onclick="window.open(this.href, this.target, \'width=550, height=350, scrollbars=yes, resizable=on\'); return false;"');

macros/compoundProblem5.pl

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -590,9 +590,12 @@ sub SECTION_SOLUTION {
590590
my $output = '';
591591
my $formatted_solution = main::solution($options->{PGML} ? PGML::Format2(join("",@_)) : main::EV3P(@_));
592592
if ($main::displayMode =~ /^HTML/ and $main::envir{use_knowls_for_solutions}) {
593-
$output = join($main::PAR, main::knowlLink(main::SOLUTION_HEADING(),
594-
value => main::escapeSolutionHTML($main::BR.$formatted_solution.$main::PAR),
595-
base64 => 1)) if $formatted_solution;
593+
$output = join($main::PAR, main::knowlLink(
594+
main::SOLUTION_HEADING(),
595+
value => main::escapeSolutionHTML($main::BR.$formatted_solution.$main::PAR),
596+
base64 => 1,
597+
type => 'solution'
598+
)) if $formatted_solution;
596599
} elsif ($main::displayMode =~ /TeX/) {
597600
$output = join($main::PAR,main::SOLUTION_HEADING(),$formatted_solution,$main::PAR) if $formatted_solution;
598601
} else {

0 commit comments

Comments
 (0)