Commit 4096b1ef authored by Plugins bot's avatar Plugins bot
Browse files

PLUGIN-25854 mod_mootyper: cibot precheck request

parent a59bec2a
# Moodle Mootyper module
- Moodle tracker component: https://github.com/drachels/moodle-mod_mootyper/issues
- Documentation: https://github.com/drachels/moodle-mod_mootyper/wiki
- Source Code: https://github.com/drachels/moodle-mod_mootyper
- License: http://www.gnu.org/licenses/gpl.txt
## Install from git
- Navigate to Moodle root folder
- **git clone git://github.com/drachels/moodle-mod_mootyper.git mod/mootyper**
- **cd mootyper**
- **git checkout MOODLE_XY_STABLE** (where XY is the moodle version, e.g: MOODLE_30_STABLE, MOODLE_28_STABLE...)
- Click the 'Notifications' link on the frontpage administration block or **php admin/cli/upgrade.php** if you have access to a command line interpreter.
## Install from a compressed file
- Extract the compressed file data
- Rename the main folder to mootyper
- Copy to the Moodle mod/ folder
- Click the 'Notifications' link on the frontpage administration block or **php admin/cli/upgrade.php** if you have access to a command line interpreter.
This is the README file for the MooTyper project. MooTyper is
a moodle extension, that adds the 'typing instructor' functionallity to Moodle.
The plugin url is: https://moodle.org/plugins/view.php?plugin=mod_mootyper
MooTyper is free software, the same as Moodle.
1. REQUIREMENTS
The MooTyper module uses javascript which is not welcome in Moodle but it is a
requirement for the use of the module. The typing procedure cannot be done without
the client side logic.
It creates some new tables in a moodle database and inserts some sample
typing exercises. This is all done automaticaly through the intstallation,
but real lessons and exercises should be added by teachers afterwards.
2. INSTALLATION
MooTyper is an activity module. You have to extract it to the 'mod' directory.
If the directory name is something like "moodle_mod_mootyper" you have to change
that to just "mootyper". So for example, the path should be like this:
<your moodle installation>/mod/mootyper/view.php
Than go to Site Administration -> Notifications and click on the button to start
the install.
Right after an install or upgrade of the new MooTyper 3.6.1, you will then see
the settings page. You can now set the date display format for the grade views.
You can also set colors for grade views, the background of the new keyboard
layouts, and the color for keytops that are not home row keys. This allows you
to color coordinate MooTyper with your theme color scheme.
3. USING MOOTYPER
Using MooTyper activity module is very simple. An instance can be added as a
new activity in a course like Lesson or Quiz. The simplest way to setup a
MooTyper, is select MooTyper from the list, Add an activity or resource.
Add the name you want to use for this activity. I recommend adding the
lesson name as part of the activity name. Add a description if you desire.
Then, add Availability times, if desired, then click, Save and display.
Yes, that's right! Don't bother with any other options as they will then be
available on the, Setup link.
Thanks to Mary Cooch from moodle.org we have this video, which shows how
to add exercises, create mootyper instance, and then view grades.
It's a little outdated (one of the first versions of mootyper), but I
guess everything still holds:
http://www.youtube.com/watch?v=Twl-7CGrS0g
4. ADDITIONAL KEYBOARD LAYOUTS
This MooTyper currently includes keyboard layouts to support many languages.
If you do not see one that need, please let the maintainer know.
Note: There are two special layouts, English(USV6) that includes both the normal
keys and the number keypad, and numberKeypadOnly(V1), which shows ONLY the
number keypad.
To implement any other layout you have to:
Create a php file with keyboard layout defined with HTML. Create a javascript
file (with the same name and .js extension) that implements the logic of the keyboard
layout. If you have any mistakes in your js file the module won't work, so in
this case try to validate your code with a tool like this...
http://www.javascriptlint.com/online_lint.php
5. SAVING YOUR OWN OR MODIFIED LESSONS
In previous versions of MooTyper, if you created your own lessons there was
no built in way to export a copy for backup purposes or for safekeeping.
Once installed, there was no way to add additional lessons to MooTyper
unless you used the built in editing capability, which is not as convenient
as it would be to create lessons in a word processing program. If you wanted
to add lessons to MooTyper without using the built in editor, you had to do
a completely new installation of MooTyper which meant you would lose all
student progress and grades.
As of version 3.1.0, MooTyper now supports Import and Export of MooTyper Lessons
via links in the Administration block, which overcomes these limitations.
6. NEW IN THIS RELEASE
There is now a new key top text color setting. This will allow you to now
have a layout with dark colored keys, with white text, or some other light
colored text.
There is now a new time limit setting that can be used for any Mode.
There is now a new required WPM rate setting that can be used for any Mode.
Information labels on the pages for view.php, gview.php, and owngrades.php
now include the new time limit, Required precision, and the new Required WPM.
You can now set a typing time limit from 0:00 (not used) to 10:00 minutes.
However, you will need to make sure each exercise is long enough, character
count wise, so that your fastest typer will NOT run out of something to type.
You can now set a required Word Per Minute rate. Failure to achieve the
posted rate, is treated just the same as failing to achieve the required
precision.
You can mix and match the time limit, precision, and wpm.
A zero timelimit lets the student type all the way to the end of the exercise,
just as it always has. If a time limit is set, the exercise is halted when
time expires.
A zero required precision means the grade will NOT be shown with a red
background no matter the precision achieved for the exercise. Any other
required precision is treated as before.
A zero required WPM rate means the grade will NOT be shown with a red
background no matter the WPM rate achieved for the exercise. Any other
required precision like the required precision rate. Red grade background
for not exceeding the required WPM. Green if it is exceeded.
If using both a required precision and required WPM, they must both be
exceeded to get a green "passed" background. If one is exceeded and one
is not, the grade background will be red.
7. OTHER IMPORTANT CAPABILITIES
There are four settings that affect the typing modes.
1.The original mode - This mode requires you to type the correct letter before
you can move to the next letter. Extra spaces are ignored. Mistyped letters
are counted as mistakes.
2. Count mistyped spaces - Same as the original mode, but counts mistyped spaces
as well as mistyped letters.
3. Continuous typing - In this mode you do not have to type the correct letter
before moving to the next letter. All mistyped letters and space are counted
as mistakes.
4. Count all keystrokes - If you mistype the same key multiple times, you have the
option of counting it as one mistake, or counting all of them.
If a user clicks, View my grades, depending on the Moodle version, they will now
see a horizontal bar chart beneath their grade table that charts Hits per minute,
Precision, and WPM results. If a non-editing teacher, teacher, manager, or admin,
clicks on, 'View all grades, depending on the Moodle version, they will see the
normal grade table as well as horizontal bar charts showing Hits per minute,
Precision, and WPM for each exercise for each student.
For more info please visit the plugins wiki on github:
https://github.com/drachels/moodle-mod_mootyper/wiki
\ No newline at end of file
<?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/>.
/**
* This file tracks student progress through an exercise.
*
* Called from three places in typer.js file.
* doStart - opens an entry in mdl_mootyper_attempts.
* doCheck - opens multiple entries in mdl_mootyper_checks and creates a
* new entry every 4 seconds listing mistakes, hits, and checktime.
* doTheEnd - mdl_mootyper_checks - updates the entry in mdl_mootyper_attempts
* and all entries for the checks are deleted when exercise is completed.
* Delete grade - If you delete an entry from View my grades (owngrades.php),
* it removes deletes the attempt from mdl_mootyper_attempts,
* but does not remove any of the mdl_mootyper_checks entries.
*
* @package mod_mootyper
* @copyright 2012 Jaka Luthar (jaka.luthar@gmail.com)
* @copyright 2016 onwards AL Rachels (drachels@drachels.com)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
use \mod_mootyper\local\results;
require(__DIR__ . '/../../config.php');
global $DB;
// For security, added the following 20190202 and things seem to be working correctly.
require_login();
$record = new stdClass();
// Status 1 indicates called from doStart in typer.js.
// Status 2 indicates called from doCheck in typer.js.
// Status 3 indicates called from doTheEnd in typer.js.
$st = optional_param('status', '', PARAM_INT);
if ($st == 1) {
$record->mootyperid = optional_param('mootyperid', 0, PARAM_INT);
$record->userid = optional_param('userid', 0, PARAM_INT);
$record->timetaken = optional_param('time', 0, PARAM_INT);
$record->inprogress = 1;
$record->suspicion = 0;
$newid = $DB->insert_record('mootyper_attempts', $record, true);
echo $newid;
} else if ($st == 2) {
$record->attemptid = optional_param('attemptid', '', PARAM_INT);
$record->mistakes = optional_param('mistakes', 0, PARAM_INT);
$record->hits = optional_param('hits', 0, PARAM_INT);
$record->checktime = time();
$DB->insert_record('mootyper_checks', $record, false);
} else if ($st == 3) {
$attid = optional_param('attemptid', 0, PARAM_INT);
$attemptold = $DB->get_record('mootyper_attempts', array('id' => $attid), '*', MUST_EXIST);
$attemptnew = new stdClass();
$attemptnew->id = $attemptold->id;
$attemptnew->mootyperid = $attemptold->mootyperid;
$attemptnew->userid = $attemptold->userid;
$attemptnew->timetaken = $attemptold->timetaken;
$attemptnew->inprogress = 0;
$dbchcks = $DB->get_records('mootyper_checks', array('attemptid' => $attemptold->id));
$checks = array();
foreach ($dbchcks as $c) {
$checks[] = array('id' => $c->id, 'mistakes' => $c->mistakes, 'hits' => $c->hits, 'checktime' => $c->checktime);
}
// Check for suspicious results for the current exercise.
if (results::suspicion($checks, $attemptold->timetaken)) {
$attemptnew->suspicion = 1;
} else {
$attemptnew->suspicion = $attemptold->suspicion;
}
// Exercise completed so update the attemp record.
$DB->update_record('mootyper_attempts', $attemptnew);
// Exercise completed so remove all the checks for this attempt.
$DB->delete_records('mootyper_checks', array('attemptid' => $attid));
}
<?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/>.
/**
* This file is used to remove the results of a student attempt.
*
* This sub-module is called from gview.php, (View All Grades),
* or from owngrades.php, (View my grades).
* Currently it does include a, Confirm... check before it removes.
*
* @package mod_mootyper
* @copyright 2011 Jaka Luthar (jaka.luthar@gmail.com)
* @copyright 2016 onwards AL Rachels (drachels@drachels.com)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later.
*/
use \mod_mootyper\event\owngrades_deleted;
use \mod_mootyper\event\grade_deleted;
require(__DIR__ . '/../../config.php');
global $DB;
$mid = optional_param('m_id', 0, PARAM_INT); // MooTyper id (mdl_mootyper).
$cid = optional_param('c_id', 0, PARAM_INT); // Course module id (mdl_course_modules).
$context = optional_param('context', 0, PARAM_INT); // MooTyper id (mdl_mootyper).
$gradeid = optional_param('g', 0, PARAM_INT);
$mtmode = optional_param('mtmode', 0, PARAM_INT);
$mootyper = $DB->get_record('mootyper', array('id' => $mid), '*', MUST_EXIST);
$course = $mootyper->course;
$cm = get_coursemodule_from_instance('mootyper', $mootyper->id, $course->id, false, MUST_EXIST);
$context = context_module::instance($cm->id);
require_login($course, true, $cm);
if (isset($gradeid)) {
$dbgrade = $DB->get_record('mootyper_grades', array('id' => $gradeid));
// Changed from attempt_id to attemptid 20180129.
$DB->delete_records('mootyper_attempts', array('id' => $dbgrade->attemptid));
$DB->delete_records('mootyper_grades', array('id' => $dbgrade->id));
// 20200808 Delete ratings too.
require_once($CFG->dirroot.'/rating/lib.php');
$delopt = new stdClass;
$delopt->contextid = $context->id;
$delopt->component = 'mod_mootyper';
$delopt->ratingarea = 'exercises';
$delopt->itemid = $dbgrade->id;
$rm = new rating_manager();
$rm->delete_ratings($delopt);
}
// Return to the View my grades or View all grades page.
if ($mtmode == 2) {
// Trigger owngrades_deleted event for mode 2 only if on the, View own grades, page.
$params = array(
'objectid' => $mootyper->id,
'context' => $context,
'other' => array(
'exercise' => $dbgrade->exercise,
'mode' => $mootyper->isexam
)
);
$event = owngrades_deleted::create($params);
$event->trigger();
$webdir = $CFG->wwwroot . '/mod/mootyper/owngrades.php?id='.$cid.'&n='.$mid;
} else {
// Trigger grade_deleted event for mode 0, 1, or 2 if on the, View all grades, page.
$params = array(
'objectid' => $mootyper->id,
'context' => $context,
'other' => array(
'exercise' => $dbgrade->exercise,
'mode' => $mootyper->isexam
),
'relateduserid' => $dbgrade->userid
);
$event = grade_deleted::create($params);
$event->trigger();
$webdir = $CFG->wwwroot . '/mod/mootyper/gview.php?id='.$cid.'&n='.$mid;
}
header('Location: '.$webdir);
<?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/>.
/**
* This file contains the backup activity for the mootyper module.
*
* @package mod_mootyper
* @copyright 2016 onwards AL Rachels (drachels@drachels.com).
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later.
*/
defined('MOODLE_INTERNAL') || die;
require_once($CFG->dirroot . '/mod/mootyper/backup/moodle2/backup_mootyper_stepslib.php'); // Because it exists (must).
// require_once($CFG->dirroot . '/mod/mootyper/backup/moodle2/backup_mootyper_settingslib.php'); // Because it exists (optional).
/**
* Mootyper backup task that provides all the settings and steps to perform one complete backup of the activity.
*
* @package mod_mootyper
* @copyright 2016 onwards AL Rachels (drachels@drachels.com).
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later.
*/
class backup_mootyper_activity_task extends backup_activity_task {
/**
* Define (add) particular settings this activity can have.
*/
protected function define_my_settings() {
// No particular settings for this activity.
}
/**
* Define (add) particular steps this activity can have.
*/
protected function define_my_steps() {
// Choice only has one structure step.
$this->add_step(new backup_mootyper_activity_structure_step('mootyper_structure', 'mootyper.xml'));
}
/**
* Code the transformations to perform in the activity in
* order to get transportable (encoded) links.
* @param string $content
* @return string
*/
static public function encode_content_links($content) {
global $CFG;
$base = preg_quote($CFG->wwwroot, "/");
// Link to the list of mootypers.
$search = "/(".$base."\/mod\/mootyper\/index.php\?id\=)([0-9]+)/";
$content = preg_replace($search, '$@MOOTYPERINDEX*$2@$', $content);
// Link to mootyper view by moduleid.
$search = "/(".$base."\/mod\/mootyper\/view.php\?id\=)([0-9]+)/";
$content = preg_replace($search, '$@MOOTYPERVIEWBYID*$2@$', $content);
return $content;
}
}
<?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/>.
/**
* Define all the backup steps that will be used by the backup_mootyper_activity_task.
*
* @package mod_mootyper
* @copyright 2016 onwards AL Rachels (drachels@drachels.co9m)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
/**
* Define the complete mootyper structure for backup, with file and id annotations
*
* @package mod_mootyper
* @copyright 2016 onwards AL Rachels (drachels@drachels.co9m)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class backup_mootyper_activity_structure_step extends backup_activity_structure_step {
/**
* Define the structure for the assign activity
* @return void
*/
protected function define_structure() {
// To know if we are including userinfo.
$userinfo = $this->get_setting_value('userinfo');
// Define each element separated.
$mootyper = new backup_nested_element('mootyper', array('id'), array(
'name',
'intro',
'introformat',
'timecreated',
'timemodified',
'timeopen',
'timeclose',
'assessed',
'assesstimestart',
'assesstimefinished',
'scale',
'grade_mootyper',
'usepassword',
'password',
'exercise',
'lesson',
'isexam',
'requiredgoal',
'requiredwpm',
'timelimit',
'layout',
'showkeyboard',
'continuoustype',
'countmistypedspaces',
'statsbgc',
'keytoptextc',
'keytopbgc',
'keybdbgc',
'textalign',
'coursorcolor',
'textbgc',
'texterrorcolor'.
'countmistakes'));
$attempts = new backup_nested_element('attempts');
$attempt = new backup_nested_element('attempt', array('id'), array(
'mootyperid',
'userid',
'timetaken',
'inprogress',
'suspicion'));
$checks = new backup_nested_element('checks');
$check = new backup_nested_element('check', array('id'), array(
'attemptid',
'mistakes',
'hits',
'checktime'));
$exercises = new backup_nested_element('exercises');
$exercise = new backup_nested_element('exercise', array('id'), array(
'texttotype',
'exercisename',
'lesson',
'snumber'));
$grades = new backup_nested_element('grades');
$grade = new backup_nested_element('grade', array('id'), array(
'mootyper',
'userid',
'grade',
'mistakes',
'timeinseconds',
'hitsperminute',
'fullhits',
'precisionfield',
'timetaken',
'exercise',
'pass',
'attemptid',
'wpm',
'mistakedetails'));
$layouts = new backup_nested_element('layouts');
$layout = new backup_nested_element('layout', array('id'), array(
'name'));
$lessons = new backup_nested_element('lessons');
$lesson = new backup_nested_element('lesson', array('id'), array(
'lessonname',
'authorid'.
'visible',
'editable',
'courseid'));
// Build the tree.
$mootyper->add_child($attempts);
$attempts->add_child($attempt);
$mootyper->add_child($checks);
$checks->add_child($check);
$mootyper->add_child($grades);
$grades->add_child($grade);
$mootyper->add_child($layouts);
$layouts->add_child($layout);
$mootyper->add_child($lessons);
$lessons->add_child($lesson);
// Define sources.
$mootyper->set_source_table('mootyper', array('id' => backup::VAR_ACTIVITYID));
// All the rest of elements only happen if we are including user info.
if ($userinfo) {
$grade->set_source_table('mootyper_grades', array('mootyper' => backup::VAR_PARENTID));
}
// Define id annotations.
$grade->annotate_ids('mootyper', 'mootyper');
$grade->annotate_ids('user', 'userid');
// Define file annotations.
// These file areas don't have an itemid.
$mootyper->annotate_files('mod_mootyper', 'intro', null);
// Return the root element (mootyper), wrapped into standard activity structure.
return $this->prepare_activity_structure($mootyper);
}
}
<?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/>.