Permalink
Browse files

MDL-13796 Most of the recaptcha implementation is done.

  • Loading branch information...
nicolasconnault
nicolasconnault committed Mar 10, 2008
1 parent 7d47ca3 commit 5d6308d491e6dcba87afdb1f0438311c3e07a393
View
@@ -25,7 +25,9 @@
get_string('authinstructions', 'auth'), ''));
$temp->add(new admin_setting_configtext('allowemailaddresses', get_string('allowemailaddresses', 'admin'), get_string('configallowemailaddresses', 'admin'), '', PARAM_NOTAGS));
$temp->add(new admin_setting_configtext('denyemailaddresses', get_string('denyemailaddresses', 'admin'), get_string('configdenyemailaddresses', 'admin'), '', PARAM_NOTAGS));
-
+
+ $temp->add(new admin_setting_configtext('recaptchapublickey', get_string('recaptchapublickey', 'admin'), get_string('configrecaptchapublickey', 'admin'), '', PARAM_NOTAGS));
+ $temp->add(new admin_setting_configtext('recaptchaprivatekey', get_string('recaptchaprivatekey', 'admin'), get_string('configrecaptchaprivatekey', 'admin'), '', PARAM_NOTAGS));
$ADMIN->add('authsettings', $temp);
View
@@ -197,6 +197,13 @@ function config_form($config, $err, $user_fields) {
* Processes and stores configuration data for this authentication plugin.
*/
function process_config($config) {
+ // set to defaults if undefined
+ if (!isset($config->recaptcha)) {
+ $config->recaptcha = false;
+ }
+
+ // save settings
+ set_config('recaptcha', $config->recaptcha, 'auth/email');
return true;
}
View
@@ -1,7 +1,25 @@
<!-- No config needed -->
-<div style="text-align: center"><?php print_string('none'); ?></div>
+<?php
+ // set to defaults if undefined
+ if (!isset($config->recaptcha)) {
+ $config->recaptcha = false;
+ }
+
+ $yesno = array( get_string('no'), get_string('yes') );
+
+?>
<table cellspacing="0" cellpadding="5" border="0">
+<tr>
+ <td colspan="3">
+ <h2 class="main"><?php print_string('auth_emailsettings', 'auth') ?> </h2>
+ </td>
+</tr>
+<tr>
+ <td align="right"><label for="recaptcha"><?php print_string('auth_emailrecaptcha_key', 'auth') ?></label></td>
+ <td><?php choose_from_menu($yesno, 'recaptcha', $config->recaptcha, ''); ?></td>
+ <td><?php print_string('auth_emailrecaptcha', 'auth') ?></td>
+</tr>
<?php
print_auth_lock_options('email', $user_fields, get_string('auth_fieldlocks_help', 'auth'), false, false);
View
@@ -188,6 +188,8 @@
</pre>If this is left empty, no password is required.';
$string['configrcache'] = 'Use the cache to store database records. Remember to set \'cachetype\' as well!';
$string['configrcachettl'] = 'Time-to-live for cached records, in seconds. Use a short (&lt;15) value here.';
+$string['configrecaptchaprivatekey'] = 'String of characters used to communicate between your Moodle server and the recaptcha.net server. Obtain one for this site by visiting http://recaptcha.net';
+$string['configrecaptchapublickey'] = 'String of characters used to display the reCAPTCHA element in the signup form. Generated by http://recaptcha.net';
$string['configrequestedstudentname'] = 'Word for student used in requested courses';
$string['configrequestedstudentsname'] = 'Word for students used in requested courses';
$string['configrequestedteachername'] = 'Word for teacher used in requested courses';
@@ -586,6 +588,8 @@
$string['questioncwqpfsok'] = 'Good. There are no \'random\' questions in your quizzes that are set up to select questions from a mixture of shared and unshared question categories.';
$string['rcache'] = 'Record cache';
$string['rcachettl'] = 'Record cache TTL';
+$string['recaptchapublickey'] = 'ReCAPTCHA public key';
+$string['recaptchaprivatekey'] = 'ReCAPTCHA private key';
$string['releasenoteslink'] = 'For information about this version of Moodle, please see the online <a target=\"_blank\" href=\"$a\">Release Notes</a>';
$string['remotelangnotavailable'] = 'Because Moodle can not connect to download.moodle.org, we are unable to do language pack installation automatically. Please download the appropriate zip file(s) from the list below, copy them to your $a directory and unzip them manually.';
$string['renameerrors'] = 'Rename errors';
View
@@ -117,6 +117,9 @@
$string['auth_emailtitle'] = 'Email-based self-registration';
$string['auth_emailnoinsert'] = 'Could not add your record to the database!';
$string['auth_emailnoemail'] = 'Tried to send you an email but failed!';
+$string['auth_emailrecaptcha'] = 'Adds a visual/audio confirmation form element to the signup page for email self-registering users. This protects your site against spammers and contributes to a worthwhile cause. See http://recaptcha.net/learnmore.html for more details.';
+$string['auth_emailrecaptcha_key'] = 'Enable reCAPTCHA element';
+$string['auth_emailsettings'] = 'Settings';
// FirstClass plugin
$string['auth_fccreators'] = 'List of groups whose members are allowed to create new courses. Separate multiple groups with \';\'. Names must be spelled exactly as on FirstClass server. System is case-sensitive.';
@@ -374,5 +377,10 @@
$string['unlocked'] = 'Unlocked';
$string['unlockedifempty'] = 'Unlocked if empty';
$string['locked'] = 'Locked';
-
+$string['incorrectpleasetryagain'] = 'Incorrect. Please try again.';
+$string['enterthewordsabove'] = 'Enter the words above:';
+$string['enterthenumbersyouhear'] = 'Enter the numbers you hear:';
+$string['getanothercaptcha'] = 'Get another CAPTCHA';
+$string['getanaudiocaptcha'] = 'Get an audio CAPTCHA';
+$string['getanimagecaptcha'] = 'Get an image CAPTCHA';
?>
@@ -1,2 +1,2 @@
<h1>Overall decimal points</h1>
-<p>Specifies the number of decimal points to display for each grade. This setting may be overridden per grading item.</p>
+<p>Specifies the number of decimal points to display for each grade. This setting has no effect on grade calculations, which are made with an accuracy of 5 decimal places.</p>
@@ -1,10 +1,71 @@
<h2>Grade</h2>
<ul>
- <li><a href="help.php?module=grade&amp;file=category.html">Category</a></li>
- <li><a href="help.php?module=grade&amp;file=exceptions.html">Exceptions</a></li>
- <li><a href="help.php?module=grade&amp;file=teacher.html">Grades</a></li>
- <li><a href="help.php?module=grade&amp;file=letter.html">Letter Scale</a></li>
- <li><a href="help.php?module=grade&amp;file=preferences.html">Set Preferences</a></li>
- <li><a href="help.php?module=grade&amp;file=student.html">Student Grade Help</a></li>
- <li><a href="help.php?module=grade&amp;file=weight.html">Weight</a></li>
-</ul>
+ <li><a href="help.php?module=grade&amp;file=aggregateonlygraded.html">Aggregate only non-empty grades</a></li>
+ <li><a href="help.php?module=grade&amp;file=aggregateoutcomes.html">Include outcomes in aggregation</a></li>
+ <li><a href="help.php?module=grade&amp;file=aggregatesubcats.html">Aggregate including subcategories</a></li>
+ <li><a href="help.php?module=grade&amp;file=aggregation.html">Category aggregation</a></li>
+ <li><a href="help.php?module=grade&amp;file=aggregationcoefextra.html">Extra credit</a></li>
+ <li><a href="help.php?module=grade&amp;file=aggregationcoefextrasum.html">Extra credit</a></li>
+ <li><a href="help.php?module=grade&amp;file=aggregationcoefweight.html">Item weight</a></li>
+ <li><a href="help.php?module=grade&amp;file=aggregationposition.html">Aggregation position</a></li>
+ <li><a href="help.php?module=grade&amp;file=aggregationview.html">Aggregation view</a></li>
+ <li><a href="help.php?module=grade&amp;file=averagesdecimalpoints.html">Decimals in column averages</a></li>
+ <li><a href="help.php?module=grade&amp;file=averagesdisplaytype.html">Column averages display type</a></li>
+ <li><a href="help.php?module=grade&amp;file=calculation.html">Calculations</a></li>
+ <li><a href="help.php?module=grade&amp;file=category.html">Category</a></li>
+ <li><a href="help.php?module=grade&amp;file=decimalpoints.html">Overall decimal points</a></li>
+ <li><a href="help.php?module=grade&amp;file=droplow.html">Drop the lowest</a></li>
+ <li><a href="help.php?module=grade&amp;file=exceptions.html">Exceptions</a></li>
+ <li><a href="help.php?module=grade&amp;file=excluded.html">Excluded grades</a></li>
+ <li><a href="help.php?module=grade&amp;file=exportdecimalpoints.html">Export decimal points</a></li>
+ <li><a href="help.php?module=grade&amp;file=feedback.html">Feedback</a></li>
+ <li><a href="help.php?module=grade&amp;file=finalgrade.html">Final grade</a></li>
+ <li><a href="help.php?module=grade&amp;file=gradeboundary.html">Grade boundary</a></li>
+ <li><a href="help.php?module=grade&amp;file=gradedisplaytype.html">Grade display type</a></li>
+ <li><a href="help.php?module=grade&amp;file=gradeexportdisplaytype.html">Grade export display type</a></li>
+ <li><a href="help.php?module=grade&amp;file=gradeletter.html">Grade letters</a></li>
+ <li><a href="help.php?module=grade&amp;file=grademax.html">Maximum Grade</a></li>
+ <li><a href="help.php?module=grade&amp;file=grademin.html">Minimum Grade</a></li>
+ <li><a href="help.php?module=grade&amp;file=gradepass.html">Grade to pass</a></li>
+ <li><a href="help.php?module=grade&amp;file=gradetype.html">Grade type</a></li>
+ <li><a href="help.php?module=grade&amp;file=hidden.html">Hidden</a></li>
+ <li><a href="help.php?module=grade&amp;file=hiddenuntil.html">Hidden until</a></li>
+ <li><a href="help.php?module=grade&amp;file=idnumber.html">Id numbers</a></li>
+ <li><a href="help.php?module=grade&amp;file=iteminfo.html">Item info</a></li>
+ <li><a href="help.php?module=grade&amp;file=keephigh.html">Keep the highest</a></li>
+ <li><a href="help.php?module=grade&amp;file=letter.html">Letter scale</a></li>
+ <li><a href="help.php?module=grade&amp;file=linkedactivity.html">Linked activity</a></li>
+ <li><a href="help.php?module=grade&amp;file=locked.html">Locked</a></li>
+ <li><a href="help.php?module=grade&amp;file=lockedafter.html">Locked after</a></li>
+ <li><a href="help.php?module=grade&amp;file=meanselection.html">Grades selected for column averages</a></li>
+ <li><a href="help.php?module=grade&amp;file=multfactor.html">Multiplicator</a></li>
+ <li><a href="help.php?module=grade&amp;file=outcomeid.html">Outcome</a></li>
+ <li><a href="help.php?module=grade&amp;file=outcomestandard.html">Standard outcomes</a></li>
+ <li><a href="help.php?module=grade&amp;file=overridden.html">Overridden</a></li>
+ <li><a href="help.php?module=grade&amp;file=overridesitedefaultgradedisplaytype.html">Override site defaults</a></li>
+ <li><a href="help.php?module=grade&amp;file=plusfactor.html">Offset</a></li>
+ <li><a href="help.php?module=grade&amp;file=preferences.html">Set Preferences</a></li>
+ <li><a href="help.php?module=grade&amp;file=quickgrading.html">Quick grading</a></li>
+ <li><a href="help.php?module=grade&amp;file=rangesdecimalpoints.html">Decimals shown in ranges</a></li>
+ <li><a href="help.php?module=grade&amp;file=rangesdisplaytype.html">Range display type</a></li>
+ <li><a href="help.php?module=grade&amp;file=scaleid.html">Scale</a></li>
+ <li><a href="help.php?module=grade&amp;file=scalestandard.html">Standard scales</a></li>
+ <li><a href="help.php?module=grade&amp;file=showactivityicons.html">Show activity icons</a></li>
+ <li><a href="help.php?module=grade&amp;file=showaverages.html">Show averages</a></li>
+ <li><a href="help.php?module=grade&amp;file=showcalculations.html">Show calculations</a></li>
+ <li><a href="help.php?module=grade&amp;file=showeyecons.html"></a>Show show/hide icons</li>
+ <li><a href="help.php?module=grade&amp;file=showfeedback.html">Show feedback</a></li>
+ <li><a href="help.php?module=grade&amp;file=showgroups.html">Show groups</a></li>
+ <li><a href="help.php?module=grade&amp;file=showhiddenitems.html">Show hidden items</a></li>
+ <li><a href="help.php?module=grade&amp;file=showlocks.html">Show locks</a></li>
+ <li><a href="help.php?module=grade&amp;file=shownumberofgrades.html">Show number of grades</a></li>
+ <li><a href="help.php?module=grade&amp;file=showquickfeedback.html">Show quick feedback</a></li>
+ <li><a href="help.php?module=grade&amp;file=showranges.html">Show ranges</a></li>
+ <li><a href="help.php?module=grade&amp;file=showrank.html">Show rank</a></li>
+ <li><a href="help.php?module=grade&amp;file=showuseridnumber.html">Show user id numbers</a></li>
+ <li><a href="help.php?module=grade&amp;file=student.html">Student Grade Help</a></li>
+ <li><a href="help.php?module=grade&amp;file=studentsperpage.html">Students per page</a></li>
+ <li><a href="help.php?module=grade&amp;file=teacher.html">Grades</a></li>
+ <li><a href="help.php?module=grade&amp;file=userkey.html">User key</a></li>
+ <li><a href="help.php?module=grade&amp;file=weight.html">Weight</a></li>
+</ul>
View
@@ -0,0 +1,84 @@
+<?php
+/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
+
+/**
+ * textarea_counter.php
+ *
+ * @category Admin
+ * @package admin
+ * @author Nicolas Connault <nicolasconnault@gmail.com>
+ * @version $Id$
+ */
+
+
+/**
+ * @category Admin
+ * @package admin
+ */
+class MoodleQuickForm_recaptcha extends HTML_QuickForm_input {
+
+ /**
+ * <code>
+ * $form->addElement('textarea_counter', 'message', 'Message',
+ * array('cols'=>60, 'rows'=>10), 160);
+ * </code>
+ */
+ function HTML_QuickForm_recaptcha($elementName = null, $elementLabel = null, $attributes = null) {
+ parent::HTML_QuickForm_input($elementName, $elementLabel, $attributes);
+ $this->_type = 'recaptcha';
+ }
+
+ /**
+ * Returns the recaptcha element in HTML
+ *
+ * @since 1.0
+ * @access public
+ * @return string
+ */
+ function toHtml() {
+ global $CFG;
+ require_once $CFG->libdir . '/recaptchalib.php';
+
+ $html = '<script type="text/javascript">
+ var RecaptchaOptions = {
+ theme : \'custom\',
+ tabindex : 2,
+ custom_theme_widget : \'recaptcha_widget\'
+ };
+ </script>' . "\n";
+
+
+ if (empty($_SESSION['recaptcha_error'])) {
+ $_SESSION['recaptcha_error'] = null;
+ }
+ $error = $_SESSION['recaptcha_error'];
+ unset($_SESSION['recaptcha_error']);
+
+ $strincorrectpleasetryagain = get_string('incorrectpleasetryagain', 'auth');
+ $strenterthewordsabove = get_string('enterthewordsabove', 'auth');
+ $strenterthenumbersyouhear = get_string('enterthenumbersyouhear', 'auth');
+ $strgetanothercaptcha = get_string('getanothercaptcha', 'auth');
+ $strgetanaudiocaptcha = get_string('getanaudiocaptcha', 'auth');
+ $strgetanimagecaptcha = get_string('getanimagecaptcha', 'auth');
+
+ $html .= '
+<div id="recaptcha_widget" style="display:none">
+
+<div id="recaptcha_image"></div>
+<div class="recaptcha_only_if_incorrect_sol" style="color:red">' . $strincorrectpleasetryagain . '</div>
+
+<span class="recaptcha_only_if_image">' . $strenterthewordsabove . '</span>
+<span class="recaptcha_only_if_audio">' . $strenterthenumbersyouhear . '</span>
+
+<input type="text" id="recaptcha_response_field" name="recaptcha_response_field" />
+
+<div><a href="javascript:Recaptcha.reload()">' . $strgetanothercaptcha . '</a></div>
+<div class="recaptcha_only_if_image"><a href="javascript:Recaptcha.switch_type(\'audio\')">' . $strgetanaudiocaptcha . '</a></div>
+<div class="recaptcha_only_if_audio"><a href="javascript:Recaptcha.switch_type(\'image\')">' . $strgetanimagecaptcha . '</a></div>
+</div>';
+
+ return $html . recaptcha_get_html($CFG->recaptchapublickey, $error);
+ }
+}
+
+?>
View
@@ -1876,4 +1876,5 @@ function getStopFieldsetElements(){
MoodleQuickForm::registerElementType('submit', "$CFG->libdir/form/submit.php", 'MoodleQuickForm_submit');
MoodleQuickForm::registerElementType('questioncategory', "$CFG->libdir/form/questioncategory.php", 'MoodleQuickForm_questioncategory');
MoodleQuickForm::registerElementType('advcheckbox', "$CFG->libdir/form/advcheckbox.php", 'MoodleQuickForm_advcheckbox');
+MoodleQuickForm::registerElementType('recaptcha', "$CFG->libdir/form/recaptcha.php", 'MoodleQuickForm_recaptcha');
?>
Oops, something went wrong.

0 comments on commit 5d6308d

Please sign in to comment.