Compare commits
49 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| cb6d0894c3 | |||
| 6686945ee3 | |||
| 1743d9399b | |||
| 9cd6ebbe55 | |||
| 72f8b520a1 | |||
| 621c41ae2b | |||
| 7e8d9a721a | |||
| ea17a9c8f2 | |||
| 593dc76c1a | |||
| 08a43cac5e | |||
| faf5d6b33d | |||
| c5adf8f923 | |||
| ed0868c364 | |||
| 6f424c1824 | |||
| b5cba5dd13 | |||
| 12d2ff509c | |||
| ea3d671a33 | |||
| c39885e2f7 | |||
| 4635f0ecd8 | |||
| ad1afa2d02 | |||
| e5161d5770 | |||
| 95069438b4 | |||
| 93e9a93cae | |||
| 0530299688 | |||
| 9936a2ecf4 | |||
| 56673355ca | |||
| 4d0348583a | |||
| 49de1ac0b6 | |||
| 055f532221 | |||
| 92cc4862ab | |||
| 6169da991c | |||
| 22cb3c80a0 | |||
| a1cec1a1cc | |||
| e15a93cf8c | |||
| ef1857c333 | |||
| fd8821b455 | |||
| 924df0e6c8 | |||
| 9a33c51dec | |||
| e0799ca496 | |||
| ca8bce95b8 | |||
| 290f9067d0 | |||
| 85fcc67e01 | |||
| 30c9b8eb50 | |||
| ab18857b08 | |||
| 4dd5053fe1 | |||
| 904da0086f | |||
| bb970e231e | |||
| d8b67539cd | |||
| 2664066699 |
+339
@@ -0,0 +1,339 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
License is intended to guarantee your freedom to share and change free
|
||||
software--to make sure the software is free for all its users. This
|
||||
General Public License applies to most of the Free Software
|
||||
Foundation's software and to any other program whose authors commit to
|
||||
using it. (Some other Free Software Foundation software is covered by
|
||||
the GNU Lesser General Public License instead.) You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
this service if you wish), that you receive source code or can get it
|
||||
if you want it, that you can change the software or use pieces of it
|
||||
in new free programs; and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
anyone to deny you these rights or to ask you to surrender the rights.
|
||||
These restrictions translate to certain responsibilities for you if you
|
||||
distribute copies of the software, or if you modify it.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must give the recipients all the rights that
|
||||
you have. You must make sure that they, too, receive or can get the
|
||||
source code. And you must show them these terms so they know their
|
||||
rights.
|
||||
|
||||
We protect your rights with two steps: (1) copyright the software, and
|
||||
(2) offer you this license which gives you legal permission to copy,
|
||||
distribute and/or modify the software.
|
||||
|
||||
Also, for each author's protection and ours, we want to make certain
|
||||
that everyone understands that there is no warranty for this free
|
||||
software. If the software is modified by someone else and passed on, we
|
||||
want its recipients to know that what they have is not the original, so
|
||||
that any problems introduced by others will not reflect on the original
|
||||
authors' reputations.
|
||||
|
||||
Finally, any free program is threatened constantly by software
|
||||
patents. We wish to avoid the danger that redistributors of a free
|
||||
program will individually obtain patent licenses, in effect making the
|
||||
program proprietary. To prevent this, we have made it clear that any
|
||||
patent must be licensed for everyone's free use or not licensed at all.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License applies to any program or other work which contains
|
||||
a notice placed by the copyright holder saying it may be distributed
|
||||
under the terms of this General Public License. The "Program", below,
|
||||
refers to any such program or work, and a "work based on the Program"
|
||||
means either the Program or any derivative work under copyright law:
|
||||
that is to say, a work containing the Program or a portion of it,
|
||||
either verbatim or with modifications and/or translated into another
|
||||
language. (Hereinafter, translation is included without limitation in
|
||||
the term "modification".) Each licensee is addressed as "you".
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running the Program is not restricted, and the output from the Program
|
||||
is covered only if its contents constitute a work based on the
|
||||
Program (independent of having been made by running the Program).
|
||||
Whether that is true depends on what the Program does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Program's
|
||||
source code as you receive it, in any medium, provided that you
|
||||
conspicuously and appropriately publish on each copy an appropriate
|
||||
copyright notice and disclaimer of warranty; keep intact all the
|
||||
notices that refer to this License and to the absence of any warranty;
|
||||
and give any other recipients of the Program a copy of this License
|
||||
along with the Program.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy, and
|
||||
you may at your option offer warranty protection in exchange for a fee.
|
||||
|
||||
2. You may modify your copy or copies of the Program or any portion
|
||||
of it, thus forming a work based on the Program, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) You must cause the modified files to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
b) You must cause any work that you distribute or publish, that in
|
||||
whole or in part contains or is derived from the Program or any
|
||||
part thereof, to be licensed as a whole at no charge to all third
|
||||
parties under the terms of this License.
|
||||
|
||||
c) If the modified program normally reads commands interactively
|
||||
when run, you must cause it, when started running for such
|
||||
interactive use in the most ordinary way, to print or display an
|
||||
announcement including an appropriate copyright notice and a
|
||||
notice that there is no warranty (or else, saying that you provide
|
||||
a warranty) and that users may redistribute the program under
|
||||
these conditions, and telling the user how to view a copy of this
|
||||
License. (Exception: if the Program itself is interactive but
|
||||
does not normally print such an announcement, your work based on
|
||||
the Program is not required to print an announcement.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Program,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Program, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Program.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Program
|
||||
with the Program (or with a work based on the Program) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may copy and distribute the Program (or a work based on it,
|
||||
under Section 2) in object code or executable form under the terms of
|
||||
Sections 1 and 2 above provided that you also do one of the following:
|
||||
|
||||
a) Accompany it with the complete corresponding machine-readable
|
||||
source code, which must be distributed under the terms of Sections
|
||||
1 and 2 above on a medium customarily used for software interchange; or,
|
||||
|
||||
b) Accompany it with a written offer, valid for at least three
|
||||
years, to give any third party, for a charge no more than your
|
||||
cost of physically performing source distribution, a complete
|
||||
machine-readable copy of the corresponding source code, to be
|
||||
distributed under the terms of Sections 1 and 2 above on a medium
|
||||
customarily used for software interchange; or,
|
||||
|
||||
c) Accompany it with the information you received as to the offer
|
||||
to distribute corresponding source code. (This alternative is
|
||||
allowed only for noncommercial distribution and only if you
|
||||
received the program in object code or executable form with such
|
||||
an offer, in accord with Subsection b above.)
|
||||
|
||||
The source code for a work means the preferred form of the work for
|
||||
making modifications to it. For an executable work, complete source
|
||||
code means all the source code for all modules it contains, plus any
|
||||
associated interface definition files, plus the scripts used to
|
||||
control compilation and installation of the executable. However, as a
|
||||
special exception, the source code distributed need not include
|
||||
anything that is normally distributed (in either source or binary
|
||||
form) with the major components (compiler, kernel, and so on) of the
|
||||
operating system on which the executable runs, unless that component
|
||||
itself accompanies the executable.
|
||||
|
||||
If distribution of executable or object code is made by offering
|
||||
access to copy from a designated place, then offering equivalent
|
||||
access to copy the source code from the same place counts as
|
||||
distribution of the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
4. You may not copy, modify, sublicense, or distribute the Program
|
||||
except as expressly provided under this License. Any attempt
|
||||
otherwise to copy, modify, sublicense or distribute the Program is
|
||||
void, and will automatically terminate your rights under this License.
|
||||
However, parties who have received copies, or rights, from you under
|
||||
this License will not have their licenses terminated so long as such
|
||||
parties remain in full compliance.
|
||||
|
||||
5. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Program or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Program (or any work based on the
|
||||
Program), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Program or works based on it.
|
||||
|
||||
6. Each time you redistribute the Program (or any work based on the
|
||||
Program), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute or modify the Program subject to
|
||||
these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties to
|
||||
this License.
|
||||
|
||||
7. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Program at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Program by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Program.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under
|
||||
any particular circumstance, the balance of the section is intended to
|
||||
apply and the section as a whole is intended to apply in other
|
||||
circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system, which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
8. If the distribution and/or use of the Program is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Program under this License
|
||||
may add an explicit geographical distribution limitation excluding
|
||||
those countries, so that distribution is permitted only in or among
|
||||
countries not thus excluded. In such case, this License incorporates
|
||||
the limitation as if written in the body of this License.
|
||||
|
||||
9. The Free Software Foundation may publish revised and/or new versions
|
||||
of the General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Program
|
||||
specifies a version number of this License which applies to it and "any
|
||||
later version", you have the option of following the terms and conditions
|
||||
either of that version or of any later version published by the Free
|
||||
Software Foundation. If the Program does not specify a version number of
|
||||
this License, you may choose any version ever published by the Free Software
|
||||
Foundation.
|
||||
|
||||
10. If you wish to incorporate parts of the Program into other free
|
||||
programs whose distribution conditions are different, write to the author
|
||||
to ask for permission. For software which is copyrighted by the Free
|
||||
Software Foundation, write to the Free Software Foundation; we sometimes
|
||||
make exceptions for this. Our decision will be guided by the two goals
|
||||
of preserving the free status of all derivatives of our free software and
|
||||
of promoting the sharing and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
||||
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
||||
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
||||
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
||||
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
||||
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
||||
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
||||
REPAIR OR CORRECTION.
|
||||
|
||||
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
||||
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
||||
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
|
||||
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
|
||||
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
||||
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program 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 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program 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 this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program is interactive, make it output a short notice like this
|
||||
when it starts in an interactive mode:
|
||||
|
||||
Gnomovision version 69, Copyright (C) year name of author
|
||||
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, the commands you use may
|
||||
be called something other than `show w' and `show c'; they could even be
|
||||
mouse-clicks or menu items--whatever suits your program.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the program, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
||||
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1989
|
||||
Ty Coon, President of Vice
|
||||
|
||||
This General Public License does not permit incorporating your program into
|
||||
proprietary programs. If your program is a subroutine library, you may
|
||||
consider it more useful to permit linking proprietary applications with the
|
||||
library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License.
|
||||
@@ -158,7 +158,7 @@
|
||||
<VENDOR name="mssql_n" version="9.0" />
|
||||
<VENDOR name="oracle" version="9.0" />
|
||||
</DATABASE>
|
||||
<PHP version="5.2.4" level="required">
|
||||
<PHP version="5.2.8" level="required">
|
||||
</PHP>
|
||||
<PHP_EXTENSIONS>
|
||||
<PHP_EXTENSION name="iconv" level="optional">
|
||||
|
||||
Executable
+369
@@ -0,0 +1,369 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Spam Cleaner
|
||||
*
|
||||
* Helps an admin to clean up spam in Moodle
|
||||
*
|
||||
* @version $Id$
|
||||
* @authors Dongsheng Cai, Martin Dougiamas, Amr Hourani
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
|
||||
*/
|
||||
|
||||
// Configuration
|
||||
|
||||
// List of known spammy keywords, please add more here
|
||||
|
||||
$autokeywords = array(
|
||||
"<img",
|
||||
"fuck",
|
||||
"casino",
|
||||
"porn",
|
||||
"xxx",
|
||||
"cialis",
|
||||
"viagra",
|
||||
"poker",
|
||||
"warcraft"
|
||||
);
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
require_once('../../../config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
function delete_user($user) {
|
||||
$updateuser = new object();
|
||||
$updateuser->id = $user->id;
|
||||
$updateuser->deleted = 1;
|
||||
$updateuser->username = addslashes("$user->email.".time());
|
||||
$updateuser->email = '';
|
||||
$updateuser->idnumber = '';
|
||||
$updateuser->timemodified = time();
|
||||
if (update_record('user', $updateuser)) {
|
||||
role_unassign(0, $user->id);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
$keyword = optional_param('keyword', '', PARAM_RAW);
|
||||
$autodetect = optional_param('autodetect', '', PARAM_RAW);
|
||||
$del = optional_param('del', '', PARAM_RAW);
|
||||
$delall = optional_param('delall', '', PARAM_RAW);
|
||||
$ignore = optional_param('ignore', '', PARAM_RAW);
|
||||
$reset = optional_param('reset', '', PARAM_RAW);
|
||||
$id = optional_param('id', '', PARAM_INT);
|
||||
|
||||
require_login();
|
||||
$adminroot = admin_get_root();
|
||||
admin_externalpage_setup('reportspamcleaner', $adminroot);
|
||||
|
||||
// Implement some AJAX calls
|
||||
|
||||
// Delete one user
|
||||
if (!empty($del) && confirm_sesskey() && ($id != $USER->id)) {
|
||||
if (isset($SESSION->users_result[$id])) {
|
||||
$user = $SESSION->users_result[$id];
|
||||
if (delete_user($user)) {
|
||||
unset($SESSION->users_result[$id]);
|
||||
echo 1;
|
||||
} else {
|
||||
echo 0;
|
||||
}
|
||||
} else {
|
||||
echo 0;
|
||||
}
|
||||
exit;
|
||||
}
|
||||
|
||||
// Delete lots of users
|
||||
if (!empty($delall) && confirm_sesskey()) {
|
||||
if (!empty($SESSION->users_result)) {
|
||||
foreach ($SESSION->users_result as $userid => $user) {
|
||||
if ($userid != $USER->id) {
|
||||
if (delete_user($user)) {
|
||||
unset($SESSION->users_result[$userid]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
echo 1;
|
||||
exit;
|
||||
}
|
||||
|
||||
if (!empty($ignore)) {
|
||||
unset($SESSION->users_result[$id]);
|
||||
echo 1;
|
||||
exit;
|
||||
}
|
||||
|
||||
admin_externalpage_print_header($adminroot);
|
||||
|
||||
// Print headers and things
|
||||
|
||||
print_spamcleaner_javascript();
|
||||
|
||||
print_simple_box(get_string('spamcleanerintro', 'report_spamcleaner'));
|
||||
|
||||
?>
|
||||
|
||||
<div class="mdl-align">
|
||||
|
||||
<form method="post" action="index.php">
|
||||
<div>
|
||||
<input type="text" name="keyword" id="keyword_el" value="<?php p($keyword) ?>" />
|
||||
<input type="hidden" name="sesskey" value="<?php echo sesskey();?>" />
|
||||
<input type="submit" value="<?php echo get_string('spamsearch', 'report_spamcleaner')?>" />
|
||||
</div>
|
||||
</form>
|
||||
<p><?php echo get_string('spameg', 'report_spamcleaner');?></p>
|
||||
|
||||
<hr />
|
||||
|
||||
<form method="post" action="index.php">
|
||||
<div>
|
||||
<input type="submit" name="autodetect" value="<?php echo get_string('spamauto', 'report_spamcleaner');?>" />
|
||||
</div>
|
||||
</form>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<?php
|
||||
|
||||
echo '<div id="result" class="mdl-align">';
|
||||
|
||||
// Print list of resulting profiles
|
||||
|
||||
if (!empty($keyword)) { // Use the keyword(s) supplied by the user
|
||||
$keywords = explode(',', $keyword);
|
||||
foreach ($keywords as $key => $keyword) {
|
||||
$keywords[$key] = trim($keyword);
|
||||
}
|
||||
search_spammers($keywords);
|
||||
|
||||
} else if (!empty($autodetect)) { // Use the inbuilt keyword list to detect users
|
||||
search_spammers($autokeywords);
|
||||
}
|
||||
|
||||
echo '</div>';
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
/// Functions
|
||||
|
||||
|
||||
function search_spammers($keywords) {
|
||||
|
||||
global $CFG, $USER, $DB;
|
||||
|
||||
if (!is_array($keywords)) {
|
||||
$keywords = array($keywords); // Make it into an array
|
||||
}
|
||||
|
||||
$like = sql_ilike();
|
||||
|
||||
$keywordfull = array();
|
||||
foreach ($keywords as $keyword) {
|
||||
$keyword = addslashes($keyword); // Just to be safe
|
||||
$keywordfull[] = " description $like '%$keyword%' ";
|
||||
$keywordfull2[] = " p.summary $like '%$keyword%' ";
|
||||
}
|
||||
$conditions = '( '.implode(' OR ', $keywordfull).' )';
|
||||
$conditions2 = '( '.implode(' OR ', $keywordfull2).' )';
|
||||
|
||||
$sql = "SELECT * FROM {$CFG->prefix}user WHERE deleted = 0 AND id <> {$USER->id} AND $conditions"; // Exclude oneself
|
||||
$sql2= "SELECT u.*, p.summary FROM {$CFG->prefix}user AS u, {$CFG->prefix}post AS p WHERE $conditions2 AND u.deleted = 0 AND u.id=p.userid AND u.id <> {$USER->id}";
|
||||
$spamusers_desc = get_recordset_sql($sql);
|
||||
$spamusers_blog = get_recordset_sql($sql2);
|
||||
|
||||
$keywordlist = implode(', ', $keywords);
|
||||
print_simple_box(get_string('spamresult', 'report_spamcleaner').s($keywordlist)).' ...';
|
||||
|
||||
print_user_list(array($spamusers_desc, $spamusers_blog), $keywords);
|
||||
|
||||
}
|
||||
|
||||
function print_user_list($users_rs, $keywords) {
|
||||
global $CFG, $SESSION;
|
||||
|
||||
// reset session everytime this function is called
|
||||
$SESSION->users_result = array();
|
||||
$count = 0;
|
||||
|
||||
foreach ($users_rs as $rs) {
|
||||
while ($user = rs_fetch_next_record($rs)) {
|
||||
if (!$count) {
|
||||
echo '<table border="1" width="100%" id="data-grid"><tr><th> </th><th>'.get_string('user','admin').'</th><th>'.get_string('spamdesc', 'report_spamcleaner').'</th><th>'.get_string('spamoperation', 'report_spamcleaner').'</th></tr>';
|
||||
}
|
||||
$count++;
|
||||
filter_user($user, $keywords, $count);
|
||||
}
|
||||
}
|
||||
|
||||
if (!$count) {
|
||||
echo get_string('spamcannotfinduser', 'report_spamcleaner');
|
||||
|
||||
} else {
|
||||
echo '</table>';
|
||||
echo '<div class="mld-align">
|
||||
<button id="removeall_btn">'.get_string('spamdeleteall', 'report_spamcleaner').'</button>
|
||||
</div>';
|
||||
}
|
||||
}
|
||||
function filter_user($user, $keywords, $count) {
|
||||
global $CFG;
|
||||
$image_search = false;
|
||||
if (in_array('<img', $keywords)) {
|
||||
$image_search = true;
|
||||
}
|
||||
if (isset($user->summary)) {
|
||||
$user->description = '<h3>'.get_string('spamfromblog', 'report_spamcleaner').'</h3>'.$user->summary;
|
||||
unset($user->summary);
|
||||
}
|
||||
if (preg_match('#<img.*src=[\"\']('.$CFG->pixpath.')#', $user->description, $matches)
|
||||
&& $image_search) {
|
||||
$result = false;
|
||||
foreach ($keywords as $keyword) {
|
||||
if (preg_match('#'.$keyword.'#', $user->description)
|
||||
&& ($keyword != '<img')) {
|
||||
$result = true;
|
||||
}
|
||||
}
|
||||
if ($result) {
|
||||
echo print_user_entry($user, $keywords, $count);
|
||||
} else {
|
||||
unset($user);
|
||||
}
|
||||
} else {
|
||||
echo print_user_entry($user, $keywords, $count);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function print_user_entry($user, $keywords, $count) {
|
||||
|
||||
global $SESSION, $CFG;
|
||||
|
||||
$smalluserobject = new object; // All we need to delete them later
|
||||
$smalluserobject->id = $user->id;
|
||||
$smalluserobject->email = $user->email;
|
||||
$smalluserobject->auth = $user->auth;
|
||||
$smalluserobject->firstname = $user->firstname;
|
||||
$smalluserobject->lastname = $user->lastname;
|
||||
|
||||
if (empty($SESSION->users_result[$user->id])) {
|
||||
$SESSION->users_result[$user->id] = $smalluserobject;
|
||||
$html = '<tr valign="top" id="row-'.$user->id.'" class="result-row">';
|
||||
$html .= '<td width="10">'.$count.'</td>';
|
||||
$html .= '<td width="30%" align="left"><a href="'.$CFG->wwwroot."/user/view.php?course=1&id=".$user->id.'" title="'.s($user->username).'">'.fullname($user).'</a>';
|
||||
|
||||
$html .= "<ul>";
|
||||
$profile_set = array('city'=>true, 'country'=>true, 'email'=>true);
|
||||
foreach ($profile_set as $key=>$value) {
|
||||
if (isset($user->$key)){
|
||||
$html .= '<li>'.$user->$key.'</li>';
|
||||
}
|
||||
}
|
||||
$html .= "</ul>";
|
||||
$html .= '</td>';
|
||||
|
||||
foreach ($keywords as $keyword) {
|
||||
$user->description = highlight($keyword, $user->description);
|
||||
}
|
||||
|
||||
$html .= '<td align="left">'.format_text($user->description, FORMAT_MOODLE).'</td>';
|
||||
$html .= '<td width="100px" align="center">';
|
||||
$html .= '<button onclick="del_user(this,'.$user->id.')">'.get_string('deleteuser', 'admin').'</button><br />';
|
||||
$html .= '<button onclick="ignore_user(this,'.$user->id.')">'.get_string('ignore', 'admin').'</button>';
|
||||
$html .= '</td>';
|
||||
$html .= '</tr>';
|
||||
return $html;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
function print_spamcleaner_javascript() {
|
||||
global $CFG;
|
||||
|
||||
$sesskey = sesskey();
|
||||
|
||||
?>
|
||||
<script type="text/javascript" src="<?php echo $CFG->wwwroot;?>/lib/yui/yahoo-dom-event/yahoo-dom-event.js"></script>
|
||||
<script type="text/javascript" src="<?php echo $CFG->wwwroot;?>/lib/yui/connection/connection-min.js"></script>
|
||||
<script type="text/javascript">
|
||||
//<![CDATA[
|
||||
var row = null;
|
||||
var delall_cb = {
|
||||
success: function(o){
|
||||
var resp = o.responseText;
|
||||
if(resp){
|
||||
window.location.href=window.location.href;
|
||||
}
|
||||
}
|
||||
}
|
||||
function init() {
|
||||
YAHOO.util.Event.addListener("removeall_btn", "click", function(){
|
||||
var yes = confirm('<?php echo get_string('spamdeleteallconfirm', 'report_spamcleaner');?>');
|
||||
if(yes){
|
||||
var cObj = YAHOO.util.Connect.asyncRequest('POST', '<?php echo me();?>?delall=yes&sesskey=<?php echo $sesskey;?>', delall_cb);
|
||||
}
|
||||
});
|
||||
}
|
||||
var del_cb = {
|
||||
success: function(o) {
|
||||
var resp = o.responseText;
|
||||
if(row) {
|
||||
if(resp){
|
||||
while(row.tagName != 'TR') {
|
||||
row = row.parentNode;
|
||||
}
|
||||
row.parentNode.removeChild(row);
|
||||
row = null;
|
||||
} else {
|
||||
alert('<?php echo get_string('spamcannotdelete', 'report_spamcleaner');?>');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
var ignore_cb = {
|
||||
success: function(o){
|
||||
var resp = o.responseText;
|
||||
if(row) {
|
||||
if(resp){
|
||||
while(row.tagName != 'TR') {
|
||||
row = row.parentNode;
|
||||
}
|
||||
row.parentNode.removeChild(row);
|
||||
row = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
function del_user(obj, id) {
|
||||
var yes = confirm('<?php echo get_string('spamdeleteconfirm', 'report_spamcleaner');?>');
|
||||
if(yes){
|
||||
row = obj;
|
||||
var cObj = YAHOO.util.Connect.asyncRequest('POST', '<?php echo me();?>?del=yes&sesskey=<?php echo $sesskey;?>&id='+id, del_cb);
|
||||
}
|
||||
}
|
||||
function ignore_user(obj, id) {
|
||||
row = obj;
|
||||
var cObj = YAHOO.util.Connect.asyncRequest('POST', '<?php echo me();?>?ignore=yes&sesskey=<?php echo $sesskey;?>&id='+id, ignore_cb);
|
||||
}
|
||||
window.onload = function(){
|
||||
init();
|
||||
}
|
||||
//]]>
|
||||
</script>
|
||||
|
||||
<?php
|
||||
}
|
||||
|
||||
admin_externalpage_print_footer($adminroot);
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,5 @@
|
||||
<?php
|
||||
|
||||
// spam cleaner
|
||||
$ADMIN->add('reports', new admin_externalpage('reportspamcleaner', get_string('spamcleaner','report_spamcleaner'), "$CFG->wwwroot/$CFG->admin/report/spamcleaner/index.php", 'moodle/site:config'));
|
||||
|
||||
+2
-1
@@ -16,7 +16,8 @@
|
||||
/* */
|
||||
/* This program 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 2 of the License. */
|
||||
/* the Free Software Foundation; either version 2 of the License or any */
|
||||
/* later version. */
|
||||
/************************************************************************/
|
||||
/* Author: Torsten Anderson, torsten.anderson@skeria.skelleftea.se
|
||||
*/
|
||||
|
||||
+1
-9
@@ -2195,16 +2195,8 @@ function move_courses ($courseids, $categoryid) {
|
||||
|
||||
$course->category = $categoryid;
|
||||
$course->sortorder = $sortorder;
|
||||
$course->fullname = addslashes($course->fullname);
|
||||
$course->shortname = addslashes($course->shortname);
|
||||
$course->summary = addslashes($course->summary);
|
||||
$course->password = addslashes($course->password);
|
||||
$course->teacher = addslashes($course->teacher);
|
||||
$course->teachers = addslashes($course->teachers);
|
||||
$course->student = addslashes($course->student);
|
||||
$course->students = addslashes($course->students);
|
||||
|
||||
if (!update_record('course', $course)) {
|
||||
if (!update_record('course', addslashes_object($course))) {
|
||||
notify("An error occurred - course not moved!");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
}
|
||||
}
|
||||
|
||||
require_once($CFG->dirroot.'/filter/tex/lib.php');
|
||||
|
||||
$CFG->texfilterdir = "filter/tex";
|
||||
$CFG->algebrafilterdir = "filter/algebra";
|
||||
$CFG->algebraimagedir = "filter/algebra";
|
||||
@@ -23,6 +25,8 @@
|
||||
$CFG->algebrafilterdirwin = "filter\\algebra";
|
||||
}
|
||||
|
||||
require_login();
|
||||
require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM));
|
||||
|
||||
$query = urldecode($_SERVER['QUERY_STRING']);
|
||||
error_reporting(E_ALL);
|
||||
@@ -233,6 +237,7 @@ function tex2image($texexp, $md5, $return=false) {
|
||||
}
|
||||
$commandpath = "";
|
||||
$cmd = "";
|
||||
$texexp = tex_sanitize_formula($texexp);
|
||||
$texexp = escapeshellarg($texexp);
|
||||
switch (PHP_OS) {
|
||||
case "Linux":
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
// disable moodle specific debug messages
|
||||
disable_debugging();
|
||||
|
||||
require_once($CFG->dirroot.'/filter/tex/lib.php');
|
||||
require_once($CFG->libdir.'/filelib.php');
|
||||
|
||||
$CFG->texfilterdir = 'filter/tex';
|
||||
@@ -54,6 +55,8 @@
|
||||
$texexp = str_replace('>','>',$texexp);
|
||||
$texexp = preg_replace('!\r\n?!',' ',$texexp);
|
||||
$texexp = '\Large ' . $texexp;
|
||||
|
||||
$texexp = tex_sanitize_formula($texexp);
|
||||
$texexp = escapeshellarg($texexp);
|
||||
|
||||
if ((PHP_OS == "WINNT") || (PHP_OS == "WIN32") || (PHP_OS == "Windows")) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
The FLV player is by Jeroen Wijering - www.jeroenwijering.com
|
||||
and included in Moodle by his permission under the GPL.
|
||||
and included in Moodle by his permission under the GNU GPL version 2 or later.
|
||||
|
||||
Thanks, Jeroen!
|
||||
|
||||
Binary file not shown.
Binary file not shown.
+114
-89
@@ -1,10 +1,10 @@
|
||||
|
||||
--------------------------------------------------------------------------
|
||||
January 11, 2004 Version 1.40
|
||||
September 6, 2008 Version 1.70
|
||||
|
||||
m i m e T e X R e a d m e F i l e
|
||||
|
||||
Copyright(c) 2002-2004, John Forkosh Associates, Inc. All rights reserved.
|
||||
Copyright(c) 2002-2008, John Forkosh Associates, Inc. All rights reserved.
|
||||
--------------------------------------------------------------------------
|
||||
|
||||
by: John Forkosh
|
||||
@@ -12,17 +12,21 @@
|
||||
|
||||
This file is part of mimeTeX, which is free software.
|
||||
You may redistribute and/or modify it under the terms
|
||||
of the GNU General Public License, version 2 or later,
|
||||
of the GNU General Public License, version 3 or later,
|
||||
as published by the Free Software Foundation. See
|
||||
http://www.gnu.org/licenses/gpl.html
|
||||
|
||||
Follow the Quick Start instructions immediately below
|
||||
or the detailed instructions in Section III to install
|
||||
mimeTeX on your machine, and then point your browser to
|
||||
http://www.yourdomain.com/mimetex.html
|
||||
for a complete discussion, including demo/tutorial and
|
||||
reference. Installation problems? Point your browser
|
||||
to my page at
|
||||
MimeTeX is discussed and illustrated online at
|
||||
its homepage
|
||||
http://www.forkosh.com/mimetex.html
|
||||
Or you can follow the Quick Start instructions below
|
||||
(or the more detailed instructions in Section III)
|
||||
to immediately install mimeTeX on your own machine.
|
||||
Then point your browser to
|
||||
http://www.yourdomain.com/mimetex.html
|
||||
for a demo/tutorial and reference.
|
||||
Installation problems? Point your browser to
|
||||
mimeTeX's homepage
|
||||
http://www.forkosh.com/mimetex.html
|
||||
then click its "full mimeTeX manual" link and see
|
||||
Section II.
|
||||
@@ -31,57 +35,63 @@
|
||||
I. QUICK START
|
||||
------------------------------------------------------------------------
|
||||
To compile and install mimeTeX
|
||||
o unzip mimetex.zip in any convenient working directory
|
||||
o to produce an executable that emits anti-aliased gif images
|
||||
* unzip mimetex.zip in any convenient working directory
|
||||
* to produce an executable that emits anti-aliased
|
||||
gif images (recommended)
|
||||
cc -DAA mimetex.c gifsave.c -lm -o mimetex.cgi
|
||||
-or- for gif images without anti-aliasing
|
||||
cc -DGIF mimetex.c gifsave.c -lm -o mimetex.cgi
|
||||
-or- to produce an executable that emits mime xbitmaps
|
||||
cc -DXBITMAP mimetex.c -lm -o mimetex.cgi
|
||||
o mv mimetex.cgi to your server's cgi-bin/ directory
|
||||
o mv mimetex.html to your server's htdocs/ directory
|
||||
o if the relative path from htdocs to cgi-bin isn't
|
||||
(For Windows, see "Compile Notes" in Section III below.)
|
||||
* mv mimetex.cgi to your server's cgi-bin/ directory
|
||||
* mv mimetex.html to your server's htdocs/ directory
|
||||
* if the relative path from htdocs to cgi-bin isn't
|
||||
../cgi-bin then edit mimetex.html and change the
|
||||
few dozen occurrences as necessary
|
||||
To quickly learn about mimeTeX
|
||||
o point your browser to www.yourdomain.com/mimetex.html
|
||||
few dozen occurrences as necessary.
|
||||
Then, to quickly learn more about mimeTeX
|
||||
* point your browser to www.yourdomain.com/mimetex.html
|
||||
Any problems with the above?
|
||||
o read the more detailed instructions in Section III below,
|
||||
or see www.forkosh.com/mimetex.html
|
||||
* read the more detailed instructions below,
|
||||
or see http://www.forkosh.com/mimetex.html
|
||||
|
||||
|
||||
II. INTRODUCTION
|
||||
------------------------------------------------------------------------
|
||||
MimeTeX is licensed under the gpl. It parses LaTeX math expressions,
|
||||
emitting either gif images or mime xbitmaps of them, rather than the
|
||||
usual TeX dvi's. And mimeTeX is an entirely separate little program
|
||||
that doesn't use TeX in any way. Therefore, mimeTeX images are easily
|
||||
inserted directly into html documents using a standard html <img> tag,
|
||||
<img src="../cgi-bin/mimetex.cgi?f(x)=\int_{-\infty}^x~e^{-t^2}dt"
|
||||
border=0 align=absmiddle>
|
||||
without intermediate dvi-to-gif conversion, and without storing lots
|
||||
of little gif image files, one file for each converted expression.
|
||||
This makes your web site and html documents more easily maintained.
|
||||
|
||||
Thus, mimeTeX is primarily intended to help you write native html
|
||||
documents containing math. In this sense it's a kind of "lightweight"
|
||||
alternative to MathML, with the advantage that mimeTeX preserves LaTeX
|
||||
syntax, and works with any browser and server.
|
||||
MimeTeX, licensed under the gpl, lets you easily embed LaTeX math in
|
||||
your html pages. It parses a LaTeX math expression and immediately
|
||||
emits the corresponding gif image, rather than the usual TeX dvi.
|
||||
And mimeTeX is an entirely separate little program that doesn't
|
||||
use TeX or its fonts in any way. It's just one cgi that you put in
|
||||
your site's cgi-bin/ directory, with no other dependencies.
|
||||
So mimeTeX is very easy to install. And it's equally easy to use.
|
||||
Just place an html <img> tag in your document wherever you want to
|
||||
see the corresponding LaTeX expression. For example,
|
||||
<img src="../cgi-bin/mimetex.cgi?f(x)=\int_{-\infty}^x~e^{-t^2}dt"
|
||||
border=0 align=absmiddle>
|
||||
generates and displays the corresponding gif image on-the-fly,
|
||||
wherever you put that <img> tag. MimeTeX doesn't need intermediate
|
||||
dvi-to-gif conversion, and it doesn't clutter your filesystem with
|
||||
separate little gif files for each converted expression. (Optional
|
||||
image caching does store gif files, and subsequently reads them as
|
||||
needed, rather than re-rendering the same images every time a page
|
||||
is reloaded.)
|
||||
|
||||
|
||||
III. COMPILATION AND INSTALLATION
|
||||
------------------------------------------------------------------------
|
||||
I've comnpiled and run mimeTeX under Linux and NetBSD using gcc.
|
||||
The source code is entirely ansi-standard C, and should compile
|
||||
I've built and run mimeTeX under Linux and NetBSD using gcc.
|
||||
The source code is ansi-standard C, and should compile
|
||||
and execute under all environments without any change whatsoever.
|
||||
Build instructions below are for Unix. Modify them as necessary
|
||||
for your particular situation.
|
||||
Build instructions below are for Unix. Modify them as necessary
|
||||
for your particular situation. Note the -DWINDOWS switch if
|
||||
applicable.
|
||||
|
||||
Unzip mimetex.zip in any convenient working directory.
|
||||
You should now have files
|
||||
Your working directory should now contain
|
||||
mimetex.zip your gnu zipped mimeTeX distribution containing...
|
||||
README this file (see mimetex.html for demo/tutorial)
|
||||
LICENSE GPL license, under which you may use mimeTeX
|
||||
COPYING GPL license, under which you may use mimeTeX
|
||||
mimetex.c mimeTeX source program and all required functions
|
||||
mimetex.h header file for mimetex.c (and for gfuntype.c)
|
||||
gfuntype.c parses output from gftype -i and writes bitmap data
|
||||
@@ -93,32 +103,35 @@ III. COMPILATION AND INSTALLATION
|
||||
Conversion for Windows, Macs, VMS, etc, can usually be accomplished
|
||||
with unzip's -a option, i.e., unzip -a mimetex.zip
|
||||
|
||||
Now, to produce an executable that emits anti-aliased gif images
|
||||
(which is how the "official" www.forkosh.com/mimetex.html page
|
||||
is displayed), compile mimetex with the command
|
||||
cc -DAA mimetex.c gifsave.c -lm -o mimetex.cgi
|
||||
Now, to compile a mimeTeX executable that emits anti-aliased gif
|
||||
images (recommended for most uses), type the command
|
||||
cc -DAA mimetex.c gifsave.c -lm -o mimetex.cgi
|
||||
|
||||
Or, to produce an executable that emits gif images
|
||||
without anti-aliasing, compile mimetex with the command
|
||||
cc -DGIF mimetex.c gifsave.c -lm -o mimetex.cgi
|
||||
Or, for an executable that emits gif images without
|
||||
anti-aliasing,
|
||||
cc -DGIF mimetex.c gifsave.c -lm -o mimetex.cgi
|
||||
|
||||
Alternatively, for an executable that emits mime xbitmaps,
|
||||
just compile mimetex with the command
|
||||
cc -DXBITMAP mimetex.c -lm -o mimetex.cgi
|
||||
Alternatively, to compile a mimeTeX executable that emits
|
||||
mime xbitmaps, just type the command
|
||||
cc -DXBITMAP mimetex.c -lm -o mimetex.cgi
|
||||
|
||||
Several additional command-line options that you may find
|
||||
useful are discussed in Section IIc (href="#options")
|
||||
of mimetex.html .
|
||||
Compile Notes:
|
||||
* If (and only if) you're compiling a Windows executable
|
||||
with the -DAA or -DGIF option (but not -DXBITMAP), then
|
||||
add -DWINDOWS also. For example,
|
||||
cc -DAA -DWINDOWS mimetex.c gifsave.c -lm -o mimetex.cgi
|
||||
The above Unix-like syntax works with MinGW (http://www.mingw.org)
|
||||
and djgpp (http://www.delorie.com/djgpp/) Windows compilers, but
|
||||
probably not with most others, where it's only intended as a
|
||||
"template".
|
||||
* Several additional command-line options that you may find
|
||||
useful are discussed in Section IId (href="#options")
|
||||
of your mimetex.html page.
|
||||
|
||||
That's all there is to building mimeTeX. You can now test mimetex.cgi
|
||||
from the Unix command line by typing, e.g.,
|
||||
./mimetex.cgi x^2+y^2
|
||||
which should emit an ascii raster something like the left-hand
|
||||
illustration. And if you've compiled mimeTeX with the anti-aliasing
|
||||
-DAA option, then you'll also see the right-hand illustration.
|
||||
It shows asterisks in the same positions as the left-hand illustration,
|
||||
and anti-aliased grayscale colormap indexes assigned to neighboring
|
||||
pixels. And you'll also be shown the actual rgb value for each index.
|
||||
That's all there is to building mimeTeX. You can now test your
|
||||
mimetex.cgi executable from the Unix command line by typing, e.g.,
|
||||
./mimetex.cgi "x^2+y^2"
|
||||
which should emit two ascii rasters something like the following
|
||||
Ascii dump of bitmap image... Hex dump of colormap indexes...
|
||||
........**..................**.. .......1**1................1**1.
|
||||
.......*..*.....*..........*..*. .......*23*.....*..........*23*.
|
||||
@@ -132,34 +145,50 @@ III. COMPILATION AND INSTALLATION
|
||||
................*....**......... ................*....**1........
|
||||
The 5 colormap indexes denote rgb...
|
||||
.-->255 1-->196 2-->186 3-->177 *-->0
|
||||
If you get much fancier than x^2+y^2, remember that many characters have
|
||||
to be escaped from the Unix command line, e.g., x\<y or f\(x\)=x^2, etc.
|
||||
Of course, you won't need these extra escapes when running mimetex from
|
||||
a browser.
|
||||
The right-hand illustration shows asterisks in the same positions as
|
||||
the left-hand one, along with anti-aliased grayscale colormap indexes
|
||||
assigned to neighboring pixels, and with the rgb value for each
|
||||
index. Just typing ./mimetex.cgi without an argument should produce
|
||||
ascii rasters for the default expression f(x)=x^2. If you see the
|
||||
two ascii rasters then your binary's good, so mv it to your server's
|
||||
cgi-bin/ directory and set permissions as necessary.
|
||||
|
||||
Once mimetex.cgi is working (and you're done playing with it),
|
||||
mv it to your server's cgi-bin/ directory, where cgi programs
|
||||
are expected (and chmod/chown it if necessary). Then mv
|
||||
mimetex.html to your server's htdocs/ directory. Now point
|
||||
your browser to www.yourdomain.com/mimetex.html , and it should
|
||||
be rendered exactly like my page at www.forkosh.com/mimetex.html .
|
||||
One "gotcha": the two directories are typically of the form
|
||||
somewhere/www/cgi-bin/ and somewhere/www/htdocs/ , so I set up
|
||||
mimtex.html to get mimetex.cgi from the relative path ../cgi-bin/ .
|
||||
If your directories are non-conforming, you may have to edit the
|
||||
few dozen occurrences of ../cgi-bin/mimetex.cgi in mimetex.html
|
||||
(globally changing ../cgi-bin/mimetex.cgi should work).
|
||||
Sometimes a suitable symlink works; if not, you'll have to edit.
|
||||
Once mimetex.cgi is working, mv it to your server's cgi-bin/ directory
|
||||
(wherever cgi programs are expected), and chmod/chown it as necessary.
|
||||
Then mv mimetex.html to your server's htdocs/ directory. Now point
|
||||
your browser to www.yourdomain.com/mimetex.html and you should see
|
||||
your mimeTeX user's manual reference page.
|
||||
|
||||
Either way, once mimetex.html displays properly, and you've reviewed
|
||||
the tutorial it contains, you can begin writing html documents using
|
||||
mimetex.cgi to render your math.
|
||||
Install Notes:
|
||||
* These two directories are typically of the form
|
||||
somewhere/www/cgi-bin/ and somewhere/www/htdocs/
|
||||
so I set up mimtex.html to access mimetex.cgi from
|
||||
the relative path ../cgi-bin/ If your directories
|
||||
are non-conforming, you may have to edit the few dozen
|
||||
occurrences of ../cgi-bin/mimetex.cgi in mimetex.html
|
||||
Sometimes a suitable symlink works. If not, you'll
|
||||
have to edit. In that case, globally changing
|
||||
../cgi-bin/mimetex.cgi often works.
|
||||
* Either way, once mimetex.html displays properly, you can
|
||||
assume everything is working, and can begin authoring html
|
||||
documents using mimetex.cgi to render your own math.
|
||||
|
||||
|
||||
IV. REVISION HISTORY
|
||||
------------------------------------------------------------------------
|
||||
01/11/04 J.Forkosh version 1.40 beta released on www.forkosh.com
|
||||
LaTeX compatibility and various new features
|
||||
A more detailed account of mimeTeX's revision history
|
||||
is maintained at http://www.forkosh.com/mimetexchangelog.html
|
||||
---
|
||||
09/06/08 J.Forkosh version 1.70 released.
|
||||
11/30/04 J.Forkosh version 1.60 released
|
||||
10/02/04 J.Forkosh version 1.50 released on CTAN with various new
|
||||
features and fixes, and updated documentation.
|
||||
07/18/04 J.Forkosh version 1.40 re-released on CTAN with minor
|
||||
changes, e.g., \mathbb font and nested \array's
|
||||
now supported.
|
||||
03/21/04 J.Forkosh version 1.40 released on CTAN, with improved
|
||||
LaTeX compatibility, various new features and
|
||||
fixes, including fix to work under Windows.
|
||||
12/21/03 J.Forkosh version 1.30 released on CTAN, with improved
|
||||
LaTeX compatibility and anti-aliasing, various new
|
||||
features, and thoroughly updated documentation.
|
||||
@@ -183,9 +212,5 @@ V. CONCLUDING REMARKS
|
||||
I hope you find mimeTeX useful. If so, a contribution to your
|
||||
country's TeX Users Group, or to the GNU project, is suggested,
|
||||
especially if you're a company that's currently profitable.
|
||||
|
||||
If you also like mimeTeX's source, I'm an independent contractor
|
||||
incorporated in the US as John Forkosh Associates, Inc. A resume
|
||||
is at www.forkosh.com or email john@forkosh.com
|
||||
========================= END-OF-FILE README ===========================
|
||||
|
||||
|
||||
@@ -44,9 +44,11 @@
|
||||
* @return string the latex document
|
||||
*/
|
||||
function construct_latex_document( $formula, $fontsize=12 ) {
|
||||
// $fontsize don't affects to formula's size. $density can change size
|
||||
|
||||
global $CFG;
|
||||
|
||||
$formula = tex_sanitize_formula($formula);
|
||||
|
||||
// $fontsize don't affects to formula's size. $density can change size
|
||||
$doc = "\\documentclass[{$fontsize}pt]{article}\n";
|
||||
$doc .= $CFG->filter_tex_latexpreamble;
|
||||
$doc .= "\\pagestyle{empty}\n";
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
<?php //$Id$
|
||||
|
||||
function tex_sanitize_formula($texexp) {
|
||||
/// Check $texexp against blacklist (whitelisting could be more complete but also harder to maintain)
|
||||
$tex_blacklist = array(
|
||||
'include','command','loop','repeat','open','toks','output',
|
||||
'input','catcode','name','^^',
|
||||
'\def','\edef','\gdef','\xdef',
|
||||
'\every','\errhelp','\errorstopmode','\scrollmode','\nonstopmode',
|
||||
'\batchmode','\read','\write','csname','\newhelp','\uppercase',
|
||||
'\lowercase','\relax','\aftergroup',
|
||||
'\afterassignment','\expandafter','\noexpand','\special',
|
||||
'\let', '\futurelet','\else','\fi','\chardef','\makeatletter','\afterground',
|
||||
'\noexpand','\line','\mathcode','\item','\section','\mbox','\declarerobustcommand'
|
||||
);
|
||||
|
||||
return str_ireplace($tex_blacklist, 'forbiddenkeyword', $texexp);
|
||||
}
|
||||
|
||||
/**
|
||||
* Purge all caches when settings changed.
|
||||
*/
|
||||
function filter_tex_updatedcallback($name) {
|
||||
global $CFG;
|
||||
|
||||
if (file_exists("$CFG->dataroot/filter/tex")) {
|
||||
remove_dir("$CFG->dataroot/filter/tex");
|
||||
}
|
||||
if (file_exists("$CFG->dataroot/filter/algebra")) {
|
||||
remove_dir("$CFG->dataroot/filter/algebra");
|
||||
}
|
||||
if (file_exists("$CFG->dataroot/temp/latex")) {
|
||||
remove_dir("$CFG->dataroot/temp/latex");
|
||||
}
|
||||
|
||||
delete_records('cache_filters', 'filter', 'tex');
|
||||
delete_records('cache_filters', 'filter', 'algebra');
|
||||
}
|
||||
|
||||
?>
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+4
-1
@@ -20,8 +20,9 @@
|
||||
disable_debugging();
|
||||
|
||||
require_once($CFG->libdir.'/filelib.php');
|
||||
require_once($CFG->dirroot.'/filter/tex/lib.php');
|
||||
require_once($CFG->dirroot.'/filter/tex/latex.php');
|
||||
require_once('defaultsettings.php' );
|
||||
require_once('latex.php');
|
||||
|
||||
$CFG->texfilterdir = 'filter/tex';
|
||||
$CFG->teximagedir = 'filter/tex';
|
||||
@@ -68,6 +69,8 @@
|
||||
$texexp = str_replace('>','>',$texexp);
|
||||
$texexp = preg_replace('!\r\n?!',' ',$texexp);
|
||||
$texexp = '\Large ' . $texexp;
|
||||
|
||||
$texexp = tex_sanitize_formula($texexp);
|
||||
$texexp = escapeshellarg($texexp);
|
||||
|
||||
if ((PHP_OS == "WINNT") || (PHP_OS == "WIN32") || (PHP_OS == "Windows")) {
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
Description of mimeTeX v 1.70 import into Moodle
|
||||
|
||||
Compiling mimeTeX:
|
||||
|
||||
===Windows===
|
||||
1/ get "Automated MinGW Installer" from https://sourceforge.net/projects/mingw/files/
|
||||
2/ install mingw
|
||||
3/ go into directory with extracted source files
|
||||
4/ execute "c:\mingw\bin\gcc -DAA -DWINDOWS mimetex.c gifsave.c -lm -o mimetex.exe"
|
||||
|
||||
===Linux===
|
||||
1/ install gcc
|
||||
2/ go into directory with extracted source files
|
||||
3/ execute "cc -DAA mimetex.c gifsave.c -lm -o mimetex.linux"
|
||||
|
||||
===FreeBSD===
|
||||
1/ go into directory with extracted source files
|
||||
2/ execute "cc -DAA mimetex.c gifsave.c -lm -o mimetex.freebsd"
|
||||
|
||||
===Apple OSX===
|
||||
1/ install gcc
|
||||
2/ go into directory with extracted source files
|
||||
3/ execute "cc -DAA mimetex.c gifsave.c -lm -o mimetex.darwin"
|
||||
|
||||
skodak
|
||||
@@ -1,10 +1,8 @@
|
||||
<?PHP // $Id$
|
||||
<?php // $Id$
|
||||
// This function fetches math. images from the data directory
|
||||
// If not, it obtains the corresponding TeX expression from the cache_tex db table
|
||||
// and uses mimeTeX to create the image file
|
||||
|
||||
$nomoodlecookie = true; // Because it interferes with caching
|
||||
|
||||
require_once("../../config.php");
|
||||
|
||||
if (empty($CFG->textfilters)) {
|
||||
@@ -16,9 +14,14 @@
|
||||
}
|
||||
}
|
||||
|
||||
require_once($CFG->dirroot.'/filter/tex/lib.php');
|
||||
|
||||
$CFG->texfilterdir = "filter/tex";
|
||||
$CFG->teximagedir = "filter/tex";
|
||||
|
||||
require_login();
|
||||
require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM), $USER->id); /// Required cap to run this. MDL-18552
|
||||
|
||||
$query = urldecode($_SERVER['QUERY_STRING']);
|
||||
error_reporting(E_ALL);
|
||||
|
||||
@@ -111,6 +114,7 @@
|
||||
}
|
||||
$commandpath = "";
|
||||
$cmd = "";
|
||||
$texexp = tex_sanitize_formula($texexp);
|
||||
$texexp = escapeshellarg($texexp);
|
||||
switch (PHP_OS) {
|
||||
case "Linux":
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
$nomoodlecookie = true; // Because it interferes with caching
|
||||
|
||||
require_once("../../config.php");
|
||||
require_once($CFG->dirroot.'/filter/tex/lib.php');
|
||||
|
||||
if (empty($CFG->textfilters)) {
|
||||
error ('Filter not enabled!');
|
||||
@@ -32,6 +33,7 @@
|
||||
make_upload_directory($CFG->teximagedir);
|
||||
}
|
||||
$pathname = "$CFG->dataroot/$CFG->teximagedir/$image";
|
||||
$texexp = tex_sanitize_formula($texexp);
|
||||
$texexp = escapeshellarg($texexp);
|
||||
|
||||
switch (PHP_OS) {
|
||||
|
||||
+3
-3
@@ -237,7 +237,7 @@ function grade_get_formatted_grades() {
|
||||
}
|
||||
$all_categories["$cur_category"]["$instance->name"]['grade_against'] = $all_categories["$cur_category"]["$instance->name"]['scaled_max'];
|
||||
if (!isset($all_categories["$cur_category"]['stats']['weight'])) {
|
||||
$weight = grade_get_category_weight($course->id, $cur_category);
|
||||
$weight = grade_get_category_weight($course->id, addslashes($cur_category));
|
||||
$all_categories["$cur_category"]['stats']['weight'] = $weight->weight;
|
||||
}
|
||||
|
||||
@@ -247,7 +247,7 @@ function grade_get_formatted_grades() {
|
||||
$all_categories["$cur_category"]["$instance->name"]['modname'] = $modname->name;
|
||||
|
||||
// get bonus points and drop the x lowest
|
||||
$drop = get_record('grade_category', 'courseid', $course->id, 'name', $cur_category);
|
||||
$drop = get_record('grade_category', 'courseid', $course->id, 'name', addslashes($cur_category));
|
||||
$all_categories["$cur_category"]['stats']['drop'] = $drop->drop_x_lowest;
|
||||
$all_categories["$cur_category"]['stats']['bonus_points'] = $drop->bonus_points;
|
||||
}
|
||||
@@ -2261,7 +2261,7 @@ function grade_set_grade_weights() {
|
||||
$submitted_category = optional_param($form_catname);
|
||||
if (is_numeric($submitted_category)) {
|
||||
// see if there is a weight if so see if it needs to be updated
|
||||
$weight = grade_get_category_weight($course->id, $category->name);
|
||||
$weight = grade_get_category_weight($course->id, addslashes($category->name));
|
||||
if ($weight) {
|
||||
if ($weight->weight != $submitted_category)
|
||||
{
|
||||
|
||||
@@ -279,6 +279,7 @@ $string['htmleditor'] = 'HTML Editor';
|
||||
$string['http'] = 'HTTP';
|
||||
$string['httpsecurity'] = 'HTTP security';
|
||||
$string['iconvrecommended'] = 'Installing the optional ICONV library is highly recommended in order to improve site performance, particularly if your site is supporting non-latin languages.';
|
||||
$string['ignore'] = 'Ignore';
|
||||
$string['importlangreminder'] = 'The database migration process is commencing. You will need to <b>log in again</b> for the upgrade to take effect. Please install unicode language packs as soon as possible from Admin->Lang->Lang Import Utility <b>after</b> the database migration process is completed.';
|
||||
$string['importtimezones'] = 'Update complete list of timezones';
|
||||
$string['importtimezonescount'] = '$a->count entries imported from $a->source';
|
||||
@@ -427,6 +428,7 @@ $string['stickyblockscourseview'] = 'Course page';
|
||||
$string['stickyblocksduplicatenotice'] = 'If any block you add here is already present in a particular page, it will result in a duplicate.<br />Only the pinned block will be non-editable, the duplicate will still be editable.';
|
||||
$string['stickyblocksmymoodle'] = 'My moodle';
|
||||
$string['stickyblockspagetype'] = 'Page type to configure';
|
||||
$string['spamcleaner'] = 'Spam cleaner';
|
||||
$string['systempaths'] = 'System Paths';
|
||||
$string['tabselectedtofront'] = 'On tables with tabs, should the row with the currently selected tag be placed at the front';
|
||||
$string['tabselectedtofronttext'] = 'Bring selected tab row to front';
|
||||
@@ -463,6 +465,7 @@ $string['upgradingdata'] = 'Upgrading data';
|
||||
$string['upgradinglogs'] = 'Upgrading logs';
|
||||
$string['upwards'] = 'upwards';
|
||||
$string['usehtmleditor'] = 'Use HTML editor';
|
||||
$string['user'] = 'User';
|
||||
$string['useraccountupdated'] = 'User updated';
|
||||
$string['userlist'] = 'Browse list of users';
|
||||
$string['userpolicies'] = 'User policies';
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
<li><a href="help.php?module=hotpot&file=reportcontent.html">Report content</a></li>
|
||||
<li><a href="help.php?module=hotpot&file=reportformat.html">Report format</a></li>
|
||||
<li><a href="help.php?module=hotpot&file=responsestable.html">Responses table</a></li>
|
||||
<li><a href="help.php?module=hotpot&file=reportselector.html">Selecting a report</a></li>
|
||||
<li><a href="help.php?module=hotpot&file=shownextquiz.html">Show next quiz</a></li>
|
||||
<li><a href="help.php?module=hotpot&file=studentfeedback.html">Student feedback</a></li>
|
||||
<li><a href="help.php?module=hotpot&file=updatequizchain.html">Update quiz chain</a></li>
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
$string['spamauto'] = 'Autodetect common spam patterns';
|
||||
$string['spamcannotdelete'] = 'Cannot delete this user';
|
||||
$string['spamcannotfinduser'] = 'No users matching your search';
|
||||
$string['spamcleaner'] = 'Spam cleaner';
|
||||
$string['spamcleanerintro'] = 'This script allows you to search all user profiles for certain strings and then delete those accounts which are obviously created by spammers. You can search for multiple keywords using commas (eg casino, porn)<br /><br />Moodle docs has more information about <a href=\"http://docs.moodle.org/en/Reducing_spam_in_Moodle\">Reducing spam in Moodle</a>.';
|
||||
$string['spamdesc'] = 'Description';
|
||||
$string['spamdeleteall'] = 'Delete all these user accounts';
|
||||
$string['spamdeleteconfirm'] = 'Are you sure you want to delete this entry? You can not undo this.';
|
||||
$string['spamdeleteallconfirm'] = 'Are you sure you want to delete all these user accounts? You can not undo this.';
|
||||
$string['spameg'] = 'eg: casino, porn, xxx ';
|
||||
$string['spamfromblog'] = 'From blog post:';
|
||||
$string['spaminvalidresult'] = 'Unknown but invalid result';
|
||||
$string['spamoperation'] = 'Operation';
|
||||
$string['spamresult'] = 'Results of searching user profiles containing: ';
|
||||
$string['spamsearch'] = 'Search for these keywords';
|
||||
?>
|
||||
+2
-5
@@ -1412,11 +1412,8 @@ function add_to_log($courseid, $module, $action, $url='', $info='', $cm=0, $user
|
||||
|
||||
if (defined('MDL_PERFDB')) { global $PERF ; $PERF->dbqueries++; $PERF->logwrites++;};
|
||||
|
||||
if ($CFG->type = 'oci8po') {
|
||||
if (empty($info)) {
|
||||
$info = ' ';
|
||||
}
|
||||
}
|
||||
$info = empty($info) ? sql_empty() : $info; // Use proper empties for each database
|
||||
$url = empty($url) ? sql_empty() : $url;
|
||||
|
||||
$result = $db->Execute('INSERT INTO '. $CFG->prefix .'log (time, userid, course, ip, module, cmid, action, url, info)
|
||||
VALUES (' . "'$timenow', '$userid', '$courseid', '$REMOTE_ADDR', '$module', '$cm', '$action', '$url', '$info')");
|
||||
|
||||
@@ -85,6 +85,11 @@ function xmldb_main_upgrade($oldversion=0) {
|
||||
$db->debug = true;
|
||||
}
|
||||
|
||||
if ($result && $oldversion < 2006101071) {
|
||||
require_once("$CFG->dirroot/filter/tex/lib.php");
|
||||
filter_tex_updatedcallback(null);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
+3
-1
@@ -1477,9 +1477,11 @@ function update_record($table, $dataobject) {
|
||||
|
||||
global $db, $CFG, $record_cache;
|
||||
|
||||
if (! isset($dataobject->id) ) {
|
||||
// integer value in id propery required
|
||||
if (empty($dataobject->id)) {
|
||||
return false;
|
||||
}
|
||||
$dataobject->id = (int)$dataobject->id;
|
||||
|
||||
// Remove this record from record cache since it will change
|
||||
if (!empty($CFG->enablerecordcache) && isset($record_cache[$table][$dataobject->id])) {
|
||||
|
||||
+1
-1
@@ -513,7 +513,7 @@ if (!function_exists('file_get_contents')) {
|
||||
* @param $location the path to remove.
|
||||
*/
|
||||
function fulldelete($location) {
|
||||
if (is_dir($location)) {
|
||||
if (is_dir($location) and !is_link($location)) {
|
||||
$currdir = opendir($location);
|
||||
while (false !== ($file = readdir($currdir))) {
|
||||
if ($file <> ".." && $file <> ".") {
|
||||
|
||||
@@ -404,9 +404,9 @@ class PHPMailer
|
||||
*/
|
||||
function SendmailSend($header, $body) {
|
||||
if ($this->Sender != "")
|
||||
$sendmail = sprintf("%s -oi -f %s -t", $this->Sendmail, $this->Sender);
|
||||
$sendmail = sprintf("%s -oi -f %s -t", escapeshellcmd($this->Sendmail), escapeshellarg($this->Sender));
|
||||
else
|
||||
$sendmail = sprintf("%s -oi -t", $this->Sendmail);
|
||||
$sendmail = sprintf("%s -oi -t", escapeshellcmd($this->Sendmail));
|
||||
|
||||
if(!@$mail = popen($sendmail, "w"))
|
||||
{
|
||||
|
||||
+2
-2
@@ -1670,8 +1670,8 @@ function clean_text($text, $format=FORMAT_MOODLE) {
|
||||
default:
|
||||
|
||||
/// Fix non standard entity notations
|
||||
$text = preg_replace('/(&#[0-9]+)(;?)/', "\\1;", $text);
|
||||
$text = preg_replace('/(&#x[0-9a-fA-F]+)(;?)/', "\\1;", $text);
|
||||
$text = preg_replace('/�*([0-9]+);?/', "&#\\1;", $text);
|
||||
$text = preg_replace('/�*([0-9a-fA-F]+);?/', "&#x\\1;", $text);
|
||||
|
||||
/// Remove tags that are not allowed
|
||||
$text = strip_tags($text, $ALLOWED_TAGS);
|
||||
|
||||
+1
-1
@@ -39,7 +39,7 @@
|
||||
'AND d.id = dr.dataid ' .
|
||||
'AND dr.id = dc.recordid ' .
|
||||
"AND df.type = 'text' " .
|
||||
'AND df.param1 = 1';
|
||||
"AND " . sql_compare_text('df.param1', 1) . " = '1'";
|
||||
|
||||
if (!$datacontents = get_records_sql($sql)) {
|
||||
return $text;
|
||||
|
||||
+1
-1
@@ -362,7 +362,7 @@ function data_generate_default_template(&$data, $template, $recordid=0, $form=fa
|
||||
|
||||
if ($update) {
|
||||
$newdata->id = $data->id;
|
||||
$newdata->{$template} = $str;
|
||||
$newdata->{$template} = addslashes($str);
|
||||
if (!update_record('data', $newdata)) {
|
||||
notify('Error updating template');
|
||||
} else {
|
||||
|
||||
+6
-1
@@ -2615,7 +2615,12 @@ function forum_file_area_name($post) {
|
||||
}
|
||||
|
||||
function forum_file_area($post) {
|
||||
return make_upload_directory( forum_file_area_name($post) );
|
||||
$path = forum_file_area_name($post);
|
||||
if ($path) {
|
||||
return make_upload_directory($path);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function forum_delete_old_attachments($post, $exception="") {
|
||||
|
||||
+1
-1
@@ -47,7 +47,7 @@
|
||||
$scale_values = make_grades_menu($forum->scale);
|
||||
|
||||
foreach ((array)$data as $postid => $rating) {
|
||||
if ($postid == "id") {
|
||||
if (!is_numeric($postid)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -23,6 +23,8 @@
|
||||
|
||||
// make sure this user is enrolled in this course
|
||||
require_login($course->id);
|
||||
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
|
||||
require_capability('mod/hotpot:attempt', $context, $USER->id);
|
||||
|
||||
$next_url = "$CFG->wwwroot/course/view.php?id=$course->id";
|
||||
$time = time();
|
||||
|
||||
@@ -324,4 +324,14 @@
|
||||
}
|
||||
return $info;
|
||||
}
|
||||
|
||||
// Return content encoded to support interactivities linking.
|
||||
// Called by "backup_encode_absolute_links()" in backup/backuplib.php
|
||||
// Content will be decoded by "hotpot_decode_content_links()"
|
||||
function hotpot_encode_content_links ($content, $preferences) {
|
||||
global $CFG;
|
||||
$base = preg_quote("$CFG->wwwroot/mod/hotpot/", '/');
|
||||
$search = "/($base)([a-z]+).php\?([a-z]+)\=([0-9]+)/";
|
||||
return preg_replace($search, '$@HOTPOT*$2*$3*$4@$', $content);
|
||||
}
|
||||
?>
|
||||
|
||||
@@ -2922,14 +2922,23 @@ hpInterceptClues();
|
||||
hpInterceptChecks();
|
||||
function hpFindForm(formname, w) {
|
||||
if (w==null) w = self;
|
||||
var f = w.document.forms[formname];
|
||||
if (f==null && w.frames) {
|
||||
var f = w.document.getElementById(formname);
|
||||
if (f) {
|
||||
return f;
|
||||
}
|
||||
var f = w.document.forms[formname];
|
||||
if (f) {
|
||||
return f;
|
||||
}
|
||||
if (w.frames) {
|
||||
for (var i=0; i<w.frames.length; i++) {
|
||||
f = hpFindForm(formname, w.frames[i]);
|
||||
if (f) break;
|
||||
var f = hpFindForm(formname, w.frames[i]);
|
||||
if (f) {
|
||||
return f;
|
||||
}
|
||||
}
|
||||
}
|
||||
return f;
|
||||
return null;
|
||||
}
|
||||
function Finish(quizstatus) {
|
||||
var mark = hpScore();
|
||||
|
||||
+22
-12
@@ -690,7 +690,7 @@ function hotpot_get_titles_and_next_ex(&$hotpot, $filepath, $get_next=false) {
|
||||
if ($get_next) {
|
||||
if (preg_match('|<div[^>]*class="NavButtonBar"[^>]*>(.*?)</div>|is', $source, $matches)) {
|
||||
$navbuttonbar = $matches[1];
|
||||
if (preg_match_all('|<button[^>]*class="NavButton"[^>]*onclick="'."location='([^']*)'".'[^"]*"[^>]*>|is', $navbuttonbar, $matches)) {
|
||||
if (preg_match_all('|<button[^>]*onclick="'."location='([^']*)'".'[^"]*"[^>]*>|is', $navbuttonbar, $matches)) {
|
||||
$lastbutton = count($matches[0])-1;
|
||||
$next = $matches[1][$lastbutton];
|
||||
}
|
||||
@@ -1666,19 +1666,21 @@ class hotpot_xml_quiz extends hotpot_xml_tree {
|
||||
$this->html = preg_replace('|</head>|i', $script.'</head>', $this->html, 1);
|
||||
}
|
||||
function insert_submission_form($attemptid, $startblock, $endblock, $keep_contents=false) {
|
||||
$form_name = 'store';
|
||||
$form_id = 'store';
|
||||
$form_fields = ''
|
||||
. '<fieldset style="display:none">'
|
||||
. '<input type="hidden" name="attemptid" value="'.$attemptid.'" />'
|
||||
. '<input type="hidden" name="starttime" value="" />'
|
||||
. '<input type="hidden" name="endtime" value="" />'
|
||||
. '<input type="hidden" name="mark" value="" />'
|
||||
. '<input type="hidden" name="detail" value="" />'
|
||||
. '<input type="hidden" name="status" value="" />'
|
||||
. '</fieldset>'
|
||||
;
|
||||
$this->insert_form($startblock, $endblock, $form_name, $form_fields, $keep_contents);
|
||||
$this->insert_form($startblock, $endblock, $form_id, $form_fields, $keep_contents);
|
||||
}
|
||||
function insert_giveup_form($attemptid, $startblock, $endblock, $keep_contents=false) {
|
||||
$form_name = ''; // no <form> tag will be generated
|
||||
$form_id = ''; // no <form> tag will be generated
|
||||
$form_fields = ''
|
||||
. '<button onclick="Finish('.HOTPOT_STATUS_ABANDONED.')" class="FuncButton" '
|
||||
. 'onfocus="FuncBtnOver(this)" onblur="FuncBtnOut(this)" '
|
||||
@@ -1686,17 +1688,22 @@ class hotpot_xml_quiz extends hotpot_xml_tree {
|
||||
. 'onmousedown="FuncBtnDown(this)" onmouseup="FuncBtnOut(this)">'
|
||||
. get_string('giveup', 'hotpot').'</button>'
|
||||
;
|
||||
$this->insert_form($startblock, $endblock, $form_name, $form_fields, $keep_contents, true);
|
||||
$this->insert_form($startblock, $endblock, $form_id, $form_fields, $keep_contents, true);
|
||||
}
|
||||
function insert_form($startblock, $endblock, $form_name, $form_fields, $keep_contents, $center=false) {
|
||||
function insert_form($startblock, $endblock, $form_id, $form_fields, $keep_contents, $center=false) {
|
||||
global $CFG;
|
||||
$search = '#('.preg_quote($startblock).')(.*?)('.preg_quote($endblock).')#s';
|
||||
$replace = $form_fields;
|
||||
if ($keep_contents) {
|
||||
$replace .= '\\2';
|
||||
}
|
||||
if ($form_name) {
|
||||
$replace = '<form action="'.$CFG->wwwroot.'/mod/hotpot/attempt.php" method="POST" name="'.$form_name.'" target="'.$CFG->framename.'">'.$replace.'</form>';
|
||||
if (! empty($CFG->framename)) {
|
||||
$frametarget = ' onsubmit="'."this.target='$CFG->framename';".'"';
|
||||
} else {
|
||||
$frametarget = '';
|
||||
}
|
||||
if ($form_id) {
|
||||
$replace = '<form action="'.$CFG->wwwroot.'/mod/hotpot/attempt.php" method="post" id="'.$form_id.'"'.$frametarget.'>'.$replace.'</form>';
|
||||
}
|
||||
if ($center) {
|
||||
$replace = '<div style="margin-left:auto; margin-right:auto; text-align: center;">'.$replace.'</div>';
|
||||
@@ -1721,7 +1728,10 @@ class hotpot_xml_quiz extends hotpot_xml_tree {
|
||||
$quote = '["'."']?"; // single, double, or no quote
|
||||
|
||||
// patterns to media files types and paths
|
||||
$filetype = "avi|mpeg|mpg|mp3|mov|wmv|swf|flv";
|
||||
$filetype = "avi|mpeg|mpg|mp3|mov|wmv|flv";
|
||||
if ($CFG->filter_mediaplugin_enable_swf) {
|
||||
$filetype .= '|swf';
|
||||
}
|
||||
$filepath = ".*?\.($filetype)";
|
||||
|
||||
$tagopen = '(?:(<)|(\\\\u003C))'; // left angle-bracket (uses two parenthese)
|
||||
@@ -1736,10 +1746,10 @@ class hotpot_xml_quiz extends hotpot_xml_tree {
|
||||
$param_url = "/{$tagopen}param{$space}name=$quote(?:movie|src|url)$quote{$space}value=$quote($filepath)$quote.*?$tagclose/is";
|
||||
|
||||
// pattern to match <a> tags which link to multimedia files
|
||||
$link_url = "/{$tagopen}a{$space}href=$quote($filepath)$quote.*?$tagclose.*?$tagreopen\/A$tagclose/is";
|
||||
$link_url = "/{$tagopen}a{$space}href=$quote($filepath)$quote.*?$tagclose.*?$tagreopen\/a$tagclose/is";
|
||||
|
||||
// extract <object> tags
|
||||
preg_match_all("/{$tagopen}object\s.*?{$tagclose}(.*?){$tagreopen}\/object{$tagclose}/is", $this->html, $objects);
|
||||
preg_match_all("/{$tagopen}object.*?{$tagclose}(.*?){$tagreopen}\/object{$tagclose}/is", $this->html, $objects);
|
||||
|
||||
$i_max = count($objects[0]);
|
||||
for ($i=0; $i<$i_max; $i++) {
|
||||
@@ -1865,7 +1875,7 @@ function hotpot_convert_url($baseurl, $reference, $url, $stripslashes=true) {
|
||||
}
|
||||
|
||||
// is this an absolute url? (or javascript pseudo url)
|
||||
if (preg_match('%^(http://|/|javascript:)%i', $url)) {
|
||||
if (preg_match('%^(http://|https://|/|javascript:)%i', $url)) {
|
||||
// do nothing
|
||||
|
||||
// has this relative url already been converted?
|
||||
|
||||
+50
-11
@@ -362,17 +362,14 @@ function hotpot_restore_record(&$restore, $status, &$xml, $table, $foreign_keys,
|
||||
foreach ($table_columns[$table] as $column) {
|
||||
if ($column->not_null) {
|
||||
$name = $column->name;
|
||||
if ($name<>'id' && empty($record->$name)) {
|
||||
if (isset($column->default_value)) {
|
||||
$default = $column->default_value;
|
||||
} else {
|
||||
if (preg_match('/int|decimal|double|float|time|year/i', $column->type)) {
|
||||
$default = 0;
|
||||
} else {
|
||||
$default = '';
|
||||
}
|
||||
}
|
||||
$record->$name = $default;
|
||||
if ($name=='id' || (isset($record->$name) && ! is_null($record->$name))) {
|
||||
// do nothing
|
||||
} else if (isset($column->default_value)) {
|
||||
$record->$name = $column->default_value;
|
||||
} else if (preg_match('/int|decimal|double|float|time|year/i', $column->type)) {
|
||||
$record->$name = 0;
|
||||
} else {
|
||||
$record->$name = '';
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -480,4 +477,46 @@ function hotpot_restore_logs($restore, $log) {
|
||||
} // end switch
|
||||
return $status ? $log : false;
|
||||
}
|
||||
|
||||
function hotpot_decode_content_links($content, $restore) {
|
||||
$search = '/\$@(HOTPOT)\*([a-z]+)\*([a-z]+)\*([0-9]+)@\$/ise';
|
||||
$replace = 'hotpot_decode_content_link("$2", "$3", "$4", $restore)';
|
||||
return preg_replace($search, $replace, $content);
|
||||
}
|
||||
|
||||
function hotpot_decode_content_link($scriptname, $paramname, $paramvalue, &$restore) {
|
||||
global $CFG;
|
||||
|
||||
$table = '';
|
||||
switch ($paramname) {
|
||||
case 'id':
|
||||
switch ($scriptname) {
|
||||
case 'index':
|
||||
$table = 'course';
|
||||
break;
|
||||
case 'report':
|
||||
case 'review':
|
||||
case 'view':
|
||||
$table = 'course_modules';
|
||||
break;
|
||||
case 'attempt':
|
||||
$table = 'hotpot_attempts';
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 'hp':
|
||||
case 'hotpotid':
|
||||
$table = 'hotpot';
|
||||
break;
|
||||
}
|
||||
|
||||
$new_id = 0;
|
||||
if ($table) {
|
||||
if ($rec = backup_getid($restore->backup_unique_code, $table, $paramvalue)) {
|
||||
$new_id = $rec->new_id;
|
||||
}
|
||||
}
|
||||
|
||||
return "$CFG->wwwroot/mod/hotpot/$scriptname.php?$paramname=$new_id";
|
||||
}
|
||||
?>
|
||||
|
||||
@@ -66,7 +66,7 @@ class hotpot_xml_template_default {
|
||||
function int_value($tags, $more_tags="[0]['#']") {
|
||||
return intval($this->parent->xml_value($tags, $more_tags));
|
||||
}
|
||||
function js_value($tags, $more_tags="[0]['#']", $convert_to_unicode=false) {
|
||||
function js_value($tags, $more_tags="[0]['#']", $convert_to_unicode=true) {
|
||||
return $this->js_safe($this->parent->xml_value($tags, $more_tags), $convert_to_unicode);
|
||||
}
|
||||
function js_safe($str, $convert_to_unicode=false) {
|
||||
|
||||
+49
-32
@@ -1,4 +1,4 @@
|
||||
<?PHP
|
||||
<?PHP
|
||||
|
||||
class hotpot_xml_quiz_template extends hotpot_xml_template_default {
|
||||
// left and right items for JMatch
|
||||
@@ -9,13 +9,13 @@ class hotpot_xml_quiz_template extends hotpot_xml_template_default {
|
||||
function hotpot_xml_quiz_template(&$parent) {
|
||||
|
||||
$this->parent = &$parent;
|
||||
|
||||
|
||||
$get_js = optional_param('js', false);
|
||||
$get_css = optional_param('css', false);
|
||||
|
||||
if (!empty($get_css)) {
|
||||
// set $this->css
|
||||
$this->v6_expand_StyleSheet();
|
||||
$this->v6_expand_StyleSheet();
|
||||
|
||||
} else if (!empty($get_js)) {
|
||||
// set $this->js
|
||||
@@ -48,6 +48,12 @@ class hotpot_xml_quiz_template extends hotpot_xml_template_default {
|
||||
if (!empty($pattern)) {
|
||||
$this->expand_strings('html', $pattern);
|
||||
}
|
||||
// fix doctype (convert short dtd to long dtd)
|
||||
$this->html = preg_replace(
|
||||
'/<!DOCTYPE[^>]*>/',
|
||||
'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">',
|
||||
$this->html, 1
|
||||
);
|
||||
}
|
||||
|
||||
// captions and messages
|
||||
@@ -68,7 +74,7 @@ class hotpot_xml_quiz_template extends hotpot_xml_template_default {
|
||||
return $this->int_value('hotpot-config-file,global,include-back');
|
||||
}
|
||||
function v6_expand_BackCaption() {
|
||||
return $this->parent->xml_value('hotpot-config-file,global,back-caption');
|
||||
return str_replace('<=', '<=', $this->parent->xml_value('hotpot-config-file,global,back-caption'));
|
||||
}
|
||||
function v6_expand_ClickToAdd() {
|
||||
return $this->parent->xml_value('hotpot-config-file,'.$this->parent->quiztype.',click-to-add');
|
||||
@@ -101,7 +107,8 @@ class hotpot_xml_quiz_template extends hotpot_xml_template_default {
|
||||
return $this->js_value('hotpot-config-file,global,incorrect-indicator');
|
||||
}
|
||||
function v6_expand_LastQCaption() {
|
||||
return $this->parent->xml_value('hotpot-config-file,global,last-q-caption');
|
||||
$caption = $this->parent->xml_value('hotpot-config-file,global,last-q-caption');
|
||||
return ($caption=='<=' ? '<=' : $caption);
|
||||
}
|
||||
function v6_expand_NextCorrect() {
|
||||
$value = $this->js_value('hotpot-config-file,'.$this->parent->quiztype.',next-correct-part');
|
||||
@@ -114,7 +121,7 @@ class hotpot_xml_quiz_template extends hotpot_xml_template_default {
|
||||
return $this->int_value('hotpot-config-file,global,include-next-ex');
|
||||
}
|
||||
function v6_expand_NextExCaption() {
|
||||
return $this->parent->xml_value('hotpot-config-file,global,next-ex-caption');
|
||||
return str_replace('=>', '=>', $this->parent->xml_value('hotpot-config-file,global,next-ex-caption'));
|
||||
}
|
||||
function v6_expand_NextQCaption() {
|
||||
return $this->parent->xml_value('hotpot-config-file,global,next-q-caption');
|
||||
@@ -166,7 +173,7 @@ class hotpot_xml_quiz_template extends hotpot_xml_template_default {
|
||||
return empty($value) ? '' : ('<h3 class="ExerciseSubtitle">'.$value.'</h3>');
|
||||
}
|
||||
|
||||
// timer
|
||||
// timer
|
||||
|
||||
function v6_expand_Timer() {
|
||||
return $this->int_value('data,timer,include-timer');
|
||||
@@ -178,7 +185,7 @@ class hotpot_xml_quiz_template extends hotpot_xml_template_default {
|
||||
return $this->parent->xml_value('data,timer,seconds');
|
||||
}
|
||||
|
||||
// send results
|
||||
// send results
|
||||
|
||||
function v6_expand_SendResults() {
|
||||
return $this->parent->xml_value('hotpot-config-file,'.$this->parent->quiztype.',send-email');
|
||||
@@ -220,7 +227,7 @@ class hotpot_xml_quiz_template extends hotpot_xml_template_default {
|
||||
}
|
||||
|
||||
// convert to comma delimited string
|
||||
$this->PreloadImageList = empty($list) ? '' : "'".implode(',', $list)."'";
|
||||
$this->PreloadImageList = empty($list) ? '' : "'".implode("','", $list)."'";
|
||||
}
|
||||
return $this->PreloadImageList;
|
||||
}
|
||||
@@ -300,7 +307,7 @@ class hotpot_xml_quiz_template extends hotpot_xml_template_default {
|
||||
}
|
||||
function v6_expand_NavLightColor() {
|
||||
$color = $this->parent->xml_value('hotpot-config-file,global,nav-bar-color');
|
||||
return $this->get_halfway_color($color, '#ffffff');
|
||||
return $this->get_halfway_color($color, '#ffffff');
|
||||
}
|
||||
function v6_expand_NavShadeColor() {
|
||||
$color = $this->parent->xml_value('hotpot-config-file,global,nav-bar-color');
|
||||
@@ -533,7 +540,7 @@ class hotpot_xml_quiz_template extends hotpot_xml_template_default {
|
||||
$value = strtr($value, $ENTITIES);
|
||||
if (preg_match_all($pattern, $value, $matches)) {
|
||||
$chars = array_merge($chars, $matches[0]);
|
||||
}
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
|
||||
@@ -655,7 +662,7 @@ class hotpot_xml_quiz_template extends hotpot_xml_template_default {
|
||||
return $this->parent->xml_value('hotpot-config-file,'.$this->parent->quiztype.',remaining-words');
|
||||
}
|
||||
function v6_expand_TimesUp() {
|
||||
return $this->js_safe($this->parent->xml_value('hotpot-config-file,global,times-up'));
|
||||
return $this->js_value('hotpot-config-file,global,times-up');
|
||||
}
|
||||
|
||||
// nav bar
|
||||
@@ -822,7 +829,7 @@ class hotpot_xml_quiz_template extends hotpot_xml_template_default {
|
||||
$a = 0;
|
||||
$aa = 0;
|
||||
while (($answer=$question."['answer'][$a]['#']") && $this->parent->xml_value($tags, $answer)) {
|
||||
$text = $this->js_value($tags, $answer."['text'][0]['#']", true);
|
||||
$text = $this->js_value($tags, $answer."['text'][0]['#']");
|
||||
if (strlen($text)) {
|
||||
if ($aa==0) { // first time only
|
||||
$str .= "\n";
|
||||
@@ -837,7 +844,7 @@ class hotpot_xml_quiz_template extends hotpot_xml_template_default {
|
||||
}
|
||||
// add clue, if any answers were found
|
||||
if ($aa) {
|
||||
$clue = $this->js_value($tags, $question."['clue'][0]['#']", true);
|
||||
$clue = $this->js_value($tags, $question."['clue'][0]['#']");
|
||||
$str .= "I[$q][2] = '$clue';\n";
|
||||
}
|
||||
$q++;
|
||||
@@ -850,15 +857,15 @@ class hotpot_xml_quiz_template extends hotpot_xml_template_default {
|
||||
|
||||
$question_type = $this->int_value($tags, $question."['question-type'][0]['#']");
|
||||
$weighting = $this->int_value($tags, $question."['weighting'][0]['#']");
|
||||
$clue = $this->js_value($tags, $question."['clue'][0]['#']", true);
|
||||
$clue = $this->js_value($tags, $question."['clue'][0]['#']");
|
||||
|
||||
$answers = $question."['answers'][0]['#']";
|
||||
|
||||
$a = 0;
|
||||
$aa = 0;
|
||||
while (($answer = $answers."['answer'][$a]['#']") && $this->parent->xml_value($tags, $answer)) {
|
||||
$text = $this->js_value($tags, $answer."['text'][0]['#']", true);
|
||||
$feedback = $this->js_value($tags, $answer."['feedback'][0]['#']", true);
|
||||
$text = $this->js_value($tags, $answer."['text'][0]['#']");
|
||||
$feedback = $this->js_value($tags, $answer."['feedback'][0]['#']");
|
||||
$correct = $this->int_value($tags, $answer."['correct'][0]['#']");
|
||||
$percent = $this->int_value($tags, $answer."['percent-correct'][0]['#']");
|
||||
$include = $this->int_value($tags, $answer."['include-in-mc-options'][0]['#']");
|
||||
@@ -1057,10 +1064,20 @@ class hotpot_xml_quiz_template extends hotpot_xml_template_default {
|
||||
}
|
||||
}
|
||||
function v6_expand_Correct() {
|
||||
return $this->js_value('hotpot-config-file,'.$this->parent->quiztype.',guesses-correct');
|
||||
if ($this->parent->quiztype=='jcloze') {
|
||||
$tag = 'guesses-correct';
|
||||
} else {
|
||||
$tag = 'guess-correct';
|
||||
}
|
||||
return $this->js_value('hotpot-config-file,'.$this->parent->quiztype.','.$tag);
|
||||
}
|
||||
function v6_expand_Incorrect() {
|
||||
return $this->js_value('hotpot-config-file,'.$this->parent->quiztype.',guesses-incorrect');
|
||||
if ($this->parent->quiztype=='jcloze') {
|
||||
$tag = 'guesses-incorrect';
|
||||
} else {
|
||||
$tag = 'guess-incorrect';
|
||||
}
|
||||
return $this->js_value('hotpot-config-file,'.$this->parent->quiztype.','.$tag);
|
||||
}
|
||||
function v6_expand_GiveHint() {
|
||||
return $this->js_value('hotpot-config-file,'.$this->parent->quiztype.',next-correct-letter');
|
||||
@@ -1072,13 +1089,13 @@ class hotpot_xml_quiz_template extends hotpot_xml_template_default {
|
||||
// JCross quiztype
|
||||
|
||||
function v6_expand_CluesAcrossLabel() {
|
||||
return $this->js_value('hotpot-config-file,'.$this->parent->quiztype.',clues-across');
|
||||
$this->parent->xml_value('hotpot-config-file,'.$this->parent->quiztype.',clues-across');
|
||||
}
|
||||
function v6_expand_CluesDownLabel() {
|
||||
return $this->js_value('hotpot-config-file,'.$this->parent->quiztype.',clues-down');
|
||||
$this->parent->xml_value('hotpot-config-file,'.$this->parent->quiztype.',clues-down');
|
||||
}
|
||||
function v6_expand_EnterCaption() {
|
||||
return $this->js_value('hotpot-config-file,'.$this->parent->quiztype.',enter-caption');
|
||||
$this->parent->xml_value('hotpot-config-file,'.$this->parent->quiztype.',enter-caption');
|
||||
}
|
||||
function v6_expand_ShowHideClueList() {
|
||||
$value = $this->int_value('hotpot-config-file,'.$this->parent->quiztype.',include-clue-list');
|
||||
@@ -1282,7 +1299,7 @@ class hotpot_xml_quiz_template extends hotpot_xml_template_default {
|
||||
$str .= '<p class="QuestionText">'.$question_text.'</p>';
|
||||
|
||||
if (
|
||||
$question_type==HOTPOT_JQUIZ_SHORTANSWER ||
|
||||
$question_type==HOTPOT_JQUIZ_SHORTANSWER ||
|
||||
$question_type==HOTPOT_JQUIZ_HYBRID
|
||||
) {
|
||||
$size = 9; // default size
|
||||
@@ -1320,13 +1337,13 @@ class hotpot_xml_quiz_template extends hotpot_xml_template_default {
|
||||
}
|
||||
|
||||
if (
|
||||
$question_type==HOTPOT_JQUIZ_MULTICHOICE ||
|
||||
$question_type==HOTPOT_JQUIZ_MULTICHOICE ||
|
||||
$question_type==HOTPOT_JQUIZ_HYBRID ||
|
||||
$question_type==HOTPOT_JQUIZ_MULTISELECT
|
||||
) {
|
||||
|
||||
switch ($question_type) {
|
||||
case HOTPOT_JQUIZ_MULTICHOICE:
|
||||
case HOTPOT_JQUIZ_MULTICHOICE:
|
||||
$str .= '<ol class="MCAnswers">'."\n";
|
||||
break;
|
||||
case HOTPOT_JQUIZ_HYBRID:
|
||||
@@ -1438,16 +1455,16 @@ class hotpot_xml_quiz_template extends hotpot_xml_template_default {
|
||||
// hp6checkshortanswers.js_ (JQuiz)
|
||||
|
||||
function v6_expand_CorrectList() {
|
||||
return $this->parent->xml_value('hotpot-config-file,'.$this->parent->quiztype.',correct-answers');
|
||||
return $this->js_value('hotpot-config-file,'.$this->parent->quiztype.',correct-answers');
|
||||
}
|
||||
function v6_expand_HybridTries() {
|
||||
return $this->parent->xml_value('hotpot-config-file,'.$this->parent->quiztype.',short-answer-tries-on-hybrid-q');
|
||||
}
|
||||
function v6_expand_PleaseEnter() {
|
||||
return $this->parent->xml_value('hotpot-config-file,'.$this->parent->quiztype.',enter-a-guess');
|
||||
return $this->js_value('hotpot-config-file,'.$this->parent->quiztype.',enter-a-guess');
|
||||
}
|
||||
function v6_expand_PartlyIncorrect() {
|
||||
return $this->parent->xml_value('hotpot-config-file,'.$this->parent->quiztype.',partly-incorrect');
|
||||
return $this->js_value('hotpot-config-file,'.$this->parent->quiztype.',partly-incorrect');
|
||||
}
|
||||
function v6_expand_ShowAnswerCaption() {
|
||||
return $this->parent->xml_value('hotpot-config-file,'.$this->parent->quiztype.',show-answer-caption');
|
||||
@@ -1465,15 +1482,15 @@ function hotpot_sort_keypad_chars($a, $b) {
|
||||
function hotpot_keypad_sort_value($char) {
|
||||
|
||||
// hexadecimal
|
||||
if (preg_match('|&#x([0-9A-F]+);|ie', $char, $matches)) {
|
||||
if (preg_match('/&#x([0-9A-F]+);/i', $char, $matches)) {
|
||||
$ord = hexdec($matches[1]);
|
||||
|
||||
// decimal
|
||||
} else if (preg_match('|&#(\d+);|i', $char, $matches)) {
|
||||
} else if (preg_match('/&#(\d+);/i', $char, $matches)) {
|
||||
$ord = intval($matches[1]);
|
||||
|
||||
// other html entity
|
||||
} else if (preg_match('|&[^;]+;|', $char, $matches)) {
|
||||
} else if (preg_match('/&[^;]+;/', $char, $matches)) {
|
||||
$char = html_entity_decode($matches[0]);
|
||||
$ord = empty($char) ? 0 : ord($char);
|
||||
|
||||
@@ -1493,6 +1510,6 @@ function hotpot_keypad_sort_value($char) {
|
||||
}
|
||||
|
||||
return $sort_value;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
@@ -36,6 +36,7 @@
|
||||
}
|
||||
require_login($course->id);
|
||||
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
|
||||
require_capability('mod/hotpot:attempt', $context, $USER->id);
|
||||
}
|
||||
// set nextpage (for error messages)
|
||||
$nextpage = "$CFG->wwwroot/course/view.php?id=$course->id";
|
||||
|
||||
@@ -170,10 +170,10 @@
|
||||
echo "<tr align=\"center\"><td>";
|
||||
echo "<input type=\"button\" value=\"".get_string("cancel").
|
||||
"\" onclick=\"parent.location='../../course/view.php?id=$course->id';\"> ";
|
||||
echo "<input type=\"button\" value=\"".get_string("continue").
|
||||
"\" onclick=\"document.password.submit();\" />";
|
||||
echo "</td></tr></table>";
|
||||
echo "<input type=\"submit\" value=\"".get_string("continue")."\"/>";
|
||||
echo "</td></tr></table></form>";
|
||||
print_simple_box_end();
|
||||
print_footer($course);
|
||||
exit();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,7 +47,9 @@ class qformat_hotpot extends qformat_default {
|
||||
|
||||
// get import file name
|
||||
global $params;
|
||||
if (isset($params) && !empty($params->choosefile)) {
|
||||
if (! empty($this->realfilename)) {
|
||||
$filename = $this->realfilename;
|
||||
} else if (isset($params) && !empty($params->choosefile)) {
|
||||
// course file (Moodle >=1.6+)
|
||||
$filename = $params->choosefile;
|
||||
} else {
|
||||
@@ -99,7 +101,12 @@ class qformat_hotpot extends qformat_default {
|
||||
notice("Unknown quiz type '$xml->quiztype'");
|
||||
}
|
||||
} // end switch
|
||||
return $questions;
|
||||
|
||||
if (count($questions)) {
|
||||
return $questions;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function process_jcloze(&$xml, &$questions) {
|
||||
@@ -185,7 +192,7 @@ class qformat_hotpot extends qformat_default {
|
||||
$text = $this->hotpot_prepare_str($xml->xml_value($tags, $answer."['text'][0]['#']"));
|
||||
$correct = $xml->xml_value($tags, $answer."['correct'][0]['#']");
|
||||
$feedback = $this->hotpot_prepare_str($xml->xml_value($tags, $answer."['feedback'][0]['#']"));
|
||||
if ($text) {
|
||||
if (strlen($text)) {
|
||||
// set score (0=0%, 1=100%)
|
||||
$fraction = empty($correct) ? 0 : 1;
|
||||
// store answer
|
||||
@@ -498,7 +505,7 @@ class qformat_hotpot extends qformat_default {
|
||||
return $this->hotpot_prepare_str($title);
|
||||
}
|
||||
function hotpot_get_instructions(&$xml) {
|
||||
$text = $xml->xml_value('hotpot-config-file,instructions');
|
||||
$text = $xml->xml_value('hotpot-config-file,'.$xml->quiztype.',instructions');
|
||||
if (empty($text)) {
|
||||
$text = "Hot Potatoes $xml->quiztype";
|
||||
}
|
||||
@@ -546,8 +553,29 @@ class hotpot_xml_tree {
|
||||
}
|
||||
function xml_value($tags, $more_tags="[0]['#']") {
|
||||
|
||||
$tags = empty($tags) ? '' : "['".str_replace(",", "'][0]['#']['", $tags)."']";
|
||||
eval('$value = &$this->xml'.$this->xml_root.$tags.$more_tags.';');
|
||||
$value = null;
|
||||
if (isset($this->xml) && is_array($this->xml)) {
|
||||
|
||||
$all_tags = $this->xml_root;
|
||||
if ($tags) {
|
||||
$all_tags .= "['".str_replace(",", "'][0]['#']['", $tags)."']";
|
||||
}
|
||||
$all_tags .= $more_tags;
|
||||
|
||||
$pos = strrpos($all_tags, '[');
|
||||
if ($pos===false) {
|
||||
$most_tags = ''; // shouldn't happen !!
|
||||
} else {
|
||||
$most_tags = substr($all_tags, 0, $pos);
|
||||
}
|
||||
|
||||
eval('if (isset($this->xml'.$most_tags.') && is_array($this->xml'.$most_tags.') && isset($this->xml'.$all_tags.')) {'
|
||||
.'$value = &$this->xml'.$all_tags.';'
|
||||
.'} else {'
|
||||
.'$value = null;'
|
||||
.'}'
|
||||
);
|
||||
}
|
||||
|
||||
if (is_string($value)) {
|
||||
if (empty($CFG->unicodedb)) {
|
||||
|
||||
@@ -1016,7 +1016,7 @@ class qformat_xml extends qformat_default {
|
||||
$expout .= " <tolerance>$tolerance</tolerance>\n";
|
||||
$expout .= " <tolerancetype>$tolerancetype</tolerancetype>\n";
|
||||
$expout .= " <correctanswerformat>$correctanswerformat</correctanswerformat>\n";
|
||||
$expout .= " <correctanswerlength>$correctanswerformat</correctanswerlength>\n";
|
||||
$expout .= " <correctanswerlength>$correctanswerlength</correctanswerlength>\n";
|
||||
$expout .= " <feedback>".$this->writetext( $answer->feedback )."</feedback>\n";
|
||||
$expout .= "</answer>\n";
|
||||
}
|
||||
|
||||
+2
-2
@@ -6,10 +6,10 @@
|
||||
// This is compared against the values stored in the database to determine
|
||||
// whether upgrades should be performed (see lib/db/*.php)
|
||||
|
||||
$version = 2006101070; // YYYYMMDD = date of the 1.7 branch (don't change)
|
||||
$version = 2006101071; // YYYYMMDD = date of the 1.7 branch (don't change)
|
||||
// X = release number 1.7.[0,1,2,3...]
|
||||
// Y = micro-increments between releases
|
||||
|
||||
$release = '1.7.7'; // Human-friendly version name
|
||||
$release = '1.7.7+'; // Human-friendly version name
|
||||
|
||||
?>
|
||||
|
||||
Reference in New Issue
Block a user