jclicmoodle-0.1.0.11/ 0000755 0001750 0001750 00000000000 11577152645 014343 5 ustar demarchi demarchi jclicmoodle-0.1.0.11/mod/ 0000755 0001750 0001750 00000000000 11577135715 015121 5 ustar demarchi demarchi jclicmoodle-0.1.0.11/mod/jclic/ 0000755 0001750 0001750 00000000000 11577135715 016205 5 ustar demarchi demarchi jclicmoodle-0.1.0.11/mod/jclic/action/ 0000755 0001750 0001750 00000000000 11577135715 017462 5 ustar demarchi demarchi jclicmoodle-0.1.0.11/mod/jclic/db/ 0000755 0001750 0001750 00000000000 11577135715 016572 5 ustar demarchi demarchi jclicmoodle-0.1.0.11/mod/jclic/lang/ 0000755 0001750 0001750 00000000000 11577135715 017126 5 ustar demarchi demarchi jclicmoodle-0.1.0.11/mod/jclic/pix/ 0000755 0001750 0001750 00000000000 11577135715 017005 5 ustar demarchi demarchi jclicmoodle-0.1.0.11/mod/jclic/lang/ca/ 0000755 0001750 0001750 00000000000 11577135715 017511 5 ustar demarchi demarchi jclicmoodle-0.1.0.11/mod/jclic/lang/ca_utf8/ 0000755 0001750 0001750 00000000000 11577135715 020457 5 ustar demarchi demarchi jclicmoodle-0.1.0.11/mod/jclic/lang/el_utf8/ 0000755 0001750 0001750 00000000000 11577135715 020474 5 ustar demarchi demarchi jclicmoodle-0.1.0.11/mod/jclic/lang/en/ 0000755 0001750 0001750 00000000000 11577135715 017530 5 ustar demarchi demarchi jclicmoodle-0.1.0.11/mod/jclic/lang/en_utf8/ 0000755 0001750 0001750 00000000000 11577135715 020476 5 ustar demarchi demarchi jclicmoodle-0.1.0.11/mod/jclic/lang/es/ 0000755 0001750 0001750 00000000000 11577135715 017535 5 ustar demarchi demarchi jclicmoodle-0.1.0.11/mod/jclic/lang/es_es_utf8/ 0000755 0001750 0001750 00000000000 11577135715 021172 5 ustar demarchi demarchi jclicmoodle-0.1.0.11/mod/jclic/lang/es_utf8/ 0000755 0001750 0001750 00000000000 11577135715 020503 5 ustar demarchi demarchi jclicmoodle-0.1.0.11/mod/jclic/lang/eu/ 0000755 0001750 0001750 00000000000 11577135715 017537 5 ustar demarchi demarchi jclicmoodle-0.1.0.11/mod/jclic/lang/eu_utf8/ 0000755 0001750 0001750 00000000000 11577135715 020505 5 ustar demarchi demarchi jclicmoodle-0.1.0.11/mod/jclic/lang/gl/ 0000755 0001750 0001750 00000000000 11577135715 017530 5 ustar demarchi demarchi jclicmoodle-0.1.0.11/mod/jclic/lang/gl_utf8/ 0000755 0001750 0001750 00000000000 11577135715 020476 5 ustar demarchi demarchi jclicmoodle-0.1.0.11/mod/jclic/lang/he_utf8/ 0000755 0001750 0001750 00000000000 11577135715 020470 5 ustar demarchi demarchi jclicmoodle-0.1.0.11/mod/jclic/lang/ca/help/ 0000755 0001750 0001750 00000000000 11577135715 020441 5 ustar demarchi demarchi jclicmoodle-0.1.0.11/mod/jclic/lang/ca_utf8/help/ 0000755 0001750 0001750 00000000000 11577135715 021407 5 ustar demarchi demarchi jclicmoodle-0.1.0.11/mod/jclic/lang/el_utf8/help/ 0000755 0001750 0001750 00000000000 11577135715 021424 5 ustar demarchi demarchi jclicmoodle-0.1.0.11/mod/jclic/lang/en/help/ 0000755 0001750 0001750 00000000000 11577135715 020460 5 ustar demarchi demarchi jclicmoodle-0.1.0.11/mod/jclic/lang/en_utf8/help/ 0000755 0001750 0001750 00000000000 11577135715 021426 5 ustar demarchi demarchi jclicmoodle-0.1.0.11/mod/jclic/lang/es/help/ 0000755 0001750 0001750 00000000000 11577135715 020465 5 ustar demarchi demarchi jclicmoodle-0.1.0.11/mod/jclic/lang/es_es_utf8/help/ 0000755 0001750 0001750 00000000000 11577135715 022122 5 ustar demarchi demarchi jclicmoodle-0.1.0.11/mod/jclic/lang/es_utf8/help/ 0000755 0001750 0001750 00000000000 11577135715 021433 5 ustar demarchi demarchi jclicmoodle-0.1.0.11/mod/jclic/lang/eu/help/ 0000755 0001750 0001750 00000000000 11577135715 020467 5 ustar demarchi demarchi jclicmoodle-0.1.0.11/mod/jclic/lang/eu_utf8/help/ 0000755 0001750 0001750 00000000000 11577135715 021435 5 ustar demarchi demarchi jclicmoodle-0.1.0.11/mod/jclic/lang/gl/help/ 0000755 0001750 0001750 00000000000 11577135715 020460 5 ustar demarchi demarchi jclicmoodle-0.1.0.11/mod/jclic/lang/gl_utf8/help/ 0000755 0001750 0001750 00000000000 11577135715 021426 5 ustar demarchi demarchi jclicmoodle-0.1.0.11/mod/jclic/lang/he_utf8/help/ 0000755 0001750 0001750 00000000000 11577135715 021420 5 ustar demarchi demarchi jclicmoodle-0.1.0.11/mod/jclic/lang/ca/help/jclic/ 0000755 0001750 0001750 00000000000 11577135715 021525 5 ustar demarchi demarchi jclicmoodle-0.1.0.11/mod/jclic/lang/ca_utf8/help/jclic/ 0000755 0001750 0001750 00000000000 11577135715 022473 5 ustar demarchi demarchi jclicmoodle-0.1.0.11/mod/jclic/lang/el_utf8/help/jclic/ 0000755 0001750 0001750 00000000000 11577135715 022510 5 ustar demarchi demarchi jclicmoodle-0.1.0.11/mod/jclic/lang/en/help/jclic/ 0000755 0001750 0001750 00000000000 11577135715 021544 5 ustar demarchi demarchi jclicmoodle-0.1.0.11/mod/jclic/lang/en_utf8/help/jclic/ 0000755 0001750 0001750 00000000000 11577135715 022512 5 ustar demarchi demarchi jclicmoodle-0.1.0.11/mod/jclic/lang/es/help/jclic/ 0000755 0001750 0001750 00000000000 11577135715 021551 5 ustar demarchi demarchi jclicmoodle-0.1.0.11/mod/jclic/lang/es_es_utf8/help/jclic/ 0000755 0001750 0001750 00000000000 11577135715 023206 5 ustar demarchi demarchi jclicmoodle-0.1.0.11/mod/jclic/lang/es_utf8/help/jclic/ 0000755 0001750 0001750 00000000000 11577135715 022517 5 ustar demarchi demarchi jclicmoodle-0.1.0.11/mod/jclic/lang/eu/help/jclic/ 0000755 0001750 0001750 00000000000 11577135715 021553 5 ustar demarchi demarchi jclicmoodle-0.1.0.11/mod/jclic/lang/eu_utf8/help/jclic/ 0000755 0001750 0001750 00000000000 11577135715 022521 5 ustar demarchi demarchi jclicmoodle-0.1.0.11/mod/jclic/lang/gl/help/jclic/ 0000755 0001750 0001750 00000000000 11577135715 021544 5 ustar demarchi demarchi jclicmoodle-0.1.0.11/mod/jclic/lang/gl_utf8/help/jclic/ 0000755 0001750 0001750 00000000000 11577135715 022512 5 ustar demarchi demarchi jclicmoodle-0.1.0.11/mod/jclic/lang/he_utf8/help/jclic/ 0000755 0001750 0001750 00000000000 11577135715 022504 5 ustar demarchi demarchi jclicmoodle-0.1.0.11/CHANGES.txt 0000664 0001750 0001750 00000010317 11567164656 016164 0 ustar demarchi demarchi Release notes for JClic Module for Moodle (https://projectes.lafarga.cat/projects/jclicmoodle)
More information on each of the fixes can be found in the project
development home at https://projectes.lafarga.cat/projects/jclicmoodle
Changes in 0.1.0.11 (2011/05/25)
---------------------------------------------------------------------------------------
- Added language parameter to the activity edition page to let specify the player language (http://projectes.lafarga.cat/projects/jclicmoodle/tracker/291/1641/detail)
- Added exiturl parameter to the activity edition page to let specify exit URL (http://projectes.lafarga.cat/projects/jclicmoodle/tracker/291/1287/detail)
- Revised information showed in summary
- Solved problem when moodle is installed in the root (without path in the URL)
- Added jclic_scale_used_anywhere function sended by David Monllao from URV to improve the performance of the module
- Fixed warnings when restoring jclic activities (http://projectes.lafarga.cat/projects/jclicmoodle/tracker/288/1200/detail)
- Fixed bug with single quote reported to Moodle tracker (http://tracker.moodle.org/browse/CONTRIB-2079?page=com.atlassian.jira.plugin.system.issuetabpanels%3Acvs-tabpanel)
- Fixed warning message when there were no users in the course (http://projectes.lafarga.cat/projects/jclicmoodle/tracker/288/1335/detail)
- Added protocol parameter to TCPReporter jclic function to let it works with HTTPS connections (https://projectes.lafarga.cat/projects/jclicmoodle/tracker/288/1507/detail)
- Solved error with maxattempts (http://projectes.lafarga.cat/projects/jclicmoodle/tracker/288/1775/detail)
Changes in 0.1.0.9 (2009/10/27)
---------------------------------------------------------------------------------------
- Added Hebrew translation (Nadav Kavalerchik - nadavkav@gmail.com)
- Removed the pass-by-reference to the $grades parameter in jclic_user_grades function.
- Assigned a default value to maxgrade parameter and removed restriction in jclic_grades function to solve the problem with the qualificator of Moodle if maxgrade isn't specified.
- Added COPYING, CREDITS and INSTALL files
- Added user picture to the teacher view
- Commented if (function_exists('date_default_timezone_set')) date_default_timezone_set('UTC'); line in lib.php file to solve time problems (Jaume Rocarias from UAB)
- Added IOC implementation for restarting courses with JClic activities (Albert Gasset Romo)
- Solved some problems with Moodle 1.6
Changes in 0.1.0.8 (2008/12/10)
---------------------------------------------------------------------------------------
- Solved include /gradelib.php bug
Changes in 0.1.0.8 (2008/11/07)
---------------------------------------------------------------------------------------
- Added Galician translation (Xosé Luis Barreiro Cebey - xoseluis@edu.xunta.es)
- Added Greek translation (Yannis Kaskamanidis - ttnfy17@yahoo.gr)
- Solved problems with Moodle 1.9 qualification
- Added preview button from teachers view
- Solved problems with white spaces in URL
- Added @mini.xml skin
Changes in 0.1.0.7 (2008/01/25)
---------------------------------------------------------------------------------------
- Added compatibility with course groups
- Solved problems with switch role button
- Added file install.xml file (for compatibility with Oracle)
- Moved lang directory inside jclic module.
- Added Basque translation (Abel Camacho - didaktika@santurtzieus.com)
Changes in 0.1.0.6 (2007/03/07)
---------------------------------------------------------------------------------------
- Added compatibility with Moodle 1.7 and 1.8; therefore, the jclicmoodle module works correctly with Moodle 1.5 and superior.
- Incorporated detailed information of the activities for each student's session.
- Added button "Choose or upload a file..." to use your own JClic activities.
- Inserted new configuration parameter (lap) which allows you configuring the time between JClic applet client and Moodle server transactions.
- Students' view updated: sessions list replaced for a button (to open the results in a new window)
Changes in 0.1.0.5 (2006/12/12)
---------------------------------------------------------------------------------------
- Solved problems detected in the backup of Moodle courses containing JClic activities.
jclicmoodle-0.1.0.11/COPYING.txt 0000664 0001750 0001750 00000104513 11270302326 016201 0 ustar demarchi demarchi GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc.
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. 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
them 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 prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. 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.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey 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;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If 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 convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU 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 that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
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.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
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.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
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
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
Copyright (C)
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 3 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, see .
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
Copyright (C)
This program 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, your program's commands
might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
.
The GNU 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. But first, please read
.
jclicmoodle-0.1.0.11/CREDITS.txt 0000664 0001750 0001750 00000003705 11343456130 016173 0 ustar demarchi demarchi JClic module for Moodle
Generalitat de Catalunya - Departament d'Educació
WWW: https://projectes.lafarga.cat/projects/jclicmoodle
Email: clic@xtec.cat
Developers:
Sara Arjona Tellez (sara.arjona+xtec@gmail.com)
With the support of:
Francesc Busquets
Community support:
Monica Grau
Translations:
Basque:
Abel Camacho - didaktika@santurtzieus.com
Greek:
Yannis Kaskamanidis - ttnfy17@yahoo.gr
Galician:
Xosé Luis Barreiro Cebey - xoseluis@edu.xunta.es
Hebrew:
Nadav Kavalerchik - nadavkav@gmail.com
Special Thanks:
Eva Gea
Birgit Ferran
Sandra Fernandez
Silvia Garcia Yague
Albert Gasset Romo
Jaume Rocarias
David Monllao
-----------------------------------------------------------------------------
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 (in a file called COPYING); if not, go
to http://www.gnu.org/copyleft/gpl.html or write to
Free Software Foundation, Inc.
59 Temple Place - Suite 330
Boston, MA 02111-1307 USA
-----------------------------------------------------------------------------
Source code to this program is always available; for more
information visit the website of the main project at:
http://clic.xtec.cat/
-----------------------------------------------------------------------------
See INSTALL.txt for installation instructions.
-----------------------------------------------------------------------------
jclicmoodle-0.1.0.11/INSTALL.txt 0000664 0001750 0001750 00000002145 11270323733 016202 0 ustar demarchi demarchi JCLIC MODULE FOR MOODLE
Departament d'Educació - Generalitat de Catalunya
--------------------------------------------------------------------------------
To Install:
1. Download the JClic[1] module for Moodle from LaFarga.cat[2] and unzip it.
2. Load the mod directory into your "mod" Moodle directory. To verify that these files have been transferred to the right place, you should check that the directory 'mod' contains a 'jclic' directory.
3. Visit your admin page to create all of the necessary data tables. To do this you'll need to access to your Moodle with an admin user and click on the Notifications link in the Administration block.
--------------------------------------------------------------------------------
To Upgrade:
1. Download the JClic[1] module for Moodle from LaFarga.cat[2] and unzip it.
2. Copy all of the mod/jclic files into your 'mod/jclic' directory.
3. Visit your admin page to update the database.
--------------------------------------------------------------------------------
[1] JClic: http://clic.xtec.cat/
[2] LaFarga.cat: https://projectes.lafarga.cat/projects/q-virtuals/
jclicmoodle-0.1.0.11/mod/jclic/backuplib.php 0000664 0001750 0001750 00000025317 11567171117 020657 0 ustar demarchi demarchi id)
// |
// |
// jclic_sessions
// (UL, pk->id, fk->jclicid)
// |
// |
// jclic_activities
// (pk->id, fk->session_id)
//
//
// Meaning: pk->primary key field of the table
// fk->foreign key to link with parent
// nt->nested field (recursive data)
// CL->course level info
// UL->user level info
// files->table may have files)
//
//-----------------------------------------------------------
function jclic_backup_mods($bf,$preferences) {
global $CFG;
$status = true;
////Iterate over jclic table
if ($jclics = get_records ("jclic","course", $preferences->backup_course, "id")) {
foreach ($jclics as $jclic) {
if (jclic_backup_mod_selected($preferences,'jclic',$jclic->id)) {
$status = jclic_backup_one_mod($bf,$preferences,$jclic);
}
}
}
return $status;
}
function jclic_backup_one_mod($bf,$preferences,$jclic) {
global $CFG;
if (is_numeric($jclic)) {
$jclic = get_record('jclic','id',$jclic);
}
$instanceid = $jclic->id;
$status = true;
//Start mod
fwrite ($bf,start_tag("MOD",3,true));
//Print jclic data
fwrite ($bf,full_tag("ID",4,false,$jclic->id));
fwrite ($bf,full_tag("MODTYPE",4,false,"jclic"));
fwrite ($bf,full_tag("NAME",4,false,$jclic->name));
fwrite ($bf,full_tag("DESCRIPTION",4,false,$jclic->description));
fwrite ($bf,full_tag("URL",4,false,$jclic->url));
fwrite ($bf,full_tag("SKIN",4,false,$jclic->skin));
fwrite ($bf,full_tag("MAXATTEMPTS",4,false,$jclic->maxattempts));
fwrite ($bf,full_tag("WIDTH",4,false,$jclic->width));
fwrite ($bf,full_tag("HEIGHT",4,false,$jclic->height));
fwrite ($bf,full_tag("AVALUATION",4,false,$jclic->avaluation));
fwrite ($bf,full_tag("MAXGRADE",4,false,$jclic->maxgrade));
//if we've selected to backup users info, then execute backup_jclic_sessions
if (jclic_backup_userdata_selected($preferences,'jclic',$jclic->id)) {
$status = backup_jclic_sessions($bf,$preferences,$jclic->id);
}
//End mod
fwrite ($bf,end_tag("MOD",3,true));
return $status;
}
//Backup jclic_sessions contents (executed from jclic_backup_mods)
function backup_jclic_sessions ($bf,$preferences,$jclic) {
global $CFG;
$status = true;
$sessions = get_records("jclic_sessions","jclicid",$jclic,"id");
//If there are sessions
if ($sessions) {
//Write start tag
$status =fwrite ($bf,start_tag("SESSIONS",4,true));
//Iterate over each sessions
foreach ($sessions as $session) {
//Entry start
$status =fwrite ($bf,start_tag("SESSION",5,true));
fwrite ($bf,full_tag("ID",6,false,$session->id));
fwrite ($bf,full_tag("USER_ID",6,false,$session->user_id));
fwrite ($bf,full_tag("SESSION_ID",6,false,$session->session_id));
fwrite ($bf,full_tag("SESSION_DATETIME",6,false,$session->session_datetime));
fwrite ($bf,full_tag("PROJECT_NAME",6,false,$session->project_name));
fwrite ($bf,full_tag("SESSION_KEY",6,false,$session->session_key));
fwrite ($bf,full_tag("SESSION_CODE",6,false,$session->session_code));
fwrite ($bf,full_tag("SESSION_CONTEXT",6,false,$session->session_context));
//$activities = get_records("jclic_activities","session_id",$session,"session_id");
$activities = get_records("jclic_activities","session_id",$session->session_id);
//If there are activities
if ($activities) {
//Write start tag
$status =fwrite ($bf,start_tag("ACTIVITIES",6,true));
//Iterate over each activity
foreach ($activities as $activity) {
//Entry start
$status =fwrite ($bf,start_tag("ACTIVITY",7,true));
fwrite ($bf,full_tag("ID",8,false,$activity->id));
fwrite ($bf,full_tag("SESSION_ID",8,false,$activity->session_id));
fwrite ($bf,full_tag("ACTIVITY_ID",8,false,$activity->activity_id));
fwrite ($bf,full_tag("ACTIVITY_NAME",8,false,$activity->activity_name));
fwrite ($bf,full_tag("NUM_ACTIONS",8,false,$activity->num_actions));
fwrite ($bf,full_tag("SCORE",8,false,$activity->score));
fwrite ($bf,full_tag("ACTIVITY_SOLVED",8,false,$activity->activity_solved));
fwrite ($bf,full_tag("QUALIFICATION",8,false,$activity->qualification));
fwrite ($bf,full_tag("TOTAL_TIME",8,false,$activity->total_time));
fwrite ($bf,full_tag("ACTIVITY_CODE",8,false,$activity->activity_code));
//Entry end
$status =fwrite ($bf,end_tag("ACTIVITY",7,true));
}
//Write end tag
$status =fwrite ($bf,end_tag("ACTIVITIES",6,true));
}
//Entry end
$status =fwrite ($bf,end_tag("SESSION",5,true));
}
//Write end tag
$status =fwrite ($bf,end_tag("SESSIONS",4,true));
}
return $status;
}
function jclic_check_backup_mods_instances($instance,$backup_unique_code) {
$info[$instance->id.'0'][0] = ''.$instance->name.'';
$info[$instance->id.'0'][1] = '';
if (!empty($instance->userdata)) {
//Sessions
$info[$instance->id.'1'][0] = get_string("sessions","jclic");
if ($ids = jclic_session_ids_by_instance ($instance->id)) {
$info[$instance->id.'1'][1] = count($ids);
} else {
$info[$instance->id.'1'][1] = 0;
}
}
return $info;
}
//Backup jclic files because we've selected to backup user info
//and files are user info's level
function backup_jclic_files_instance($bf,$preferences,$instanceid) {
global $CFG;
$status = true;
//First we check to moddata exists and create it as necessary
//in temp/backup/$backup_code dir
$status = check_and_create_moddata_dir($preferences->backup_unique_code);
$status = check_dir_exists($CFG->dataroot."/temp/backup/".$preferences->backup_unique_code."/moddata/jclic/",true);
//Now copy the jclic dir
if ($status) {
//Only if it exists !!
if (is_dir($CFG->dataroot."/".$preferences->backup_course."/".$CFG->moddata."/jclic/".$instanceid)) {
$status = backup_copy_file($CFG->dataroot."/".$preferences->backup_course."/".$CFG->moddata."/jclic/".$instanceid,
$CFG->dataroot."/temp/jclic/".$preferences->backup_unique_code."/moddata/jclic/".$instanceid);
}
}
return $status;
}
////Return an array of info (name,value)
function jclic_check_backup_mods($course,$user_data=false,$backup_unique_code,$instances=null) {
if (!empty($instances) && is_array($instances) && count($instances)) {
$info = array();
foreach ($instances as $id => $instance) {
$info += jclic_check_backup_mods_instances($instance,$backup_unique_code);
}
return $info;
}
//First the course data
$info[0][0] = get_string("modulenameplural","jclic");
if ($ids = jclic_ids ($course)) {
$info[0][1] = count($ids);
} else {
$info[0][1] = 0;
}
//Now, if requested, the user_data
if ($user_data) {
//Sessions
$info[1][0] = get_string("sessions","jclic");
if ($ids = jclic_session_ids_by_course ($course)) {
$info[1][1] = count($ids);
} else {
$info[1][1] = 0;
}
}
return $info;
}
//Return a content encoded to support interactivities linking. Every module
//should have its own. They are called automatically from the backup procedure.
function jclic_encode_content_links ($content,$preferences) {
global $CFG;
$base = preg_quote($CFG->wwwroot,"/");
//Link to the list of jclics
$buscar="/(".$base."\/mod\/jclic\/index.php\?id\=)([0-9]+)/";
$result= preg_replace($buscar,'$@JCLICINDEX*$2@$',$content);
//Link to jclic view by moduleid
$buscar="/(".$base."\/mod\/jclic\/view.php\?id\=)([0-9]+)/";
$result= preg_replace($buscar,'$@JCLICVIEWBYID*$2@$',$result);
return $result;
}
// INTERNAL FUNCTIONS. BASED IN THE MOD STRUCTURE
//Returns an array of jclic id
function jclic_ids ($course) {
global $CFG;
return get_records_sql ("SELECT j.id, j.course
FROM {$CFG->prefix}jclic j
WHERE j.course = '$course'");
}
//Returns an array of jclic sessions id
function jclic_session_ids_by_course ($course) {
global $CFG;
return get_records_sql ("SELECT js.id , js.jclicid
FROM {$CFG->prefix}jclic j,
{$CFG->prefix}jclic_sessions js
WHERE j.course = '$course' AND
js.jclicid = j.id");
}
//Returns an array of jclic sessions id
function jclic_session_ids_by_instance($instanceid) {
global $CFG;
return get_records_sql ("SELECT js.id , js.jclicid
FROM {$CFG->prefix}jclic_sessions js
WHERE js.jclicid = $instanceid");
}
/* Functions from Moodle 1.6 added for compatibility with 1.5 */
function jclic_backup_mod_selected($preferences,$modname,$modid) {
return ((empty($preferences->mods[$modname]->instances)
&& !empty($preferences->mods[$modname]->backup))
|| (is_array($preferences->mods[$modname]->instances)
&& array_key_exists($modid,$preferences->mods[$modname]->instances)
&& !empty($preferences->mods[$modname]->instances[$modid]->backup)));
}
function jclic_backup_userdata_selected($preferences,$modname,$modid) {
return ((empty($preferences->mods[$modname]->instances)
&& !empty($preferences->mods[$modname]->userinfo))
|| (is_array($preferences->mods[$modname]->instances)
&& array_key_exists($modid,$preferences->mods[$modname]->instances)
&& !empty($preferences->mods[$modname]->instances[$modid]->userinfo)));
}
?>
jclicmoodle-0.1.0.11/mod/jclic/lib.php 0000664 0001750 0001750 00000050335 11567171117 017467 0 ustar demarchi demarchi libdir.'/pagelib.php');
if (!isset($CFG->jclic_jclicpluginjs)) {
set_config("jclic_jclicpluginjs", "http://clic.xtec.cat/dist/jclic/jclicplugin.js");
}
if (!isset($CFG->jclic_lap)) {
set_config("jclic_lap", "5");
}
function jclic_add_instance($jclic) {
/// Given an object containing all the necessary data,
/// (defined by the form in mod.html) this function
/// will create a new instance and return the id number
/// of the new instance.
$jclic->url=trim($jclic->url);
if ($jclic->skin=='') $jclic->skin="default";
return insert_record("jclic", $jclic);
}
function jclic_update_instance($jclic) {
/// Given an object containing all the necessary data,
/// (defined by the form in mod.html) this function
/// will update an existing instance with new data.
$jclic->id = $jclic->instance;
$jclic->url=trim($jclic->url);
if(update_record("jclic", $jclic)){
return jclic_update_gradebook(null, $jclic);
}
return false;
}
function jclic_delete_instance($id) {
/// Given an ID of an instance of this module,
/// this function will permanently delete the instance
/// and any data that depends on it.
if (! $jclic = get_record("jclic", "id", "$id")) {
return false;
}
$result = true;
# Delete any dependent records here #
$rs = get_record("jclic_sessions", "jclicid", "$id");
foreach($rs as $session){
delete_records("jclic_activities", "session_id", "$rs->session_id");
}
delete_records("jclic_sessions", "jclicid", "$id");
if (! delete_records("jclic", "id", "$id")) {
$result = false;
}
return $result;
}
function jclic_user_outline($course, $user, $mod, $jclic) {
/// Return a small object with summary information about what a
/// user has done with a given particular instance of this module
/// Used for user activity reports.
$jclic_summary = jclic_get_sessions_summary($jclic->id, $user->id);
$return->time = $jclic_summary->totaltime;
$maxgrade = 0;
if (property_exists($jclic, 'maxgrade')) $maxgrade = $jclic->maxgrade;
$return->info = get_string("score", "jclic").": ".$jclic_summary->score."/".$maxgrade;
return $return;
}
function jclic_user_complete($course, $user, $mod, $jclic) {
/// Print a detailed representation of what a user has done with
/// a given particular instance of this module, for user activity reports.
return true;
}
function jclic_print_recent_activity($course, $isteacher, $timestart) {
/// Given a course and a time, this module should find recent activity
/// that has occurred in jclic activities and print it out.
/// Return true if there was output, or false is there was none.
global $CFG;
return false; // True if anything was printed, otherwise false
}
function jclic_cron () {
/// Function to be run periodically according to the moodle cron
/// This function searches for things that need to be done, such
/// as sending out mail, toggling flags etc ...
global $CFG;
return true;
}
function jclic_grades($jclicid, $userid=NULL) {
global $CFG;
/// Must return an array of grades for a given instance of this module,
/// indexed by user. It also returns a maximum allowed grade.
///
/// $return->grades = array of grades;
/// $return->maxgrade = maximum allowed grade;
///
if (!$jclic = get_record('jclic', 'id', $jclicid)) {
return NULL;
}
$return = new object();
$grades = array();
if ($userid==NULL){
if ($participants = jclic_get_participants($jclicid)){
foreach ($participants as $participant) {
$grades = jclic_user_grades($grades, $jclic, $participant->userid);
}
}
} else{
$grades = jclic_user_grades($grades, $jclic, $userid);
}
$return->grades=$grades;
$return->maxgrade=$jclic->maxgrade;
return $return;
}
function jclic_user_grades($grades, $jclic, $userid) {
$sessions_summary=jclic_get_sessions_summary($jclic->id, $userid);
if ($jclic->avaluation=='score'){
$grades[$userid]=$sessions_summary->score;
}else{
$grades[$userid]=$sessions_summary->solved;
}
return $grades;
}
function jclic_update_gradebook($jclic_activity=NULL, $jclic=NULL){
global $CFG;
if (!function_exists('grade_update')) { //workaround for buggy PHP versions
if (file_exists($CFG->libdir.'/gradelib.php')) include_once($CFG->libdir.'/gradelib.php');
}
if (!function_exists('grade_update')) {
return true;
}
if ($jclic_activity != NULL){
if (!$jclic_session = get_record('jclic_sessions', 'session_id', $jclic_activity->session_id)) {
return NULL;
}
if (!$jclic = get_record('jclic', 'id', $jclic_session->jclicid)) {
return NULL;
}
}
if ($jclic != NULL){
// Get the grades
$userid = (isset($jclic_session)?$jclic_session->user_id:null);
$jclic_grades = jclic_grades($jclic->id, $userid);
$grades = array();
foreach ($jclic_grades->grades as $k=>$v){
$grades[$k]->userid=$k;
$grades[$k]->rawgrade=$v;
}
// Get the params
$params = array('itemname'=>$jclic->name);
$params['gradetype'] = GRADE_TYPE_VALUE;
if ($jclic->maxgrade==NULL) $jclic_grades->maxgrade = 0;
$params['gradepass'] = $jclic_grades->maxgrade;
$params['grademin'] = 0;
if ($jclic->avaluation=='score') $params['grademax'] = 100;
else $params['grademax'] = $jclic_grades->maxgrade;
grade_update('mod/jclic', $jclic->course, 'mod', 'jclic', $jclic->id, 0, $grades, $params);
return true;
}
return false;
}
function jclic_get_students($cm, $course, $jclicid) {
global $CFG;
$version_moodle = (float)substr($CFG->release,0,3);
if ($version_moodle>=1.7){
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
$currentgroup = get_and_set_current_group($course, groupmode($course, $cm));
$users = get_users_by_capability($context, 'mod/jclic:submit', 'u.id, u.id', '', '', '', $currentgroup, '', false);
$dbstudents = array();
if (!empty($users)){
$select = 'SELECT u.id AS userid, u.firstname, u.lastname, u.picture ';
$sql = 'FROM '.$CFG->prefix.'user u '.
'LEFT JOIN '.$CFG->prefix.'jclic_sessions a ON u.id = a.user_id AND a.jclicid = '.$jclicid.' '.
'WHERE u.id IN ('.implode(',', array_keys($users)).') ';
$dbstudents=get_records_sql($select.$sql);
}
}else{
$dbstudents = get_records_sql("SELECT DISTINCT us.userid, u.firstname, u.lastname
FROM {$CFG->prefix}user u,{$CFG->prefix}user_students us, {$CFG->prefix}jclic j
WHERE us.course=j.course AND j.id=$jclicid AND u.id=us.userid");
}
return $dbstudents;
}
function jclic_get_participants($jclicid) {
//Must return an array of user records (all data) who are participants
//for a given instance of jclic. Must include every user involved
//in the instance, independient of his role (student, teacher, admin...)
//See other modules as example.
global $CFG;
//Get students
$students = get_records_sql("SELECT DISTINCT u.id, u.id as userid
FROM {$CFG->prefix}user u,
{$CFG->prefix}jclic_sessions js
WHERE js.jclicid = '$jclicid' and
u.id = js.user_id");
//Get teachers
$teachers = get_records_sql("SELECT DISTINCT u.id, u.id as userid
FROM {$CFG->prefix}user u,
{$CFG->prefix}jclic_sessions js
WHERE js.jclicid = '$jclicid' and
u.id = js.user_id");
//Add teachers to students
if ($teachers) {
foreach ($teachers as $teacher) {
$students[$teacher->id] = $teacher;
}
}
//Return students array (it contains an array of unique users)
return ($students);
}
function jclic_scale_used ($jclicid,$scaleid) {
//This function returns if a scale is being used by one jclic
//it it has support for grading and scales. Commented code should be
//modified if necessary. See forum, glossary or journal modules
//as reference.
$return = false;
return $return;
}
/**
* Checks if scale is being used by any instance of jclic
*
* This is used to find out if scale used anywhere
* @param $scaleid int
* @return boolean
*/
function jclic_scale_used_anywhere($scaleid) {
return false;
}
//////////////////////////////////////////////////////////////////////////////////////
/**
* Get user sessions
*
* @return array [0=>session1,1=>session2...] where session1 is an array with keys: id,score,totaltime,starttime,done,solved,attempts. First sessions are newest.
* @param object $jclicid The jclic to get sessions
* @param object $userid The user id to get sessions
*/
function jclic_get_sessions($jclicid, $userid) {
global $CFG;
$sessions=array();
if($rs = get_records_sql("SELECT js.*
FROM {$CFG->prefix}jclic j, {$CFG->prefix}jclic_sessions js
WHERE j.id=js.jclicid AND js.jclicid=$jclicid AND js.user_id=$userid
ORDER BY js.session_datetime")){
$i=0;
foreach($rs as $session){
$activity=jclic_get_activity($session);
$activity->attempts=$i+1;
$sessions[$i++]=$activity;
}
}
return $sessions;
}
/**
* Get session activities
*
* @return array [0=>act0,1=>act1...] where act0 is an array with keys: activity_id,activity_name,num_actions,score,activity_solved,qualification, total_time. First activity are oldest.
* @param string $session_id The session id to get actitivies
*/
function jclic_get_activities($session_id) {
global $CFG;
if($rs = get_records("jclic_activities", "session_id", "$session_id",'activity_id')){
$i=0;
foreach($rs as $activity){
$activities[$i++]=$activity;
}
}
return $activities;
}
/**
* Get information about activities of specified session
*
* @return array Array has these keys id,score,totaltime,starttime,done,solved,attempts
* @param object $session The session object
*/
function jclic_get_activity($session) {
global $CFG;
$activity->starttime=$session->session_datetime;
$activity->session_id=$session->session_id;
if($rs = get_record_sql("SELECT AVG(ja.qualification) as qualification, SUM(ja.total_time) as totaltime
FROM {$CFG->prefix}jclic_activities ja
WHERE ja.session_id='$session->session_id'")){
$activity->score=round($rs->qualification,0);
$activity->totaltime=round($rs->totaltime/60000,0)."' ".round(fmod($rs->totaltime,60000)/1000,0)."''";
}
if ($rs = get_record_sql("SELECT COUNT(*) as done
FROM (SELECT DISTINCT ja.activity_name
FROM {$CFG->prefix}jclic_activities ja
WHERE ja.session_id='$session->session_id') t")){
$activity->done=$rs->done;
}
if ($rs = get_record_sql("SELECT COUNT(*) as solved
FROM (SELECT DISTINCT ja.activity_name
FROM {$CFG->prefix}jclic_activities ja
WHERE ja.session_id='$session->session_id' AND ja.activity_solved=1) t")){
$activity->solved=$rs->solved;
}
return $activity;
}
/**
* Get user activity summary
*
* @return object session object with score, totaltime, activities done and solved and attempts information
*/
function jclic_get_sessions_summary($jclicid, $userid) {
global $CFG;
$sessions_sumari = array('attempts'=>'','score'=>'','totaltime'=>'','starttime'=>'','done'=>'','solved'=>'');
if ($rs = get_record_sql("SELECT COUNT(*) AS attempts, AVG(t.qualification) AS qualification, SUM(t.totaltime) AS totaltime, MAX(t.starttime) AS starttime
FROM (SELECT AVG(ja.qualification) AS qualification, SUM(ja.total_time) AS totaltime, MAX(js.session_datetime) AS starttime
FROM {$CFG->prefix}jclic j, {$CFG->prefix}jclic_sessions js, {$CFG->prefix}jclic_activities ja
WHERE j.id=js.jclicid AND js.user_id=$userid AND js.jclicid=$jclicid AND ja.session_id=js.session_id
GROUP BY js.session_id) t")){
$sessions_summary->attempts=$rs->attempts;
$sessions_summary->score=round($rs->qualification,0);
$sessions_summary->totaltime=round($rs->totaltime/60000,0)."' ".round(fmod($rs->totaltime,60000)/1000,0)."''";
$sessions_summary->starttime=$rs->starttime;
}
if ($rs = get_record_sql("SELECT COUNT(*) as done
FROM (SELECT DISTINCT ja.activity_name
FROM {$CFG->prefix}jclic j, {$CFG->prefix}jclic_sessions js, {$CFG->prefix}jclic_activities ja
WHERE j.id=js.jclicid AND js.user_id=$userid AND js.jclicid=$jclicid AND js.session_id=ja.session_id) t")){
$sessions_summary->done=$rs->done;
}
if ($rs = get_record_sql("SELECT COUNT(*) as solved
FROM (SELECT DISTINCT ja.activity_name
FROM {$CFG->prefix}jclic j, {$CFG->prefix}jclic_sessions js, {$CFG->prefix}jclic_activities ja
WHERE j.id=js.jclicid AND js.user_id=$userid AND js.jclicid=$jclicid AND js.session_id=ja.session_id AND ja.activity_solved=1) t")){
$sessions_summary->solved=$rs->solved;
}
return $sessions_summary;
}
/**
* Format time from milliseconds to string
*
* @return string Formated string [x' y''], where x are the minutes and y are the seconds.
* @param int $time The time (in ms)
*/
function jclic_time2str($time){
return round($time/60000,0)."' ".round(fmod($time,60000)/1000,0)."''";
}
/**
* Print data in array as a row. Uses jclic_make_row function to get the string representation to print
*
* @param array $row Data
* @param array $align Cell alignment
* @param array $props Style, rowspan, colspan...
* @param boolean $header If true the row will be printed as th; otherwise as td.
*/
function jclic_print_row($row, $align, $props=array(), $header=false){
echo jclic_make_row($row, $align, $props, $header);
}
function jclic_make_row($row, $row_align, $row_props=array(), $header=false){
$strrow = '';
$strtd = $header?'th':'td';
if (sizeof($row)>0){
$strrow.='';
$i=0;
foreach($row as $cell){
$prop = ''; $align='';
if ($row_props!='' && array_key_exists($i, $row_props) && $row_props[$i]!='') $prop = ' '.$row_props[$i].' ';
if ($row_align!=''&& array_key_exists($i, $row_align) && $row_align[$i]!='') $align = ' align='.$row_align[$i].' ';
$strrow.='<'.$strtd.' '.($header?'':'class="cell"').$prop.$align.'>'.$cell.''.$strtd.'>';
$i++;
}
$strrow.='
';
}
return $strrow;
}
/**
* Print a table data with all session activities
*
* @param string $session_id The session identifier
*/
function print_session_activities($session_id){
// Import language strings
$stractivity = get_string("activity", "jclic");
$strsolved = get_string("solved", "jclic");
$stractions = get_string("actions", "jclic");
$strtime = get_string("time", "jclic");
$strscore = get_string("score", "jclic");
$stryes = get_string("yes");
$strno = get_string("no");
// Print activities for each session
$activities=jclic_get_activities($session_id);
if (sizeof($activities)>0){
echo '';
echo ' ';
$subtable_align=array('left','center','center','center','center');
jclic_print_row(array($stractivity, $strsolved, $stractions, $strtime, $strscore),$subtable_align,'',true);
foreach($activities as $activity){
$subtable_props=array('', 'style="background-color:'.($activity->activity_solved?'#DFFFDF':'#FFDFDF').'"','','','');
$act_percent=$activity->num_actions>0?round(($activity->score/$activity->num_actions)*100,0):0;
jclic_print_row(array($activity->activity_name, ($activity->activity_solved?$stryes:$strno), $activity->score.'/'.$activity->num_actions.' ('.$act_percent.'%)', jclic_time2str($activity->total_time), $activity->qualification.'%'), $subtable_align, $subtable_props);
}
echo ' |
';
}
}
function jclic_get_skins(){
return array('@default.xml' => 'default','@blue.xml' => 'blue','@orange.xml' => 'orange','@green.xml' => 'green','@simple.xml' => 'simple', '@mini.xml' => 'mini');
}
/**
* Get an array with the languages
*
* @return array The array with each language.
*/
function jclic_get_languages(){
global $CFG;
$tmplanglist = get_list_of_languages();
$langlist = array();
foreach ($tmplanglist as $lang=>$langname) {
if (substr($lang, -5) == '_utf8') { //Remove the _utf8 suffix from the lang to show
$lang = substr($lang, 0, -5);
}
$langlist[$lang]=$langname;
}
return $langlist;
}
/**
* Get moodle server
*
* @return string myserver.com:port
*/
function jclic_get_server() {
global $CFG;
if (!empty($CFG->wwwroot)) {
$url = parse_url($CFG->wwwroot);
}
if (!empty($url['host'])) {
$hostname = $url['host'];
} else if (!empty($_SERVER['SERVER_NAME'])) {
$hostname = $_SERVER['SERVER_NAME'];
} else if (!empty($_ENV['SERVER_NAME'])) {
$hostname = $_ENV['SERVER_NAME'];
} else if (!empty($_SERVER['HTTP_HOST'])) {
$hostname = $_SERVER['HTTP_HOST'];
} else if (!empty($_ENV['HTTP_HOST'])) {
$hostname = $_ENV['HTTP_HOST'];
} else {
notify('Warning: could not find the name of this server!');
return false;
}
if (!empty($url['port'])) {
$hostname .= ':'.$url['port'];
} else if (!empty($_SERVER['SERVER_PORT'])) {
if ($_SERVER['SERVER_PORT'] != 80 && $_SERVER['SERVER_PORT'] != 443) {
$hostname .= ':'.$_SERVER['SERVER_PORT'];
}
}
return $hostname;
}
/**
* Get moodle path
*
* @return string /path_to_moodle
*/
function jclic_get_path() {
global $CFG;
$path = '/';
if (!empty($CFG->wwwroot)) {
$url = parse_url($CFG->wwwroot);
if (array_key_exists('path', $url)){
$path = $url['path'];
}
}
return $path;
}
if (!function_exists('get_coursemodule_from_id')) {
// Add this function for Moodle < 1.6
function get_coursemodule_from_id($modulename, $cmid, $courseid=0) {
global $CFG;
return get_record_sql("
SELECT
cm.*, m.name, md.name as modname
FROM
{$CFG->prefix}course_modules cm,
{$CFG->prefix}modules md,
{$CFG->prefix}$modulename m
WHERE
".($courseid ? "cm.course = '$courseid' AND " : '')."
cm.id = '$cmid' AND
cm.instance = m.id AND
md.name = '$modulename' AND
md.id = cm.module
");
}
}
/**
* This function is used by the reset_course_userdata function in moodlelib.
* This function will remove all jclic sessions in the specified course.
* @param $data the data submitted from the reset course.
* @return array status array
*/
function jclic_reset_userdata($data) {
global $CFG;
require_once($CFG->libdir.'/filelib.php');
$status = array();
if (!empty($data->reset_jclic_deleteallsessions)) {
$select = 'session_id IN'
. " (SELECT s.session_id FROM {$CFG->prefix}jclic_sessions s"
. " INNER JOIN {$CFG->prefix}jclic j ON s.jclicid = j.id"
. " WHERE j.course = {$data->courseid})";
delete_records_select('jclic_activities', $select);
$select = 'jclicid IN'
. " (SELECT j.id FROM {$CFG->prefix}jclic j"
. " WHERE j.course = {$data->courseid})";
delete_records_select('jclic_sessions', $select);
$status[] = array('component' => get_string('modulenameplural', 'jclic'),
'item' => get_string('deleteallsessions', 'jclic'),
'error' => false);
}
return $status;
}
/**
* Called by course/reset.php
* @param $mform form passed by reference
*/
function jclic_reset_course_form_definition(&$mform) {
$mform->addElement('header', 'jclicheader', get_string('modulenameplural', 'jclic'));
$mform->addElement('checkbox', 'reset_jclic_deleteallsessions', get_string('deleteallsessions', 'jclic'));
}
/**
* Course reset form defaults.
*/
function jclic_reset_course_form_defaults($course) {
return array('reset_jclic_deleteallsessions' => 1);
}
?>
jclicmoodle-0.1.0.11/mod/jclic/icon.gif 0000664 0001750 0001750 00000000250 11567136416 017621 0 ustar demarchi demarchi GIF89a f M L %ـrf3 ! , UI$8k}1Ha@0v
, !
n7
Fh8EsxIC e::8ZY ; jclicmoodle-0.1.0.11/mod/jclic/version.php 0000664 0001750 0001750 00000001017 11567171117 020377 0 ustar demarchi demarchi version = 2011011900; // The current module version (Date: YYYYMMDDXX)
$module->cron = 0; // Period for cron to check this module (secs)
?>
jclicmoodle-0.1.0.11/mod/jclic/restorelib.php 0000664 0001750 0001750 00000016124 11567171117 021071 0 ustar demarchi demarchi id)
//
// jclic_sessions
// (UL, pk->id, fk->jclicid)
//
// jclic_activities
// (pk->id, fk->session_id)
//
//
// Meaning: pk->primary key field of the table
// fk->foreign key to link with parent
// nt->nested field (recursive data)
// CL->course level info
// UL->user level info
// files->table may have files)
//
//-----------------------------------------------------------
function jclic_restore_mods($mod,$restore) {
global $CFG;
$status = true;
//Get record from backup_ids
$data = backup_getid($restore->backup_unique_code,$mod->modtype,$mod->id);
if ($data) {
//Now get completed xmlized object
$info = $data->info;
//traverse_xmlize($info); //Debug
//print_object ($GLOBALS['traverse_array']); //Debug
//$GLOBALS['traverse_array']=""; //Debug
//Now, build the JClic record structure
$jclic->course = $restore->course_id;
$jclic->name = backup_todb($info['MOD']['#']['NAME']['0']['#']);
$jclic->description = backup_todb($info['MOD']['#']['DESCRIPTION']['0']['#']);
$jclic->url = backup_todb($info['MOD']['#']['URL']['0']['#']);
$jclic->skin = backup_todb($info['MOD']['#']['SKIN']['0']['#']);
$jclic->maxattempts = backup_todb($info['MOD']['#']['MAXATTEMPTS']['0']['#']);
$jclic->width = backup_todb($info['MOD']['#']['WIDTH']['0']['#']);
$jclic->height = backup_todb($info['MOD']['#']['HEIGHT']['0']['#']);
$jclic->avaluation = backup_todb($info['MOD']['#']['AVALUATION']['0']['#']);
$jclic->maxgrade = backup_todb($info['MOD']['#']['MAXGRADE']['0']['#']);
//The structure is equal to the db, so insert the jclic
$newid = insert_record ("jclic",$jclic);
//Do some output
echo "".get_string("modulename","jclic")." \"".format_string(stripslashes($jclic->name),true)."\"";
backup_flush(300);
if ($newid) {
//We have the newid, update backup_ids
backup_putid($restore->backup_unique_code,$mod->modtype,
$mod->id, $newid);
//Now check if want to restore user data and do it.
if ($restore->mods['jclic']->userinfo) {
//Restore jclic_sessions
$status = jclic_sessions_restore_mods($mod->id,$newid,$info,$restore);
}
} else {
$status = false;
}
} else {
$status = false;
}
return $status;
}
//This function restores the jclic_sessions
function jclic_sessions_restore_mods($old_jclic_id,$new_jclic_id,$info,$restore) {
global $CFG;
$status = true;
//Get the sessions array
$sessions = array();
if (array_key_exists('SESSIONS', $info['MOD']['#']))
$sessions = $info['MOD']['#']['SESSIONS']['0']['#']['SESSION'];
//Iterate over sessions
for($i = 0; $i < sizeof($sessions); $i++) {
$session = $sessions[$i];
//traverse_xmlize($ent_info); //Debug
//print_object ($GLOBALS['traverse_array']); //Debug
//$GLOBALS['traverse_array']=""; //Debug
//Now, build the jclic_sessions record structure
$entry->jclicid = $new_jclic_id;
//$entry->session_id = backup_todb($session['#']['SESSION_ID']['0']['#']);
$entry->user_id = backup_todb($session['#']['USER_ID']['0']['#']);
$entry->session_datetime = backup_todb($session['#']['SESSION_DATETIME']['0']['#']);
$entry->project_name = backup_todb($session['#']['PROJECT_NAME']['0']['#']);
$entry->session_key = backup_todb($session['#']['SESSION_KEY']['0']['#']);
$entry->session_code = backup_todb($session['#']['SESSION_CODE']['0']['#']);
$entry->session_context = backup_todb($session['#']['SESSION_CONTEXT']['0']['#']);
//We have to recode the user_id field
$user = backup_getid($restore->backup_unique_code,"user",$entry->user_id);
if ($user) {
$entry->user_id = $user->new_id;
}
$microtime_arr=split(' ',microtime());
$entry->session_id = $entry->user_id."_".$microtime_arr[1].substr($microtime_arr[0],2);
//The structure is equal to the db, so insert the jclic_sessions
$newid = insert_record ("jclic_sessions",$entry);
//Get the activities array
$activities = array();
if (array_key_exists('ACTIVITIES', $session['#']))
$activities = $session['#']['ACTIVITIES']['0']['#']['ACTIVITY'];
//Iterate over activities
for($j = 0; $j < sizeof($activities); $j++) {
$activity = $activities[$j];
//Now, build the jclic_activities record structure
$entry2->session_id = $entry->session_id;
$entry2->activity_id = backup_todb($activity['#']['ACTIVITY_ID']['0']['#']);
$entry2->activity_name = backup_todb($activity['#']['ACTIVITY_NAME']['0']['#']);
$entry2->num_actions = backup_todb($activity['#']['NUM_ACTIONS']['0']['#']);
$entry2->score = backup_todb($activity['#']['SCORE']['0']['#']);
$entry2->activity_solved = backup_todb($activity['#']['ACTIVITY_SOLVED']['0']['#']);
$entry2->qualification = backup_todb($activity['#']['QUALIFICATION']['0']['#']);
$entry2->total_time = backup_todb($activity['#']['TOTAL_TIME']['0']['#']);
$entry2->activity_code = backup_todb($activity['#']['ACTIVITY_CODE']['0']['#']);
//The structure is equal to the db, so insert the jclic_activities
$newid2 = insert_record ("jclic_activities",$entry2);
//Do some output
if (($j+1) % 50 == 0) {
echo ".";
if (($j+1) % 1000 == 0) {
echo "
";
}
backup_flush(300);
}
}
//Do some output
if (($i+1) % 50 == 0) {
echo ".";
if (($i+1) % 1000 == 0) {
echo "
";
}
backup_flush(300);
}
}
return $status;
}
?>
jclicmoodle-0.1.0.11/mod/jclic/mod.html 0000664 0001750 0001750 00000011271 11567171117 017651 0 ustar demarchi demarchi
name)) {
$form->name = '';
}
if (!isset($form->url)) {
$form->url = '';
}
if (!isset($form->skin)) {
$form->skin = '';
}
?>
jclicmoodle-0.1.0.11/mod/jclic/index.php 0000664 0001750 0001750 00000010065 11567171117 020024 0 ustar demarchi demarchi id);
add_to_log($course->id, "jclic", "view all", "index.php?id=$course->id", "");
/// Get all required strings
$strjclics = get_string("modulenameplural", "jclic");
$strjclic = get_string("modulename", "jclic");
$strnotavailable = get_string("notavailable");
/// Print the header
if ($course->category) {
$navigation = "id\">$course->shortname ->";
}
print_header_simple("$strjclics", "", "$strjclics", "", "", true, "", navmenu($course));
print_heading(get_string("modulename", "jclic"));
/// Get all the appropriate data
if (! $jclics = get_all_instances_in_course("jclic", $course)) {
notice("There are no jclics", "../../course/view.php?id=$course->id");
die;
}
/// Print the list of instances (your module will probably extend this)
$strweek = get_string("week");
$strtopic = get_string("topic");
$strname = get_string("name");
$strdescription = get_string("description");
if ($course->format == "weeks" || $course->format == "topics") {
if ($course->format == "weeks") $first=$strweek;
else if ($course->format == "topics") $first=$strtopic;
if (isteacher($course->id)){
$table->head = array ($first, ' '.$strname, $strdescription);
$table->align = array ("CENTER", "LEFT", "LEFT", "CENTER");
}else{
$strlastaccess = get_string("lastaccess","jclic");
$strscore = get_string("score","jclic");
$strattempts = get_string("attempts","jclic");
$table->head = array ($first, ' '.$strname, $strdescription,$strlastaccess,$strscore,$strattempts);
$table->align = array ("CENTER", "LEFT", "LEFT", "CENTER","CENTER","CENTER");
}
$table->wrap = array ("NOWRAP","NOWRAP");
} else {
$table->head = array ($strname);
$table->align = array ("LEFT", "LEFT", "LEFT");
}
if (isteacher($course->id)){
foreach ($jclics as $jclic) {
if (!$jclic->visible) {
//Show dimmed if the mod is hidden
$link = "coursemodule\">$jclic->name";
} else {
//Show normal if the mod is visible
$link = "coursemodule\">$jclic->name";
}
if ($course->format == "weeks" or $course->format == "topics") {
$table->data[] = array ($jclic->section, $link, $jclic->description);
} else {
$table->data[] = array ($link);
}
}
echo "
";
print_table($table);
}else{
foreach ($jclics as $jclic) {
if (!$jclic->visible) {
//Show dimmed if the mod is hidden
$link = "coursemodule\">$jclic->name";
} else {
//Show normal if the mod is visible
$link = "coursemodule\">$jclic->name";
}
$sessions_summary=jclic_get_sessions_summary($jclic->id,$USER->id);
$lastaccess='-';
if ($sessions_summary->starttime>0) $lastaccess=date('d/m/Y H:i',strtotime($sessions_summary->starttime));
$score=$sessions_summary->score.'%';
$attempts=$sessions_summary->attempts;
if ($jclic->maxattempts>0)$attempts.='/'.$jclic->maxattempts;
if ($course->format == "weeks" or $course->format == "topics") {
$table->data[] = array ($jclic->section, $link, $jclic->description,$lastaccess,$score,$attempts);
} else {
$table->data[] = array ($link);
}
}
echo "
";
print_table($table);
}
/// Finish the page
print_footer($course);
?>
jclicmoodle-0.1.0.11/mod/jclic/prototype.js 0000664 0001750 0001750 00000273456 11567136416 020631 0 ustar demarchi demarchi /* Prototype JavaScript framework, version 1.5.1
* (c) 2005-2007 Sam Stephenson
*
* Prototype is freely distributable under the terms of an MIT-style license.
* For details, see the Prototype web site: http://www.prototypejs.org/
*
/*--------------------------------------------------------------------------*/
var Prototype = {
Version: '1.5.1',
Browser: {
IE: !!(window.attachEvent && !window.opera),
Opera: !!window.opera,
WebKit: navigator.userAgent.indexOf('AppleWebKit/') > -1,
Gecko: navigator.userAgent.indexOf('Gecko') > -1 && navigator.userAgent.indexOf('KHTML') == -1
},
BrowserFeatures: {
XPath: !!document.evaluate,
ElementExtensions: !!window.HTMLElement,
SpecificElementExtensions:
(document.createElement('div').__proto__ !==
document.createElement('form').__proto__)
},
ScriptFragment: '',
JSONFilter: /^\/\*-secure-\s*(.*)\s*\*\/\s*$/,
emptyFunction: function() { },
K: function(x) { return x }
}
var Class = {
create: function() {
return function() {
this.initialize.apply(this, arguments);
}
}
}
var Abstract = new Object();
Object.extend = function(destination, source) {
for (var property in source) {
destination[property] = source[property];
}
return destination;
}
Object.extend(Object, {
inspect: function(object) {
try {
if (object === undefined) return 'undefined';
if (object === null) return 'null';
return object.inspect ? object.inspect() : object.toString();
} catch (e) {
if (e instanceof RangeError) return '...';
throw e;
}
},
toJSON: function(object) {
var type = typeof object;
switch(type) {
case 'undefined':
case 'function':
case 'unknown': return;
case 'boolean': return object.toString();
}
if (object === null) return 'null';
if (object.toJSON) return object.toJSON();
if (object.ownerDocument === document) return;
var results = [];
for (var property in object) {
var value = Object.toJSON(object[property]);
if (value !== undefined)
results.push(property.toJSON() + ': ' + value);
}
return '{' + results.join(', ') + '}';
},
keys: function(object) {
var keys = [];
for (var property in object)
keys.push(property);
return keys;
},
values: function(object) {
var values = [];
for (var property in object)
values.push(object[property]);
return values;
},
clone: function(object) {
return Object.extend({}, object);
}
});
Function.prototype.bind = function() {
var __method = this, args = $A(arguments), object = args.shift();
return function() {
return __method.apply(object, args.concat($A(arguments)));
}
}
Function.prototype.bindAsEventListener = function(object) {
var __method = this, args = $A(arguments), object = args.shift();
return function(event) {
return __method.apply(object, [event || window.event].concat(args));
}
}
Object.extend(Number.prototype, {
toColorPart: function() {
return this.toPaddedString(2, 16);
},
succ: function() {
return this + 1;
},
times: function(iterator) {
$R(0, this, true).each(iterator);
return this;
},
toPaddedString: function(length, radix) {
var string = this.toString(radix || 10);
return '0'.times(length - string.length) + string;
},
toJSON: function() {
return isFinite(this) ? this.toString() : 'null';
}
});
Date.prototype.toJSON = function() {
return '"' + this.getFullYear() + '-' +
(this.getMonth() + 1).toPaddedString(2) + '-' +
this.getDate().toPaddedString(2) + 'T' +
this.getHours().toPaddedString(2) + ':' +
this.getMinutes().toPaddedString(2) + ':' +
this.getSeconds().toPaddedString(2) + '"';
};
var Try = {
these: function() {
var returnValue;
for (var i = 0, length = arguments.length; i < length; i++) {
var lambda = arguments[i];
try {
returnValue = lambda();
break;
} catch (e) {}
}
return returnValue;
}
}
/*--------------------------------------------------------------------------*/
var PeriodicalExecuter = Class.create();
PeriodicalExecuter.prototype = {
initialize: function(callback, frequency) {
this.callback = callback;
this.frequency = frequency;
this.currentlyExecuting = false;
this.registerCallback();
},
registerCallback: function() {
this.timer = setInterval(this.onTimerEvent.bind(this), this.frequency * 1000);
},
stop: function() {
if (!this.timer) return;
clearInterval(this.timer);
this.timer = null;
},
onTimerEvent: function() {
if (!this.currentlyExecuting) {
try {
this.currentlyExecuting = true;
this.callback(this);
} finally {
this.currentlyExecuting = false;
}
}
}
}
Object.extend(String, {
interpret: function(value) {
return value == null ? '' : String(value);
},
specialChar: {
'\b': '\\b',
'\t': '\\t',
'\n': '\\n',
'\f': '\\f',
'\r': '\\r',
'\\': '\\\\'
}
});
Object.extend(String.prototype, {
gsub: function(pattern, replacement) {
var result = '', source = this, match;
replacement = arguments.callee.prepareReplacement(replacement);
while (source.length > 0) {
if (match = source.match(pattern)) {
result += source.slice(0, match.index);
result += String.interpret(replacement(match));
source = source.slice(match.index + match[0].length);
} else {
result += source, source = '';
}
}
return result;
},
sub: function(pattern, replacement, count) {
replacement = this.gsub.prepareReplacement(replacement);
count = count === undefined ? 1 : count;
return this.gsub(pattern, function(match) {
if (--count < 0) return match[0];
return replacement(match);
});
},
scan: function(pattern, iterator) {
this.gsub(pattern, iterator);
return this;
},
truncate: function(length, truncation) {
length = length || 30;
truncation = truncation === undefined ? '...' : truncation;
return this.length > length ?
this.slice(0, length - truncation.length) + truncation : this;
},
strip: function() {
return this.replace(/^\s+/, '').replace(/\s+$/, '');
},
stripTags: function() {
return this.replace(/<\/?[^>]+>/gi, '');
},
stripScripts: function() {
return this.replace(new RegExp(Prototype.ScriptFragment, 'img'), '');
},
extractScripts: function() {
var matchAll = new RegExp(Prototype.ScriptFragment, 'img');
var matchOne = new RegExp(Prototype.ScriptFragment, 'im');
return (this.match(matchAll) || []).map(function(scriptTag) {
return (scriptTag.match(matchOne) || ['', ''])[1];
});
},
evalScripts: function() {
return this.extractScripts().map(function(script) { return eval(script) });
},
escapeHTML: function() {
var self = arguments.callee;
self.text.data = this;
return self.div.innerHTML;
},
unescapeHTML: function() {
var div = document.createElement('div');
div.innerHTML = this.stripTags();
return div.childNodes[0] ? (div.childNodes.length > 1 ?
$A(div.childNodes).inject('', function(memo, node) { return memo+node.nodeValue }) :
div.childNodes[0].nodeValue) : '';
},
toQueryParams: function(separator) {
var match = this.strip().match(/([^?#]*)(#.*)?$/);
if (!match) return {};
return match[1].split(separator || '&').inject({}, function(hash, pair) {
if ((pair = pair.split('='))[0]) {
var key = decodeURIComponent(pair.shift());
var value = pair.length > 1 ? pair.join('=') : pair[0];
if (value != undefined) value = decodeURIComponent(value);
if (key in hash) {
if (hash[key].constructor != Array) hash[key] = [hash[key]];
hash[key].push(value);
}
else hash[key] = value;
}
return hash;
});
},
toArray: function() {
return this.split('');
},
succ: function() {
return this.slice(0, this.length - 1) +
String.fromCharCode(this.charCodeAt(this.length - 1) + 1);
},
times: function(count) {
var result = '';
for (var i = 0; i < count; i++) result += this;
return result;
},
camelize: function() {
var parts = this.split('-'), len = parts.length;
if (len == 1) return parts[0];
var camelized = this.charAt(0) == '-'
? parts[0].charAt(0).toUpperCase() + parts[0].substring(1)
: parts[0];
for (var i = 1; i < len; i++)
camelized += parts[i].charAt(0).toUpperCase() + parts[i].substring(1);
return camelized;
},
capitalize: function() {
return this.charAt(0).toUpperCase() + this.substring(1).toLowerCase();
},
underscore: function() {
return this.gsub(/::/, '/').gsub(/([A-Z]+)([A-Z][a-z])/,'#{1}_#{2}').gsub(/([a-z\d])([A-Z])/,'#{1}_#{2}').gsub(/-/,'_').toLowerCase();
},
dasherize: function() {
return this.gsub(/_/,'-');
},
inspect: function(useDoubleQuotes) {
var escapedString = this.gsub(/[\x00-\x1f\\]/, function(match) {
var character = String.specialChar[match[0]];
return character ? character : '\\u00' + match[0].charCodeAt().toPaddedString(2, 16);
});
if (useDoubleQuotes) return '"' + escapedString.replace(/"/g, '\\"') + '"';
return "'" + escapedString.replace(/'/g, '\\\'') + "'";
},
toJSON: function() {
return this.inspect(true);
},
unfilterJSON: function(filter) {
return this.sub(filter || Prototype.JSONFilter, '#{1}');
},
evalJSON: function(sanitize) {
var json = this.unfilterJSON();
try {
if (!sanitize || (/^("(\\.|[^"\\\n\r])*?"|[,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t])+?$/.test(json)))
return eval('(' + json + ')');
} catch (e) { }
throw new SyntaxError('Badly formed JSON string: ' + this.inspect());
},
include: function(pattern) {
return this.indexOf(pattern) > -1;
},
startsWith: function(pattern) {
return this.indexOf(pattern) === 0;
},
endsWith: function(pattern) {
var d = this.length - pattern.length;
return d >= 0 && this.lastIndexOf(pattern) === d;
},
empty: function() {
return this == '';
},
blank: function() {
return /^\s*$/.test(this);
}
});
if (Prototype.Browser.WebKit || Prototype.Browser.IE) Object.extend(String.prototype, {
escapeHTML: function() {
return this.replace(/&/g,'&').replace(//g,'>');
},
unescapeHTML: function() {
return this.replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>');
}
});
String.prototype.gsub.prepareReplacement = function(replacement) {
if (typeof replacement == 'function') return replacement;
var template = new Template(replacement);
return function(match) { return template.evaluate(match) };
}
String.prototype.parseQuery = String.prototype.toQueryParams;
Object.extend(String.prototype.escapeHTML, {
div: document.createElement('div'),
text: document.createTextNode('')
});
with (String.prototype.escapeHTML) div.appendChild(text);
var Template = Class.create();
Template.Pattern = /(^|.|\r|\n)(#\{(.*?)\})/;
Template.prototype = {
initialize: function(template, pattern) {
this.template = template.toString();
this.pattern = pattern || Template.Pattern;
},
evaluate: function(object) {
return this.template.gsub(this.pattern, function(match) {
var before = match[1];
if (before == '\\') return match[2];
return before + String.interpret(object[match[3]]);
});
}
}
var $break = {}, $continue = new Error('"throw $continue" is deprecated, use "return" instead');
var Enumerable = {
each: function(iterator) {
var index = 0;
try {
this._each(function(value) {
iterator(value, index++);
});
} catch (e) {
if (e != $break) throw e;
}
return this;
},
eachSlice: function(number, iterator) {
var index = -number, slices = [], array = this.toArray();
while ((index += number) < array.length)
slices.push(array.slice(index, index+number));
return slices.map(iterator);
},
all: function(iterator) {
var result = true;
this.each(function(value, index) {
result = result && !!(iterator || Prototype.K)(value, index);
if (!result) throw $break;
});
return result;
},
any: function(iterator) {
var result = false;
this.each(function(value, index) {
if (result = !!(iterator || Prototype.K)(value, index))
throw $break;
});
return result;
},
collect: function(iterator) {
var results = [];
this.each(function(value, index) {
results.push((iterator || Prototype.K)(value, index));
});
return results;
},
detect: function(iterator) {
var result;
this.each(function(value, index) {
if (iterator(value, index)) {
result = value;
throw $break;
}
});
return result;
},
findAll: function(iterator) {
var results = [];
this.each(function(value, index) {
if (iterator(value, index))
results.push(value);
});
return results;
},
grep: function(pattern, iterator) {
var results = [];
this.each(function(value, index) {
var stringValue = value.toString();
if (stringValue.match(pattern))
results.push((iterator || Prototype.K)(value, index));
})
return results;
},
include: function(object) {
var found = false;
this.each(function(value) {
if (value == object) {
found = true;
throw $break;
}
});
return found;
},
inGroupsOf: function(number, fillWith) {
fillWith = fillWith === undefined ? null : fillWith;
return this.eachSlice(number, function(slice) {
while(slice.length < number) slice.push(fillWith);
return slice;
});
},
inject: function(memo, iterator) {
this.each(function(value, index) {
memo = iterator(memo, value, index);
});
return memo;
},
invoke: function(method) {
var args = $A(arguments).slice(1);
return this.map(function(value) {
return value[method].apply(value, args);
});
},
max: function(iterator) {
var result;
this.each(function(value, index) {
value = (iterator || Prototype.K)(value, index);
if (result == undefined || value >= result)
result = value;
});
return result;
},
min: function(iterator) {
var result;
this.each(function(value, index) {
value = (iterator || Prototype.K)(value, index);
if (result == undefined || value < result)
result = value;
});
return result;
},
partition: function(iterator) {
var trues = [], falses = [];
this.each(function(value, index) {
((iterator || Prototype.K)(value, index) ?
trues : falses).push(value);
});
return [trues, falses];
},
pluck: function(property) {
var results = [];
this.each(function(value, index) {
results.push(value[property]);
});
return results;
},
reject: function(iterator) {
var results = [];
this.each(function(value, index) {
if (!iterator(value, index))
results.push(value);
});
return results;
},
sortBy: function(iterator) {
return this.map(function(value, index) {
return {value: value, criteria: iterator(value, index)};
}).sort(function(left, right) {
var a = left.criteria, b = right.criteria;
return a < b ? -1 : a > b ? 1 : 0;
}).pluck('value');
},
toArray: function() {
return this.map();
},
zip: function() {
var iterator = Prototype.K, args = $A(arguments);
if (typeof args.last() == 'function')
iterator = args.pop();
var collections = [this].concat(args).map($A);
return this.map(function(value, index) {
return iterator(collections.pluck(index));
});
},
size: function() {
return this.toArray().length;
},
inspect: function() {
return '#';
}
}
Object.extend(Enumerable, {
map: Enumerable.collect,
find: Enumerable.detect,
select: Enumerable.findAll,
member: Enumerable.include,
entries: Enumerable.toArray
});
var $A = Array.from = function(iterable) {
if (!iterable) return [];
if (iterable.toArray) {
return iterable.toArray();
} else {
var results = [];
for (var i = 0, length = iterable.length; i < length; i++)
results.push(iterable[i]);
return results;
}
}
if (Prototype.Browser.WebKit) {
$A = Array.from = function(iterable) {
if (!iterable) return [];
if (!(typeof iterable == 'function' && iterable == '[object NodeList]') &&
iterable.toArray) {
return iterable.toArray();
} else {
var results = [];
for (var i = 0, length = iterable.length; i < length; i++)
results.push(iterable[i]);
return results;
}
}
}
Object.extend(Array.prototype, Enumerable);
if (!Array.prototype._reverse)
Array.prototype._reverse = Array.prototype.reverse;
Object.extend(Array.prototype, {
_each: function(iterator) {
for (var i = 0, length = this.length; i < length; i++)
iterator(this[i]);
},
clear: function() {
this.length = 0;
return this;
},
first: function() {
return this[0];
},
last: function() {
return this[this.length - 1];
},
compact: function() {
return this.select(function(value) {
return value != null;
});
},
flatten: function() {
return this.inject([], function(array, value) {
return array.concat(value && value.constructor == Array ?
value.flatten() : [value]);
});
},
without: function() {
var values = $A(arguments);
return this.select(function(value) {
return !values.include(value);
});
},
indexOf: function(object) {
for (var i = 0, length = this.length; i < length; i++)
if (this[i] == object) return i;
return -1;
},
reverse: function(inline) {
return (inline !== false ? this : this.toArray())._reverse();
},
reduce: function() {
return this.length > 1 ? this : this[0];
},
uniq: function(sorted) {
return this.inject([], function(array, value, index) {
if (0 == index || (sorted ? array.last() != value : !array.include(value)))
array.push(value);
return array;
});
},
clone: function() {
return [].concat(this);
},
size: function() {
return this.length;
},
inspect: function() {
return '[' + this.map(Object.inspect).join(', ') + ']';
},
toJSON: function() {
var results = [];
this.each(function(object) {
var value = Object.toJSON(object);
if (value !== undefined) results.push(value);
});
return '[' + results.join(', ') + ']';
}
});
Array.prototype.toArray = Array.prototype.clone;
function $w(string) {
string = string.strip();
return string ? string.split(/\s+/) : [];
}
if (Prototype.Browser.Opera){
Array.prototype.concat = function() {
var array = [];
for (var i = 0, length = this.length; i < length; i++) array.push(this[i]);
for (var i = 0, length = arguments.length; i < length; i++) {
if (arguments[i].constructor == Array) {
for (var j = 0, arrayLength = arguments[i].length; j < arrayLength; j++)
array.push(arguments[i][j]);
} else {
array.push(arguments[i]);
}
}
return array;
}
}
var Hash = function(object) {
if (object instanceof Hash) this.merge(object);
else Object.extend(this, object || {});
};
Object.extend(Hash, {
toQueryString: function(obj) {
var parts = [];
parts.add = arguments.callee.addPair;
this.prototype._each.call(obj, function(pair) {
if (!pair.key) return;
var value = pair.value;
if (value && typeof value == 'object') {
if (value.constructor == Array) value.each(function(value) {
parts.add(pair.key, value);
});
return;
}
parts.add(pair.key, value);
});
return parts.join('&');
},
toJSON: function(object) {
var results = [];
this.prototype._each.call(object, function(pair) {
var value = Object.toJSON(pair.value);
if (value !== undefined) results.push(pair.key.toJSON() + ': ' + value);
});
return '{' + results.join(', ') + '}';
}
});
Hash.toQueryString.addPair = function(key, value, prefix) {
key = encodeURIComponent(key);
if (value === undefined) this.push(key);
else this.push(key + '=' + (value == null ? '' : encodeURIComponent(value)));
}
Object.extend(Hash.prototype, Enumerable);
Object.extend(Hash.prototype, {
_each: function(iterator) {
for (var key in this) {
var value = this[key];
if (value && value == Hash.prototype[key]) continue;
var pair = [key, value];
pair.key = key;
pair.value = value;
iterator(pair);
}
},
keys: function() {
return this.pluck('key');
},
values: function() {
return this.pluck('value');
},
merge: function(hash) {
return $H(hash).inject(this, function(mergedHash, pair) {
mergedHash[pair.key] = pair.value;
return mergedHash;
});
},
remove: function() {
var result;
for(var i = 0, length = arguments.length; i < length; i++) {
var value = this[arguments[i]];
if (value !== undefined){
if (result === undefined) result = value;
else {
if (result.constructor != Array) result = [result];
result.push(value)
}
}
delete this[arguments[i]];
}
return result;
},
toQueryString: function() {
return Hash.toQueryString(this);
},
inspect: function() {
return '#';
},
toJSON: function() {
return Hash.toJSON(this);
}
});
function $H(object) {
if (object instanceof Hash) return object;
return new Hash(object);
};
// Safari iterates over shadowed properties
if (function() {
var i = 0, Test = function(value) { this.key = value };
Test.prototype.key = 'foo';
for (var property in new Test('bar')) i++;
return i > 1;
}()) Hash.prototype._each = function(iterator) {
var cache = [];
for (var key in this) {
var value = this[key];
if ((value && value == Hash.prototype[key]) || cache.include(key)) continue;
cache.push(key);
var pair = [key, value];
pair.key = key;
pair.value = value;
iterator(pair);
}
};
ObjectRange = Class.create();
Object.extend(ObjectRange.prototype, Enumerable);
Object.extend(ObjectRange.prototype, {
initialize: function(start, end, exclusive) {
this.start = start;
this.end = end;
this.exclusive = exclusive;
},
_each: function(iterator) {
var value = this.start;
while (this.include(value)) {
iterator(value);
value = value.succ();
}
},
include: function(value) {
if (value < this.start)
return false;
if (this.exclusive)
return value < this.end;
return value <= this.end;
}
});
var $R = function(start, end, exclusive) {
return new ObjectRange(start, end, exclusive);
}
var Ajax = {
getTransport: function() {
return Try.these(
function() {return new XMLHttpRequest()},
function() {return new ActiveXObject('Msxml2.XMLHTTP')},
function() {return new ActiveXObject('Microsoft.XMLHTTP')}
) || false;
},
activeRequestCount: 0
}
Ajax.Responders = {
responders: [],
_each: function(iterator) {
this.responders._each(iterator);
},
register: function(responder) {
if (!this.include(responder))
this.responders.push(responder);
},
unregister: function(responder) {
this.responders = this.responders.without(responder);
},
dispatch: function(callback, request, transport, json) {
this.each(function(responder) {
if (typeof responder[callback] == 'function') {
try {
responder[callback].apply(responder, [request, transport, json]);
} catch (e) {}
}
});
}
};
Object.extend(Ajax.Responders, Enumerable);
Ajax.Responders.register({
onCreate: function() {
Ajax.activeRequestCount++;
},
onComplete: function() {
Ajax.activeRequestCount--;
}
});
Ajax.Base = function() {};
Ajax.Base.prototype = {
setOptions: function(options) {
this.options = {
method: 'post',
asynchronous: true,
contentType: 'application/x-www-form-urlencoded',
encoding: 'UTF-8',
parameters: ''
}
Object.extend(this.options, options || {});
this.options.method = this.options.method.toLowerCase();
if (typeof this.options.parameters == 'string')
this.options.parameters = this.options.parameters.toQueryParams();
}
}
Ajax.Request = Class.create();
Ajax.Request.Events =
['Uninitialized', 'Loading', 'Loaded', 'Interactive', 'Complete'];
Ajax.Request.prototype = Object.extend(new Ajax.Base(), {
_complete: false,
initialize: function(url, options) {
this.transport = Ajax.getTransport();
this.setOptions(options);
this.request(url);
},
request: function(url) {
this.url = url;
this.method = this.options.method;
var params = Object.clone(this.options.parameters);
if (!['get', 'post'].include(this.method)) {
// simulate other verbs over post
params['_method'] = this.method;
this.method = 'post';
}
this.parameters = params;
if (params = Hash.toQueryString(params)) {
// when GET, append parameters to URL
if (this.method == 'get')
this.url += (this.url.include('?') ? '&' : '?') + params;
else if (/Konqueror|Safari|KHTML/.test(navigator.userAgent))
params += '&_=';
}
try {
if (this.options.onCreate) this.options.onCreate(this.transport);
Ajax.Responders.dispatch('onCreate', this, this.transport);
this.transport.open(this.method.toUpperCase(), this.url,
this.options.asynchronous);
if (this.options.asynchronous)
setTimeout(function() { this.respondToReadyState(1) }.bind(this), 10);
this.transport.onreadystatechange = this.onStateChange.bind(this);
this.setRequestHeaders();
this.body = this.method == 'post' ? (this.options.postBody || params) : null;
this.transport.send(this.body);
/* Force Firefox to handle ready state 4 for synchronous requests */
if (!this.options.asynchronous && this.transport.overrideMimeType)
this.onStateChange();
}
catch (e) {
this.dispatchException(e);
}
},
onStateChange: function() {
var readyState = this.transport.readyState;
if (readyState > 1 && !((readyState == 4) && this._complete))
this.respondToReadyState(this.transport.readyState);
},
setRequestHeaders: function() {
var headers = {
'X-Requested-With': 'XMLHttpRequest',
'X-Prototype-Version': Prototype.Version,
'Accept': 'text/javascript, text/html, application/xml, text/xml, */*'
};
if (this.method == 'post') {
headers['Content-type'] = this.options.contentType +
(this.options.encoding ? '; charset=' + this.options.encoding : '');
/* Force "Connection: close" for older Mozilla browsers to work
* around a bug where XMLHttpRequest sends an incorrect
* Content-length header. See Mozilla Bugzilla #246651.
*/
if (this.transport.overrideMimeType &&
(navigator.userAgent.match(/Gecko\/(\d{4})/) || [0,2005])[1] < 2005)
headers['Connection'] = 'close';
}
// user-defined headers
if (typeof this.options.requestHeaders == 'object') {
var extras = this.options.requestHeaders;
if (typeof extras.push == 'function')
for (var i = 0, length = extras.length; i < length; i += 2)
headers[extras[i]] = extras[i+1];
else
$H(extras).each(function(pair) { headers[pair.key] = pair.value });
}
for (var name in headers)
this.transport.setRequestHeader(name, headers[name]);
},
success: function() {
return !this.transport.status
|| (this.transport.status >= 200 && this.transport.status < 300);
},
respondToReadyState: function(readyState) {
var state = Ajax.Request.Events[readyState];
var transport = this.transport, json = this.evalJSON();
if (state == 'Complete') {
try {
this._complete = true;
(this.options['on' + this.transport.status]
|| this.options['on' + (this.success() ? 'Success' : 'Failure')]
|| Prototype.emptyFunction)(transport, json);
} catch (e) {
this.dispatchException(e);
}
var contentType = this.getHeader('Content-type');
if (contentType && contentType.strip().
match(/^(text|application)\/(x-)?(java|ecma)script(;.*)?$/i))
this.evalResponse();
}
try {
(this.options['on' + state] || Prototype.emptyFunction)(transport, json);
Ajax.Responders.dispatch('on' + state, this, transport, json);
} catch (e) {
this.dispatchException(e);
}
if (state == 'Complete') {
// avoid memory leak in MSIE: clean up
this.transport.onreadystatechange = Prototype.emptyFunction;
}
},
getHeader: function(name) {
try {
return this.transport.getResponseHeader(name);
} catch (e) { return null }
},
evalJSON: function() {
try {
var json = this.getHeader('X-JSON');
return json ? json.evalJSON() : null;
} catch (e) { return null }
},
evalResponse: function() {
try {
return eval((this.transport.responseText || '').unfilterJSON());
} catch (e) {
this.dispatchException(e);
}
},
dispatchException: function(exception) {
(this.options.onException || Prototype.emptyFunction)(this, exception);
Ajax.Responders.dispatch('onException', this, exception);
}
});
Ajax.Updater = Class.create();
Object.extend(Object.extend(Ajax.Updater.prototype, Ajax.Request.prototype), {
initialize: function(container, url, options) {
this.container = {
success: (container.success || container),
failure: (container.failure || (container.success ? null : container))
}
this.transport = Ajax.getTransport();
this.setOptions(options);
var onComplete = this.options.onComplete || Prototype.emptyFunction;
this.options.onComplete = (function(transport, param) {
this.updateContent();
onComplete(transport, param);
}).bind(this);
this.request(url);
},
updateContent: function() {
var receiver = this.container[this.success() ? 'success' : 'failure'];
var response = this.transport.responseText;
if (!this.options.evalScripts) response = response.stripScripts();
if (receiver = $(receiver)) {
if (this.options.insertion)
new this.options.insertion(receiver, response);
else
receiver.update(response);
}
if (this.success()) {
if (this.onComplete)
setTimeout(this.onComplete.bind(this), 10);
}
}
});
Ajax.PeriodicalUpdater = Class.create();
Ajax.PeriodicalUpdater.prototype = Object.extend(new Ajax.Base(), {
initialize: function(container, url, options) {
this.setOptions(options);
this.onComplete = this.options.onComplete;
this.frequency = (this.options.frequency || 2);
this.decay = (this.options.decay || 1);
this.updater = {};
this.container = container;
this.url = url;
this.start();
},
start: function() {
this.options.onComplete = this.updateComplete.bind(this);
this.onTimerEvent();
},
stop: function() {
this.updater.options.onComplete = undefined;
clearTimeout(this.timer);
(this.onComplete || Prototype.emptyFunction).apply(this, arguments);
},
updateComplete: function(request) {
if (this.options.decay) {
this.decay = (request.responseText == this.lastText ?
this.decay * this.options.decay : 1);
this.lastText = request.responseText;
}
this.timer = setTimeout(this.onTimerEvent.bind(this),
this.decay * this.frequency * 1000);
},
onTimerEvent: function() {
this.updater = new Ajax.Updater(this.container, this.url, this.options);
}
});
function $(element) {
if (arguments.length > 1) {
for (var i = 0, elements = [], length = arguments.length; i < length; i++)
elements.push($(arguments[i]));
return elements;
}
if (typeof element == 'string')
element = document.getElementById(element);
return Element.extend(element);
}
if (Prototype.BrowserFeatures.XPath) {
document._getElementsByXPath = function(expression, parentElement) {
var results = [];
var query = document.evaluate(expression, $(parentElement) || document,
null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
for (var i = 0, length = query.snapshotLength; i < length; i++)
results.push(query.snapshotItem(i));
return results;
};
document.getElementsByClassName = function(className, parentElement) {
var q = ".//*[contains(concat(' ', @class, ' '), ' " + className + " ')]";
return document._getElementsByXPath(q, parentElement);
}
} else document.getElementsByClassName = function(className, parentElement) {
var children = ($(parentElement) || document.body).getElementsByTagName('*');
var elements = [], child;
for (var i = 0, length = children.length; i < length; i++) {
child = children[i];
if (Element.hasClassName(child, className))
elements.push(Element.extend(child));
}
return elements;
};
/*--------------------------------------------------------------------------*/
if (!window.Element) var Element = {};
Element.extend = function(element) {
var F = Prototype.BrowserFeatures;
if (!element || !element.tagName || element.nodeType == 3 ||
element._extended || F.SpecificElementExtensions || element == window)
return element;
var methods = {}, tagName = element.tagName, cache = Element.extend.cache,
T = Element.Methods.ByTag;
// extend methods for all tags (Safari doesn't need this)
if (!F.ElementExtensions) {
Object.extend(methods, Element.Methods),
Object.extend(methods, Element.Methods.Simulated);
}
// extend methods for specific tags
if (T[tagName]) Object.extend(methods, T[tagName]);
for (var property in methods) {
var value = methods[property];
if (typeof value == 'function' && !(property in element))
element[property] = cache.findOrStore(value);
}
element._extended = Prototype.emptyFunction;
return element;
};
Element.extend.cache = {
findOrStore: function(value) {
return this[value] = this[value] || function() {
return value.apply(null, [this].concat($A(arguments)));
}
}
};
Element.Methods = {
visible: function(element) {
return $(element).style.display != 'none';
},
toggle: function(element) {
element = $(element);
Element[Element.visible(element) ? 'hide' : 'show'](element);
return element;
},
hide: function(element) {
$(element).style.display = 'none';
return element;
},
show: function(element) {
$(element).style.display = '';
return element;
},
remove: function(element) {
element = $(element);
element.parentNode.removeChild(element);
return element;
},
update: function(element, html) {
html = typeof html == 'undefined' ? '' : html.toString();
$(element).innerHTML = html.stripScripts();
setTimeout(function() {html.evalScripts()}, 10);
return element;
},
replace: function(element, html) {
element = $(element);
html = typeof html == 'undefined' ? '' : html.toString();
if (element.outerHTML) {
element.outerHTML = html.stripScripts();
} else {
var range = element.ownerDocument.createRange();
range.selectNodeContents(element);
element.parentNode.replaceChild(
range.createContextualFragment(html.stripScripts()), element);
}
setTimeout(function() {html.evalScripts()}, 10);
return element;
},
inspect: function(element) {
element = $(element);
var result = '<' + element.tagName.toLowerCase();
$H({'id': 'id', 'className': 'class'}).each(function(pair) {
var property = pair.first(), attribute = pair.last();
var value = (element[property] || '').toString();
if (value) result += ' ' + attribute + '=' + value.inspect(true);
});
return result + '>';
},
recursivelyCollect: function(element, property) {
element = $(element);
var elements = [];
while (element = element[property])
if (element.nodeType == 1)
elements.push(Element.extend(element));
return elements;
},
ancestors: function(element) {
return $(element).recursivelyCollect('parentNode');
},
descendants: function(element) {
return $A($(element).getElementsByTagName('*')).each(Element.extend);
},
firstDescendant: function(element) {
element = $(element).firstChild;
while (element && element.nodeType != 1) element = element.nextSibling;
return $(element);
},
immediateDescendants: function(element) {
if (!(element = $(element).firstChild)) return [];
while (element && element.nodeType != 1) element = element.nextSibling;
if (element) return [element].concat($(element).nextSiblings());
return [];
},
previousSiblings: function(element) {
return $(element).recursivelyCollect('previousSibling');
},
nextSiblings: function(element) {
return $(element).recursivelyCollect('nextSibling');
},
siblings: function(element) {
element = $(element);
return element.previousSiblings().reverse().concat(element.nextSiblings());
},
match: function(element, selector) {
if (typeof selector == 'string')
selector = new Selector(selector);
return selector.match($(element));
},
up: function(element, expression, index) {
element = $(element);
if (arguments.length == 1) return $(element.parentNode);
var ancestors = element.ancestors();
return expression ? Selector.findElement(ancestors, expression, index) :
ancestors[index || 0];
},
down: function(element, expression, index) {
element = $(element);
if (arguments.length == 1) return element.firstDescendant();
var descendants = element.descendants();
return expression ? Selector.findElement(descendants, expression, index) :
descendants[index || 0];
},
previous: function(element, expression, index) {
element = $(element);
if (arguments.length == 1) return $(Selector.handlers.previousElementSibling(element));
var previousSiblings = element.previousSiblings();
return expression ? Selector.findElement(previousSiblings, expression, index) :
previousSiblings[index || 0];
},
next: function(element, expression, index) {
element = $(element);
if (arguments.length == 1) return $(Selector.handlers.nextElementSibling(element));
var nextSiblings = element.nextSiblings();
return expression ? Selector.findElement(nextSiblings, expression, index) :
nextSiblings[index || 0];
},
getElementsBySelector: function() {
var args = $A(arguments), element = $(args.shift());
return Selector.findChildElements(element, args);
},
getElementsByClassName: function(element, className) {
return document.getElementsByClassName(className, element);
},
readAttribute: function(element, name) {
element = $(element);
if (Prototype.Browser.IE) {
if (!element.attributes) return null;
var t = Element._attributeTranslations;
if (t.values[name]) return t.values[name](element, name);
if (t.names[name]) name = t.names[name];
var attribute = element.attributes[name];
return attribute ? attribute.nodeValue : null;
}
return element.getAttribute(name);
},
getHeight: function(element) {
return $(element).getDimensions().height;
},
getWidth: function(element) {
return $(element).getDimensions().width;
},
classNames: function(element) {
return new Element.ClassNames(element);
},
hasClassName: function(element, className) {
if (!(element = $(element))) return;
var elementClassName = element.className;
if (elementClassName.length == 0) return false;
if (elementClassName == className ||
elementClassName.match(new RegExp("(^|\\s)" + className + "(\\s|$)")))
return true;
return false;
},
addClassName: function(element, className) {
if (!(element = $(element))) return;
Element.classNames(element).add(className);
return element;
},
removeClassName: function(element, className) {
if (!(element = $(element))) return;
Element.classNames(element).remove(className);
return element;
},
toggleClassName: function(element, className) {
if (!(element = $(element))) return;
Element.classNames(element)[element.hasClassName(className) ? 'remove' : 'add'](className);
return element;
},
observe: function() {
Event.observe.apply(Event, arguments);
return $A(arguments).first();
},
stopObserving: function() {
Event.stopObserving.apply(Event, arguments);
return $A(arguments).first();
},
// removes whitespace-only text node children
cleanWhitespace: function(element) {
element = $(element);
var node = element.firstChild;
while (node) {
var nextNode = node.nextSibling;
if (node.nodeType == 3 && !/\S/.test(node.nodeValue))
element.removeChild(node);
node = nextNode;
}
return element;
},
empty: function(element) {
return $(element).innerHTML.blank();
},
descendantOf: function(element, ancestor) {
element = $(element), ancestor = $(ancestor);
while (element = element.parentNode)
if (element == ancestor) return true;
return false;
},
scrollTo: function(element) {
element = $(element);
var pos = Position.cumulativeOffset(element);
window.scrollTo(pos[0], pos[1]);
return element;
},
getStyle: function(element, style) {
element = $(element);
style = style == 'float' ? 'cssFloat' : style.camelize();
var value = element.style[style];
if (!value) {
var css = document.defaultView.getComputedStyle(element, null);
value = css ? css[style] : null;
}
if (style == 'opacity') return value ? parseFloat(value) : 1.0;
return value == 'auto' ? null : value;
},
getOpacity: function(element) {
return $(element).getStyle('opacity');
},
setStyle: function(element, styles, camelized) {
element = $(element);
var elementStyle = element.style;
for (var property in styles)
if (property == 'opacity') element.setOpacity(styles[property])
else
elementStyle[(property == 'float' || property == 'cssFloat') ?
(elementStyle.styleFloat === undefined ? 'cssFloat' : 'styleFloat') :
(camelized ? property : property.camelize())] = styles[property];
return element;
},
setOpacity: function(element, value) {
element = $(element);
element.style.opacity = (value == 1 || value === '') ? '' :
(value < 0.00001) ? 0 : value;
return element;
},
getDimensions: function(element) {
element = $(element);
var display = $(element).getStyle('display');
if (display != 'none' && display != null) // Safari bug
return {width: element.offsetWidth, height: element.offsetHeight};
// All *Width and *Height properties give 0 on elements with display none,
// so enable the element temporarily
var els = element.style;
var originalVisibility = els.visibility;
var originalPosition = els.position;
var originalDisplay = els.display;
els.visibility = 'hidden';
els.position = 'absolute';
els.display = 'block';
var originalWidth = element.clientWidth;
var originalHeight = element.clientHeight;
els.display = originalDisplay;
els.position = originalPosition;
els.visibility = originalVisibility;
return {width: originalWidth, height: originalHeight};
},
makePositioned: function(element) {
element = $(element);
var pos = Element.getStyle(element, 'position');
if (pos == 'static' || !pos) {
element._madePositioned = true;
element.style.position = 'relative';
// Opera returns the offset relative to the positioning context, when an
// element is position relative but top and left have not been defined
if (window.opera) {
element.style.top = 0;
element.style.left = 0;
}
}
return element;
},
undoPositioned: function(element) {
element = $(element);
if (element._madePositioned) {
element._madePositioned = undefined;
element.style.position =
element.style.top =
element.style.left =
element.style.bottom =
element.style.right = '';
}
return element;
},
makeClipping: function(element) {
element = $(element);
if (element._overflow) return element;
element._overflow = element.style.overflow || 'auto';
if ((Element.getStyle(element, 'overflow') || 'visible') != 'hidden')
element.style.overflow = 'hidden';
return element;
},
undoClipping: function(element) {
element = $(element);
if (!element._overflow) return element;
element.style.overflow = element._overflow == 'auto' ? '' : element._overflow;
element._overflow = null;
return element;
}
};
Object.extend(Element.Methods, {
childOf: Element.Methods.descendantOf,
childElements: Element.Methods.immediateDescendants
});
if (Prototype.Browser.Opera) {
Element.Methods._getStyle = Element.Methods.getStyle;
Element.Methods.getStyle = function(element, style) {
switch(style) {
case 'left':
case 'top':
case 'right':
case 'bottom':
if (Element._getStyle(element, 'position') == 'static') return null;
default: return Element._getStyle(element, style);
}
};
}
else if (Prototype.Browser.IE) {
Element.Methods.getStyle = function(element, style) {
element = $(element);
style = (style == 'float' || style == 'cssFloat') ? 'styleFloat' : style.camelize();
var value = element.style[style];
if (!value && element.currentStyle) value = element.currentStyle[style];
if (style == 'opacity') {
if (value = (element.getStyle('filter') || '').match(/alpha\(opacity=(.*)\)/))
if (value[1]) return parseFloat(value[1]) / 100;
return 1.0;
}
if (value == 'auto') {
if ((style == 'width' || style == 'height') && (element.getStyle('display') != 'none'))
return element['offset'+style.capitalize()] + 'px';
return null;
}
return value;
};
Element.Methods.setOpacity = function(element, value) {
element = $(element);
var filter = element.getStyle('filter'), style = element.style;
if (value == 1 || value === '') {
style.filter = filter.replace(/alpha\([^\)]*\)/gi,'');
return element;
} else if (value < 0.00001) value = 0;
style.filter = filter.replace(/alpha\([^\)]*\)/gi, '') +
'alpha(opacity=' + (value * 100) + ')';
return element;
};
// IE is missing .innerHTML support for TABLE-related elements
Element.Methods.update = function(element, html) {
element = $(element);
html = typeof html == 'undefined' ? '' : html.toString();
var tagName = element.tagName.toUpperCase();
if (['THEAD','TBODY','TR','TD'].include(tagName)) {
var div = document.createElement('div');
switch (tagName) {
case 'THEAD':
case 'TBODY':
div.innerHTML = '' + html.stripScripts() + '
';
depth = 2;
break;
case 'TR':
div.innerHTML = '' + html.stripScripts() + '
';
depth = 3;
break;
case 'TD':
div.innerHTML = '' + html.stripScripts() + ' |
';
depth = 4;
}
$A(element.childNodes).each(function(node) { element.removeChild(node) });
depth.times(function() { div = div.firstChild });
$A(div.childNodes).each(function(node) { element.appendChild(node) });
} else {
element.innerHTML = html.stripScripts();
}
setTimeout(function() { html.evalScripts() }, 10);
return element;
}
}
else if (Prototype.Browser.Gecko) {
Element.Methods.setOpacity = function(element, value) {
element = $(element);
element.style.opacity = (value == 1) ? 0.999999 :
(value === '') ? '' : (value < 0.00001) ? 0 : value;
return element;
};
}
Element._attributeTranslations = {
names: {
colspan: "colSpan",
rowspan: "rowSpan",
valign: "vAlign",
datetime: "dateTime",
accesskey: "accessKey",
tabindex: "tabIndex",
enctype: "encType",
maxlength: "maxLength",
readonly: "readOnly",
longdesc: "longDesc"
},
values: {
_getAttr: function(element, attribute) {
return element.getAttribute(attribute, 2);
},
_flag: function(element, attribute) {
return $(element).hasAttribute(attribute) ? attribute : null;
},
style: function(element) {
return element.style.cssText.toLowerCase();
},
title: function(element) {
var node = element.getAttributeNode('title');
return node.specified ? node.nodeValue : null;
}
}
};
(function() {
Object.extend(this, {
href: this._getAttr,
src: this._getAttr,
type: this._getAttr,
disabled: this._flag,
checked: this._flag,
readonly: this._flag,
multiple: this._flag
});
}).call(Element._attributeTranslations.values);
Element.Methods.Simulated = {
hasAttribute: function(element, attribute) {
var t = Element._attributeTranslations, node;
attribute = t.names[attribute] || attribute;
node = $(element).getAttributeNode(attribute);
return node && node.specified;
}
};
Element.Methods.ByTag = {};
Object.extend(Element, Element.Methods);
if (!Prototype.BrowserFeatures.ElementExtensions &&
document.createElement('div').__proto__) {
window.HTMLElement = {};
window.HTMLElement.prototype = document.createElement('div').__proto__;
Prototype.BrowserFeatures.ElementExtensions = true;
}
Element.hasAttribute = function(element, attribute) {
if (element.hasAttribute) return element.hasAttribute(attribute);
return Element.Methods.Simulated.hasAttribute(element, attribute);
};
Element.addMethods = function(methods) {
var F = Prototype.BrowserFeatures, T = Element.Methods.ByTag;
if (!methods) {
Object.extend(Form, Form.Methods);
Object.extend(Form.Element, Form.Element.Methods);
Object.extend(Element.Methods.ByTag, {
"FORM": Object.clone(Form.Methods),
"INPUT": Object.clone(Form.Element.Methods),
"SELECT": Object.clone(Form.Element.Methods),
"TEXTAREA": Object.clone(Form.Element.Methods)
});
}
if (arguments.length == 2) {
var tagName = methods;
methods = arguments[1];
}
if (!tagName) Object.extend(Element.Methods, methods || {});
else {
if (tagName.constructor == Array) tagName.each(extend);
else extend(tagName);
}
function extend(tagName) {
tagName = tagName.toUpperCase();
if (!Element.Methods.ByTag[tagName])
Element.Methods.ByTag[tagName] = {};
Object.extend(Element.Methods.ByTag[tagName], methods);
}
function copy(methods, destination, onlyIfAbsent) {
onlyIfAbsent = onlyIfAbsent || false;
var cache = Element.extend.cache;
for (var property in methods) {
var value = methods[property];
if (!onlyIfAbsent || !(property in destination))
destination[property] = cache.findOrStore(value);
}
}
function findDOMClass(tagName) {
var klass;
var trans = {
"OPTGROUP": "OptGroup", "TEXTAREA": "TextArea", "P": "Paragraph",
"FIELDSET": "FieldSet", "UL": "UList", "OL": "OList", "DL": "DList",
"DIR": "Directory", "H1": "Heading", "H2": "Heading", "H3": "Heading",
"H4": "Heading", "H5": "Heading", "H6": "Heading", "Q": "Quote",
"INS": "Mod", "DEL": "Mod", "A": "Anchor", "IMG": "Image", "CAPTION":
"TableCaption", "COL": "TableCol", "COLGROUP": "TableCol", "THEAD":
"TableSection", "TFOOT": "TableSection", "TBODY": "TableSection", "TR":
"TableRow", "TH": "TableCell", "TD": "TableCell", "FRAMESET":
"FrameSet", "IFRAME": "IFrame"
};
if (trans[tagName]) klass = 'HTML' + trans[tagName] + 'Element';
if (window[klass]) return window[klass];
klass = 'HTML' + tagName + 'Element';
if (window[klass]) return window[klass];
klass = 'HTML' + tagName.capitalize() + 'Element';
if (window[klass]) return window[klass];
window[klass] = {};
window[klass].prototype = document.createElement(tagName).__proto__;
return window[klass];
}
if (F.ElementExtensions) {
copy(Element.Methods, HTMLElement.prototype);
copy(Element.Methods.Simulated, HTMLElement.prototype, true);
}
if (F.SpecificElementExtensions) {
for (var tag in Element.Methods.ByTag) {
var klass = findDOMClass(tag);
if (typeof klass == "undefined") continue;
copy(T[tag], klass.prototype);
}
}
Object.extend(Element, Element.Methods);
delete Element.ByTag;
};
var Toggle = { display: Element.toggle };
/*--------------------------------------------------------------------------*/
Abstract.Insertion = function(adjacency) {
this.adjacency = adjacency;
}
Abstract.Insertion.prototype = {
initialize: function(element, content) {
this.element = $(element);
this.content = content.stripScripts();
if (this.adjacency && this.element.insertAdjacentHTML) {
try {
this.element.insertAdjacentHTML(this.adjacency, this.content);
} catch (e) {
var tagName = this.element.tagName.toUpperCase();
if (['TBODY', 'TR'].include(tagName)) {
this.insertContent(this.contentFromAnonymousTable());
} else {
throw e;
}
}
} else {
this.range = this.element.ownerDocument.createRange();
if (this.initializeRange) this.initializeRange();
this.insertContent([this.range.createContextualFragment(this.content)]);
}
setTimeout(function() {content.evalScripts()}, 10);
},
contentFromAnonymousTable: function() {
var div = document.createElement('div');
div.innerHTML = '';
return $A(div.childNodes[0].childNodes[0].childNodes);
}
}
var Insertion = new Object();
Insertion.Before = Class.create();
Insertion.Before.prototype = Object.extend(new Abstract.Insertion('beforeBegin'), {
initializeRange: function() {
this.range.setStartBefore(this.element);
},
insertContent: function(fragments) {
fragments.each((function(fragment) {
this.element.parentNode.insertBefore(fragment, this.element);
}).bind(this));
}
});
Insertion.Top = Class.create();
Insertion.Top.prototype = Object.extend(new Abstract.Insertion('afterBegin'), {
initializeRange: function() {
this.range.selectNodeContents(this.element);
this.range.collapse(true);
},
insertContent: function(fragments) {
fragments.reverse(false).each((function(fragment) {
this.element.insertBefore(fragment, this.element.firstChild);
}).bind(this));
}
});
Insertion.Bottom = Class.create();
Insertion.Bottom.prototype = Object.extend(new Abstract.Insertion('beforeEnd'), {
initializeRange: function() {
this.range.selectNodeContents(this.element);
this.range.collapse(this.element);
},
insertContent: function(fragments) {
fragments.each((function(fragment) {
this.element.appendChild(fragment);
}).bind(this));
}
});
Insertion.After = Class.create();
Insertion.After.prototype = Object.extend(new Abstract.Insertion('afterEnd'), {
initializeRange: function() {
this.range.setStartAfter(this.element);
},
insertContent: function(fragments) {
fragments.each((function(fragment) {
this.element.parentNode.insertBefore(fragment,
this.element.nextSibling);
}).bind(this));
}
});
/*--------------------------------------------------------------------------*/
Element.ClassNames = Class.create();
Element.ClassNames.prototype = {
initialize: function(element) {
this.element = $(element);
},
_each: function(iterator) {
this.element.className.split(/\s+/).select(function(name) {
return name.length > 0;
})._each(iterator);
},
set: function(className) {
this.element.className = className;
},
add: function(classNameToAdd) {
if (this.include(classNameToAdd)) return;
this.set($A(this).concat(classNameToAdd).join(' '));
},
remove: function(classNameToRemove) {
if (!this.include(classNameToRemove)) return;
this.set($A(this).without(classNameToRemove).join(' '));
},
toString: function() {
return $A(this).join(' ');
}
};
Object.extend(Element.ClassNames.prototype, Enumerable);
/* Portions of the Selector class are derived from Jack Slocum’s DomQuery,
* part of YUI-Ext version 0.40, distributed under the terms of an MIT-style
* license. Please see http://www.yui-ext.com/ for more information. */
var Selector = Class.create();
Selector.prototype = {
initialize: function(expression) {
this.expression = expression.strip();
this.compileMatcher();
},
compileMatcher: function() {
// Selectors with namespaced attributes can't use the XPath version
if (Prototype.BrowserFeatures.XPath && !(/\[[\w-]*?:/).test(this.expression))
return this.compileXPathMatcher();
var e = this.expression, ps = Selector.patterns, h = Selector.handlers,
c = Selector.criteria, le, p, m;
if (Selector._cache[e]) {
this.matcher = Selector._cache[e]; return;
}
this.matcher = ["this.matcher = function(root) {",
"var r = root, h = Selector.handlers, c = false, n;"];
while (e && le != e && (/\S/).test(e)) {
le = e;
for (var i in ps) {
p = ps[i];
if (m = e.match(p)) {
this.matcher.push(typeof c[i] == 'function' ? c[i](m) :
new Template(c[i]).evaluate(m));
e = e.replace(m[0], '');
break;
}
}
}
this.matcher.push("return h.unique(n);\n}");
eval(this.matcher.join('\n'));
Selector._cache[this.expression] = this.matcher;
},
compileXPathMatcher: function() {
var e = this.expression, ps = Selector.patterns,
x = Selector.xpath, le, m;
if (Selector._cache[e]) {
this.xpath = Selector._cache[e]; return;
}
this.matcher = ['.//*'];
while (e && le != e && (/\S/).test(e)) {
le = e;
for (var i in ps) {
if (m = e.match(ps[i])) {
this.matcher.push(typeof x[i] == 'function' ? x[i](m) :
new Template(x[i]).evaluate(m));
e = e.replace(m[0], '');
break;
}
}
}
this.xpath = this.matcher.join('');
Selector._cache[this.expression] = this.xpath;
},
findElements: function(root) {
root = root || document;
if (this.xpath) return document._getElementsByXPath(this.xpath, root);
return this.matcher(root);
},
match: function(element) {
return this.findElements(document).include(element);
},
toString: function() {
return this.expression;
},
inspect: function() {
return "#";
}
};
Object.extend(Selector, {
_cache: {},
xpath: {
descendant: "//*",
child: "/*",
adjacent: "/following-sibling::*[1]",
laterSibling: '/following-sibling::*',
tagName: function(m) {
if (m[1] == '*') return '';
return "[local-name()='" + m[1].toLowerCase() +
"' or local-name()='" + m[1].toUpperCase() + "']";
},
className: "[contains(concat(' ', @class, ' '), ' #{1} ')]",
id: "[@id='#{1}']",
attrPresence: "[@#{1}]",
attr: function(m) {
m[3] = m[5] || m[6];
return new Template(Selector.xpath.operators[m[2]]).evaluate(m);
},
pseudo: function(m) {
var h = Selector.xpath.pseudos[m[1]];
if (!h) return '';
if (typeof h === 'function') return h(m);
return new Template(Selector.xpath.pseudos[m[1]]).evaluate(m);
},
operators: {
'=': "[@#{1}='#{3}']",
'!=': "[@#{1}!='#{3}']",
'^=': "[starts-with(@#{1}, '#{3}')]",
'$=': "[substring(@#{1}, (string-length(@#{1}) - string-length('#{3}') + 1))='#{3}']",
'*=': "[contains(@#{1}, '#{3}')]",
'~=': "[contains(concat(' ', @#{1}, ' '), ' #{3} ')]",
'|=': "[contains(concat('-', @#{1}, '-'), '-#{3}-')]"
},
pseudos: {
'first-child': '[not(preceding-sibling::*)]',
'last-child': '[not(following-sibling::*)]',
'only-child': '[not(preceding-sibling::* or following-sibling::*)]',
'empty': "[count(*) = 0 and (count(text()) = 0 or translate(text(), ' \t\r\n', '') = '')]",
'checked': "[@checked]",
'disabled': "[@disabled]",
'enabled': "[not(@disabled)]",
'not': function(m) {
var e = m[6], p = Selector.patterns,
x = Selector.xpath, le, m, v;
var exclusion = [];
while (e && le != e && (/\S/).test(e)) {
le = e;
for (var i in p) {
if (m = e.match(p[i])) {
v = typeof x[i] == 'function' ? x[i](m) : new Template(x[i]).evaluate(m);
exclusion.push("(" + v.substring(1, v.length - 1) + ")");
e = e.replace(m[0], '');
break;
}
}
}
return "[not(" + exclusion.join(" and ") + ")]";
},
'nth-child': function(m) {
return Selector.xpath.pseudos.nth("(count(./preceding-sibling::*) + 1) ", m);
},
'nth-last-child': function(m) {
return Selector.xpath.pseudos.nth("(count(./following-sibling::*) + 1) ", m);
},
'nth-of-type': function(m) {
return Selector.xpath.pseudos.nth("position() ", m);
},
'nth-last-of-type': function(m) {
return Selector.xpath.pseudos.nth("(last() + 1 - position()) ", m);
},
'first-of-type': function(m) {
m[6] = "1"; return Selector.xpath.pseudos['nth-of-type'](m);
},
'last-of-type': function(m) {
m[6] = "1"; return Selector.xpath.pseudos['nth-last-of-type'](m);
},
'only-of-type': function(m) {
var p = Selector.xpath.pseudos; return p['first-of-type'](m) + p['last-of-type'](m);
},
nth: function(fragment, m) {
var mm, formula = m[6], predicate;
if (formula == 'even') formula = '2n+0';
if (formula == 'odd') formula = '2n+1';
if (mm = formula.match(/^(\d+)$/)) // digit only
return '[' + fragment + "= " + mm[1] + ']';
if (mm = formula.match(/^(-?\d*)?n(([+-])(\d+))?/)) { // an+b
if (mm[1] == "-") mm[1] = -1;
var a = mm[1] ? Number(mm[1]) : 1;
var b = mm[2] ? Number(mm[2]) : 0;
predicate = "[((#{fragment} - #{b}) mod #{a} = 0) and " +
"((#{fragment} - #{b}) div #{a} >= 0)]";
return new Template(predicate).evaluate({
fragment: fragment, a: a, b: b });
}
}
}
},
criteria: {
tagName: 'n = h.tagName(n, r, "#{1}", c); c = false;',
className: 'n = h.className(n, r, "#{1}", c); c = false;',
id: 'n = h.id(n, r, "#{1}", c); c = false;',
attrPresence: 'n = h.attrPresence(n, r, "#{1}"); c = false;',
attr: function(m) {
m[3] = (m[5] || m[6]);
return new Template('n = h.attr(n, r, "#{1}", "#{3}", "#{2}"); c = false;').evaluate(m);
},
pseudo: function(m) {
if (m[6]) m[6] = m[6].replace(/"/g, '\\"');
return new Template('n = h.pseudo(n, "#{1}", "#{6}", r, c); c = false;').evaluate(m);
},
descendant: 'c = "descendant";',
child: 'c = "child";',
adjacent: 'c = "adjacent";',
laterSibling: 'c = "laterSibling";'
},
patterns: {
// combinators must be listed first
// (and descendant needs to be last combinator)
laterSibling: /^\s*~\s*/,
child: /^\s*>\s*/,
adjacent: /^\s*\+\s*/,
descendant: /^\s/,
// selectors follow
tagName: /^\s*(\*|[\w\-]+)(\b|$)?/,
id: /^#([\w\-\*]+)(\b|$)/,
className: /^\.([\w\-\*]+)(\b|$)/,
pseudo: /^:((first|last|nth|nth-last|only)(-child|-of-type)|empty|checked|(en|dis)abled|not)(\((.*?)\))?(\b|$|\s|(?=:))/,
attrPresence: /^\[([\w]+)\]/,
attr: /\[((?:[\w-]*:)?[\w-]+)\s*(?:([!^$*~|]?=)\s*((['"])([^\]]*?)\4|([^'"][^\]]*?)))?\]/
},
handlers: {
// UTILITY FUNCTIONS
// joins two collections
concat: function(a, b) {
for (var i = 0, node; node = b[i]; i++)
a.push(node);
return a;
},
// marks an array of nodes for counting
mark: function(nodes) {
for (var i = 0, node; node = nodes[i]; i++)
node._counted = true;
return nodes;
},
unmark: function(nodes) {
for (var i = 0, node; node = nodes[i]; i++)
node._counted = undefined;
return nodes;
},
// mark each child node with its position (for nth calls)
// "ofType" flag indicates whether we're indexing for nth-of-type
// rather than nth-child
index: function(parentNode, reverse, ofType) {
parentNode._counted = true;
if (reverse) {
for (var nodes = parentNode.childNodes, i = nodes.length - 1, j = 1; i >= 0; i--) {
node = nodes[i];
if (node.nodeType == 1 && (!ofType || node._counted)) node.nodeIndex = j++;
}
} else {
for (var i = 0, j = 1, nodes = parentNode.childNodes; node = nodes[i]; i++)
if (node.nodeType == 1 && (!ofType || node._counted)) node.nodeIndex = j++;
}
},
// filters out duplicates and extends all nodes
unique: function(nodes) {
if (nodes.length == 0) return nodes;
var results = [], n;
for (var i = 0, l = nodes.length; i < l; i++)
if (!(n = nodes[i])._counted) {
n._counted = true;
results.push(Element.extend(n));
}
return Selector.handlers.unmark(results);
},
// COMBINATOR FUNCTIONS
descendant: function(nodes) {
var h = Selector.handlers;
for (var i = 0, results = [], node; node = nodes[i]; i++)
h.concat(results, node.getElementsByTagName('*'));
return results;
},
child: function(nodes) {
var h = Selector.handlers;
for (var i = 0, results = [], node; node = nodes[i]; i++) {
for (var j = 0, children = [], child; child = node.childNodes[j]; j++)
if (child.nodeType == 1 && child.tagName != '!') results.push(child);
}
return results;
},
adjacent: function(nodes) {
for (var i = 0, results = [], node; node = nodes[i]; i++) {
var next = this.nextElementSibling(node);
if (next) results.push(next);
}
return results;
},
laterSibling: function(nodes) {
var h = Selector.handlers;
for (var i = 0, results = [], node; node = nodes[i]; i++)
h.concat(results, Element.nextSiblings(node));
return results;
},
nextElementSibling: function(node) {
while (node = node.nextSibling)
if (node.nodeType == 1) return node;
return null;
},
previousElementSibling: function(node) {
while (node = node.previousSibling)
if (node.nodeType == 1) return node;
return null;
},
// TOKEN FUNCTIONS
tagName: function(nodes, root, tagName, combinator) {
tagName = tagName.toUpperCase();
var results = [], h = Selector.handlers;
if (nodes) {
if (combinator) {
// fastlane for ordinary descendant combinators
if (combinator == "descendant") {
for (var i = 0, node; node = nodes[i]; i++)
h.concat(results, node.getElementsByTagName(tagName));
return results;
} else nodes = this[combinator](nodes);
if (tagName == "*") return nodes;
}
for (var i = 0, node; node = nodes[i]; i++)
if (node.tagName.toUpperCase() == tagName) results.push(node);
return results;
} else return root.getElementsByTagName(tagName);
},
id: function(nodes, root, id, combinator) {
var targetNode = $(id), h = Selector.handlers;
if (!nodes && root == document) return targetNode ? [targetNode] : [];
if (nodes) {
if (combinator) {
if (combinator == 'child') {
for (var i = 0, node; node = nodes[i]; i++)
if (targetNode.parentNode == node) return [targetNode];
} else if (combinator == 'descendant') {
for (var i = 0, node; node = nodes[i]; i++)
if (Element.descendantOf(targetNode, node)) return [targetNode];
} else if (combinator == 'adjacent') {
for (var i = 0, node; node = nodes[i]; i++)
if (Selector.handlers.previousElementSibling(targetNode) == node)
return [targetNode];
} else nodes = h[combinator](nodes);
}
for (var i = 0, node; node = nodes[i]; i++)
if (node == targetNode) return [targetNode];
return [];
}
return (targetNode && Element.descendantOf(targetNode, root)) ? [targetNode] : [];
},
className: function(nodes, root, className, combinator) {
if (nodes && combinator) nodes = this[combinator](nodes);
return Selector.handlers.byClassName(nodes, root, className);
},
byClassName: function(nodes, root, className) {
if (!nodes) nodes = Selector.handlers.descendant([root]);
var needle = ' ' + className + ' ';
for (var i = 0, results = [], node, nodeClassName; node = nodes[i]; i++) {
nodeClassName = node.className;
if (nodeClassName.length == 0) continue;
if (nodeClassName == className || (' ' + nodeClassName + ' ').include(needle))
results.push(node);
}
return results;
},
attrPresence: function(nodes, root, attr) {
var results = [];
for (var i = 0, node; node = nodes[i]; i++)
if (Element.hasAttribute(node, attr)) results.push(node);
return results;
},
attr: function(nodes, root, attr, value, operator) {
if (!nodes) nodes = root.getElementsByTagName("*");
var handler = Selector.operators[operator], results = [];
for (var i = 0, node; node = nodes[i]; i++) {
var nodeValue = Element.readAttribute(node, attr);
if (nodeValue === null) continue;
if (handler(nodeValue, value)) results.push(node);
}
return results;
},
pseudo: function(nodes, name, value, root, combinator) {
if (nodes && combinator) nodes = this[combinator](nodes);
if (!nodes) nodes = root.getElementsByTagName("*");
return Selector.pseudos[name](nodes, value, root);
}
},
pseudos: {
'first-child': function(nodes, value, root) {
for (var i = 0, results = [], node; node = nodes[i]; i++) {
if (Selector.handlers.previousElementSibling(node)) continue;
results.push(node);
}
return results;
},
'last-child': function(nodes, value, root) {
for (var i = 0, results = [], node; node = nodes[i]; i++) {
if (Selector.handlers.nextElementSibling(node)) continue;
results.push(node);
}
return results;
},
'only-child': function(nodes, value, root) {
var h = Selector.handlers;
for (var i = 0, results = [], node; node = nodes[i]; i++)
if (!h.previousElementSibling(node) && !h.nextElementSibling(node))
results.push(node);
return results;
},
'nth-child': function(nodes, formula, root) {
return Selector.pseudos.nth(nodes, formula, root);
},
'nth-last-child': function(nodes, formula, root) {
return Selector.pseudos.nth(nodes, formula, root, true);
},
'nth-of-type': function(nodes, formula, root) {
return Selector.pseudos.nth(nodes, formula, root, false, true);
},
'nth-last-of-type': function(nodes, formula, root) {
return Selector.pseudos.nth(nodes, formula, root, true, true);
},
'first-of-type': function(nodes, formula, root) {
return Selector.pseudos.nth(nodes, "1", root, false, true);
},
'last-of-type': function(nodes, formula, root) {
return Selector.pseudos.nth(nodes, "1", root, true, true);
},
'only-of-type': function(nodes, formula, root) {
var p = Selector.pseudos;
return p['last-of-type'](p['first-of-type'](nodes, formula, root), formula, root);
},
// handles the an+b logic
getIndices: function(a, b, total) {
if (a == 0) return b > 0 ? [b] : [];
return $R(1, total).inject([], function(memo, i) {
if (0 == (i - b) % a && (i - b) / a >= 0) memo.push(i);
return memo;
});
},
// handles nth(-last)-child, nth(-last)-of-type, and (first|last)-of-type
nth: function(nodes, formula, root, reverse, ofType) {
if (nodes.length == 0) return [];
if (formula == 'even') formula = '2n+0';
if (formula == 'odd') formula = '2n+1';
var h = Selector.handlers, results = [], indexed = [], m;
h.mark(nodes);
for (var i = 0, node; node = nodes[i]; i++) {
if (!node.parentNode._counted) {
h.index(node.parentNode, reverse, ofType);
indexed.push(node.parentNode);
}
}
if (formula.match(/^\d+$/)) { // just a number
formula = Number(formula);
for (var i = 0, node; node = nodes[i]; i++)
if (node.nodeIndex == formula) results.push(node);
} else if (m = formula.match(/^(-?\d*)?n(([+-])(\d+))?/)) { // an+b
if (m[1] == "-") m[1] = -1;
var a = m[1] ? Number(m[1]) : 1;
var b = m[2] ? Number(m[2]) : 0;
var indices = Selector.pseudos.getIndices(a, b, nodes.length);
for (var i = 0, node, l = indices.length; node = nodes[i]; i++) {
for (var j = 0; j < l; j++)
if (node.nodeIndex == indices[j]) results.push(node);
}
}
h.unmark(nodes);
h.unmark(indexed);
return results;
},
'empty': function(nodes, value, root) {
for (var i = 0, results = [], node; node = nodes[i]; i++) {
// IE treats comments as element nodes
if (node.tagName == '!' || (node.firstChild && !node.innerHTML.match(/^\s*$/))) continue;
results.push(node);
}
return results;
},
'not': function(nodes, selector, root) {
var h = Selector.handlers, selectorType, m;
var exclusions = new Selector(selector).findElements(root);
h.mark(exclusions);
for (var i = 0, results = [], node; node = nodes[i]; i++)
if (!node._counted) results.push(node);
h.unmark(exclusions);
return results;
},
'enabled': function(nodes, value, root) {
for (var i = 0, results = [], node; node = nodes[i]; i++)
if (!node.disabled) results.push(node);
return results;
},
'disabled': function(nodes, value, root) {
for (var i = 0, results = [], node; node = nodes[i]; i++)
if (node.disabled) results.push(node);
return results;
},
'checked': function(nodes, value, root) {
for (var i = 0, results = [], node; node = nodes[i]; i++)
if (node.checked) results.push(node);
return results;
}
},
operators: {
'=': function(nv, v) { return nv == v; },
'!=': function(nv, v) { return nv != v; },
'^=': function(nv, v) { return nv.startsWith(v); },
'$=': function(nv, v) { return nv.endsWith(v); },
'*=': function(nv, v) { return nv.include(v); },
'~=': function(nv, v) { return (' ' + nv + ' ').include(' ' + v + ' '); },
'|=': function(nv, v) { return ('-' + nv.toUpperCase() + '-').include('-' + v.toUpperCase() + '-'); }
},
matchElements: function(elements, expression) {
var matches = new Selector(expression).findElements(), h = Selector.handlers;
h.mark(matches);
for (var i = 0, results = [], element; element = elements[i]; i++)
if (element._counted) results.push(element);
h.unmark(matches);
return results;
},
findElement: function(elements, expression, index) {
if (typeof expression == 'number') {
index = expression; expression = false;
}
return Selector.matchElements(elements, expression || '*')[index || 0];
},
findChildElements: function(element, expressions) {
var exprs = expressions.join(','), expressions = [];
exprs.scan(/(([\w#:.~>+()\s-]+|\*|\[.*?\])+)\s*(,|$)/, function(m) {
expressions.push(m[1].strip());
});
var results = [], h = Selector.handlers;
for (var i = 0, l = expressions.length, selector; i < l; i++) {
selector = new Selector(expressions[i].strip());
h.concat(results, selector.findElements(element));
}
return (l > 1) ? h.unique(results) : results;
}
});
function $$() {
return Selector.findChildElements(document, $A(arguments));
}
var Form = {
reset: function(form) {
$(form).reset();
return form;
},
serializeElements: function(elements, getHash) {
var data = elements.inject({}, function(result, element) {
if (!element.disabled && element.name) {
var key = element.name, value = $(element).getValue();
if (value != null) {
if (key in result) {
if (result[key].constructor != Array) result[key] = [result[key]];
result[key].push(value);
}
else result[key] = value;
}
}
return result;
});
return getHash ? data : Hash.toQueryString(data);
}
};
Form.Methods = {
serialize: function(form, getHash) {
return Form.serializeElements(Form.getElements(form), getHash);
},
getElements: function(form) {
return $A($(form).getElementsByTagName('*')).inject([],
function(elements, child) {
if (Form.Element.Serializers[child.tagName.toLowerCase()])
elements.push(Element.extend(child));
return elements;
}
);
},
getInputs: function(form, typeName, name) {
form = $(form);
var inputs = form.getElementsByTagName('input');
if (!typeName && !name) return $A(inputs).map(Element.extend);
for (var i = 0, matchingInputs = [], length = inputs.length; i < length; i++) {
var input = inputs[i];
if ((typeName && input.type != typeName) || (name && input.name != name))
continue;
matchingInputs.push(Element.extend(input));
}
return matchingInputs;
},
disable: function(form) {
form = $(form);
Form.getElements(form).invoke('disable');
return form;
},
enable: function(form) {
form = $(form);
Form.getElements(form).invoke('enable');
return form;
},
findFirstElement: function(form) {
return $(form).getElements().find(function(element) {
return element.type != 'hidden' && !element.disabled &&
['input', 'select', 'textarea'].include(element.tagName.toLowerCase());
});
},
focusFirstElement: function(form) {
form = $(form);
form.findFirstElement().activate();
return form;
},
request: function(form, options) {
form = $(form), options = Object.clone(options || {});
var params = options.parameters;
options.parameters = form.serialize(true);
if (params) {
if (typeof params == 'string') params = params.toQueryParams();
Object.extend(options.parameters, params);
}
if (form.hasAttribute('method') && !options.method)
options.method = form.method;
return new Ajax.Request(form.readAttribute('action'), options);
}
}
/*--------------------------------------------------------------------------*/
Form.Element = {
focus: function(element) {
$(element).focus();
return element;
},
select: function(element) {
$(element).select();
return element;
}
}
Form.Element.Methods = {
serialize: function(element) {
element = $(element);
if (!element.disabled && element.name) {
var value = element.getValue();
if (value != undefined) {
var pair = {};
pair[element.name] = value;
return Hash.toQueryString(pair);
}
}
return '';
},
getValue: function(element) {
element = $(element);
var method = element.tagName.toLowerCase();
return Form.Element.Serializers[method](element);
},
clear: function(element) {
$(element).value = '';
return element;
},
present: function(element) {
return $(element).value != '';
},
activate: function(element) {
element = $(element);
try {
element.focus();
if (element.select && (element.tagName.toLowerCase() != 'input' ||
!['button', 'reset', 'submit'].include(element.type)))
element.select();
} catch (e) {}
return element;
},
disable: function(element) {
element = $(element);
element.blur();
element.disabled = true;
return element;
},
enable: function(element) {
element = $(element);
element.disabled = false;
return element;
}
}
/*--------------------------------------------------------------------------*/
var Field = Form.Element;
var $F = Form.Element.Methods.getValue;
/*--------------------------------------------------------------------------*/
Form.Element.Serializers = {
input: function(element) {
switch (element.type.toLowerCase()) {
case 'checkbox':
case 'radio':
return Form.Element.Serializers.inputSelector(element);
default:
return Form.Element.Serializers.textarea(element);
}
},
inputSelector: function(element) {
return element.checked ? element.value : null;
},
textarea: function(element) {
return element.value;
},
select: function(element) {
return this[element.type == 'select-one' ?
'selectOne' : 'selectMany'](element);
},
selectOne: function(element) {
var index = element.selectedIndex;
return index >= 0 ? this.optionValue(element.options[index]) : null;
},
selectMany: function(element) {
var values, length = element.length;
if (!length) return null;
for (var i = 0, values = []; i < length; i++) {
var opt = element.options[i];
if (opt.selected) values.push(this.optionValue(opt));
}
return values;
},
optionValue: function(opt) {
// extend element because hasAttribute may not be native
return Element.extend(opt).hasAttribute('value') ? opt.value : opt.text;
}
}
/*--------------------------------------------------------------------------*/
Abstract.TimedObserver = function() {}
Abstract.TimedObserver.prototype = {
initialize: function(element, frequency, callback) {
this.frequency = frequency;
this.element = $(element);
this.callback = callback;
this.lastValue = this.getValue();
this.registerCallback();
},
registerCallback: function() {
setInterval(this.onTimerEvent.bind(this), this.frequency * 1000);
},
onTimerEvent: function() {
var value = this.getValue();
var changed = ('string' == typeof this.lastValue && 'string' == typeof value
? this.lastValue != value : String(this.lastValue) != String(value));
if (changed) {
this.callback(this.element, value);
this.lastValue = value;
}
}
}
Form.Element.Observer = Class.create();
Form.Element.Observer.prototype = Object.extend(new Abstract.TimedObserver(), {
getValue: function() {
return Form.Element.getValue(this.element);
}
});
Form.Observer = Class.create();
Form.Observer.prototype = Object.extend(new Abstract.TimedObserver(), {
getValue: function() {
return Form.serialize(this.element);
}
});
/*--------------------------------------------------------------------------*/
Abstract.EventObserver = function() {}
Abstract.EventObserver.prototype = {
initialize: function(element, callback) {
this.element = $(element);
this.callback = callback;
this.lastValue = this.getValue();
if (this.element.tagName.toLowerCase() == 'form')
this.registerFormCallbacks();
else
this.registerCallback(this.element);
},
onElementEvent: function() {
var value = this.getValue();
if (this.lastValue != value) {
this.callback(this.element, value);
this.lastValue = value;
}
},
registerFormCallbacks: function() {
Form.getElements(this.element).each(this.registerCallback.bind(this));
},
registerCallback: function(element) {
if (element.type) {
switch (element.type.toLowerCase()) {
case 'checkbox':
case 'radio':
Event.observe(element, 'click', this.onElementEvent.bind(this));
break;
default:
Event.observe(element, 'change', this.onElementEvent.bind(this));
break;
}
}
}
}
Form.Element.EventObserver = Class.create();
Form.Element.EventObserver.prototype = Object.extend(new Abstract.EventObserver(), {
getValue: function() {
return Form.Element.getValue(this.element);
}
});
Form.EventObserver = Class.create();
Form.EventObserver.prototype = Object.extend(new Abstract.EventObserver(), {
getValue: function() {
return Form.serialize(this.element);
}
});
if (!window.Event) {
var Event = new Object();
}
Object.extend(Event, {
KEY_BACKSPACE: 8,
KEY_TAB: 9,
KEY_RETURN: 13,
KEY_ESC: 27,
KEY_LEFT: 37,
KEY_UP: 38,
KEY_RIGHT: 39,
KEY_DOWN: 40,
KEY_DELETE: 46,
KEY_HOME: 36,
KEY_END: 35,
KEY_PAGEUP: 33,
KEY_PAGEDOWN: 34,
element: function(event) {
return $(event.target || event.srcElement);
},
isLeftClick: function(event) {
return (((event.which) && (event.which == 1)) ||
((event.button) && (event.button == 1)));
},
pointerX: function(event) {
return event.pageX || (event.clientX +
(document.documentElement.scrollLeft || document.body.scrollLeft));
},
pointerY: function(event) {
return event.pageY || (event.clientY +
(document.documentElement.scrollTop || document.body.scrollTop));
},
stop: function(event) {
if (event.preventDefault) {
event.preventDefault();
event.stopPropagation();
} else {
event.returnValue = false;
event.cancelBubble = true;
}
},
// find the first node with the given tagName, starting from the
// node the event was triggered on; traverses the DOM upwards
findElement: function(event, tagName) {
var element = Event.element(event);
while (element.parentNode && (!element.tagName ||
(element.tagName.toUpperCase() != tagName.toUpperCase())))
element = element.parentNode;
return element;
},
observers: false,
_observeAndCache: function(element, name, observer, useCapture) {
if (!this.observers) this.observers = [];
if (element.addEventListener) {
this.observers.push([element, name, observer, useCapture]);
element.addEventListener(name, observer, useCapture);
} else if (element.attachEvent) {
this.observers.push([element, name, observer, useCapture]);
element.attachEvent('on' + name, observer);
}
},
unloadCache: function() {
if (!Event.observers) return;
for (var i = 0, length = Event.observers.length; i < length; i++) {
Event.stopObserving.apply(this, Event.observers[i]);
Event.observers[i][0] = null;
}
Event.observers = false;
},
observe: function(element, name, observer, useCapture) {
element = $(element);
useCapture = useCapture || false;
if (name == 'keypress' &&
(Prototype.Browser.WebKit || element.attachEvent))
name = 'keydown';
Event._observeAndCache(element, name, observer, useCapture);
},
stopObserving: function(element, name, observer, useCapture) {
element = $(element);
useCapture = useCapture || false;
if (name == 'keypress' &&
(Prototype.Browser.WebKit || element.attachEvent))
name = 'keydown';
if (element.removeEventListener) {
element.removeEventListener(name, observer, useCapture);
} else if (element.detachEvent) {
try {
element.detachEvent('on' + name, observer);
} catch (e) {}
}
}
});
/* prevent memory leaks in IE */
if (Prototype.Browser.IE)
Event.observe(window, 'unload', Event.unloadCache, false);
var Position = {
// set to true if needed, warning: firefox performance problems
// NOT neeeded for page scrolling, only if draggable contained in
// scrollable elements
includeScrollOffsets: false,
// must be called before calling withinIncludingScrolloffset, every time the
// page is scrolled
prepare: function() {
this.deltaX = window.pageXOffset
|| document.documentElement.scrollLeft
|| document.body.scrollLeft
|| 0;
this.deltaY = window.pageYOffset
|| document.documentElement.scrollTop
|| document.body.scrollTop
|| 0;
},
realOffset: function(element) {
var valueT = 0, valueL = 0;
do {
valueT += element.scrollTop || 0;
valueL += element.scrollLeft || 0;
element = element.parentNode;
} while (element);
return [valueL, valueT];
},
cumulativeOffset: function(element) {
var valueT = 0, valueL = 0;
do {
valueT += element.offsetTop || 0;
valueL += element.offsetLeft || 0;
element = element.offsetParent;
} while (element);
return [valueL, valueT];
},
positionedOffset: function(element) {
var valueT = 0, valueL = 0;
do {
valueT += element.offsetTop || 0;
valueL += element.offsetLeft || 0;
element = element.offsetParent;
if (element) {
if(element.tagName=='BODY') break;
var p = Element.getStyle(element, 'position');
if (p == 'relative' || p == 'absolute') break;
}
} while (element);
return [valueL, valueT];
},
offsetParent: function(element) {
if (element.offsetParent) return element.offsetParent;
if (element == document.body) return element;
while ((element = element.parentNode) && element != document.body)
if (Element.getStyle(element, 'position') != 'static')
return element;
return document.body;
},
// caches x/y coordinate pair to use with overlap
within: function(element, x, y) {
if (this.includeScrollOffsets)
return this.withinIncludingScrolloffsets(element, x, y);
this.xcomp = x;
this.ycomp = y;
this.offset = this.cumulativeOffset(element);
return (y >= this.offset[1] &&
y < this.offset[1] + element.offsetHeight &&
x >= this.offset[0] &&
x < this.offset[0] + element.offsetWidth);
},
withinIncludingScrolloffsets: function(element, x, y) {
var offsetcache = this.realOffset(element);
this.xcomp = x + offsetcache[0] - this.deltaX;
this.ycomp = y + offsetcache[1] - this.deltaY;
this.offset = this.cumulativeOffset(element);
return (this.ycomp >= this.offset[1] &&
this.ycomp < this.offset[1] + element.offsetHeight &&
this.xcomp >= this.offset[0] &&
this.xcomp < this.offset[0] + element.offsetWidth);
},
// within must be called directly before
overlap: function(mode, element) {
if (!mode) return 0;
if (mode == 'vertical')
return ((this.offset[1] + element.offsetHeight) - this.ycomp) /
element.offsetHeight;
if (mode == 'horizontal')
return ((this.offset[0] + element.offsetWidth) - this.xcomp) /
element.offsetWidth;
},
page: function(forElement) {
var valueT = 0, valueL = 0;
var element = forElement;
do {
valueT += element.offsetTop || 0;
valueL += element.offsetLeft || 0;
// Safari fix
if (element.offsetParent == document.body)
if (Element.getStyle(element,'position')=='absolute') break;
} while (element = element.offsetParent);
element = forElement;
do {
if (!window.opera || element.tagName=='BODY') {
valueT -= element.scrollTop || 0;
valueL -= element.scrollLeft || 0;
}
} while (element = element.parentNode);
return [valueL, valueT];
},
clone: function(source, target) {
var options = Object.extend({
setLeft: true,
setTop: true,
setWidth: true,
setHeight: true,
offsetTop: 0,
offsetLeft: 0
}, arguments[2] || {})
// find page position of source
source = $(source);
var p = Position.page(source);
// find coordinate system to use
target = $(target);
var delta = [0, 0];
var parent = null;
// delta [0,0] will do fine with position: fixed elements,
// position:absolute needs offsetParent deltas
if (Element.getStyle(target,'position') == 'absolute') {
parent = Position.offsetParent(target);
delta = Position.page(parent);
}
// correct by body offsets (fixes Safari)
if (parent == document.body) {
delta[0] -= document.body.offsetLeft;
delta[1] -= document.body.offsetTop;
}
// set position
if(options.setLeft) target.style.left = (p[0] - delta[0] + options.offsetLeft) + 'px';
if(options.setTop) target.style.top = (p[1] - delta[1] + options.offsetTop) + 'px';
if(options.setWidth) target.style.width = source.offsetWidth + 'px';
if(options.setHeight) target.style.height = source.offsetHeight + 'px';
},
absolutize: function(element) {
element = $(element);
if (element.style.position == 'absolute') return;
Position.prepare();
var offsets = Position.positionedOffset(element);
var top = offsets[1];
var left = offsets[0];
var width = element.clientWidth;
var height = element.clientHeight;
element._originalLeft = left - parseFloat(element.style.left || 0);
element._originalTop = top - parseFloat(element.style.top || 0);
element._originalWidth = element.style.width;
element._originalHeight = element.style.height;
element.style.position = 'absolute';
element.style.top = top + 'px';
element.style.left = left + 'px';
element.style.width = width + 'px';
element.style.height = height + 'px';
},
relativize: function(element) {
element = $(element);
if (element.style.position == 'relative') return;
Position.prepare();
element.style.position = 'relative';
var top = parseFloat(element.style.top || 0) - (element._originalTop || 0);
var left = parseFloat(element.style.left || 0) - (element._originalLeft || 0);
element.style.top = top + 'px';
element.style.left = left + 'px';
element.style.height = element._originalHeight;
element.style.width = element._originalWidth;
}
}
// Safari returns margins on body which is incorrect if the child is absolutely
// positioned. For performance reasons, redefine Position.cumulativeOffset for
// KHTML/WebKit only.
if (Prototype.Browser.WebKit) {
Position.cumulativeOffset = function(element) {
var valueT = 0, valueL = 0;
do {
valueT += element.offsetTop || 0;
valueL += element.offsetLeft || 0;
if (element.offsetParent == document.body)
if (Element.getStyle(element, 'position') == 'absolute') break;
element = element.offsetParent;
} while (element);
return [valueL, valueT];
}
}
Element.addMethods(); jclicmoodle-0.1.0.11/mod/jclic/config.html 0000664 0001750 0001750 00000001462 11567136416 020343 0 ustar demarchi demarchi
jclicmoodle-0.1.0.11/mod/jclic/view.php 0000664 0001750 0001750 00000021164 11567171117 017671 0 ustar demarchi demarchi course)) {
error("Course is misconfigured");
}
require_login($course->id, false, $cm);
if (function_exists('get_context_instance')) $context = get_context_instance(CONTEXT_MODULE, $cm->id);
if (! $jclic = get_record("jclic", "id", $cm->instance)) {
error("JClic id was incorrect");
}
add_to_log($course->id, "jclic", "view", "view.php?id=$cm->id", "$jclic->id");
/// Print the page header
if ($course->category) {
$navigation = "id\">$course->shortname ->";
}
$strjclics = get_string("modulenameplural", "jclic");
$strjclic = get_string("modulename", "jclic");
$strstarttime = get_string("starttime", "jclic");
$strscore = get_string("score", "jclic");
$strtotaltime = get_string("totaltime", "jclic");
$strdone = get_string("activitydone", "jclic");
$strsolved = get_string("activitysolved", "jclic");
$strattempts = get_string("attempts", "jclic");
$strnoattempts = get_string("msg_noattempts", "jclic");
$strlastaccess = get_string("lastaccess", "jclic");
$strtotals = get_string("totals", "jclic");
$strshowall = get_string("showall", "jclic");
$strhideall = get_string("hideall", "jclic");
$strshow_results = get_string("show_results", "jclic");
$strpreview_jclic = get_string("preview_jclic", "jclic");
print_header_simple(format_string($jclic->name), "",
"id\">$strjclics -> ".format_string($jclic->name), "", "", true,
update_module_button($cm->id, $course->id, $strjclic), navmenu($course, $cm));
$groupmode = groupmode($course, $cm);
$currentgroup = setup_and_print_groups($course, $groupmode, 'view.php?id=' . $cm->id);
/// Print the main part of the page
echo "";
echo "".$jclic->description."
";
$jclic_url = (substr($jclic->url, 0, 4)=='http')?$jclic->url:'http://'.jclic_get_server().jclic_get_path().'/file.php/'.$course->id.'/'.$jclic->url;
if (isteacher($course->id) && (!function_exists('has_capability') || has_capability('mod/jclic:viewjclic', $context)) ){
// Preview the JClic activity
echo '
';
// echo "";
$showall=optional_param('showall', false, PARAM_BOOL);
$strshow=$showall?$strhideall:$strshowall;
echo "";
// Print manual table
echo '';
$general_align=array('left','center','center','center','center','center','center');
jclic_print_row(array('',$showall?$strstarttime:$strlastaccess, $strdone,$strsolved,$strtotaltime,$strscore,$strattempts),$general_align,'',true);
// Print sessions and activities of all students
if ($students=jclic_get_students($cm, $course, $jclic->id)){
foreach($students as $student){
$student->id=$student->userid;
if ($showall){
// Print sessions for each student
$sessions=jclic_get_sessions($jclic->id,$student->userid);
if (sizeof($sessions)>0){
$first_session=true;
foreach($sessions as $session){
$sessiontime=''.date('d/m/Y H:i',strtotime($session->starttime)).'';
if ($first_session){
$first_session=false;
$student_info = print_user_picture($student, $course->id, NULL, 0, true).$student->firstname.' '.$student->lastname;
$table_data = array($student_info, $sessiontime, $session->done,$session->solved, $session->totaltime, $session->score.'%', $session->attempts.($jclic->maxattempts>0?'/'.$jclic->maxattempts:''));
$table_props = array('rowspan="'.(sizeof($sessions)*2+1).'"','','','','','','');
$table_align=$general_align;
}else{
$table_data = array($sessiontime, $session->done,$session->solved,$session->totaltime,$session->score.'%', $session->attempts.($jclic->maxattempts>0?'/'.$jclic->maxattempts:''));
$table_props = '';
$table_align=array('center','center','center','center','center','center');
}
jclic_print_row($table_data, $table_align, $table_props);
// Print activities for each session
print_session_activities($session->session_id);
}
}
}
$sessions_summary=jclic_get_sessions_summary($jclic->id,$student->userid);
$starttime=array_key_exists('starttime', $sessions_summary)?$sessions_summary->starttime:'0';
if ($starttime>0) $starttime=date('d/m/Y H:i',strtotime($sessions_summary->starttime));
else $starttime='-';
if (!$showall || sizeof($sessions)<=0){
$table_align=$general_align;
$student_info = print_user_picture($student, $course->id, NULL, 0, true).$student->firstname.' '.$student->lastname;
jclic_print_row(array ($student_info, !$showall?$starttime:(sizeof($sessions)<=0?'-':''.$strtotals.''), ''.$sessions_summary->done.'',''.$sessions_summary->solved.'',''.$sessions_summary->totaltime.'',''.$sessions_summary->score.' %', ''.$sessions_summary->attempts.($jclic->maxattempts>0?'/'.$jclic->maxattempts:'').''), $table_align);
}else {
$table_align=array('center','center','center','center','center','center');
jclic_print_row(array (!$showall?$starttime:(sizeof($sessions)<=0?'-':''.$strtotals.''), ''.$sessions_summary->done.'',''.$sessions_summary->solved.'', ''.$sessions_summary->totaltime.'',''.$sessions_summary->score.' %',''.$sessions_summary->attempts.($jclic->maxattempts>0?'/'.$jclic->maxattempts:'').''), $table_align);
}
}
}
echo '
';
$delid=optional_param('delete', PARAM_INT);
if (isset($delid)){
jclic_delete_instance($delid);
}
}else{
$protocol = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443) ? "https" : "http";
echo "";
echo '
'.$strshow_results.'';
$sessions=jclic_get_sessions($jclic->id,$USER->id);
$attempts=sizeof($sessions);
if ($jclic->maxattempts<0 || $attempts < $jclic->maxattempts){
//$jclic_url = (substr($jclic->url, 0, 4)=='http')?$jclic->url:'http://'.jclic_get_server().jclic_get_path().'/file.php/'.$course->id.'/'.$jclic->url;
echo '';
echo '";
echo '
';
}else{
echo "
".$strnoattempts;
}
}
echo "
";
/// Finish the page
print_footer($course);
?>
jclicmoodle-0.1.0.11/mod/jclic/mod_form.php 0000664 0001750 0001750 00000007722 11567171117 020525 0 ustar demarchi demarchi dirroot.'/course/moodleform_mod.php');
class mod_jclic_mod_form extends moodleform_mod {
function definition() {
global $CFG, $COURSE;
$mform =& $this->_form;
$strrequired = get_string('required');
//-------------------------------------------------------------------------------
$mform->addElement('header', 'general', get_string('general', 'form'));
$mform->addElement('text', 'name', get_string('name'), array('size'=>'64'));
$mform->setType('name', PARAM_TEXT);
$mform->addRule('name', null, 'required', null, 'client');
$mform->addElement('htmleditor', 'description', get_string('description'));
$mform->setType('description', PARAM_RAW);
$mform->setHelpButton('description', array('writing', 'questions', 'text'), false, 'editorhelpbutton');
//-------------------------------------------------------------------------------
$mform->addElement('header', 'header_jclic', get_string('header_jclic', 'jclic'));
$mform->addElement('choosecoursefile', 'url', get_string('url', 'jclic'), array('courseid'=>$COURSE->id));
$mform->setHelpButton('url', array('url',get_string('url', 'jclic'), 'jclic'), false, 'helpbutton');
$mform->setDefault('url', '');
$mform->setType('url', PARAM_RAW);
$mform->addRule('url', null, 'required', null, 'client');
$mform->addElement('text', 'exiturl', get_string('exiturl', 'jclic'), array('size'=>75));
$mform->setHelpButton('exiturl', array('exiturl',get_string('exiturl', 'jclic'), 'jclic'), false, 'helpbutton');
$mform->setDefault('exiturl', '');
$mform->setType('exiturl', PARAM_RAW);
$options = jclic_get_languages();
$mform->addElement('select', 'lang', get_string('lang', 'jclic'), $options);
$mform->setDefault('lang', substr($CFG->lang, 0, -5));
$options = jclic_get_skins();
$mform->addElement('select', 'skin', get_string('skin', 'jclic'), $options);
$mform->addElement('text', 'width', get_string('width', 'jclic'), array('size'=>'5'));
$mform->setDefault('width', '600');
$mform->addElement('text', 'height', get_string('height', 'jclic'), array('size'=>'5'));
$mform->setDefault('height', '400');
//-------------------------------------------------------------------------------
$mform->addElement('header', 'header_score', get_string('header_score', 'jclic'));
/*$mform->addElement('modgrade', 'maxxgrade', get_string('grade'));
$mform->setDefault('grade', 100);
$mform->addElement('date_time_selector', 'timeavailable', get_string('availabledate', 'jclic'), array('optional'=>true));
$mform->setDefault('timeavailable', time());
$mform->addElement('date_time_selector', 'timedue', get_string('duedate', 'jclic'), array('optional'=>true));
$mform->setDefault('timedue', time()+7*24*3600);*/
$options = array(-1 => get_string('unlimited','jclic'), 1 => 1, 2 => 2, 3 => 3, 4 => 4, 5 => 5, 10 => 10);
$mform->addElement('select', 'maxattempts', get_string('maxattempts', 'jclic'), $options);
$mform->setDefault('maxattempts', '-1');
$options = array('score' => get_string('avaluation_score','jclic'),'solved' => get_string('avaluation_solved','jclic'));
$mform->addElement('select', 'avaluation', get_string('avaluation', 'jclic'), $options);
$mform->setDefault('avaluation', '-1');
$mform->addElement('text', 'maxgrade', get_string('maxgrade', 'jclic'), array('size'=>'5'));
$mform->addRule('maxgrade', null, 'numeric', null, 'client');
$mform->setDefault('maxgrade', '100');
//-------------------------------------------------------------------------------
$this->standard_coursemodule_elements();
// buttons
$this->add_action_buttons();
}
}
?>
jclicmoodle-0.1.0.11/mod/jclic/action/student_results.php 0000664 0001750 0001750 00000006232 11567171117 023442 0 ustar demarchi demarchi course)) {
error("Course is misconfigured");
}
if (! $jclic = get_record("jclic", "id", $cm->instance)) {
error("Course module is incorrect");
}
}
require_login($course->id);
$strjclics = get_string("modulenameplural", "jclic");
$strstarttime = get_string("starttime", "jclic");
$strscore = get_string("score", "jclic");
$strtotaltime = get_string("totaltime", "jclic");
$strtotals = get_string("totals", "jclic");
$strdone = get_string("activitydone", "jclic");
$stractivitysolved = get_string("activitysolved", "jclic");
$strattempts = get_string("attempts", "jclic");
$strlastaccess = get_string("lastaccess", "jclic");
$strmsgnosessions = get_string("msg_nosessions", "jclic");
$stractivity = get_string("activity", "jclic");
$strsolved = get_string("solved", "jclic");
$stractions = get_string("actions", "jclic");
$strtime = get_string("time", "jclic");
$stryes = get_string("yes");
$strno = get_string("no");
print_header("$course->shortname: $jclic->name", "$jclic->name", "");
$sessions=jclic_get_sessions($jclic->id,$USER->id);
if (sizeof($sessions)>0){
echo "";
echo '';
$general_align=array('center','center','center','center','center','center');
// Print header
jclic_print_row(array($strstarttime, $strscore, $strtotaltime, $strdone, $stractivitysolved, $strattempts),$general_align,'',true);
// Print session data
foreach($sessions as $session){
$sessiontime=''.date('d/m/Y H:i',strtotime($session->starttime)).'';
$table_data = array($sessiontime, $session->score.'%', $session->totaltime,$session->done,$session->solved,$session->attempts.($jclic->maxattempts>0?'/'.$jclic->maxattempts:''));
jclic_print_row($table_data, $general_align);
// Print activities for each session
print_session_activities($session->session_id);
}
if (sizeof($sessions)>1){
$sessions_summary=jclic_get_sessions_summary($jclic->id,$USER->id);
jclic_print_row(array (''.$strtotals.'', ''.$sessions_summary->score.'%', ''.$sessions_summary->totaltime.'',''.$sessions_summary->done.'',''.$sessions_summary->solved.'',''.$sessions_summary->attempts.''),$general_align);
}
echo '
';
}else{
echo '
'.$strmsgnosessions.'';
}
?>
jclicmoodle-0.1.0.11/mod/jclic/action/beans.php 0000664 0001750 0001750 00000013521 11567171117 021262 0 ustar demarchi demarchi $attribs['NAME'],'start'=>$attribs['START'],'time'=>$attribs['TIME'],'solved'=>$attribs['SOLVED'],'score'=>$attribs['SCORE'],'minActions'=>$attribs['MINACTIONS'],'actions'=>$attribs['ACTIONS']);
}
$elements[ $thisElement ] = $attribs;
}
function endElement($parser, $name) {
global $beans, $currentBean, $params, $thisElement, $oldElements;
$thisElement= array_pop( $oldElements);
$beans[$currentBean]['PARAMS']=$params;
}
function characterData($parser, $text) {
global $beans, $currentBean, $params, $thisElement, $elements;
$elements[ $thisElement ] .= $text;
}
$xml_parser = xml_parser_create('');
xml_set_element_handler($xml_parser, "startElement", "endElement");
xml_set_character_data_handler($xml_parser, "characterData");
xml_parse($xml_parser, $my_xml);
xml_parser_free($xml_parser);
/*$jclic_log->bean=$beans[0]['ID'];
$jclic_log->xml=$my_xml;
$jclic_log->time=time();
insert_record("jclic_log", $jclic_log);*/
//addEntry($beans[0]['ID'], $my_xml);
switch($beans[0]['ID']){
case "get_properties":
echo '';
echo '';
$settings = get_records("jclic_settings");
foreach($settings as $setting){
echo ' ';
}
echo '';
break;
case "add session":
$jclic_session->jclicid=$beans[0]['PARAMS']['key'];
$jclic_session->user_id=$beans[0]['PARAMS']['user'];
$jclic_session->session_datetime=round($beans[0]['PARAMS']['time']/1000);
$jclic_session->session_id=$beans[0]['PARAMS']['user'].'_'.$beans[0]['PARAMS']['time'];
$jclic_session->project_name=$beans[0]['PARAMS']['project'];
insert_record("jclic_sessions", $jclic_session);
if (!get_record("jclic_users", "user_id", $beans[0]['PARAMS']['user'].'')){
if ($user = get_record("user", "id", $beans[0]['PARAMS']['user'].'')){
$jclic_user->user_id=$beans[0]['PARAMS']['user'];
$jclic_user->group_id='1';
$jclic_user->user_name=$user->firstname.' '.$user->lastname;
insert_record("jclic_users", $jclic_user);
}
}
echo '';
echo '';
echo ' ';
echo '';
break;
case "multiple":
foreach ($beans as $bean){
if ($bean['ID']=='add activity'){
$jclic_activity->session_id=$bean['PARAMS']['session'];
$jclic_activity->activity_id=$bean['PARAMS']['num'];
$jclic_activity->activity_name=$bean['ACTIVITY']['name'];
$jclic_activity->num_actions=$bean['ACTIVITY']['actions'];
$jclic_activity->activity_solved=$bean['ACTIVITY']['solved']=='true'?1:0;
$jclic_activity->score=$bean['ACTIVITY']['score'];
$jclic_activity->qualification=getPrecision($bean['ACTIVITY']['minActions'], $bean['ACTIVITY']['actions'], ''.$bean['ACTIVITY']['solved'], $bean['ACTIVITY']['score']);
//$jclic_activity->starttime=$bean['ACTIVITY']['start'];
$jclic_activity->total_time=$bean['ACTIVITY']['time'];
insert_record("jclic_activities", $jclic_activity);
}
}
jclic_update_gradebook($jclic_activity);
echo '';
echo '';
echo ' ';
echo '';
break;
default:
echo '';
echo '';
echo ' ';
echo '';
}
function getPrecision($minActions, $numActions, $solved, $score){
$precision = 0;
if ($minActions>0 && $numActions>0){
if ($solved=='true'){
if ($numActions<$minActions) $precision=100;
else $precision=($minActions*100)/$numActions;
}else{
$precision=100*($score*$score)/($minActions*$numActions);
}
}
return $precision;
}
//
//
//
?>
jclicmoodle-0.1.0.11/mod/jclic/action/preview_jclic.php 0000664 0001750 0001750 00000002603 11567171117 023016 0 ustar demarchi demarchi course)) {
error("Course is misconfigured");
}
if (! $jclic = get_record("jclic", "id", $cm->instance)) {
error("Course module is incorrect");
}
}
require_login($course->id);
print_header("$course->shortname: $jclic_name", "$jclic_name", "");
echo "";
echo '';
echo '";
echo '
';
?>
jclicmoodle-0.1.0.11/mod/jclic/db/mysql.php 0000664 0001750 0001750 00000000372 11567171117 020447 0 ustar demarchi demarchi
jclicmoodle-0.1.0.11/mod/jclic/db/mysql.sql 0000664 0001750 0001750 00000007415 11567136416 020467 0 ustar demarchi demarchi # This file contains a complete database schema for all the
# tables used by jclic module, written in SQL
#
# Table structure for `jclic`
#
CREATE TABLE `prefix_jclic` (
`id` int(10) unsigned NOT NULL auto_increment,
`course` int(10) unsigned NOT NULL default '0',
`name` varchar(255) NOT NULL default '',
`description` text,
`url` varchar(100) NOT NULL default '',
`skin` varchar(20) NOT NULL default '',
`maxattempts` int(3) default '0',
`width` int(5) unsigned default '600',
`height` int(5) unsigned default '400',
`avaluation` varchar(10) default NULL,
`maxgrade` varchar(15) default NULL,
PRIMARY KEY (`id`),
KEY `course` (`course`)
) COMMENT='Main information about each jclic activity';
# --------------------------------------------------------
#
# Table structure for `jclic_sessions`
#
CREATE TABLE `prefix_jclic_sessions` (
`id` int(10) unsigned NOT NULL auto_increment,
`jclicid` int(10) unsigned NOT NULL default '0',
`session_id` varchar(50) NOT NULL default '',
`user_id` varchar(50) NOT NULL default '',
`session_datetime` timestamp(14) NOT NULL,
`project_name` varchar(100) NOT NULL default '',
`session_key`varchar(50) default NULL,
`session_code` varchar(50) default NULL,
`session_context` varchar(50) default NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `session_id` (`session_id`),
KEY `user_id` (`user_id`),
KEY `jclicid` (`jclicid`)
) COMMENT='Main information about each jclic session';
#
# Table structure for `jclic_activities`
#
CREATE TABLE `prefix_jclic_activities` (
`id` int(10) unsigned NOT NULL auto_increment,
`session_id` varchar(50) NOT NULL default '',
`activity_id` int(5) NOT NULL default '0',
`activity_name` varchar(50) NOT NULL default '',
`num_actions` int(4) default NULL,
`score` int(4) default NULL,
`activity_solved` int(1) default NULL,
`qualification` int(3) default NULL,
`total_time` int(5) default NULL,
`activity_code` varchar(50) default NULL,
PRIMARY KEY (`id`)
) COMMENT='Stores user information for each jclic activity';
#
# Table structure for `jclic_settings`
#
CREATE TABLE `prefix_jclic_settings` (
`setting_key` varchar(255) NOT NULL default '',
`setting_value` varchar(255) default NULL,
PRIMARY KEY (`setting_key`)
) COMMENT='Stores settings information';
-- Load data
INSERT INTO `prefix_jclic_settings` VALUES ('ALLOW_CREATE_GROUPS', 'false');
INSERT INTO `prefix_jclic_settings` VALUES ('ALLOW_CREATE_USERS', 'false');
INSERT INTO `prefix_jclic_settings` VALUES ('SHOW_GROUP_LIST', 'false');
INSERT INTO `prefix_jclic_settings` VALUES ('SHOW_USER_LIST', 'false');
INSERT INTO `prefix_jclic_settings` VALUES ('USER_TABLES', 'true');
INSERT INTO `prefix_jclic_settings` VALUES ('TIME_LAP', '10');
# --------------------------------------------------------
#
# Table structure for `jclic_groups`
#
CREATE TABLE `prefix_jclic_groups` (
`id` int(10) unsigned NOT NULL auto_increment,
`group_id` varchar(50) NOT NULL default '',
`group_name` varchar(80) NOT NULL default '',
`group_description` varchar(255) default NULL,
`group_icon` varchar(255) default NULL,
`group_code` varchar(50) default NULL,
`group_keywords` varchar(255) default NULL,
PRIMARY KEY (`id`)
);
-- Load data
INSERT INTO `prefix_jclic_groups` (group_id, group_name) VALUES ('1', 'Moodle');
# --------------------------------------------------------
#
# Table structure for `jclic_users`
#
CREATE TABLE `prefix_jclic_users` (
`id` int(10) unsigned NOT NULL auto_increment,
`user_id` varchar(50) NOT NULL default '',
`group_id` varchar(50) NOT NULL default '',
`user_name` varchar(80) NOT NULL default '',
`user_pwd` varchar(255) default NULL,
`user_icon` varchar(255) default NULL,
`user_code` varchar(50) default NULL,
`user_keywords` varchar(255) default NULL,
PRIMARY KEY (`id`)
);
jclicmoodle-0.1.0.11/mod/jclic/db/access.php 0000664 0001750 0001750 00000003206 11567171117 020542 0 ustar demarchi demarchi :
//
// component_name should be the same as the directory name of the mod or block.
//
// Core moodle capabilities are defined thus:
// moodle/:
//
// Examples: mod/forum:viewpost
// block/recent_activity:view
// moodle/site:deleteuser
//
// The variable name for the capability definitions array follows the format
// $__capabilities
//
// For the core capabilities, the variable is $moodle_capabilities.
$mod_jclic_capabilities = array(
'mod/jclic:submit' => array(
'captype' => 'write',
'contextlevel' => CONTEXT_MODULE,
'legacy' => array(
'student' => CAP_ALLOW
)
),
'mod/jclic:viewjclic' => array(
'captype' => 'read',
'contextlevel' => CONTEXT_MODULE,
'legacy' => array(
'teacher' => CAP_ALLOW,
'editingteacher' => CAP_ALLOW,
'admin' => CAP_ALLOW
)
)
);
?>
jclicmoodle-0.1.0.11/mod/jclic/db/postgres7.php 0000664 0001750 0001750 00000000377 11567171117 021244 0 ustar demarchi demarchi
jclicmoodle-0.1.0.11/mod/jclic/db/install.xml 0000664 0001750 0001750 00000024324 11567143030 020755 0 ustar demarchi demarchi
jclicmoodle-0.1.0.11/mod/jclic/db/upgrade.php 0000664 0001750 0001750 00000002504 11567171117 020730 0 ustar demarchi demarchi setAttributes(XMLDB_TYPE_CHAR, '10', null, XMLDB_NOTNULL, null, null, null, 'ca', 'url');
$result = $result && add_field($table, $field);
/// Define exiturl field format to be added to jclic
$field = new XMLDBField('exiturl');
$field->setAttributes(XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null, null, null, 'url');
$result = $result && add_field($table, $field);
}
return $result;
}
?>
jclicmoodle-0.1.0.11/mod/jclic/db/postgres7.sql 0000664 0001750 0001750 00000010112 11567136416 021243 0 ustar demarchi demarchi # This file contains a complete database schema for all the
# tables used by jclic module, written in SQL
#
# Table structure for `jclic`
#
CREATE TABLE prefix_jclic (
id SERIAL PRIMARY KEY,
course INT4 NOT NULL default '0',
name VARCHAR(255) NOT NULL default '',
description TEXT,
url VARCHAR(100) NOT NULL default '',
skin VARCHAR(20) NOT NULL default '',
maxattempts INT2 default '0',
width INT2 default '600',
height INT2 default '400',
avaluation VARCHAR(10) default NULL,
maxgrade VARCHAR(15) default NULL
);
COMMENT ON TABLE prefix_jclic IS 'Main information about each jclic activity';
CREATE INDEX prefix_jclic_course ON prefix_jclic (course);
# PRIMARY KEY (`id`),
# KEY `course` (`course`)
# --------------------------------------------------------
#
# Table structure for `jclic_sessions`
#
CREATE TABLE prefix_jclic_sessions (
id SERIAL PRIMARY KEY,
jclicid INT2 NOT NULL default '0',
session_id VARCHAR(50) NOT NULL default '',
user_id VARCHAR(50) NOT NULL default '',
session_datetime TIMESTAMP NOT NULL,
project_name VARCHAR(100) NOT NULL default '',
session_key VARCHAR(50) default NULL,
session_code VARCHAR(50) default NULL,
session_context VARCHAR(50) default NULL
);
COMMENT ON TABLE prefix_jclic_sessions IS 'Main information about each jclic session';
CREATE INDEX prefix_jclic_sessions_user_id ON prefix_jclic_sessions (user_id);
CREATE INDEX prefix_jclic_sessions_jclicid ON prefix_jclic_sessions (jclicid);
CREATE UNIQUE INDEX prefix_jclic_sessions_session_id_uk ON prefix_jclic_sessions (session_id);
#
# Table structure for `jclic_activities`
#
CREATE TABLE prefix_jclic_activities (
id SERIAL PRIMARY KEY,
session_id VARCHAR(50) NOT NULL default '',
activity_id INT2 NOT NULL default '0',
activity_name VARCHAR(50) NOT NULL default '',
num_actions INT2 default NULL,
score INT2 default NULL,
activity_solved INT2 default NULL,
qualification INT2 default NULL,
total_time INT2 default NULL,
activity_code VARCHAR(50) default NULL
);
COMMENT ON TABLE prefix_jclic_activities IS 'Stores user information for each jclic activity';
#
# Table structure for `jclic_settings`
#
CREATE TABLE prefix_jclic_settings (
setting_key VARCHAR(255) NOT NULL default '',
setting_value VARCHAR(255) default NULL,
PRIMARY KEY (setting_key)
);
COMMENT ON TABLE prefix_jclic_settings IS 'Stores settings information';
# PRIMARY KEY (`setting_key`)
-- Load data
INSERT INTO prefix_jclic_settings VALUES ('ALLOW_CREATE_GROUPS', 'false');
INSERT INTO prefix_jclic_settings VALUES ('ALLOW_CREATE_USERS', 'false');
INSERT INTO prefix_jclic_settings VALUES ('SHOW_GROUP_LIST', 'false');
INSERT INTO prefix_jclic_settings VALUES ('SHOW_USER_LIST', 'false');
INSERT INTO prefix_jclic_settings VALUES ('USER_TABLES', 'true');
INSERT INTO prefix_jclic_settings VALUES ('TIME_LAP', '10');
# --------------------------------------------------------
#
# Table structure for `jclic_groups`
#
CREATE TABLE prefix_jclic_groups (
id SERIAL PRIMARY KEY,
group_id VARCHAR(50) NOT NULL default '',
group_name VARCHAR(80) NOT NULL default '',
group_description VARCHAR(255) default NULL,
group_icon VARCHAR(255) default NULL,
group_code VARCHAR(50) default NULL,
group_keywords VARCHAR(255) default NULL
);
-- Load data
INSERT INTO prefix_jclic_groups (group_id, group_name) VALUES ('1', 'Moodle');
# --------------------------------------------------------
#
# Table structure for `jclic_users`
#
CREATE TABLE prefix_jclic_users (
id SERIAL PRIMARY KEY,
user_id VARCHAR(50) NOT NULL default '',
group_id VARCHAR(50) NOT NULL default '',
user_name VARCHAR(80) NOT NULL default '',
user_pwd VARCHAR(255) default NULL,
user_icon VARCHAR(255) default NULL,
user_code VARCHAR(50) default NULL,
user_keywords VARCHAR(255) default NULL
);
jclicmoodle-0.1.0.11/mod/jclic/pix/jclic_upload_es.gif 0000664 0001750 0001750 00000020052 11567136416 022612 0 ustar demarchi demarchi GIF89a^ ===߽Ť̤ oeK%{{{ŵ 3ʾqóϾԜ~Z[ͽ%ŽffzU33ŷXmmss̙ޔd{{2þ/fffɽſ|WWuRRSq]]]~ #!T?C}Ŀ÷ĽKNPfƾ%ttݰ ܆ﵽ歭III߽аff
86!÷ühsĵ;*Ħ! , ^ mH*\ȰÇ#JHŋ3jȱǏ CIɓ!IYɲ˗0cʜI͛8sɳϟ@
zsdH*]ʴӧPJJիXjʵׯSQKٳhӪ]˶۷pʝKݻx˷߿LÈj&G>,}##ܿp3nLfdcWㅉ
,:q:^ǐ+X49K6~PyLhdTdxDAQڍ0 pDK4g}؍j
v"" = :.@!
t .ôq-M&A/Xa6B.&(a.
_xđ!0;Ysd
}y!.$
فA
"6@-0!+j20P 6ϼC@|3w8&
wM
6'|bQ% P1
#$/w+"⏧D!|J*TB-aO AC;Ѝ$M*$`.Zhj L+ٶsª;T3l6 |_%ks˄1a8>j+aøL`4LQn]ć=%8s|Ɏ+,:]MO4c_$o[^n`@*@0e60s^-܄)+QH%od"JH]3*>"3L@I
q,kNs5-Wr/`.dN2|h/͗dNDL@+KՇ;ҵE"3'ac{Ü#ath%i8RaЈ)Xe!j8`P
aGiƱ^P<7Hǁ6D/pSu-{ѳǾNa@gx @ǽRֆa$X@4|g`><
[x]%ȃ6$
z9@(hDaߘ9Q / IG91x GR |H"l4B"m@5>Rñ"KF8]є (ǁD!#GIZ̥.mi^0IbL2f:Ќ4IjRș6nzS"8
r~1vWs/oL-?>A òW"pdlЍؠaE)1сNЌ C&*BPN0Ctl)(UpP
A7䁨#}6ĩ)E|x 28
0 n$m8 \Ѐ<#
4X"1
#upq 3 A 80x,SN0 + ,cQC3ҕNd`1H v|ablw@HpP,aER["` t[6`Za,a@@3pMupJP\ R«|[D*h| =a,ʒ.d` Ԍ
W_Ul[trjJB2lPOXT +MJP+xkC҈ 7`#X
R y 4 "0UT݁H7 s