Commit c3a8b7fb authored by Administrator's avatar Administrator 💬

Sort the pages in a lesson from the `level` parameter.

parent 443668f2
Pipeline #53 passed with stage
in 52 seconds
......@@ -239,7 +239,6 @@ class M3P2Plugin extends Plugin
}
$lesson_slug = $uri->paths(1);
// var_dump($lesson_slug);
// $target_pages = $pages->all()->filter(function ($p) use ($lesson_slug) {
$target_pages = array_filter($pages->instances(), function (Page $p) use ($lesson_slug) {
......@@ -258,11 +257,30 @@ class M3P2Plugin extends Plugin
return false;
});
// var_dump($target_pages);
usort($target_pages, function (Page $a, Page $b) use ($lesson_slug) {
$la = 0;
$lb = 0;
// fixme: sort pages
$ha = $a->header();
$hb = $b->header();
// $target_page = $pages->all();
$fdp = function ($pp) use ($lesson_slug) {
return $pp["slug"] == $lesson_slug;
};
// We're assuming the config exists (it should)
$ma = array_filter($ha->pedagogic_paths, $fdp)[0];
$mb = array_filter($hb->pedagogic_paths, $fdp)[0];
if (isset($ma['level'])) {
$la = floor($ma['level']);
}
if (isset($mb['level'])) {
$lb = floor($mb['level']);
}
return $la - $lb;
});
if (empty($target_pages)) {
return;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment