From 5821b36d0b546a3b452bb605e2448de0203b2ea2 Mon Sep 17 00:00:00 2001 From: Fabien Benetou Date: Fri, 12 Aug 2011 21:59:18 +0200 Subject: [PATCH] (hopefuly) fixed documentation syntax and clarified display --- pmwiki_recipes/exercises.php | 75 +++++++++++++++++++++--------------- 1 file changed, 44 insertions(+), 31 deletions(-) diff --git a/pmwiki_recipes/exercises.php b/pmwiki_recipes/exercises.php index 76d54ba..841c8c0 100644 --- a/pmwiki_recipes/exercises.php +++ b/pmwiki_recipes/exercises.php @@ -1,4 +1,4 @@ - 0) { - $counter++; - $result .="See if you can [[$pagename?action=Exercises&counter=$counter|solve yet another one]]. "; - } else { - $result .="See if you can [[$pagename?action=Exercises&counter=1|solve yet another one]]. "; - } - } else { - $result .="No, [[$sourcepage]] is not linked to [[$answer]] "; - $result .="but $links are. "; - $result .="Try to redeem yourself by [[$pagename?action=Exercises|trying another time]]. "; + switch ($type) { + case "pagelink": + $content = ReadPage($sourcepage,READPAGE_CURRENT); + $links = $content["targets"]; + $links_array = explode(",",$links); + $formattedlinks = implode(", ",$links_array); + + if ( in_array($answer,$links_array) ) { + $result .="Excellent! [[$sourcepage]] is indeed linked to [[$answer]]. "; + $result .="Note that $formattedlinks also are. "; + if ( $counter > 0) { + $counter++; + $result .="\n\nSee if you can [[$pagename?action=Exercises&counter=$counter|solve yet another one]]. "; + } else { + $result .="\n\nSee if you can [[$pagename?action=Exercises&counter=1|solve yet another one]]. "; + } + } else { + $result .="No, [[$sourcepage]] is not linked to [[$answer]] "; + $result .="but $formattedlinks are. "; + $result .="\n\nTry to redeem yourself by [[$pagename?action=Exercises|trying another time]]. "; + } + break; } + $result .= "\n\nGenerated by [[http://fabien.benetou.fr/MemoryRecalls/ImprovingPIM#PIMBasedExercises|PIM Based Exercises]]"; $renderedresult = MarkupToHTML($pagename, $result); print $renderedresult; - - //$text = RetrieveAuthSection($pagename,$auth); - //$content = MarkupToHTML($pagename, $text); - //print $content; } ?>