|
|
|
@ -6,6 +6,10 @@ error_reporting(0); |
|
|
|
|
# generate exercises based on wiki content and its structure |
|
|
|
|
# |
|
|
|
|
# still to implement (cf http://fabien.benetou.fr/Cookbook/Cognition#DailyExercisesFeed ) |
|
|
|
|
# refactor in classes? |
|
|
|
|
# random type is not implemented properly enough for score tracking |
|
|
|
|
# e.g. highest score from random appear as other exercise |
|
|
|
|
# after 1 random exercise, going back to the same type of the last picked exercise |
|
|
|
|
# which of those group corresponds the graph visualization V, A, B or C? |
|
|
|
|
# using groupnetworkvisualization.php |
|
|
|
|
# what is the correct order for pages A, B and C on descending criteria i A>B>C? A>C>B? B>C>A? B>A>C? C>B>A? C>A>B? |
|
|
|
@ -24,11 +28,12 @@ error_reporting(0); |
|
|
|
|
# does page A contains word X, Y or Z? (type=pagehasexpression) |
|
|
|
|
# which of those page corresponds the updates visualization V, A, B or C? (type=historyvisualization) |
|
|
|
|
# is page A linked to page B? (type=pagelink) |
|
|
|
|
# consider a difficulty parameter |
|
|
|
|
# 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) |
|
|
|
|
# consider doing a trip rather than random jumps |
|
|
|
|
# do a graph traversal rather than random jumps |
|
|
|
|
# i.e. if pick randomly from the linked pages or from the group or from the the whole wiki of the previous page |
|
|
|
|
# consider https://research.cc.gatech.edu/inc/game-forge |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$RecipeInfo['Exercises']['Version'] = '2015-16-08'; |
|
|
|
@ -43,11 +48,15 @@ function Exercises($pagename, $auth){ |
|
|
|
|
$difficulty = (int) $_GET["difficulty"]; |
|
|
|
|
list($group,$page) = explode(".",$pagename); |
|
|
|
|
|
|
|
|
|
$availableexercisetypes = array("pagelink", "expressioninpage", "pagehasexpression", "historyvisualization"); |
|
|
|
|
//should also test if the pim_functions.php generated the PJS has been loaded, else not make historyvisualization available |
|
|
|
|
$availableexercisetypes = array("pagelink", "expressioninpage", "pagehasexpression"); |
|
|
|
|
if (file_exists($FarmD."/pub/visualization/edits_per_page/" )) |
|
|
|
|
//the pim_functions.php generated the PJS has been loaded before |
|
|
|
|
$availableexercisetypes[] = "historyvisualization"; |
|
|
|
|
|
|
|
|
|
if ($type=="random" || $type=="") |
|
|
|
|
$type= $availableexercisetypes[rand(0,count($availableexercisetypes)-1)]; |
|
|
|
|
if ($type=="random" || $type=="") { |
|
|
|
|
$type= $availableexercisetypes[array_rand($availableexercisetypes)]; |
|
|
|
|
$random=true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$result = ""; |
|
|
|
|
$verbatimresult = ""; |
|
|
|
@ -61,10 +70,12 @@ function Exercises($pagename, $auth){ |
|
|
|
|
// this could also be consider a difficulty, the shorter the harder |
|
|
|
|
// it can be overwritten per each exercise |
|
|
|
|
|
|
|
|
|
// tracking the current score |
|
|
|
|
$counterparam = ""; |
|
|
|
|
if ( $counter > 0) { |
|
|
|
|
$counterparam = "counter=$counter&"; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// the pattern should be improve, e.g. remove PmWiki. , RecentChanges, GroupFooter, GroupHeader, Template, ... |
|
|
|
|
if ($group == "AllPages"){ |
|
|
|
|
// equivalent to getting ALL pages |
|
|
|
@ -392,17 +403,36 @@ Markup("exercisesresults", "directives", "/\(:exercisesresults:\)/", ExercisesRe |
|
|
|
|
# consider first sparklines for visuals |
|
|
|
|
function ExercisesResults(){ |
|
|
|
|
global $ScriptUrl, $FarmD, $Author; |
|
|
|
|
$availableexercisetypes = array("pagelink", "expressioninpage", "pagehasexpression", "historyvisualization"); |
|
|
|
|
$activityfile = $FarmD."/wiki.d/.exercisesscores"; |
|
|
|
|
if (file_exists($activityfile)) { |
|
|
|
|
$raw_scores = file_get_contents($activityfile); |
|
|
|
|
$allscores = explode("\n",$raw_scores); |
|
|
|
|
rsort($allscores,SORT_NUMERIC); |
|
|
|
|
//dirty, but array_filter with an lambda to test for current exercise didn't work |
|
|
|
|
foreach ($allscores as $score ) { |
|
|
|
|
list($counter,$author,$type,$time) = explode(",",$score); |
|
|
|
|
if ($Author == $author) $author = "<b>$author</b>"; |
|
|
|
|
// $Author somehow never gets initialized |
|
|
|
|
if ($counter != "") |
|
|
|
|
$past_scores .= "<li> $counter done by $author doing $type at $time</li>\n"; |
|
|
|
|
if ($counter.$author.$type.$time != "") |
|
|
|
|
$structuredanswers[] = array("counter"=>$counter,"author"=>$author,"type"=>$type,"time"=>$time); |
|
|
|
|
} |
|
|
|
|
// could instead filter by exercise and sort by highest score, listing the top3 score per per exercise |
|
|
|
|
$past_scores .= "<table><tr>"; |
|
|
|
|
foreach ($availableexercisetypes as $exercisetype){ |
|
|
|
|
$past_scores .= "<td><a href=\"?action=Exercises&type=$exercisetype\">$exercisetype</a></td>"; |
|
|
|
|
} |
|
|
|
|
$past_scores .= "</tr><tr>"; |
|
|
|
|
foreach ($availableexercisetypes as $exercisetype){ |
|
|
|
|
$past_scores .= "<td valign=\"top\">"; |
|
|
|
|
$answers_added = 1; |
|
|
|
|
foreach ($structuredanswers as $sa){ |
|
|
|
|
if ($sa["type"]==$exercisetype && $answers_added<4){ |
|
|
|
|
$past_scores .= "".$sa["counter"]." done by ".$sa["author"]." (".date("H:m m/d/y",$sa["time"]).")<br/>"; |
|
|
|
|
$answers_added++; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
$past_scores .= "</td>"; |
|
|
|
|
} |
|
|
|
|
$past_scores .= "</tr></table>"; |
|
|
|
|
} else { |
|
|
|
|
$past_scores = "Currently no scores have been recorded. Consider starting an exercise first"; |
|
|
|
|
// print "Go above the minimum threshold of good answers while being logged in."; |
|
|
|
|