Example #1
0
        }
        break;
}
// Log it
add_to_log($course->id, 'lesson', 'view highscores', "highscores.php?id={$cm->id}", $lesson->name, $cm->id);
lesson_print_header($cm, $course, $lesson, 'highscores');
switch ($mode) {
    case 'add':
        print_simple_box_start('center');
        echo '<div class="mdl-align">
                 <form id="nickname" method ="post" action="' . $CFG->wwwroot . '/mod/lesson/highscores.php" autocomplete="off">
                 <input type="hidden" name="id" value="' . $cm->id . '" />
                 <input type="hidden" name="mode" value="save" />
                 <input type="hidden" name="sesskey" value="' . sesskey() . '" />';
        echo get_string("entername", "lesson") . ": <input type=\"text\" name=\"name\" size=\"7\" maxlength=\"5\" />\n<p>\n";
        lesson_print_submit_link(get_string("submitname", "lesson"), 'nickname');
        echo "</p>\n</form>\n</div>\n";
        print_simple_box_end();
        break;
    default:
        $params = array("lessonid" => $lesson->id);
        if (!($grades = $DB->get_records_select("lesson_grades", "lessonid = :lessonid", $params, "completed"))) {
            $grades = array();
        }
        print_heading(get_string("topscorestitle", "lesson", $lesson->maxhighscores), 'center', 4);
        if (!($highscores = $DB->get_records_select("lesson_high_scores", "lessonid = :lessonid", $params))) {
            print_heading(get_string("nohighscores", "lesson"), 'center', 3);
        } else {
            foreach ($highscores as $highscore) {
                $grade = $grades[$highscore->gradeid]->grade;
                $topscores[$grade][] = $highscore->nickname;
Example #2
0
             // sort to find the lowest score
             sort($topscores);
             $lowscore = $topscores[0];
             if ($gradeinfo->grade >= $lowscore || count($uniquescores) <= $lesson->maxhighscores) {
                 $madeit = true;
             }
         }
         if (!$highscores or $madeit) {
             echo '<p>' . get_string("youmadehighscore", "lesson", $lesson->maxhighscores) . '</p>
                       <form method="post" id="highscores" action="' . $CFG->wwwroot . '/mod/lesson/highscores.php">
                       <div>
                       <input type="hidden" name="mode" value="add" />
                       <input type="hidden" name="id" value="' . $cm->id . '" />
                       <input type="hidden" name="sesskey" value="' . sesskey() . '" />
                       <p>';
             lesson_print_submit_link(get_string('clicktopost', 'lesson'), 'highscores');
             echo '</p>
                       </div>
                       </form>';
         } else {
             echo get_string("nothighscore", "lesson", $lesson->maxhighscores) . "<br />";
         }
     }
     echo "<br /><div style=\"padding: 5px;\" class=\"lessonbutton standardbutton\"><a href=\"{$CFG->wwwroot}/mod/lesson/highscores.php?id={$cm->id}&amp;link=1\">" . get_string("viewhighscores", "lesson") . '</a></div>';
     echo "</div>";
 }
 if ($lesson->modattempts && !has_capability('mod/lesson:manage', $context)) {
     // make sure if the student is reviewing, that he/she sees the same pages/page path that he/she saw the first time
     // look at the attempt records to find the first QUESTION page that the user answered, then use that page id
     // to pass to view again.  This is slick cause it wont call the empty($pageid) code
     // $ntries is decremented above