MDL-23692 forgotpw: Move functionality to lib.

Move the password reset request handling into a function.
Move the password reset confirmation handling into a function.
MDL-23692 forgotpw: Remove redundant code.
MDL-23692 forgotpw: Comments & layout changes.

No functional change.
MDL-23692 forgotpw: Improve failure notices.
MDL-23692 forgotpw: Move redirection logic to fn.

Moving to a function because the same logic will be needed in a new
place in later commits.
MDL-23692 forgotpw: Simplify forgotpw process.
MDL-32188 question engine: behaviour static methods -> new classes

It was always a bit of a hack to use static methods on the
qbehaviour_whatever classes to return metadata about the behaviour. It
is better design to have real qbehaviour_whatever_type classes to report
that metadata, particularly now that we are planning to add more such.

For example, inheritance works better with real classes. See, for
example, the improvements in
question_engine::get_behaviour_unused_display_options().

This change has been implemented in a backwards-compatbile way. Old
behaviours will continue to work. There will just be some developer debug
output to prompt people to upgrade their code properly.
MDL-32188 quiz/question: behaviours can add to the review summary.

At the top of the quiz reivew page, there is a table that summarises
infomration about the quiz attempt as a whole. For some question
behaviours, we would like to be able to add additional information to
that summary.

This commit introduces a generic method for the behaviour to provide
summary information about an entire question usage.
MDL-42105 questions: let attempts have a max fraction > 1.

This parallels question_attempt->minfraction, which allows the
fractional mark to go below zere.

This is needed to allow the certainty-base marking behaviours to work
better.
MDL-32188 question rendering: let behaviours control mark display.

Then use this in the CBM behaviours to change how the question marks are
displayed there.
MDL-32188 question CBM: fix typos in comments.

Also one method name.
MDL-32188 question CBM: fix hard-coded numbers -> constants.
MDL-32188 question CBM: alter score handling.

We now change so that minfraction is -6 and maxfraction is 3, so getting
the question right a low certainty gives maxmark marks, and you get a
bonus for being more confident (rather than being penalised for being
unconfident). Mathematically it is the same, but the difference is
importnat psychologically.

We also change how partially correct scores are handled.
It is too harsh to penalise a partially correct score with full
certainty by doing a linear interpolation between -6 and +3. Instead,
any partially correct score (e.g. 0.5) becomes that fraction of the
correct score (e.g. 0.5 * 3 = 1.5). Also, any incorrect score is treated
as 0, so if you have a multiple choice question that normally gives a
negative score for a wrong choice, this will now never give a score of
less than -6.

Finally we change how this is displayed to students beside the question.
Rather than saying "Marked out of 1.00", we say "Base mark 1.00", and
then later we say "CBM mark 3.00" (or whatever it is).
MDL-32188 question CBM: improve display of the certainty choices

Switch to the neutral C=1, 2, 3 mode. Also add a helpicon, and improve
line-wrapping.
MDL-32188 question CBM: compute summary stats for CBM behaviours

We now compute the average CBM score, accuracy, CBM bonus and enhanced
accuracy, both for the entire quiz, and for just the questions answered.

Note that these calculations must work correctly in the presence of
descriptions, ungraded questions, and manually graded questions. For
example, imagine a essay added at the end of the quiz "Summarise what
you learned attempting this exercise." This might have max mark zero or
non-zero. The CBM statistics just ignores questions like that.
MDL-32188 question CBM: minimal handling of certainty -1

Certainty -1 has never been used in standard Moodle, but is
used in Tony-Gardiner Medwin's patches to mean 'No idea' which
we intend to implement: MDL-42077. In the mean time, these changes
avoid errors for people who have used TGM's patches.
MDL-32188 question CBM: use short certainty name in response summaries.
MDL-23692 forgotpw: Coding style tidyups.
MDL-23692 forgotpw:adhere to site autocomp setting
Merge branch 'MDL-32188' of git://github.com/timhunt/moodle

Conflicts:
	lib/db/upgrade.php