(hopefuly) fixed documentation syntax and clarified display
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php if (!defined('PmWiki')) exit();
|
||||
|
||||
# generate exercises based on wiki content and its structure
|
||||
#
|
||||
@@ -9,9 +9,8 @@
|
||||
# e.g. size, frequency update, last edition, ...
|
||||
# which of those page corresponds the updates visualization V, A, B or C?
|
||||
# keyword or URL in pages
|
||||
# page linked to other page
|
||||
# implemented
|
||||
# is page A linked to page B?
|
||||
# is page A linked to page B? (type=pagelink)
|
||||
# consider a difficulty parameter
|
||||
# should be linked to the counter
|
||||
# e.g. increasing the number of possibilities (at least 1 out of 5 pages instead of at least 1 out of 3)
|
||||
@@ -19,8 +18,8 @@
|
||||
|
||||
$RecipeInfo['Exercises']['Version'] = '2011-12-08';
|
||||
|
||||
$HandleActions['Exercises'] = 'Exercises';
|
||||
$HandleAuth['Exercises'] = 'read';
|
||||
SDV($HandleActions['Exercises'], 'Exercises');
|
||||
SDV($HandleAuth['Exercises'],'read');
|
||||
|
||||
function Exercises($pagename, $auth){
|
||||
|
||||
@@ -71,12 +70,24 @@ function Exercises($pagename, $auth){
|
||||
$answers = array ($pageA,$pageB,$pageC);
|
||||
shuffle($answers);
|
||||
for ($i=0;$i<count($answers);$i++) {
|
||||
if ( $i == count($answers) -1 )
|
||||
$result .= " or ";
|
||||
$result .="[[$pagename?action=ExercisesCheck&".$counterparam."type=$exercisetype&source=$sourcepage&answer=".$answers[$i]."|".$answers[$i]."]],";
|
||||
if ($answers[$i] != "") {
|
||||
if ( $i == count($answers) -1 )
|
||||
$result .= " or ";
|
||||
//display the groupname everytime only if using AllPages
|
||||
if ($group != "AllPages") {
|
||||
list($currentgroup,$currentpage) = explode(".",$answers[$i]);
|
||||
$result .="[[$pagename?action=ExercisesCheck&".$counterparam
|
||||
."type=$exercisetype&source=$sourcepage&answer=".$answers[$i]."|".$currentpage."]], ";
|
||||
} else {
|
||||
$result .="[[$pagename?action=ExercisesCheck&".$counterparam
|
||||
."type=$exercisetype&source=$sourcepage&answer=".$answers[$i]."|".$answers[$i]."]], ";
|
||||
}
|
||||
}
|
||||
}
|
||||
$result .="? ";
|
||||
$result .="\n\nClick on the answer.";
|
||||
|
||||
$result .= "\n\nGenerated by [[http://fabien.benetou.fr/MemoryRecalls/ImprovingPIM#PIMBasedExercises|PIM Based Exercises]]";
|
||||
$renderedresult = MarkupToHTML($pagename, $result);
|
||||
print $renderedresult;
|
||||
|
||||
@@ -85,12 +96,11 @@ function Exercises($pagename, $auth){
|
||||
//print $content;
|
||||
}
|
||||
|
||||
$HandleActions['ExercisesCheck'] = 'ExercisesCheck';
|
||||
$HandleAuth['ExercisesCheck'] = 'read';
|
||||
SDV($HandleActions['ExercisesCheck'], 'ExercisesCheck');
|
||||
SDV($HandleAuth['ExercisesCheck'],'read');
|
||||
|
||||
function ExercisesCheck($pagename, $auth){
|
||||
$type = $_GET["type"];
|
||||
// assuming pagelink
|
||||
$sourcepage = $_GET["source"];
|
||||
$answer = $_GET["answer"];
|
||||
$counter = (int) $_GET["counter"];
|
||||
@@ -102,30 +112,33 @@ function ExercisesCheck($pagename, $auth){
|
||||
} else {
|
||||
$pages = ListPages("/$group\./e");
|
||||
}
|
||||
$content = ReadPage($sourcepage,READPAGE_CURRENT);
|
||||
$links = $content["targets"];
|
||||
$links_array = explode(",",$links);
|
||||
|
||||
if ( in_array($answer,$links_array) ) {
|
||||
$result .="Excellent! [[$sourcepage]] is indeed linked to [[$answer]]. ";
|
||||
$result .="Note that $links also are. ";
|
||||
if ( $counter > 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;
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
Reference in New Issue
Block a user