|
|
|
@ -22,8 +22,12 @@ SDV($HandleActions['Exercises'], 'Exercises'); |
|
|
|
|
SDV($HandleAuth['Exercises'],'read'); |
|
|
|
|
|
|
|
|
|
function Exercises($pagename, $auth){ |
|
|
|
|
$type = $_GET["type"]; |
|
|
|
|
|
|
|
|
|
$availableexercisetypes = array("pagelink", "expressioninpage"); |
|
|
|
|
|
|
|
|
|
$exercisetype="pagelink"; |
|
|
|
|
switch ($type){ |
|
|
|
|
case "pagelink": |
|
|
|
|
list($group,$page) = explode(".",$pagename); |
|
|
|
|
// the pattern should be improve, e.g. remove PmWiki. , RecentChanges, GroupFooter, GroupHeader, Template, ... |
|
|
|
|
if ($group == "AllPages"){ |
|
|
|
@ -35,8 +39,7 @@ function Exercises($pagename, $auth){ |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//randomly pick a page in the possible pages |
|
|
|
|
$sourcepage = $pages[rand(0,count($pages))]; |
|
|
|
|
// -1? |
|
|
|
|
$sourcepage = $pages[rand(0,count($pages)-1)]; |
|
|
|
|
|
|
|
|
|
$content = ReadPage($sourcepage,READPAGE_CURRENT); |
|
|
|
|
//$text = $content["text"]; |
|
|
|
@ -77,17 +80,36 @@ function Exercises($pagename, $auth){ |
|
|
|
|
if ($group != "AllPages") { |
|
|
|
|
list($currentgroup,$currentpage) = explode(".",$answers[$i]); |
|
|
|
|
$result .="[[$pagename?action=ExercisesCheck&".$counterparam |
|
|
|
|
."type=$exercisetype&source=$sourcepage&answer=".$answers[$i]."|".$currentpage."]], "; |
|
|
|
|
."type=$type&source=$sourcepage&answer=".$answers[$i]."|".$currentpage."]], "; |
|
|
|
|
} else { |
|
|
|
|
$result .="[[$pagename?action=ExercisesCheck&".$counterparam |
|
|
|
|
."type=$exercisetype&source=$sourcepage&answer=".$answers[$i]."|".$answers[$i]."]], "; |
|
|
|
|
."type=$type&source=$sourcepage&answer=".$answers[$i]."|".$answers[$i]."]], "; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
$result .="? "; |
|
|
|
|
$result .="\n\nClick on the answer."; |
|
|
|
|
break; |
|
|
|
|
case "expressioninpage": |
|
|
|
|
// explode content by line "%0a" or word " " |
|
|
|
|
$result .= "Does the expression 'EXPRESSION' come from PAGEA PAGEB or PAGEC?"; |
|
|
|
|
break; |
|
|
|
|
default: |
|
|
|
|
$result .= "Exercise type unknown."; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$result .= "\n\nGenerated by [[http://fabien.benetou.fr/MemoryRecalls/ImprovingPIM#PIMBasedExercises|PIM Based Exercises]]"; |
|
|
|
|
$result .= "\n\nGenerated by [[http://fabien.benetou.fr/MemoryRecalls/ImprovingPIM#PIMBasedExercises|PIM Based Exercises]]. "; |
|
|
|
|
unset($availableexercisetypes[array_search($type,$availableexercisetypes)]); |
|
|
|
|
if (count($availableexercisetypes) > 0) { |
|
|
|
|
$result .= " Try other types of exercises:"; |
|
|
|
|
foreach ($availableexercisetypes as $e) { |
|
|
|
|
$result .= " [[$pagename?action=Exercises&type=$e|$e]],"; |
|
|
|
|
} |
|
|
|
|
$result .= "."; |
|
|
|
|
} |
|
|
|
|
if ( $counter > 0) { |
|
|
|
|
$result .= " (note that it resets the counter)"; |
|
|
|
|
} |
|
|
|
|
$renderedresult = MarkupToHTML($pagename, $result); |
|
|
|
|
print $renderedresult; |
|
|
|
|
|
|
|
|
@ -135,6 +157,8 @@ function ExercisesCheck($pagename, $auth){ |
|
|
|
|
$result .="\n\nTry to redeem yourself by [[$pagename?action=Exercises|trying another time]]. "; |
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
|
default: |
|
|
|
|
$result .= "Exercise type unknown."; |
|
|
|
|
} |
|
|
|
|
$result .= "\n\nGenerated by [[http://fabien.benetou.fr/MemoryRecalls/ImprovingPIM#PIMBasedExercises|PIM Based Exercises]]"; |
|
|
|
|
$renderedresult = MarkupToHTML($pagename, $result); |
|
|
|
|