MDL-49581 Lesson: Remove broken high score function

This commit is contained in:
Stephen Bourget
2015-07-20 20:06:44 -04:00
parent e1d4e288ac
commit bb685cf3fa
23 changed files with 108 additions and 414 deletions
@@ -75,11 +75,6 @@ class backup_lesson_activity_task extends backup_activity_task {
$replacement = '$@LESSONESSAY*$1@$';
$content = preg_replace($pattern, $replacement, $content);
// Provides the interface for viewing and adding high scores
$pattern = '#'.$base.'/highscores\.php\?id=([0-9]+)#';
$replacement = '$@LESSONHIGHSCORES*$1@$';
$content = preg_replace($pattern, $replacement, $content);
// Provides the interface for viewing the report
$pattern = '#'.$base.'/report\.php\?id=([0-9]+)#';
$replacement = '$@LESSONREPORT*$1@$';
@@ -20,11 +20,11 @@
*
* This is the "graphical" structure of the lesson module:
*
* lesson ---------->-------------|------------>---------|----------->----------|----------->----------|
* (CL,pk->id) | | | |
* | | | | |
* | lesson_grades lesson_high_scores lesson_timer lesson_overrides
* | (UL, pk->id,fk->lessonid) (UL, pk->id,fk->lessonid) (UL, pk->id,fk->lessonid) (UL, pk->id,fk->lessonid)
* lesson ---------->-------------|------------>---------|----------->----------|
* (CL,pk->id) | | |
* | | | |
* | lesson_grades lesson_timer lesson_overrides
* | (UL, pk->id,fk->lessonid) (UL, pk->id,fk->lessonid) (UL, pk->id,fk->lessonid)
* | |
* | |
* | |
@@ -67,7 +67,7 @@ class backup_lesson_activity_structure_step extends backup_activity_structure_st
// The lesson table
// This table contains all of the goodness for the lesson module, quite
// alot goes into it but nothing relational other than course when will
// need to be corrected upon restore
// need to be corrected upon restore.
$lesson = new backup_nested_element('lesson', array('id'), array(
'course', 'name', 'intro', 'introformat', 'practice', 'modattempts',
'usepassword', 'password',
@@ -76,12 +76,9 @@ class backup_lesson_activity_structure_step extends backup_activity_structure_st
'minquestions', 'maxpages', 'timelimit', 'retake', 'activitylink',
'mediafile', 'mediaheight', 'mediawidth', 'mediaclose', 'slideshow',
'width', 'height', 'bgcolor', 'displayleft', 'displayleftif', 'progressbar',
'showhighscores', 'maxhighscores', 'available', 'deadline', 'timemodified',
'available', 'deadline', 'timemodified',
'completionendreached', 'completiontimespent'
));
// Tell the lesson element about the showhighscores elements mapping to the highscores
// database field.
$lesson->set_source_alias('highscores', 'showhighscores');
// The lesson_pages table
// Grouped within a `pages` element, important to note that page is relational
@@ -130,14 +127,6 @@ class backup_lesson_activity_structure_step extends backup_activity_structure_st
'userid','grade','late','completed'
));
// The lesson_high_scores table
// Grouped by a highscores element this is relational to the lesson, user,
// and possibly a grade.
$highscores = new backup_nested_element('highscores');
$highscore = new backup_nested_element('highscore', array('id'), array(
'gradeid','userid','nickname'
));
// The lesson_timer table
// Grouped by a `timers` element this is relational to the lesson and user.
$timers = new backup_nested_element('timers');
@@ -162,8 +151,6 @@ class backup_lesson_activity_structure_step extends backup_activity_structure_st
$branches->add_child($branch);
$lesson->add_child($grades);
$grades->add_child($grade);
$lesson->add_child($highscores);
$highscores->add_child($highscore);
$lesson->add_child($timers);
$timers->add_child($timer);
$lesson->add_child($overrides);
@@ -184,11 +171,10 @@ class backup_lesson_activity_structure_step extends backup_activity_structure_st
// Check if we are also backing up user information
if ($this->get_setting_value('userinfo')) {
// Set the source table for elements that are reliant on the user
// lesson_attempts, lesson_branch, lesson_grades, lesson_high_scores, lesson_timer
// lesson_attempts, lesson_branch, lesson_grades, lesson_timer.
$attempt->set_source_table('lesson_attempts', array('answerid' => backup::VAR_PARENTID));
$branch->set_source_table('lesson_branch', array('pageid' => backup::VAR_PARENTID));
$grade->set_source_table('lesson_grades', array('lessonid'=>backup::VAR_PARENTID));
$highscore->set_source_table('lesson_high_scores', array('lessonid' => backup::VAR_PARENTID));
$timer->set_source_table('lesson_timer', array('lessonid' => backup::VAR_PARENTID));
} else {
$overrideparams['userid'] = backup_helper::is_sqlparam(null); // Without userinfo, skip user overrides.
@@ -200,7 +186,6 @@ class backup_lesson_activity_structure_step extends backup_activity_structure_st
$attempt->annotate_ids('user', 'userid');
$branch->annotate_ids('user', 'userid');
$grade->annotate_ids('user', 'userid');
$highscore->annotate_ids('user', 'userid');
$timer->annotate_ids('user', 'userid');
$override->annotate_ids('user', 'userid');
$override->annotate_ids('group', 'groupid');
@@ -70,7 +70,6 @@ class restore_lesson_activity_task extends restore_activity_task {
$rules[] = new restore_decode_rule('LESSONEDIT', '/mod/lesson/edit.php?id=$1', 'course_module');
$rules[] = new restore_decode_rule('LESSONESAY', '/mod/lesson/essay.php?id=$1', 'course_module');
$rules[] = new restore_decode_rule('LESSONHIGHSCORES', '/mod/lesson/highscores.php?id=$1', 'course_module');
$rules[] = new restore_decode_rule('LESSONREPORT', '/mod/lesson/report.php?id=$1', 'course_module');
$rules[] = new restore_decode_rule('LESSONMEDIAFILE', '/mod/lesson/mediafile.php?id=$1', 'course_module');
$rules[] = new restore_decode_rule('LESSONVIEWBYID', '/mod/lesson/view.php?id=$1', 'course_module');
@@ -99,8 +98,6 @@ class restore_lesson_activity_task extends restore_activity_task {
$rules[] = new restore_log_rule('lesson', 'view grade', 'essay.php?id={course_module}', '[name]');
$rules[] = new restore_log_rule('lesson', 'update grade', 'essay.php?id={course_module}', '[name]');
$rules[] = new restore_log_rule('lesson', 'update email essay grade', 'essay.php?id={course_module}', '[name]');
$rules[] = new restore_log_rule('lesson', 'update highscores', 'highscores.php?id={course_module}', '[name]');
$rules[] = new restore_log_rule('lesson', 'view highscores', 'highscores.php?id={course_module}', '[name]');
return $rules;
}
@@ -66,12 +66,14 @@ class restore_lesson_activity_structure_step extends restore_activity_structure_
$data->deadline = $this->apply_date_offset($data->deadline);
$data->timemodified = $this->apply_date_offset($data->timemodified);
// lesson->highscores can come both in data->highscores and
// data->showhighscores, handle both. MDL-26229
// The lesson->highscore code was removed in MDL-49581.
// Remove it if found in the backup file.
if (isset($data->showhighscores)) {
$data->highscores = $data->showhighscores;
unset($data->showhighscores);
}
if (isset($data->highscores)) {
unset($data->highscores);
}
// Supply items that maybe missing from previous versions.
if (!isset($data->completionendreached)) {
@@ -178,15 +180,8 @@ class restore_lesson_activity_structure_step extends restore_activity_structure_
}
protected function process_lesson_highscore($data) {
global $DB;
$data = (object)$data;
$oldid = $data->id;
$data->lessonid = $this->get_new_parentid('lesson');
$data->userid = $this->get_mappingid('user', $data->userid);
$data->gradeid = $this->get_mappingid('lesson_grade', $data->gradeid);
$newitemid = $DB->insert_record('lesson_high_scores', $data);
// Do not process any high score data.
// high scores were removed in Moodle 3.0 See MDL-49581.
}
protected function process_lesson_timer($data) {
@@ -18,6 +18,7 @@
* The mod_lesson highscore added event.
*
* @package mod_lesson
* @deprecated since Moodle 3.0
* @copyright 2013 Mark Nelson <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later.
*/
@@ -26,6 +27,8 @@ namespace mod_lesson\event;
defined('MOODLE_INTERNAL') || die();
debugging('mod_lesson\event\highscore_added has been deprecated. Since the functionality no longer resides in the lesson module.',
DEBUG_DEVELOPER);
/**
* The mod_lesson highscore added event class.
*
@@ -18,6 +18,7 @@
* The mod_lesson highscores viewed.
*
* @package mod_lesson
* @deprecated since Moodle 3.0
* @copyright 2013 Mark Nelson <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later.
*/
@@ -26,6 +27,8 @@ namespace mod_lesson\event;
defined('MOODLE_INTERNAL') || die();
debugging('mod_lesson\event\highscores_viewed has been deprecated. Since the functionality no longer resides in the lesson module.',
DEBUG_DEVELOPER);
/**
* The mod_lesson highscores viewed class.
*
+2 -20
View File
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
<XMLDB PATH="mod/lesson/db" VERSION="20150303" COMMENT="XMLDB file for Moodle mod/lesson"
<XMLDB PATH="mod/lesson/db" VERSION="20150720" COMMENT="XMLDB file for Moodle mod/lesson"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../../../lib/xmldb/xmldb.xsd"
>
@@ -42,8 +42,6 @@
<FIELD NAME="displayleft" TYPE="int" LENGTH="3" NOTNULL="true" DEFAULT="0" SEQUENCE="false"/>
<FIELD NAME="displayleftif" TYPE="int" LENGTH="3" NOTNULL="true" DEFAULT="0" SEQUENCE="false"/>
<FIELD NAME="progressbar" TYPE="int" LENGTH="3" NOTNULL="true" DEFAULT="0" SEQUENCE="false"/>
<FIELD NAME="highscores" TYPE="int" LENGTH="3" NOTNULL="true" DEFAULT="0" SEQUENCE="false"/>
<FIELD NAME="maxhighscores" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false"/>
<FIELD NAME="available" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false"/>
<FIELD NAME="deadline" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false"/>
<FIELD NAME="timemodified" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false"/>
@@ -176,22 +174,6 @@
<INDEX NAME="userid" UNIQUE="false" FIELDS="userid"/>
</INDEXES>
</TABLE>
<TABLE NAME="lesson_high_scores" COMMENT="high scores for each lesson">
<FIELDS>
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="true"/>
<FIELD NAME="lessonid" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false"/>
<FIELD NAME="userid" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false"/>
<FIELD NAME="gradeid" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false"/>
<FIELD NAME="nickname" TYPE="char" LENGTH="5" NOTNULL="true" SEQUENCE="false"/>
</FIELDS>
<KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
<KEY NAME="lessonid" TYPE="foreign" FIELDS="lessonid" REFTABLE="lesson" REFFIELDS="id"/>
</KEYS>
<INDEXES>
<INDEX NAME="userid" UNIQUE="false" FIELDS="userid"/>
</INDEXES>
</TABLE>
<TABLE NAME="lesson_overrides" COMMENT="The overrides to lesson settings.">
<FIELDS>
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="true"/>
@@ -214,4 +196,4 @@
</KEYS>
</TABLE>
</TABLES>
</XMLDB>
</XMLDB>
+50
View File
@@ -299,5 +299,55 @@ function xmldb_lesson_upgrade($oldversion) {
// Moodle v2.9.0 release upgrade line.
// Put any upgrade step following this.
if ($oldversion < 2015071800) {
// Define table lesson_high_scores to be dropped.
$table = new xmldb_table('lesson_high_scores');
// Conditionally launch drop table for lesson_high_scores.
if ($dbman->table_exists($table)) {
$dbman->drop_table($table);
}
// Lesson savepoint reached.
upgrade_mod_savepoint(true, 2015071800, 'lesson');
}
if ($oldversion < 2015071801) {
// Define field highscores to be dropped from lesson.
$table = new xmldb_table('lesson');
$field = new xmldb_field('highscores');
// Conditionally launch drop field highscores.
if ($dbman->field_exists($table, $field)) {
$dbman->drop_field($table, $field);
}
// Lesson savepoint reached.
upgrade_mod_savepoint(true, 2015071801, 'lesson');
}
if ($oldversion < 2015071802) {
// Define field maxhighscores to be dropped from lesson.
$table = new xmldb_table('lesson');
$field = new xmldb_field('maxhighscores');
// Conditionally launch drop field maxhighscores.
if ($dbman->field_exists($table, $field)) {
$dbman->drop_field($table, $field);
}
// Lesson savepoint reached.
upgrade_mod_savepoint(true, 2015071802, 'lesson');
}
if ($oldversion < 2015071803) {
unset_config('lesson_maxhighscores');
// Lesson savepoint reached.
upgrade_mod_savepoint(true, 2015071803, 'lesson');
}
return true;
}
-240
View File
@@ -1,240 +0,0 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Provides the interface for viewing and adding high scores
*
* @package mod_lesson
* @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
**/
/** include required files */
require_once('../../config.php');
require_once($CFG->dirroot.'/mod/lesson/locallib.php');
$id = required_param('id', PARAM_INT); // Course Module ID
$mode = optional_param('mode', '', PARAM_ALPHA);
$link = optional_param('link', 0, PARAM_INT);
$cm = get_coursemodule_from_id('lesson', $id, 0, false, MUST_EXIST);
$course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST);
$lesson = new lesson($DB->get_record('lesson', array('id' => $cm->instance), '*', MUST_EXIST));
require_login($course, false, $cm);
$url = new moodle_url('/mod/lesson/highscores.php', array('id'=>$id));
if ($mode !== '') {
$url->param('mode', $mode);
}
if ($link !== 0) {
$url->param('link', $link);
}
$PAGE->set_url($url);
$context = context_module::instance($cm->id);
switch ($mode) {
case 'add':
// Ensure that we came from view.php
if (!confirm_sesskey() or !data_submitted()) {
print_error('invalidformdata');
}
break;
case 'save':
if (confirm_sesskey() and $form = data_submitted($CFG->wwwroot.'/mod/lesson/view.php')) {
$name = trim(optional_param('name', '', PARAM_CLEAN));
// Make sure it is not empty
if (empty($name)) {
$lesson->add_message(get_string('missingname', 'lesson'));
$mode = 'add';
break;
}
// Check for censored words
$filterwords = explode(',', get_string('censorbadwords'));
foreach ($filterwords as $filterword) {
if (strstr($name, $filterword)) {
$lesson->add_message(get_string('namereject', 'lesson'));
$mode = 'add';
break;
}
}
// Bad word was found
if ($mode == 'add') {
break;
}
$params = array ("lessonid" => $lesson->id, "userid" => $USER->id);
if (!$grades = $DB->get_records_select('lesson_grades', "lessonid = :lessonid", $params, 'completed')) {
print_error('cannotfindfirstgrade', 'lesson');
}
if (!$newgrade = $DB->get_record_sql("SELECT *
FROM {lesson_grades}
WHERE lessonid = :lessonid
AND userid = :userid
ORDER BY completed DESC", $params, true)) {
print_error('cannotfindnewestgrade', 'lesson');
}
// Check for multiple submissions
if ($DB->record_exists('lesson_high_scores', array('gradeid' => $newgrade->id))) {
print_error('onpostperpage', 'lesson');
}
// Find out if we need to delete any records
if ($highscores = $DB->get_records_sql("SELECT h.*, g.grade
FROM {lesson_grades} g, {lesson_high_scores} h
WHERE h.gradeid = g.id
AND h.lessonid = :lessonid
ORDER BY g.grade DESC", $params)) {
// Only count unique scores in our total for max high scores
$uniquescores = array();
foreach ($highscores as $highscore) {
$uniquescores[$highscore->grade] = 1;
}
if (count($uniquescores) >= $lesson->maxhighscores) {
// Top scores list is full, might need to delete a score
$flag = true;
// See if the new score is already listed in the top scores list
// if it is listed, then dont need to delete any records
foreach ($highscores as $highscore) {
if ($newgrade->grade == $highscore->grade) {
$flag = false;
}
}
if ($flag) {
// Pushing out the lowest score (could be multiple records)
$lowscore = 0;
foreach ($highscores as $highscore) {
if (empty($lowscore) or $lowscore > $highscore->grade) {
$lowscore = $highscore->grade;
}
}
// Now, delete all high scores with the low score
foreach ($highscores as $highscore) {
if ($highscore->grade == $lowscore) {
$DB->delete_records('lesson_high_scores', array('id' => $highscore->id));
}
}
}
}
}
$newhighscore = new stdClass;
$newhighscore->lessonid = $lesson->id;
$newhighscore->userid = $USER->id;
$newhighscore->gradeid = $newgrade->id;
$newhighscore->nickname = $name;
$newhighscore->id = $DB->insert_record('lesson_high_scores', $newhighscore);
// Trigger highscore updated event.
$event = \mod_lesson\event\highscore_added::create(array(
'objectid' => $newhighscore->id,
'context' => $context,
'courseid' => $course->id,
'other' => array(
'lessonid' => $lesson->id,
'nickname' => $newhighscore->nickname
)
));
$event->trigger();
$lesson->add_message(get_string('postsuccess', 'lesson'), 'notifysuccess');
redirect("$CFG->wwwroot/mod/lesson/highscores.php?id=$cm->id&amp;link=1");
} else {
print_error('invalidformdata');
}
break;
}
// Trigger highscore viewed event.
$event = \mod_lesson\event\highscores_viewed::create(array(
'objectid' => $lesson->properties()->id,
'context' => $context,
'courseid' => $course->id
));
$event->trigger();
$lessonoutput = $PAGE->get_renderer('mod_lesson');
echo $lessonoutput->header($lesson, $cm, 'highscores', false, null, get_string('viewhighscores', 'lesson'));
switch ($mode) {
case 'add':
echo $lessonoutput->add_highscores_form($lesson);
break;
default:
$params = array ("lessonid" => $lesson->id);
if (!$grades = $DB->get_records_select("lesson_grades", "lessonid = :lessonid", $params, "completed")) {
$grades = array();
}
echo $OUTPUT->heading(get_string("topscorestitle", "lesson", $lesson->maxhighscores), 4);
if (!$highscores = $DB->get_records_select("lesson_high_scores", "lessonid = :lessonid", $params)) {
echo $OUTPUT->heading(get_string("nohighscores", "lesson"), 3);
} else {
foreach ($highscores as $highscore) {
$grade = $grades[$highscore->gradeid]->grade;
$topscores[$grade][] = $highscore->nickname;
}
krsort($topscores);
$table = new html_table();
$table->align = array('center', 'left', 'right');
$table->wrap = array();
$table->width = "30%";
$table->cellspacing = '10px';
$table->size = array('*', '*', '*');
$table->head = array(get_string("rank", "lesson"), get_string('name'), get_string("scores", "lesson"));
$printed = 0;
while (true) {
$temp = current($topscores);
$score = key($topscores);
$rank = $printed + 1;
sort($temp);
foreach ($temp as $student) {
$table->data[] = array($rank, $student, $score.'%');
}
$printed++;
if (!next($topscores) || !($printed < $lesson->maxhighscores)) {
break;
}
}
echo html_writer::table($table);
}
if (!has_capability('mod/lesson:manage', $context)) { // teachers don't need the links
echo $OUTPUT->box_start('mdl-align');
echo $OUTPUT->box_start('lessonbutton standardbutton');
if ($link) {
echo html_writer::link(new moodle_url('/course/view.php', array('id'=>$course->id)), get_string("returntocourse", "lesson"));
} else {
echo html_writer::link(new moodle_url('/course/view.php', array('id'=>$course->id)), get_string("cancel", "lesson")). ' ';
echo html_writer::link(new moodle_url('/mod/lesson/view.php', array('id'=>$cm->id, 'viewed'=>'1')), get_string("startlesson", "lesson"));
}
echo $OUTPUT->box_end();
echo $OUTPUT->box_end();
}
break;
}
echo $lessonoutput->footer();
+12
View File
@@ -1,2 +1,14 @@
essayemailmessage,mod_lesson
lessonattempted,mod_lesson
clicktopost,mod_lesson
configmaxhighscores,mod_lesson
displayhighscores,mod_lesson
entername,mod_lesson
eventhighscoreadded,mod_lesson
eventhighscoresviewed,mod_lesson
highscores,mod_lesson
maxhighscores,mod_lesson
nothighscore,mod_lesson
topscorestitle,mod_lesson
viewhighscores,mod_lesson
youmadehighscore,mod_lesson
+15 -12
View File
@@ -89,7 +89,6 @@ $string['casesensitive'] = 'Use regular expressions';
$string['casesensitive_help'] = 'Tick the checkbox to use regular expressions for analysing responses.';
$string['classstats'] = 'Class statistics';
$string['clicktodownload'] = 'Click on the following link to download the file.';
$string['clicktopost'] = 'Click here to post your grade on the High Scores list.';
$string['closebeforeopen'] = 'Could not update the lesson. You have specified a close date before the open date.';
$string['cluster'] = 'Cluster';
$string['clusterjump'] = 'Unseen question within a cluster';
@@ -106,7 +105,6 @@ $string['completiontimespentgroup'] = 'Require time spent';
$string['conditionsfordependency'] = 'Condition(s) for the dependency';
$string['configactionaftercorrectanswer'] = 'The default action to take after a correct answer';
$string['configmaxanswers'] = 'Default maximum number of answers per page';
$string['configmaxhighscores'] = 'Number of high scores displayed';
$string['configmediaclose'] = 'Displays a close button as part of the popup generated for a linked media file';
$string['configmediaheight'] = 'Sets the height of the popup displayed for a linked media file';
$string['configmediawidth'] = 'Sets the width of the popup displayed for a linked media file';
@@ -143,7 +141,6 @@ $string['didnotreceivecredit'] = 'Did not receive credit';
$string['disabled'] = 'Disabled';
$string['displaydefaultfeedback'] = 'Use default feedback';
$string['displaydefaultfeedback_help'] = 'If enabled, when a response is not found for a particular question, the default response of "That\'s the correct answer" or "That\'s the wrong answer" will be shown.';
$string['displayhighscores'] = 'Display high scores';
$string['displayinleftmenu'] = 'Display in menu?';
$string['displayleftif'] = 'Minimum grade to display menu';
$string['displayleftif_help'] = 'This setting determines whether a student must obtain a certain grade before viewing the lesson menu. This forces the student to go through the entire lesson on their first attempt, then after obtaining the required grade they can use the menu for review.';
@@ -172,7 +169,6 @@ $string['endofcluster'] = 'End of cluster';
$string['endofclustertitle'] = 'End of cluster';
$string['endoflesson'] = 'End of lesson';
$string['enteredthis'] = 'entered this.';
$string['entername'] = 'Enter a nickname for the high scores list';
$string['enterpassword'] = 'Please enter the password:';
$string['emptypassword'] = 'Password cannot be empty';
$string['eolstudentoutoftime'] = 'Attention: You ran out of time for this lesson. Your last answer may not have counted if it was answered after the time was up.';
@@ -186,8 +182,6 @@ $string['essayscore'] = 'Essay score';
$string['eventcontentpageviewed'] = 'Content page viewed';
$string['eventessayassessed'] = 'Essay assessed';
$string['eventessayattemptviewed'] = 'Essay attempt viewed';
$string['eventhighscoreadded'] = 'Highscore added';
$string['eventhighscoresviewed'] = 'Highscores viewed';
$string['eventlessonended'] = 'Lesson ended';
$string['eventlessonrestarted'] = 'Lesson restarted';
$string['eventlessonresumed'] = 'Lesson resumed';
@@ -226,7 +220,6 @@ $string['handlingofretakes_help'] = 'If re-takes are allowed, this setting speci
$string['havenotgradedyet'] = 'Have not graded yet.';
$string['here'] = 'here';
$string['highscore'] = 'High score';
$string['highscores'] = 'High scores';
$string['hightime'] = 'High time';
$string['checkbranchtable'] = 'Check content page';
$string['checkedthisone'] = 'Checked this one.';
@@ -277,7 +270,6 @@ $string['matching'] = 'Matching';
$string['matchingpair'] = 'Matching pair {$a}';
$string['maxgrade'] = 'Maximum grade';
$string['maxgrade_help'] = 'This setting specifies the maximum grade for the lesson. If set to 0, the lesson does not appear in the grades pages.';
$string['maxhighscores'] = 'Number of high scores displayed';
$string['maximumnumberofanswersbranches'] = 'Maximum number of answers';
$string['maximumnumberofanswersbranches_help'] = 'This setting specifies the maximum number of answers that may be used in the lesson. If only true/false questions are used, it can be set to 2. The setting may be changed at any time, since it only affects what the teacher sees, not the data.';
$string['maximumnumberofattempts'] = 'Maximum number of attempts';
@@ -351,7 +343,6 @@ $string['notyetcompleted'] = 'Lesson has been started, but not yet completed';
$string['notdefined'] = 'Not defined';
$string['notenoughsubquestions'] = 'Not enough sub-questions have been defined!';
$string['notenoughtimespent'] = 'You completed this lesson in {$a->timespent}, which is less than the required time of {$a->timerequired}. You might need to attempt the lesson again.';
$string['nothighscore'] = 'You did not make the top {$a} high scores list.';
$string['notitle'] = 'No title';
$string['numberofcorrectanswers'] = 'Number of correct answers: {$a}';
$string['numberofcorrectanswersheader'] = 'Number of correct answers';
@@ -484,7 +475,6 @@ $string['timeremaining'] = 'Time remaining';
$string['timespenterror'] = 'Spend at least {$a} minutes in the lesson';
$string['timespentminutes'] = 'Time spent (minutes)';
$string['timetaken'] = 'Time taken';
$string['topscorestitle'] = 'Top {$a} high scores';
$string['true'] = 'True';
$string['truefalse'] = 'True/false';
$string['unabledtosavefile'] = 'The file you uploaded could not be saved';
@@ -502,7 +492,6 @@ $string['useroverrides'] = 'User overrides';
$string['useroverridesdeleted'] = 'User overrides deleted';
$string['usersnone'] = 'No students have access to this lesson';
$string['viewgrades'] = 'View grades';
$string['viewhighscores'] = 'View high scores list';
$string['viewreports'] = 'View {$a->attempts} completed {$a->student} attempts';
$string['viewreports2'] = 'View {$a} completed attempts';
$string['warning'] = 'Warning';
@@ -513,7 +502,6 @@ $string['wronganswerscore'] = 'Wrong answer score';
$string['wrongresponse'] = 'Wrong response';
$string['xattempts'] = '{$a} attempts';
$string['youhaveseen'] = 'You have seen more than one page of this lesson already.<br />Do you want to start at the last page you saw?';
$string['youmadehighscore'] = 'You made it on the top {$a} high scores list.';
$string['youranswer'] = 'Your answer';
$string['yourcurrentgradeis'] = 'Your current grade is {$a}';
$string['yourcurrentgradeisoutof'] = 'Your current grade is {$a->grade} out of {$a->total}';
@@ -523,3 +511,18 @@ $string['youshouldview'] = 'You should answer at least: {$a}';
$string['essayemailmessage'] = '<p>Essay prompt:<blockquote>{$a->question}</blockquote></p><p>Your response:<blockquote><em>{$a->response}</em></blockquote></p><p>{$a->teacher}\'s comments:<blockquote><em>{$a->comment}</em></blockquote></p><p>You have received {$a->earned} out of {$a->outof} for this essay question.</p><p>Your grade for the lesson has been changed to {$a->newgrade}&#37;.</p>';
$string['lessonattempted'] = 'Lesson attempted';
// Deprecated since Moodle 3.0.
$string['clicktopost'] = 'Click here to post your grade on the High Scores list.';
$string['configmaxhighscores'] = 'Number of high scores displayed';
$string['displayhighscores'] = 'Display high scores';
$string['entername'] = 'Enter a nickname for the high scores list';
$string['eventhighscoreadded'] = 'Highscore added';
$string['eventhighscoresviewed'] = 'Highscores viewed';
$string['highscores'] = 'High scores';
$string['maxhighscores'] = 'Number of high scores displayed';
$string['nothighscore'] = 'You did not make the top {$a} high scores list.';
$string['topscorestitle'] = 'Top {$a} high scores';
$string['viewhighscores'] = 'View high scores list';
$string['youmadehighscore'] = 'You made it on the top {$a} high scores list.';
-5
View File
@@ -930,7 +930,6 @@ function lesson_reset_userdata($data) {
}
$DB->delete_records_select('lesson_timer', "lessonid IN ($lessonssql)", $params);
$DB->delete_records_select('lesson_high_scores', "lessonid IN ($lessonssql)", $params);
$DB->delete_records_select('lesson_grades', "lessonid IN ($lessonssql)", $params);
$DB->delete_records_select('lesson_attempts', "lessonid IN ($lessonssql)", $params);
$DB->delete_records_select('lesson_branch', "lessonid IN ($lessonssql)", $params);
@@ -1127,10 +1126,6 @@ function lesson_extend_settings_navigation($settings, $lessonnode) {
$lessonnode->add(get_string('manualgrading', 'lesson'), $url);
}
if ($PAGE->activityrecord->highscores) {
$url = new moodle_url('/mod/lesson/highscores.php', array('id'=>$PAGE->cm->id));
$lessonnode->add(get_string('highscores', 'lesson'), $url);
}
}
/**
-3
View File
@@ -967,8 +967,6 @@ abstract class lesson_add_page_form_base extends moodleform {
* @property int $displayleft Display a left menu
* @property int $displayleftif Sets the condition on which the left menu is displayed
* @property int $progressbar Flag to toggle display of a lesson progress bar
* @property int $highscores Flag to toggle collection of high scores
* @property int $maxhighscores Number of high scores to limit to
* @property int $available Timestamp of when this lesson becomes available
* @property int $deadline Timestamp of when this lesson is no longer available
* @property int $timemodified Timestamp when lesson was last modified
@@ -1056,7 +1054,6 @@ class lesson extends lesson_base {
$DB->delete_records("lesson_grades", array("lessonid"=>$this->properties->id));
$DB->delete_records("lesson_timer", array("lessonid"=>$this->properties->id));
$DB->delete_records("lesson_branch", array("lessonid"=>$this->properties->id));
$DB->delete_records("lesson_high_scores", array("lessonid"=>$this->properties->id));
if ($events = $DB->get_records('event', array("modulename"=>'lesson', "instance"=>$this->properties->id))) {
foreach($events as $event) {
$event = calendar_event::load($event);
-9
View File
@@ -74,7 +74,6 @@ echo $lessonoutput->header($lesson, $cm);
/// Check lesson availability
/// Check for password
/// Check dependencies
/// Check for high scores
if (!$canmanage) {
if (!$lesson->is_accessible()) { // Deadline restrictions
echo $lessonoutput->header($lesson, $cm);
@@ -91,20 +90,12 @@ if (!$canmanage) {
// with or without md5 for backward compatibility (MDL-11090)
$USER->lessonloggedin[$lesson->id] = true;
$correctpass = true;
if ($lesson->highscores) {
// Logged in - redirect so we go through all of these checks before starting the lesson.
redirect("$CFG->wwwroot/mod/lesson/view.php?id=$cm->id");
}
} else if (isset($lesson->extrapasswords)) {
// Group overrides may have additional passwords.
foreach ($lesson->extrapasswords as $password) {
if (strcmp($password, md5(trim($userpassword))) === 0 || strcmp($password, trim($userpassword)) === 0) {
$correctpass = true;
$USER->lessonloggedin[$lesson->id] = true;
if ($lesson->highscores) {
// Logged in - redirect so we go through all of these checks before starting the lesson.
redirect("$CFG->wwwroot/mod/lesson/view.php?id=$cm->id");
}
}
}
}
-5
View File
@@ -77,11 +77,6 @@ class mod_lesson_mod_form extends moodleform_mod {
$mform->setType('mediaclose', PARAM_BOOL);
$mform->setDefault('mediaclose', $CFG->lesson_mediaclose);
/** Legacy maximum highscores element to maintain backwards compatibility */
$mform->addElement('hidden', 'maxhighscores');
$mform->setType('maxhighscores', PARAM_INT);
$mform->setDefault('maxhighscores', $CFG->lesson_maxhighscores);
$mform->addElement('text', 'name', get_string('name'), array('size'=>'64'));
if (!empty($CFG->formatstringstriptags)) {
$mform->setType('name', PARAM_TEXT);
-20
View File
@@ -601,24 +601,4 @@ class mod_lesson_renderer extends plugin_renderer_base {
$output = html_writer::tag('p', $contents, $attributes);
return $output;
}
/**
* Returns HTML to display add_highscores_form
* @param lesson $lesson
* @return string
*/
public function add_highscores_form(lesson $lesson) {
global $CFG;
$output = $this->output->box_start('generalbox boxaligncenter');
$output .= $this->output->box_start('mdl-align');
$output .= '<form id="nickname" method ="post" action="'.$CFG->wwwroot.'/mod/lesson/highscores.php" autocomplete="off">
<input type="hidden" name="id" value="'.$this->page->cm->id.'" />
<input type="hidden" name="mode" value="save" />
<input type="hidden" name="sesskey" value="'.sesskey().'" />';
$output .= get_string("entername", "lesson").": <input type=\"text\" name=\"name\" size=\"7\" maxlength=\"5\" />";
$output .= $this->output->box("<input type='submit' value='".get_string('submitname', 'lesson')."' />", 'lessonbutton center');
$output .= "</form>";
$output .= $this->output->box_end();
$output .= $this->output->box_end();
return $output;
}
}
+1 -2
View File
@@ -82,7 +82,7 @@ if ($action === 'delete') {
$DB->delete_records('lesson_timer', array('id' => $timer->id));
}
/// Remove the grade from the grades and high_scores tables - this is silly, it should be linked to specific attempt (skodak)
// Remove the grade from the grades tables - this is silly, it should be linked to specific attempt (skodak).
$grades = $DB->get_records_sql("SELECT id FROM {lesson_grades}
WHERE userid = :userid AND lessonid = :lessonid
ORDER BY completed", $params, $try, 1);
@@ -90,7 +90,6 @@ if ($action === 'delete') {
if ($grades) {
$grade = reset($grades);
$DB->delete_records('lesson_grades', array('id' => $grade->id));
$DB->delete_records('lesson_high_scores', array('gradeid' => $grade->id, 'lessonid' => $lesson->id, 'userid' => $userid));
}
/// Remove attempts and update the retry number
-4
View File
@@ -48,10 +48,6 @@ if ($ADMIN->fulltree) {
$settings->add(new admin_setting_configcheckbox('lesson_mediaclose', get_string('mediaclose', 'lesson'),
get_string('configmediaclose', 'lesson'), false, PARAM_TEXT));
/** Misc lesson settings */
$settings->add(new admin_setting_configtext('lesson_maxhighscores', get_string('maxhighscores', 'lesson'),
get_string('configmaxhighscores','lesson'), 10, PARAM_INT));
/** Default lesson settings */
$numbers = array();
for ($i=20; $i>1; $i--) {
-3
View File
@@ -57,9 +57,6 @@ if (has_capability('mod/lesson:viewreports', $context)) {
if (has_capability('mod/lesson:grade', $context)) {
$row[] = new tabobject('essay', "$CFG->wwwroot/mod/lesson/essay.php?id=$cm->id", get_string('manualgrading', 'lesson'));
}
if ($lesson->highscores) {
$row[] = new tabobject('highscores', "$CFG->wwwroot/mod/lesson/highscores.php?id=$cm->id", get_string('highscores', 'lesson'));
}
$tabs[] = $row;
+2
View File
@@ -241,6 +241,7 @@ class mod_lesson_events_testcase extends advanced_testcase {
'noob', $this->lesson->properties()->cmid);
$this->assertEventLegacyLogData($expected, $event);
$this->assertEventContextNotUsed($event);
$this->assertDebuggingCalled();
}
/**
@@ -270,6 +271,7 @@ class mod_lesson_events_testcase extends advanced_testcase {
$this->lesson->properties()->name, $this->lesson->properties()->cmid);
$this->assertEventLegacyLogData($expected, $event);
$this->assertEventContextNotUsed($event);
$this->assertDebuggingCalled();
}
/**
+3
View File
@@ -1,5 +1,8 @@
This files describes API changes in the lesson code.
=== 3.0 ===
* Removed broken high score code. Use the activity results block instead.
=== 2.9 ===
* The grade_item_delete function in mod/lesson/lib.php was removed because it was not doing anything and was never called.
* A third optional boolean parameter $endreached was added to lesson::update_timer to indicate that end of lesson was reached. This is used by 'completionendreached' custom completion rule.
+1 -1
View File
@@ -24,7 +24,7 @@
defined('MOODLE_INTERNAL') || die();
$plugin->version = 2015051100; // The current module version (Date: YYYYMMDDXX)
$plugin->version = 2015072000; // The current module version (Date: YYYYMMDDXX)
$plugin->requires = 2015050500; // Requires this Moodle version
$plugin->component = 'mod_lesson'; // Full name of the plugin (used for diagnostics)
$plugin->cron = 0;
+1 -47
View File
@@ -73,7 +73,6 @@ if ($userhasgrade && !$lesson->retake) {
/// Check lesson availability
/// Check for password
/// Check dependencies
/// Check for high scores
if (!$canmanage) {
if (!$lesson->is_accessible()) { // Deadline restrictions
echo $lessonoutput->header($lesson, $cm, '', false, null, get_string('notavailable'));
@@ -90,20 +89,13 @@ if (!$canmanage) {
// with or without md5 for backward compatibility (MDL-11090)
$correctpass = true;
$USER->lessonloggedin[$lesson->id] = true;
if ($lesson->highscores) {
// Logged in - redirect so we go through all of these checks before starting the lesson.
redirect("$CFG->wwwroot/mod/lesson/view.php?id=$cm->id");
}
} else if (isset($lesson->extrapasswords)) {
// Group overrides may have additional passwords.
foreach ($lesson->extrapasswords as $password) {
if (strcmp($password, md5(trim($userpassword))) === 0 || strcmp($password, trim($userpassword)) === 0) {
$correctpass = true;
$USER->lessonloggedin[$lesson->id] = true;
if ($lesson->highscores) {
// Logged in - redirect so we go through all of these checks before starting the lesson.
redirect("$CFG->wwwroot/mod/lesson/view.php?id=$cm->id");
}
}
}
}
@@ -167,9 +159,6 @@ if (!$canmanage) {
exit();
}
}
} else if ($lesson->highscores && !$lesson->practice && !optional_param('viewed', 0, PARAM_INT) && empty($pageid)) {
// Display high scores before starting lesson
redirect(new moodle_url('/mod/lesson/highscores.php', array("id"=>$cm->id)));
}
}
@@ -572,41 +561,6 @@ if ($pageid != LESSON_EOL) {
}
$lessoncontent .= $OUTPUT->box_end(); //End of Lesson button to Continue.
// high scores code
if ($lesson->highscores && !$canmanage && !$lesson->practice) {
$lessoncontent .= $OUTPUT->box_start('center');
if ($grades = $DB->get_records("lesson_grades", array("lessonid" => $lesson->id), "completed")) {
$madeit = false;
if ($highscores = $DB->get_records("lesson_high_scores", array("lessonid" => $lesson->id))) {
// get all the high scores into an array
$topscores = array();
$uniquescores = array();
foreach ($highscores as $highscore) {
$grade = $grades[$highscore->gradeid]->grade;
$topscores[] = $grade;
$uniquescores[$grade] = 1;
}
// 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) {
$lessoncontent .= $lessonoutput->paragraph(get_string("youmadehighscore", "lesson", $lesson->maxhighscores), 'center');
$aurl = new moodle_url('/mod/lesson/highscores.php', array('id'=>$PAGE->cm->id, 'sesskey'=>sesskey()));
$lessoncontent .= $OUTPUT->single_button($aurl, get_string('clicktopost', 'lesson'));
} else {
$lessoncontent .= get_string("nothighscore", "lesson", $lesson->maxhighscores)."<br />";
}
}
$url = new moodle_url('/mod/lesson/highscores.php', array('id'=>$PAGE->cm->id, 'link'=>'1'));
$lessoncontent .= html_writer::link($url, get_string('viewhighscores', 'lesson'), array('class'=>'centerpadded lessonbutton standardbutton'));
$lessoncontent .= $OUTPUT->box_end();
}
if ($lesson->modattempts && !$canmanage) {
// 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