diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 00000000..2bb482a2 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,12 @@ +# Set the default behavior, in case people don't have core.autocrlf set. +* text eol=lf + +# Explicitly declare text files you want to always be normalized and converted +# to native line endings on checkout. +*.php text +*.js text +*.css text + +# Denote all files that are truly binary and should not be modified. +*.png binary +*.jpg binary \ No newline at end of file diff --git a/.jshintrc b/.jshintrc new file mode 100644 index 00000000..8ec7b646 --- /dev/null +++ b/.jshintrc @@ -0,0 +1,9 @@ +{ + "extends": "../../../.jshintrc", + "globals": { + "$": false, + "console": false, + "Modernizr": false, + "Headroom": false + } +} \ No newline at end of file diff --git a/.travis.yml b/.travis.yml index 5d0f802f..06f19ce2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,43 +1,44 @@ -language: php - -sudo: false - -cache: - directories: - - $HOME/.composer/cache - -php: - - 5.4 - - 5.5 - - 5.6 - - 7.0 - -matrix: - allow_failures: - - php: 7.0 - -env: - global: - - MOODLE_BRANCH=MOODLE_30_STABLE - - IGNORE_NAMES=tc_colourpopup.php,tc_colourpopup.js - matrix: - - DB=pgsql - - DB=mysqli - -before_install: - - cd ../.. - - composer selfupdate - - composer create-project -n --no-dev moodlerooms/moodle-plugin-ci ci ^1 - - export PATH="$(cd ci/bin; pwd):$(cd ci/vendor/bin; pwd):$PATH" - -install: - - moodle-plugin-ci install - -script: - - moodle-plugin-ci phplint - - moodle-plugin-ci phpcpd - - moodle-plugin-ci phpmd - - moodle-plugin-ci codechecker - - moodle-plugin-ci csslint - - moodle-plugin-ci jshint - - moodle-plugin-ci phpunit +language: php + +sudo: false + +cache: + directories: + - $HOME/.composer/cache + +php: + # Only run the lowest and highest supported versions to reduce the load on travis-ci.org. + - 5.4 + # - 5.5 + # - 5.6 + - 7.0 + +matrix: + allow_failures: + - php: 7.0 + +env: + global: + - MOODLE_BRANCH=MOODLE_30_STABLE + - IGNORE_NAMES=tc_colourpopup.php,tc_colourpopup.js + matrix: + - DB=pgsql + - DB=mysqli + +before_install: + - cd ../.. + - composer selfupdate + - composer create-project -n --no-dev moodlerooms/moodle-plugin-ci ci ^1 + - export PATH="$(cd ci/bin; pwd):$(cd ci/vendor/bin; pwd):$PATH" + +install: + - moodle-plugin-ci install + +script: + - moodle-plugin-ci phplint + - moodle-plugin-ci phpcpd + - moodle-plugin-ci phpmd + - moodle-plugin-ci codechecker + - moodle-plugin-ci csslint + - moodle-plugin-ci jshint + - moodle-plugin-ci phpunit diff --git a/COPYING.txt b/COPYING.txt index 818433ec..94a9ed02 100644 --- a/COPYING.txt +++ b/COPYING.txt @@ -1,674 +1,674 @@ - 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 -. + 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 +. diff --git a/Readme.md b/Readme.md index 033c7493..d794d312 100644 --- a/Readme.md +++ b/Readme.md @@ -1,1233 +1,1238 @@ -Introduction -============ -Topic based course format with an individual 'toggle' for each topic except 0. - -If you find an issue with the format, please see the 'Reporting Issues' section below. - -Required version of Moodle -========================== -This version works with Moodle version 2015111600.00 3.0 (Build: 20151116) and above within the 3.0 branch until the -next release. - -Please ensure that your hardware and software complies with 'Requirements' in 'Installing Moodle' on -'docs.moodle.org/30/en/Installing_Moodle'. - -Downloads and documentation -=========================== -The primary source for downloading this branch of the format is https://moodle.org/plugins/view.php?plugin=format_topcoll -with 'Select Moodle version:' set at 'Moodle 3.0'. - -The secondary source is a tagged version with the v3.0 prefix on https://github.com/gjb2048/moodle-format_topcoll/tags - -If you download from the development area - https://github.com/gjb2048/moodle-format_topcoll/ - consider that -the code is unstable and not for use in production environments. This is because I develop the next version in stages -and use GitHub as a means of backup. Therefore the code is not finished, subject to alteration and requires testing. - -Documented on http://docs.moodle.org/29/en/Collapsed_Topics_course_format - -Bespoke changes -=============== -Would you like a bespoke Collapsed Topics? Contact me via www.gjbarnard.co.uk/contact/ for a competitive quote. - -Free software -============= -The Collapsed Topics format is 'free' software under the terms of the GNU GPLv3 License, please see 'COPYING.txt'. - -It can be obtained for free from the links in 'Downloads and documentation' above. - -You have all the rights granted to you by the GPLv3 license. If you are unsure about anything, then the -FAQ - http://www.gnu.org/licenses/gpl-faq.html - is a good place to look. - -If you reuse any of the code then I kindly ask that you make reference to the format. - -If you make improvements or bug fixes then I would appreciate if you would send them back to me by forking from -https://github.com/gjb2048/moodle-format_topcoll and doing a 'Pull Request' so that the rest of the -Moodle community benefits. - -Sponsorships -============ -Collapsed Topics is provided to you for free, and if you want to express your gratitude for using this format, please consider -sponsoring by: - -PayPal - Please contact me via my 'Moodle profile' (above) for details as I am an individual and therefore am unable to have -'buy me now' buttons under their terms. - -Flattr - https://flattr.com/profile/gjb2048 - -Sponsorships may allow me to provide you with more or better features in less time. - -New features for this Moodle 3.0 version -======================================== - 1. Same features as version 2.9.1.5 in Moodle 2.9. - -Installation -============ - 1. Ensure you have the version of Moodle as stated above in 'Required version of Moodle'. This is essential as the - format relies on underlying core code that is out of my control. - 2. If upgrading from Moodle 1.9, 2.0 or 2.1, please see 'Upgrading from Moodle 1.9, 2.0 or 2.1' below. - 3. If upgrading from Moodle 2.2, please see 'Upgrading from Moodle 2.2' below. - 4. If upgrading from Moodle 2.3, please see 'Upgrade Instructions' below. - 5. Put Moodle in 'Maintenance Mode' (docs.moodle.org/en/admin/setting/maintenancemode) so that there are no - users using it bar you as the administrator - if you have not already done so. - 6. Copy 'topcoll' to '/course/format/' if you have not already done so. - 7. In 'Site Administration -> Plugins -> Course formats -> Collapsed Topics' change the values of 'defaultlayoutelement', - 'defaultlayoutstructure' and 'defaultlayoutcolumns' for setting the default layout, structure and columns respectively - for new / updating courses as desired by following the instructions contained within. - 8. In 'Site Administration -> Plugins -> Course formats -> Collapsed Topics' change the values of 'defaulttgfgcolour', - 'defaulttgbgcolour' and 'defaulttgbghvrcolour' for setting the default toggle colours. - 9. In 'Site Administration -> Plugins -> Course formats -> Collapsed Topics' turn off toggle persistence if desired by - changing 'defaulttogglepersistence' as indicated. -10. In 'Site Administration -> Plugins -> Course formats -> Collapsed Topics' set the default toggle alignment by changing - 'defaulttogglealignment' as indicated. -11. Login as an administrator and follow standard the 'plugin' update notification. If needed, go to - 'Site administration' -> 'Notifications' if this does not happen. -12. To change the arrow graphic please see 'Icon Sets' below. -13. Put Moodle out of Maintenance Mode. - -Upgrade Instructions -==================== -1. Ensure you have the version of Moodle as stated above in 'Required version of Moodle'. This is essential as the - format relies on underlying core code that is out of my control. -2. If upgrading from Moodle 1.9, 2.0, 2.1 or 2.2 please read the appropriate sections below. -3. Put Moodle in 'Maintenance Mode' so that there are no users using it bar you as the administrator. -4. In '/course/format/' move old 'topcoll' directory to a backup folder outside of Moodle. -5. Follow installation instructions above. -6. If automatic 'Purge all caches' appears not to work by lack of display etc. then perform a manual 'Purge all caches' - under 'Home -> Site administration -> Development -> Purge all caches'. -7. Put Moodle out of Maintenance Mode. - -Upgrading from Moodle 1.9, 2.0 or 2.1 -------------------------------------- -Moodle 2.4 requires that Moodle 2.2 is installed to upgrade from, so therefore Moodle 2.2 is an intermediate step. -So: -1. Put Moodle in 'Maintenance Mode' so that there are no users using it bar you as the administrator. -2. In '/course/format/' move old 'topcoll' directory to a backup folder outside of Moodle. -3. Do not copy in the new version of 'topcoll' yet! As this will cause the upgrade to fail. -4. Upgrade to Moodle 2.2 first - http://docs.moodle.org/22/en/Upgrading_to_Moodle_2.2. -5. After you have installed Moodle 2.2, now upgrade to Moodle 2.4 with this new topcoll - - http://docs.moodle.org/24/en/Upgrading_to_Moodle_2.4 - but before initiating the upgrade you can copy the - new (i.e. this) 'topcoll' folder to '/course/format'. -6. Now follow 'Upgrading from Moodle 2.2' below please. -INFO: Having no 'topcoll' folder in '/course/format' is fine as the courses that use it are not accessed and - both the old and new versions will confuse an intermediate 2.2 version and cause it's installation to fail. - -Upgrading from Moodle 2.2 -------------------------- -1. Put Moodle in 'Maintenance Mode' so that there are no users using it bar you as the administrator - if you have - not already done so. -2. In '/course/format/' move old 'topcoll' directory to a backup folder outside of Moodle - if you have not - already done so. -3. Copy this new 'topcoll' folder to '/course/format/'. -4. Upgrade to Moodle 2.4 by being logged in as 'admin' and clicking on 'Home'. If you have previously upgraded but - 'topcoll' was an old version and the upgrade failed, this should still work. -5. Follow installation instructions above. -6. Put Moodle out of Maintenance Mode. -NOTE: If the automated upgrade fails for which can be seen by getting errors when using a Collapsed Topics course, - then please follow this. - Please carry on if a table / field has been removed / changed / already exists as it should still work - this - is to cope with the different possible scenarios. These instructions are written with the MySQL database in - mind, however should work with other database engines but the types should be compared with other tables in - the database to get an idea of what they should be. If possible please kindly feedback to me any additional - information you discover so I can update these instructions - contact details at the very bottom. - The table prefix i.e, 'mdl_' is not stated in the instructions but ensure you know what yours is and use - it with the table names. -1. In your database: -2.1 Rename the table 'format_topcoll_layout' to 'format_topcoll_settings'. -2.2 With the table 'format_topcoll_settings' change all integer types to signed if using a MySQL database. -2.3 If the table 'format_topcoll_settings' does not exist, then create it and add the following fields - in this order: -2.3.1 'id' of type 'BIGINT(10)' type, not null, auto increment, no zero fill with a null default value - the same - as any other 'id' field in the other tables. Make it the primary key. -2.3.2 'courseid' of type 'BIGINT(10)' type, not null, no auto increment, no zero fill with a null default value - the - same as the 'course' field in the 'course_sections' table bar the default value. -2.3.3 'layoutelement' of type 'TINYINT(2)' type, not null, no auto increment, no zero fill with a default value - of '1'. -2.3.4 'layoutstructure' of type 'TINYINT(1)' type, not null, no auto increment, no zero fill with a default value - of '1'. -2.4 With the table 'format_topcoll_settings' append three new fields of 'VARCHAR(6)' type, not null, called - 'tgfgcolour', 'tgbgcolour' and 'tgbghvrcolour' in that order with the default values of '000000', 'e2e2f2' - and 'eeeeff' respectively. -2.5 With the table 'format_topcoll_settings' append a new field 'layoutcolumns' after the 'layoutstructure' field - and with identical size, type and attributes. The default is '1'. i.e: -2.5.1 'layoutcolumns' of type 'TINYINT(1)' type, not null, no auto increment, no zero fill with a default value - of '1'. -2.6 Drop the table 'format_topcoll_cookie_cnsnt'. - -Uninstallation -============== -1. Put Moodle in 'Maintenance Mode' so that there are no users using it bar you as the administrator. -2. It is recommended but not essential to change all of the courses that use the format to another. If this is - not done Moodle will pick the last format in your list of formats to use but display in 'Edit settings' of the - course the first format in the list. You can then set the desired format. -3. In '/course/format/' remove the folder 'topcoll'. -4. In the database, remove the table 'format_topcoll_settings' along with the entry for 'format_topcoll' - ('plugin' attribute) in the table 'config_plugins'. If using the default prefix this will be - 'mdl_format_topcoll_settings' and 'mdl_config_plugins' respectively. -5. Put Moodle out of Maintenance Mode. - -Course Backup and Restore Instructions -====================================== -1. Backup as you would any other course. The layout configuration will be stored with the course settings. -2. Restore as you would any other course. If you are offered the option of 'Overwrite Course Configuration' - you must say 'Yes' to have the layout configuration restored otherwise the restored course will retain the - layout it previously had or the default in the 'config.php' file as mentioned in the 'Installation' - instructions above depending on the situation. -3. Note: I believe that if you restore a Collapsed Topic's course on an installation that does not have the - format then it will work and become the default course format. However the layout data will not be - stored if you install Collapsed Topic's at a later date. - -Remembered Toggle State Information -=================================== -The state of the toggles are remembered beyond the session on a per user per course basis though the employment -of a user preference. This functionality is now built in from previous versions. You do not need to do anything. - -Icon Sets -========= -Icon sets allow you to choose what is the most appropriate set of icons to use for a given courses demographic. They -are set on a per course basis but with all the functionality of the other settings in respect to a default and resetting -the current or all courses. - -If you want to change what icon represents which state / action, then edit 'styles.css' and change the selectors with -the 'background' attribute with a 'toggle-...' type class within them. There are selectors for both the 'toggles' and -the 'toggle all' functionality. For example: - - body.jsenabled .course-content ul.ctopics li.section .content .toggle-arrow a.toggle_closed { - background-image: url([[pix:format_topcoll|arrow_right]]); - } - - #toggle-all .content .toggle-arrow h4 a.off { - background-image: url([[pix:format_topcoll|arrow_down]]); - } - -If you would like your own icon set, either replace the icons in the 'pix' folder, deduce how the code works or better -still create new icons yourself and ask me to add them to the release. If you do the latter then the icons must be your -own for which you grant the same GPL licence as [Moodle](http://www.gnu.org/copyleft/gpl.html) or provide direct evidence -of the originator under the same licence. The icons must be 24x24 pixels with a transparent background. - -Known Issues -============ -1. If you get toggle text issues in languages other than English please ensure you have the latest version of Moodle installed. - More information on http://moodle.org/mod/forum/discuss.php?d=184150. -2. Importing a Moodle 1.9 course does not currently work, please see CONTRIB-3552 which depends on MDL-32205 - as - a workaround, please select the 'Topics' format first in 1.9, backup and restore then select the Collapsed Topics - course format in the course settings. You will have to reset your decisions on structure etc. -3. Sometimes when restoring a course, it is accessed for the first time and a toggle is clicked a 'Error updating user - preference 'topcoll_toggle_x'' (where 'x' is the course id as shown in the URL 'id=x') can occur. I'm not completely sure - why this is happening as the 'user_preference_allow_ajax_update' call in 'format.php' should establish that the user - preference can be set. Could be a page cache thing as the 'init' code is getting the course id unlike an issue I'm - currently experiencing with the MyMobile theme - MDL-33115. The work around is to refresh the page. Having altered some - of the event handing code to operate after page load, I'm hoping that this has now been resolved, please let me know - if you encounter it. - -Reporting Issues -================ -Before reporting an issue, please ensure that you are running the latest version for your release of Moodle. The primary -release area is located on https://moodle.org/plugins/view.php?plugin=format_topcoll. It is also essential that you are -operating the required version of Moodle as stated at the top - this is because the format relies on core functionality that -is out of its control. - -All Collapsed Topics does is integrate with the course page and control it's layout, therefore what may appear to be an issue -with the format is in fact to do with a theme or core component. Please be confident that it is an issue with Collapsed Topics -but if in doubt, ask. - -I operate a policy that we will fix all genuine issues for free (this only applies to the code as supplied from the sources listed -in 'Downloads and documentation' above. Any changes / improvements you make are not covered and invalidate this policy for all of -the code). Improvements are at my discretion. I am happy to make bespoke customisations / improvements for a negotiated fee. I -will endeavour to respond to all requests for support as quickly as possible, if you require a faster service then offering payment -for the service will expedite the response. - -When reporting an issue you can post in the course format's forum on Moodle.org (currently 'moodle.org/mod/forum/view.php?id=47'), -on Moodle tracker 'tracker.moodle.org' ensuring that you chose the 'Non-core contributed modules' and 'Course Format: Topcoll' -for the component or contact me direct (details at the bottom). - -It is essential that you provide as much information as possible, the critical information being the contents of the format's -version.php file. Other version information such as specific Moodle version, theme name and version also helps. A screen shot -can be really useful in visualising the issue along with any files you consider to be relevant. - -Version Information -=================== -Version 3.0.2 - 1. Code checker tidy up. - 2. ARIA button role: https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/ARIA_Techniques/Using_the_button_role but - still need to think about keyboard control. - 3. Add TravisCI support: https://docs.moodle.org/dev/Travis_Integration and https://github.com/moodlerooms/moodle-plugin-ci. - -Version 3.0.1 - 1. Fixed #22, Orphaned sections are not responsive. - 2. Stable version. - 3. Start of PHPUnit tests. - -Version 3.0.0.3 - 1. Fixed #18, Collapsed Topics Edit menu and MDL-42634-28, ref: https://github.com/gjb2048/moodle-format_topcoll/issues/18 - 2. Fixed slight issue with heading colour conflict and themes. - 3. Fixed #19, Drag and drop handle does not show when editing in RTL. - 4. Apply MDL-10405. - -Version 3.0.0.2 - 1. Added responsive theme support, now a new 'Format responsive' setting in Site Administration -> Plugins -> - Course Formats -> Collapsed Topics where you can turn on the old responsive behaviour that the format - provided if you don't have a responsive theme. - -Version 3.0.0.1 - 1. First 'beta' version for M3.0. - 2. Apply MDL-48947, MDL-51250 and MDL-51610. - -Version 2.9.1.5 - 1. Fixed 'Strict standards warning shown when using collapsed topics format' - CONTRIB-5974. - 2. Fixed iconset issue when editing the course settings. - 3. Fixed hidden content margins. - -Version 2.9.1.4 - 1. Fixed display of sections when 'Hidden sections' is set to 'Hidden sections are shown in collapsed form' and the - 'Structure' is one of 'Current topic first' or 'Current week first'. - 2. Language files tidy up. - 3. Fix left and right section information not being displayed in Bootstrap V3 themes. - 4. Improve RTL support by swapping left and right sides. - 5. Improve side widths in different languages by checking that the value retrieved is for the current language and - not the default English one by mistake so that the default value in the styles.css file is used in preference. - 6. Fix position of icon set icon in course settings 'Icon set' drop down. - 7. Fix missing ground signal icon in course settings 'Icon set' drop down. - 8. Change 'Configuration' setting 'What to do with the toggles when the user first accesses the course, adds more sections or - toggle peristence is off' to 'Initial toggle state' for clarity. - -Version 2.9.1.3 - 1. Removed MyMobile theme support as theme has passed away. - 2. Fix CONTRIB-5817. - 3. Update readme. - 4. Fix 'Edit quiz page displays oddly' - https://moodle.org/mod/forum/discuss.php?d=317476. - -Version 2.9.1.2. - 1. Fixed coding fault when restoring a course from backup file. - -Version 2.9.1.1. - 1. Fixed broken default for defaulttoggleiconsize - thanks to Davo Smith - issue #16. - -Version 2.9.1. - 1. First stable version for Moodle 2.9. - -Version 2.9.0.2. - 1. Added the capability to delete a section. - 2. Tidy up column padding after testing with Shoehorn. TODO: Decide if column padding is needed now. - 3. Removed out of date development test code. - 4. Removed out of date IE7 styles. - -Version 2.9.0.1. - 1. First 'release candidate' version for Moodle 2.9. - 2. Note: Need to seriously think about using AMD and transitioning to using jQuery instead of YUI as AJAX is possible in jQuery, - but almost certainly not in the first instance as YUI is still supported in core. Modularisation is do-able in AMD - with parameters required: https://docs.moodle.org/dev/Javascript_Modules. - -Version 2.8.2.3 - 1. Fixed logic flaw with section parameters on course URL's when using single page display. - -Version 2.8.2.2 - 1. Added print media styles. - 2. Version information to no longer have the date as will work better. - -27th January 2015 Version 2.8.2.1 - 1. Refix issue #4 - No block drag and drop icon when blockeditingmenu is false - activity editing menu no longer shows. - -23rd January 2015 Version 2.8.2 - 1. New 'Do not show date' feature gratefully funded by 'GAC Corporate Academy, GAC HQ, Dubai, UAE (http://www.gacacademy.com)'. - 2. Fix issue #14 - No block drag and drop icon when blockeditingmenu is false. - -11th December 2014 Version 2.8.1.1 - 1. New 'Show section summary when collapsed' feature gratefully funded by 'Te Rito Maioha Early Childhood New Zealand - https://ecnz.ac.nz'. - 2. Fix CONTRIB-5472. - 3. Integrated 'Use core required_param for toggle parameters.': https://github.com/gjb2048/moodle-format_topcoll/pull/12 - "This work was made possible through funding from Te Rito Maioha Early Childhood New Zealand". - Improves on work instigated in CONTRIB-5211 and related to MDL-46754. - 4. Improved HTTP protocol handling in 'settopcollpref.php'. - -16th November 2014 Version 2.8.1 - 1. Stable version for Moodle 2.8. - -10th November 2014 Version 2.8.0.1 - Release Candidate - 1. Release candidate for Moodle 2.8 - NOT for production servers. - -20th September 2014 Version 2.7.1.5 - 1. Fixed issue where a debug message was being written to the PHP error log. - 2. When toggle persistence is off then the state of the toggles on page load will depend on the default user preference setting. - 3. Added the ability to set the size of the toggle icon site wide as: Small = 16px, Medium = 24px and Large = 32px. - 4. Added the ability to set each corner of the toggle border radius site wide between 0.0 and 4.0em in increments of 0.1. - -19th August 2014 Version 2.7.1.4 - 1. Fixed issue #11: Moodle notice - https://github.com/gjb2048/moodle-format_topcoll/issues/11. - -18th August 2014 Version 2.7.1.3 - 1. Fixed a few typos. - 2. Fixed CONTRIB-5211: Section 5 does not remain expanded when browsing away and back. - -17th July 2014 Version 2.7.1.2 - 1. Slight tweak to css to tidy things up when editing. - 2. Patch for IE8(!!!) kindly supplied by Mathew Gancarz - https://moodle.org/user/profile.php?id=1471695. To fix an issue - where the activities / resources were still being displayed even after the toggle had closed. If you are still on IE8, - then please see this: http://www.microsoft.com/en-gb/security/pc-security/updates.aspx?linkId=8591289. - 3. Fixed being able to manipulate sections via left and right content areas on tablets. Thanks to Rick Jerz for reporting this - on https://moodle.org/mod/forum/discuss.php?d=263739. - -12th June 2014 Version 2.7.1.1 - 1. Fixed toggle name word break: https://moodle.org/mod/forum/discuss.php?d=261388. - 2. Added toggle foreground colour hover. - -20th May 2014 Version 2.7.1 - Stable. - 1. Stable release for M2.7. - 2. Fixed CONTRIB-5073 - invisible section causes an error with "topcoll" format. - -22nd April 2014 Version 2.7.0.1 - BETA - 1. First beta version for Moodle 2.7beta. - -17th April 2014 Version 2.6.1.5 - 1. Fixed CONTRIB-4099 with the arrangement of the editing icon and associated functionality such that a better solution is - applied for the specific nature of the format. - -28th March 2014 Version 2.6.1.4 - 1. Fixed slight issue with mobile / tablet display issue of toggle all and instructions. - 2. Fixed issue with Bootstrap 3 breaking the layout of hidden sections when >= 2 columns. - 3. Fixed hidden section when "Hidden sections are shown in collapsed form." mode breaks columns. - 4. Fixed slight mobile / tablet display issues as shown on https://moodle.org/mod/forum/discuss.php?d=256093. - 5. Optimised 'print_multiple_section_page' in 'renderer.php' by using a 'break' instead of a 'continue' when the number of - sections is exceeded. - -20th February 2014 Version 2.6.1.3 - 1. Refactoring for the 'Elegance' theme: https://github.com/moodleman/moodle-theme_elegance. - -16th January 2014 Version 2.6.1.2 - 1. Fixed Essential theme overriding toggle text colour - see: https://moodle.org/mod/forum/discuss.php?d=251951. - 2. Fixed bullet point styles - see: https://moodle.org/mod/forum/discuss.php?d=251944. - 3. Refactored 'print_single_section_page()' in 'renderer.php' to call parent version of method and thus reduce - code duplication and maintenance. - 4. Removed duplicate section title when editing. - -18th December 2013 Version 2.6.1.1 - 1. Fixed issue reported by Graham Woodsford whereby teachers could not create Collapsed Topics courses. This is because the - validation method 'edit_form_validation' in 'lib.php' was failing the values passed to it. These happened to be the - hidden label values from 'course_format_options' which were being used because the 'Course creator' role that teachers - have before becoming an 'editingteacher' role as defined in 'db/access.php' does not allow the teacher to have the - the 'format/topcoll:changelayout', 'format/topcoll:changecolour', 'format/topcoll:changetogglealignment' and - 'format/topcoll:changetoggleiconset' capabilities. This also implies that the values of the other settings are wrong, - which in fact they are, causing courses to be created (after fixing the colour settings for 'edit_form_validation') with - odd values and not the defaults resulting in no icon set etc. And therefore needing to go back to edit the course settings. - - Ok, this now leads on to a dilemma. Currently the course creator role does not have the CT capabilities listed above. If - they were added to 'access.php' then the role would have them (existing CT admins would have to add manually). Then the - teacher would see all the options when first creating a course as they do whilst editing. However, this means that if you - wish to restrict the teacher from changing things as is the purpose of the capabilities in the first place, then you have - to remove the capability in both the 'coursecreator' and 'editingteacher' roles. This is because by default 'coursecreator' - is above 'editingteacher' and once enrolled on the course after having created it, the teacher has both. This makes things - a bit complex and to be honest not that admin friendly. Therefore to keep things simple in what is in reality an event - that is rare, I have decided not to add the capabilities to the 'coursecreator' role. This is additionally based on the - presumed work-flow of a teacher where they create the course using the defaults, look at it and then decide what to change - in the settings. The fix as it stands will facilitate this. - -18th November 2013 Version 2.6.1 -Change by G J Barnard - 1. Fixed slight issue with lack of prefixing '#' for colour settings in default settings. - -14th November 2013 Version 2.6.0.1 - 1. Initial BETA code for Moodle 2.6. - -14th November 2013 Version 2.5.3.5 - 1. Changes for 'Accessibility' based upon MDL-41252. - 2. Fully implemented MDL-39542. - 3. Slight tweak to colour pop up code such that default settings courses don't have a prefixing '#'. - 4. Implemented validation on colours as an implied result of CONTRIB-4736. Thanks to Kirill Astashov for this. - 5. Fixed sections not being aligned at the top when more than one column and with a vertical column orientation. - 6. Fixed updating from Moodle 2.3 for existing courses issue - CONTRIB-4743. Thanks to Kirill Astashov for this. - -24th October 2013 Version 2.5.3.4 - 1. Fixed reset toggle instructions not working when only thing reset. - 2. Fixed reset logic as was updating course format options when should not have done even though there would have been no effect. - 3. Slight optimisation to 'renderer.php' for getting 'format_topcoll' object when already have it. - 4. Slight optimisation to getting the strings for the current section 'light bulb'. - -2nd October 2013 Version 2.5.3.3 - 1. Added: Bulb, Cloud, Eye, LED, Radio, Smiley, Square, Sun / Moon and Switch icon sets as a result of remembering about: - https://moodle.org/mod/forum/discuss.php?d=220142. - 2. Added instructions on how to use the toggles from a suggestion by Guido Rößling on Learn Moodle. - 3. Added setting to turn on (default) / off the instructions at the course and site default level with 'Reset' and 'Reset all' - capability. - 4. Worked out how to get the reset options on the course settings page in-line in groups. - -19th August 2013 Version 2.5.3.2 - 1. Fixed issue with the 'float: left' CSS style when used to ensure that the columns were displayed correctly in the - 'vertical' column orientation. The fix is to use 'display: inline-block' instead but this does not work in IE7, so as - it does in IE8+ and other browsers I'm going to have to go with it. Thanks to Ed Przyzycki for reporting this. - -27th July 2013 - Version 2.5.3.1 - 1. Fixed issue with dates being shown on section zero with temporal structures. Thanks to Michael Turico for reporting this. - -9th July 2013 - Version 2.5.3 - 1. Added the ability to set the position of the toggle as either left or right on a per course basis with - a default setting. You need the 'changelayout' capability to be able to set this. - 2. Gratefully crowd funded on Moodle Garage -> http://www.moodlegarage.com/projects/collapsed-topics-left-to-right/. - -26th June 2013 - Version 2.5.2.2 - 1. Fixed issue with 'Notice: String offset cast occurred in togglelib.php on line 68' when running on PHP 5.4. Thanks - to Halldór Kristjánsson (https://moodle.org/user/profile.php?id=1611408) for reporting this. - -24th June 2013 - Version 2.5.2.1 - 1. Fixed CONTRIB-4436 with a 'blocker' bug on V2.5.2 below with backups failing (do not ever install this version unless you - want to test your disaster recovery procedures). Thanks to Mike Turico for reporting it. Note to self and all, using html - tags in the 'get_section_name()' method in 'lib.php' will break backups and trash your database. - -23rd June 2013 - Version 2.5.2 - 1. Fixed issue with sections not showing their contents in editing mode when open all has been used, then they are individually - closed and reopened. Thanks to Marc Hermon for reporting this. - 2. Added small icon which shows up when updating. - 3. Ensure the correct arrow is used when not using JavaScript. - 4. Radically changed the toggle persistence storage mechanism to be based on a base 64 system using the following subset of ASCII: - ":;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxy". This is more efficient than the actual Base64 system of: - "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/" because there is no complex conversion from the character to - to the value it represents. I also decided not to include "01" as that makes detection of the old mechanism simple for upgrade - purposes. - This was done to support courses with sections greater than fifty two. Currently there is no upper limit bar what your machine - is capable of serving. The length of the toggle persistence data increases and decreases automatically in responce to the number - of sections. There are six sections per digit. - 5. Finally fixed having the 'toggle' word on toggles and not on the navigation menu with AJAX drag and drop working - CONTRIB-4403. - 6. Implemented MDL-33546. - 7. Fixed size of toggles altering when using AJAX drag and drop. - 8. Ran the code through the infamous 'Code Checker' version 2013060600, release 2.2.7 and cleared as much as possible. - 9. Note: Once you upgrade to this version and beyond then going back will mean loss of the user preferences as you will need to - remove all 'topcoll_toggle_x' rows from the 'user_preferences' table first. - -6th June 2013 Version 2.5.1.1 - 1. Implemented MDL-39764 to fix maxsections < numsections issue. - 2. Reversed the order of the history in this file for easy reading. - 3. Cleaned up some of the CSS. - 4. Changes to 'renderer.php' because of MDL-21097. - -14th May 2013 Version 2.5.1 - Stable - 1. First stable version for Moodle 2.5 stable. - -12th May 2013 - Version 2.5.0.6 - Beta - 1. Changes for MDL-39542. - -9th May 2013 - Version 2.5.0.5 - Beta - 1. Fixed coding fault with resetting introduced in capabilities change. - 2. Fixed coding fault with language string in layout settings. - -8th May 2013 - Version 2.5.0.4 - Beta - 1. Fixed "When in 'Show one section per page' mode and the column orientation is set to 'Horizontal' the sections on the main - page do not fill their correct width. This is due to the use of the 'section_summary()' method which needs to be changed - within the format to set the calculated width on the 'li' tag." because the core fix I submitted on MDL-39099 has now - been integrated. Thus requiring version 2013050200.00 2.5beta+ (Build: 20130502). - 2. Changed the layout descriptions to be more 'positive' in nature. Should be backwards compatible in terms of languages. From - a suggestion by Guido Hornig. - 3. Added automatic 'Purge all caches' when upgrading. If this appears not to work by lack of display etc. then perform a - manual 'Purge all caches' under 'Home -> Site administration -> Development -> Purge all caches'. - -29th April 2013 - Version 2.5.0.3 - Beta - 1. Fixed non-referenced member variable bug which showed up as 'undefined' but should have been a reference error in testing. - 2. Please perform a 'Purge all caches' under 'Home -> Site administration -> Development -> Purge all caches' when upgrading. - -27th April 2013 - Version 2.5.0.2 - Beta - 1. Thanks to ideas from Ben Kelada and help from Andrew Nicols / Tim Hunt, I have made the event handing toggle functions more efficient. - 2. Fixed an obscure bug with '$defaultuserpreference' in 'format.php' not being parsed to 'M.format_topcoll.init' in 'module.js'. - 3. Removed '.jumpmenu' from styles.css because of MDL-38907. - 4. Please perform a 'Purge all caches' under 'Home -> Site administration -> Development -> Purge all caches' when upgrading. - -12th April 2013 - Version 2.5.0.1 - Beta - 1. First 'Beta' release for Moodle 2.5 Beta. - 2. Note: Date in version file (2013041500) is greater than actual date code released publically to facilitate updates to Moodle 2.4 version. - 3. Please perform a 'Purge all caches' under 'Home -> Site administration -> Development -> Purge all caches' when upgrading. - -11th April 2013 - Version 2.4.4 - 1. Implemented the administrator setting for the format so that the default state of the toggles can be set to - 'all closed' or 'all opened' for new users. Thanks to Jamie Burgess (https://moodle.org/user/profile.php?id=1489185) for the idea. - 2. Realised that Tablets have more space, so allow two columns even when two or more are set. - 3. Please perform a 'Purge all caches' under 'Home -> Site administration -> Development -> Purge all caches' when upgrading. - -16th March 2013 - Version 2.4.3.1.1 - 1. Fixed toggle peristence issue caused by code checking the code and not realising the implications of '==='. - Thanks to Marc Hermon for reporting this. - 2. Implemented round toggle borders to reduce the harshness and integrate with jQueryMobile themes in line with Moodle 2.3 version. - 3. Please perform a 'Purge all caches' under 'Home -> Site administration -> Development -> Purge all caches' when upgrading. - -14th March 2013 - Version 2.4.3.1 - 1. Improved mobile and tablet theme detection and support. - 2. Added 'Downloads and documentation' to this readme to clarify the download locations. - 3. Cleaned JavaScript through use of http://jshint.com/. - 4. Added 'Previous versions and required version of Moodle' to this guide. - 5. Implemented MDL-37901. - 6. Implemented MDL-37976. - 7. Moved 'float: left' to styles.css for Henrik Thorn - CONTRIB-4198. - 8. Improvements for MDL-34917. - 9. Please perform a 'Purge all caches' under 'Home -> Site administration -> Development -> Purge all caches' when upgrading. - -8th February 2013 - Version 2.4.3 - 1. Taking inspiration from the IEC 5009 standard standby symbol as described on http://en.wikipedia.org/wiki/Power_symbol and a - suggestion with the + / - symbols by Ben Kelada on CONTRIB-4098. I have used the 'standby' concept as Moodle is on - and waiting for input. - 2. I created the icons in Paint.Net and are released under the same GPL licence as the rest of Collapsed Topics and indeed - Moodle. - 3. Implemented 'Icon sets' such that the user can choose what set of icons they wish to use without complex code changes. I am - hoping that this will spark more 'sets' to incorporated in the main release from users. - 4. Added the ability to control if the toggle all icons will change when hovered over, for Rick Jerz. - 5. Moved all 'tcconfig.php' default functionalty to 'Site Administration -> Plugins -> Course formats -> Collapsed Topics' - so that defaults can be changed by the administrator from within Moodle without resorting to code changes. - 6. Added capabilities 'format/topcoll:changelayout', 'format/topcoll:changecolour', 'format/topcoll:changetogglealignment' - and 'format/topcoll:changetoggleiconset' to editing teachers and managers such that site administrators can choose to - disable functionality through roles if they wish. In order for this to work the version number must be updated. - 7. Code cleaned with ['code-checker'](https://moodle.org/plugins/view.php?plugin=local_codechecker) - not finished yet - - no functional changes. - 8. Added toggle icons to the selection boxes of the edit settings and plugin settings. Does not work with Chrome - known - browser issue. - 9. Changed this readme to ['Markdown' format](http://en.wikipedia.org/wiki/Markdown). - 10. Please perform a 'Purge all caches' under 'Home -> Site administration -> Development -> Purge all caches'. - -23rd January 2013 - Version 2.4.2.1 - 1. Further tweaks for toggle line height and to make work in IE9 with and without IE7 mode. - 2. Please perform a 'Purge all caches' under 'Home -> Site administration -> Development -> Purge all caches' when upgrading. - -22nd January 2013 - Version 2.4.2 - 1. Added ability to control the orientation of columns when more than one is used. You can now choose between - having the sections number down the page (vertical) or left to right (horizontal). Default is horizontal. This - is from a suggestion on CONTRIB-4098 by Michele Turre. The MyMobile theme only uses one column regardless of the number - of columns setting. - 2. Fixed section number not updating in the left part of a section when using AJAX drag and drop moving. - 3. Implemented and adjusted CSS for CONTRIB-4106 to have consistent section name styles. - 4. Tweaked no JavaScript operation such that the 'Toggle all' functionality is hidden. - 5. Implemented removal of css float for MyMobile theme for CONTRIB-4108. - 6. Fixed issue with JavaScript in 'module.js' breaking with 0 or 1 sections causing the 'Add an activity or resource' to fail. - 7. Changes to 'renderer.php' because of MDL-36095 hence requiring Moodle version 2012120301.02 release 2.4.1+ (Build: 20130118) - and above. - 8. Tweaked for the MyMobile theme but point '2' on 'Known issues' still occurring - any help appreciated. - 9. Please perform a 'Purge all caches' under 'Home -> Site administration -> Development -> Purge all caches' when upgrading. - -11th January 2013 - Version 2.4.1.7 - Further improvements inspired by CONTRIB-4098. - 1. Changed 'Latest Week' to 'Current Week' to be less confusing. - 2. Added 'Reporting Issues' to this file. - 3. Please perform a 'Purge all caches' under 'Home -> Site administration -> Development -> Purge all caches' when upgrading. - -10th January 2013 - Version 2.4.1.6 - Improvements inspired by CONTRIB-4098 - Thanks to Michele Turre and Rick Jerz. - 1. Changed the direction of the up arrow in line with the navigation block. - 2. Refactored the global constant structure in tcconfig.php to be a class with constants, thus removing the 'globalness'. - 3. Added ability to determine the alignment of the toggle text, left, centre or right. - 4. Fixed version year which was still stuck at 2012 - please ensure you use this version when upgrading rather than - a previous 2013 release. - 5. If upgrading, please perform a 'Purge all caches' under 'Home -> Site administration -> Development -> Purge all caches'. - -5th January 2013 - Version 2.4.1.5 - 1. In applying versions 2.4.1.2 and 2.4.1.4 to the Moodle 2.3 version I considered that when a section had - a name that the date should be after and not before. Thereby being more aesthetically pleasing. - -3rd January 2013 - Version 2.4.1.4 - 1. Fixed unexpected issue when the number of sections is '0'. Thanks to 'Aylwin Cal' for reporting this. - -2nd January 2013 - Version 2.4.1.3 - 1. Fixed unexpected issue with changes made to 'get_section_name()' in lib.php in version 2.4.1.2 caused - course backup to fail. This was due to the inclusion of a 'br' tag to make the section name and date - look effective. I have refactored to apply the 'br' tag formatting in renderer.php instead. The - down side of this being the navigation window does not contain the date when a section name is set. - Apart from doing a lot of string splitting in renderer.php to insert the 'br' tag in the right place, - there is no other way of solving this - and I consider for efficiency and clutter that the date should - be omitted in this circumstance. - -31st December 2012 - Version 2.4.1.2 - 1. Fixed missing date text in week / day based structures that were in 2.2 versions and below. Thanks - to Michael Turico for informing me of this. - 2. Moved edit section icon to the right of the toggle as it was not click-able on the toggle itself. - 3. Changed format.js to have better results when moving sections - I hope. - -19th December 2012 - Version 2.4.1.1 - 1. Minor refactor to remove redundant parameter on 'section_nav_selection()' in 'renderer.php'. - -17th December 2012 - Version 2.4.1 - Stable - 1. Tested completely fix for CONTRIB-4065. - 2. Re-factored to remove global '$tcsettings' and place in 'lib.php' so code is more OO. - 3. Code now considered stable. - -12th December 2012 - Version 2.4.0.6 - Beta - Do not install on production sites. - 1. Fix for CONTRIB-4065. - -8th December 2012 - Version 2.4.0.5 - Beta - Do not install on production sites. - 1. Changes for CONTRIB-4018 so that the toggles are not click-able until after the page has loaded, thus - preventing JavaScript errors during page load. - 2. If upgrading, please perform a 'Purge all caches' under 'Home -> Site administration -> Development -> Purge all caches'. - 3. Ensure the toggle word is not appended to section zero. - -4th December 2012 - Version 2.4.0.4 - Beta - Do not install on production sites. - 1. Adjusted logic of optional postfixed 'Toggle' word because of 'drag and drop section name' issue. - 2. Moved reset code to custom group box on course editing form thanks to Marina Glancy on MDL-35218. - 3. Added the course display option as a default in 'tcconfig.php' so that all new CT courses are set to this value. - 4. Reset now incorporates the course display option to put it back to the default. - 5. Removed old reset form, icon and CSS. - -3rd December 2012 - Version 2.4.0.3 - Beta - Do not install on production sites. - 1. Fixed drag and drop section name issue. - 2. Implemented a few suggestions by Marina Glancy on MDL-35218. - 3. Updated required version to first stable release. - -1st December 2012 - Version 2.4.0.2 - Beta - Do not install on production sites. - 1. Beta version for Moodle 2.4 with one new known issue 'When moving sections around in editing mode the toggle name - and section summary do not update until page refresh.' - 2. Do not install on a production site. - 3. Feedback appreciated though the course format forum (https://moodle.org/mod/forum/view.php?id=47) or - Moodle messaging (moodle.org/user/profile.php?id=442195). - 4. Using the colour picker for the toggle colours no longer requires a prefixing hash for the hexadecimal number. - 5. Three new language strings added: 'numbersections', 'ctreset' and 'ctreset_help' to the English file, others to follow. - 6. I have tested using Zend Server 5.6.0 Community Edition (MySQL DB) on Windows 7 with Chrome 23.0.1271.95: - - Upgrading from Moodle 2.2 and 2.3. - - Restoring 2.2 and 2.3 courses. - - Resetting to defaults for the 'current course' and 'all courses' as an administrator. - - Course backup and restore. - - Toggle persistence on and off. - - AJAX section move (with section name & summary caveat). - - Course layout and colour settings. - - Deleting the course. - - Moving from the 'topics' format. - - One section per page setting. - - Invalid number of columns in the database, both low and high. - However, this is not exhaustive, therefore if you are able to test on different environments and upgrades - from older versions of Moodle, then that would be helpful. - 7. I am currently deliberating on the issues raised on [CONTRIB-4018](http://tracker.moodle.org/browse/CONTRIB-4018) which - apply to this version too. If you have any thoughts / solutions, please comment on the tracker, thank you. - -2nd August 2012+ - Version 2.4.0.1 - Do not install on production sites. - 1. Development for Moodle 2.4. - 2. Major changes for course formats refactoring - MDL-35218 - mainly to do with moving the settings into the course - settings. - -9th November 2012 - Version 2.3.9.3 - 1. Fixed issue with wrong text colour being used for the current right section text. Had to use 'left' side selector - for getting the correct text colour on the right for the current section. This is because the selector - '.course-content .current .left' defines the colour in the theme and therefore any CT specific 'right' implementation - would not work for all themes. - 2. Tweaked CSS for 'Anomaly', 'Afterburner', 'MyMobile' and 'Rocket' themes. - -23rd October 2012 - Version 2.3.9.2 - 1. Fixed issue with wrong colour being used for current section background. - Thanks to [Rick Jerz](https://moodle.org/user/profile.php?id=520965) for reporting this. - -18th October 2012 - Version 2.3.9.1 - 1. Fixed potential issue when the course is first accessed and there is no user preference. - 2. Identified that sometimes when restoring a course, it is accessed for the first time and a toggle is clicked a 'Error - updating user preference 'topcoll_toggle_x'' (where 'x' is the course id as shown in the URL 'id=x') can occur. I'm not - completely sure why this is happening as the 'user_preference_allow_ajax_update' call in 'format.php' should establish that - the user preference can be set. Could be a page cache thing as the 'init' code is getting the course id unlike an issue - I'm currently experiencing with the MyMobile theme - MDL-33115. The work around is to refresh the page. - -17th October 2012 - Version 2.3.9 - 1. Idea posed on https://moodle.org/mod/forum/discuss.php?d=213138 (implemented in 2.3.2 first as it is currently the main - development branch), led to the thought that the code could now be optimised to set the toggle state at the server end as - that is where the persistence is now stored. So to speed things up this version should reduce page load times by about 0.4 - of a second. This has been achieved by setting the state of the toggle when writing out the HTML at the server end instead - of making all toggles initially closed and then getting the client side JavaScript to open them as required. Until the - move to server side persistence this would not have been possible. - -7th October 2012 - Version 2.3.8.2 1. Changes to 'renderer.php' because of MDL-31976 and MDL-35276 - thus requiring - Moodle 2.3.2+, version 2012062502.05 (Build: 20121005). - -10th September 2012 - Version 2.3.8.1 - 1. Fixed 'Warning: Illegal string offset 'defaultblocks' in ...\topcoll\config.php on line 39' issue when - operating with developer level debugging messages under PHP 5.4.3. This was due to 'config.php's inclusion in 'lib.php' - with a 'require_once' function call. Somehow Moodle core must include this file in another way. Therefore collapsed - topics specific settings have been placed in a new file 'tcconfig.php' and all files changed to reflect this. - Thanks to [Paul Nijbakker](http://moodle.org/user/profile.php?id=10036) for spotting this issue. - -3rd September 2012 - Version 2.3.8 - 1. Changes to 'renderer.php' because of MDL-28207 - thus requiring Moodle 2.3.1 2012062501.09 (Build: 20120809). - 2. Implemented MDL-34798 which I reported for AJAX section moving. - 3. Integrated CONTRIB-3827 to fix proliferation of CSS styles across other course formats. - 4. Change to 'format.php' because of MDL-34829. - 5. Sorted wording of 'light bulb' when editing. - 6. Integrated CONTRIB-3825 to fix upgrade issue when converting a non-MySQL the database. - 7. Implemented MDL-34858 which I reported as a section zero default name issue. - 8. Implemented MDL-34917 which I reported as an improvement. Code is slightly different, feedback appreciated. - 9. Make toggle titles bold and change 'all toggles' to 'all sections', from comments made on MDL-35048. - 10. Cherry picked Luiggi's change - https://github.com/luiggisanso/moodle-format_topcoll/commit/9bd818f5a4efb347aef4f5154ea2930526552bfc - 11. Figured out how to use 'pix:' for URL's in css for the format, so have changed so that the images are now controlled by css classes. This - means that it is now possible to override them in your theme in css. The following is the selectors for the various images, override - the 'background' attribute: - - `body.jsenabled .course-content ul.ctopics li.section .content .toggle a.toggle_open` - For the 'up' arrow in the toggle - original is 24px. - `body.jsenabled .course-content ul.ctopics li.section .content .toggle a.toggle_closed` - For the 'down' arrow in the toggle - original is 24px. - `.course-content ul.ctopics li.section .content .toggle a.toggle_closed` - For the 'up' arrow in the toggle when JavaScript is disabled and the toggles default to open. - `#toggle-all .content .sectionbody h4 a.on` - For the 'open all sections' image - original is 24px. - `#toggle-all .content .sectionbody h4 a.off` - For the 'closed all sections' image - original is 24px. - `#tc-set-settings` - For the 'settings' image. - - If in doubt, please consult 'styles.css' in the format. - 12. Checked operation in 'MyMobile' theme, all seems good except bottom left and right navigation links in 'One section per - page' mode. HTML is identical to that of 'Topics' format bar difference classes higher up the document object model to - distinguish 'Collapsed Topics' from 'Topics'. Hopefully will be resolved when MDL-33115 implemented. - -1st August 2012 - Version 2.3.7.2 - 1. Changes to 'renderer.php' because of MDL-33767. - 2. Tidied up some of the logic in 'renderer.php'. - 3. Made 'format.php' more adaptable to old style section 'x' only urls. - 4. Made inclusion of 'config.php' in 'lib.php' more precise. - 5. Removed 'callback_topcoll_get_section_url' in 'lib.php' because it is no longer required by - 'load_generic_course_sections' in '/lib/navigationlib.php'. - 6. Added 'currentsection' string to '/lang/en/format_topcoll.php' - thanks to [Carlos Kiyan Tsunami](http://moodle.org/mod/forum/discuss.php?d=208066). - 7. Shrunk the settings icon to 75% of the original size so that it is not so 'in your face' and added - instructions on the left. The instructions are in the 'en' langauge file as the 'formatsettingsinformation' - string for translation. - -11th July 2012 - Version 2.3.7.1 - 1. Updated french lanugage file thanks to Luiggi Sansonetti. - 2. Fixed an issue with section zero summary not showing - thanks [Chris Adams](http://moodle.org/mod/forum/discuss.php?d=206423) - 3. Attempted automated upgrade in 'upgrade.php' to cope with issues users are experiencing. Altered upgrade from - Moodle 1.9, 2.0, 2.1 and 2.2 instructions to reflect this. Version control for older versions less than Moodle 2.3 - needs to follow a 'branching date' strategy for this to work properly - - http://moodle.org/mod/forum/discuss.php?d=206647#p901061. This was sparked by CONTRIB-3765. - 4. Tidied up and clarified the instructions for upgrading. - -3rd July 2012 - Version 2.3.7 Stable - Completion of CONTRIB-3652 development - rewrite for Moodle 2.3. - 1. Test and tidy up code. - 2. Placed check and correction for columns out of range 1-4 in renderer.php. - 3. Cope with backups from Moodle 2.0, 2.1 and 2.2. - 4. Cope when sections are not shown in column calculations. - 5. Test with MyMobile to understand underlying issue. - -29th June 2012 - Version 2.3.7rc5 - CONTRIB-3652 development - rewrite for Moodle 2.3 - 1. Test and tidy up code. - -28th June 2012 - Version 2.3.7rc4 - CONTRIB-3652 development - rewrite for Moodle 2.3 - 1. Corrected an issue in 'renderer.php' for the overridden method 'print_multiple_section_page()' so that section 0 has a name - displayed if there is one - see http://moodle.org/mod/forum/discuss.php?d=205724. - 2. Ensured that only one column is present when using the MyMobile theme regardless of setting. - 3. Made work to a greater extent with the MyMobile theme - not quite as the theme intends as all changes within CT. - 4. Tidied up left and right sides to be language specific when not editing for variations in the words 'Topic' and 'Week'. - 5. Optimised open and close all toggles such that persistence is now only one AJAX call to update the user preferences instead - of one per section. - -27th June 2012 - Version 2.3.7rc3 - CONTRIB-3652 development - rewrite for Moodle 2.3 - 1. Put layout columns into backup and restore code. - 2. Tidy up instructions in this readme. - 3. A few slight alterations for the MyMobile theme - MDL-33115. - -26th June 2012 - Version 2.3.7rc2 - CONTRIB-3652 development - rewrite for Moodle 2.3 - 1. Removed line that was related to the cookie functionality - thanks Hartmut Scherer and Kyle Smith on - http://moodle.org/mod/forum/discuss.php?d=204705. - 2. Removed cookie consent code from lib.php. - 3. To keep things clean for what will be a fresh install for all I have decided to remove the update code in update.php, - so if you have previously installed a beta version please kindly follow step 4 of the 'Uninstallation Instructions' above - after updating your code but before clicking on 'Notifications' to 'upgrade'. - 4. Request from Kyle Smith to implement the functionality of being able to reset to defaults for all Collapsed Topics courses. - I have made this for 'admins' only. - 5. Added in multi-column functionality as a layout setting. Default in config.php. Can have one to four columns. - -24th June 2012 - Version 2.3.7rc - CONTRIB-3652 development - rewrite for Moodle 2.3 - 1. Removed cookie functionality in favour of user preferences via AJAX - see MDL-17084. - 2. Updated instructions above to reflect changes. - 3. Tidied up code and removed redundant files in this branch. - -12th June 2012 - Version 2.3.7beta - CONTRIB-3652 development - rewrite for Moodle 2.3 - 1. Completed bulk of code development, now 'Beta' version for testing. - -3rd June 2012 - Version 2.3.7dev - CONTRIB-3652 development - rewrite for Moodle 2.3 - 1. Started rewrite of Collapsed Topics for Moodle 2.3 as course formats now use a completely new renderer system introduced - in MDL-32508. - 2. This branch now in 'Alpha' for stability as existing code does not work and reapplying old code in a progressive manner. - -31st May 2012 - Version 2.3.6.3 - CONTRIB-3682 - 1. Fixed issue with students not being able to perform cookie consent because of incorrect application of requiring the - capability of course update. - 2. Code change done in line with other versions but format not working with development version. - -20th May 2012 - Version 2.3.6.2.1 - CONTRIB-3655 - 1. Changes in module.js for MyMobile theme. - -14th May 2012 - Version 2.3.6.2 - 1. Fixed slight issue with version number causing 'Site Administration -> Plugins -> Plugin Overview' to fail, please - see 'http://moodle.org/mod/forum/discuss.php?d=202578'. - -3rd May 2012 - Version 2.3.6.1 - 1. Reverted back to unsigned data types in database due to error with MSSQL database code probably in core, but not essential - change at this point in time - see http://moodle.org/mod/forum/discuss.php?d=201460. - 2. Updated French translation thanks to Luiggi Sansonetti. - -1st May 2012 - Version 2.3.6 - CONTRIB-3624 - 1. Implemented code to facilitate the ability to confirm with the user that it is ok to place the cookie 'mdl_cf_topcoll' on - their computer. This fucntionality can be switched on / off through the changing of `$TCCFG->defaultcookieconsent` in the - format's 'config.php'. This functionality exists because I believe that the cookie is a 'Category 3' cookie in line with - the forthcoming UK EU Cookie Law - please see 'UK / EU Cookie Law' at the top of this file. - 2. Fixed - Changing the language on the 'Settings' form produces an invalid Moodle URL. - 3. Fixed - Toggles are open and sections displayed when JavaScript is turned off in the user's browser. - 4. A few fixes to changes made in version 2.2.5 where I had renamed table 'format_topcoll_layout' to 'format_topcoll_settings' - in the code. - 5. Created a `$TCCFG` object in the 'config.php' file to solve the 'globals' issue in 'lib.php'. - -26th April 2012 - Version 2.3.5 - CONTRIB-3529 - As suggested by [Leonie Vos](http://moodle.org/user/profile.php?id=1435066). - 1. Added the ability to set the colour attributes of the toggle. - 2. Added the ability to reset the layout and colour attributes back to the defaults as defined in the 'config.php' file. - 3. Thank you to 'Nadav Kavalerchik' for pointing out on MDL-23320 how this can be done by modifying the colour picker code - implemented by 'Iain Checkland' in his Quick Structure block - 'https://github.com/drcheckers/moodle-block_quickstructure/tree/master/blocks/quickstructure', and to 'Matthew Cannings' - on MDL-23320 for the colour validation rule. - 4. Moved JavaScript code into its own folder 'js' for neatness. - 5. Renamed 'format_topcoll_layout' table to 'format_topcoll_settings' so that it is a better representation of what it - stores. Restores from previous versions should work. Raised MDL-32650 as cannot rename the comment for the renamed - table in upgrading installations. - 6. Added an American English translation (en_us) because of the incorporation of the word 'colour'. More information on - 'http://en.wikipedia.org/wiki/American_and_British_English_spelling_differences'. I may have not got everything correct! - 7. Added an English Pirate translation (en_ar) upon discovery of the 'Pirate' treasure language pack mee hearties :). - 8. Additional language strings have been placed in the language files, where I have been unable to translate them they are in - English, if you are able to translate them into your own language I would appreciate the translation, please contact me - via Moodle - http://moodle.org/user/profile.php?id=442195. - 9. Minor tweaks to format.php for showing the correct wording over icons when in a 'weeks' structure. - 10. Discovered a minor issue with hovering over the light bulb when in a week based structure and using AJAX that it describes - 'topics' and not 'weeks', raised a point on MDL-31052 for this. Not sure how to fix yet as it is in the initialisation - code of 'section_classes.js' and overloading does not seem to work. - -21st March 2012 - Version 2.3.4.2 - 1. Received an updated version of 'format_topcoll.php' from Luiggi Sansonetti for the French translation - Merci :). - -17th March 2012 - Version 2.3.4.1 - 1. Tried with restorelib.php in the root folder for importing Moodle 1.9 courses and did not work. So for tidiness, moved the - Moodle 1.9 backup and restore code to backup/moodle1 folder. - 2. So please note that restoring Moodle 1.9 courses in this course format will not retain the structure settings and will - default to the values in 'config.php'. I hope to investigate and either fix or have this fixed. - 3. Release '2012030100.02' of Moodle 2.3dev converted all tables to have signed integers in the function - 'upgrade_mysql_fix_unsigned_columns()' in '/lib/db/upgradelib.php' called from 'upgrade.php' in the same folder. This - included 'format_topcoll_layout' because of the code was written. This made it very difficult for me to create an - effective upgrade in my own 'upgrade.php' because I would be converting what had already been converted if the format was - installed and you were updating Moodle 2.3dev but if you install for the first time, the code has been written as such to - have signed fields. Therefore if you have previously installed this format for Moodle 2.3, please remove the table - 'format_topcoll_layout' from your database before upgrading. This is not quite brilliant, but I consider reasonable for - this development version at this stage. - 4. Implemented the change in 'format.php' introduced by MDL-31255, therefore you now require Moodle 2.3 version - '2012031500.00'. - -15th March 2012 - Version 2.3.4 - CONTRIB-3520 - Stable. - 1. Completed files for 1.9 and placed in the root folder of the format in the hope that they are executed by the upgrade - restoring code as they are in the Moodle 1.9 version of this issue. I think it is a Moodle core coding issue that they are - not called in Moodle 2.x+ when importing a Moodle 1.9 course backup - need to investigate. - 2. Translated the words 'Topic' and 'Week' in all language files so that the toggle bar is correct in all structures. If you - are a native speaker I would appreciate translation of the rest as Google Translate is not so good with long sentences. - 3. Added backup and restore instructions to this file. - -14th March 2012 - Version 2.3.4 - BETA - CONTRIB-3520. - 1. Added backup and restore functionality. If required when restoring a course 'Overwrite course configuration' needs to be - 'Yes' to set the structure and elements correctly. - 2. Added the function 'format_topcoll_delete_course' in 'lib.php' which will remove the entry in the 'format_topcoll_layout' - table for the course when it is deleted. - 3. Added language strings to the language files that were missing previous changes. Still in English at the moment in the - hope a native speaker will translate them for me. I intend to translate the basics like 'Topic' and 'Week' though before - release in line with what was already there. - -2nd March 2012 - Version 2.3.3.1 - 1. Minor fix to ensure consistent use of $coursecontext and not $context. - -29th February 2012 - Version 2.3.3 - Release Candidate 4 - 1. Updated Spanish language files thanks to Carlos Sánchez Martín. - 2. Added setting default layout and structure to installation instructions. - 3. Decided to have '$formcourselayoutstrutures' out of config.php to prevent possible future user error. - 4. Spotted a minor issue with changing language whilst on the 'Set Layout' form. Added to known issues as very minor and rare - as almost certainly the user will not have changed language on this form but would have done so beforehand. - 5. Fixed duplicate entry issue in 'course_sections' table when the default structure is 'Current Topic First' and a new course - is created. - -1st March 2012 - Version 2.3.3 - Stable - 1. Integrated Git Branch CONTRIB-3378 into stable branch master. - 2. NOTE: If you have previously installed a Beta or Release Candidate please drop the table 'format_topcoll_layout' before use. - 3. Removed redundant lib.js and lib_min.js in this branch. - -28th February 2012 - Version 2.3.3 - Release Candidate 3 - 1. Tidied up 'module.js' to be more efficient in using the YUI instance given. - 2. Updated installation and toggle state instructions. - 3. Added uninstall procedure in the unlikely event that you need it. - -28th February 2012 - Version 2.3.3 - Release Candidate 2 - 1. Added 'Current Topic First' as a new structure as suggested by ['Hartmut Scherer'] - (http://moodle.org/user/view.php?id=441502) on discussion 'Collapsed Topics with Custom Layouts' - (http://moodle.org/mod/forum/discuss.php?d=195292). - 2. Fixed an issue in moving to js_init_call() in RC 1 and then followed the - ['JavaScript guidelines'](http://docs.moodle.org/dev/JavaScript_guidelines) and - ['How to include javascript file in a new course format?'](http://moodle.org/mod/forum/discuss.php?d=169124) - to understand how to transition to using 'module.js' correctly. Still going to include 'tc_section_classes_min.js' - using the old way until I can figure out how to do this the new way. - 3. 'lib.js' and 'lib_min.js' will remain for reference until I backport the code to the Moodle 1.9 version which does not - follow the changes in '2' and work out how to merge in Git and not have those files removed in that branch. - 4. In 'Show only section x' mode the 'Open / Close all toggles' option is not shown as not really appropriate. - 5. Topic structure now opens current section by default in the same way as the weekly ones. - 6. Changed name of 'Latest First' to 'Latest Week First' to be clearer. - -NOTE: If uninstallation fails, drop the table 'format_topcoll_layout' and the entry for 'format_topcoll' in the table - 'config_plugins' where tables are with the prefix you use, the default being 'mdl_'. Then delete the installation folder - and replace with the current stable version. - -25th February 2012 - Version 2.3.3 - Release Candidate 1 - 1. Added help information to the drop down options on the set layout form. - 2. Tidied up to be consistent and use less words where required. - 3. In format.php changed from depreciated `js_function_call()` to `js_init_call()`. - 4. If you have previously installed a beta version you will need to drop the table 'format_topcoll_layout' in the database. - 5. If you are a native speaker of a language other than English, I would be grateful of a translation of the new language - strings in 'lang/en/format_topcoll.php' under the comment 'Layout enhancement - Moodle Tracker CONTRIB-3378'. Please - message me using the details in my Moodle profile 'http://moodle.org/user/profile.php?id=442195'. - -18th February 2012 - Version 2.3.3 - BETA 8 - 1. CONTRIB-3225 - Added screen reader capability using 'h3' tags, the same as the standard Topics format. - -15th February 2012 - Version 2.3.3 - BETA 7 - 1. Added strings for MDL-26105 in format_topcoll.php. - 2. Used non-depreciated 'create_table' method in 'upgrade.php'. - 3. Finally worked out how to ensure that the 'Settings Block' displays the course and not front page administration by using - `require_login($course)`. - -12th February 2012 - Version 2.3.3 - BETA 6 - 1. Fixed CONTRIB-3283 in lib.js (and hence lib_min.js) for when you are in display only 'Section x' mode and the number of - sections is reduced, you go back to the course with a section number for you in the database that no longer exists and the - 'Jump to...' drop down box does not work. Leading to having to change the database or the value of 'ctopics' in the URL to - that of a valid one. - 2. Added 'callback_topcoll_get_section_url' in 'lib.php' for MDL-26477. - 3. Corrected slight mistake with version number. - -11th February 2012 - Version 2.3.3 - BETA 5 - 1. Implemented the capability to have different 'structures' thereby encapsulating the 'Collapsed Weeks' and 'Latest First' - formats into this one. - 2. If you have previously installed this development, you need to drop the table 'format_topcoll_layout' in your database to - upgrade as I do not wish to have a complicated upgrade.php in the db folder at this stage whilst development continues. - 3. As a consequence of some changes, the Spanish translation now needs fixing, sorry Carlos. - -8th February 2012 - Version 2.3.3 - BETA 4 - 1. A big thank you to [Andrew Nicols](http://moodle.org/user/view.php?id=268794) for his contribution on the developer forum - http://moodle.org/mod/forum/discuss.php?d=195293. - 2. Implemented the fixes and suggestions to tidy up the code as specified by Andrew above. - 3. Implemented Spanish translations thanks to [Carlos Sánchez Martín](http://moodle.org/user/profile.php?id=743362). - -5th February 2012 - Version 2.3.3 - BETA 3 - 1. A big thank you to [Carlos Sánchez Martín](http://moodle.org/user/profile.php?id=743362) spotting issues in set_layout.php. - 2. Fixed issues in set_layout.php. - 3. Tidied up code to remove debug statements and development code. - 4. Created icon for setting the layout instead of words. - 5. Made strings in the English language file for the layout options and 'Set layout format'. Others to follow. - 6. Raised CONTRIB-3378 to document the development. - -4th February 2012 - Version 2.3.3 - BETA 2 - 1. A big thank you to [Carlos Sánchez Martín](http://moodle.org/user/profile.php?id=743362) for his help in discovering the - install.xml bug. - 2. Fixed issue with install.xml file, gained knowledge on uninstallation for the note below: - -2nd February 2012 - Version 2.3.3 - BETA - 1. Added capability for layouts with persistence in the database. - -23rd January 2012 - Version 2.3.2 - 1. Sorted out UTF-8 BOM issue, see MDL-31343. - 2. Added Russian translation, thanks to [Pavel Evgenjevich Timoshenko](http://moodle.org/user/profile.php?id=1322784). - -9th January 2012 - Version 2.3.1.1.2 - 1. Corrected licence to be correct one used by Moodle Plugins - thanks to {Tim Hunt](http://moodle.org/user/profile.php?id=93821). - -3rd January 2012 - Version 2.3.1.1.1 - Moodle Tracker MDL-30632 - 1. Use consistent edit section icon. - -9th December 2011 - Version 2.3.1.1 - Moodle Tracker CONTRIB-3295 - 1. Fixed issue of the web browser miscaluating the width of the content in 'editing' mode so that the sections - are less than 100%. - -8th December 2011 - Version 2.2.1 - Moodle Tracker CONTRIB-2497 - 1. Updated Brazilian translation thanks to [Tarcísio Nunes](http://moodle.org/user/profile.php?id=1149633). - 2. Changed version to relate to Moodle version, so this is for Moodle 2.2. - -11th October 2011 - Version 1.3.1 - Branched from Moodle 2.0.x version. - 1. Updated version.php to be fully populated. - 2. MDL-29188 - Formatting of section name. Causing Moodle 2.1.x branch of Collapsed Topics. - -6th October 2011 - Version 1.3 - Moodle Tracker CONTRIB-2975, CONTRIB-3189 and CONTRIB-3190. - 1. CONTRIB-2975 - AJAX support reinstated after working out a way of swapping the content as well as the toggle. Solution - sparked off by [Amanda Doughty](http://tracker.moodle.org/secure/ViewProfile.jspa?name=amanda.doughty). - 2. CONTRIB-3189 - Reported by Benn Cass that text in IE8- does not hide when the toggle is closed, solution suggested - by [Mark Ward](http://moodle.org/user/profile.php?id=489101) - please see - http://moodle.org/mod/forum/discuss.php?d=183875. - 3. CONTRIB-3190 - In realising that to make CONTRIB-2975 easier to use I suggested 'Toggle all' functionality and the - community said it was a good idea with no negative comments, please see - http://moodle.org/mod/forum/discuss.php?d=176806. - -9th June 2011 - Version 1.2.3 - Moodle Tracker CONTRIB-2975 - Unfinished. - 1. AJAX support temporarily withdrawn due to issue with moving sections and the toggle title not following. - Complex to resolve. - -30th May 2011 - Version 1.2.2 - Moodle Tracker CONTRIB-2963 - 1. Added in copyright and contact information. - -12th May 2011 - Version 1.2.1 - Fixed typo with this readme in expiring cookie duration example. - -9th May 2011 - Version 1.2 - Moodle Tracker CONTRIB-2925 - 1. Convert all language files to UTF-8 encoding. - -12th March 2011 - Version 1.1 - Moodle Tracker CONTRIB-2747 - 1. Make the toggle state last beyond the user session if desired. - 2. Changes made for MDL-25927 & MDL-23939. - 3. Because of 'displaysection' logic issue introduced with MDL-23939, I've decided to allow the showing of a single topic - regardless of being in editing mode or not. I think that the improved functionality of showing the topic fully when in - 'single topic' mode will be fine. - -Released Moodle 2.0 version. Treat as completed and out of development. -25th November 2010 - CONTRIB-1471 - Changes as follows: - 1. As Moodle 2.0 was released on the 24th November now using lib_min.js. - 2. Tidied up and removed any development code / styles that was not being used. - 3. Sorted out topic spacing for Internet Explorer 7 and below. This also has the side effect bonus of not allowing - section content to appear above the toggle when the toggle is open and closed with the mouse - reload is not affected. - This only affects Internet Explorer 7-, other web browsers work as expected. - 4. Removed   when no summary as putting in spacing that was pointless and made the section look odd. - 5. Removed redundant $timenow = time() line as not used. Strangely this is in the topic format's format.php - MDL-25417 raised. - -20th November 2010 - CONTRIB-1471 - Changes as follows: - 1. In format.php added completionlib.php include as a result of MDL-24698. - 2. In lib.php fixed non-functioning code added as a result of MDL-22647 which means that the navigation block will - correctly display the right wording for the section names: 'General' for section 0, 'Topic' for other sections - unless they have names defined by the user on the course, in which case they will be displayed. Language - changes of the 12th November will give translations for 'General' and 'Topic'. - -12th November 2010 - CONTRIB-1471 & CONTRIB-2497 - Changes as a result of MDL-25072: - 1. Movement of ajax capable stating 'code' from ajax.php to lib.php. - 2. As a consequence, ajax.php removed. - 3. Added German, French, Spanish (Spain, Mexico and International), Italian, Polish, Portuguese (Brazil too) - and Welsh. I used Google Translate! If inaccurate, please let me know! - 4. Added the string 'topcolltogglewidth' to the relevant language file and amended format.php so that - the word 'Topic' when translated fits within the toggle. - -6th November 2010 - CONTRIB-1471 - Changes as follows: - 1. ajax.php changed to add more browser support as a result of MDL-22528. - 2. format.php changed in light of MDL-24680, MDL-24895, MDL-24927. - 3. Fixed edit icon showing even when not in edit mode. A big thank you to [Peeush Bajpai] - (http://moodle.org/user/profile.php?id=1127356) - for spotting this and suggesting the fix. - 4. Added Dutch language. Thanks to [Pieter Wolters](http://moodle.org/user/profile.php?id=537037) for this. - -25th October 2010 - CONTRIB-1471 - Removal of redundant JavaScript Code. - -17th October 2010 - CONTRIB-1471 - Changes as a result of MDL-14679, MDL-20366 and MDL-24316. - 1. Removed the requirement of needing js-override-topcoll.css - to make things simpler. - 2. Tidied up some of the JavaScript to be slightly more efficient. - -24th September 2010 - CONTRIB-1471 - Changes as a result of MDL-24321 - changed object to stdClass. - -12th September 2010 - Moodle Tracker CONTRIB-2355 & CONTRIB-1471 - 1. CONTRIB-2355 - Added the ability to remove 'topic x' and the section number from being displayed. To do this, open up - format.php in a text editor - preferably with line numbers displayed - such as Notepad++ - and read the - instructions on lines 216 and 226. - 2. CONTRIB-1471 - Changes as a result of MDL-14679. - -31st July 2010 - Summary of developments towards release version as I keep pace with Moodle 2.0 changes: - 13th April 2010 - CONTRIB-1471 - Changes as a result of MDL-15252, MDL-21693 & MDL-22056. - 24th April 2010 - CONTRIB-1471 - Fixed section jump when in 'Show only topic x' mode. - 31st May 2010 - CONTRIB-1471 - thanks to Skodak in 1.120 of format.php in the topics format - 'summaryformat' attribute in - section class. - 11th June 2010 - CONTRIB-1471 as a result of MDL-22647 - Changes to Moodle 2.0 call-backs in lib.php. - 3rd July 2010 - CONTRIB-1471 as a result of MDL-20475 & MDL-22950. - 30th July 2010 - CONTRIB-1471 as a result of MDL-20628 and CONTRIB-2111 - in essence, sections now have a name attribute, so - this can be used for the topic name instead of the section summary - far better. - -5th April 2010 - Moodle Tracker CONTRIB-1952 & CONTRIB-1954 - 1. CONTRIB-1952 - Having an apostrophy in the site shortname causes the format to fail. - 2. CONTRIB-1954 - Reloading of the toggles by using JavaScript DOM events not working for the function reload_toggles, - but instead the function was being called at the end of the page regardless of the readiness state of the DOM. - -16th February 2010 - Moodle Tracker CONTRIB-1825 - 1. Removed the capability to 'Show topic x' unless editing as confusing to users. - 2. Removed redundant 'aToggle' as existing `$course->numsections` already contained the correct figure - and counting toggles that are displayed causes an issue when in 'Show topic x' mode as the toggle - number does not match the display number for the specific element. - 3. Removed redundant calls to `get_context_instance(CONTEXT_COURSE, $course->id)` as result already - stored in $context variable towards the top - so use in more places. - -23rd January 2010 - Moodle Tracler CONTRIB-1756 - 1. Put instructions in the CSS file 'topics_collapsed.css' on how you can define theme based toggle colours. - 2. Redesigned the arrow to be more 'modern'. - -24th August 2009 - - 1. Removed duplication in section name. - 2. Tidied up format.php to be XHTML strict in line with http://docs.moodle.org/en/Development:JavaScript_guidelines - - but I will need to revisit this at the end of development to tidy up any unintentional introduced issues & - adapt to have a non-javascript functionality where all the contents of the toggles are shown and the toggles do - not exist. - 3. Converted to using the Page Requirements Manager ($PAGE) as much as possible for JavaScript. - -Development Notes: -21st August 2009 - - 1. Fully comment code for future reference. - 2. Please see the documentation on http://docs.moodle.org/en/Collapsed_Topics_course_format - -16th July 2009 - Moodle 2.0 Development Version - This is now the 2.0 development version under the HEAD CVS Tag. - -15th July 2009 - Version 1.3 - Visual tidy up and Javascript file reduction! - 1. Moved the prefix words of 'Topic x' to the right hand side of the toggle when the summary exists. - 2. Compressed the lib.js into lib_min.js for faster loading using YUICompressor - original source still available. - 3. Moved as much as possible into css so that the files can be cached by the web browser and less transmitted in - terms of HTML. - 4. Sorted out the way the topic table is constructed in terms of column widths to be more robust on different - web browsers. Tested on a Vista PC with: FireFox 3.5, IE 8.0.6001.18783 in both normal and compatibility - modes, Google Chrome 2.0.172.33, Safari 4.0 (530.17) and Opera 9.64 build 10487. - -28th June 2009 - Version 1.2 - Persistence - tested on Moodle 1.9.5. - 1. Persistence is session based on a per user per course basis. - 2. Cookies must be enabled for it to work. - 3. I need to tidy up the code and remove the development comments. - 4. I would like to slightly alter the binary string to be an array. - 5. I would like to make the lib.js functions a part of a class for future proofing. - 6. Sort out page refresh event so that it works instead of saving the cookie every time a toggle is toggled. - -3rd March 2009 - Version 1.1 - Adjusted the Topic Toggle to make the topic summary standout more. - -2nd March 2009 - Version 1.0 - -1st March 2009 - Version 0.2 - -21st February 2009 - Version 0.1 - -Thanks -====== -I would like to thank Anthony Borrow - arborrow@jesuits.net & anthony@moodle.org - for his invaluable input. - -Craig Grannell of Snub Communications who wrote the article on Collapsed Tables in .Net Magazine Issue 186 from whom -the original code is based and concept used with his permission. - -For the persistence upgrade I would like to thank all those who contributed to the -[developer forum](http://moodle.org/mod/forum/discuss.php?d=124264) - Frank Ralf, Matt Gibson, Howard Miller and Tim Hunt. And -indeed all those who have worked on the developer documentation - http://docs.moodle.org/en/Javascript_FAQ. - -Michael de Raadt for CONTRIB-1945 & 1946 which sparked fixes in CONTRIB-1952 & CONTRIB-1954. - -[Amanda Doughty](http://moodle.org/user/profile.php?id=1062329) for her contribution in solving the AJAX move problem. - -[Mark Ward](http://moodle.org/user/profile.php?id=489101) for his contribution solving the IE8- display problem. - -[Pieter Wolters](http://moodle.org/user/profile.php?id=537037) - for the Dutch translation. - -[Tarcísio Nunes](http://moodle.org/user/profile.php?id=1149633) - for the Brazilian translation. - -[Pavel Evgenjevich Timoshenko](http://moodle.org/user/profile.php?id=1322784) - for the Russian translation. - -All of the developers of the [Grid Course format](https://github.com/PukunuiAustralia/moodle-courseformat_grid) for showing how -the database can be used with a course format. - -[Carlos Sánchez Martín](http://moodle.org/user/profile.php?id=743362) for his assistance on CONTRIB-3378 and the -Spanish translation. - -[Andrew Nicols](http://moodle.org/user/view.php?id=268794) for his assistance on CONTRIB-3378. - -[Hartmut Scherer](http://moodle.org/user/view.php?id=441502) for suggesting the 'Current Topic First' structure and testing the -Moodle 2.2 code on discussion [Collapsed Topics with Custom Layouts](http://moodle.org/mod/forum/discuss.php?d=195292). - -[Luiggi Sansonetti](http://moodle.org/user/profile.php?id=1297063) for the French translation. - -References -========== -.Net Magazine Issue 186 - Article on Collapsed Tables by Craig Grannell - - http://www.netmag.co.uk/zine/latest-issue/issue-186 - -Craig Grannell - http://www.snubcommunications.com/ - -Accordion Format - Initiated the thought - http://moodle.org/mod/forum/discuss.php?d=44773 & - http://www.moodleman.net/archives/47 - -Paint.Net - http://www.getpaint.net/ - -JavaScript: The Definitive Guide - David Flanagan - O'Reilly - ISBN: 978-0-596-10199-2 - -Desired Enhancements -==================== -1. Smoother animated toggle action. -2. Toggle saving only when the user closes the window / moves to another course. - -Me -== -G J Barnard MSc. BSc(Hons)(Sndw). MBCS. CEng. CITP. PGCE. -Moodle profile: http://moodle.org/user/profile.php?id=442195. -Web profile : http://about.me/gjbarnard +Introduction +============ +Topic based course format with an individual 'toggle' for each topic except 0. + +If you find an issue with the format, please see the 'Reporting Issues' section below. + +[![Build Status](https://travis-ci.org/gjb2048/moodle-format_topcoll.svg?branch=master)](https://travis-ci.org/gjb2048/moodle-format_topcoll) + +Required version of Moodle +========================== +This version works with Moodle version 2015111600.00 3.0 (Build: 20151116) and above within the 3.0 branch until the +next release. + +Please ensure that your hardware and software complies with 'Requirements' in 'Installing Moodle' on +'docs.moodle.org/30/en/Installing_Moodle'. + +Downloads and documentation +=========================== +The primary source for downloading this branch of the format is https://moodle.org/plugins/view.php?plugin=format_topcoll +with 'Select Moodle version:' set at 'Moodle 3.0'. + +The secondary source is a tagged version with the v3.0 prefix on https://github.com/gjb2048/moodle-format_topcoll/tags + +If you download from the development area - https://github.com/gjb2048/moodle-format_topcoll/ - consider that +the code is unstable and not for use in production environments. This is because I develop the next version in stages +and use GitHub as a means of backup. Therefore the code is not finished, subject to alteration and requires testing. + +Documented on http://docs.moodle.org/30/en/Collapsed_Topics_course_format + +Bespoke changes +=============== +Would you like a bespoke Collapsed Topics? Contact me via www.gjbarnard.co.uk/contact/ for a competitive quote. + +Free software +============= +The Collapsed Topics format is 'free' software under the terms of the GNU GPLv3 License, please see 'COPYING.txt'. + +It can be obtained for free from the links in 'Downloads and documentation' above. + +You have all the rights granted to you by the GPLv3 license. If you are unsure about anything, then the +FAQ - http://www.gnu.org/licenses/gpl-faq.html - is a good place to look. + +If you reuse any of the code then I kindly ask that you make reference to the format. + +If you make improvements or bug fixes then I would appreciate if you would send them back to me by forking from +https://github.com/gjb2048/moodle-format_topcoll and doing a 'Pull Request' so that the rest of the +Moodle community benefits. + +Sponsorships +============ +Collapsed Topics is provided to you for free, and if you want to express your gratitude for using this format, please consider +sponsoring by: + +PayPal - Please contact me via my 'Moodle profile' (above) for details as I am an individual and therefore am unable to have +'buy me now' buttons under their terms. + +Flattr - https://flattr.com/profile/gjb2048 + +Sponsorships may allow me to provide you with more or better features in less time. + +New features for this Moodle 3.0 version +======================================== + 1. Same features as version 2.9.1.5 in Moodle 2.9. + +Installation +============ + 1. Ensure you have the version of Moodle as stated above in 'Required version of Moodle'. This is essential as the + format relies on underlying core code that is out of my control. + 2. If upgrading from Moodle 1.9, 2.0 or 2.1, please see 'Upgrading from Moodle 1.9, 2.0 or 2.1' below. + 3. If upgrading from Moodle 2.2, please see 'Upgrading from Moodle 2.2' below. + 4. If upgrading from Moodle 2.3, please see 'Upgrade Instructions' below. + 5. Put Moodle in 'Maintenance Mode' (docs.moodle.org/en/admin/setting/maintenancemode) so that there are no + users using it bar you as the administrator - if you have not already done so. + 6. Copy 'topcoll' to '/course/format/' if you have not already done so. + 7. In 'Site Administration -> Plugins -> Course formats -> Collapsed Topics' change the values of 'defaultlayoutelement', + 'defaultlayoutstructure' and 'defaultlayoutcolumns' for setting the default layout, structure and columns respectively + for new / updating courses as desired by following the instructions contained within. + 8. In 'Site Administration -> Plugins -> Course formats -> Collapsed Topics' change the values of 'defaulttgfgcolour', + 'defaulttgbgcolour' and 'defaulttgbghvrcolour' for setting the default toggle colours. + 9. In 'Site Administration -> Plugins -> Course formats -> Collapsed Topics' turn off toggle persistence if desired by + changing 'defaulttogglepersistence' as indicated. +10. In 'Site Administration -> Plugins -> Course formats -> Collapsed Topics' set the default toggle alignment by changing + 'defaulttogglealignment' as indicated. +11. Login as an administrator and follow standard the 'plugin' update notification. If needed, go to + 'Site administration' -> 'Notifications' if this does not happen. +12. To change the arrow graphic please see 'Icon Sets' below. +13. Put Moodle out of Maintenance Mode. + +Upgrade Instructions +==================== +1. Ensure you have the version of Moodle as stated above in 'Required version of Moodle'. This is essential as the + format relies on underlying core code that is out of my control. +2. If upgrading from Moodle 1.9, 2.0, 2.1 or 2.2 please read the appropriate sections below. +3. Put Moodle in 'Maintenance Mode' so that there are no users using it bar you as the administrator. +4. In '/course/format/' move old 'topcoll' directory to a backup folder outside of Moodle. +5. Follow installation instructions above. +6. If automatic 'Purge all caches' appears not to work by lack of display etc. then perform a manual 'Purge all caches' + under 'Home -> Site administration -> Development -> Purge all caches'. +7. Put Moodle out of Maintenance Mode. + +Upgrading from Moodle 1.9, 2.0 or 2.1 +------------------------------------- +Moodle 2.4 requires that Moodle 2.2 is installed to upgrade from, so therefore Moodle 2.2 is an intermediate step. +So: +1. Put Moodle in 'Maintenance Mode' so that there are no users using it bar you as the administrator. +2. In '/course/format/' move old 'topcoll' directory to a backup folder outside of Moodle. +3. Do not copy in the new version of 'topcoll' yet! As this will cause the upgrade to fail. +4. Upgrade to Moodle 2.2 first - http://docs.moodle.org/22/en/Upgrading_to_Moodle_2.2. +5. After you have installed Moodle 2.2, now upgrade to Moodle 2.4 with this new topcoll - + http://docs.moodle.org/24/en/Upgrading_to_Moodle_2.4 - but before initiating the upgrade you can copy the + new (i.e. this) 'topcoll' folder to '/course/format'. +6. Now follow 'Upgrading from Moodle 2.2' below please. +INFO: Having no 'topcoll' folder in '/course/format' is fine as the courses that use it are not accessed and + both the old and new versions will confuse an intermediate 2.2 version and cause it's installation to fail. + +Upgrading from Moodle 2.2 +------------------------- +1. Put Moodle in 'Maintenance Mode' so that there are no users using it bar you as the administrator - if you have + not already done so. +2. In '/course/format/' move old 'topcoll' directory to a backup folder outside of Moodle - if you have not + already done so. +3. Copy this new 'topcoll' folder to '/course/format/'. +4. Upgrade to Moodle 2.4 by being logged in as 'admin' and clicking on 'Home'. If you have previously upgraded but + 'topcoll' was an old version and the upgrade failed, this should still work. +5. Follow installation instructions above. +6. Put Moodle out of Maintenance Mode. +NOTE: If the automated upgrade fails for which can be seen by getting errors when using a Collapsed Topics course, + then please follow this. + Please carry on if a table / field has been removed / changed / already exists as it should still work - this + is to cope with the different possible scenarios. These instructions are written with the MySQL database in + mind, however should work with other database engines but the types should be compared with other tables in + the database to get an idea of what they should be. If possible please kindly feedback to me any additional + information you discover so I can update these instructions - contact details at the very bottom. + The table prefix i.e, 'mdl_' is not stated in the instructions but ensure you know what yours is and use + it with the table names. +1. In your database: +2.1 Rename the table 'format_topcoll_layout' to 'format_topcoll_settings'. +2.2 With the table 'format_topcoll_settings' change all integer types to signed if using a MySQL database. +2.3 If the table 'format_topcoll_settings' does not exist, then create it and add the following fields + in this order: +2.3.1 'id' of type 'BIGINT(10)' type, not null, auto increment, no zero fill with a null default value - the same + as any other 'id' field in the other tables. Make it the primary key. +2.3.2 'courseid' of type 'BIGINT(10)' type, not null, no auto increment, no zero fill with a null default value - the + same as the 'course' field in the 'course_sections' table bar the default value. +2.3.3 'layoutelement' of type 'TINYINT(2)' type, not null, no auto increment, no zero fill with a default value + of '1'. +2.3.4 'layoutstructure' of type 'TINYINT(1)' type, not null, no auto increment, no zero fill with a default value + of '1'. +2.4 With the table 'format_topcoll_settings' append three new fields of 'VARCHAR(6)' type, not null, called + 'tgfgcolour', 'tgbgcolour' and 'tgbghvrcolour' in that order with the default values of '000000', 'e2e2f2' + and 'eeeeff' respectively. +2.5 With the table 'format_topcoll_settings' append a new field 'layoutcolumns' after the 'layoutstructure' field + and with identical size, type and attributes. The default is '1'. i.e: +2.5.1 'layoutcolumns' of type 'TINYINT(1)' type, not null, no auto increment, no zero fill with a default value + of '1'. +2.6 Drop the table 'format_topcoll_cookie_cnsnt'. + +Uninstallation +============== +1. Put Moodle in 'Maintenance Mode' so that there are no users using it bar you as the administrator. +2. It is recommended but not essential to change all of the courses that use the format to another. If this is + not done Moodle will pick the last format in your list of formats to use but display in 'Edit settings' of the + course the first format in the list. You can then set the desired format. +3. In '/course/format/' remove the folder 'topcoll'. +4. In the database, remove the table 'format_topcoll_settings' along with the entry for 'format_topcoll' + ('plugin' attribute) in the table 'config_plugins'. If using the default prefix this will be + 'mdl_format_topcoll_settings' and 'mdl_config_plugins' respectively. +5. Put Moodle out of Maintenance Mode. + +Course Backup and Restore Instructions +====================================== +1. Backup as you would any other course. The layout configuration will be stored with the course settings. +2. Restore as you would any other course. If you are offered the option of 'Overwrite Course Configuration' + you must say 'Yes' to have the layout configuration restored otherwise the restored course will retain the + layout it previously had or the default in the 'config.php' file as mentioned in the 'Installation' + instructions above depending on the situation. +3. Note: I believe that if you restore a Collapsed Topic's course on an installation that does not have the + format then it will work and become the default course format. However the layout data will not be + stored if you install Collapsed Topic's at a later date. + +Remembered Toggle State Information +=================================== +The state of the toggles are remembered beyond the session on a per user per course basis though the employment +of a user preference. This functionality is now built in from previous versions. You do not need to do anything. + +Icon Sets +========= +Icon sets allow you to choose what is the most appropriate set of icons to use for a given courses demographic. They +are set on a per course basis but with all the functionality of the other settings in respect to a default and resetting +the current or all courses. + +If you want to change what icon represents which state / action, then edit 'styles.css' and change the selectors with +the 'background' attribute with a 'toggle-...' type class within them. There are selectors for both the 'toggles' and +the 'toggle all' functionality. For example: + + body.jsenabled .course-content ul.ctopics li.section .content .toggle-arrow a.toggle_closed { + background-image: url([[pix:format_topcoll|arrow_right]]); + } + + #toggle-all .content .toggle-arrow h4 a.off { + background-image: url([[pix:format_topcoll|arrow_down]]); + } + +If you would like your own icon set, either replace the icons in the 'pix' folder, deduce how the code works or better +still create new icons yourself and ask me to add them to the release. If you do the latter then the icons must be your +own for which you grant the same GPL licence as [Moodle](http://www.gnu.org/copyleft/gpl.html) or provide direct evidence +of the originator under the same licence. The icons must be 24x24 pixels with a transparent background. + +Known Issues +============ +1. If you get toggle text issues in languages other than English please ensure you have the latest version of Moodle installed. + More information on http://moodle.org/mod/forum/discuss.php?d=184150. +2. Importing a Moodle 1.9 course does not currently work, please see CONTRIB-3552 which depends on MDL-32205 - as + a workaround, please select the 'Topics' format first in 1.9, backup and restore then select the Collapsed Topics + course format in the course settings. You will have to reset your decisions on structure etc. +3. Sometimes when restoring a course, it is accessed for the first time and a toggle is clicked a 'Error updating user + preference 'topcoll_toggle_x'' (where 'x' is the course id as shown in the URL 'id=x') can occur. I'm not completely sure + why this is happening as the 'user_preference_allow_ajax_update' call in 'format.php' should establish that the user + preference can be set. Could be a page cache thing as the 'init' code is getting the course id unlike an issue I'm + currently experiencing with the MyMobile theme - MDL-33115. The work around is to refresh the page. Having altered some + of the event handing code to operate after page load, I'm hoping that this has now been resolved, please let me know + if you encounter it. + +Reporting Issues +================ +Before reporting an issue, please ensure that you are running the latest version for your release of Moodle. The primary +release area is located on https://moodle.org/plugins/view.php?plugin=format_topcoll. It is also essential that you are +operating the required version of Moodle as stated at the top - this is because the format relies on core functionality that +is out of its control. + +All Collapsed Topics does is integrate with the course page and control it's layout, therefore what may appear to be an issue +with the format is in fact to do with a theme or core component. Please be confident that it is an issue with Collapsed Topics +but if in doubt, ask. + +I operate a policy that we will fix all genuine issues for free (this only applies to the code as supplied from the sources listed +in 'Downloads and documentation' above. Any changes / improvements you make are not covered and invalidate this policy for all of +the code). Improvements are at my discretion. I am happy to make bespoke customisations / improvements for a negotiated fee. I +will endeavour to respond to all requests for support as quickly as possible, if you require a faster service then offering payment +for the service will expedite the response. + +When reporting an issue you can post in the course format's forum on Moodle.org (currently 'moodle.org/mod/forum/view.php?id=47'), +on Moodle tracker 'tracker.moodle.org' ensuring that you chose the 'Non-core contributed modules' and 'Course Format: Topcoll' +for the component or contact me direct (details at the bottom). + +It is essential that you provide as much information as possible, the critical information being the contents of the format's +version.php file. Other version information such as specific Moodle version, theme name and version also helps. A screen shot +can be really useful in visualising the issue along with any files you consider to be relevant. + +Version Information +=================== +Version 3.0.2 + 1. Code checker tidy up. + 2. ARIA button role: https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/ARIA_Techniques/Using_the_button_role but + still need to think about keyboard control. + 3. Add TravisCI support: https://docs.moodle.org/dev/Travis_Integration and https://github.com/moodlerooms/moodle-plugin-ci. + 4. Simplify icon set CSS. + 5. Using https://github.com/squizlabs/PHP_CodeSniffer/wiki/Advanced-Usage#ignoring-parts-of-a-file on bitwise operators in + module.js until CONTRIB-5862 / https://github.com/moodlerooms/moodle-plugin-ci/issues/6 resolved. + +Version 3.0.1 + 1. Fixed #22, Orphaned sections are not responsive. + 2. Stable version. + 3. Start of PHPUnit tests. + +Version 3.0.0.3 + 1. Fixed #18, Collapsed Topics Edit menu and MDL-42634-28, ref: https://github.com/gjb2048/moodle-format_topcoll/issues/18 + 2. Fixed slight issue with heading colour conflict and themes. + 3. Fixed #19, Drag and drop handle does not show when editing in RTL. + 4. Apply MDL-10405. + +Version 3.0.0.2 + 1. Added responsive theme support, now a new 'Format responsive' setting in Site Administration -> Plugins -> + Course Formats -> Collapsed Topics where you can turn on the old responsive behaviour that the format + provided if you don't have a responsive theme. + +Version 3.0.0.1 + 1. First 'beta' version for M3.0. + 2. Apply MDL-48947, MDL-51250 and MDL-51610. + +Version 2.9.1.5 + 1. Fixed 'Strict standards warning shown when using collapsed topics format' - CONTRIB-5974. + 2. Fixed iconset issue when editing the course settings. + 3. Fixed hidden content margins. + +Version 2.9.1.4 + 1. Fixed display of sections when 'Hidden sections' is set to 'Hidden sections are shown in collapsed form' and the + 'Structure' is one of 'Current topic first' or 'Current week first'. + 2. Language files tidy up. + 3. Fix left and right section information not being displayed in Bootstrap V3 themes. + 4. Improve RTL support by swapping left and right sides. + 5. Improve side widths in different languages by checking that the value retrieved is for the current language and + not the default English one by mistake so that the default value in the styles.css file is used in preference. + 6. Fix position of icon set icon in course settings 'Icon set' drop down. + 7. Fix missing ground signal icon in course settings 'Icon set' drop down. + 8. Change 'Configuration' setting 'What to do with the toggles when the user first accesses the course, adds more sections or + toggle peristence is off' to 'Initial toggle state' for clarity. + +Version 2.9.1.3 + 1. Removed MyMobile theme support as theme has passed away. + 2. Fix CONTRIB-5817. + 3. Update readme. + 4. Fix 'Edit quiz page displays oddly' - https://moodle.org/mod/forum/discuss.php?d=317476. + +Version 2.9.1.2. + 1. Fixed coding fault when restoring a course from backup file. + +Version 2.9.1.1. + 1. Fixed broken default for defaulttoggleiconsize - thanks to Davo Smith - issue #16. + +Version 2.9.1. + 1. First stable version for Moodle 2.9. + +Version 2.9.0.2. + 1. Added the capability to delete a section. + 2. Tidy up column padding after testing with Shoehorn. TODO: Decide if column padding is needed now. + 3. Removed out of date development test code. + 4. Removed out of date IE7 styles. + +Version 2.9.0.1. + 1. First 'release candidate' version for Moodle 2.9. + 2. Note: Need to seriously think about using AMD and transitioning to using jQuery instead of YUI as AJAX is possible in jQuery, + but almost certainly not in the first instance as YUI is still supported in core. Modularisation is do-able in AMD + with parameters required: https://docs.moodle.org/dev/Javascript_Modules. + +Version 2.8.2.3 + 1. Fixed logic flaw with section parameters on course URL's when using single page display. + +Version 2.8.2.2 + 1. Added print media styles. + 2. Version information to no longer have the date as will work better. + +27th January 2015 Version 2.8.2.1 + 1. Refix issue #4 - No block drag and drop icon when blockeditingmenu is false - activity editing menu no longer shows. + +23rd January 2015 Version 2.8.2 + 1. New 'Do not show date' feature gratefully funded by 'GAC Corporate Academy, GAC HQ, Dubai, UAE (http://www.gacacademy.com)'. + 2. Fix issue #14 - No block drag and drop icon when blockeditingmenu is false. + +11th December 2014 Version 2.8.1.1 + 1. New 'Show section summary when collapsed' feature gratefully funded by 'Te Rito Maioha Early Childhood New Zealand - https://ecnz.ac.nz'. + 2. Fix CONTRIB-5472. + 3. Integrated 'Use core required_param for toggle parameters.': https://github.com/gjb2048/moodle-format_topcoll/pull/12 + "This work was made possible through funding from Te Rito Maioha Early Childhood New Zealand". + Improves on work instigated in CONTRIB-5211 and related to MDL-46754. + 4. Improved HTTP protocol handling in 'settopcollpref.php'. + +16th November 2014 Version 2.8.1 + 1. Stable version for Moodle 2.8. + +10th November 2014 Version 2.8.0.1 - Release Candidate + 1. Release candidate for Moodle 2.8 - NOT for production servers. + +20th September 2014 Version 2.7.1.5 + 1. Fixed issue where a debug message was being written to the PHP error log. + 2. When toggle persistence is off then the state of the toggles on page load will depend on the default user preference setting. + 3. Added the ability to set the size of the toggle icon site wide as: Small = 16px, Medium = 24px and Large = 32px. + 4. Added the ability to set each corner of the toggle border radius site wide between 0.0 and 4.0em in increments of 0.1. + +19th August 2014 Version 2.7.1.4 + 1. Fixed issue #11: Moodle notice - https://github.com/gjb2048/moodle-format_topcoll/issues/11. + +18th August 2014 Version 2.7.1.3 + 1. Fixed a few typos. + 2. Fixed CONTRIB-5211: Section 5 does not remain expanded when browsing away and back. + +17th July 2014 Version 2.7.1.2 + 1. Slight tweak to css to tidy things up when editing. + 2. Patch for IE8(!!!) kindly supplied by Mathew Gancarz - https://moodle.org/user/profile.php?id=1471695. To fix an issue + where the activities / resources were still being displayed even after the toggle had closed. If you are still on IE8, + then please see this: http://www.microsoft.com/en-gb/security/pc-security/updates.aspx?linkId=8591289. + 3. Fixed being able to manipulate sections via left and right content areas on tablets. Thanks to Rick Jerz for reporting this + on https://moodle.org/mod/forum/discuss.php?d=263739. + +12th June 2014 Version 2.7.1.1 + 1. Fixed toggle name word break: https://moodle.org/mod/forum/discuss.php?d=261388. + 2. Added toggle foreground colour hover. + +20th May 2014 Version 2.7.1 - Stable. + 1. Stable release for M2.7. + 2. Fixed CONTRIB-5073 - invisible section causes an error with "topcoll" format. + +22nd April 2014 Version 2.7.0.1 - BETA + 1. First beta version for Moodle 2.7beta. + +17th April 2014 Version 2.6.1.5 + 1. Fixed CONTRIB-4099 with the arrangement of the editing icon and associated functionality such that a better solution is + applied for the specific nature of the format. + +28th March 2014 Version 2.6.1.4 + 1. Fixed slight issue with mobile / tablet display issue of toggle all and instructions. + 2. Fixed issue with Bootstrap 3 breaking the layout of hidden sections when >= 2 columns. + 3. Fixed hidden section when "Hidden sections are shown in collapsed form." mode breaks columns. + 4. Fixed slight mobile / tablet display issues as shown on https://moodle.org/mod/forum/discuss.php?d=256093. + 5. Optimised 'print_multiple_section_page' in 'renderer.php' by using a 'break' instead of a 'continue' when the number of + sections is exceeded. + +20th February 2014 Version 2.6.1.3 + 1. Refactoring for the 'Elegance' theme: https://github.com/moodleman/moodle-theme_elegance. + +16th January 2014 Version 2.6.1.2 + 1. Fixed Essential theme overriding toggle text colour - see: https://moodle.org/mod/forum/discuss.php?d=251951. + 2. Fixed bullet point styles - see: https://moodle.org/mod/forum/discuss.php?d=251944. + 3. Refactored 'print_single_section_page()' in 'renderer.php' to call parent version of method and thus reduce + code duplication and maintenance. + 4. Removed duplicate section title when editing. + +18th December 2013 Version 2.6.1.1 + 1. Fixed issue reported by Graham Woodsford whereby teachers could not create Collapsed Topics courses. This is because the + validation method 'edit_form_validation' in 'lib.php' was failing the values passed to it. These happened to be the + hidden label values from 'course_format_options' which were being used because the 'Course creator' role that teachers + have before becoming an 'editingteacher' role as defined in 'db/access.php' does not allow the teacher to have the + the 'format/topcoll:changelayout', 'format/topcoll:changecolour', 'format/topcoll:changetogglealignment' and + 'format/topcoll:changetoggleiconset' capabilities. This also implies that the values of the other settings are wrong, + which in fact they are, causing courses to be created (after fixing the colour settings for 'edit_form_validation') with + odd values and not the defaults resulting in no icon set etc. And therefore needing to go back to edit the course settings. + + Ok, this now leads on to a dilemma. Currently the course creator role does not have the CT capabilities listed above. If + they were added to 'access.php' then the role would have them (existing CT admins would have to add manually). Then the + teacher would see all the options when first creating a course as they do whilst editing. However, this means that if you + wish to restrict the teacher from changing things as is the purpose of the capabilities in the first place, then you have + to remove the capability in both the 'coursecreator' and 'editingteacher' roles. This is because by default 'coursecreator' + is above 'editingteacher' and once enrolled on the course after having created it, the teacher has both. This makes things + a bit complex and to be honest not that admin friendly. Therefore to keep things simple in what is in reality an event + that is rare, I have decided not to add the capabilities to the 'coursecreator' role. This is additionally based on the + presumed work-flow of a teacher where they create the course using the defaults, look at it and then decide what to change + in the settings. The fix as it stands will facilitate this. + +18th November 2013 Version 2.6.1 +Change by G J Barnard + 1. Fixed slight issue with lack of prefixing '#' for colour settings in default settings. + +14th November 2013 Version 2.6.0.1 + 1. Initial BETA code for Moodle 2.6. + +14th November 2013 Version 2.5.3.5 + 1. Changes for 'Accessibility' based upon MDL-41252. + 2. Fully implemented MDL-39542. + 3. Slight tweak to colour pop up code such that default settings courses don't have a prefixing '#'. + 4. Implemented validation on colours as an implied result of CONTRIB-4736. Thanks to Kirill Astashov for this. + 5. Fixed sections not being aligned at the top when more than one column and with a vertical column orientation. + 6. Fixed updating from Moodle 2.3 for existing courses issue - CONTRIB-4743. Thanks to Kirill Astashov for this. + +24th October 2013 Version 2.5.3.4 + 1. Fixed reset toggle instructions not working when only thing reset. + 2. Fixed reset logic as was updating course format options when should not have done even though there would have been no effect. + 3. Slight optimisation to 'renderer.php' for getting 'format_topcoll' object when already have it. + 4. Slight optimisation to getting the strings for the current section 'light bulb'. + +2nd October 2013 Version 2.5.3.3 + 1. Added: Bulb, Cloud, Eye, LED, Radio, Smiley, Square, Sun / Moon and Switch icon sets as a result of remembering about: + https://moodle.org/mod/forum/discuss.php?d=220142. + 2. Added instructions on how to use the toggles from a suggestion by Guido Rößling on Learn Moodle. + 3. Added setting to turn on (default) / off the instructions at the course and site default level with 'Reset' and 'Reset all' + capability. + 4. Worked out how to get the reset options on the course settings page in-line in groups. + +19th August 2013 Version 2.5.3.2 + 1. Fixed issue with the 'float: left' CSS style when used to ensure that the columns were displayed correctly in the + 'vertical' column orientation. The fix is to use 'display: inline-block' instead but this does not work in IE7, so as + it does in IE8+ and other browsers I'm going to have to go with it. Thanks to Ed Przyzycki for reporting this. + +27th July 2013 - Version 2.5.3.1 + 1. Fixed issue with dates being shown on section zero with temporal structures. Thanks to Michael Turico for reporting this. + +9th July 2013 - Version 2.5.3 + 1. Added the ability to set the position of the toggle as either left or right on a per course basis with + a default setting. You need the 'changelayout' capability to be able to set this. + 2. Gratefully crowd funded on Moodle Garage -> http://www.moodlegarage.com/projects/collapsed-topics-left-to-right/. + +26th June 2013 - Version 2.5.2.2 + 1. Fixed issue with 'Notice: String offset cast occurred in togglelib.php on line 68' when running on PHP 5.4. Thanks + to Halldór Kristjánsson (https://moodle.org/user/profile.php?id=1611408) for reporting this. + +24th June 2013 - Version 2.5.2.1 + 1. Fixed CONTRIB-4436 with a 'blocker' bug on V2.5.2 below with backups failing (do not ever install this version unless you + want to test your disaster recovery procedures). Thanks to Mike Turico for reporting it. Note to self and all, using html + tags in the 'get_section_name()' method in 'lib.php' will break backups and trash your database. + +23rd June 2013 - Version 2.5.2 + 1. Fixed issue with sections not showing their contents in editing mode when open all has been used, then they are individually + closed and reopened. Thanks to Marc Hermon for reporting this. + 2. Added small icon which shows up when updating. + 3. Ensure the correct arrow is used when not using JavaScript. + 4. Radically changed the toggle persistence storage mechanism to be based on a base 64 system using the following subset of ASCII: + ":;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxy". This is more efficient than the actual Base64 system of: + "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/" because there is no complex conversion from the character to + to the value it represents. I also decided not to include "01" as that makes detection of the old mechanism simple for upgrade + purposes. + This was done to support courses with sections greater than fifty two. Currently there is no upper limit bar what your machine + is capable of serving. The length of the toggle persistence data increases and decreases automatically in responce to the number + of sections. There are six sections per digit. + 5. Finally fixed having the 'toggle' word on toggles and not on the navigation menu with AJAX drag and drop working - CONTRIB-4403. + 6. Implemented MDL-33546. + 7. Fixed size of toggles altering when using AJAX drag and drop. + 8. Ran the code through the infamous 'Code Checker' version 2013060600, release 2.2.7 and cleared as much as possible. + 9. Note: Once you upgrade to this version and beyond then going back will mean loss of the user preferences as you will need to + remove all 'topcoll_toggle_x' rows from the 'user_preferences' table first. + +6th June 2013 Version 2.5.1.1 + 1. Implemented MDL-39764 to fix maxsections < numsections issue. + 2. Reversed the order of the history in this file for easy reading. + 3. Cleaned up some of the CSS. + 4. Changes to 'renderer.php' because of MDL-21097. + +14th May 2013 Version 2.5.1 - Stable + 1. First stable version for Moodle 2.5 stable. + +12th May 2013 - Version 2.5.0.6 - Beta + 1. Changes for MDL-39542. + +9th May 2013 - Version 2.5.0.5 - Beta + 1. Fixed coding fault with resetting introduced in capabilities change. + 2. Fixed coding fault with language string in layout settings. + +8th May 2013 - Version 2.5.0.4 - Beta + 1. Fixed "When in 'Show one section per page' mode and the column orientation is set to 'Horizontal' the sections on the main + page do not fill their correct width. This is due to the use of the 'section_summary()' method which needs to be changed + within the format to set the calculated width on the 'li' tag." because the core fix I submitted on MDL-39099 has now + been integrated. Thus requiring version 2013050200.00 2.5beta+ (Build: 20130502). + 2. Changed the layout descriptions to be more 'positive' in nature. Should be backwards compatible in terms of languages. From + a suggestion by Guido Hornig. + 3. Added automatic 'Purge all caches' when upgrading. If this appears not to work by lack of display etc. then perform a + manual 'Purge all caches' under 'Home -> Site administration -> Development -> Purge all caches'. + +29th April 2013 - Version 2.5.0.3 - Beta + 1. Fixed non-referenced member variable bug which showed up as 'undefined' but should have been a reference error in testing. + 2. Please perform a 'Purge all caches' under 'Home -> Site administration -> Development -> Purge all caches' when upgrading. + +27th April 2013 - Version 2.5.0.2 - Beta + 1. Thanks to ideas from Ben Kelada and help from Andrew Nicols / Tim Hunt, I have made the event handing toggle functions more efficient. + 2. Fixed an obscure bug with '$defaultuserpreference' in 'format.php' not being parsed to 'M.format_topcoll.init' in 'module.js'. + 3. Removed '.jumpmenu' from styles.css because of MDL-38907. + 4. Please perform a 'Purge all caches' under 'Home -> Site administration -> Development -> Purge all caches' when upgrading. + +12th April 2013 - Version 2.5.0.1 - Beta + 1. First 'Beta' release for Moodle 2.5 Beta. + 2. Note: Date in version file (2013041500) is greater than actual date code released publically to facilitate updates to Moodle 2.4 version. + 3. Please perform a 'Purge all caches' under 'Home -> Site administration -> Development -> Purge all caches' when upgrading. + +11th April 2013 - Version 2.4.4 + 1. Implemented the administrator setting for the format so that the default state of the toggles can be set to + 'all closed' or 'all opened' for new users. Thanks to Jamie Burgess (https://moodle.org/user/profile.php?id=1489185) for the idea. + 2. Realised that Tablets have more space, so allow two columns even when two or more are set. + 3. Please perform a 'Purge all caches' under 'Home -> Site administration -> Development -> Purge all caches' when upgrading. + +16th March 2013 - Version 2.4.3.1.1 + 1. Fixed toggle peristence issue caused by code checking the code and not realising the implications of '==='. + Thanks to Marc Hermon for reporting this. + 2. Implemented round toggle borders to reduce the harshness and integrate with jQueryMobile themes in line with Moodle 2.3 version. + 3. Please perform a 'Purge all caches' under 'Home -> Site administration -> Development -> Purge all caches' when upgrading. + +14th March 2013 - Version 2.4.3.1 + 1. Improved mobile and tablet theme detection and support. + 2. Added 'Downloads and documentation' to this readme to clarify the download locations. + 3. Cleaned JavaScript through use of http://jshint.com/. + 4. Added 'Previous versions and required version of Moodle' to this guide. + 5. Implemented MDL-37901. + 6. Implemented MDL-37976. + 7. Moved 'float: left' to styles.css for Henrik Thorn - CONTRIB-4198. + 8. Improvements for MDL-34917. + 9. Please perform a 'Purge all caches' under 'Home -> Site administration -> Development -> Purge all caches' when upgrading. + +8th February 2013 - Version 2.4.3 + 1. Taking inspiration from the IEC 5009 standard standby symbol as described on http://en.wikipedia.org/wiki/Power_symbol and a + suggestion with the + / - symbols by Ben Kelada on CONTRIB-4098. I have used the 'standby' concept as Moodle is on + and waiting for input. + 2. I created the icons in Paint.Net and are released under the same GPL licence as the rest of Collapsed Topics and indeed + Moodle. + 3. Implemented 'Icon sets' such that the user can choose what set of icons they wish to use without complex code changes. I am + hoping that this will spark more 'sets' to incorporated in the main release from users. + 4. Added the ability to control if the toggle all icons will change when hovered over, for Rick Jerz. + 5. Moved all 'tcconfig.php' default functionalty to 'Site Administration -> Plugins -> Course formats -> Collapsed Topics' + so that defaults can be changed by the administrator from within Moodle without resorting to code changes. + 6. Added capabilities 'format/topcoll:changelayout', 'format/topcoll:changecolour', 'format/topcoll:changetogglealignment' + and 'format/topcoll:changetoggleiconset' to editing teachers and managers such that site administrators can choose to + disable functionality through roles if they wish. In order for this to work the version number must be updated. + 7. Code cleaned with ['code-checker'](https://moodle.org/plugins/view.php?plugin=local_codechecker) - not finished yet + - no functional changes. + 8. Added toggle icons to the selection boxes of the edit settings and plugin settings. Does not work with Chrome - known + browser issue. + 9. Changed this readme to ['Markdown' format](http://en.wikipedia.org/wiki/Markdown). + 10. Please perform a 'Purge all caches' under 'Home -> Site administration -> Development -> Purge all caches'. + +23rd January 2013 - Version 2.4.2.1 + 1. Further tweaks for toggle line height and to make work in IE9 with and without IE7 mode. + 2. Please perform a 'Purge all caches' under 'Home -> Site administration -> Development -> Purge all caches' when upgrading. + +22nd January 2013 - Version 2.4.2 + 1. Added ability to control the orientation of columns when more than one is used. You can now choose between + having the sections number down the page (vertical) or left to right (horizontal). Default is horizontal. This + is from a suggestion on CONTRIB-4098 by Michele Turre. The MyMobile theme only uses one column regardless of the number + of columns setting. + 2. Fixed section number not updating in the left part of a section when using AJAX drag and drop moving. + 3. Implemented and adjusted CSS for CONTRIB-4106 to have consistent section name styles. + 4. Tweaked no JavaScript operation such that the 'Toggle all' functionality is hidden. + 5. Implemented removal of css float for MyMobile theme for CONTRIB-4108. + 6. Fixed issue with JavaScript in 'module.js' breaking with 0 or 1 sections causing the 'Add an activity or resource' to fail. + 7. Changes to 'renderer.php' because of MDL-36095 hence requiring Moodle version 2012120301.02 release 2.4.1+ (Build: 20130118) + and above. + 8. Tweaked for the MyMobile theme but point '2' on 'Known issues' still occurring - any help appreciated. + 9. Please perform a 'Purge all caches' under 'Home -> Site administration -> Development -> Purge all caches' when upgrading. + +11th January 2013 - Version 2.4.1.7 - Further improvements inspired by CONTRIB-4098. + 1. Changed 'Latest Week' to 'Current Week' to be less confusing. + 2. Added 'Reporting Issues' to this file. + 3. Please perform a 'Purge all caches' under 'Home -> Site administration -> Development -> Purge all caches' when upgrading. + +10th January 2013 - Version 2.4.1.6 - Improvements inspired by CONTRIB-4098 - Thanks to Michele Turre and Rick Jerz. + 1. Changed the direction of the up arrow in line with the navigation block. + 2. Refactored the global constant structure in tcconfig.php to be a class with constants, thus removing the 'globalness'. + 3. Added ability to determine the alignment of the toggle text, left, centre or right. + 4. Fixed version year which was still stuck at 2012 - please ensure you use this version when upgrading rather than + a previous 2013 release. + 5. If upgrading, please perform a 'Purge all caches' under 'Home -> Site administration -> Development -> Purge all caches'. + +5th January 2013 - Version 2.4.1.5 + 1. In applying versions 2.4.1.2 and 2.4.1.4 to the Moodle 2.3 version I considered that when a section had + a name that the date should be after and not before. Thereby being more aesthetically pleasing. + +3rd January 2013 - Version 2.4.1.4 + 1. Fixed unexpected issue when the number of sections is '0'. Thanks to 'Aylwin Cal' for reporting this. + +2nd January 2013 - Version 2.4.1.3 + 1. Fixed unexpected issue with changes made to 'get_section_name()' in lib.php in version 2.4.1.2 caused + course backup to fail. This was due to the inclusion of a 'br' tag to make the section name and date + look effective. I have refactored to apply the 'br' tag formatting in renderer.php instead. The + down side of this being the navigation window does not contain the date when a section name is set. + Apart from doing a lot of string splitting in renderer.php to insert the 'br' tag in the right place, + there is no other way of solving this - and I consider for efficiency and clutter that the date should + be omitted in this circumstance. + +31st December 2012 - Version 2.4.1.2 + 1. Fixed missing date text in week / day based structures that were in 2.2 versions and below. Thanks + to Michael Turico for informing me of this. + 2. Moved edit section icon to the right of the toggle as it was not click-able on the toggle itself. + 3. Changed format.js to have better results when moving sections - I hope. + +19th December 2012 - Version 2.4.1.1 + 1. Minor refactor to remove redundant parameter on 'section_nav_selection()' in 'renderer.php'. + +17th December 2012 - Version 2.4.1 - Stable + 1. Tested completely fix for CONTRIB-4065. + 2. Re-factored to remove global '$tcsettings' and place in 'lib.php' so code is more OO. + 3. Code now considered stable. + +12th December 2012 - Version 2.4.0.6 - Beta - Do not install on production sites. + 1. Fix for CONTRIB-4065. + +8th December 2012 - Version 2.4.0.5 - Beta - Do not install on production sites. + 1. Changes for CONTRIB-4018 so that the toggles are not click-able until after the page has loaded, thus + preventing JavaScript errors during page load. + 2. If upgrading, please perform a 'Purge all caches' under 'Home -> Site administration -> Development -> Purge all caches'. + 3. Ensure the toggle word is not appended to section zero. + +4th December 2012 - Version 2.4.0.4 - Beta - Do not install on production sites. + 1. Adjusted logic of optional postfixed 'Toggle' word because of 'drag and drop section name' issue. + 2. Moved reset code to custom group box on course editing form thanks to Marina Glancy on MDL-35218. + 3. Added the course display option as a default in 'tcconfig.php' so that all new CT courses are set to this value. + 4. Reset now incorporates the course display option to put it back to the default. + 5. Removed old reset form, icon and CSS. + +3rd December 2012 - Version 2.4.0.3 - Beta - Do not install on production sites. + 1. Fixed drag and drop section name issue. + 2. Implemented a few suggestions by Marina Glancy on MDL-35218. + 3. Updated required version to first stable release. + +1st December 2012 - Version 2.4.0.2 - Beta - Do not install on production sites. + 1. Beta version for Moodle 2.4 with one new known issue 'When moving sections around in editing mode the toggle name + and section summary do not update until page refresh.' + 2. Do not install on a production site. + 3. Feedback appreciated though the course format forum (https://moodle.org/mod/forum/view.php?id=47) or + Moodle messaging (moodle.org/user/profile.php?id=442195). + 4. Using the colour picker for the toggle colours no longer requires a prefixing hash for the hexadecimal number. + 5. Three new language strings added: 'numbersections', 'ctreset' and 'ctreset_help' to the English file, others to follow. + 6. I have tested using Zend Server 5.6.0 Community Edition (MySQL DB) on Windows 7 with Chrome 23.0.1271.95: + - Upgrading from Moodle 2.2 and 2.3. + - Restoring 2.2 and 2.3 courses. + - Resetting to defaults for the 'current course' and 'all courses' as an administrator. + - Course backup and restore. + - Toggle persistence on and off. + - AJAX section move (with section name & summary caveat). + - Course layout and colour settings. + - Deleting the course. + - Moving from the 'topics' format. + - One section per page setting. + - Invalid number of columns in the database, both low and high. + However, this is not exhaustive, therefore if you are able to test on different environments and upgrades + from older versions of Moodle, then that would be helpful. + 7. I am currently deliberating on the issues raised on [CONTRIB-4018](http://tracker.moodle.org/browse/CONTRIB-4018) which + apply to this version too. If you have any thoughts / solutions, please comment on the tracker, thank you. + +2nd August 2012+ - Version 2.4.0.1 - Do not install on production sites. + 1. Development for Moodle 2.4. + 2. Major changes for course formats refactoring - MDL-35218 - mainly to do with moving the settings into the course + settings. + +9th November 2012 - Version 2.3.9.3 + 1. Fixed issue with wrong text colour being used for the current right section text. Had to use 'left' side selector + for getting the correct text colour on the right for the current section. This is because the selector + '.course-content .current .left' defines the colour in the theme and therefore any CT specific 'right' implementation + would not work for all themes. + 2. Tweaked CSS for 'Anomaly', 'Afterburner', 'MyMobile' and 'Rocket' themes. + +23rd October 2012 - Version 2.3.9.2 + 1. Fixed issue with wrong colour being used for current section background. + Thanks to [Rick Jerz](https://moodle.org/user/profile.php?id=520965) for reporting this. + +18th October 2012 - Version 2.3.9.1 + 1. Fixed potential issue when the course is first accessed and there is no user preference. + 2. Identified that sometimes when restoring a course, it is accessed for the first time and a toggle is clicked a 'Error + updating user preference 'topcoll_toggle_x'' (where 'x' is the course id as shown in the URL 'id=x') can occur. I'm not + completely sure why this is happening as the 'user_preference_allow_ajax_update' call in 'format.php' should establish that + the user preference can be set. Could be a page cache thing as the 'init' code is getting the course id unlike an issue + I'm currently experiencing with the MyMobile theme - MDL-33115. The work around is to refresh the page. + +17th October 2012 - Version 2.3.9 + 1. Idea posed on https://moodle.org/mod/forum/discuss.php?d=213138 (implemented in 2.3.2 first as it is currently the main + development branch), led to the thought that the code could now be optimised to set the toggle state at the server end as + that is where the persistence is now stored. So to speed things up this version should reduce page load times by about 0.4 + of a second. This has been achieved by setting the state of the toggle when writing out the HTML at the server end instead + of making all toggles initially closed and then getting the client side JavaScript to open them as required. Until the + move to server side persistence this would not have been possible. + +7th October 2012 - Version 2.3.8.2 1. Changes to 'renderer.php' because of MDL-31976 and MDL-35276 - thus requiring + Moodle 2.3.2+, version 2012062502.05 (Build: 20121005). + +10th September 2012 - Version 2.3.8.1 + 1. Fixed 'Warning: Illegal string offset 'defaultblocks' in ...\topcoll\config.php on line 39' issue when + operating with developer level debugging messages under PHP 5.4.3. This was due to 'config.php's inclusion in 'lib.php' + with a 'require_once' function call. Somehow Moodle core must include this file in another way. Therefore collapsed + topics specific settings have been placed in a new file 'tcconfig.php' and all files changed to reflect this. + Thanks to [Paul Nijbakker](http://moodle.org/user/profile.php?id=10036) for spotting this issue. + +3rd September 2012 - Version 2.3.8 + 1. Changes to 'renderer.php' because of MDL-28207 - thus requiring Moodle 2.3.1 2012062501.09 (Build: 20120809). + 2. Implemented MDL-34798 which I reported for AJAX section moving. + 3. Integrated CONTRIB-3827 to fix proliferation of CSS styles across other course formats. + 4. Change to 'format.php' because of MDL-34829. + 5. Sorted wording of 'light bulb' when editing. + 6. Integrated CONTRIB-3825 to fix upgrade issue when converting a non-MySQL the database. + 7. Implemented MDL-34858 which I reported as a section zero default name issue. + 8. Implemented MDL-34917 which I reported as an improvement. Code is slightly different, feedback appreciated. + 9. Make toggle titles bold and change 'all toggles' to 'all sections', from comments made on MDL-35048. + 10. Cherry picked Luiggi's change + https://github.com/luiggisanso/moodle-format_topcoll/commit/9bd818f5a4efb347aef4f5154ea2930526552bfc + 11. Figured out how to use 'pix:' for URL's in css for the format, so have changed so that the images are now controlled by css classes. This + means that it is now possible to override them in your theme in css. The following is the selectors for the various images, override + the 'background' attribute: + + `body.jsenabled .course-content ul.ctopics li.section .content .toggle a.toggle_open` - For the 'up' arrow in the toggle - original is 24px. + `body.jsenabled .course-content ul.ctopics li.section .content .toggle a.toggle_closed` - For the 'down' arrow in the toggle - original is 24px. + `.course-content ul.ctopics li.section .content .toggle a.toggle_closed` - For the 'up' arrow in the toggle when JavaScript is disabled and the toggles default to open. + `#toggle-all .content .sectionbody h4 a.on` - For the 'open all sections' image - original is 24px. + `#toggle-all .content .sectionbody h4 a.off` - For the 'closed all sections' image - original is 24px. + `#tc-set-settings` - For the 'settings' image. + + If in doubt, please consult 'styles.css' in the format. + 12. Checked operation in 'MyMobile' theme, all seems good except bottom left and right navigation links in 'One section per + page' mode. HTML is identical to that of 'Topics' format bar difference classes higher up the document object model to + distinguish 'Collapsed Topics' from 'Topics'. Hopefully will be resolved when MDL-33115 implemented. + +1st August 2012 - Version 2.3.7.2 + 1. Changes to 'renderer.php' because of MDL-33767. + 2. Tidied up some of the logic in 'renderer.php'. + 3. Made 'format.php' more adaptable to old style section 'x' only urls. + 4. Made inclusion of 'config.php' in 'lib.php' more precise. + 5. Removed 'callback_topcoll_get_section_url' in 'lib.php' because it is no longer required by + 'load_generic_course_sections' in '/lib/navigationlib.php'. + 6. Added 'currentsection' string to '/lang/en/format_topcoll.php' - thanks to [Carlos Kiyan Tsunami](http://moodle.org/mod/forum/discuss.php?d=208066). + 7. Shrunk the settings icon to 75% of the original size so that it is not so 'in your face' and added + instructions on the left. The instructions are in the 'en' langauge file as the 'formatsettingsinformation' + string for translation. + +11th July 2012 - Version 2.3.7.1 + 1. Updated french lanugage file thanks to Luiggi Sansonetti. + 2. Fixed an issue with section zero summary not showing - thanks [Chris Adams](http://moodle.org/mod/forum/discuss.php?d=206423) + 3. Attempted automated upgrade in 'upgrade.php' to cope with issues users are experiencing. Altered upgrade from + Moodle 1.9, 2.0, 2.1 and 2.2 instructions to reflect this. Version control for older versions less than Moodle 2.3 + needs to follow a 'branching date' strategy for this to work properly - + http://moodle.org/mod/forum/discuss.php?d=206647#p901061. This was sparked by CONTRIB-3765. + 4. Tidied up and clarified the instructions for upgrading. + +3rd July 2012 - Version 2.3.7 Stable - Completion of CONTRIB-3652 development - rewrite for Moodle 2.3. + 1. Test and tidy up code. + 2. Placed check and correction for columns out of range 1-4 in renderer.php. + 3. Cope with backups from Moodle 2.0, 2.1 and 2.2. + 4. Cope when sections are not shown in column calculations. + 5. Test with MyMobile to understand underlying issue. + +29th June 2012 - Version 2.3.7rc5 - CONTRIB-3652 development - rewrite for Moodle 2.3 + 1. Test and tidy up code. + +28th June 2012 - Version 2.3.7rc4 - CONTRIB-3652 development - rewrite for Moodle 2.3 + 1. Corrected an issue in 'renderer.php' for the overridden method 'print_multiple_section_page()' so that section 0 has a name + displayed if there is one - see http://moodle.org/mod/forum/discuss.php?d=205724. + 2. Ensured that only one column is present when using the MyMobile theme regardless of setting. + 3. Made work to a greater extent with the MyMobile theme - not quite as the theme intends as all changes within CT. + 4. Tidied up left and right sides to be language specific when not editing for variations in the words 'Topic' and 'Week'. + 5. Optimised open and close all toggles such that persistence is now only one AJAX call to update the user preferences instead + of one per section. + +27th June 2012 - Version 2.3.7rc3 - CONTRIB-3652 development - rewrite for Moodle 2.3 + 1. Put layout columns into backup and restore code. + 2. Tidy up instructions in this readme. + 3. A few slight alterations for the MyMobile theme - MDL-33115. + +26th June 2012 - Version 2.3.7rc2 - CONTRIB-3652 development - rewrite for Moodle 2.3 + 1. Removed line that was related to the cookie functionality - thanks Hartmut Scherer and Kyle Smith on + http://moodle.org/mod/forum/discuss.php?d=204705. + 2. Removed cookie consent code from lib.php. + 3. To keep things clean for what will be a fresh install for all I have decided to remove the update code in update.php, + so if you have previously installed a beta version please kindly follow step 4 of the 'Uninstallation Instructions' above + after updating your code but before clicking on 'Notifications' to 'upgrade'. + 4. Request from Kyle Smith to implement the functionality of being able to reset to defaults for all Collapsed Topics courses. + I have made this for 'admins' only. + 5. Added in multi-column functionality as a layout setting. Default in config.php. Can have one to four columns. + +24th June 2012 - Version 2.3.7rc - CONTRIB-3652 development - rewrite for Moodle 2.3 + 1. Removed cookie functionality in favour of user preferences via AJAX - see MDL-17084. + 2. Updated instructions above to reflect changes. + 3. Tidied up code and removed redundant files in this branch. + +12th June 2012 - Version 2.3.7beta - CONTRIB-3652 development - rewrite for Moodle 2.3 + 1. Completed bulk of code development, now 'Beta' version for testing. + +3rd June 2012 - Version 2.3.7dev - CONTRIB-3652 development - rewrite for Moodle 2.3 + 1. Started rewrite of Collapsed Topics for Moodle 2.3 as course formats now use a completely new renderer system introduced + in MDL-32508. + 2. This branch now in 'Alpha' for stability as existing code does not work and reapplying old code in a progressive manner. + +31st May 2012 - Version 2.3.6.3 - CONTRIB-3682 + 1. Fixed issue with students not being able to perform cookie consent because of incorrect application of requiring the + capability of course update. + 2. Code change done in line with other versions but format not working with development version. + +20th May 2012 - Version 2.3.6.2.1 - CONTRIB-3655 + 1. Changes in module.js for MyMobile theme. + +14th May 2012 - Version 2.3.6.2 + 1. Fixed slight issue with version number causing 'Site Administration -> Plugins -> Plugin Overview' to fail, please + see 'http://moodle.org/mod/forum/discuss.php?d=202578'. + +3rd May 2012 - Version 2.3.6.1 + 1. Reverted back to unsigned data types in database due to error with MSSQL database code probably in core, but not essential + change at this point in time - see http://moodle.org/mod/forum/discuss.php?d=201460. + 2. Updated French translation thanks to Luiggi Sansonetti. + +1st May 2012 - Version 2.3.6 - CONTRIB-3624 + 1. Implemented code to facilitate the ability to confirm with the user that it is ok to place the cookie 'mdl_cf_topcoll' on + their computer. This fucntionality can be switched on / off through the changing of `$TCCFG->defaultcookieconsent` in the + format's 'config.php'. This functionality exists because I believe that the cookie is a 'Category 3' cookie in line with + the forthcoming UK EU Cookie Law - please see 'UK / EU Cookie Law' at the top of this file. + 2. Fixed - Changing the language on the 'Settings' form produces an invalid Moodle URL. + 3. Fixed - Toggles are open and sections displayed when JavaScript is turned off in the user's browser. + 4. A few fixes to changes made in version 2.2.5 where I had renamed table 'format_topcoll_layout' to 'format_topcoll_settings' + in the code. + 5. Created a `$TCCFG` object in the 'config.php' file to solve the 'globals' issue in 'lib.php'. + +26th April 2012 - Version 2.3.5 - CONTRIB-3529 - As suggested by [Leonie Vos](http://moodle.org/user/profile.php?id=1435066). + 1. Added the ability to set the colour attributes of the toggle. + 2. Added the ability to reset the layout and colour attributes back to the defaults as defined in the 'config.php' file. + 3. Thank you to 'Nadav Kavalerchik' for pointing out on MDL-23320 how this can be done by modifying the colour picker code + implemented by 'Iain Checkland' in his Quick Structure block + 'https://github.com/drcheckers/moodle-block_quickstructure/tree/master/blocks/quickstructure', and to 'Matthew Cannings' + on MDL-23320 for the colour validation rule. + 4. Moved JavaScript code into its own folder 'js' for neatness. + 5. Renamed 'format_topcoll_layout' table to 'format_topcoll_settings' so that it is a better representation of what it + stores. Restores from previous versions should work. Raised MDL-32650 as cannot rename the comment for the renamed + table in upgrading installations. + 6. Added an American English translation (en_us) because of the incorporation of the word 'colour'. More information on + 'http://en.wikipedia.org/wiki/American_and_British_English_spelling_differences'. I may have not got everything correct! + 7. Added an English Pirate translation (en_ar) upon discovery of the 'Pirate' treasure language pack mee hearties :). + 8. Additional language strings have been placed in the language files, where I have been unable to translate them they are in + English, if you are able to translate them into your own language I would appreciate the translation, please contact me + via Moodle - http://moodle.org/user/profile.php?id=442195. + 9. Minor tweaks to format.php for showing the correct wording over icons when in a 'weeks' structure. + 10. Discovered a minor issue with hovering over the light bulb when in a week based structure and using AJAX that it describes + 'topics' and not 'weeks', raised a point on MDL-31052 for this. Not sure how to fix yet as it is in the initialisation + code of 'section_classes.js' and overloading does not seem to work. + +21st March 2012 - Version 2.3.4.2 + 1. Received an updated version of 'format_topcoll.php' from Luiggi Sansonetti for the French translation - Merci :). + +17th March 2012 - Version 2.3.4.1 + 1. Tried with restorelib.php in the root folder for importing Moodle 1.9 courses and did not work. So for tidiness, moved the + Moodle 1.9 backup and restore code to backup/moodle1 folder. + 2. So please note that restoring Moodle 1.9 courses in this course format will not retain the structure settings and will + default to the values in 'config.php'. I hope to investigate and either fix or have this fixed. + 3. Release '2012030100.02' of Moodle 2.3dev converted all tables to have signed integers in the function + 'upgrade_mysql_fix_unsigned_columns()' in '/lib/db/upgradelib.php' called from 'upgrade.php' in the same folder. This + included 'format_topcoll_layout' because of the code was written. This made it very difficult for me to create an + effective upgrade in my own 'upgrade.php' because I would be converting what had already been converted if the format was + installed and you were updating Moodle 2.3dev but if you install for the first time, the code has been written as such to + have signed fields. Therefore if you have previously installed this format for Moodle 2.3, please remove the table + 'format_topcoll_layout' from your database before upgrading. This is not quite brilliant, but I consider reasonable for + this development version at this stage. + 4. Implemented the change in 'format.php' introduced by MDL-31255, therefore you now require Moodle 2.3 version + '2012031500.00'. + +15th March 2012 - Version 2.3.4 - CONTRIB-3520 - Stable. + 1. Completed files for 1.9 and placed in the root folder of the format in the hope that they are executed by the upgrade + restoring code as they are in the Moodle 1.9 version of this issue. I think it is a Moodle core coding issue that they are + not called in Moodle 2.x+ when importing a Moodle 1.9 course backup - need to investigate. + 2. Translated the words 'Topic' and 'Week' in all language files so that the toggle bar is correct in all structures. If you + are a native speaker I would appreciate translation of the rest as Google Translate is not so good with long sentences. + 3. Added backup and restore instructions to this file. + +14th March 2012 - Version 2.3.4 - BETA - CONTRIB-3520. + 1. Added backup and restore functionality. If required when restoring a course 'Overwrite course configuration' needs to be + 'Yes' to set the structure and elements correctly. + 2. Added the function 'format_topcoll_delete_course' in 'lib.php' which will remove the entry in the 'format_topcoll_layout' + table for the course when it is deleted. + 3. Added language strings to the language files that were missing previous changes. Still in English at the moment in the + hope a native speaker will translate them for me. I intend to translate the basics like 'Topic' and 'Week' though before + release in line with what was already there. + +2nd March 2012 - Version 2.3.3.1 + 1. Minor fix to ensure consistent use of $coursecontext and not $context. + +29th February 2012 - Version 2.3.3 - Release Candidate 4 + 1. Updated Spanish language files thanks to Carlos Sánchez Martín. + 2. Added setting default layout and structure to installation instructions. + 3. Decided to have '$formcourselayoutstrutures' out of config.php to prevent possible future user error. + 4. Spotted a minor issue with changing language whilst on the 'Set Layout' form. Added to known issues as very minor and rare + as almost certainly the user will not have changed language on this form but would have done so beforehand. + 5. Fixed duplicate entry issue in 'course_sections' table when the default structure is 'Current Topic First' and a new course + is created. + +1st March 2012 - Version 2.3.3 - Stable + 1. Integrated Git Branch CONTRIB-3378 into stable branch master. + 2. NOTE: If you have previously installed a Beta or Release Candidate please drop the table 'format_topcoll_layout' before use. + 3. Removed redundant lib.js and lib_min.js in this branch. + +28th February 2012 - Version 2.3.3 - Release Candidate 3 + 1. Tidied up 'module.js' to be more efficient in using the YUI instance given. + 2. Updated installation and toggle state instructions. + 3. Added uninstall procedure in the unlikely event that you need it. + +28th February 2012 - Version 2.3.3 - Release Candidate 2 + 1. Added 'Current Topic First' as a new structure as suggested by ['Hartmut Scherer'] + (http://moodle.org/user/view.php?id=441502) on discussion 'Collapsed Topics with Custom Layouts' + (http://moodle.org/mod/forum/discuss.php?d=195292). + 2. Fixed an issue in moving to js_init_call() in RC 1 and then followed the + ['JavaScript guidelines'](http://docs.moodle.org/dev/JavaScript_guidelines) and + ['How to include javascript file in a new course format?'](http://moodle.org/mod/forum/discuss.php?d=169124) + to understand how to transition to using 'module.js' correctly. Still going to include 'tc_section_classes_min.js' + using the old way until I can figure out how to do this the new way. + 3. 'lib.js' and 'lib_min.js' will remain for reference until I backport the code to the Moodle 1.9 version which does not + follow the changes in '2' and work out how to merge in Git and not have those files removed in that branch. + 4. In 'Show only section x' mode the 'Open / Close all toggles' option is not shown as not really appropriate. + 5. Topic structure now opens current section by default in the same way as the weekly ones. + 6. Changed name of 'Latest First' to 'Latest Week First' to be clearer. + +NOTE: If uninstallation fails, drop the table 'format_topcoll_layout' and the entry for 'format_topcoll' in the table + 'config_plugins' where tables are with the prefix you use, the default being 'mdl_'. Then delete the installation folder + and replace with the current stable version. + +25th February 2012 - Version 2.3.3 - Release Candidate 1 + 1. Added help information to the drop down options on the set layout form. + 2. Tidied up to be consistent and use less words where required. + 3. In format.php changed from depreciated `js_function_call()` to `js_init_call()`. + 4. If you have previously installed a beta version you will need to drop the table 'format_topcoll_layout' in the database. + 5. If you are a native speaker of a language other than English, I would be grateful of a translation of the new language + strings in 'lang/en/format_topcoll.php' under the comment 'Layout enhancement - Moodle Tracker CONTRIB-3378'. Please + message me using the details in my Moodle profile 'http://moodle.org/user/profile.php?id=442195'. + +18th February 2012 - Version 2.3.3 - BETA 8 + 1. CONTRIB-3225 - Added screen reader capability using 'h3' tags, the same as the standard Topics format. + +15th February 2012 - Version 2.3.3 - BETA 7 + 1. Added strings for MDL-26105 in format_topcoll.php. + 2. Used non-depreciated 'create_table' method in 'upgrade.php'. + 3. Finally worked out how to ensure that the 'Settings Block' displays the course and not front page administration by using + `require_login($course)`. + +12th February 2012 - Version 2.3.3 - BETA 6 + 1. Fixed CONTRIB-3283 in lib.js (and hence lib_min.js) for when you are in display only 'Section x' mode and the number of + sections is reduced, you go back to the course with a section number for you in the database that no longer exists and the + 'Jump to...' drop down box does not work. Leading to having to change the database or the value of 'ctopics' in the URL to + that of a valid one. + 2. Added 'callback_topcoll_get_section_url' in 'lib.php' for MDL-26477. + 3. Corrected slight mistake with version number. + +11th February 2012 - Version 2.3.3 - BETA 5 + 1. Implemented the capability to have different 'structures' thereby encapsulating the 'Collapsed Weeks' and 'Latest First' + formats into this one. + 2. If you have previously installed this development, you need to drop the table 'format_topcoll_layout' in your database to + upgrade as I do not wish to have a complicated upgrade.php in the db folder at this stage whilst development continues. + 3. As a consequence of some changes, the Spanish translation now needs fixing, sorry Carlos. + +8th February 2012 - Version 2.3.3 - BETA 4 + 1. A big thank you to [Andrew Nicols](http://moodle.org/user/view.php?id=268794) for his contribution on the developer forum + http://moodle.org/mod/forum/discuss.php?d=195293. + 2. Implemented the fixes and suggestions to tidy up the code as specified by Andrew above. + 3. Implemented Spanish translations thanks to [Carlos Sánchez Martín](http://moodle.org/user/profile.php?id=743362). + +5th February 2012 - Version 2.3.3 - BETA 3 + 1. A big thank you to [Carlos Sánchez Martín](http://moodle.org/user/profile.php?id=743362) spotting issues in set_layout.php. + 2. Fixed issues in set_layout.php. + 3. Tidied up code to remove debug statements and development code. + 4. Created icon for setting the layout instead of words. + 5. Made strings in the English language file for the layout options and 'Set layout format'. Others to follow. + 6. Raised CONTRIB-3378 to document the development. + +4th February 2012 - Version 2.3.3 - BETA 2 + 1. A big thank you to [Carlos Sánchez Martín](http://moodle.org/user/profile.php?id=743362) for his help in discovering the + install.xml bug. + 2. Fixed issue with install.xml file, gained knowledge on uninstallation for the note below: + +2nd February 2012 - Version 2.3.3 - BETA + 1. Added capability for layouts with persistence in the database. + +23rd January 2012 - Version 2.3.2 + 1. Sorted out UTF-8 BOM issue, see MDL-31343. + 2. Added Russian translation, thanks to [Pavel Evgenjevich Timoshenko](http://moodle.org/user/profile.php?id=1322784). + +9th January 2012 - Version 2.3.1.1.2 + 1. Corrected licence to be correct one used by Moodle Plugins - thanks to {Tim Hunt](http://moodle.org/user/profile.php?id=93821). + +3rd January 2012 - Version 2.3.1.1.1 - Moodle Tracker MDL-30632 + 1. Use consistent edit section icon. + +9th December 2011 - Version 2.3.1.1 - Moodle Tracker CONTRIB-3295 + 1. Fixed issue of the web browser miscaluating the width of the content in 'editing' mode so that the sections + are less than 100%. + +8th December 2011 - Version 2.2.1 - Moodle Tracker CONTRIB-2497 + 1. Updated Brazilian translation thanks to [Tarcísio Nunes](http://moodle.org/user/profile.php?id=1149633). + 2. Changed version to relate to Moodle version, so this is for Moodle 2.2. + +11th October 2011 - Version 1.3.1 - Branched from Moodle 2.0.x version. + 1. Updated version.php to be fully populated. + 2. MDL-29188 - Formatting of section name. Causing Moodle 2.1.x branch of Collapsed Topics. + +6th October 2011 - Version 1.3 - Moodle Tracker CONTRIB-2975, CONTRIB-3189 and CONTRIB-3190. + 1. CONTRIB-2975 - AJAX support reinstated after working out a way of swapping the content as well as the toggle. Solution + sparked off by [Amanda Doughty](http://tracker.moodle.org/secure/ViewProfile.jspa?name=amanda.doughty). + 2. CONTRIB-3189 - Reported by Benn Cass that text in IE8- does not hide when the toggle is closed, solution suggested + by [Mark Ward](http://moodle.org/user/profile.php?id=489101) - please see + http://moodle.org/mod/forum/discuss.php?d=183875. + 3. CONTRIB-3190 - In realising that to make CONTRIB-2975 easier to use I suggested 'Toggle all' functionality and the + community said it was a good idea with no negative comments, please see + http://moodle.org/mod/forum/discuss.php?d=176806. + +9th June 2011 - Version 1.2.3 - Moodle Tracker CONTRIB-2975 - Unfinished. + 1. AJAX support temporarily withdrawn due to issue with moving sections and the toggle title not following. + Complex to resolve. + +30th May 2011 - Version 1.2.2 - Moodle Tracker CONTRIB-2963 + 1. Added in copyright and contact information. + +12th May 2011 - Version 1.2.1 - Fixed typo with this readme in expiring cookie duration example. + +9th May 2011 - Version 1.2 - Moodle Tracker CONTRIB-2925 + 1. Convert all language files to UTF-8 encoding. + +12th March 2011 - Version 1.1 - Moodle Tracker CONTRIB-2747 + 1. Make the toggle state last beyond the user session if desired. + 2. Changes made for MDL-25927 & MDL-23939. + 3. Because of 'displaysection' logic issue introduced with MDL-23939, I've decided to allow the showing of a single topic + regardless of being in editing mode or not. I think that the improved functionality of showing the topic fully when in + 'single topic' mode will be fine. + +Released Moodle 2.0 version. Treat as completed and out of development. +25th November 2010 - CONTRIB-1471 - Changes as follows: + 1. As Moodle 2.0 was released on the 24th November now using lib_min.js. + 2. Tidied up and removed any development code / styles that was not being used. + 3. Sorted out topic spacing for Internet Explorer 7 and below. This also has the side effect bonus of not allowing + section content to appear above the toggle when the toggle is open and closed with the mouse - reload is not affected. + This only affects Internet Explorer 7-, other web browsers work as expected. + 4. Removed   when no summary as putting in spacing that was pointless and made the section look odd. + 5. Removed redundant $timenow = time() line as not used. Strangely this is in the topic format's format.php - MDL-25417 raised. + +20th November 2010 - CONTRIB-1471 - Changes as follows: + 1. In format.php added completionlib.php include as a result of MDL-24698. + 2. In lib.php fixed non-functioning code added as a result of MDL-22647 which means that the navigation block will + correctly display the right wording for the section names: 'General' for section 0, 'Topic' for other sections + unless they have names defined by the user on the course, in which case they will be displayed. Language + changes of the 12th November will give translations for 'General' and 'Topic'. + +12th November 2010 - CONTRIB-1471 & CONTRIB-2497 - Changes as a result of MDL-25072: + 1. Movement of ajax capable stating 'code' from ajax.php to lib.php. + 2. As a consequence, ajax.php removed. + 3. Added German, French, Spanish (Spain, Mexico and International), Italian, Polish, Portuguese (Brazil too) + and Welsh. I used Google Translate! If inaccurate, please let me know! + 4. Added the string 'topcolltogglewidth' to the relevant language file and amended format.php so that + the word 'Topic' when translated fits within the toggle. + +6th November 2010 - CONTRIB-1471 - Changes as follows: + 1. ajax.php changed to add more browser support as a result of MDL-22528. + 2. format.php changed in light of MDL-24680, MDL-24895, MDL-24927. + 3. Fixed edit icon showing even when not in edit mode. A big thank you to [Peeush Bajpai] + (http://moodle.org/user/profile.php?id=1127356) - for spotting this and suggesting the fix. + 4. Added Dutch language. Thanks to [Pieter Wolters](http://moodle.org/user/profile.php?id=537037) for this. + +25th October 2010 - CONTRIB-1471 - Removal of redundant JavaScript Code. + +17th October 2010 - CONTRIB-1471 - Changes as a result of MDL-14679, MDL-20366 and MDL-24316. + 1. Removed the requirement of needing js-override-topcoll.css - to make things simpler. + 2. Tidied up some of the JavaScript to be slightly more efficient. + +24th September 2010 - CONTRIB-1471 - Changes as a result of MDL-24321 - changed object to stdClass. + +12th September 2010 - Moodle Tracker CONTRIB-2355 & CONTRIB-1471 + 1. CONTRIB-2355 - Added the ability to remove 'topic x' and the section number from being displayed. To do this, open up + format.php in a text editor - preferably with line numbers displayed - such as Notepad++ - and read the + instructions on lines 216 and 226. + 2. CONTRIB-1471 - Changes as a result of MDL-14679. + +31st July 2010 - Summary of developments towards release version as I keep pace with Moodle 2.0 changes: + 13th April 2010 - CONTRIB-1471 - Changes as a result of MDL-15252, MDL-21693 & MDL-22056. + 24th April 2010 - CONTRIB-1471 - Fixed section jump when in 'Show only topic x' mode. + 31st May 2010 - CONTRIB-1471 - thanks to Skodak in 1.120 of format.php in the topics format - 'summaryformat' attribute in + section class. + 11th June 2010 - CONTRIB-1471 as a result of MDL-22647 - Changes to Moodle 2.0 call-backs in lib.php. + 3rd July 2010 - CONTRIB-1471 as a result of MDL-20475 & MDL-22950. + 30th July 2010 - CONTRIB-1471 as a result of MDL-20628 and CONTRIB-2111 - in essence, sections now have a name attribute, so + this can be used for the topic name instead of the section summary - far better. + +5th April 2010 - Moodle Tracker CONTRIB-1952 & CONTRIB-1954 + 1. CONTRIB-1952 - Having an apostrophy in the site shortname causes the format to fail. + 2. CONTRIB-1954 - Reloading of the toggles by using JavaScript DOM events not working for the function reload_toggles, + but instead the function was being called at the end of the page regardless of the readiness state of the DOM. + +16th February 2010 - Moodle Tracker CONTRIB-1825 + 1. Removed the capability to 'Show topic x' unless editing as confusing to users. + 2. Removed redundant 'aToggle' as existing `$course->numsections` already contained the correct figure + and counting toggles that are displayed causes an issue when in 'Show topic x' mode as the toggle + number does not match the display number for the specific element. + 3. Removed redundant calls to `get_context_instance(CONTEXT_COURSE, $course->id)` as result already + stored in $context variable towards the top - so use in more places. + +23rd January 2010 - Moodle Tracler CONTRIB-1756 + 1. Put instructions in the CSS file 'topics_collapsed.css' on how you can define theme based toggle colours. + 2. Redesigned the arrow to be more 'modern'. + +24th August 2009 - + 1. Removed duplication in section name. + 2. Tidied up format.php to be XHTML strict in line with http://docs.moodle.org/en/Development:JavaScript_guidelines - + but I will need to revisit this at the end of development to tidy up any unintentional introduced issues & + adapt to have a non-javascript functionality where all the contents of the toggles are shown and the toggles do + not exist. + 3. Converted to using the Page Requirements Manager ($PAGE) as much as possible for JavaScript. + +Development Notes: +21st August 2009 - + 1. Fully comment code for future reference. + 2. Please see the documentation on http://docs.moodle.org/en/Collapsed_Topics_course_format + +16th July 2009 - Moodle 2.0 Development Version + This is now the 2.0 development version under the HEAD CVS Tag. + +15th July 2009 - Version 1.3 - Visual tidy up and Javascript file reduction! + 1. Moved the prefix words of 'Topic x' to the right hand side of the toggle when the summary exists. + 2. Compressed the lib.js into lib_min.js for faster loading using YUICompressor - original source still available. + 3. Moved as much as possible into css so that the files can be cached by the web browser and less transmitted in + terms of HTML. + 4. Sorted out the way the topic table is constructed in terms of column widths to be more robust on different + web browsers. Tested on a Vista PC with: FireFox 3.5, IE 8.0.6001.18783 in both normal and compatibility + modes, Google Chrome 2.0.172.33, Safari 4.0 (530.17) and Opera 9.64 build 10487. + +28th June 2009 - Version 1.2 - Persistence - tested on Moodle 1.9.5. + 1. Persistence is session based on a per user per course basis. + 2. Cookies must be enabled for it to work. + 3. I need to tidy up the code and remove the development comments. + 4. I would like to slightly alter the binary string to be an array. + 5. I would like to make the lib.js functions a part of a class for future proofing. + 6. Sort out page refresh event so that it works instead of saving the cookie every time a toggle is toggled. + +3rd March 2009 - Version 1.1 + Adjusted the Topic Toggle to make the topic summary standout more. + +2nd March 2009 - Version 1.0 + +1st March 2009 - Version 0.2 + +21st February 2009 - Version 0.1 + +Thanks +====== +I would like to thank Anthony Borrow - arborrow@jesuits.net & anthony@moodle.org - for his invaluable input. + +Craig Grannell of Snub Communications who wrote the article on Collapsed Tables in .Net Magazine Issue 186 from whom +the original code is based and concept used with his permission. + +For the persistence upgrade I would like to thank all those who contributed to the +[developer forum](http://moodle.org/mod/forum/discuss.php?d=124264) - Frank Ralf, Matt Gibson, Howard Miller and Tim Hunt. And +indeed all those who have worked on the developer documentation - http://docs.moodle.org/en/Javascript_FAQ. + +Michael de Raadt for CONTRIB-1945 & 1946 which sparked fixes in CONTRIB-1952 & CONTRIB-1954. + +[Amanda Doughty](http://moodle.org/user/profile.php?id=1062329) for her contribution in solving the AJAX move problem. + +[Mark Ward](http://moodle.org/user/profile.php?id=489101) for his contribution solving the IE8- display problem. + +[Pieter Wolters](http://moodle.org/user/profile.php?id=537037) - for the Dutch translation. + +[Tarcísio Nunes](http://moodle.org/user/profile.php?id=1149633) - for the Brazilian translation. + +[Pavel Evgenjevich Timoshenko](http://moodle.org/user/profile.php?id=1322784) - for the Russian translation. + +All of the developers of the [Grid Course format](https://github.com/PukunuiAustralia/moodle-courseformat_grid) for showing how +the database can be used with a course format. + +[Carlos Sánchez Martín](http://moodle.org/user/profile.php?id=743362) for his assistance on CONTRIB-3378 and the +Spanish translation. + +[Andrew Nicols](http://moodle.org/user/view.php?id=268794) for his assistance on CONTRIB-3378. + +[Hartmut Scherer](http://moodle.org/user/view.php?id=441502) for suggesting the 'Current Topic First' structure and testing the +Moodle 2.2 code on discussion [Collapsed Topics with Custom Layouts](http://moodle.org/mod/forum/discuss.php?d=195292). + +[Luiggi Sansonetti](http://moodle.org/user/profile.php?id=1297063) for the French translation. + +References +========== +.Net Magazine Issue 186 - Article on Collapsed Tables by Craig Grannell - + http://www.netmag.co.uk/zine/latest-issue/issue-186 + +Craig Grannell - http://www.snubcommunications.com/ + +Accordion Format - Initiated the thought - http://moodle.org/mod/forum/discuss.php?d=44773 & + http://www.moodleman.net/archives/47 + +Paint.Net - http://www.getpaint.net/ + +JavaScript: The Definitive Guide - David Flanagan - O'Reilly - ISBN: 978-0-596-10199-2 + +Desired Enhancements +==================== +1. Smoother animated toggle action. +2. Toggle saving only when the user closes the window / moves to another course. + +Me +== +G J Barnard MSc. BSc(Hons)(Sndw). MBCS. CEng. CITP. PGCE. +Moodle profile: http://moodle.org/user/profile.php?id=442195. +Web profile : http://about.me/gjbarnard diff --git a/db/access.php b/db/access.php index e7893575..9aaf2487 100644 --- a/db/access.php +++ b/db/access.php @@ -1 +1,74 @@ -. /** * Collapsed Topics Information * * A topic based format that solves the issue of the 'Scroll of Death' when a course has many topics. All topics * except zero have a toggle that displays that topic. One or more topics can be displayed at any given time. * Toggles are persistent on a per browser session per course basis but can be made to persist longer by a small * code change. Full installation instructions, code adaptions and credits are included in the 'Readme.txt' file. * * @package course/format * @subpackage topcoll * @version See the value of '$plugin->version' in below. * @copyright © 2012-onwards G J Barnard in respect to modifications of standard topics format. * @author G J Barnard - gjbarnard at gmail dot com and {@link http://moodle.org/user/profile.php?id=442195} * @link http://docs.moodle.org/en/Collapsed_Topics_course_format * @license http://www.gnu.org/copyleft/gpl.html GNU Public License * */ defined('MOODLE_INTERNAL') || die(); $capabilities = array( 'format/topcoll:changelayout' => array( 'captype' => 'write', 'contextlevel' => CONTEXT_COURSE, 'archetypes' => array( 'editingteacher' => CAP_ALLOW, 'manager' => CAP_ALLOW ) ), 'format/topcoll:changecolour' => array( 'captype' => 'write', 'contextlevel' => CONTEXT_COURSE, 'archetypes' => array( 'editingteacher' => CAP_ALLOW, 'manager' => CAP_ALLOW ) ), 'format/topcoll:changetogglealignment' => array( 'captype' => 'write', 'contextlevel' => CONTEXT_COURSE, 'archetypes' => array( 'editingteacher' => CAP_ALLOW, 'manager' => CAP_ALLOW ) ), 'format/topcoll:changetoggleiconset' => array( 'captype' => 'write', 'contextlevel' => CONTEXT_COURSE, 'archetypes' => array( 'editingteacher' => CAP_ALLOW, 'manager' => CAP_ALLOW ) ) ); \ No newline at end of file +. + +/** + * Collapsed Topics Information + * + * A topic based format that solves the issue of the 'Scroll of Death' when a course has many topics. All topics + * except zero have a toggle that displays that topic. One or more topics can be displayed at any given time. + * Toggles are persistent on a per browser session per course basis but can be made to persist longer by a small + * code change. Full installation instructions, code adaptions and credits are included in the 'Readme.txt' file. + * + * @package course/format + * @subpackage topcoll + * @version See the value of '$plugin->version' in below. + * @copyright © 2012-onwards G J Barnard in respect to modifications of standard topics format. + * @author G J Barnard - gjbarnard at gmail dot com and {@link http://moodle.org/user/profile.php?id=442195} + * @link http://docs.moodle.org/en/Collapsed_Topics_course_format + * @license http://www.gnu.org/copyleft/gpl.html GNU Public License + * + */ + +defined('MOODLE_INTERNAL') || die(); + +$capabilities = array( + + 'format/topcoll:changelayout' => array( + 'captype' => 'write', + 'contextlevel' => CONTEXT_COURSE, + 'archetypes' => array( + 'editingteacher' => CAP_ALLOW, + 'manager' => CAP_ALLOW + ) + ), + + 'format/topcoll:changecolour' => array( + 'captype' => 'write', + 'contextlevel' => CONTEXT_COURSE, + 'archetypes' => array( + 'editingteacher' => CAP_ALLOW, + 'manager' => CAP_ALLOW + ) + ), + + 'format/topcoll:changetogglealignment' => array( + 'captype' => 'write', + 'contextlevel' => CONTEXT_COURSE, + 'archetypes' => array( + 'editingteacher' => CAP_ALLOW, + 'manager' => CAP_ALLOW + ) + ), + + 'format/topcoll:changetoggleiconset' => array( + 'captype' => 'write', + 'contextlevel' => CONTEXT_COURSE, + 'archetypes' => array( + 'editingteacher' => CAP_ALLOW, + 'manager' => CAP_ALLOW + ) + ) +); \ No newline at end of file diff --git a/format.js b/format.js index cc870e01..2fd1935b 100644 --- a/format.js +++ b/format.js @@ -1,134 +1,132 @@ -/** - * Collapsed Topics Information - * - * A topic based format that solves the issue of the 'Scroll of Death' when a course has many topics. All topics - * except zero have a toggle that displays that topic. One or more topics can be displayed at any given time. - * Toggles are persistent on a per browser session per course basis but can be made to persist longer by a small - * code change. Full installation instructions, code adaptions and credits are included in the 'Readme.txt' file. - * - * @package course/format - * @subpackage topcoll - * @version See the value of '$plugin->version' in version.php. - * @copyright © 2012-onwards G J Barnard in respect to modifications of standard topics format. - * @author G J Barnard - gjbarnard at gmail dot com and {@link http://moodle.org/user/profile.php?id=442195} - * @link http://docs.moodle.org/en/Collapsed_Topics_course_format - * @license http://www.gnu.org/copyleft/gpl.html GNU Public License - * - * 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 . - */ - -M.course = M.course || {}; - -M.course.format = M.course.format || {}; - -/** - * Get sections config for this format - * - * The section structure is: - *
    - *
  • ...
  • - *
  • ...
  • - * ... - *
- * - * @return {object} section list configuration - */ -M.course.format.get_config = function() { - return { - container_node : 'ul', - container_class : 'ctopics', - section_node : 'li', - section_class : 'section' - }; -} - -/** - * Swap section - * - * @param {YUI} Y YUI3 instance. - * @param {string} node1 node to swap to. - * @param {string} node2 node to swap with. - * @return {NodeList} section list. - */ -M.course.format.swap_sections = function(Y, node1, node2) { - var CSS = { - COURSECONTENT : '.course-content', - SECTIONADDMENUS : '.section_add_menus' - }; - - var sectionlist = Y.Node.all(CSS.COURSECONTENT + ' ' + M.course.format.get_section_selector(Y)); - // Swap menus - sectionlist.item(node1).one(CSS.SECTIONADDMENUS).swap(sectionlist.item(node2).one(CSS.SECTIONADDMENUS)); -} - - -/** - * Process sections after ajax response - * - * @param {YUI} Y YUI3 instance - * @param {array} response ajax response - * @param {string} sectionfrom first affected section - * @param {string} sectionto last affected section - * @return void - */ -M.course.format.process_sections = function(Y, sectionlist, response, sectionfrom, sectionto) { - var CSS = { - SECTIONNAME : '.the_toggle h3' - }, - SELECTORS = { - LEFTCONTENT : '.left .cps_centre', - SECTIONLEFTSIDE : '.left .section-handle img' - }; - - if (response.action == 'move') { - if (sectionfrom > sectionto) { // MDL-34798 - var temp = sectionto; - sectionto = sectionfrom; - sectionfrom = temp; - } - - // Update titles and move icons in all affected sections. - var leftcontent, ele, str, stridx, newstr; - - for (var i = sectionfrom; i <= sectionto; i++) { - // Update section title. - var content = Y.Node.create('' + response.sectiontitles[i] + ''); - sectionlist.item(i).all('.' + CSS.SECTIONNAME).setHTML(content); - // If the left content section number exists, then set it. - leftcontent = sectionlist.item(i).one(SELECTORS.LEFTCONTENT); - if (leftcontent) { // Only set if the section number is shown otherwise JS crashes and stops working. - leftcontent.setContent(i); - } - // Update move icon. MDL-37901. - ele = sectionlist.item(i).one(SELECTORS.SECTIONLEFTSIDE); - str = ele.getAttribute('alt'); - stridx = str.lastIndexOf(' '); - newstr = str.substr(0, stridx + 1) + i; - ele.setAttribute('alt', newstr); - ele.setAttribute('title', newstr); // For FireFox as 'alt' is not refreshed. - - if (response.current !== -1) { - if (sectionlist.item(i).hasClass('current')) { - // Remove the current class as section has been moved. MDL-33546. - sectionlist.item(i).removeClass('current'); - } - } - } - // If there is a current section, apply corresponding class in order to highlight it. MDL-33546. - if (response.current !== -1) { - // Add current class to the required section. - sectionlist.item(response.current).addClass('current'); - } - } -} +/** + * Collapsed Topics Information + * + * A topic based format that solves the issue of the 'Scroll of Death' when a course has many topics. All topics + * except zero have a toggle that displays that topic. One or more topics can be displayed at any given time. + * Toggles are persistent on a per browser session per course basis but can be made to persist longer by a small + * code change. Full installation instructions, code adaptions and credits are included in the 'Readme.txt' file. + * + * @package course/format + * @subpackage topcoll + * @version See the value of '$plugin->version' in version.php. + * @copyright © 2012-onwards G J Barnard in respect to modifications of standard topics format. + * @author G J Barnard - gjbarnard at gmail dot com and {@link http://moodle.org/user/profile.php?id=442195} + * @link http://docs.moodle.org/en/Collapsed_Topics_course_format + * @license http://www.gnu.org/copyleft/gpl.html GNU Public License + * + * 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 . + */ + +M.course = M.course || {}; +M.course.format = M.course.format || {}; + +/** + * Get sections config for this format + * + * The section structure is: + *
    + *
  • ...
  • + *
  • ...
  • + * ... + *
+ * + * @return {object} section list configuration + */ +M.course.format.get_config = function() { + return { + container_node : 'ul', + container_class : 'ctopics', + section_node : 'li', + section_class : 'section' + }; +}; + +/** + * Swap section + * + * @param {YUI} Y YUI3 instance. + * @param {string} node1 node to swap to. + * @param {string} node2 node to swap with. + * @return {NodeList} section list. + */ +M.course.format.swap_sections = function(Y, node1, node2) { + var CSS = { + COURSECONTENT : '.course-content', + SECTIONADDMENUS : '.section_add_menus' + }; + + var sectionlist = Y.Node.all(CSS.COURSECONTENT + ' ' + M.course.format.get_section_selector(Y)); + // Swap menus + sectionlist.item(node1).one(CSS.SECTIONADDMENUS).swap(sectionlist.item(node2).one(CSS.SECTIONADDMENUS)); +}; + +/** + * Process sections after ajax response + * + * @param {YUI} Y YUI3 instance + * @param {array} response ajax response + * @param {string} sectionfrom first affected section + * @param {string} sectionto last affected section + * @return void + */ +M.course.format.process_sections = function(Y, sectionlist, response, sectionfrom, sectionto) { + var CSS = { + SECTIONNAME : '.the_toggle h3' + }, + SELECTORS = { + LEFTCONTENT : '.left .cps_centre', + SECTIONLEFTSIDE : '.left .section-handle img' + }; + + if (response.action == 'move') { + if (sectionfrom > sectionto) { // MDL-34798 + var temp = sectionto; + sectionto = sectionfrom; + sectionfrom = temp; + } + + // Update titles and move icons in all affected sections. + var leftcontent, ele, str, stridx, newstr; + + for (var i = sectionfrom; i <= sectionto; i++) { + // Update section title. + var content = Y.Node.create('' + response.sectiontitles[i] + ''); + sectionlist.item(i).all('.' + CSS.SECTIONNAME).setHTML(content); + // If the left content section number exists, then set it. + leftcontent = sectionlist.item(i).one(SELECTORS.LEFTCONTENT); + if (leftcontent) { // Only set if the section number is shown otherwise JS crashes and stops working. + leftcontent.setContent(i); + } + // Update move icon. MDL-37901. + ele = sectionlist.item(i).one(SELECTORS.SECTIONLEFTSIDE); + str = ele.getAttribute('alt'); + stridx = str.lastIndexOf(' '); + newstr = str.substr(0, stridx + 1) + i; + ele.setAttribute('alt', newstr); + ele.setAttribute('title', newstr); // For FireFox as 'alt' is not refreshed. + + if (response.current !== -1) { + if (sectionlist.item(i).hasClass('current')) { + // Remove the current class as section has been moved. MDL-33546. + sectionlist.item(i).removeClass('current'); + } + } + } + // If there is a current section, apply corresponding class in order to highlight it. MDL-33546. + if (response.current !== -1) { + // Add current class to the required section. + sectionlist.item(response.current).addClass('current'); + } + } +}; diff --git a/format.php b/format.php index 42d2ff79..c348621a 100644 --- a/format.php +++ b/format.php @@ -1,240 +1,240 @@ -. - -/** - * Collapsed Topics Information - * - * A topic based format that solves the issue of the 'Scroll of Death' when a course has many topics. All topics - * except zero have a toggle that displays that topic. One or more topics can be displayed at any given time. - * Toggles are persistent on a per browser session per course basis but can be made to persist longer by a small - * code change. Full installation instructions, code adaptions and credits are included in the 'Readme.txt' file. - * - * @package course/format - * @subpackage topcoll - * @version See the value of '$plugin->version' in below. - * @copyright © 2009-onwards G J Barnard in respect to modifications of standard topics format. - * @author G J Barnard - gjbarnard at gmail dot com and {@link http://moodle.org/user/profile.php?id=442195} - * @link http://docs.moodle.org/en/Collapsed_Topics_course_format - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - * - */ -defined('MOODLE_INTERNAL') || die(); - -require_once($CFG->libdir . '/filelib.php'); -require_once($CFG->libdir . '/completionlib.php'); -require_once($CFG->dirroot . '/course/format/topcoll/togglelib.php'); - -// Horrible backwards compatible parameter aliasing.. -if ($ctopic = optional_param('ctopics', 0, PARAM_INT)) { // Collapsed Topics old section parameter. - $url = $PAGE->url; - $url->param('section', $ctopic); - debugging('Outdated collapsed topic param passed to course/view.php', DEBUG_DEVELOPER); - redirect($url); -} -if ($topic = optional_param('topic', 0, PARAM_INT)) { // Topics and Grid old section parameter. - $url = $PAGE->url; - $url->param('section', $topic); - debugging('Outdated topic / grid param passed to course/view.php', DEBUG_DEVELOPER); - redirect($url); -} -if ($week = optional_param('week', 0, PARAM_INT)) { // Weeks old section parameter. - $url = $PAGE->url; - $url->param('section', $week); - debugging('Outdated week param passed to course/view.php', DEBUG_DEVELOPER); - redirect($url); -} -// End backwards-compatible aliasing.. - -$context = context_course::instance($course->id); - -if (($marker >= 0) && has_capability('moodle/course:setcurrentsection', $context) && confirm_sesskey()) { - $course->marker = $marker; - course_set_marker($course->id, $marker); -} - -// Make sure all sections are created. -$courseformat = course_get_format($course); -$course = $courseformat->get_course(); -course_create_sections_if_missing($course, range(0, $course->numsections)); - -$renderer = $PAGE->get_renderer('format_topcoll'); - -$devicetype = core_useragent::get_device_type(); // In /lib/classes/useragent.php. -if ($devicetype == "mobile") { - $portable = 1; -} else if ($devicetype == "tablet") { - $portable = 2; -} else { - $portable = 0; -} -$renderer->set_portable($portable); - -if ((!empty($displaysection)) && ($course->coursedisplay == COURSE_DISPLAY_MULTIPAGE)) { - $renderer->print_single_section_page($course, null, null, null, null, $displaysection); -} else { - $defaulttogglepersistence = clean_param(get_config('format_topcoll', 'defaulttogglepersistence'), PARAM_INT); - - if ($defaulttogglepersistence == 1) { - user_preference_allow_ajax_update('topcoll_toggle_' . $course->id, PARAM_RAW); - $userpreference = get_user_preferences('topcoll_toggle_' . $course->id); - } else { - $userpreference = null; - } - $renderer->set_user_preference($userpreference); - - $defaultuserpreference = clean_param(get_config('format_topcoll', 'defaultuserpreference'), PARAM_INT); - $renderer->set_default_user_preference($defaultuserpreference); - - $PAGE->requires->js_init_call('M.format_topcoll.init', array( - $course->id, - $userpreference, - $course->numsections, - $defaulttogglepersistence, - $defaultuserpreference)); - - $tcsettings = $courseformat->get_settings(); - ?> - - print_multiple_section_page($course, null, null, null, null); -} - -// Include course format js module. -$PAGE->requires->js('/course/format/topcoll/format.js'); +. + +/** + * Collapsed Topics Information + * + * A topic based format that solves the issue of the 'Scroll of Death' when a course has many topics. All topics + * except zero have a toggle that displays that topic. One or more topics can be displayed at any given time. + * Toggles are persistent on a per browser session per course basis but can be made to persist longer by a small + * code change. Full installation instructions, code adaptions and credits are included in the 'Readme.txt' file. + * + * @package course/format + * @subpackage topcoll + * @version See the value of '$plugin->version' in below. + * @copyright © 2009-onwards G J Barnard in respect to modifications of standard topics format. + * @author G J Barnard - gjbarnard at gmail dot com and {@link http://moodle.org/user/profile.php?id=442195} + * @link http://docs.moodle.org/en/Collapsed_Topics_course_format + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + * + */ +defined('MOODLE_INTERNAL') || die(); + +require_once($CFG->libdir . '/filelib.php'); +require_once($CFG->libdir . '/completionlib.php'); +require_once($CFG->dirroot . '/course/format/topcoll/togglelib.php'); + +// Horrible backwards compatible parameter aliasing.... +if ($ctopic = optional_param('ctopics', 0, PARAM_INT)) { // Collapsed Topics old section parameter. + $url = $PAGE->url; + $url->param('section', $ctopic); + debugging('Outdated collapsed topic param passed to course/view.php', DEBUG_DEVELOPER); + redirect($url); +} +if ($topic = optional_param('topic', 0, PARAM_INT)) { // Topics and Grid old section parameter. + $url = $PAGE->url; + $url->param('section', $topic); + debugging('Outdated topic / grid param passed to course/view.php', DEBUG_DEVELOPER); + redirect($url); +} +if ($week = optional_param('week', 0, PARAM_INT)) { // Weeks old section parameter. + $url = $PAGE->url; + $url->param('section', $week); + debugging('Outdated week param passed to course/view.php', DEBUG_DEVELOPER); + redirect($url); +} +// End backwards-compatible aliasing.... + +$context = context_course::instance($course->id); + +if (($marker >= 0) && has_capability('moodle/course:setcurrentsection', $context) && confirm_sesskey()) { + $course->marker = $marker; + course_set_marker($course->id, $marker); +} + +// Make sure all sections are created. +$courseformat = course_get_format($course); +$course = $courseformat->get_course(); +course_create_sections_if_missing($course, range(0, $course->numsections)); + +$renderer = $PAGE->get_renderer('format_topcoll'); + +$devicetype = core_useragent::get_device_type(); // In /lib/classes/useragent.php. +if ($devicetype == "mobile") { + $portable = 1; +} else if ($devicetype == "tablet") { + $portable = 2; +} else { + $portable = 0; +} +$renderer->set_portable($portable); + +if ((!empty($displaysection)) && ($course->coursedisplay == COURSE_DISPLAY_MULTIPAGE)) { + $renderer->print_single_section_page($course, null, null, null, null, $displaysection); +} else { + $defaulttogglepersistence = clean_param(get_config('format_topcoll', 'defaulttogglepersistence'), PARAM_INT); + + if ($defaulttogglepersistence == 1) { + user_preference_allow_ajax_update('topcoll_toggle_' . $course->id, PARAM_RAW); + $userpreference = get_user_preferences('topcoll_toggle_' . $course->id); + } else { + $userpreference = null; + } + $renderer->set_user_preference($userpreference); + + $defaultuserpreference = clean_param(get_config('format_topcoll', 'defaultuserpreference'), PARAM_INT); + $renderer->set_default_user_preference($defaultuserpreference); + + $PAGE->requires->js_init_call('M.format_topcoll.init', array( + $course->id, + $userpreference, + $course->numsections, + $defaulttogglepersistence, + $defaultuserpreference)); + + $tcsettings = $courseformat->get_settings(); + ?> + + print_multiple_section_page($course, null, null, null, null); +} + +// Include course format js module. +$PAGE->requires->js('/course/format/topcoll/format.js'); diff --git a/js/tc_colourpopup.js b/js/tc_colourpopup.js index 4350f698..25f2453e 100644 --- a/js/tc_colourpopup.js +++ b/js/tc_colourpopup.js @@ -1,199 +1,199 @@ -// This file is part of Moodle - http://moodle.org/ -// -// Moodle is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// Moodle is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with Moodle. If not, see . - -/** - * Collapsed Topics Information - * - * A topic based format that solves the issue of the 'Scroll of Death' when a course has many topics. All topics - * except zero have a toggle that displays that topic. One or more topics can be displayed at any given time. - * Toggles are persistent on a per browser session per course basis but can be made to persist longer by a small - * code change. Full installation instructions, code adaptions and credits are included in the 'Readme.txt' file. - * - * @package course/format - * @subpackage topcoll - * @version See the value of '$plugin->version' in below. - * @copyright © 2012-onwards G J Barnard in respect to modifications of standard topics format. - * @author G J Barnard - gjbarnard at gmail dot com and {@link http://moodle.org/user/profile.php?id=442195} - * @link http://docs.moodle.org/en/Collapsed_Topics_course_format - * @license http://www.gnu.org/copyleft/gpl.html GNU Public License - * - */ - - M.util.init_tccolour_popup = function(Y, id, previewconf) { - Y.use('node', 'event-mouseenter', function(){ - /** - * The colour popup object - */ - var colourpopup = { - box : null, - input : null, - swatch : null, - image : null, - preview : null, - current : null, - eventClick : null, - eventFocus : null, - eventMouseEnter : null, - eventMouseLeave : null, - eventMouseMove : null, - width : 300, - height : 100, - factor : 5, - /** - * Initalises the colour popup by putting everything together and wiring the events - */ - init : function() { - this.input = Y.one('#' + id); - this.swatch = Y.one('#colpicked_' + id); - this.box = this.input.ancestor().one('.admin_colourpicker'); - this.image = Y.Node.create(''); - this.image.setAttribute('src', M.util.image_url('i/colourpicker', 'moodle')); - this.preview = Y.Node.create('
'); - this.preview.setStyle('width', this.height / 2).setStyle('height', this.height / 2).setStyle('backgroundColor', this.input.get('value')); - this.current = Y.Node.create('
'); - this.current.setStyle('width', this.height / 2).setStyle('height', this.height / 2 - 1).setStyle('backgroundColor', this.input.get('value')); - this.box.setContent('').append(this.image).append(this.preview).append(this.current); - //this.box.setContent(''); - - if (typeof(previewconf) === 'object' && previewconf !== null) { - Y.one('#' + id + '_preview').on('click', function(e){ - if (Y.Lang.isString(previewconf.selector)) { - Y.all(previewconf.selector).setStyle(previewconf.style, this.input.get('value')); - } else { - for (var i in previewconf.selector) { - Y.all(previewconf.selector[i]).setStyle(previewconf.style, this.input.get('value')); - } - } - }, this); - } - this.swatch.on('click',this.popup,this); - this.input.on('blur', this.setColour, this); - this.eventClick = this.image.on('click', this.pickColour, this); - this.eventMouseEnter = Y.on('mouseenter', this.startFollow, this.image, this); - }, - popup: function(e){ - this.box.ancestor().setStyle('display', 'block'); - }, - showColours : function(e){ - this.eventFocus.detach(); - this.box.setContent('').append(this.image).append(this.preview).append(this.current); - }, - setColour : function(e){ - var colour = this.input.get('value'); - this.swatch.setStyle('backgroundColor', '#' + colour); - }, - startFollow : function(e) { - this.eventMouseEnter.detach(); - this.eventMouseLeave = Y.on('mouseleave', this.endFollow, this.image, this); - this.eventMouseMove = this.image.on('mousemove', function(e){ - var colour = this.determineColour(e); - //this.swatch.setStyle('backgroundColor', colour); - this.preview.setStyle('backgroundColor', '#' + colour); - }, this); - }, - /** - * Stops following the mouse - */ - endFollow : function(e) { - this.eventMouseMove.detach(); - this.eventMouseLeave.detach(); - this.box.ancestor().setStyle('display','none'); - this.eventMouseEnter = Y.on('mouseenter', this.startFollow, this.image, this); - }, - /** - * Picks the colour the was clicked on - */ - pickColour : function(e) { - var colour = this.determineColour(e); - this.input.set('value', colour); - this.input.focus(); - this.swatch.setStyle('backgroundColor', '#' + colour); - this.current.setStyle('backgroundColor', '#' + colour); - this.box.ancestor().setStyle('display', 'none'); - }, - /** - * Calculates the colour from the given co-ordinates - */ - determineColour : function(e) { - var eventx = Math.floor(e.pageX - e.target.getX()); - var eventy = Math.floor(e.pageY - e.target.getY()); - - var imagewidth = this.width; - var imageheight = this.height; - var factor = this.factor; - var colour = [255,0,0]; - - var matrices = [ - [ 0, 1, 0], - [ -1, 0, 0], - [ 0, 0, 1], - [ 0, -1, 0], - [ 1, 0, 0], - [ 0, 0, -1] - ]; - - var matrixcount = matrices.length; - var limit = Math.round(imagewidth / matrixcount); - var heightbreak = Math.round(imageheight / 2); - - for (var x = 0; x < imagewidth; x++) { - var divisor = Math.floor(x / limit); - var matrix = matrices[divisor]; - - colour[0] += matrix[0] * factor; - colour[1] += matrix[1] * factor; - colour[2] += matrix[2] * factor; - - if (eventx == x) { - break; - } - } - - var pixel = [colour[0], colour[1], colour[2]]; - if (eventy < heightbreak) { - pixel[0] += Math.floor(((255 - pixel[0]) / heightbreak) * (heightbreak - eventy)); - pixel[1] += Math.floor(((255 - pixel[1]) / heightbreak) * (heightbreak - eventy)); - pixel[2] += Math.floor(((255 - pixel[2]) / heightbreak) * (heightbreak - eventy)); - } else if (eventy > heightbreak) { - pixel[0] = Math.floor((imageheight - eventy) * (pixel[0] / heightbreak)); - pixel[1] = Math.floor((imageheight - eventy) * (pixel[1] / heightbreak)); - pixel[2] = Math.floor((imageheight - eventy) * (pixel[2] / heightbreak)); - } - - return this.convert_rgb_to_hex(pixel); - }, - /** - * Converts an RGB value to Hex - */ - convert_rgb_to_hex : function(rgb) { - var hex = ''; - var hexchars = "0123456789ABCDEF"; - for (var i = 0; i < 3; i++) { - var number = Math.abs(rgb[i]); - if (number == 0 || isNaN(number)) { - hex += '00'; - } else { - hex += hexchars.charAt((number - number % 16) / 16) + hexchars.charAt(number % 16); - } - } - return hex; - } - }; - /** - * Initialise the colour popup :) Hoorah - */ - colourpopup.init(); - }); -}; +// This file is part of Moodle - http://moodle.org/ +// +// Moodle is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Moodle is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Moodle. If not, see . + +/** + * Collapsed Topics Information + * + * A topic based format that solves the issue of the 'Scroll of Death' when a course has many topics. All topics + * except zero have a toggle that displays that topic. One or more topics can be displayed at any given time. + * Toggles are persistent on a per browser session per course basis but can be made to persist longer by a small + * code change. Full installation instructions, code adaptions and credits are included in the 'Readme.txt' file. + * + * @package course/format + * @subpackage topcoll + * @version See the value of '$plugin->version' in below. + * @copyright © 2012-onwards G J Barnard in respect to modifications of standard topics format. + * @author G J Barnard - gjbarnard at gmail dot com and {@link http://moodle.org/user/profile.php?id=442195} + * @link http://docs.moodle.org/en/Collapsed_Topics_course_format + * @license http://www.gnu.org/copyleft/gpl.html GNU Public License + * + */ + + M.util.init_tccolour_popup = function(Y, id, previewconf) { + Y.use('node', 'event-mouseenter', function(){ + /** + * The colour popup object + */ + var colourpopup = { + box : null, + input : null, + swatch : null, + image : null, + preview : null, + current : null, + eventClick : null, + eventFocus : null, + eventMouseEnter : null, + eventMouseLeave : null, + eventMouseMove : null, + width : 300, + height : 100, + factor : 5, + /** + * Initalises the colour popup by putting everything together and wiring the events + */ + init : function() { + this.input = Y.one('#' + id); + this.swatch = Y.one('#colpicked_' + id); + this.box = this.input.ancestor().one('.admin_colourpicker'); + this.image = Y.Node.create(''); + this.image.setAttribute('src', M.util.image_url('i/colourpicker', 'moodle')); + this.preview = Y.Node.create('
'); + this.preview.setStyle('width', this.height / 2).setStyle('height', this.height / 2).setStyle('backgroundColor', this.input.get('value')); + this.current = Y.Node.create('
'); + this.current.setStyle('width', this.height / 2).setStyle('height', this.height / 2 - 1).setStyle('backgroundColor', this.input.get('value')); + this.box.setContent('').append(this.image).append(this.preview).append(this.current); + //this.box.setContent(''); + + if (typeof(previewconf) === 'object' && previewconf !== null) { + Y.one('#' + id + '_preview').on('click', function(e){ + if (Y.Lang.isString(previewconf.selector)) { + Y.all(previewconf.selector).setStyle(previewconf.style, this.input.get('value')); + } else { + for (var i in previewconf.selector) { + Y.all(previewconf.selector[i]).setStyle(previewconf.style, this.input.get('value')); + } + } + }, this); + } + this.swatch.on('click',this.popup,this); + this.input.on('blur', this.setColour, this); + this.eventClick = this.image.on('click', this.pickColour, this); + this.eventMouseEnter = Y.on('mouseenter', this.startFollow, this.image, this); + }, + popup: function(e){ + this.box.ancestor().setStyle('display', 'block'); + }, + showColours : function(e){ + this.eventFocus.detach(); + this.box.setContent('').append(this.image).append(this.preview).append(this.current); + }, + setColour : function(e){ + var colour = this.input.get('value'); + this.swatch.setStyle('backgroundColor', '#' + colour); + }, + startFollow : function(e) { + this.eventMouseEnter.detach(); + this.eventMouseLeave = Y.on('mouseleave', this.endFollow, this.image, this); + this.eventMouseMove = this.image.on('mousemove', function(e){ + var colour = this.determineColour(e); + //this.swatch.setStyle('backgroundColor', colour); + this.preview.setStyle('backgroundColor', '#' + colour); + }, this); + }, + /** + * Stops following the mouse + */ + endFollow : function(e) { + this.eventMouseMove.detach(); + this.eventMouseLeave.detach(); + this.box.ancestor().setStyle('display','none'); + this.eventMouseEnter = Y.on('mouseenter', this.startFollow, this.image, this); + }, + /** + * Picks the colour the was clicked on + */ + pickColour : function(e) { + var colour = this.determineColour(e); + this.input.set('value', colour); + this.input.focus(); + this.swatch.setStyle('backgroundColor', '#' + colour); + this.current.setStyle('backgroundColor', '#' + colour); + this.box.ancestor().setStyle('display', 'none'); + }, + /** + * Calculates the colour from the given co-ordinates + */ + determineColour : function(e) { + var eventx = Math.floor(e.pageX - e.target.getX()); + var eventy = Math.floor(e.pageY - e.target.getY()); + + var imagewidth = this.width; + var imageheight = this.height; + var factor = this.factor; + var colour = [255,0,0]; + + var matrices = [ + [ 0, 1, 0], + [ -1, 0, 0], + [ 0, 0, 1], + [ 0, -1, 0], + [ 1, 0, 0], + [ 0, 0, -1] + ]; + + var matrixcount = matrices.length; + var limit = Math.round(imagewidth / matrixcount); + var heightbreak = Math.round(imageheight / 2); + + for (var x = 0; x < imagewidth; x++) { + var divisor = Math.floor(x / limit); + var matrix = matrices[divisor]; + + colour[0] += matrix[0] * factor; + colour[1] += matrix[1] * factor; + colour[2] += matrix[2] * factor; + + if (eventx == x) { + break; + } + } + + var pixel = [colour[0], colour[1], colour[2]]; + if (eventy < heightbreak) { + pixel[0] += Math.floor(((255 - pixel[0]) / heightbreak) * (heightbreak - eventy)); + pixel[1] += Math.floor(((255 - pixel[1]) / heightbreak) * (heightbreak - eventy)); + pixel[2] += Math.floor(((255 - pixel[2]) / heightbreak) * (heightbreak - eventy)); + } else if (eventy > heightbreak) { + pixel[0] = Math.floor((imageheight - eventy) * (pixel[0] / heightbreak)); + pixel[1] = Math.floor((imageheight - eventy) * (pixel[1] / heightbreak)); + pixel[2] = Math.floor((imageheight - eventy) * (pixel[2] / heightbreak)); + } + + return this.convert_rgb_to_hex(pixel); + }, + /** + * Converts an RGB value to Hex + */ + convert_rgb_to_hex : function(rgb) { + var hex = ''; + var hexchars = "0123456789ABCDEF"; + for (var i = 0; i < 3; i++) { + var number = Math.abs(rgb[i]); + if (number == 0 || isNaN(number)) { + hex += '00'; + } else { + hex += hexchars.charAt((number - number % 16) / 16) + hexchars.charAt(number % 16); + } + } + return hex; + } + }; + /** + * Initialise the colour popup :) Hoorah + */ + colourpopup.init(); + }); +}; diff --git a/js/tc_colourpopup.php b/js/tc_colourpopup.php index 77d35a24..fc61ce10 100644 --- a/js/tc_colourpopup.php +++ b/js/tc_colourpopup.php @@ -1,132 +1,132 @@ -. - -/** - * Collapsed Topics Information - * - * A topic based format that solves the issue of the 'Scroll of Death' when a course has many topics. All topics - * except zero have a toggle that displays that topic. One or more topics can be displayed at any given time. - * Toggles are persistent on a per browser session per course basis but can be made to persist longer by a small - * code change. Full installation instructions, code adaptions and credits are included in the 'Readme.txt' file. - * - * @package course/format - * @subpackage topcoll - * @version See the value of '$plugin->version' in below. - * @copyright © 2012-onwards G J Barnard in respect to modifications of standard topics format. - * @author G J Barnard - gjbarnard at gmail dot com and {@link http://moodle.org/user/profile.php?id=442195} - * @link http://docs.moodle.org/en/Collapsed_Topics_course_format - * @license http://www.gnu.org/copyleft/gpl.html GNU Public License - * - */ -require_once("HTML/QuickForm/text.php"); - -/** - * HTML class for a colorpopup type element - * - * @author Iain Checkland - modified from ColourPicker by Jamie Pratt [thanks] - * @access public - */ -class MoodleQuickForm_tccolourpopup extends HTML_QuickForm_text { - - /* - * html for help button, if empty then no help - * - * @var string - */ - public $_helpbutton = ''; - public $_hiddenLabel = false; - - public function MoodleQuickForm_tccolourpopup($elementname = null, $elementlabel = null, $attributes = null, $options = null) { - parent::__construct($elementname, $elementlabel, $attributes); - } - - public function setHiddenLabel($hiddenLabel) { - $this->_hiddenLabel = $hiddenLabel; - } - - public function toHtml() { - global $PAGE; - $id = $this->getAttribute('id'); - $PAGE->requires->js('/course/format/topcoll/js/tc_colourpopup.js'); - $PAGE->requires->js_init_call('M.util.init_tccolour_popup', array($id)); - $colour = $this->getValue(); - if ((!empty($colour)) && ($colour[0] == '#')) { - $colour = substr($colour, 1); - } - $content = "_getAttrString($this->_attributes) . " >"; - $content .= html_writer::tag('span', ' ', array('id' => 'colpicked_' . $id, 'tabindex' => '-1', - 'style' => 'background-color:#' . $colour . - ';cursor:pointer;margin:0px;padding: 0 8px;border:1px solid black')); - $content .= html_writer::start_tag('div', array('id' => 'colpick_' . $id, - 'style' => "display:none;position:absolute;z-index:500;", - 'class' => 'form-colourpicker defaultsnext')); - $content .= html_writer::tag('div', '', array('class' => 'admin_colourpicker clearfix')); - $content .= html_writer::end_tag('div'); - return $content; - } - - /** - * Automatically generates and assigns an 'id' attribute for the element. - * - * Currently used to ensure that labels work on radio buttons and - * checkboxes. Per idea of Alexander Radivanovich. - * Overriden in moodleforms to remove qf_ prefix. - * - * @return void - */ - public function _generateId() { - static $idx = 1; - - if (!$this->getAttribute('id')) { - $this->updateAttributes(array('id' => 'id_' . substr(md5(microtime() . $idx++), 0, 6))); - } - } - - /** - * set html for help button - * - * @param array $help array of arguments to make a help button - * @param string $function function name to call to get html - */ - public function setHelpButton($helpbuttonargs, $function = 'helpbutton') { - debugging('component setHelpButton() is not used any more, please use $mform->setHelpButton() instead'); - } - - /** - * get html for help button - * - * @return string html for help button - */ - public function getHelpButton() { - return $this->_helpbutton; - } - - /** - * Slightly different container template when frozen. Don't want to use a label tag - * with a for attribute in that case for the element label but instead use a div. - * Templates are defined in renderer constructor. - * - * @return string - */ - public function getElementTemplateType() { - if ($this->_flagFrozen) { - return 'static'; - } else { - return 'default'; - } - } -} +. + +/** + * Collapsed Topics Information + * + * A topic based format that solves the issue of the 'Scroll of Death' when a course has many topics. All topics + * except zero have a toggle that displays that topic. One or more topics can be displayed at any given time. + * Toggles are persistent on a per browser session per course basis but can be made to persist longer by a small + * code change. Full installation instructions, code adaptions and credits are included in the 'Readme.txt' file. + * + * @package course/format + * @subpackage topcoll + * @version See the value of '$plugin->version' in below. + * @copyright © 2012-onwards G J Barnard in respect to modifications of standard topics format. + * @author G J Barnard - gjbarnard at gmail dot com and {@link http://moodle.org/user/profile.php?id=442195} + * @link http://docs.moodle.org/en/Collapsed_Topics_course_format + * @license http://www.gnu.org/copyleft/gpl.html GNU Public License + * + */ +require_once("HTML/QuickForm/text.php"); + +/** + * HTML class for a colorpopup type element + * + * @author Iain Checkland - modified from ColourPicker by Jamie Pratt [thanks] + * @access public + */ +class MoodleQuickForm_tccolourpopup extends HTML_QuickForm_text { + + /* + * html for help button, if empty then no help + * + * @var string + */ + public $_helpbutton = ''; + public $_hiddenLabel = false; + + public function MoodleQuickForm_tccolourpopup($elementname = null, $elementlabel = null, $attributes = null, $options = null) { + parent::__construct($elementname, $elementlabel, $attributes); + } + + public function setHiddenLabel($hiddenLabel) { + $this->_hiddenLabel = $hiddenLabel; + } + + public function toHtml() { + global $PAGE; + $id = $this->getAttribute('id'); + $PAGE->requires->js('/course/format/topcoll/js/tc_colourpopup.js'); + $PAGE->requires->js_init_call('M.util.init_tccolour_popup', array($id)); + $colour = $this->getValue(); + if ((!empty($colour)) && ($colour[0] == '#')) { + $colour = substr($colour, 1); + } + $content = "_getAttrString($this->_attributes) . " >"; + $content .= html_writer::tag('span', ' ', array('id' => 'colpicked_' . $id, 'tabindex' => '-1', + 'style' => 'background-color:#' . $colour . + ';cursor:pointer;margin:0px;padding: 0 8px;border:1px solid black')); + $content .= html_writer::start_tag('div', array('id' => 'colpick_' . $id, + 'style' => "display:none;position:absolute;z-index:500;", + 'class' => 'form-colourpicker defaultsnext')); + $content .= html_writer::tag('div', '', array('class' => 'admin_colourpicker clearfix')); + $content .= html_writer::end_tag('div'); + return $content; + } + + /** + * Automatically generates and assigns an 'id' attribute for the element. + * + * Currently used to ensure that labels work on radio buttons and + * checkboxes. Per idea of Alexander Radivanovich. + * Overriden in moodleforms to remove qf_ prefix. + * + * @return void + */ + public function _generateId() { + static $idx = 1; + + if (!$this->getAttribute('id')) { + $this->updateAttributes(array('id' => 'id_' . substr(md5(microtime() . $idx++), 0, 6))); + } + } + + /** + * set html for help button + * + * @param array $help array of arguments to make a help button + * @param string $function function name to call to get html + */ + public function setHelpButton($helpbuttonargs, $function = 'helpbutton') { + debugging('component setHelpButton() is not used any more, please use $mform->setHelpButton() instead'); + } + + /** + * get html for help button + * + * @return string html for help button + */ + public function getHelpButton() { + return $this->_helpbutton; + } + + /** + * Slightly different container template when frozen. Don't want to use a label tag + * with a for attribute in that case for the element label but instead use a div. + * Templates are defined in renderer constructor. + * + * @return string + */ + public function getElementTemplateType() { + if ($this->_flagFrozen) { + return 'static'; + } else { + return 'default'; + } + } +} diff --git a/lang/en/format_topcoll.php b/lang/en/format_topcoll.php index 2240fd75..95710768 100644 --- a/lang/en/format_topcoll.php +++ b/lang/en/format_topcoll.php @@ -1,332 +1,332 @@ -. - -/** - * Collapsed Topics Information - * - * A topic based format that solves the issue of the 'Scroll of Death' when a course has many topics. All topics - * except zero have a toggle that displays that topic. One or more topics can be displayed at any given time. - * Toggles are persistent on a per browser session per course basis but can be made to persist longer by a small - * code change. Full installation instructions, code adaptions and credits are included in the 'Readme.md' file. - * - * @package course/format - * @subpackage topcoll - * @version See the value of '$plugin->version' in below. - * @copyright © 2009-onwards G J Barnard in respect to modifications of standard topics format. - * @author G J Barnard - gjbarnard at gmail dot com and {@link http://moodle.org/user/profile.php?id=442195} - * @link http://docs.moodle.org/en/Collapsed_Topics_course_format - * @license http://www.gnu.org/copyleft/gpl.html GNU Public License - * - */ -// Used by the Moodle Core for identifing the format and displaying in the list of formats for a course in its settings. -// Possibly legacy to be removed after Moodle 2.0 is stable. -$string['nametopcoll'] = 'Collapsed Topics'; -$string['formattopcoll'] = 'Collapsed Topics'; - -// Used in format.php. -$string['topcolltoggle'] = 'Toggle'; -$string['topcollsidewidthlang'] = 'en-28px'; - -// Toggle all - Moodle Tracker CONTRIB-3190. -$string['topcollall'] = 'sections.'; // Leave as AMOS maintains only the latest translation - so previous versions are still supported. -$string['topcollopened'] = 'Open all'; -$string['topcollclosed'] = 'Close all'; - -// Moodle 2.0 Enhancement - Moodle Tracker MDL-15252, MDL-21693 & MDL-22056 - http://docs.moodle.org/en/Development:Languages. -$string['sectionname'] = 'Section'; -$string['pluginname'] = 'Collapsed Topics'; -$string['section0name'] = 'General'; - -// MDL-26105. -$string['page-course-view-topcoll'] = 'Any course main page in the collapsed topics format'; -$string['page-course-view-topcoll-x'] = 'Any course page in the collapsed topics format'; - -// Moodle 2.3 Enhancement. -$string['hidefromothers'] = 'Hide section'; -$string['showfromothers'] = 'Show section'; -$string['currentsection'] = 'This section'; -$string['editsection'] = 'Edit section'; -$string['deletesection'] = 'Delete section'; -// These are 'topic' as they are only shown in 'topic' based structures. -$string['markedthissection'] = 'This topic is highlighted as the current topic'; -$string['markthissection'] = 'Highlight this topic as the current topic'; - -// Reset. -$string['resetgrp'] = 'Reset:'; -$string['resetallgrp'] = 'Reset all:'; - -// Layout enhancement - Moodle Tracker CONTRIB-3378. -$string['formatsettings'] = 'Format reset settings'; // CONTRIB-3529. -$string['formatsettingsinformation'] = '
To reset the settings of the course format to the defaults, click on the icon to the right.'; -$string['setlayout'] = 'Set layout'; - -// Negative view of layout, kept for previous versions until such time as they are updated. -$string['setlayout_default'] = 'Default'; // 1. -$string['setlayout_no_toggle_section_x'] = 'No toggle section x'; // 2. -$string['setlayout_no_section_no'] = 'No section number'; // 3. -$string['setlayout_no_toggle_section_x_section_no'] = 'No toggle section x and section number'; // 4. -$string['setlayout_no_toggle_word'] = 'No toggle word'; // 5. -$string['setlayout_no_toggle_word_toggle_section_x'] = 'No toggle word and toggle section x'; // 6. -$string['setlayout_no_toggle_word_toggle_section_x_section_no'] = 'No toggle word, toggle section x and section number'; // 7. -// Positive view of layout. -$string['setlayout_all'] = "Toggle word, 'Topic x' / 'Week x' / 'Day x' and section number"; // 1. -$string['setlayout_toggle_word_section_number'] = 'Toggle word and section number'; // 2. -$string['setlayout_toggle_word_section_x'] = "Toggle word and 'Topic x' / 'Week x' / 'Day x'"; // 3. -$string['setlayout_toggle_word'] = 'Toggle word'; // 4. -$string['setlayout_toggle_section_x_section_number'] = "'Topic x' / 'Week x' / 'Day x' and section number"; // 5. -$string['setlayout_section_number'] = 'Section number'; // 6. -$string['setlayout_no_additions'] = 'No additions'; // 7. -$string['setlayout_toggle_section_x'] = "'Topic x' / 'Week x' / 'Day x'"; // 8. - -$string['setlayoutelements'] = 'Elements'; -$string['setlayoutstructure'] = 'Structure'; -$string['setlayoutstructuretopic'] = 'Topic'; -$string['setlayoutstructureweek'] = 'Week'; -$string['setlayoutstructurelatweekfirst'] = 'Current week first'; -$string['setlayoutstructurecurrenttopicfirst'] = 'Current topic first'; -$string['setlayoutstructureday'] = 'Day'; -$string['resetlayout'] = 'Layout'; // CONTRIB-3529. -$string['resetalllayout'] = 'Layouts'; - -// Colour enhancement - Moodle Tracker CONTRIB-3529. -$string['setcolour'] = 'Colour'; -$string['colourrule'] = "Please enter a valid RGB colour, six hexadecimal digits."; -$string['settoggleforegroundcolour'] = 'Toggle foreground'; -$string['settoggleforegroundhovercolour'] = 'Toggle foreground hover'; -$string['settogglebackgroundcolour'] = 'Toggle background'; -$string['settogglebackgroundhovercolour'] = 'Toggle background hover'; -$string['resetcolour'] = 'Colour'; -$string['resetallcolour'] = 'Colours'; - -// Columns enhancement. -$string['setlayoutcolumns'] = 'Columns'; -$string['one'] = 'One'; -$string['two'] = 'Two'; -$string['three'] = 'Three'; -$string['four'] = 'Four'; -$string['setlayoutcolumnorientation'] = 'Column orientation'; -$string['columnvertical'] = 'Vertical'; -$string['columnhorizontal'] = 'Horizontal'; - -// MDL-34917 - implemented in M2.5 but needs to be here to support M2.4- versions. -$string['maincoursepage'] = 'Main course page'; - -// Help. -$string['setlayoutelements_help'] = 'How much information about the toggles / sections you wish to be displayed.'; -$string['setlayoutstructure_help'] = "The layout structure of the course. You can choose between:
'Topics' - where each section is presented as a topic in section number order.
'Weeks' - where each section is presented as a week in ascending week order from the start date of the course.
'Current week first' - which is the same as weeks but the current week is shown at the top and preceding weeks in descending order are displayed below except in editing mode where the structure is the same as 'Weeks'.
'Current topic first' - which is the same as 'Topics' except that the current topic is shown at the top if it has been set.
'Day' - where each section is presented as a day in ascending day order from the start date of the course."; -$string['setlayout_help'] = 'Contains the settings to do with the layout of the format within the course.'; -$string['resetlayout_help'] = 'Resets the layout element, structure, columns, icon position and shown section summary to the default values so it will be the same as a course the first time it is in the \'Collapsed Topics\' format.'; -$string['resetalllayout_help'] = 'Resets the layout to the default values for all courses so it will be the same as a course the first time it is in the \'Collapsed Topics \'format.'; -// Moodle Tracker CONTRIB-3529. -$string['setcolour_help'] = 'Contains the settings to do with the colour of the format within the course.'; -$string['settoggleforegroundcolour_help'] = 'Sets the colour of the text on the toggle.'; -$string['settoggleforegroundhovercolour_help'] = 'Sets the colour of the text on the toggle when the mouse moves over it.'; -$string['settogglebackgroundcolour_help'] = 'Sets the background colour of the toggle.'; -$string['settogglebackgroundhovercolour_help'] = 'Sets the background colour of the toggle when the mouse moves over it.'; -$string['resetcolour_help'] = 'Resets the colours to the default values so it will be the same as a course the first time it is in the \'Collapsed Topics\' format.'; -$string['resetallcolour_help'] = 'Resets the colours to the default values for all courses so it will be the same as a course the first time it is in the \'Collapsed Topics\' format.'; -// Columns enhancement. -$string['setlayoutcolumns_help'] = 'How many columns to use.'; -$string['setlayoutcolumnorientation_help'] = 'Vertical - Sections go top to bottom.
Horizontal - Sections go left to right.'; - -// Moodle 2.4 Course format refactoring - MDL-35218. -$string['numbersections'] = 'Number of sections'; -$string['ctreset'] = 'Collapsed Topics reset options'; -$string['ctreset_help'] = 'Reset to Collapsed Topics defaults.'; - -// Toggle alignment - CONTRIB-4098. -$string['settogglealignment'] = 'Toggle text alignment'; -$string['settogglealignment_help'] = 'Sets the alignment of the text in the toggle.'; -$string['left'] = 'Left'; -$string['center'] = 'Centre'; -$string['right'] = 'Right'; -$string['resettogglealignment'] = 'Toggle alignment'; -$string['resetalltogglealignment'] = 'Toggle alignments'; -$string['resettogglealignment_help'] = 'Resets the toggle alignment to the default values so it will be the same as a course the first time it is in the \'Collapsed Topics\' format.'; -$string['resetalltogglealignment_help'] = 'Resets the toggle alignment to the default values for all courses so it will be the same as a course the first time it is in the \'Collapsed Topics\' format.'; - -// Icon position - CONTRIB-4470. -$string['settoggleiconposition'] = 'Icon position'; -$string['settoggleiconposition_help'] = 'States that the icon should be on the left or the right of the toggle text.'; -$string['defaulttoggleiconposition'] = 'Icon position'; -$string['defaulttoggleiconposition_desc'] = 'States if the icon should be on the left or the right of the toggle text.'; - -// Icon set enhancement. -$string['settoggleiconset'] = 'Icon set'; -$string['settoggleiconset_help'] = 'Sets the icon set of the toggle.'; -$string['settoggleallhover'] = 'Toggle all icon hover'; -$string['settoggleallhover_help'] = 'Sets if the toggle all icons will change when the mouse moves over them.'; -$string['arrow'] = 'Arrow'; -$string['bulb'] = 'Bulb'; -$string['cloud'] = 'Cloud'; -$string['eye'] = 'Eye'; -$string['groundsignal'] = 'Ground signal'; -$string['led'] = 'Light emitting diode'; -$string['point'] = 'Point'; -$string['power'] = 'Power'; -$string['radio'] = 'Radio'; -$string['smiley'] = 'Smiley'; -$string['square'] = 'Square'; -$string['sunmoon'] = 'Sun / Moon'; -$string['switch'] = 'Switch'; -$string['resettoggleiconset'] = 'Toggle icon set'; -$string['resetalltoggleiconset'] = 'Toggle icon sets'; -$string['resettoggleiconset_help'] = 'Resets the toggle icon set and toggle all hover to the default values so it will be the same as a course the first time it is in the \'Collapsed Topics\' format.'; -$string['resetalltoggleiconset_help'] = 'Resets the toggle icon set and toggle all hover to the default values for all courses so it will be the same as a course the first time it is in the \'Collapsed Topics\' format.'; - -// Site Administration -> Plugins -> Course formats -> Collapsed Topics. -$string['defaultheadingsub'] = 'Defaults'; -$string['defaultheadingsubdesc'] = 'Default settings'; -$string['configurationheadingsub'] = 'Configuration'; -$string['configurationheadingsubdesc'] = 'Configuration settings'; - -$string['off'] = 'Off'; -$string['on'] = 'On'; -$string['defaultcoursedisplay'] = 'Course display'; -$string['defaultcoursedisplay_desc'] = "Either show all the sections on a single page or section zero and the chosen section on page."; -$string['defaultlayoutelement'] = 'Layout'; -// Negative view of layout, kept for previous versions until such time as they are updated. -$string['defaultlayoutelement_desc'] = "The layout setting can be one of:
'Default' with everything displayed.
No 'Topic x' / 'Week x' / 'Day x'.
No section number.
No 'Topic x' / 'Week x' / 'Day x' and no section number.
No 'Toggle' word.
No 'Toggle' word and no 'Topic x' / 'Week x' / 'Day x'.
No 'Toggle' word, no 'Topic x' / 'Week x' / 'Day x' and no section number."; -// Positive view of layout. -$string['defaultlayoutelement_descpositive'] = "The layout setting can be one of:
Toggle word, 'Topic x' / 'Week x' / 'Day x' and section number.
Toggle word and 'Topic x' / 'Week x' / 'Day x'.
Toggle word and section number.
'Topic x' / 'Week x' / 'Day x' and section number.
Toggle word.
'Topic x' / 'Week x' / 'Day x'.
Section number.
No additions."; - -$string['defaultlayoutstructure'] = 'Structure configuration'; -$string['defaultlayoutstructure_desc'] = "The structure setting can be one of:
Topic
Week
Latest Week First
Current Topic First
Day"; - -$string['defaultlayoutcolumns'] = 'Number of columns'; -$string['defaultlayoutcolumns_desc'] = "Number of columns between one and four."; - -$string['defaultlayoutcolumnorientation'] = 'Column orientation'; -$string['defaultlayoutcolumnorientation_desc'] = "The default column orientation: Vertical or Horizontal."; - -$string['defaulttgfgcolour'] = 'Toggle foreground colour'; -$string['defaulttgfgcolour_desc'] = "Toggle foreground colour in hexidecimal RGB."; - -$string['defaulttgfghvrcolour'] = 'Toggle foreground hover colour'; -$string['defaulttgfghvrcolour_desc'] = "Toggle foreground hover colour in hexidecimal RGB."; - -$string['defaulttgbgcolour'] = 'Toggle background colour'; -$string['defaulttgbgcolour_desc'] = "Toggle background colour in hexidecimal RGB."; - -$string['defaulttgbghvrcolour'] = 'Toggle background hover colour'; -$string['defaulttgbghvrcolour_desc'] = "Toggle background hover colour in hexidecimal RGB."; - -$string['defaulttogglealignment'] = 'Toggle text alignment'; -$string['defaulttogglealignment_desc'] = "'Left', 'Centre' or 'Right'."; - -$string['defaulttoggleiconset'] = 'Toggle icon set'; -$string['defaulttoggleiconset_desc'] = "'Arrow' => Arrow icon set.
'Bulb' => Bulb icon set.
'Cloud' => Cloud icon set.
'Eye' => Eye icon set.
'Light Emitting Diode' => LED icon set.
'Point' => Point icon set.
'Power' => Power icon set.
'Radio' => Radio icon set.
'Smiley' => Smiley icon set.
'Square' => Square icon set.
'Sun / Moon' => Sun / Moon icon set.
'Switch' => Switch icon set."; - -$string['defaulttoggleallhover'] = 'Toggle all icon hovers'; -$string['defaulttoggleallhover_desc'] = "'No' or 'Yes'."; - -$string['defaulttogglepersistence'] = 'Toggle persistence'; -$string['defaulttogglepersistence_desc'] = "'On' or 'Off'. Turn off for an AJAX performance increase but user toggle selections will not be remembered on page refresh or revisit.
Note: When turning persistence off, please remove any rows containing 'topcoll_toggle_x' in the 'name' field of the 'user_preferences' table in the database. Where the 'x' in 'topcoll_toggle_x' will be a course id. This is to save space if you do not intend to turn it back on."; - -$string['defaultuserpreference'] = 'Initial toggle state'; -$string['defaultuserpreference_desc'] = 'States what to do with the toggles when the user first accesses the course, the state of additional sections when they are added or toggle persistence is off.'; - -// Toggle icon size. -$string['defaulttoggleiconsize'] = 'Toggle icon size'; -$string['defaulttoggleiconsize_desc'] = "Icon size: Small = 16px, Medium = 24px and Large = 32px."; -$string['small'] = 'Small'; -$string['medium'] = 'Medium'; -$string['large'] = 'Large'; - -// Toggle border radius. -$string['defaulttoggleborderradiustl'] = 'Toggle top left border radius'; -$string['defaulttoggleborderradiustl_desc'] = 'Border top left radius of the toggle.'; -$string['defaulttoggleborderradiustr'] = 'Toggle top right border radius'; -$string['defaulttoggleborderradiustr_desc'] = 'Border top right radius of the toggle.'; -$string['defaulttoggleborderradiusbr'] = 'Toggle bottom right border radius'; -$string['defaulttoggleborderradiusbr_desc'] = 'Border bottom right radius of the toggle.'; -$string['defaulttoggleborderradiusbl'] = 'Toggle bottom left border radius'; -$string['defaulttoggleborderradiusbl_desc'] = 'Border bottom left radius of the toggle.'; -$string['em0_0'] = '0.0em'; -$string['em0_1'] = '0.1em'; -$string['em0_2'] = '0.2em'; -$string['em0_3'] = '0.3em'; -$string['em0_4'] = '0.4em'; -$string['em0_5'] = '0.5em'; -$string['em0_6'] = '0.6em'; -$string['em0_7'] = '0.7em'; -$string['em0_8'] = '0.8em'; -$string['em0_9'] = '0.9em'; -$string['em1_0'] = '1.0em'; -$string['em1_1'] = '1.1em'; -$string['em1_2'] = '1.2em'; -$string['em1_3'] = '1.3em'; -$string['em1_4'] = '1.4em'; -$string['em1_5'] = '1.5em'; -$string['em1_6'] = '1.6em'; -$string['em1_7'] = '1.7em'; -$string['em1_8'] = '1.8em'; -$string['em1_9'] = '1.9em'; -$string['em2_0'] = '2.0em'; -$string['em2_1'] = '2.1em'; -$string['em2_2'] = '2.2em'; -$string['em2_3'] = '2.3em'; -$string['em2_4'] = '2.4em'; -$string['em2_5'] = '2.5em'; -$string['em2_6'] = '2.6em'; -$string['em2_7'] = '2.7em'; -$string['em2_8'] = '2.8em'; -$string['em2_9'] = '2.9em'; -$string['em3_0'] = '3.0em'; -$string['em3_1'] = '3.1em'; -$string['em3_2'] = '3.2em'; -$string['em3_3'] = '3.3em'; -$string['em3_4'] = '3.4em'; -$string['em3_5'] = '3.5em'; -$string['em3_6'] = '3.6em'; -$string['em3_7'] = '3.7em'; -$string['em3_8'] = '3.8em'; -$string['em3_9'] = '3.9em'; -$string['em4_0'] = '4.0em'; - -$string['formatresponsive'] = 'Format responsive'; -$string['formatresponsive_desc'] = "Turn on if you are using a non-responsive theme and the format will adjust to the screen size / device. Turn off if you are using a reponsive theme. Bootstrap 2.3.2 support is built in, for other frameworks and versions, override the methods 'get_row_class()' and 'get_column_class()' in renderer.php."; - -// Show section summary when collapsed. -$string['setshowsectionsummary'] = 'Show the section summary when collapsed'; -$string['setshowsectionsummary_help'] = 'States if the section summary will always be shown regardless of toggle state.'; -$string['defaultshowsectionsummary'] = 'Show the section summary when collapsed'; -$string['defaultshowsectionsummary_desc'] = 'States if the section summary will always be shown regardless of toggle state.'; - -// Do not show date. -$string['donotshowdate'] = 'Do not show the date'; -$string['donotshowdate_help'] = 'Do not show the date when using a weekly based structure and \'Use default section name\' has been un-ticked.'; - -// Capabilities. -$string['topcoll:changelayout'] = 'Change or reset the layout'; -$string['topcoll:changecolour'] = 'Change or reset the colour'; -$string['topcoll:changetogglealignment'] = 'Change or reset the toggle alignment'; -$string['topcoll:changetoggleiconset'] = 'Change or reset the toggle icon set'; - -// Instructions. -$string['instructions'] = 'Instructions: Clicking on the section name will show / hide the section.'; -$string['displayinstructions'] = 'Display instructions'; -$string['displayinstructions_help'] = 'States that the instructions should be displayed to the user or not.'; -$string['defaultdisplayinstructions'] = 'Display instructions to users'; -$string['defaultdisplayinstructions_desc'] = "Display instructions to users informing them how to use the toggles. Can be yes or no."; -$string['resetdisplayinstructions'] = 'Display instructions'; -$string['resetalldisplayinstructions'] = 'Display instructions'; -$string['resetdisplayinstructions_help'] = 'Resets the display instructions to the default value so it will be the same as a course the first time it is in the Collapsed Topics format.'; -$string['resetalldisplayinstructions_help'] = 'Resets the display instructions to the default value for all courses so it will be the same as a course the first time it is in the Collapsed Topics format.'; - -// Readme. -$string['readme_title'] = 'Collapsed Topics read-me'; -$string['readme_desc'] = 'Please click on \'{$a->url}\' for lots more information about Collapsed Topics.'; +. + +/** + * Collapsed Topics Information + * + * A topic based format that solves the issue of the 'Scroll of Death' when a course has many topics. All topics + * except zero have a toggle that displays that topic. One or more topics can be displayed at any given time. + * Toggles are persistent on a per browser session per course basis but can be made to persist longer by a small + * code change. Full installation instructions, code adaptions and credits are included in the 'Readme.md' file. + * + * @package course/format + * @subpackage topcoll + * @version See the value of '$plugin->version' in below. + * @copyright © 2009-onwards G J Barnard in respect to modifications of standard topics format. + * @author G J Barnard - gjbarnard at gmail dot com and {@link http://moodle.org/user/profile.php?id=442195} + * @link http://docs.moodle.org/en/Collapsed_Topics_course_format + * @license http://www.gnu.org/copyleft/gpl.html GNU Public License + * + */ +// Used by the Moodle Core for identifing the format and displaying in the list of formats for a course in its settings. +// Possibly legacy to be removed after Moodle 2.0 is stable. +$string['nametopcoll'] = 'Collapsed Topics'; +$string['formattopcoll'] = 'Collapsed Topics'; + +// Used in format.php. +$string['topcolltoggle'] = 'Toggle'; +$string['topcollsidewidthlang'] = 'en-28px'; + +// Toggle all - Moodle Tracker CONTRIB-3190. +$string['topcollall'] = 'sections.'; // Leave as AMOS maintains only the latest translation - so previous versions are still supported. +$string['topcollopened'] = 'Open all'; +$string['topcollclosed'] = 'Close all'; + +// Moodle 2.0 Enhancement - Moodle Tracker MDL-15252, MDL-21693 & MDL-22056 - http://docs.moodle.org/en/Development:Languages. +$string['sectionname'] = 'Section'; +$string['pluginname'] = 'Collapsed Topics'; +$string['section0name'] = 'General'; + +// MDL-26105. +$string['page-course-view-topcoll'] = 'Any course main page in the collapsed topics format'; +$string['page-course-view-topcoll-x'] = 'Any course page in the collapsed topics format'; + +// Moodle 2.3 Enhancement. +$string['hidefromothers'] = 'Hide section'; +$string['showfromothers'] = 'Show section'; +$string['currentsection'] = 'This section'; +$string['editsection'] = 'Edit section'; +$string['deletesection'] = 'Delete section'; +// These are 'topic' as they are only shown in 'topic' based structures. +$string['markedthissection'] = 'This topic is highlighted as the current topic'; +$string['markthissection'] = 'Highlight this topic as the current topic'; + +// Reset. +$string['resetgrp'] = 'Reset:'; +$string['resetallgrp'] = 'Reset all:'; + +// Layout enhancement - Moodle Tracker CONTRIB-3378. +$string['formatsettings'] = 'Format reset settings'; // CONTRIB-3529. +$string['formatsettingsinformation'] = '
To reset the settings of the course format to the defaults, click on the icon to the right.'; +$string['setlayout'] = 'Set layout'; + +// Negative view of layout, kept for previous versions until such time as they are updated. +$string['setlayout_default'] = 'Default'; // 1. +$string['setlayout_no_toggle_section_x'] = 'No toggle section x'; // 2. +$string['setlayout_no_section_no'] = 'No section number'; // 3. +$string['setlayout_no_toggle_section_x_section_no'] = 'No toggle section x and section number'; // 4. +$string['setlayout_no_toggle_word'] = 'No toggle word'; // 5. +$string['setlayout_no_toggle_word_toggle_section_x'] = 'No toggle word and toggle section x'; // 6. +$string['setlayout_no_toggle_word_toggle_section_x_section_no'] = 'No toggle word, toggle section x and section number'; // 7. +// Positive view of layout. +$string['setlayout_all'] = "Toggle word, 'Topic x' / 'Week x' / 'Day x' and section number"; // 1. +$string['setlayout_toggle_word_section_number'] = 'Toggle word and section number'; // 2. +$string['setlayout_toggle_word_section_x'] = "Toggle word and 'Topic x' / 'Week x' / 'Day x'"; // 3. +$string['setlayout_toggle_word'] = 'Toggle word'; // 4. +$string['setlayout_toggle_section_x_section_number'] = "'Topic x' / 'Week x' / 'Day x' and section number"; // 5. +$string['setlayout_section_number'] = 'Section number'; // 6. +$string['setlayout_no_additions'] = 'No additions'; // 7. +$string['setlayout_toggle_section_x'] = "'Topic x' / 'Week x' / 'Day x'"; // 8. + +$string['setlayoutelements'] = 'Elements'; +$string['setlayoutstructure'] = 'Structure'; +$string['setlayoutstructuretopic'] = 'Topic'; +$string['setlayoutstructureweek'] = 'Week'; +$string['setlayoutstructurelatweekfirst'] = 'Current week first'; +$string['setlayoutstructurecurrenttopicfirst'] = 'Current topic first'; +$string['setlayoutstructureday'] = 'Day'; +$string['resetlayout'] = 'Layout'; // CONTRIB-3529. +$string['resetalllayout'] = 'Layouts'; + +// Colour enhancement - Moodle Tracker CONTRIB-3529. +$string['setcolour'] = 'Colour'; +$string['colourrule'] = "Please enter a valid RGB colour, six hexadecimal digits."; +$string['settoggleforegroundcolour'] = 'Toggle foreground'; +$string['settoggleforegroundhovercolour'] = 'Toggle foreground hover'; +$string['settogglebackgroundcolour'] = 'Toggle background'; +$string['settogglebackgroundhovercolour'] = 'Toggle background hover'; +$string['resetcolour'] = 'Colour'; +$string['resetallcolour'] = 'Colours'; + +// Columns enhancement. +$string['setlayoutcolumns'] = 'Columns'; +$string['one'] = 'One'; +$string['two'] = 'Two'; +$string['three'] = 'Three'; +$string['four'] = 'Four'; +$string['setlayoutcolumnorientation'] = 'Column orientation'; +$string['columnvertical'] = 'Vertical'; +$string['columnhorizontal'] = 'Horizontal'; + +// MDL-34917 - implemented in M2.5 but needs to be here to support M2.4- versions. +$string['maincoursepage'] = 'Main course page'; + +// Help. +$string['setlayoutelements_help'] = 'How much information about the toggles / sections you wish to be displayed.'; +$string['setlayoutstructure_help'] = "The layout structure of the course. You can choose between:
'Topics' - where each section is presented as a topic in section number order.
'Weeks' - where each section is presented as a week in ascending week order from the start date of the course.
'Current week first' - which is the same as weeks but the current week is shown at the top and preceding weeks in descending order are displayed below except in editing mode where the structure is the same as 'Weeks'.
'Current topic first' - which is the same as 'Topics' except that the current topic is shown at the top if it has been set.
'Day' - where each section is presented as a day in ascending day order from the start date of the course."; +$string['setlayout_help'] = 'Contains the settings to do with the layout of the format within the course.'; +$string['resetlayout_help'] = 'Resets the layout element, structure, columns, icon position and shown section summary to the default values so it will be the same as a course the first time it is in the \'Collapsed Topics\' format.'; +$string['resetalllayout_help'] = 'Resets the layout to the default values for all courses so it will be the same as a course the first time it is in the \'Collapsed Topics \'format.'; +// Moodle Tracker CONTRIB-3529. +$string['setcolour_help'] = 'Contains the settings to do with the colour of the format within the course.'; +$string['settoggleforegroundcolour_help'] = 'Sets the colour of the text on the toggle.'; +$string['settoggleforegroundhovercolour_help'] = 'Sets the colour of the text on the toggle when the mouse moves over it.'; +$string['settogglebackgroundcolour_help'] = 'Sets the background colour of the toggle.'; +$string['settogglebackgroundhovercolour_help'] = 'Sets the background colour of the toggle when the mouse moves over it.'; +$string['resetcolour_help'] = 'Resets the colours to the default values so it will be the same as a course the first time it is in the \'Collapsed Topics\' format.'; +$string['resetallcolour_help'] = 'Resets the colours to the default values for all courses so it will be the same as a course the first time it is in the \'Collapsed Topics\' format.'; +// Columns enhancement. +$string['setlayoutcolumns_help'] = 'How many columns to use.'; +$string['setlayoutcolumnorientation_help'] = 'Vertical - Sections go top to bottom.
Horizontal - Sections go left to right.'; + +// Moodle 2.4 Course format refactoring - MDL-35218. +$string['numbersections'] = 'Number of sections'; +$string['ctreset'] = 'Collapsed Topics reset options'; +$string['ctreset_help'] = 'Reset to Collapsed Topics defaults.'; + +// Toggle alignment - CONTRIB-4098. +$string['settogglealignment'] = 'Toggle text alignment'; +$string['settogglealignment_help'] = 'Sets the alignment of the text in the toggle.'; +$string['left'] = 'Left'; +$string['center'] = 'Centre'; +$string['right'] = 'Right'; +$string['resettogglealignment'] = 'Toggle alignment'; +$string['resetalltogglealignment'] = 'Toggle alignments'; +$string['resettogglealignment_help'] = 'Resets the toggle alignment to the default values so it will be the same as a course the first time it is in the \'Collapsed Topics\' format.'; +$string['resetalltogglealignment_help'] = 'Resets the toggle alignment to the default values for all courses so it will be the same as a course the first time it is in the \'Collapsed Topics\' format.'; + +// Icon position - CONTRIB-4470. +$string['settoggleiconposition'] = 'Icon position'; +$string['settoggleiconposition_help'] = 'States that the icon should be on the left or the right of the toggle text.'; +$string['defaulttoggleiconposition'] = 'Icon position'; +$string['defaulttoggleiconposition_desc'] = 'States if the icon should be on the left or the right of the toggle text.'; + +// Icon set enhancement. +$string['settoggleiconset'] = 'Icon set'; +$string['settoggleiconset_help'] = 'Sets the icon set of the toggle.'; +$string['settoggleallhover'] = 'Toggle all icon hover'; +$string['settoggleallhover_help'] = 'Sets if the toggle all icons will change when the mouse moves over them.'; +$string['arrow'] = 'Arrow'; +$string['bulb'] = 'Bulb'; +$string['cloud'] = 'Cloud'; +$string['eye'] = 'Eye'; +$string['groundsignal'] = 'Ground signal'; +$string['led'] = 'Light emitting diode'; +$string['point'] = 'Point'; +$string['power'] = 'Power'; +$string['radio'] = 'Radio'; +$string['smiley'] = 'Smiley'; +$string['square'] = 'Square'; +$string['sunmoon'] = 'Sun / Moon'; +$string['switch'] = 'Switch'; +$string['resettoggleiconset'] = 'Toggle icon set'; +$string['resetalltoggleiconset'] = 'Toggle icon sets'; +$string['resettoggleiconset_help'] = 'Resets the toggle icon set and toggle all hover to the default values so it will be the same as a course the first time it is in the \'Collapsed Topics\' format.'; +$string['resetalltoggleiconset_help'] = 'Resets the toggle icon set and toggle all hover to the default values for all courses so it will be the same as a course the first time it is in the \'Collapsed Topics\' format.'; + +// Site Administration -> Plugins -> Course formats -> Collapsed Topics. +$string['defaultheadingsub'] = 'Defaults'; +$string['defaultheadingsubdesc'] = 'Default settings'; +$string['configurationheadingsub'] = 'Configuration'; +$string['configurationheadingsubdesc'] = 'Configuration settings'; + +$string['off'] = 'Off'; +$string['on'] = 'On'; +$string['defaultcoursedisplay'] = 'Course display'; +$string['defaultcoursedisplay_desc'] = "Either show all the sections on a single page or section zero and the chosen section on page."; +$string['defaultlayoutelement'] = 'Layout'; +// Negative view of layout, kept for previous versions until such time as they are updated. +$string['defaultlayoutelement_desc'] = "The layout setting can be one of:
'Default' with everything displayed.
No 'Topic x' / 'Week x' / 'Day x'.
No section number.
No 'Topic x' / 'Week x' / 'Day x' and no section number.
No 'Toggle' word.
No 'Toggle' word and no 'Topic x' / 'Week x' / 'Day x'.
No 'Toggle' word, no 'Topic x' / 'Week x' / 'Day x' and no section number."; +// Positive view of layout. +$string['defaultlayoutelement_descpositive'] = "The layout setting can be one of:
Toggle word, 'Topic x' / 'Week x' / 'Day x' and section number.
Toggle word and 'Topic x' / 'Week x' / 'Day x'.
Toggle word and section number.
'Topic x' / 'Week x' / 'Day x' and section number.
Toggle word.
'Topic x' / 'Week x' / 'Day x'.
Section number.
No additions."; + +$string['defaultlayoutstructure'] = 'Structure configuration'; +$string['defaultlayoutstructure_desc'] = "The structure setting can be one of:
Topic
Week
Latest Week First
Current Topic First
Day"; + +$string['defaultlayoutcolumns'] = 'Number of columns'; +$string['defaultlayoutcolumns_desc'] = "Number of columns between one and four."; + +$string['defaultlayoutcolumnorientation'] = 'Column orientation'; +$string['defaultlayoutcolumnorientation_desc'] = "The default column orientation: Vertical or Horizontal."; + +$string['defaulttgfgcolour'] = 'Toggle foreground colour'; +$string['defaulttgfgcolour_desc'] = "Toggle foreground colour in hexidecimal RGB."; + +$string['defaulttgfghvrcolour'] = 'Toggle foreground hover colour'; +$string['defaulttgfghvrcolour_desc'] = "Toggle foreground hover colour in hexidecimal RGB."; + +$string['defaulttgbgcolour'] = 'Toggle background colour'; +$string['defaulttgbgcolour_desc'] = "Toggle background colour in hexidecimal RGB."; + +$string['defaulttgbghvrcolour'] = 'Toggle background hover colour'; +$string['defaulttgbghvrcolour_desc'] = "Toggle background hover colour in hexidecimal RGB."; + +$string['defaulttogglealignment'] = 'Toggle text alignment'; +$string['defaulttogglealignment_desc'] = "'Left', 'Centre' or 'Right'."; + +$string['defaulttoggleiconset'] = 'Toggle icon set'; +$string['defaulttoggleiconset_desc'] = "'Arrow' => Arrow icon set.
'Bulb' => Bulb icon set.
'Cloud' => Cloud icon set.
'Eye' => Eye icon set.
'Light Emitting Diode' => LED icon set.
'Point' => Point icon set.
'Power' => Power icon set.
'Radio' => Radio icon set.
'Smiley' => Smiley icon set.
'Square' => Square icon set.
'Sun / Moon' => Sun / Moon icon set.
'Switch' => Switch icon set."; + +$string['defaulttoggleallhover'] = 'Toggle all icon hovers'; +$string['defaulttoggleallhover_desc'] = "'No' or 'Yes'."; + +$string['defaulttogglepersistence'] = 'Toggle persistence'; +$string['defaulttogglepersistence_desc'] = "'On' or 'Off'. Turn off for an AJAX performance increase but user toggle selections will not be remembered on page refresh or revisit.
Note: When turning persistence off, please remove any rows containing 'topcoll_toggle_x' in the 'name' field of the 'user_preferences' table in the database. Where the 'x' in 'topcoll_toggle_x' will be a course id. This is to save space if you do not intend to turn it back on."; + +$string['defaultuserpreference'] = 'Initial toggle state'; +$string['defaultuserpreference_desc'] = 'States what to do with the toggles when the user first accesses the course, the state of additional sections when they are added or toggle persistence is off.'; + +// Toggle icon size. +$string['defaulttoggleiconsize'] = 'Toggle icon size'; +$string['defaulttoggleiconsize_desc'] = "Icon size: Small = 16px, Medium = 24px and Large = 32px."; +$string['small'] = 'Small'; +$string['medium'] = 'Medium'; +$string['large'] = 'Large'; + +// Toggle border radius. +$string['defaulttoggleborderradiustl'] = 'Toggle top left border radius'; +$string['defaulttoggleborderradiustl_desc'] = 'Border top left radius of the toggle.'; +$string['defaulttoggleborderradiustr'] = 'Toggle top right border radius'; +$string['defaulttoggleborderradiustr_desc'] = 'Border top right radius of the toggle.'; +$string['defaulttoggleborderradiusbr'] = 'Toggle bottom right border radius'; +$string['defaulttoggleborderradiusbr_desc'] = 'Border bottom right radius of the toggle.'; +$string['defaulttoggleborderradiusbl'] = 'Toggle bottom left border radius'; +$string['defaulttoggleborderradiusbl_desc'] = 'Border bottom left radius of the toggle.'; +$string['em0_0'] = '0.0em'; +$string['em0_1'] = '0.1em'; +$string['em0_2'] = '0.2em'; +$string['em0_3'] = '0.3em'; +$string['em0_4'] = '0.4em'; +$string['em0_5'] = '0.5em'; +$string['em0_6'] = '0.6em'; +$string['em0_7'] = '0.7em'; +$string['em0_8'] = '0.8em'; +$string['em0_9'] = '0.9em'; +$string['em1_0'] = '1.0em'; +$string['em1_1'] = '1.1em'; +$string['em1_2'] = '1.2em'; +$string['em1_3'] = '1.3em'; +$string['em1_4'] = '1.4em'; +$string['em1_5'] = '1.5em'; +$string['em1_6'] = '1.6em'; +$string['em1_7'] = '1.7em'; +$string['em1_8'] = '1.8em'; +$string['em1_9'] = '1.9em'; +$string['em2_0'] = '2.0em'; +$string['em2_1'] = '2.1em'; +$string['em2_2'] = '2.2em'; +$string['em2_3'] = '2.3em'; +$string['em2_4'] = '2.4em'; +$string['em2_5'] = '2.5em'; +$string['em2_6'] = '2.6em'; +$string['em2_7'] = '2.7em'; +$string['em2_8'] = '2.8em'; +$string['em2_9'] = '2.9em'; +$string['em3_0'] = '3.0em'; +$string['em3_1'] = '3.1em'; +$string['em3_2'] = '3.2em'; +$string['em3_3'] = '3.3em'; +$string['em3_4'] = '3.4em'; +$string['em3_5'] = '3.5em'; +$string['em3_6'] = '3.6em'; +$string['em3_7'] = '3.7em'; +$string['em3_8'] = '3.8em'; +$string['em3_9'] = '3.9em'; +$string['em4_0'] = '4.0em'; + +$string['formatresponsive'] = 'Format responsive'; +$string['formatresponsive_desc'] = "Turn on if you are using a non-responsive theme and the format will adjust to the screen size / device. Turn off if you are using a reponsive theme. Bootstrap 2.3.2 support is built in, for other frameworks and versions, override the methods 'get_row_class()' and 'get_column_class()' in renderer.php."; + +// Show section summary when collapsed. +$string['setshowsectionsummary'] = 'Show the section summary when collapsed'; +$string['setshowsectionsummary_help'] = 'States if the section summary will always be shown regardless of toggle state.'; +$string['defaultshowsectionsummary'] = 'Show the section summary when collapsed'; +$string['defaultshowsectionsummary_desc'] = 'States if the section summary will always be shown regardless of toggle state.'; + +// Do not show date. +$string['donotshowdate'] = 'Do not show the date'; +$string['donotshowdate_help'] = 'Do not show the date when using a weekly based structure and \'Use default section name\' has been un-ticked.'; + +// Capabilities. +$string['topcoll:changelayout'] = 'Change or reset the layout'; +$string['topcoll:changecolour'] = 'Change or reset the colour'; +$string['topcoll:changetogglealignment'] = 'Change or reset the toggle alignment'; +$string['topcoll:changetoggleiconset'] = 'Change or reset the toggle icon set'; + +// Instructions. +$string['instructions'] = 'Instructions: Clicking on the section name will show / hide the section.'; +$string['displayinstructions'] = 'Display instructions'; +$string['displayinstructions_help'] = 'States that the instructions should be displayed to the user or not.'; +$string['defaultdisplayinstructions'] = 'Display instructions to users'; +$string['defaultdisplayinstructions_desc'] = "Display instructions to users informing them how to use the toggles. Can be yes or no."; +$string['resetdisplayinstructions'] = 'Display instructions'; +$string['resetalldisplayinstructions'] = 'Display instructions'; +$string['resetdisplayinstructions_help'] = 'Resets the display instructions to the default value so it will be the same as a course the first time it is in the Collapsed Topics format.'; +$string['resetalldisplayinstructions_help'] = 'Resets the display instructions to the default value for all courses so it will be the same as a course the first time it is in the Collapsed Topics format.'; + +// Readme. +$string['readme_title'] = 'Collapsed Topics read-me'; +$string['readme_desc'] = 'Please click on \'{$a->url}\' for lots more information about Collapsed Topics.'; diff --git a/lang/en_ar/format_topcoll.php b/lang/en_ar/format_topcoll.php index 999356a4..70afea1a 100644 --- a/lang/en_ar/format_topcoll.php +++ b/lang/en_ar/format_topcoll.php @@ -1,229 +1,229 @@ -. - -/** - * Collapsed Topics Information - * - * A topic based format that solves the issue of the 'Scroll of Death' when a course has many topics. All topics - * except zero have a toggle that displays that topic. One or more topics can be displayed at any given time. - * Toggles are persistent on a per browser session per course basis but can be made to persist longer by a small - * code change. Full installation instructions, code adaptions and credits are included in the 'Readme.md' file. - * - * @package course/format - * @subpackage topcoll - * @version See the value of '$plugin->version' in below. - * @copyright © 2009-onwards G J Barnard in respect to modifications of standard topics format. - * @author G J Barnard - gjbarnard at gmail dot com and {@link http://moodle.org/user/profile.php?id=442195} - * @link http://docs.moodle.org/en/Collapsed_Topics_course_format - * @license http://www.gnu.org/copyleft/gpl.html GNU Public License - * - */ - -// English Pirate Translation of Collapsed Topics Course Format. - -// Used in format.php. -$string['topcollsidewidthlang'] = 'en_ar-40px'; - -// These are 'topic' as they are only shown in 'topic' based structures. -$string['markedthissection'] = 'Thy topic is illuminated as thee current topic'; -$string['markthissection'] = 'Illuminate thy topic as thee current topic'; - -// Toggle all - Moodle Tracker CONTRIB-3190. -$string['topcollopened'] = 'Untie'; -$string['topcollclosed'] = 'Tie'; - -// Layout enhancement - Moodle Tracker CONTRIB-3378. -$string['formatsettings'] = 'Ye format settings'; // CONTRIB-3529. -$string['setlayout'] = 'Thee layout'; -$string['setlayout_default'] = 'Default'; -$string['setlayoutelements'] = 'Thee elements'; -// Negative view of layout, kept for previous versions until such time as they are updated. -$string['setlayout_no_toggle_section_x'] = "Nay 'Treasure Chest x' / 'Sailing Week x' / 'Sailing Day x'"; // 2. -$string['setlayout_no_toggle_section_x_section_no'] = "Nay 'Treasure Chest x' / 'Sailing Week x' / 'Sailing Day x' and section number"; // 4. -$string['setlayout_no_toggle_word_toggle_section_x'] = "Nay toggle word and 'Treasure Chest x' / 'Sailing Week x' / 'Sailing Day x'"; // 6. -$string['setlayout_no_toggle_word_toggle_section_x_section_no'] = "Nay toggle word, 'Treasure Chest x' / 'Sailing Week x' / 'Sailing Day x' and section number"; // 7. -// Positive view of layout. -$string['setlayout_all'] = "Toggle word, 'Treasure Chest x' / 'Sailing Week x' / 'Sailing Day x' and section number"; // 1. -$string['setlayout_toggle_word_section_x'] = "Toggle word and 'Treasure Chest x' / 'Sailing Week x' / 'Sailing Day x'"; // 3. -$string['setlayout_toggle_section_x'] = "'Treasure Chest x' / 'Sailing Week x' / 'Sailing Day x' and section number"; // 5. -$string['setlayout_toggle_section_x'] = "'Treasure Chest x' / 'Sailing Week x' / 'Sailing Day x'"; // 8. - -$string['setlayoutstructure'] = 'Thee structure'; -$string['setlayoutstructuretopic'] = 'Treasure Chest'; -$string['setlayoutstructureweek'] = 'Sailing Week'; -$string['setlayoutstructureday'] = 'Sailing Day'; -$string['setlayoutstructurelatweekfirst'] = 'Current Sailing Week First'; -$string['setlayoutstructurecurrenttopicfirst'] = 'Current Treasure Chest First'; -$string['resetlayout'] = 'Thee layout'; // CONTRIB-3529. -$string['resetalllayout'] = 'Thee layouts'; - -// Colour enhancement - Moodle Tracker CONTRIB-3529. -$string['setcolour'] = 'Thee colour'; -$string['colourrule'] = "Enter a valid RGB colour, a '#' and then six hexadecimal digits or walk thy plank."; -$string['settoggleforegroundcolour'] = 'Thy toggle foreground'; -$string['settogglebackgroundhovercolour'] = 'Thy toggle foreground hover'; -$string['settoggleforegroundcolour'] = 'Thy toggle foreground'; -$string['settogglebackgroundhovercolour'] = 'Thy toggle background hover'; -$string['resetcolour'] = 'Thee colour'; -$string['resetallcolour'] = 'Thee colours'; - -// Columns enhancement. -$string['setlayoutcolumns'] = 'Thee columns'; -$string['one'] = 'One'; -$string['two'] = 'Two'; -$string['three'] = 'Three'; -$string['four'] = 'Four'; -$string['setlayoutcolumnorientation'] = 'Thee column orientation'; -$string['columnvertical'] = 'Vertical as a mast'; -$string['columnhorizontal'] = 'Horizontal as a cannon'; - -// Temporary until MDL-34917 in core. -$string['maincoursepage'] = 'Ye main course page'; - -// Help. -$string['setlayoutelements_help'] = 'How much information about thee toggles / sections you wish to be displayed.'; -$string['setlayoutstructure_help'] = "Avast ye landlubbers, this be thee layout structure of thee course. Ye choose between:
'Treasure chest' - where each section is presented as thy treasure chest in section number order.
'Sailing week' - where each section is presented as thy week in ascending week order.
'Current sailing week first' - which is the same as weeks but thee current week is shown at thee top and preceding weeks in descending order are displayed below except in editing mode where thee structure is thy same as 'Weeks'.
'Current treasure chest first' - which is thee same as 'Treasure chest' except that thee current treasure chest is shown at thee top if it has been set.
'Sailing Day' - where each section is presented as a day in thy ascending day order from thee start date of thee course."; -$string['setlayout_help'] = 'Contains thee settings to do with thee layout of the format within thy course.'; -$string['resetlayout_help'] = 'Resets thee layout to thee default so it will be the same as a course the first time it is in thy Collapsed Topics format'; -$string['resetalllayout_help'] = 'Resets the layout to the default values for all courses so it will be the same as a course the first time it is in the Collapsed Topics format.'; -// Moodle Tracker CONTRIB-3529. -$string['setcolour_help'] = 'Contains thee settings to do with thy colour of the format within the course.'; -$string['settoggleforegroundcolour_help'] = 'Sets thee colour of thy text on the toggle.'; -$string['settoggleforegroundhovercolour_help'] = 'Sets thee colour of thy text on thy toggle when thee mouse scuttles over it.'; -$string['settogglebackgroundcolour_help'] = 'Sets thee background of thy toggle.'; -$string['settogglebackgroundhovercolour_help'] = 'Sets thee background of thy toggle when thee mouse scuttles over it.'; -$string['resetcolour_help'] = 'Resets thee colours to thee default values so it will be thee same as a course thy first time it is in thee Collapsed Topics format'; -$string['resetallcolour_help'] = 'Resets thee colours to the default values for all courses so it will be thy same as a course the first time it is in thee Collapsed Topics format.'; -// Columns enhancement. -$string['setlayoutcolumns_help'] = 'How many columns to use.'; - -// Toggle alignment - CONTRIB-4098. -$string['settogglealignment'] = 'Thee toggle text alignment'; -$string['settogglealignment_help'] = 'Sets thee alignment of thee text in thy toggle.'; -$string['left'] = 'Port'; -$string['center'] = 'Midships'; -$string['right'] = 'Starboard'; -$string['resettogglealignment'] = 'Thee toggle alignment'; -$string['resetalltogglealignment'] = 'Thee toggle alignments'; -$string['resettogglealignment_help'] = 'Resets thee toggle alignment to thy default values so thy will be thy same as a course thee first time it is in thee Collapsed Topics format.'; -$string['resetalltogglealignment_help'] = 'Resets thee toggle alignment to thy default values for all courses so it will be thy same as a course thee first time it is in thee Collapsed Topics format.'; - -// Icon position - CONTRIB-4470. -$string['settoggleiconposition'] = 'Icon position'; -$string['settoggleiconposition_help'] = 'States that thee icon should be on thy left or thee right of thy toggle text.'; -$string['defaulttoggleiconposition'] = 'Icon position'; -$string['defaulttoggleiconposition_desc'] = 'States if thee icon should be on thy left or thee right of thy toggle text.'; - -// Icon set enhancement. -$string['settoggleiconset'] = 'Thee icon set'; -$string['settoggleiconset_help'] = 'Sets thee icon set of thy toggle.'; -$string['settoggleallhover'] = 'Set thee toggle all icon hover'; -$string['settoggleallhover_help'] = 'Sets if thee toggle all icons will change when thy mouse moves over them.'; -$string['arrow'] = 'Straight as an arrow'; -$string['bulb'] = 'Lantern'; -$string['cloud'] = 'Cloud'; -$string['eye'] = 'Eyeball'; -$string['led'] = 'LED from thee future'; -$string['point'] = 'Point thee bow towards thy treasure'; -$string['power'] = 'Power mee hearties'; -$string['radio'] = 'Wireless'; -$string['smiley'] = 'Smiley they bee not'; -$string['square'] = 'Square riggin'; -$string['sunmoon'] = 'Sun / Moon'; -$string['switch'] = 'Switch thy flag'; -$string['resettoggleiconset'] = 'Thee toggle icon set'; -$string['resetalltoggleiconset'] = 'Thee toggle icon sets'; -$string['resettoggleiconset_help'] = 'Resets thee toggle icon set and thy toggle all hover to thy default values so thy will be thee same as a course thee first time it is in thy Collapsed Topics format.'; -$string['resetalltoggleiconset_help'] = 'Resets thee toggle icon set and thy toggle all hover to thy default values for all courses so it will be thy same as a course thee first time it is in thy Collapsed Topics format.'; - -// Site Administration -> Plugins -> Course formats -> Collapsed Topics or Manage course formats - Settings. -$string['off'] = 'Off'; -$string['on'] = 'On'; -$string['defaultcoursedisplay'] = 'Course display default'; -$string['defaultcoursedisplay_desc'] = "Either show all thee sections on a single page or section zero and thee chosen section on page."; -$string['defaultlayoutelement'] = 'Layout configuration'; -// Negative view of layout, kept for previous versions until such time as they are updated. -$string['defaultlayoutelement_desc'] = "Thee layout setting can be one of:
'Default' with everything displayed.
Nay 'Treasure chest x' / 'Sailing week x' / 'Sailing day x'.
Nay section number.
Nay 'Treasure chest x' / 'Sailing week x' / 'Sailing day x' and nay section number.
Nay 'Toggle' word.
Nay 'Toggle' word and nay 'Treasure chest x' / 'Sailing week x' / 'Sailing day x'.
Nay 'Toggle' word, nay 'Treasure chest x' / 'Sailing week x' / 'Sailing day x' and nay section number."; -// Positive view of layout. -$string['defaultlayoutelement_descpositive'] = "The layout setting can be one of:
Toggle word, 'Treasure chest x' / 'Sailing week x' / 'Sailing day x' and section number.
Toggle word and 'Treasure chest x' / 'Sailing week x' / 'Sailing day x'.
Toggle word and section number.
'Treasure chest x' / 'Sailing week x' / 'Sailing day x' and section number.
Toggle word.
'Treasure chest x' / 'Sailing week x' / 'Sailing day x'.
Section number.
Nay additions."; - -$string['defaultlayoutstructure'] = 'Structure configuration'; -$string['defaultlayoutstructure_desc'] = "Thee structure setting can be one of:
Treasure Chest
Sailing Week
Current Sailing Week First
Current Treasure Chest First
Sailing Day"; - -$string['defaultlayoutcolumns'] = 'Number of columns'; -$string['defaultlayoutcolumns_desc'] = "Number of columns between one and four."; - -$string['defaultlayoutcolumnorientation'] = 'Column orientation'; -$string['defaultlayoutcolumnorientation_desc'] = "Thee default column orientation: Vertical or Horizontal."; - -$string['defaulttgfgcolour'] = 'Toggle foreground colour'; -$string['defaulttgfgcolour_desc'] = "Toggle foreground colour in hexidecimal RGB."; - -$string['defaulttgbgcolour'] = 'Toggle background colour'; -$string['defaulttgbgcolour_desc'] = "Toggle background colour in hexidecimal RGB."; - -$string['defaulttgbghvrcolour'] = 'Toggle background hover colour'; -$string['defaulttgbghvrcolour_desc'] = "Toggle background hover colour in hexidecimal RGB."; - -$string['defaulttogglepersistence'] = 'Toggle persistence'; -$string['defaulttogglepersistence_desc'] = "'On' or 'Off'. You may wish to turn off for an AJAX performance increase but sailor toggle selections will not be recalled on page refresh or revisit.
Note: If turning persistence off remove any rows containing 'topcoll_toggle_x' in the 'name' field of the 'user_preferences' table in the database. Where thee 'x' in 'topcoll_toggle_x' will be a course id."; - -$string['defaulttogglealignment'] = 'Toggle text alignment'; -$string['defaulttogglealignment_desc'] = "'Left', 'Centre' or 'Right'."; - -$string['defaulttoggleiconset'] = 'Toggle icon set'; -$string['defaulttoggleiconset_desc'] = "'Straight as an arrow' => Arrow icon set.
'Lantern' => Bulb icon set.
'Cloud' => Cloud icon set.
'Eyeball' => Eye icon set.
'LED from thee future' => LED icon set.
'Point thee bow towards thy treasure' => Point icon set.
'Power mee hearties' => Power icon set.
'Wireless' => Radio icon set.
'Smiley they bee not' => Smiley icon set.
'Square riggin' => Square icon set.
'Sun / Moon' => Sun / Moon icon set.
'Switch thy flag' => Switch icon set."; - -$string['defaulttoggleallhover'] = 'Toggle all icon hovers'; -$string['defaulttoggleallhover_desc'] = "'Nay' or 'Aye'."; - -// Default sailor preference. -$string['defaultuserpreference'] = 'What to do with thee toggles when thy sailor first accesses thee course or adds more sections'; -$string['defaultuserpreference_desc'] = 'States what to do with thee toggles when thy sailor first accesses thee course or thee state of additional sections when they are added mee hearties.'; - -// Capabilities. -$string['topcoll:changelayout'] = 'Change or reset thee layout'; -$string['topcoll:changecolour'] = 'Change or reset thee colour'; -$string['topcoll:changetogglealignment'] = 'Change or reset thee toggle alignment'; -$string['topcoll:changetoggleiconset'] = 'Change or reset thee toggle icon set'; - -// Instructions. -$string['instructions'] = 'Orders: Avast! Clicking on thee section name will show / hide thy section. And yee betin not forgetin dat!'; -$string['displayinstructions'] = 'Display orders'; -$string['displayinstructions_help'] = 'States that thee orders should be displayed to thy crew or not.'; -$string['defaultdisplayinstructions'] = 'Display orders to crew'; -$string['defaultdisplayinstructions_desc'] = "Display orders to crew informing them how to use thee toggles. Can bee aye or nay."; -$string['resetdisplayinstructions'] = 'Display orders'; -$string['resetalldisplayinstructions'] = 'Display orders'; -$string['resetdisplayinstructions_help'] = 'Resets thy display orders to thee default value so it will be thy same as a course thee first time it is in thy Collapsed Topics format.'; -$string['resetalldisplayinstructions_help'] = 'Resets thy display orders to thee default value for all courses so it will be thee same as a course thee first time it is in thy Collapsed Topics format.'; - -// Toggle icon size. -$string['defaulttoggleiconsize'] = 'Toggle icon size'; -$string['defaulttoggleiconsize_desc'] = "Icon size: Cutter = 16px, Brig = 24px and Barque = 32px."; -$string['small'] = 'Cutter'; -$string['medium'] = 'Brig'; -$string['large'] = 'Barque'; - -// Toggle border radius. -$string['defaulttoggleborderradiustl'] = 'Toggle top left border radius'; -$string['defaulttoggleborderradiustl_desc'] = 'Border top left radius of thy toggle.'; -$string['defaulttoggleborderradiustr'] = 'Toggle top right border radius'; -$string['defaulttoggleborderradiustr_desc'] = 'Border top right radius of thy toggle.'; -$string['defaulttoggleborderradiusbr'] = 'Toggle bottom right border radius'; -$string['defaulttoggleborderradiusbr_desc'] = 'Border bottom right radius of thy toggle.'; -$string['defaulttoggleborderradiusbl'] = 'Toggle bottom left border radius'; -$string['defaulttoggleborderradiusbl_desc'] = 'Border bottom left radius of thy toggle.'; +. + +/** + * Collapsed Topics Information + * + * A topic based format that solves the issue of the 'Scroll of Death' when a course has many topics. All topics + * except zero have a toggle that displays that topic. One or more topics can be displayed at any given time. + * Toggles are persistent on a per browser session per course basis but can be made to persist longer by a small + * code change. Full installation instructions, code adaptions and credits are included in the 'Readme.md' file. + * + * @package course/format + * @subpackage topcoll + * @version See the value of '$plugin->version' in below. + * @copyright © 2009-onwards G J Barnard in respect to modifications of standard topics format. + * @author G J Barnard - gjbarnard at gmail dot com and {@link http://moodle.org/user/profile.php?id=442195} + * @link http://docs.moodle.org/en/Collapsed_Topics_course_format + * @license http://www.gnu.org/copyleft/gpl.html GNU Public License + * + */ + +// English Pirate Translation of Collapsed Topics Course Format. + +// Used in format.php. +$string['topcollsidewidthlang'] = 'en_ar-40px'; + +// These are 'topic' as they are only shown in 'topic' based structures. +$string['markedthissection'] = 'Thy topic is illuminated as thee current topic'; +$string['markthissection'] = 'Illuminate thy topic as thee current topic'; + +// Toggle all - Moodle Tracker CONTRIB-3190. +$string['topcollopened'] = 'Untie'; +$string['topcollclosed'] = 'Tie'; + +// Layout enhancement - Moodle Tracker CONTRIB-3378. +$string['formatsettings'] = 'Ye format settings'; // CONTRIB-3529. +$string['setlayout'] = 'Thee layout'; +$string['setlayout_default'] = 'Default'; +$string['setlayoutelements'] = 'Thee elements'; +// Negative view of layout, kept for previous versions until such time as they are updated. +$string['setlayout_no_toggle_section_x'] = "Nay 'Treasure Chest x' / 'Sailing Week x' / 'Sailing Day x'"; // 2. +$string['setlayout_no_toggle_section_x_section_no'] = "Nay 'Treasure Chest x' / 'Sailing Week x' / 'Sailing Day x' and section number"; // 4. +$string['setlayout_no_toggle_word_toggle_section_x'] = "Nay toggle word and 'Treasure Chest x' / 'Sailing Week x' / 'Sailing Day x'"; // 6. +$string['setlayout_no_toggle_word_toggle_section_x_section_no'] = "Nay toggle word, 'Treasure Chest x' / 'Sailing Week x' / 'Sailing Day x' and section number"; // 7. +// Positive view of layout. +$string['setlayout_all'] = "Toggle word, 'Treasure Chest x' / 'Sailing Week x' / 'Sailing Day x' and section number"; // 1. +$string['setlayout_toggle_word_section_x'] = "Toggle word and 'Treasure Chest x' / 'Sailing Week x' / 'Sailing Day x'"; // 3. +$string['setlayout_toggle_section_x'] = "'Treasure Chest x' / 'Sailing Week x' / 'Sailing Day x' and section number"; // 5. +$string['setlayout_toggle_section_x'] = "'Treasure Chest x' / 'Sailing Week x' / 'Sailing Day x'"; // 8. + +$string['setlayoutstructure'] = 'Thee structure'; +$string['setlayoutstructuretopic'] = 'Treasure Chest'; +$string['setlayoutstructureweek'] = 'Sailing Week'; +$string['setlayoutstructureday'] = 'Sailing Day'; +$string['setlayoutstructurelatweekfirst'] = 'Current Sailing Week First'; +$string['setlayoutstructurecurrenttopicfirst'] = 'Current Treasure Chest First'; +$string['resetlayout'] = 'Thee layout'; // CONTRIB-3529. +$string['resetalllayout'] = 'Thee layouts'; + +// Colour enhancement - Moodle Tracker CONTRIB-3529. +$string['setcolour'] = 'Thee colour'; +$string['colourrule'] = "Enter a valid RGB colour, a '#' and then six hexadecimal digits or walk thy plank."; +$string['settoggleforegroundcolour'] = 'Thy toggle foreground'; +$string['settogglebackgroundhovercolour'] = 'Thy toggle foreground hover'; +$string['settoggleforegroundcolour'] = 'Thy toggle foreground'; +$string['settogglebackgroundhovercolour'] = 'Thy toggle background hover'; +$string['resetcolour'] = 'Thee colour'; +$string['resetallcolour'] = 'Thee colours'; + +// Columns enhancement. +$string['setlayoutcolumns'] = 'Thee columns'; +$string['one'] = 'One'; +$string['two'] = 'Two'; +$string['three'] = 'Three'; +$string['four'] = 'Four'; +$string['setlayoutcolumnorientation'] = 'Thee column orientation'; +$string['columnvertical'] = 'Vertical as a mast'; +$string['columnhorizontal'] = 'Horizontal as a cannon'; + +// Temporary until MDL-34917 in core. +$string['maincoursepage'] = 'Ye main course page'; + +// Help. +$string['setlayoutelements_help'] = 'How much information about thee toggles / sections you wish to be displayed.'; +$string['setlayoutstructure_help'] = "Avast ye landlubbers, this be thee layout structure of thee course. Ye choose between:
'Treasure chest' - where each section is presented as thy treasure chest in section number order.
'Sailing week' - where each section is presented as thy week in ascending week order.
'Current sailing week first' - which is the same as weeks but thee current week is shown at thee top and preceding weeks in descending order are displayed below except in editing mode where thee structure is thy same as 'Weeks'.
'Current treasure chest first' - which is thee same as 'Treasure chest' except that thee current treasure chest is shown at thee top if it has been set.
'Sailing Day' - where each section is presented as a day in thy ascending day order from thee start date of thee course."; +$string['setlayout_help'] = 'Contains thee settings to do with thee layout of the format within thy course.'; +$string['resetlayout_help'] = 'Resets thee layout to thee default so it will be the same as a course the first time it is in thy Collapsed Topics format'; +$string['resetalllayout_help'] = 'Resets the layout to the default values for all courses so it will be the same as a course the first time it is in the Collapsed Topics format.'; +// Moodle Tracker CONTRIB-3529. +$string['setcolour_help'] = 'Contains thee settings to do with thy colour of the format within the course.'; +$string['settoggleforegroundcolour_help'] = 'Sets thee colour of thy text on the toggle.'; +$string['settoggleforegroundhovercolour_help'] = 'Sets thee colour of thy text on thy toggle when thee mouse scuttles over it.'; +$string['settogglebackgroundcolour_help'] = 'Sets thee background of thy toggle.'; +$string['settogglebackgroundhovercolour_help'] = 'Sets thee background of thy toggle when thee mouse scuttles over it.'; +$string['resetcolour_help'] = 'Resets thee colours to thee default values so it will be thee same as a course thy first time it is in thee Collapsed Topics format'; +$string['resetallcolour_help'] = 'Resets thee colours to the default values for all courses so it will be thy same as a course the first time it is in thee Collapsed Topics format.'; +// Columns enhancement. +$string['setlayoutcolumns_help'] = 'How many columns to use.'; + +// Toggle alignment - CONTRIB-4098. +$string['settogglealignment'] = 'Thee toggle text alignment'; +$string['settogglealignment_help'] = 'Sets thee alignment of thee text in thy toggle.'; +$string['left'] = 'Port'; +$string['center'] = 'Midships'; +$string['right'] = 'Starboard'; +$string['resettogglealignment'] = 'Thee toggle alignment'; +$string['resetalltogglealignment'] = 'Thee toggle alignments'; +$string['resettogglealignment_help'] = 'Resets thee toggle alignment to thy default values so thy will be thy same as a course thee first time it is in thee Collapsed Topics format.'; +$string['resetalltogglealignment_help'] = 'Resets thee toggle alignment to thy default values for all courses so it will be thy same as a course thee first time it is in thee Collapsed Topics format.'; + +// Icon position - CONTRIB-4470. +$string['settoggleiconposition'] = 'Icon position'; +$string['settoggleiconposition_help'] = 'States that thee icon should be on thy left or thee right of thy toggle text.'; +$string['defaulttoggleiconposition'] = 'Icon position'; +$string['defaulttoggleiconposition_desc'] = 'States if thee icon should be on thy left or thee right of thy toggle text.'; + +// Icon set enhancement. +$string['settoggleiconset'] = 'Thee icon set'; +$string['settoggleiconset_help'] = 'Sets thee icon set of thy toggle.'; +$string['settoggleallhover'] = 'Set thee toggle all icon hover'; +$string['settoggleallhover_help'] = 'Sets if thee toggle all icons will change when thy mouse moves over them.'; +$string['arrow'] = 'Straight as an arrow'; +$string['bulb'] = 'Lantern'; +$string['cloud'] = 'Cloud'; +$string['eye'] = 'Eyeball'; +$string['led'] = 'LED from thee future'; +$string['point'] = 'Point thee bow towards thy treasure'; +$string['power'] = 'Power mee hearties'; +$string['radio'] = 'Wireless'; +$string['smiley'] = 'Smiley they bee not'; +$string['square'] = 'Square riggin'; +$string['sunmoon'] = 'Sun / Moon'; +$string['switch'] = 'Switch thy flag'; +$string['resettoggleiconset'] = 'Thee toggle icon set'; +$string['resetalltoggleiconset'] = 'Thee toggle icon sets'; +$string['resettoggleiconset_help'] = 'Resets thee toggle icon set and thy toggle all hover to thy default values so thy will be thee same as a course thee first time it is in thy Collapsed Topics format.'; +$string['resetalltoggleiconset_help'] = 'Resets thee toggle icon set and thy toggle all hover to thy default values for all courses so it will be thy same as a course thee first time it is in thy Collapsed Topics format.'; + +// Site Administration -> Plugins -> Course formats -> Collapsed Topics or Manage course formats - Settings. +$string['off'] = 'Off'; +$string['on'] = 'On'; +$string['defaultcoursedisplay'] = 'Course display default'; +$string['defaultcoursedisplay_desc'] = "Either show all thee sections on a single page or section zero and thee chosen section on page."; +$string['defaultlayoutelement'] = 'Layout configuration'; +// Negative view of layout, kept for previous versions until such time as they are updated. +$string['defaultlayoutelement_desc'] = "Thee layout setting can be one of:
'Default' with everything displayed.
Nay 'Treasure chest x' / 'Sailing week x' / 'Sailing day x'.
Nay section number.
Nay 'Treasure chest x' / 'Sailing week x' / 'Sailing day x' and nay section number.
Nay 'Toggle' word.
Nay 'Toggle' word and nay 'Treasure chest x' / 'Sailing week x' / 'Sailing day x'.
Nay 'Toggle' word, nay 'Treasure chest x' / 'Sailing week x' / 'Sailing day x' and nay section number."; +// Positive view of layout. +$string['defaultlayoutelement_descpositive'] = "The layout setting can be one of:
Toggle word, 'Treasure chest x' / 'Sailing week x' / 'Sailing day x' and section number.
Toggle word and 'Treasure chest x' / 'Sailing week x' / 'Sailing day x'.
Toggle word and section number.
'Treasure chest x' / 'Sailing week x' / 'Sailing day x' and section number.
Toggle word.
'Treasure chest x' / 'Sailing week x' / 'Sailing day x'.
Section number.
Nay additions."; + +$string['defaultlayoutstructure'] = 'Structure configuration'; +$string['defaultlayoutstructure_desc'] = "Thee structure setting can be one of:
Treasure Chest
Sailing Week
Current Sailing Week First
Current Treasure Chest First
Sailing Day"; + +$string['defaultlayoutcolumns'] = 'Number of columns'; +$string['defaultlayoutcolumns_desc'] = "Number of columns between one and four."; + +$string['defaultlayoutcolumnorientation'] = 'Column orientation'; +$string['defaultlayoutcolumnorientation_desc'] = "Thee default column orientation: Vertical or Horizontal."; + +$string['defaulttgfgcolour'] = 'Toggle foreground colour'; +$string['defaulttgfgcolour_desc'] = "Toggle foreground colour in hexidecimal RGB."; + +$string['defaulttgbgcolour'] = 'Toggle background colour'; +$string['defaulttgbgcolour_desc'] = "Toggle background colour in hexidecimal RGB."; + +$string['defaulttgbghvrcolour'] = 'Toggle background hover colour'; +$string['defaulttgbghvrcolour_desc'] = "Toggle background hover colour in hexidecimal RGB."; + +$string['defaulttogglepersistence'] = 'Toggle persistence'; +$string['defaulttogglepersistence_desc'] = "'On' or 'Off'. You may wish to turn off for an AJAX performance increase but sailor toggle selections will not be recalled on page refresh or revisit.
Note: If turning persistence off remove any rows containing 'topcoll_toggle_x' in the 'name' field of the 'user_preferences' table in the database. Where thee 'x' in 'topcoll_toggle_x' will be a course id."; + +$string['defaulttogglealignment'] = 'Toggle text alignment'; +$string['defaulttogglealignment_desc'] = "'Left', 'Centre' or 'Right'."; + +$string['defaulttoggleiconset'] = 'Toggle icon set'; +$string['defaulttoggleiconset_desc'] = "'Straight as an arrow' => Arrow icon set.
'Lantern' => Bulb icon set.
'Cloud' => Cloud icon set.
'Eyeball' => Eye icon set.
'LED from thee future' => LED icon set.
'Point thee bow towards thy treasure' => Point icon set.
'Power mee hearties' => Power icon set.
'Wireless' => Radio icon set.
'Smiley they bee not' => Smiley icon set.
'Square riggin' => Square icon set.
'Sun / Moon' => Sun / Moon icon set.
'Switch thy flag' => Switch icon set."; + +$string['defaulttoggleallhover'] = 'Toggle all icon hovers'; +$string['defaulttoggleallhover_desc'] = "'Nay' or 'Aye'."; + +// Default sailor preference. +$string['defaultuserpreference'] = 'What to do with thee toggles when thy sailor first accesses thee course or adds more sections'; +$string['defaultuserpreference_desc'] = 'States what to do with thee toggles when thy sailor first accesses thee course or thee state of additional sections when they are added mee hearties.'; + +// Capabilities. +$string['topcoll:changelayout'] = 'Change or reset thee layout'; +$string['topcoll:changecolour'] = 'Change or reset thee colour'; +$string['topcoll:changetogglealignment'] = 'Change or reset thee toggle alignment'; +$string['topcoll:changetoggleiconset'] = 'Change or reset thee toggle icon set'; + +// Instructions. +$string['instructions'] = 'Orders: Avast! Clicking on thee section name will show / hide thy section. And yee betin not forgetin dat!'; +$string['displayinstructions'] = 'Display orders'; +$string['displayinstructions_help'] = 'States that thee orders should be displayed to thy crew or not.'; +$string['defaultdisplayinstructions'] = 'Display orders to crew'; +$string['defaultdisplayinstructions_desc'] = "Display orders to crew informing them how to use thee toggles. Can bee aye or nay."; +$string['resetdisplayinstructions'] = 'Display orders'; +$string['resetalldisplayinstructions'] = 'Display orders'; +$string['resetdisplayinstructions_help'] = 'Resets thy display orders to thee default value so it will be thy same as a course thee first time it is in thy Collapsed Topics format.'; +$string['resetalldisplayinstructions_help'] = 'Resets thy display orders to thee default value for all courses so it will be thee same as a course thee first time it is in thy Collapsed Topics format.'; + +// Toggle icon size. +$string['defaulttoggleiconsize'] = 'Toggle icon size'; +$string['defaulttoggleiconsize_desc'] = "Icon size: Cutter = 16px, Brig = 24px and Barque = 32px."; +$string['small'] = 'Cutter'; +$string['medium'] = 'Brig'; +$string['large'] = 'Barque'; + +// Toggle border radius. +$string['defaulttoggleborderradiustl'] = 'Toggle top left border radius'; +$string['defaulttoggleborderradiustl_desc'] = 'Border top left radius of thy toggle.'; +$string['defaulttoggleborderradiustr'] = 'Toggle top right border radius'; +$string['defaulttoggleborderradiustr_desc'] = 'Border top right radius of thy toggle.'; +$string['defaulttoggleborderradiusbr'] = 'Toggle bottom right border radius'; +$string['defaulttoggleborderradiusbr_desc'] = 'Border bottom right radius of thy toggle.'; +$string['defaulttoggleborderradiusbl'] = 'Toggle bottom left border radius'; +$string['defaulttoggleborderradiusbl_desc'] = 'Border bottom left radius of thy toggle.'; diff --git a/lib.php b/lib.php index 93f7fc87..36fb89fa 100644 --- a/lib.php +++ b/lib.php @@ -1,1247 +1,1246 @@ -. - -/** - * Collapsed Topics Information - * - * A topic based format that solves the issue of the 'Scroll of Death' when a course has many topics. All topics - * except zero have a toggle that displays that topic. One or more topics can be displayed at any given time. - * Toggles are persistent on a per browser session per course basis but can be made to persist longer by a small - * code change. Full installation instructions, code adaptions and credits are included in the 'Readme.md' file. - * - * @package course/format - * @subpackage topcoll - * @version See the value of '$plugin->version' in below. - * @copyright © 2012-onwards G J Barnard in respect to modifications of standard topics format. - * @author G J Barnard - gjbarnard at gmail dot com and {@link http://moodle.org/user/profile.php?id=442195} - * @link http://docs.moodle.org/en/Collapsed_Topics_course_format - * @license http://www.gnu.org/copyleft/gpl.html GNU Public License - * - */ -require_once($CFG->dirroot . '/course/format/lib.php'); // For format_base. - -class format_topcoll extends format_base { - - private $settings; - - /** - * Creates a new instance of class - * - * Please use {@link course_get_format($courseorid)} to get an instance of the format class - * - * @param string $format - * @param int $courseid - * @return format_topcoll - */ - protected function __construct($format, $courseid) { - if ($courseid === 0) { - global $COURSE; - $courseid = $COURSE->id; // Save lots of global $COURSE as we will never be the site course. - } - parent::__construct($format, $courseid); - } - - /** - * Returns the format's settings and gets them if they do not exist. - * @return type The settings as an array. - */ - public function get_settings() { - if (empty($this->settings) == true) { - $this->settings = $this->get_format_options(); - } - return $this->settings; - } - - /** - * Indicates this format uses sections. - * - * @return bool Returns true - */ - public function uses_sections() { - return true; - } - - /** - * Gets the name for the provided section. - * - * @param int|stdClass $section Section object from database or just field section.section - * @return string The section name. - */ - public function get_section_name($section) { - $course = $this->get_course(); - // Don't add additional text as called in creating the navigation. - return $this->get_topcoll_section_name($course, $section, false); - } - - /** - * Returns the default section name for the format. - * - * @param stdClass $section Section object from database or just field course_sections section - * @return string The default value for the section name. - */ - public function get_default_section_name($section) { - /* Follow the same logic so that this method is supported. The MDL-51610 enchancement refactored things, - but that is not appropriate for us. */ - return $this->get_section_name($section); - } - - /** - * Gets the name for the provided course, section and state if need to add addional text. - * - * @param stdClass $course The course entry from DB - * @param int|stdClass $section Section object from database or just field section.section - * @param boolean $additional State to add additional text yes = true or no = false. - * @return string The section name. - */ - public function get_topcoll_section_name($course, $section, $additional) { - $thesection = $this->get_section($section); - if (is_null($thesection)) { - $thesection = new stdClass; - $thesection->name = ''; - if (is_object($section)) { - $thesection->section = $section->section; - } else { - $thesection->section = $section; - } - } - $o = ''; - $tcsettings = $this->get_settings(); - $tcsectionsettings = $this->get_format_options($thesection->section); - $coursecontext = context_course::instance($course->id); - - // We can't add a node without any text. - if ((string) $thesection->name !== '') { - $o .= format_string($thesection->name, true, array('context' => $coursecontext)); - if (($thesection->section != 0) && (($tcsettings['layoutstructure'] == 2) || - ($tcsettings['layoutstructure'] == 3) || ($tcsettings['layoutstructure'] == 5))) { - $o .= ' '; - if (empty($tcsectionsettings['donotshowdate'])) { - if ($additional == true) { // Break 'br' tags break backups! - $o .= html_writer::empty_tag('br'); - } - $o .= $this->get_section_dates($section, $course, $tcsettings); - } - } - } else if ($thesection->section == 0) { - $o = get_string('section0name', 'format_topcoll'); - } else { - if (($tcsettings['layoutstructure'] == 1) || ($tcsettings['layoutstructure'] == 4)) { - $o = get_string('sectionname', 'format_topcoll') . ' ' . $thesection->section; - } else { - $o .= $this->get_section_dates($section, $course, $tcsettings); - } - } - - /* - * Now done here so that the drag and drop titles will be the correct strings as swapped in format.js. - * But only if we are using toggles which will be if all sections are on one page or we are editing the main page - * when in one section per page which is coded in 'renderer.php/print_multiple_section_page()' when it calls - * 'section_header()' as that gets called from 'format.php' when there is no entry for '$displaysetting' - confused? - * I was, took ages to figure. - */ - if (($additional == true) && ($thesection->section != 0)) { - switch ($tcsettings['layoutelement']) { - case 1: - case 2: - case 3: - case 4: - // The word 'Toggle'. - $o .= ' - ' . get_string('topcolltoggle', 'format_topcoll') . ''; - break; - } - } - - return $o; - } - - public function get_section_dates($section, $course, $tcsettings) { - $dateformat = get_string('strftimedateshort'); - $o = ''; - if ($tcsettings['layoutstructure'] == 5) { - $day = $this->format_topcoll_get_section_day($section, $course); - - $weekday = userdate($day, $dateformat); - $o = $weekday; - } else { - $dates = $this->format_topcoll_get_section_dates($section, $course); - - // We subtract 24 hours for display purposes. - $dates->end = ($dates->end - 86400); - - $weekday = userdate($dates->start, $dateformat); - $endweekday = userdate($dates->end, $dateformat); - $o = $weekday . ' - ' . $endweekday; - } - return $o; - } - - /** - * The URL to use for the specified course (with section) - * - * @param int|stdClass $section Section object from database or just field course_sections.section - * if omitted the course view page is returned - * @param array $options options for view URL. At the moment core uses: - * 'navigation' (bool) if true and section has no separate page, the function returns null - * 'sr' (int) used by multipage formats to specify to which section to return - * @return null|moodle_url - */ - public function get_view_url($section, $options = array()) { - $course = $this->get_course(); - $url = new moodle_url('/course/view.php', array('id' => $course->id)); - - $sr = null; - if (array_key_exists('sr', $options)) { - $sr = $options['sr']; - } - if (is_object($section)) { - $sectionno = $section->section; - } else { - $sectionno = $section; - } - if ($sectionno !== null) { - if ($sr !== null) { - if ($sr) { - $usercoursedisplay = COURSE_DISPLAY_MULTIPAGE; - $sectionno = $sr; - } else { - $usercoursedisplay = COURSE_DISPLAY_SINGLEPAGE; - } - } else { - $usercoursedisplay = $course->coursedisplay; - } - if ($sectionno != 0 && $usercoursedisplay == COURSE_DISPLAY_MULTIPAGE) { - $url->param('section', $sectionno); - } else { - if (!empty($options['navigation'])) { - return null; - } - $url->set_anchor('section-' . $sectionno); - } - } - return $url; - } - - /** - * Returns the information about the ajax support in the given source format - * - * The returned object's property (boolean)capable indicates that - * the course format supports Moodle course ajax features. - * The property (array)testedbrowsers can be used as a parameter for {@link ajaxenabled()}. - * - * @return stdClass - */ - public function supports_ajax() { - $ajaxsupport = new stdClass(); - $ajaxsupport->capable = true; - return $ajaxsupport; - } - - /** - * Custom action after section has been moved in AJAX mode - * - * Used in course/rest.php - * - * @return array This will be passed in ajax respose - */ - public function ajax_section_move() { - $titles = array(); - $current = -1; // MDL-33546. - $weekformat = false; - $tcsettings = $this->get_settings(); - if (($tcsettings['layoutstructure'] == 2) || ($tcsettings['layoutstructure'] == 3) || - ($tcsettings['layoutstructure'] == 5)) { - $weekformat = true; - } - $course = $this->get_course(); - $modinfo = get_fast_modinfo($course); - if ($sections = $modinfo->get_section_info_all()) { - foreach ($sections as $number => $section) { - $titles[$number] = $this->get_topcoll_section_name($course, $section, true); - if (($weekformat == true) && ($this->is_section_current($section))) { - $current = $number; // Only set if a week based course to keep the current week in the same place. - } - } - } - return array('sectiontitles' => $titles, 'current' => $current, 'action' => 'move'); - } - - /** - * Returns the list of blocks to be automatically added for the newly created course - * - * @return array of default blocks, must contain two keys BLOCK_POS_LEFT and BLOCK_POS_RIGHT - * each of values is an array of block names (for left and right side columns) - */ - public function get_default_blocks() { - return array( - BLOCK_POS_LEFT => array(), - BLOCK_POS_RIGHT => array('search_forums', 'news_items', 'calendar_upcoming', 'recent_activity') - ); - } - - public function section_format_options($foreditform = false) { - static $sectionformatoptions = false; - - if ($sectionformatoptions === false) { - $sectionformatoptions = array( - 'donotshowdate' => array( - 'default' => 0, - 'type' => PARAM_INT - ) - ); - } - if ($foreditform && !isset($sectionformatoptions['donotshowdate']['label'])) { - $sectionformatoptionsedit = array( - 'donotshowdate' => array( - 'label' => new lang_string('donotshowdate', 'format_topcoll'), - 'help' => 'donotshowdate', - 'help_component' => 'format_topcoll', - 'element_type' => 'checkbox' - ) - ); - $sectionformatoptions = array_merge_recursive($sectionformatoptions, $sectionformatoptionsedit); - } - - $tcsettings = $this->get_settings(); - if (($tcsettings['layoutstructure'] == 2) || ($tcsettings['layoutstructure'] == 3) || - ($tcsettings['layoutstructure'] == 5)) { - // Weekly layout. - return $sectionformatoptions; - } else { - return array(); - } - } - /** - * Definitions of the additional options that this course format uses for course - * - * Collapsed Topics format uses the following options (until extras are migrated): - * - coursedisplay - * - numsections - * - hiddensections - * - * @param bool $foreditform - * @return array of options - */ - public function course_format_options($foreditform = false) { - static $courseformatoptions = false; - - if ($courseformatoptions === false) { - /* Note: Because 'admin_setting_configcolourpicker' in 'settings.php' needs to use a prefixing '#' - this needs to be stripped off here if it's there for the format's specific colour picker. */ - $defaulttgfgcolour = get_config('format_topcoll', 'defaulttgfgcolour'); - if ($defaulttgfgcolour[0] == '#') { - $defaulttgfgcolour = substr($defaulttgfgcolour, 1); - } - $defaulttgfghvrcolour = get_config('format_topcoll', 'defaulttgfghvrcolour'); - if ($defaulttgfghvrcolour[0] == '#') { - $defaulttgfghvrcolour = substr($defaulttgfghvrcolour, 1); - } - $defaulttgbgcolour = get_config('format_topcoll', 'defaulttgbgcolour'); - if ($defaulttgbgcolour[0] == '#') { - $defaulttgbgcolour = substr($defaulttgbgcolour, 1); - } - $defaulttgbghvrcolour = get_config('format_topcoll', 'defaulttgbghvrcolour'); - if ($defaulttgbghvrcolour[0] == '#') { - $defaulttgbghvrcolour = substr($defaulttgbghvrcolour, 1); - } - $readme = new moodle_url('/course/format/topcoll/Readme.md'); - $readme = html_writer::link($readme, 'Readme.md', array('target' => '_blank')); - $courseconfig = get_config('moodlecourse'); - $courseformatoptions = array( - 'numsections' => array( - 'default' => $courseconfig->numsections, - 'type' => PARAM_INT, - ), - 'hiddensections' => array( - 'default' => $courseconfig->hiddensections, - 'type' => PARAM_INT, - ), - 'coursedisplay' => array( - 'default' => get_config('format_topcoll', 'defaultcoursedisplay'), - 'type' => PARAM_INT, - ), - 'displayinstructions' => array( - 'default' => get_config('format_topcoll', 'defaultdisplayinstructions'), - 'type' => PARAM_INT, - ), - 'layoutelement' => array( - 'default' => get_config('format_topcoll', 'defaultlayoutelement'), - 'type' => PARAM_INT, - ), - 'layoutstructure' => array( - 'default' => get_config('format_topcoll', 'defaultlayoutstructure'), - 'type' => PARAM_INT, - ), - 'layoutcolumns' => array( - 'default' => get_config('format_topcoll', 'defaultlayoutcolumns'), - 'type' => PARAM_INT, - ), - 'layoutcolumnorientation' => array( - 'default' => get_config('format_topcoll', 'defaultlayoutcolumnorientation'), - 'type' => PARAM_INT, - ), - 'togglealignment' => array( - 'default' => get_config('format_topcoll', 'defaulttogglealignment'), - 'type' => PARAM_INT, - ), - 'toggleiconposition' => array( - 'default' => get_config('format_topcoll', 'defaulttoggleiconposition'), - 'type' => PARAM_INT, - ), - 'toggleiconset' => array( - 'default' => get_config('format_topcoll', 'defaulttoggleiconset'), - 'type' => PARAM_ALPHA, - ), - 'toggleallhover' => array( - 'default' => get_config('format_topcoll', 'defaulttoggleallhover'), - 'type' => PARAM_INT, - ), - 'toggleforegroundcolour' => array( - 'default' => $defaulttgfgcolour, - 'type' => PARAM_ALPHANUM, - ), - 'toggleforegroundhovercolour' => array( - 'default' => $defaulttgfghvrcolour, - 'type' => PARAM_ALPHANUM, - ), - 'togglebackgroundcolour' => array( - 'default' => $defaulttgbgcolour, - 'type' => PARAM_ALPHANUM, - ), - 'togglebackgroundhovercolour' => array( - 'default' => $defaulttgbghvrcolour, - 'type' => PARAM_ALPHANUM, - ), - 'showsectionsummary' => array( - 'default' => get_config('format_topcoll', 'defaultshowsectionsummary'), - 'type' => PARAM_INT, - ), - 'readme' => array( - 'default' => get_string('readme_desc', 'format_topcoll', array('url' => $readme)), - 'type' => PARAM_ALPHA, - ) - ); - } - if ($foreditform && !isset($courseformatoptions['coursedisplay']['label'])) { - /* Note: Because 'admin_setting_configcolourpicker' in 'settings.php' needs to use a prefixing '#' - this needs to be stripped off here if it's there for the format's specific colour picker. */ - $defaulttgfgcolour = get_config('format_topcoll', 'defaulttgfgcolour'); - if ($defaulttgfgcolour[0] == '#') { - $defaulttgfgcolour = substr($defaulttgfgcolour, 1); - } - $defaulttgfghvrcolour = get_config('format_topcoll', 'defaulttgfghvrcolour'); - if ($defaulttgfghvrcolour[0] == '#') { - $defaulttgfghvrcolour = substr($defaulttgfghvrcolour, 1); - } - $defaulttgbgcolour = get_config('format_topcoll', 'defaulttgbgcolour'); - if ($defaulttgbgcolour[0] == '#') { - $defaulttgbgcolour = substr($defaulttgbgcolour, 1); - } - $defaulttgbghvrcolour = get_config('format_topcoll', 'defaulttgbghvrcolour'); - if ($defaulttgbghvrcolour[0] == '#') { - $defaulttgbghvrcolour = substr($defaulttgbghvrcolour, 1); - } - - $coursecontext = context_course::instance($this->courseid); - - $courseconfig = get_config('moodlecourse'); - $sectionmenu = array(); - for ($i = 0; $i <= $courseconfig->maxsections; $i++) { - $sectionmenu[$i] = "$i"; - } - $courseformatoptionsedit = array( - 'numsections' => array( - 'label' => new lang_string('numbersections', 'format_topcoll'), - 'element_type' => 'select', - 'element_attributes' => array($sectionmenu), - ), - 'hiddensections' => array( - 'label' => new lang_string('hiddensections'), - 'help' => 'hiddensections', - 'help_component' => 'moodle', - 'element_type' => 'select', - 'element_attributes' => array( - array(0 => new lang_string('hiddensectionscollapsed'), - 1 => new lang_string('hiddensectionsinvisible') - ) - ), - ), - 'coursedisplay' => array( - 'label' => new lang_string('coursedisplay'), - 'element_type' => 'select', - 'element_attributes' => array( - array( - COURSE_DISPLAY_SINGLEPAGE => new lang_string('coursedisplay_single'), - COURSE_DISPLAY_MULTIPAGE => new lang_string('coursedisplay_multi') - ) - ), - 'help' => 'coursedisplay', - 'help_component' => 'moodle', - ), - 'displayinstructions' => array( - 'label' => new lang_string('displayinstructions', 'format_topcoll'), - 'help' => 'displayinstructions', - 'help_component' => 'format_topcoll', - 'element_type' => 'select', - 'element_attributes' => array( - array(1 => new lang_string('no'), - 2 => new lang_string('yes')) - ) - ) - ); - if (has_capability('format/topcoll:changelayout', $coursecontext)) { - $courseformatoptionsedit['layoutelement'] = array( - 'label' => new lang_string('setlayoutelements', 'format_topcoll'), - 'help' => 'setlayoutelements', - 'help_component' => 'format_topcoll', - 'element_type' => 'select', - 'element_attributes' => array( // In insertion order and not numeric for sorting purposes. - array( - // Toggle word, toggle section x and section number. - 1 => new lang_string('setlayout_all', 'format_topcoll'), - // Toggle word and toggle section x. - 3 => new lang_string('setlayout_toggle_word_section_x', 'format_topcoll'), - // Toggle word and section number. - 2 => new lang_string('setlayout_toggle_word_section_number', 'format_topcoll'), - // Toggle section x and section number. - 5 => new lang_string('setlayout_toggle_section_x_section_number', 'format_topcoll'), - // Toggle word. - 4 => new lang_string('setlayout_toggle_word', 'format_topcoll'), - // Toggle section x. - 8 => new lang_string('setlayout_toggle_section_x', 'format_topcoll'), - // Section number. - 6 => new lang_string('setlayout_section_number', 'format_topcoll'), - // No additions. - 7 => new lang_string('setlayout_no_additions', 'format_topcoll')) - ) - ); - $courseformatoptionsedit['layoutstructure'] = array( - 'label' => new lang_string('setlayoutstructure', 'format_topcoll'), - 'help' => 'setlayoutstructure', - 'help_component' => 'format_topcoll', - 'element_type' => 'select', - 'element_attributes' => array( - array( - // Topic. - 1 => new lang_string('setlayoutstructuretopic', 'format_topcoll'), - // Week. - 2 => new lang_string('setlayoutstructureweek', 'format_topcoll'), - // Current Week First. - 3 => new lang_string('setlayoutstructurelatweekfirst', 'format_topcoll'), - // Current Topic First. - 4 => new lang_string('setlayoutstructurecurrenttopicfirst', 'format_topcoll'), - // Day. - 5 => new lang_string('setlayoutstructureday', 'format_topcoll')) - ) - ); - $courseformatoptionsedit['layoutcolumns'] = array( - 'label' => new lang_string('setlayoutcolumns', 'format_topcoll'), - 'help' => 'setlayoutcolumns', - 'help_component' => 'format_topcoll', - 'element_type' => 'select', - 'element_attributes' => array( - array(1 => new lang_string('one', 'format_topcoll'), // Default. - 2 => new lang_string('two', 'format_topcoll'), // Two. - 3 => new lang_string('three', 'format_topcoll'), // Three. - 4 => new lang_string('four', 'format_topcoll')) // Four. - ) - ); - $courseformatoptionsedit['layoutcolumnorientation'] = array( - 'label' => new lang_string('setlayoutcolumnorientation', 'format_topcoll'), - 'help' => 'setlayoutcolumnorientation', - 'help_component' => 'format_topcoll', - 'element_type' => 'select', - 'element_attributes' => array( - array(1 => new lang_string('columnvertical', 'format_topcoll'), - 2 => new lang_string('columnhorizontal', 'format_topcoll')) // Default. - ) - ); - $courseformatoptionsedit['toggleiconposition'] = array( - 'label' => new lang_string('settoggleiconposition', 'format_topcoll'), - 'help' => 'settoggleiconposition', - 'help_component' => 'format_topcoll', - 'element_type' => 'select', - 'element_attributes' => array( - array(1 => new lang_string('left', 'format_topcoll'), // Left. - 2 => new lang_string('right', 'format_topcoll')) // Right. - ) - ); - $courseformatoptionsedit['showsectionsummary'] = array( - 'label' => new lang_string('setshowsectionsummary', 'format_topcoll'), - 'help' => 'setshowsectionsummary', - 'help_component' => 'format_topcoll', - 'element_type' => 'select', - 'element_attributes' => array( - array(1 => new lang_string('no'), - 2 => new lang_string('yes')) - ) - ); - } else { - $courseformatoptionsedit['layoutelement'] = array( - 'label' => get_config('format_topcoll', 'defaultlayoutelement'), 'element_type' => 'hidden'); - $courseformatoptionsedit['layoutstructure'] = array( - 'label' => get_config('format_topcoll', 'defaultlayoutstructure'), 'element_type' => 'hidden'); - $courseformatoptionsedit['layoutcolumns'] = array( - 'label' => get_config('format_topcoll', 'defaultlayoutcolumns'), 'element_type' => 'hidden'); - $courseformatoptionsedit['layoutcolumnorientation'] = array( - 'label' => get_config('format_topcoll', 'defaultlayoutcolumnorientation'), 'element_type' => 'hidden'); - $courseformatoptionsedit['toggleiconposition'] = array( - 'label' => get_config('format_topcoll', 'defaulttoggleiconposition'), 'element_type' => 'hidden'); - $courseformatoptionsedit['showsectionsummary'] = array( - 'label' => get_config('format_topcoll', 'defaultshowsectionsummary'), 'element_type' => 'hidden'); - } - - if (has_capability('format/topcoll:changetogglealignment', $coursecontext)) { - $courseformatoptionsedit['togglealignment'] = array( - 'label' => new lang_string('settogglealignment', 'format_topcoll'), - 'help' => 'settogglealignment', - 'help_component' => 'format_topcoll', - 'element_type' => 'select', - 'element_attributes' => array( - array(1 => new lang_string('left', 'format_topcoll'), // Left. - 2 => new lang_string('center', 'format_topcoll'), // Centre. - 3 => new lang_string('right', 'format_topcoll')) // Right. - ) - ); - } else { - $courseformatoptionsedit['togglealignment'] = array( - 'label' => get_config('format_topcoll', 'defaulttogglealignment'), 'element_type' => 'hidden'); - } - - if (has_capability('format/topcoll:changetoggleiconset', $coursecontext)) { - $courseformatoptionsedit['toggleiconset'] = array( - 'label' => new lang_string('settoggleiconset', 'format_topcoll'), - 'help' => 'settoggleiconset', - 'help_component' => 'format_topcoll', - 'element_type' => 'select', - 'element_attributes' => array( - array( - 'arrow' => new lang_string('arrow', 'format_topcoll'), // Arrow icon set. - 'bulb' => new lang_string('bulb', 'format_topcoll'), // Bulb icon set. - 'cloud' => new lang_string('cloud', 'format_topcoll'), // Cloud icon set. - 'eye' => new lang_string('eye', 'format_topcoll'), // Eye icon set. - 'groundsignal' => new lang_string('groundsignal', 'format_topcoll'), // Ground signal set. - 'led' => new lang_string('led', 'format_topcoll'), // LED icon set. - 'point' => new lang_string('point', 'format_topcoll'), // Point icon set. - 'power' => new lang_string('power', 'format_topcoll'), // Power icon set. - 'radio' => new lang_string('radio', 'format_topcoll'), // Radio icon set. - 'smiley' => new lang_string('smiley', 'format_topcoll'), // Smiley icon set. - 'square' => new lang_string('square', 'format_topcoll'), // Square icon set. - 'sunmoon' => new lang_string('sunmoon', 'format_topcoll'), // Sun / Moon icon set. - 'switch' => new lang_string('switch', 'format_topcoll')) // Switch icon set. - ) - ); - $courseformatoptionsedit['toggleallhover'] = array( - 'label' => new lang_string('settoggleallhover', 'format_topcoll'), - 'help' => 'settoggleallhover', - 'help_component' => 'format_topcoll', - 'element_type' => 'select', - 'element_attributes' => array( - array(1 => new lang_string('no'), - 2 => new lang_string('yes')) - ) - ); - } else { - $courseformatoptionsedit['toggleiconset'] = array( - 'label' => get_config('format_topcoll', 'defaulttoggleiconset'), 'element_type' => 'hidden'); - $courseformatoptionsedit['toggleallhover'] = array( - 'label' => get_config('format_topcoll', 'defaulttoggleallhover'), 'element_type' => 'hidden'); - } - - if (has_capability('format/topcoll:changecolour', $coursecontext)) { - $courseformatoptionsedit['toggleforegroundcolour'] = array( - 'label' => new lang_string('settoggleforegroundcolour', 'format_topcoll'), - 'help' => 'settoggleforegroundcolour', - 'help_component' => 'format_topcoll', - 'element_type' => 'tccolourpopup', - 'element_attributes' => array( - array('tabindex' => -1, 'value' => $defaulttgfgcolour) - ) - ); - $courseformatoptionsedit['toggleforegroundhovercolour'] = array( - 'label' => new lang_string('settoggleforegroundhovercolour', 'format_topcoll'), - 'help' => 'settoggleforegroundhovercolour', - 'help_component' => 'format_topcoll', - 'element_type' => 'tccolourpopup', - 'element_attributes' => array( - array('tabindex' => -1, 'value' => $defaulttgfghvrcolour) - ) - ); - $courseformatoptionsedit['togglebackgroundcolour'] = array( - 'label' => new lang_string('settogglebackgroundcolour', 'format_topcoll'), - 'help' => 'settogglebackgroundcolour', - 'help_component' => 'format_topcoll', - 'element_type' => 'tccolourpopup', - 'element_attributes' => array( - array('tabindex' => -1, 'value' => $defaulttgbgcolour) - ) - ); - $courseformatoptionsedit['togglebackgroundhovercolour'] = array( - 'label' => new lang_string('settogglebackgroundhovercolour', 'format_topcoll'), - 'help' => 'settogglebackgroundhovercolour', - 'help_component' => 'format_topcoll', - 'element_type' => 'tccolourpopup', - 'element_attributes' => array( - array('tabindex' => -1, 'value' => $defaulttgbghvrcolour) - ) - ); - } else { - $courseformatoptionsedit['toggleforegroundcolour'] = array( - 'label' => $defaulttgfgcolour, 'element_type' => 'hidden'); - $courseformatoptionsedit['toggleforegroundhovercolour'] = array( - 'label' => $defaulttgfghvrcolour, 'element_type' => 'hidden'); - $courseformatoptionsedit['togglebackgroundcolour'] = array( - 'label' => $defaulttgbgcolour, 'element_type' => 'hidden'); - $courseformatoptionsedit['togglebackgroundhovercolour'] = array( - 'label' => $defaulttgbghvrcolour, 'element_type' => 'hidden'); - } - $courseformatoptionsedit['readme'] = array( - 'label' => get_string('readme_title', 'format_topcoll'), - 'element_type' => 'static' - ); - $courseformatoptions = array_merge_recursive($courseformatoptions, $courseformatoptionsedit); - } - return $courseformatoptions; - } - - /** - * Adds format options elements to the course/section edit form - * - * This function is called from {@link course_edit_form::definition_after_data()} - * - * @param MoodleQuickForm $mform form the elements are added to - * @param bool $forsection 'true' if this is a section edit form, 'false' if this is course edit form - * @return array array of references to the added form elements - */ - public function create_edit_form_elements(&$mform, $forsection = false) { - global $CFG, $OUTPUT; - MoodleQuickForm::registerElementType('tccolourpopup', "$CFG->dirroot/course/format/topcoll/js/tc_colourpopup.php", - 'MoodleQuickForm_tccolourpopup'); - - $elements = parent::create_edit_form_elements($mform, $forsection); - if ($forsection == false) { - global $COURSE, $USER; - /* - Increase the number of sections combo box values if the user has increased the number of sections - using the icon on the course page beyond course 'maxsections' or course 'maxsections' has been - reduced below the number of sections already set for the course on the site administration course - defaults page. This is so that the number of sections is not reduced leaving unintended orphaned - activities / resources. - */ - $maxsections = get_config('moodlecourse', 'maxsections'); - $numsections = $mform->getElementValue('numsections'); - $numsections = $numsections[0]; - if ($numsections > $maxsections) { - $element = $mform->getElement('numsections'); - for ($i = ($maxsections + 1); $i <= $numsections; $i++) { - $element->addOption("$i", $i); - } - } - - $coursecontext = context_course::instance($COURSE->id); - - $changelayout = has_capability('format/topcoll:changelayout', $coursecontext); - $changecolour = has_capability('format/topcoll:changecolour', $coursecontext); - $changetogglealignment = has_capability('format/topcoll:changetogglealignment', $coursecontext); - $changetoggleiconset = has_capability('format/topcoll:changetoggleiconset', $coursecontext); - $resetall = is_siteadmin($USER); // Site admins only. - - $elements[] = $mform->addElement('header', 'ctreset', get_string('ctreset', 'format_topcoll')); - $mform->addHelpButton('ctreset', 'ctreset', 'format_topcoll', '', true); - - $resetelements = array(); - $checkboxname = get_string('resetdisplayinstructions', 'format_topcoll'). - $OUTPUT->help_icon('resetdisplayinstructions', 'format_topcoll'); - $resetelements[] =& $mform->createElement('checkbox', 'resetdisplayinstructions', '', $checkboxname); - - if ($changelayout) { - $checkboxname = get_string('resetlayout', 'format_topcoll').$OUTPUT->help_icon('resetlayout', 'format_topcoll'); - $resetelements[] =& $mform->createElement('checkbox', 'resetlayout', '', $checkboxname); - } - - if ($changecolour) { - $checkboxname = get_string('resetcolour', 'format_topcoll').$OUTPUT->help_icon('resetcolour', 'format_topcoll'); - $resetelements[] =& $mform->createElement('checkbox', 'resetcolour', '', $checkboxname); - } - - if ($changetogglealignment) { - $checkboxname = get_string('resettogglealignment', 'format_topcoll'). - $OUTPUT->help_icon('resettogglealignment', 'format_topcoll'); - $resetelements[] =& $mform->createElement('checkbox', 'resettogglealignment', '', $checkboxname); - } - - if ($changetoggleiconset) { - $checkboxname = get_string('resettoggleiconset', 'format_topcoll'). - $OUTPUT->help_icon('resettoggleiconset', 'format_topcoll'); - $resetelements[] =& $mform->createElement('checkbox', 'resettoggleiconset', '', $checkboxname); - } - $elements[] = $mform->addGroup($resetelements, 'resetgroup', get_string('resetgrp', 'format_topcoll'), null, false); - - if ($resetall) { - $resetallelements = array(); - - $checkboxname = get_string('resetalldisplayinstructions', 'format_topcoll'). - $OUTPUT->help_icon('resetalldisplayinstructions', 'format_topcoll'); - $resetallelements[] =& $mform->createElement('checkbox', 'resetalldisplayinstructions', '', $checkboxname); - - $checkboxname = get_string('resetalllayout', 'format_topcoll'). - $OUTPUT->help_icon('resetalllayout', 'format_topcoll'); - $resetallelements[] =& $mform->createElement('checkbox', 'resetalllayout', '', $checkboxname); - - $checkboxname = get_string('resetallcolour', 'format_topcoll'). - $OUTPUT->help_icon('resetallcolour', 'format_topcoll'); - $resetallelements[] =& $mform->createElement('checkbox', 'resetallcolour', '', $checkboxname); - - $checkboxname = get_string('resetalltogglealignment', 'format_topcoll'). - $OUTPUT->help_icon('resetalltogglealignment', 'format_topcoll'); - $resetallelements[] =& $mform->createElement('checkbox', 'resetalltogglealignment', '', $checkboxname); - - $checkboxname = get_string('resetalltoggleiconset', 'format_topcoll'). - $OUTPUT->help_icon('resetalltoggleiconset', 'format_topcoll'); - $resetallelements[] =& $mform->createElement('checkbox', 'resetalltoggleiconset', '', $checkboxname); - - $elements[] = $mform->addGroup($resetallelements, 'resetallgroup', - get_string('resetallgrp', 'format_topcoll'), null, false); - } - } - - return $elements; - } - - /** - * Override if you need to perform some extra validation of the format options - * - * @param array $data array of ("fieldname"=>value) of submitted data - * @param array $files array of uploaded files "element_name"=>tmp_file_path - * @param array $errors errors already discovered in edit form validation - * @return array of "element_name"=>"error_description" if there are errors, - * or an empty array if everything is OK. - * Do not repeat errors from $errors param here - */ - public function edit_form_validation($data, $files, $errors) { - $retr = array(); - - if ($this->validate_colour($data['toggleforegroundcolour']) === false) { - $retr['toggleforegroundcolour'] = get_string('colourrule', 'format_topcoll'); - } - if ($this->validate_colour($data['toggleforegroundhovercolour']) === false) { - $retr['toggleforegroundhovercolour'] = get_string('colourrule', 'format_topcoll'); - } - if ($this->validate_colour($data['togglebackgroundcolour']) === false) { - $retr['togglebackgroundcolour'] = get_string('colourrule', 'format_topcoll'); - } - if ($this->validate_colour($data['togglebackgroundhovercolour']) === false) { - $retr['togglebackgroundhovercolour'] = get_string('colourrule', 'format_topcoll'); - } - - return $retr; - } - - /** - * Validates the colour that was entered by the user. - * Borrowed from 'admin_setting_configcolourpicker' in '/lib/adminlib.php'. - * - * I'm not completely happy with this solution as would rather embed in the colour - * picker code in the form, however I find this area rather fraut and I hear that - * Dan Poltawski (via MDL-42270) will be re-writing the forms lib so hopefully more - * developer friendly. - * - * Note: Colour names removed, but might consider putting them back in if asked, but - * at the moment that would require quite a few changes and coping with existing - * settings. Either convert the names to hex or allow them as valid values and - * fix the colour picker code and the CSS code in 'format.php' for the setting. - * - * Colour name to hex on: http://www.w3schools.com/cssref/css_colornames.asp. - * - * @param string $data the colour string to validate. - * @return true|false - */ - private function validate_colour($data) { - if (preg_match('/^#?([[:xdigit:]]{3}){1,2}$/', $data)) { - return true; - } else { - return false; - } - } - - /** - * Updates format options for a course - * - * In case if course format was changed to 'Collapsed Topics', we try to copy options - * 'coursedisplay', 'numsections' and 'hiddensections' from the previous format. - * If previous course format did not have 'numsections' option, we populate it with the - * current number of sections. The layout and colour defaults will come from 'course_format_options'. - * - * @param stdClass|array $data return value from {@link moodleform::get_data()} or array with data - * @param stdClass $oldcourse if this function is called from {@link update_course()} - * this object contains information about the course before update - * @return bool whether there were any changes to the options values - */ - public function update_course_format_options($data, $oldcourse = null) { - global $DB; // MDL-37976. - - /* - * Notes: Using 'unset' to really ensure that the reset form elements never get into the database. - * This has to be done here so that the reset occurs after we have done updates such that the - * reset itself is not seen as an update. - */ - $resetdisplayinstructions = false; - $resetlayout = false; - $resetcolour = false; - $resettogglealignment = false; - $resettoggleiconset = false; - $resetalldisplayinstructions = false; - $resetalllayout = false; - $resetallcolour = false; - $resetalltogglealignment = false; - $resetalltoggleiconset = false; - if (isset($data->resetdisplayinstructions) == true) { - $resetdisplayinstructions = true; - unset($data->resetdisplayinstructions); - } - if (isset($data->resetlayout) == true) { - $resetlayout = true; - unset($data->resetlayout); - } - if (isset($data->resetcolour) == true) { - $resetcolour = true; - unset($data->resetcolour); - } - if (isset($data->resettogglealignment) == true) { - $resettogglealignment = true; - unset($data->resettogglealignment); - } - if (isset($data->resettoggleiconset) == true) { - $resettoggleiconset = true; - unset($data->resettoggleiconset); - } - if (isset($data->resetalldisplayinstructions) == true) { - $resetalldisplayinstructions = true; - unset($data->resetalldisplayinstructions); - } - if (isset($data->resetalllayout) == true) { - $resetalllayout = true; - unset($data->resetalllayout); - } - if (isset($data->resetallcolour) == true) { - $resetallcolour = true; - unset($data->resetallcolour); - } - if (isset($data->resetalltogglealignment) == true) { - $resetalltogglealignment = true; - unset($data->resetalltogglealignment); - } - if (isset($data->resetalltoggleiconset) == true) { - $resetalltoggleiconset = true; - unset($data->resetalltoggleiconset); - } - - $data = (array) $data; - if ($oldcourse !== null) { - $oldcourse = (array) $oldcourse; - $options = $this->course_format_options(); - foreach ($options as $key => $unused) { - if (!array_key_exists($key, $data)) { - if (array_key_exists($key, $oldcourse)) { - $data[$key] = $oldcourse[$key]; - } else if ($key === 'numsections') { - /* If previous format does not have the field 'numsections' - * and $data['numsections'] is not set, - * we fill it with the maximum section number from the DB */ - $maxsection = $DB->get_field_sql('SELECT max(section) from {course_sections} WHERE course = ?', - array($this->courseid)); - if ($maxsection) { - // If there are no sections, or just default 0-section, 'numsections' will be set to default. - $data['numsections'] = $maxsection; - } - } - } - } - } - - $changes = $this->update_format_options($data); - - if ($changes && array_key_exists('numsections', $data)) { - // If the numsections was decreased, try to completely delete the orphaned sections (unless they are not empty). - $numsections = (int)$data['numsections']; - $maxsection = $DB->get_field_sql( - 'SELECT max(section) from {course_sections} WHERE course = ?', array($this->courseid)); - for ($sectionnum = $maxsection; $sectionnum > $numsections; $sectionnum--) { - if (!$this->delete_section($sectionnum, false)) { - break; - } - } - } - - // Now we can do the reset. - if (($resetalldisplayinstructions) || - ($resetalllayout) || - ($resetallcolour) || - ($resetalltogglealignment) || - ($resetalltoggleiconset)) { - $this->reset_topcoll_setting(0, $resetalldisplayinstructions, $resetalllayout, $resetallcolour, - $resetalltogglealignment, $resetalltoggleiconset); - $changes = true; - } else if (($resetdisplayinstructions) || - ($resetlayout) || - ($resetcolour) || - ($resettogglealignment) || - ($resettoggleiconset)) { - $this->reset_topcoll_setting($this->courseid, $resetdisplayinstructions, $resetlayout, $resetcolour, - $resettogglealignment, $resettoggleiconset); - $changes = true; - } - - return $changes; - } - - /** - * Is the section passed in the current section? - * - * @param stdClass $section The course_section entry from the DB - * @return bool true if the section is current - */ - public function is_section_current($section) { - $tcsettings = $this->get_settings(); - if (($tcsettings['layoutstructure'] == 2) || ($tcsettings['layoutstructure'] == 3)) { - if ($section->section < 1) { - return false; - } - - $timenow = time(); - $dates = $this->format_topcoll_get_section_dates($section, $this->get_course()); - - return (($timenow >= $dates->start) && ($timenow < $dates->end)); - } else if ($tcsettings['layoutstructure'] == 5) { - if ($section->section < 1) { - return false; - } - - $timenow = time(); - $day = $this->format_topcoll_get_section_day($section, $this->get_course()); - $onedayseconds = 86400; - return (($timenow >= $day) && ($timenow < ($day + $onedayseconds))); - } else { - return parent::is_section_current($section); - } - } - - /** - * Return the start and end date of the passed section. - * - * @param int|stdClass $section The course_section entry from the DB. - * @param stdClass $course The course entry from DB. - * @return stdClass property start for startdate, property end for enddate. - */ - private function format_topcoll_get_section_dates($section, $course) { - $oneweekseconds = 604800; - /* Hack alert. We add 2 hours to avoid possible DST problems. (e.g. we go into daylight - savings and the date changes. */ - $startdate = $course->startdate + 7200; - - $dates = new stdClass(); - if (is_object($section)) { - $section = $section->section; - } - - $dates->start = $startdate + ($oneweekseconds * ($section - 1)); - $dates->end = $dates->start + $oneweekseconds; - - return $dates; - } - - /** - * Return the date of the passed section. - * - * @param int|stdClass $section The course_section entry from the DB. - * @param stdClass $course The course entry from DB. - * @return stdClass property date. - */ - private function format_topcoll_get_section_day($section, $course) { - $onedayseconds = 86400; - /* Hack alert. We add 2 hours to avoid possible DST problems. (e.g. we go into daylight - savings and the date changes. */ - $startdate = $course->startdate + 7200; - - if (is_object($section)) { - $section = $section->section; - } - - $day = $startdate + ($onedayseconds * ($section - 1)); - - return $day; - } - - /** - * Resets the format setting to the default. - * @param int $courseid If not 0, then a specific course to reset. - * @param int $displayinstructions If true, reset the display instructions to the default in the settings for the format. - * @param int $layout If true, reset the layout to the default in the settings for the format. - * @param int $colour If true, reset the colour to the default in the settings for the format. - * @param int $togglealignment If true, reset the toggle alignment to the default in the settings for the format. - * @param int $toggleiconset If true, reset the toggle icon set to the default in the settings for the format. - */ - public function reset_topcoll_setting($courseid, $displayinstructions, $layout, $colour, $togglealignment, $toggleiconset) { - global $DB, $USER, $COURSE; - - $coursecontext = context_course::instance($COURSE->id); - - $currentcourseid = 0; - if ($courseid == 0) { - $records = $DB->get_records('course_format_options', array('format' => $this->format), '', 'id,courseid'); - } else { - $records = $DB->get_records('course_format_options', array('courseid' => $courseid, 'format' => $this->format), - '', 'id,courseid'); - } - - $resetallifall = ((is_siteadmin($USER)) || ($courseid != 0)); // Will be true if reset all capability or a single course. - - $updatedata = array(); - $updatedisplayinstructions = false; - $updatelayout = false; - $updatetogglealignment = false; - $updatecolour = false; - $updatetoggleiconset = false; - if ($displayinstructions && $resetallifall) { - $updatedata['displayinstructions'] = get_config('format_topcoll', 'defaultdisplayinstructions'); - $updatedisplayinstructions = true; - } - if ($layout && has_capability('format/topcoll:changelayout', $coursecontext) && $resetallifall) { - $updatedata['coursedisplay'] = get_config('format_topcoll', 'defaultcoursedisplay'); - $updatedata['layoutelement'] = get_config('format_topcoll', 'defaultlayoutelement'); - $updatedata['layoutstructure'] = get_config('format_topcoll', 'defaultlayoutstructure'); - $updatedata['layoutcolumns'] = get_config('format_topcoll', 'defaultlayoutcolumns'); - $updatedata['layoutcolumnorientation'] = get_config('format_topcoll', 'defaultlayoutcolumnorientation'); - $updatedata['toggleiconposition'] = get_config('format_topcoll', 'defaulttoggleiconposition'); - $updatedata['showsectionsummary'] = get_config('format_topcoll', 'defaultshowsectionsummary'); - $updatelayout = true; - } - if ($togglealignment && has_capability('format/topcoll:changetogglealignment', $coursecontext) && $resetallifall) { - $updatedata['togglealignment'] = get_config('format_topcoll', 'defaulttogglealignment'); - $updatetogglealignment = true; - } - if ($colour && has_capability('format/topcoll:changecolour', $coursecontext) && $resetallifall) { - $updatedata['toggleforegroundcolour'] = get_config('format_topcoll', 'defaulttgfgcolour'); - $updatedata['toggleforegroundhovercolour'] = get_config('format_topcoll', 'defaulttgfghvrcolour'); - $updatedata['togglebackgroundcolour'] = get_config('format_topcoll', 'defaulttgbgcolour'); - $updatedata['togglebackgroundhovercolour'] = get_config('format_topcoll', 'defaulttgbghvrcolour'); - $updatecolour = true; - } - if ($toggleiconset && has_capability('format/topcoll:changetoggleiconset', $coursecontext) && $resetallifall) { - $updatedata['toggleiconset'] = get_config('format_topcoll', 'defaulttoggleiconset'); - $updatedata['toggleallhover'] = get_config('format_topcoll', 'defaulttoggleallhover'); - $updatetoggleiconset = true; - } - - foreach ($records as $record) { - if ($currentcourseid != $record->courseid) { - $currentcourseid = $record->courseid; // Only do once per course. - if (($updatedisplayinstructions) || - ($updatelayout) || - ($updatetogglealignment) || - ($updatecolour) || - ($updatetoggleiconset)) { - $ourcourseid = $this->courseid; - $this->courseid = $currentcourseid; - $this->update_format_options($updatedata); - $this->courseid = $ourcourseid; - } - } - } - } - - /** - * Restores the course settings when restoring a Moodle 2.3 or below (bar 1.9) course and sets the settings when upgrading - * from a prevous version. Hence no need for 'coursedisplay' as that is a core rather than CT specific setting and not - * in the old 'format_topcoll_settings' table. - * @param int $courseid If not 0, then a specific course to reset. - * @param int $layoutelement The layout element. - * @param int $layoutstructure The layout structure. - * @param int $layoutcolumns The layout columns. - * @param int $tgfgcolour The foreground colour. - * @param int $tgbgcolour The background colour. - * @param int $tgbghvrcolour The background hover colour. - */ - public function restore_topcoll_setting($courseid, $layoutelement, $layoutstructure, $layoutcolumns, $tgfgcolour, - $tgbgcolour, $tgbghvrcolour) { - $currentcourseid = $this->courseid; // Save for later - stack data model. - $this->courseid = $courseid; - // Create data array. - $data = array( - 'layoutelement' => $layoutelement, - 'layoutstructure' => $layoutstructure, - 'layoutcolumns' => $layoutcolumns, - 'toggleforegroundcolour' => $tgfgcolour, - 'togglebackgroundcolour' => $tgbgcolour, - 'togglebackgroundhovercolour' => $tgbghvrcolour); - - $lco = get_config('format_topcoll', 'defaultlayoutcolumnorientation'); - if (empty($lco)) { - // Upgrading from M2.3 and the defaults in 'settings.php' have not been processed at this time. - // Defaults taken from 'settings.php'. - $data['displayinstructions'] = get_config('format_topcoll', 'defaultdisplayinstructions'); - $data['layoutcolumnorientation'] = get_config('format_topcoll', 'defaultlayoutcolumnorientation'); - $data['showsectionsummary'] = get_config('format_topcoll', 'defaultshowsectionsummary'); - $data['togglealignment'] = get_config('format_topcoll', 'defaulttogglealignment'); - $data['toggleallhover'] = get_config('format_topcoll', 'defaulttoggleallhover'); - $data['toggleiconposition'] = get_config('format_topcoll', 'defaulttoggleiconposition'); - $data['toggleiconset'] = get_config('format_topcoll', 'defaulttoggleiconset'); - } - $this->update_course_format_options($data); - - $this->courseid = $currentcourseid; - } - - /** - * Updates the number of columns when the renderer detects that they are wrong. - * @param int $layoutcolumns The layout columns to use, see tcconfig.php. - */ - public function update_topcoll_columns_setting($layoutcolumns) { - // Create data array. - $data = array('layoutcolumns' => $layoutcolumns); - - $this->update_course_format_options($data); - } - - /** - * Whether this format allows to delete sections - * - * Do not call this function directly, instead use {@link course_can_delete_section()} - * - * @param int|stdClass|section_info $section - * @return bool - */ - public function can_delete_section($section) { - return true; - } -} - -/** - * The string that is used to describe a section of the course. - * - * @return string The section description. - */ -function callback_topcoll_definition() { - return get_string('sectionname', 'format_topcoll'); -} - -/** - * Deletes the user preference entries for the given course upon course deletion. - * CONTRIB-3520. - */ -function format_topcoll_delete_course($courseid) { - global $DB; - $DB->delete_records("user_preferences", array("name" => 'topcoll_toggle_' . $courseid)); +. + +/** + * Collapsed Topics Information + * + * A topic based format that solves the issue of the 'Scroll of Death' when a course has many topics. All topics + * except zero have a toggle that displays that topic. One or more topics can be displayed at any given time. + * Toggles are persistent on a per browser session per course basis but can be made to persist longer by a small + * code change. Full installation instructions, code adaptions and credits are included in the 'Readme.md' file. + * + * @package course/format + * @subpackage topcoll + * @version See the value of '$plugin->version' in below. + * @copyright © 2012-onwards G J Barnard in respect to modifications of standard topics format. + * @author G J Barnard - gjbarnard at gmail dot com and {@link http://moodle.org/user/profile.php?id=442195} + * @link http://docs.moodle.org/en/Collapsed_Topics_course_format + * @license http://www.gnu.org/copyleft/gpl.html GNU Public License + * + */ +require_once($CFG->dirroot . '/course/format/lib.php'); // For format_base. + +class format_topcoll extends format_base { + private $settings; + + /** + * Creates a new instance of class + * + * Please use {@link course_get_format($courseorid)} to get an instance of the format class + * + * @param string $format + * @param int $courseid + * @return format_topcoll + */ + protected function __construct($format, $courseid) { + if ($courseid === 0) { + global $COURSE; + $courseid = $COURSE->id; // Save lots of global $COURSE as we will never be the site course. + } + parent::__construct($format, $courseid); + } + + /** + * Returns the format's settings and gets them if they do not exist. + * @return type The settings as an array. + */ + public function get_settings() { + if (empty($this->settings) == true) { + $this->settings = $this->get_format_options(); + } + return $this->settings; + } + + /** + * Indicates this format uses sections. + * + * @return bool Returns true + */ + public function uses_sections() { + return true; + } + + /** + * Gets the name for the provided section. + * + * @param int|stdClass $section Section object from database or just field section.section + * @return string The section name. + */ + public function get_section_name($section) { + $course = $this->get_course(); + // Don't add additional text as called in creating the navigation. + return $this->get_topcoll_section_name($course, $section, false); + } + + /** + * Returns the default section name for the format. + * + * @param stdClass $section Section object from database or just field course_sections section + * @return string The default value for the section name. + */ + public function get_default_section_name($section) { + /* Follow the same logic so that this method is supported. The MDL-51610 enchancement refactored things, + but that is not appropriate for us. */ + return $this->get_section_name($section); + } + + /** + * Gets the name for the provided course, section and state if need to add addional text. + * + * @param stdClass $course The course entry from DB + * @param int|stdClass $section Section object from database or just field section.section + * @param boolean $additional State to add additional text yes = true or no = false. + * @return string The section name. + */ + public function get_topcoll_section_name($course, $section, $additional) { + $thesection = $this->get_section($section); + if (is_null($thesection)) { + $thesection = new stdClass; + $thesection->name = ''; + if (is_object($section)) { + $thesection->section = $section->section; + } else { + $thesection->section = $section; + } + } + $o = ''; + $tcsettings = $this->get_settings(); + $tcsectionsettings = $this->get_format_options($thesection->section); + $coursecontext = context_course::instance($course->id); + + // We can't add a node without any text. + if ((string) $thesection->name !== '') { + $o .= format_string($thesection->name, true, array('context' => $coursecontext)); + if (($thesection->section != 0) && (($tcsettings['layoutstructure'] == 2) || + ($tcsettings['layoutstructure'] == 3) || ($tcsettings['layoutstructure'] == 5))) { + $o .= ' '; + if (empty($tcsectionsettings['donotshowdate'])) { + if ($additional == true) { // Break 'br' tags break backups! + $o .= html_writer::empty_tag('br'); + } + $o .= $this->get_section_dates($section, $course, $tcsettings); + } + } + } else if ($thesection->section == 0) { + $o = get_string('section0name', 'format_topcoll'); + } else { + if (($tcsettings['layoutstructure'] == 1) || ($tcsettings['layoutstructure'] == 4)) { + $o = get_string('sectionname', 'format_topcoll') . ' ' . $thesection->section; + } else { + $o .= $this->get_section_dates($section, $course, $tcsettings); + } + } + + /* + * Now done here so that the drag and drop titles will be the correct strings as swapped in format.js. + * But only if we are using toggles which will be if all sections are on one page or we are editing the main page + * when in one section per page which is coded in 'renderer.php/print_multiple_section_page()' when it calls + * 'section_header()' as that gets called from 'format.php' when there is no entry for '$displaysetting' - confused? + * I was, took ages to figure. + */ + if (($additional == true) && ($thesection->section != 0)) { + switch ($tcsettings['layoutelement']) { + case 1: + case 2: + case 3: + case 4: + // The word 'Toggle'. + $o .= ' - ' . get_string('topcolltoggle', 'format_topcoll') . ''; + break; + } + } + + return $o; + } + + public function get_section_dates($section, $course, $tcsettings) { + $dateformat = get_string('strftimedateshort'); + $o = ''; + if ($tcsettings['layoutstructure'] == 5) { + $day = $this->format_topcoll_get_section_day($section, $course); + + $weekday = userdate($day, $dateformat); + $o = $weekday; + } else { + $dates = $this->format_topcoll_get_section_dates($section, $course); + + // We subtract 24 hours for display purposes. + $dates->end = ($dates->end - 86400); + + $weekday = userdate($dates->start, $dateformat); + $endweekday = userdate($dates->end, $dateformat); + $o = $weekday . ' - ' . $endweekday; + } + return $o; + } + + /** + * The URL to use for the specified course (with section) + * + * @param int|stdClass $section Section object from database or just field course_sections.section + * if omitted the course view page is returned + * @param array $options options for view URL. At the moment core uses: + * 'navigation' (bool) if true and section has no separate page, the function returns null + * 'sr' (int) used by multipage formats to specify to which section to return + * @return null|moodle_url + */ + public function get_view_url($section, $options = array()) { + $course = $this->get_course(); + $url = new moodle_url('/course/view.php', array('id' => $course->id)); + + $sr = null; + if (array_key_exists('sr', $options)) { + $sr = $options['sr']; + } + if (is_object($section)) { + $sectionno = $section->section; + } else { + $sectionno = $section; + } + if ($sectionno !== null) { + if ($sr !== null) { + if ($sr) { + $usercoursedisplay = COURSE_DISPLAY_MULTIPAGE; + $sectionno = $sr; + } else { + $usercoursedisplay = COURSE_DISPLAY_SINGLEPAGE; + } + } else { + $usercoursedisplay = $course->coursedisplay; + } + if ($sectionno != 0 && $usercoursedisplay == COURSE_DISPLAY_MULTIPAGE) { + $url->param('section', $sectionno); + } else { + if (!empty($options['navigation'])) { + return null; + } + $url->set_anchor('section-' . $sectionno); + } + } + return $url; + } + + /** + * Returns the information about the ajax support in the given source format + * + * The returned object's property (boolean)capable indicates that + * the course format supports Moodle course ajax features. + * The property (array)testedbrowsers can be used as a parameter for {@link ajaxenabled()}. + * + * @return stdClass + */ + public function supports_ajax() { + $ajaxsupport = new stdClass(); + $ajaxsupport->capable = true; + return $ajaxsupport; + } + + /** + * Custom action after section has been moved in AJAX mode + * + * Used in course/rest.php + * + * @return array This will be passed in ajax respose + */ + public function ajax_section_move() { + $titles = array(); + $current = -1; // MDL-33546. + $weekformat = false; + $tcsettings = $this->get_settings(); + if (($tcsettings['layoutstructure'] == 2) || ($tcsettings['layoutstructure'] == 3) || + ($tcsettings['layoutstructure'] == 5)) { + $weekformat = true; + } + $course = $this->get_course(); + $modinfo = get_fast_modinfo($course); + if ($sections = $modinfo->get_section_info_all()) { + foreach ($sections as $number => $section) { + $titles[$number] = $this->get_topcoll_section_name($course, $section, true); + if (($weekformat == true) && ($this->is_section_current($section))) { + $current = $number; // Only set if a week based course to keep the current week in the same place. + } + } + } + return array('sectiontitles' => $titles, 'current' => $current, 'action' => 'move'); + } + + /** + * Returns the list of blocks to be automatically added for the newly created course + * + * @return array of default blocks, must contain two keys BLOCK_POS_LEFT and BLOCK_POS_RIGHT + * each of values is an array of block names (for left and right side columns) + */ + public function get_default_blocks() { + return array( + BLOCK_POS_LEFT => array(), + BLOCK_POS_RIGHT => array('search_forums', 'news_items', 'calendar_upcoming', 'recent_activity') + ); + } + + public function section_format_options($foreditform = false) { + static $sectionformatoptions = false; + + if ($sectionformatoptions === false) { + $sectionformatoptions = array( + 'donotshowdate' => array( + 'default' => 0, + 'type' => PARAM_INT + ) + ); + } + if ($foreditform && !isset($sectionformatoptions['donotshowdate']['label'])) { + $sectionformatoptionsedit = array( + 'donotshowdate' => array( + 'label' => new lang_string('donotshowdate', 'format_topcoll'), + 'help' => 'donotshowdate', + 'help_component' => 'format_topcoll', + 'element_type' => 'checkbox' + ) + ); + $sectionformatoptions = array_merge_recursive($sectionformatoptions, $sectionformatoptionsedit); + } + + $tcsettings = $this->get_settings(); + if (($tcsettings['layoutstructure'] == 2) || ($tcsettings['layoutstructure'] == 3) || + ($tcsettings['layoutstructure'] == 5)) { + // Weekly layout. + return $sectionformatoptions; + } else { + return array(); + } + } + /** + * Definitions of the additional options that this course format uses for course + * + * Collapsed Topics format uses the following options (until extras are migrated): + * - coursedisplay + * - numsections + * - hiddensections + * + * @param bool $foreditform + * @return array of options + */ + public function course_format_options($foreditform = false) { + static $courseformatoptions = false; + + if ($courseformatoptions === false) { + /* Note: Because 'admin_setting_configcolourpicker' in 'settings.php' needs to use a prefixing '#' + this needs to be stripped off here if it's there for the format's specific colour picker. */ + $defaulttgfgcolour = get_config('format_topcoll', 'defaulttgfgcolour'); + if ($defaulttgfgcolour[0] == '#') { + $defaulttgfgcolour = substr($defaulttgfgcolour, 1); + } + $defaulttgfghvrcolour = get_config('format_topcoll', 'defaulttgfghvrcolour'); + if ($defaulttgfghvrcolour[0] == '#') { + $defaulttgfghvrcolour = substr($defaulttgfghvrcolour, 1); + } + $defaulttgbgcolour = get_config('format_topcoll', 'defaulttgbgcolour'); + if ($defaulttgbgcolour[0] == '#') { + $defaulttgbgcolour = substr($defaulttgbgcolour, 1); + } + $defaulttgbghvrcolour = get_config('format_topcoll', 'defaulttgbghvrcolour'); + if ($defaulttgbghvrcolour[0] == '#') { + $defaulttgbghvrcolour = substr($defaulttgbghvrcolour, 1); + } + $readme = new moodle_url('/course/format/topcoll/Readme.md'); + $readme = html_writer::link($readme, 'Readme.md', array('target' => '_blank')); + $courseconfig = get_config('moodlecourse'); + $courseformatoptions = array( + 'numsections' => array( + 'default' => $courseconfig->numsections, + 'type' => PARAM_INT, + ), + 'hiddensections' => array( + 'default' => $courseconfig->hiddensections, + 'type' => PARAM_INT, + ), + 'coursedisplay' => array( + 'default' => get_config('format_topcoll', 'defaultcoursedisplay'), + 'type' => PARAM_INT, + ), + 'displayinstructions' => array( + 'default' => get_config('format_topcoll', 'defaultdisplayinstructions'), + 'type' => PARAM_INT, + ), + 'layoutelement' => array( + 'default' => get_config('format_topcoll', 'defaultlayoutelement'), + 'type' => PARAM_INT, + ), + 'layoutstructure' => array( + 'default' => get_config('format_topcoll', 'defaultlayoutstructure'), + 'type' => PARAM_INT, + ), + 'layoutcolumns' => array( + 'default' => get_config('format_topcoll', 'defaultlayoutcolumns'), + 'type' => PARAM_INT, + ), + 'layoutcolumnorientation' => array( + 'default' => get_config('format_topcoll', 'defaultlayoutcolumnorientation'), + 'type' => PARAM_INT, + ), + 'togglealignment' => array( + 'default' => get_config('format_topcoll', 'defaulttogglealignment'), + 'type' => PARAM_INT, + ), + 'toggleiconposition' => array( + 'default' => get_config('format_topcoll', 'defaulttoggleiconposition'), + 'type' => PARAM_INT, + ), + 'toggleiconset' => array( + 'default' => get_config('format_topcoll', 'defaulttoggleiconset'), + 'type' => PARAM_ALPHA, + ), + 'toggleallhover' => array( + 'default' => get_config('format_topcoll', 'defaulttoggleallhover'), + 'type' => PARAM_INT, + ), + 'toggleforegroundcolour' => array( + 'default' => $defaulttgfgcolour, + 'type' => PARAM_ALPHANUM, + ), + 'toggleforegroundhovercolour' => array( + 'default' => $defaulttgfghvrcolour, + 'type' => PARAM_ALPHANUM, + ), + 'togglebackgroundcolour' => array( + 'default' => $defaulttgbgcolour, + 'type' => PARAM_ALPHANUM, + ), + 'togglebackgroundhovercolour' => array( + 'default' => $defaulttgbghvrcolour, + 'type' => PARAM_ALPHANUM, + ), + 'showsectionsummary' => array( + 'default' => get_config('format_topcoll', 'defaultshowsectionsummary'), + 'type' => PARAM_INT, + ), + 'readme' => array( + 'default' => get_string('readme_desc', 'format_topcoll', array('url' => $readme)), + 'type' => PARAM_ALPHA, + ) + ); + } + if ($foreditform && !isset($courseformatoptions['coursedisplay']['label'])) { + /* Note: Because 'admin_setting_configcolourpicker' in 'settings.php' needs to use a prefixing '#' + this needs to be stripped off here if it's there for the format's specific colour picker. */ + $defaulttgfgcolour = get_config('format_topcoll', 'defaulttgfgcolour'); + if ($defaulttgfgcolour[0] == '#') { + $defaulttgfgcolour = substr($defaulttgfgcolour, 1); + } + $defaulttgfghvrcolour = get_config('format_topcoll', 'defaulttgfghvrcolour'); + if ($defaulttgfghvrcolour[0] == '#') { + $defaulttgfghvrcolour = substr($defaulttgfghvrcolour, 1); + } + $defaulttgbgcolour = get_config('format_topcoll', 'defaulttgbgcolour'); + if ($defaulttgbgcolour[0] == '#') { + $defaulttgbgcolour = substr($defaulttgbgcolour, 1); + } + $defaulttgbghvrcolour = get_config('format_topcoll', 'defaulttgbghvrcolour'); + if ($defaulttgbghvrcolour[0] == '#') { + $defaulttgbghvrcolour = substr($defaulttgbghvrcolour, 1); + } + + $coursecontext = context_course::instance($this->courseid); + + $courseconfig = get_config('moodlecourse'); + $sectionmenu = array(); + for ($i = 0; $i <= $courseconfig->maxsections; $i++) { + $sectionmenu[$i] = "$i"; + } + $courseformatoptionsedit = array( + 'numsections' => array( + 'label' => new lang_string('numbersections', 'format_topcoll'), + 'element_type' => 'select', + 'element_attributes' => array($sectionmenu), + ), + 'hiddensections' => array( + 'label' => new lang_string('hiddensections'), + 'help' => 'hiddensections', + 'help_component' => 'moodle', + 'element_type' => 'select', + 'element_attributes' => array( + array(0 => new lang_string('hiddensectionscollapsed'), + 1 => new lang_string('hiddensectionsinvisible') + ) + ), + ), + 'coursedisplay' => array( + 'label' => new lang_string('coursedisplay'), + 'element_type' => 'select', + 'element_attributes' => array( + array( + COURSE_DISPLAY_SINGLEPAGE => new lang_string('coursedisplay_single'), + COURSE_DISPLAY_MULTIPAGE => new lang_string('coursedisplay_multi') + ) + ), + 'help' => 'coursedisplay', + 'help_component' => 'moodle', + ), + 'displayinstructions' => array( + 'label' => new lang_string('displayinstructions', 'format_topcoll'), + 'help' => 'displayinstructions', + 'help_component' => 'format_topcoll', + 'element_type' => 'select', + 'element_attributes' => array( + array(1 => new lang_string('no'), + 2 => new lang_string('yes')) + ) + ) + ); + if (has_capability('format/topcoll:changelayout', $coursecontext)) { + $courseformatoptionsedit['layoutelement'] = array( + 'label' => new lang_string('setlayoutelements', 'format_topcoll'), + 'help' => 'setlayoutelements', + 'help_component' => 'format_topcoll', + 'element_type' => 'select', + 'element_attributes' => array( // In insertion order and not numeric for sorting purposes. + array( + // Toggle word, toggle section x and section number. + 1 => new lang_string('setlayout_all', 'format_topcoll'), + // Toggle word and toggle section x. + 3 => new lang_string('setlayout_toggle_word_section_x', 'format_topcoll'), + // Toggle word and section number. + 2 => new lang_string('setlayout_toggle_word_section_number', 'format_topcoll'), + // Toggle section x and section number. + 5 => new lang_string('setlayout_toggle_section_x_section_number', 'format_topcoll'), + // Toggle word. + 4 => new lang_string('setlayout_toggle_word', 'format_topcoll'), + // Toggle section x. + 8 => new lang_string('setlayout_toggle_section_x', 'format_topcoll'), + // Section number. + 6 => new lang_string('setlayout_section_number', 'format_topcoll'), + // No additions. + 7 => new lang_string('setlayout_no_additions', 'format_topcoll')) + ) + ); + $courseformatoptionsedit['layoutstructure'] = array( + 'label' => new lang_string('setlayoutstructure', 'format_topcoll'), + 'help' => 'setlayoutstructure', + 'help_component' => 'format_topcoll', + 'element_type' => 'select', + 'element_attributes' => array( + array( + // Topic. + 1 => new lang_string('setlayoutstructuretopic', 'format_topcoll'), + // Week. + 2 => new lang_string('setlayoutstructureweek', 'format_topcoll'), + // Current Week First. + 3 => new lang_string('setlayoutstructurelatweekfirst', 'format_topcoll'), + // Current Topic First. + 4 => new lang_string('setlayoutstructurecurrenttopicfirst', 'format_topcoll'), + // Day. + 5 => new lang_string('setlayoutstructureday', 'format_topcoll')) + ) + ); + $courseformatoptionsedit['layoutcolumns'] = array( + 'label' => new lang_string('setlayoutcolumns', 'format_topcoll'), + 'help' => 'setlayoutcolumns', + 'help_component' => 'format_topcoll', + 'element_type' => 'select', + 'element_attributes' => array( + array(1 => new lang_string('one', 'format_topcoll'), // Default. + 2 => new lang_string('two', 'format_topcoll'), // Two. + 3 => new lang_string('three', 'format_topcoll'), // Three. + 4 => new lang_string('four', 'format_topcoll')) // Four. + ) + ); + $courseformatoptionsedit['layoutcolumnorientation'] = array( + 'label' => new lang_string('setlayoutcolumnorientation', 'format_topcoll'), + 'help' => 'setlayoutcolumnorientation', + 'help_component' => 'format_topcoll', + 'element_type' => 'select', + 'element_attributes' => array( + array(1 => new lang_string('columnvertical', 'format_topcoll'), + 2 => new lang_string('columnhorizontal', 'format_topcoll')) // Default. + ) + ); + $courseformatoptionsedit['toggleiconposition'] = array( + 'label' => new lang_string('settoggleiconposition', 'format_topcoll'), + 'help' => 'settoggleiconposition', + 'help_component' => 'format_topcoll', + 'element_type' => 'select', + 'element_attributes' => array( + array(1 => new lang_string('left', 'format_topcoll'), // Left. + 2 => new lang_string('right', 'format_topcoll')) // Right. + ) + ); + $courseformatoptionsedit['showsectionsummary'] = array( + 'label' => new lang_string('setshowsectionsummary', 'format_topcoll'), + 'help' => 'setshowsectionsummary', + 'help_component' => 'format_topcoll', + 'element_type' => 'select', + 'element_attributes' => array( + array(1 => new lang_string('no'), + 2 => new lang_string('yes')) + ) + ); + } else { + $courseformatoptionsedit['layoutelement'] = array( + 'label' => get_config('format_topcoll', 'defaultlayoutelement'), 'element_type' => 'hidden'); + $courseformatoptionsedit['layoutstructure'] = array( + 'label' => get_config('format_topcoll', 'defaultlayoutstructure'), 'element_type' => 'hidden'); + $courseformatoptionsedit['layoutcolumns'] = array( + 'label' => get_config('format_topcoll', 'defaultlayoutcolumns'), 'element_type' => 'hidden'); + $courseformatoptionsedit['layoutcolumnorientation'] = array( + 'label' => get_config('format_topcoll', 'defaultlayoutcolumnorientation'), 'element_type' => 'hidden'); + $courseformatoptionsedit['toggleiconposition'] = array( + 'label' => get_config('format_topcoll', 'defaulttoggleiconposition'), 'element_type' => 'hidden'); + $courseformatoptionsedit['showsectionsummary'] = array( + 'label' => get_config('format_topcoll', 'defaultshowsectionsummary'), 'element_type' => 'hidden'); + } + + if (has_capability('format/topcoll:changetogglealignment', $coursecontext)) { + $courseformatoptionsedit['togglealignment'] = array( + 'label' => new lang_string('settogglealignment', 'format_topcoll'), + 'help' => 'settogglealignment', + 'help_component' => 'format_topcoll', + 'element_type' => 'select', + 'element_attributes' => array( + array(1 => new lang_string('left', 'format_topcoll'), // Left. + 2 => new lang_string('center', 'format_topcoll'), // Centre. + 3 => new lang_string('right', 'format_topcoll')) // Right. + ) + ); + } else { + $courseformatoptionsedit['togglealignment'] = array( + 'label' => get_config('format_topcoll', 'defaulttogglealignment'), 'element_type' => 'hidden'); + } + + if (has_capability('format/topcoll:changetoggleiconset', $coursecontext)) { + $courseformatoptionsedit['toggleiconset'] = array( + 'label' => new lang_string('settoggleiconset', 'format_topcoll'), + 'help' => 'settoggleiconset', + 'help_component' => 'format_topcoll', + 'element_type' => 'select', + 'element_attributes' => array( + array( + 'arrow' => new lang_string('arrow', 'format_topcoll'), // Arrow icon set. + 'bulb' => new lang_string('bulb', 'format_topcoll'), // Bulb icon set. + 'cloud' => new lang_string('cloud', 'format_topcoll'), // Cloud icon set. + 'eye' => new lang_string('eye', 'format_topcoll'), // Eye icon set. + 'groundsignal' => new lang_string('groundsignal', 'format_topcoll'), // Ground signal set. + 'led' => new lang_string('led', 'format_topcoll'), // LED icon set. + 'point' => new lang_string('point', 'format_topcoll'), // Point icon set. + 'power' => new lang_string('power', 'format_topcoll'), // Power icon set. + 'radio' => new lang_string('radio', 'format_topcoll'), // Radio icon set. + 'smiley' => new lang_string('smiley', 'format_topcoll'), // Smiley icon set. + 'square' => new lang_string('square', 'format_topcoll'), // Square icon set. + 'sunmoon' => new lang_string('sunmoon', 'format_topcoll'), // Sun / Moon icon set. + 'switch' => new lang_string('switch', 'format_topcoll')) // Switch icon set. + ) + ); + $courseformatoptionsedit['toggleallhover'] = array( + 'label' => new lang_string('settoggleallhover', 'format_topcoll'), + 'help' => 'settoggleallhover', + 'help_component' => 'format_topcoll', + 'element_type' => 'select', + 'element_attributes' => array( + array(1 => new lang_string('no'), + 2 => new lang_string('yes')) + ) + ); + } else { + $courseformatoptionsedit['toggleiconset'] = array( + 'label' => get_config('format_topcoll', 'defaulttoggleiconset'), 'element_type' => 'hidden'); + $courseformatoptionsedit['toggleallhover'] = array( + 'label' => get_config('format_topcoll', 'defaulttoggleallhover'), 'element_type' => 'hidden'); + } + + if (has_capability('format/topcoll:changecolour', $coursecontext)) { + $courseformatoptionsedit['toggleforegroundcolour'] = array( + 'label' => new lang_string('settoggleforegroundcolour', 'format_topcoll'), + 'help' => 'settoggleforegroundcolour', + 'help_component' => 'format_topcoll', + 'element_type' => 'tccolourpopup', + 'element_attributes' => array( + array('tabindex' => -1, 'value' => $defaulttgfgcolour) + ) + ); + $courseformatoptionsedit['toggleforegroundhovercolour'] = array( + 'label' => new lang_string('settoggleforegroundhovercolour', 'format_topcoll'), + 'help' => 'settoggleforegroundhovercolour', + 'help_component' => 'format_topcoll', + 'element_type' => 'tccolourpopup', + 'element_attributes' => array( + array('tabindex' => -1, 'value' => $defaulttgfghvrcolour) + ) + ); + $courseformatoptionsedit['togglebackgroundcolour'] = array( + 'label' => new lang_string('settogglebackgroundcolour', 'format_topcoll'), + 'help' => 'settogglebackgroundcolour', + 'help_component' => 'format_topcoll', + 'element_type' => 'tccolourpopup', + 'element_attributes' => array( + array('tabindex' => -1, 'value' => $defaulttgbgcolour) + ) + ); + $courseformatoptionsedit['togglebackgroundhovercolour'] = array( + 'label' => new lang_string('settogglebackgroundhovercolour', 'format_topcoll'), + 'help' => 'settogglebackgroundhovercolour', + 'help_component' => 'format_topcoll', + 'element_type' => 'tccolourpopup', + 'element_attributes' => array( + array('tabindex' => -1, 'value' => $defaulttgbghvrcolour) + ) + ); + } else { + $courseformatoptionsedit['toggleforegroundcolour'] = array( + 'label' => $defaulttgfgcolour, 'element_type' => 'hidden'); + $courseformatoptionsedit['toggleforegroundhovercolour'] = array( + 'label' => $defaulttgfghvrcolour, 'element_type' => 'hidden'); + $courseformatoptionsedit['togglebackgroundcolour'] = array( + 'label' => $defaulttgbgcolour, 'element_type' => 'hidden'); + $courseformatoptionsedit['togglebackgroundhovercolour'] = array( + 'label' => $defaulttgbghvrcolour, 'element_type' => 'hidden'); + } + $courseformatoptionsedit['readme'] = array( + 'label' => get_string('readme_title', 'format_topcoll'), + 'element_type' => 'static' + ); + $courseformatoptions = array_merge_recursive($courseformatoptions, $courseformatoptionsedit); + } + return $courseformatoptions; + } + + /** + * Adds format options elements to the course/section edit form + * + * This function is called from {@link course_edit_form::definition_after_data()} + * + * @param MoodleQuickForm $mform form the elements are added to + * @param bool $forsection 'true' if this is a section edit form, 'false' if this is course edit form + * @return array array of references to the added form elements + */ + public function create_edit_form_elements(&$mform, $forsection = false) { + global $CFG, $OUTPUT; + MoodleQuickForm::registerElementType('tccolourpopup', "$CFG->dirroot/course/format/topcoll/js/tc_colourpopup.php", + 'MoodleQuickForm_tccolourpopup'); + + $elements = parent::create_edit_form_elements($mform, $forsection); + if ($forsection == false) { + global $COURSE, $USER; + /* + Increase the number of sections combo box values if the user has increased the number of sections + using the icon on the course page beyond course 'maxsections' or course 'maxsections' has been + reduced below the number of sections already set for the course on the site administration course + defaults page. This is so that the number of sections is not reduced leaving unintended orphaned + activities / resources. + */ + $maxsections = get_config('moodlecourse', 'maxsections'); + $numsections = $mform->getElementValue('numsections'); + $numsections = $numsections[0]; + if ($numsections > $maxsections) { + $element = $mform->getElement('numsections'); + for ($i = ($maxsections + 1); $i <= $numsections; $i++) { + $element->addOption("$i", $i); + } + } + + $coursecontext = context_course::instance($COURSE->id); + + $changelayout = has_capability('format/topcoll:changelayout', $coursecontext); + $changecolour = has_capability('format/topcoll:changecolour', $coursecontext); + $changetogglealignment = has_capability('format/topcoll:changetogglealignment', $coursecontext); + $changetoggleiconset = has_capability('format/topcoll:changetoggleiconset', $coursecontext); + $resetall = is_siteadmin($USER); // Site admins only. + + $elements[] = $mform->addElement('header', 'ctreset', get_string('ctreset', 'format_topcoll')); + $mform->addHelpButton('ctreset', 'ctreset', 'format_topcoll', '', true); + + $resetelements = array(); + $checkboxname = get_string('resetdisplayinstructions', 'format_topcoll'). + $OUTPUT->help_icon('resetdisplayinstructions', 'format_topcoll'); + $resetelements[] =& $mform->createElement('checkbox', 'resetdisplayinstructions', '', $checkboxname); + + if ($changelayout) { + $checkboxname = get_string('resetlayout', 'format_topcoll').$OUTPUT->help_icon('resetlayout', 'format_topcoll'); + $resetelements[] =& $mform->createElement('checkbox', 'resetlayout', '', $checkboxname); + } + + if ($changecolour) { + $checkboxname = get_string('resetcolour', 'format_topcoll').$OUTPUT->help_icon('resetcolour', 'format_topcoll'); + $resetelements[] =& $mform->createElement('checkbox', 'resetcolour', '', $checkboxname); + } + + if ($changetogglealignment) { + $checkboxname = get_string('resettogglealignment', 'format_topcoll'). + $OUTPUT->help_icon('resettogglealignment', 'format_topcoll'); + $resetelements[] =& $mform->createElement('checkbox', 'resettogglealignment', '', $checkboxname); + } + + if ($changetoggleiconset) { + $checkboxname = get_string('resettoggleiconset', 'format_topcoll'). + $OUTPUT->help_icon('resettoggleiconset', 'format_topcoll'); + $resetelements[] =& $mform->createElement('checkbox', 'resettoggleiconset', '', $checkboxname); + } + $elements[] = $mform->addGroup($resetelements, 'resetgroup', get_string('resetgrp', 'format_topcoll'), null, false); + + if ($resetall) { + $resetallelements = array(); + + $checkboxname = get_string('resetalldisplayinstructions', 'format_topcoll'). + $OUTPUT->help_icon('resetalldisplayinstructions', 'format_topcoll'); + $resetallelements[] =& $mform->createElement('checkbox', 'resetalldisplayinstructions', '', $checkboxname); + + $checkboxname = get_string('resetalllayout', 'format_topcoll'). + $OUTPUT->help_icon('resetalllayout', 'format_topcoll'); + $resetallelements[] =& $mform->createElement('checkbox', 'resetalllayout', '', $checkboxname); + + $checkboxname = get_string('resetallcolour', 'format_topcoll'). + $OUTPUT->help_icon('resetallcolour', 'format_topcoll'); + $resetallelements[] =& $mform->createElement('checkbox', 'resetallcolour', '', $checkboxname); + + $checkboxname = get_string('resetalltogglealignment', 'format_topcoll'). + $OUTPUT->help_icon('resetalltogglealignment', 'format_topcoll'); + $resetallelements[] =& $mform->createElement('checkbox', 'resetalltogglealignment', '', $checkboxname); + + $checkboxname = get_string('resetalltoggleiconset', 'format_topcoll'). + $OUTPUT->help_icon('resetalltoggleiconset', 'format_topcoll'); + $resetallelements[] =& $mform->createElement('checkbox', 'resetalltoggleiconset', '', $checkboxname); + + $elements[] = $mform->addGroup($resetallelements, 'resetallgroup', + get_string('resetallgrp', 'format_topcoll'), null, false); + } + } + + return $elements; + } + + /** + * Override if you need to perform some extra validation of the format options + * + * @param array $data array of ("fieldname"=>value) of submitted data + * @param array $files array of uploaded files "element_name"=>tmp_file_path + * @param array $errors errors already discovered in edit form validation + * @return array of "element_name"=>"error_description" if there are errors, + * or an empty array if everything is OK. + * Do not repeat errors from $errors param here + */ + public function edit_form_validation($data, $files, $errors) { + $retr = array(); + + if ($this->validate_colour($data['toggleforegroundcolour']) === false) { + $retr['toggleforegroundcolour'] = get_string('colourrule', 'format_topcoll'); + } + if ($this->validate_colour($data['toggleforegroundhovercolour']) === false) { + $retr['toggleforegroundhovercolour'] = get_string('colourrule', 'format_topcoll'); + } + if ($this->validate_colour($data['togglebackgroundcolour']) === false) { + $retr['togglebackgroundcolour'] = get_string('colourrule', 'format_topcoll'); + } + if ($this->validate_colour($data['togglebackgroundhovercolour']) === false) { + $retr['togglebackgroundhovercolour'] = get_string('colourrule', 'format_topcoll'); + } + + return $retr; + } + + /** + * Validates the colour that was entered by the user. + * Borrowed from 'admin_setting_configcolourpicker' in '/lib/adminlib.php'. + * + * I'm not completely happy with this solution as would rather embed in the colour + * picker code in the form, however I find this area rather fraut and I hear that + * Dan Poltawski (via MDL-42270) will be re-writing the forms lib so hopefully more + * developer friendly. + * + * Note: Colour names removed, but might consider putting them back in if asked, but + * at the moment that would require quite a few changes and coping with existing + * settings. Either convert the names to hex or allow them as valid values and + * fix the colour picker code and the CSS code in 'format.php' for the setting. + * + * Colour name to hex on: http://www.w3schools.com/cssref/css_colornames.asp. + * + * @param string $data the colour string to validate. + * @return true|false + */ + private function validate_colour($data) { + if (preg_match('/^#?([[:xdigit:]]{3}){1,2}$/', $data)) { + return true; + } else { + return false; + } + } + + /** + * Updates format options for a course + * + * In case if course format was changed to 'Collapsed Topics', we try to copy options + * 'coursedisplay', 'numsections' and 'hiddensections' from the previous format. + * If previous course format did not have 'numsections' option, we populate it with the + * current number of sections. The layout and colour defaults will come from 'course_format_options'. + * + * @param stdClass|array $data return value from {@link moodleform::get_data()} or array with data + * @param stdClass $oldcourse if this function is called from {@link update_course()} + * this object contains information about the course before update + * @return bool whether there were any changes to the options values + */ + public function update_course_format_options($data, $oldcourse = null) { + global $DB; // MDL-37976. + + /* + * Notes: Using 'unset' to really ensure that the reset form elements never get into the database. + * This has to be done here so that the reset occurs after we have done updates such that the + * reset itself is not seen as an update. + */ + $resetdisplayinstructions = false; + $resetlayout = false; + $resetcolour = false; + $resettogglealignment = false; + $resettoggleiconset = false; + $resetalldisplayinstructions = false; + $resetalllayout = false; + $resetallcolour = false; + $resetalltogglealignment = false; + $resetalltoggleiconset = false; + if (isset($data->resetdisplayinstructions) == true) { + $resetdisplayinstructions = true; + unset($data->resetdisplayinstructions); + } + if (isset($data->resetlayout) == true) { + $resetlayout = true; + unset($data->resetlayout); + } + if (isset($data->resetcolour) == true) { + $resetcolour = true; + unset($data->resetcolour); + } + if (isset($data->resettogglealignment) == true) { + $resettogglealignment = true; + unset($data->resettogglealignment); + } + if (isset($data->resettoggleiconset) == true) { + $resettoggleiconset = true; + unset($data->resettoggleiconset); + } + if (isset($data->resetalldisplayinstructions) == true) { + $resetalldisplayinstructions = true; + unset($data->resetalldisplayinstructions); + } + if (isset($data->resetalllayout) == true) { + $resetalllayout = true; + unset($data->resetalllayout); + } + if (isset($data->resetallcolour) == true) { + $resetallcolour = true; + unset($data->resetallcolour); + } + if (isset($data->resetalltogglealignment) == true) { + $resetalltogglealignment = true; + unset($data->resetalltogglealignment); + } + if (isset($data->resetalltoggleiconset) == true) { + $resetalltoggleiconset = true; + unset($data->resetalltoggleiconset); + } + + $data = (array) $data; + if ($oldcourse !== null) { + $oldcourse = (array) $oldcourse; + $options = $this->course_format_options(); + foreach ($options as $key => $unused) { + if (!array_key_exists($key, $data)) { + if (array_key_exists($key, $oldcourse)) { + $data[$key] = $oldcourse[$key]; + } else if ($key === 'numsections') { + /* If previous format does not have the field 'numsections' + * and $data['numsections'] is not set, + * we fill it with the maximum section number from the DB */ + $maxsection = $DB->get_field_sql('SELECT max(section) from {course_sections} WHERE course = ?', + array($this->courseid)); + if ($maxsection) { + // If there are no sections, or just default 0-section, 'numsections' will be set to default. + $data['numsections'] = $maxsection; + } + } + } + } + } + + $changes = $this->update_format_options($data); + + if ($changes && array_key_exists('numsections', $data)) { + // If the numsections was decreased, try to completely delete the orphaned sections (unless they are not empty). + $numsections = (int)$data['numsections']; + $maxsection = $DB->get_field_sql( + 'SELECT max(section) from {course_sections} WHERE course = ?', array($this->courseid)); + for ($sectionnum = $maxsection; $sectionnum > $numsections; $sectionnum--) { + if (!$this->delete_section($sectionnum, false)) { + break; + } + } + } + + // Now we can do the reset. + if (($resetalldisplayinstructions) || + ($resetalllayout) || + ($resetallcolour) || + ($resetalltogglealignment) || + ($resetalltoggleiconset)) { + $this->reset_topcoll_setting(0, $resetalldisplayinstructions, $resetalllayout, $resetallcolour, + $resetalltogglealignment, $resetalltoggleiconset); + $changes = true; + } else if (($resetdisplayinstructions) || + ($resetlayout) || + ($resetcolour) || + ($resettogglealignment) || + ($resettoggleiconset)) { + $this->reset_topcoll_setting($this->courseid, $resetdisplayinstructions, $resetlayout, $resetcolour, + $resettogglealignment, $resettoggleiconset); + $changes = true; + } + + return $changes; + } + + /** + * Is the section passed in the current section? + * + * @param stdClass $section The course_section entry from the DB + * @return bool true if the section is current + */ + public function is_section_current($section) { + $tcsettings = $this->get_settings(); + if (($tcsettings['layoutstructure'] == 2) || ($tcsettings['layoutstructure'] == 3)) { + if ($section->section < 1) { + return false; + } + + $timenow = time(); + $dates = $this->format_topcoll_get_section_dates($section, $this->get_course()); + + return (($timenow >= $dates->start) && ($timenow < $dates->end)); + } else if ($tcsettings['layoutstructure'] == 5) { + if ($section->section < 1) { + return false; + } + + $timenow = time(); + $day = $this->format_topcoll_get_section_day($section, $this->get_course()); + $onedayseconds = 86400; + return (($timenow >= $day) && ($timenow < ($day + $onedayseconds))); + } else { + return parent::is_section_current($section); + } + } + + /** + * Return the start and end date of the passed section. + * + * @param int|stdClass $section The course_section entry from the DB. + * @param stdClass $course The course entry from DB. + * @return stdClass property start for startdate, property end for enddate. + */ + private function format_topcoll_get_section_dates($section, $course) { + $oneweekseconds = 604800; + /* Hack alert. We add 2 hours to avoid possible DST problems. (e.g. we go into daylight + savings and the date changes. */ + $startdate = $course->startdate + 7200; + + $dates = new stdClass(); + if (is_object($section)) { + $section = $section->section; + } + + $dates->start = $startdate + ($oneweekseconds * ($section - 1)); + $dates->end = $dates->start + $oneweekseconds; + + return $dates; + } + + /** + * Return the date of the passed section. + * + * @param int|stdClass $section The course_section entry from the DB. + * @param stdClass $course The course entry from DB. + * @return stdClass property date. + */ + private function format_topcoll_get_section_day($section, $course) { + $onedayseconds = 86400; + /* Hack alert. We add 2 hours to avoid possible DST problems. (e.g. we go into daylight + savings and the date changes. */ + $startdate = $course->startdate + 7200; + + if (is_object($section)) { + $section = $section->section; + } + + $day = $startdate + ($onedayseconds * ($section - 1)); + + return $day; + } + + /** + * Resets the format setting to the default. + * @param int $courseid If not 0, then a specific course to reset. + * @param int $displayinstructions If true, reset the display instructions to the default in the settings for the format. + * @param int $layout If true, reset the layout to the default in the settings for the format. + * @param int $colour If true, reset the colour to the default in the settings for the format. + * @param int $togglealignment If true, reset the toggle alignment to the default in the settings for the format. + * @param int $toggleiconset If true, reset the toggle icon set to the default in the settings for the format. + */ + public function reset_topcoll_setting($courseid, $displayinstructions, $layout, $colour, $togglealignment, $toggleiconset) { + global $DB, $USER, $COURSE; + + $coursecontext = context_course::instance($COURSE->id); + + $currentcourseid = 0; + if ($courseid == 0) { + $records = $DB->get_records('course_format_options', array('format' => $this->format), '', 'id,courseid'); + } else { + $records = $DB->get_records('course_format_options', array('courseid' => $courseid, 'format' => $this->format), + '', 'id,courseid'); + } + + $resetallifall = ((is_siteadmin($USER)) || ($courseid != 0)); // Will be true if reset all capability or a single course. + + $updatedata = array(); + $updatedisplayinstructions = false; + $updatelayout = false; + $updatetogglealignment = false; + $updatecolour = false; + $updatetoggleiconset = false; + if ($displayinstructions && $resetallifall) { + $updatedata['displayinstructions'] = get_config('format_topcoll', 'defaultdisplayinstructions'); + $updatedisplayinstructions = true; + } + if ($layout && has_capability('format/topcoll:changelayout', $coursecontext) && $resetallifall) { + $updatedata['coursedisplay'] = get_config('format_topcoll', 'defaultcoursedisplay'); + $updatedata['layoutelement'] = get_config('format_topcoll', 'defaultlayoutelement'); + $updatedata['layoutstructure'] = get_config('format_topcoll', 'defaultlayoutstructure'); + $updatedata['layoutcolumns'] = get_config('format_topcoll', 'defaultlayoutcolumns'); + $updatedata['layoutcolumnorientation'] = get_config('format_topcoll', 'defaultlayoutcolumnorientation'); + $updatedata['toggleiconposition'] = get_config('format_topcoll', 'defaulttoggleiconposition'); + $updatedata['showsectionsummary'] = get_config('format_topcoll', 'defaultshowsectionsummary'); + $updatelayout = true; + } + if ($togglealignment && has_capability('format/topcoll:changetogglealignment', $coursecontext) && $resetallifall) { + $updatedata['togglealignment'] = get_config('format_topcoll', 'defaulttogglealignment'); + $updatetogglealignment = true; + } + if ($colour && has_capability('format/topcoll:changecolour', $coursecontext) && $resetallifall) { + $updatedata['toggleforegroundcolour'] = get_config('format_topcoll', 'defaulttgfgcolour'); + $updatedata['toggleforegroundhovercolour'] = get_config('format_topcoll', 'defaulttgfghvrcolour'); + $updatedata['togglebackgroundcolour'] = get_config('format_topcoll', 'defaulttgbgcolour'); + $updatedata['togglebackgroundhovercolour'] = get_config('format_topcoll', 'defaulttgbghvrcolour'); + $updatecolour = true; + } + if ($toggleiconset && has_capability('format/topcoll:changetoggleiconset', $coursecontext) && $resetallifall) { + $updatedata['toggleiconset'] = get_config('format_topcoll', 'defaulttoggleiconset'); + $updatedata['toggleallhover'] = get_config('format_topcoll', 'defaulttoggleallhover'); + $updatetoggleiconset = true; + } + + foreach ($records as $record) { + if ($currentcourseid != $record->courseid) { + $currentcourseid = $record->courseid; // Only do once per course. + if (($updatedisplayinstructions) || + ($updatelayout) || + ($updatetogglealignment) || + ($updatecolour) || + ($updatetoggleiconset)) { + $ourcourseid = $this->courseid; + $this->courseid = $currentcourseid; + $this->update_format_options($updatedata); + $this->courseid = $ourcourseid; + } + } + } + } + + /** + * Restores the course settings when restoring a Moodle 2.3 or below (bar 1.9) course and sets the settings when upgrading + * from a prevous version. Hence no need for 'coursedisplay' as that is a core rather than CT specific setting and not + * in the old 'format_topcoll_settings' table. + * @param int $courseid If not 0, then a specific course to reset. + * @param int $layoutelement The layout element. + * @param int $layoutstructure The layout structure. + * @param int $layoutcolumns The layout columns. + * @param int $tgfgcolour The foreground colour. + * @param int $tgbgcolour The background colour. + * @param int $tgbghvrcolour The background hover colour. + */ + public function restore_topcoll_setting($courseid, $layoutelement, $layoutstructure, $layoutcolumns, $tgfgcolour, + $tgbgcolour, $tgbghvrcolour) { + $currentcourseid = $this->courseid; // Save for later - stack data model. + $this->courseid = $courseid; + // Create data array. + $data = array( + 'layoutelement' => $layoutelement, + 'layoutstructure' => $layoutstructure, + 'layoutcolumns' => $layoutcolumns, + 'toggleforegroundcolour' => $tgfgcolour, + 'togglebackgroundcolour' => $tgbgcolour, + 'togglebackgroundhovercolour' => $tgbghvrcolour); + + $lco = get_config('format_topcoll', 'defaultlayoutcolumnorientation'); + if (empty($lco)) { + // Upgrading from M2.3 and the defaults in 'settings.php' have not been processed at this time. + // Defaults taken from 'settings.php'. + $data['displayinstructions'] = get_config('format_topcoll', 'defaultdisplayinstructions'); + $data['layoutcolumnorientation'] = get_config('format_topcoll', 'defaultlayoutcolumnorientation'); + $data['showsectionsummary'] = get_config('format_topcoll', 'defaultshowsectionsummary'); + $data['togglealignment'] = get_config('format_topcoll', 'defaulttogglealignment'); + $data['toggleallhover'] = get_config('format_topcoll', 'defaulttoggleallhover'); + $data['toggleiconposition'] = get_config('format_topcoll', 'defaulttoggleiconposition'); + $data['toggleiconset'] = get_config('format_topcoll', 'defaulttoggleiconset'); + } + $this->update_course_format_options($data); + + $this->courseid = $currentcourseid; + } + + /** + * Updates the number of columns when the renderer detects that they are wrong. + * @param int $layoutcolumns The layout columns to use, see tcconfig.php. + */ + public function update_topcoll_columns_setting($layoutcolumns) { + // Create data array. + $data = array('layoutcolumns' => $layoutcolumns); + + $this->update_course_format_options($data); + } + + /** + * Whether this format allows to delete sections + * + * Do not call this function directly, instead use {@link course_can_delete_section()} + * + * @param int|stdClass|section_info $section + * @return bool + */ + public function can_delete_section($section) { + return true; + } +} + +/** + * The string that is used to describe a section of the course. + * + * @return string The section description. + */ +function callback_topcoll_definition() { + return get_string('sectionname', 'format_topcoll'); +} + +/** + * Deletes the user preference entries for the given course upon course deletion. + * CONTRIB-3520. + */ +function format_topcoll_delete_course($courseid) { + global $DB; + $DB->delete_records("user_preferences", array("name" => 'topcoll_toggle_' . $courseid)); } \ No newline at end of file diff --git a/module.js b/module.js index a3d6eca5..c7d29c57 100644 --- a/module.js +++ b/module.js @@ -1,356 +1,367 @@ -/** - * Collapsed Topics Information - * - * A topic based format that solves the issue of the 'Scroll of Death' when a course has many topics. All topics - * except zero have a toggle that displays that topic. One or more topics can be displayed at any given time. - * Toggles are persistent on a per browser session per course basis but can be made to persist longer by a small - * code change. Full installation instructions, code adaptions and credits are included in the 'Readme.txt' file. - * - * @package course/format - * @subpackage topcoll - * @version See the value of '$plugin->version' in version.php. - * @copyright © 2009-onwards G J Barnard in respect to modifications of standard topics format. - * @author G J Barnard - gjbarnard at gmail dot com and {@link http://moodle.org/user/profile.php?id=442195} - * @link http://docs.moodle.org/en/Collapsed_Topics_course_format - * @license http://www.gnu.org/copyleft/gpl.html GNU Public License - * - * 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 . - */ - -// Cleaned through use of http://jshint.com/. -/** - * @namespace - */ -M.format_topcoll = M.format_topcoll || {}; - -// Namespace variables: -M.format_topcoll.thesparezeros = "00000000000000000000000000"; // A constant of 26 0's to be used to pad the storage state of the toggles when converting between base 2 and 36, this is to be compact. -M.format_topcoll.togglestate; -M.format_topcoll.courseid; -M.format_topcoll.togglePersistence = 1; // Toggle persistence - 1 = on, 0 = off. -M.format_topcoll.ourYUI; -M.format_topcoll.numSections; -M.format_topcoll.ie8; - -// Namespace constants: -M.format_topcoll.TOGGLE_6 = 1; -M.format_topcoll.TOGGLE_5 = 2; -M.format_topcoll.TOGGLE_4 = 4; -M.format_topcoll.TOGGLE_3 = 8; -M.format_topcoll.TOGGLE_2 = 16; -M.format_topcoll.TOGGLE_1 = 32; - -/** - * Initialise with the information supplied from the course format 'format.php' so we can operate. - * @param {Object} Y YUI instance - * @param {String} theCourseId the id of the current course to allow for settings for each course. - * @param {String} theToggleState the current state of the toggles. - * @param {Integer} theNumSections the number of sections in the course. - * @param {Integer} theTogglePersistence Persistence on (1) or off (0). - * @param {Integer} theDefaultTogglePersistence Persistence all open (1) or all closed (0) when thetogglestate is null. - */ -M.format_topcoll.init = function(Y, theCourseId, theToggleState, theNumSections, theTogglePersistence, theDefaultTogglePersistence) { - "use strict"; - // Init. - this.ourYUI = Y; - this.courseid = theCourseId; - this.togglestate = theToggleState; - this.numSections = parseInt(theNumSections); - this.togglePersistence = theTogglePersistence; - - // IE8 - humm! - var bodyNode = Y.one(document.body); - M.format_topcoll.ie8 = bodyNode.hasClass('ie8'); - if ((this.togglestate !== null) && (this.togglePersistence == 1)) { // Toggle persistence - 1 = on, 0 = off. - if (this.is_old_preference(this.togglestate) == true) { - // Old preference, so convert to new. - this.convert_to_new_preference(); - } - // Check we have enough digits for the number of toggles in case this has increased. - var numdigits = this.get_required_digits(this.numSections); - if (numdigits > this.togglestate.length) { - var dchar; - if (theDefaultTogglePersistence == 0) { - dchar = this.get_min_digit(); - } else { - dchar = this.get_max_digit(); - } - for (var i = this.togglestate.length; i < numdigits; i++) { - this.togglestate += dchar; - } - } else if (numdigits < this.togglestate.length) { - // Shorten to save space. - this.togglestate = this.togglestate.substring(0, numdigits); - } - } else { - // Reset to default. - if (theDefaultTogglePersistence == 0) { - this.resetState(this.get_min_digit()); - } else { - this.resetState(this.get_max_digit()); - } - } - - /* Info on http://yuilibrary.com/yui/docs/event/delegation.html - Delegated event handler for the toggles. - Inspiration thanks to Ben Kelada. - Code help thanks to the guru Andrew Nicols. */ - Y.delegate('click', this.toggleClick, Y.config.doc, 'ul.ctopics .toggle', this); - /*Y.use('node-event-delegate', 'event-key', function (Y) { - Y.delegate('key', M.format_topcoll.toggleClick, 'up:32', 'ul.ctopics .toggle'); - });*/ - - // Event handlers for all opened / closed. - var allopen = Y.one("#toggles-all-opened"); - if (allopen) { - allopen.on('click', this.allOpenClick); - } - var allclosed = Y.one("#toggles-all-closed"); - if (allclosed) { - allclosed.on('click', this.allCloseClick); - } -}; - -M.format_topcoll.toggleClick = function(e) { - var toggleIndex = parseInt(e.currentTarget.get('id').replace("toggle-", "")); - e.preventDefault(); - this.toggle_topic(e.currentTarget, toggleIndex); -}; - -M.format_topcoll.allOpenClick = function(e) { - e.preventDefault(); - M.format_topcoll.ourYUI.all(".toggledsection").addClass('sectionopen'); - M.format_topcoll.ourYUI.all(".toggle a").addClass('toggle_open').removeClass('toggle_closed').setAttribute('aria-pressed', 'true'); - M.format_topcoll.resetState(M.format_topcoll.get_max_digit()); - M.format_topcoll.save_toggles(); -}; - -M.format_topcoll.allCloseClick = function(e) { - e.preventDefault(); - M.format_topcoll.ourYUI.all(".toggledsection").removeClass('sectionopen'); - M.format_topcoll.ourYUI.all(".toggle a").addClass('toggle_closed').removeClass('toggle_open').setAttribute('aria-pressed', 'false'); - M.format_topcoll.resetState(M.format_topcoll.get_min_digit()); - M.format_topcoll.save_toggles(); -}; - -M.format_topcoll.resetState = function(dchar) { - M.format_topcoll.togglestate = ""; - var numdigits = M.format_topcoll.get_required_digits(M.format_topcoll.numSections); - for (var i = 0; i < numdigits; i++) { - M.format_topcoll.togglestate += dchar; - } -}; - -// Toggle functions -// Args - targetNode that initiated the call, toggleNum the number of the toggle. -M.format_topcoll.toggle_topic = function(targetNode, toggleNum) { - "use strict"; - var targetLink = targetNode.one('a'); - var state; - if (!targetLink.hasClass('toggle_open')) { - targetLink.addClass('toggle_open').removeClass('toggle_closed').setAttribute('aria-pressed', 'true'); - targetNode.next('.toggledsection').addClass('sectionopen'); - state = true; - } else { - targetLink.addClass('toggle_closed').removeClass('toggle_open').setAttribute('aria-pressed', 'false'); - targetNode.next('.toggledsection').removeClass('sectionopen'); - state = false; - } - // IE 8 Hack/workaround to force IE8 to repaint everything. - if (M.format_topcoll.ie8) { - M.format_topcoll.ourYUI.all(".toggle a").addClass('ie8_hackclass_donotuseincss').removeClass('ie8_hackclass_donotuseincss'); - console.log('IE8 repaint.'); - } - - this.set_toggle_state(toggleNum, state); - this.save_toggles(); -}; - -/* Old maximum number of sections was 52, but as the conversion utilises integers which are 32 bit signed, this must be broken into two string segments for the - process to work. Therefore each 6 character base 36 string will represent 26 characters for part 1 and 27 for part 2 in base 2. - This is all required to save cookie space, so instead of using 53 bytes (characters) per course, only 12 are used. - Convert from a base 36 string to a base 2 string - effectively a private function. - Args - thirtysix - a 12 character string representing a base 36 number. */ -M.format_topcoll.to2baseString = function(thirtysix) { - "use strict"; - // Break apart the string because integers are signed 32 bit and therefore can only store 31 bits, therefore a 53 bit number will cause overflow / carry with loss of resolution. - var firstpart = parseInt(thirtysix.substring(0,6),36); - var secondpart = parseInt(thirtysix.substring(6,12),36); - var fps = firstpart.toString(2); - var sps = secondpart.toString(2); - - // Add in preceding 0's if base 2 sub strings are not long enough. - if (fps.length < 26) { - // Need to PAD. - fps = this.thesparezeros.substring(0,(26 - fps.length)) + fps; - } - if (sps.length < 27) { - // Need to PAD. - sps = this.thesparezeros.substring(0,(27 - sps.length)) + sps; - } - - return fps + sps; -}; - -/* Save the toggles - called from togglebinary and allToggle. - AJAX call to server to save the state of the toggles for this course for the current user if on. */ -M.format_topcoll.save_toggles = function() { - "use strict"; - if (this.togglePersistence == 1) { // Toggle persistence - 1 = on, 0 = off. - M.format_topcoll.set_user_preference('topcoll_toggle_' + this.courseid, this.togglestate); - } -}; - -// New base 64 code: -M.format_topcoll.is_old_preference = function(pref) { - "use strict"; - var retr = false; - var firstchar = pref[0]; - - if ((firstchar == '0') || (firstchar == '1')) { - retr = true; - } - - return retr; -}; - -M.format_topcoll.convert_to_new_preference = function() { - "use strict"; - var toggleBinary = this.to2baseString(this.togglestate); - var bin, value; - this.togglestate = ""; - var logbintext = ""; - - for (var i = 1; i <= 43; i = i + 6) { - bin = toggleBinary.substring(i, i + 6); - value = parseInt(bin, 2); - this.togglestate += this.encode_value_to_character(value); - logbintext += bin + ' '; - } - - bin = toggleBinary.substring(49, 53); - logbintext += bin + ' '; - value = parseInt(bin, 2); - value = value << 2; - this.togglestate += this.encode_value_to_character(value); -}; - -/** - * Sets the state of the requested Toggle number. - * int togglenum - The toggle number. - * boolean state - true or false. - */ -M.format_topcoll.set_toggle_state = function(togglenum, state) { - "use strict"; - var togglecharpos = this.get_toggle_pos(togglenum); - var toggleflag = this.get_toggle_flag(togglenum, togglecharpos); - var value = this.decode_character_to_value(this.togglestate.charAt(togglecharpos - 1)); - if (state == true) { - value |= toggleflag; - } else { - value &= ~toggleflag; - } - var newchar = this.encode_value_to_character(value); - var start = this.togglestate.substring(0,togglecharpos - 1); - var end = this.togglestate.substring(togglecharpos); - this.togglestate = start + newchar + end; -}; - -M.format_topcoll.get_required_digits = function(numtoggles) { - "use strict"; - return this.get_toggle_pos(numtoggles); -}; - -M.format_topcoll.get_toggle_pos = function(togglenum) { - "use strict"; - return Math.ceil(togglenum / 6); -}; - -M.format_topcoll.get_min_digit = function() { - "use strict"; - return ':'; // 58 ':'; -}; - -M.format_topcoll.get_max_digit = function() { - "use strict"; - return 'y'; // 58 'y'; -}; - -M.format_topcoll.get_toggle_flag = function(togglenum, togglecharpos) { - "use strict"; - var toggleflagpos = togglenum - ((togglecharpos - 1) * 6); - var flag; - switch (toggleflagpos) { - case 1: - flag = this.TOGGLE_1; - break; - case 2: - flag = this.TOGGLE_2; - break; - case 3: - flag = this.TOGGLE_3; - break; - case 4: - flag = this.TOGGLE_4; - break; - case 5: - flag = this.TOGGLE_5; - break; - case 6: - flag = this.TOGGLE_6; - break; - } - return flag; -}; - -M.format_topcoll.decode_character_to_value = function(character) { - "use strict"; - return character.charCodeAt(0) - 58; -} - -M.format_topcoll.encode_value_to_character = function(val) { - "use strict"; - return String.fromCharCode(val + 58); -}; - -/** - * Makes a best effort to connect back to Moodle to update a user preference, - * however, there is no mechanism for finding out if the update succeeded. - * - * Before you can use this function in your JavsScript, you must have called - * user_preference_allow_ajax_update from moodlelib.php to tell Moodle that - * the update is allowed, and how to safely clean and submitted values. - * - * @param String name the name of the setting to update. - * @param String the value to set it to. - */ -M.format_topcoll.set_user_preference = function(name, value) { - YUI().use('io', function(Y) { - var url = M.cfg.wwwroot + '/course/format/topcoll/settopcollpref.php?sesskey=' + M.cfg.sesskey + '&pref=' + encodeURI(name) + '&value=' + encodeURI(value); - - // If we are a developer, ensure that failures are reported. - var cfg = { - method: 'get', - on: {} - }; - if (M.cfg.developerdebug) { - cfg.on.failure = function(id, o, args) { - console.log("Error updating topcoll preference '" + name + "' using AJAX. Almost certainly your session has timed out. Clicking this link will repeat the AJAX call that failed so you can see the error: "); - } - } - - // Make the request. - Y.io(url, cfg); - }); -}; +/** + * Collapsed Topics Information + * + * A topic based format that solves the issue of the 'Scroll of Death' when a course has many topics. All topics + * except zero have a toggle that displays that topic. One or more topics can be displayed at any given time. + * Toggles are persistent on a per browser session per course basis but can be made to persist longer by a small + * code change. Full installation instructions, code adaptions and credits are included in the 'Readme.txt' file. + * + * @package course/format + * @subpackage topcoll + * @version See the value of '$plugin->version' in version.php. + * @copyright © 2009-onwards G J Barnard in respect to modifications of standard topics format. + * @author G J Barnard - gjbarnard at gmail dot com and {@link http://moodle.org/user/profile.php?id=442195} + * @link http://docs.moodle.org/en/Collapsed_Topics_course_format + * @license http://www.gnu.org/copyleft/gpl.html GNU Public License + * + * 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 . + */ + +// Cleaned through use of http://jshint.com/. +/** + * @namespace + */ +M.format_topcoll = M.format_topcoll || {}; + +// Namespace variables: +// A constant of 26 0's to be used to pad the storage state of the toggles when converting between base 2 and 36, +// this is to be compact. +M.format_topcoll.thesparezeros = "00000000000000000000000000"; +M.format_topcoll.togglestate = false; +M.format_topcoll.courseid = 0; +M.format_topcoll.togglePersistence = 1; // Toggle persistence - 1 = on, 0 = off. +M.format_topcoll.ourYUI = false; +M.format_topcoll.numSections = 0; +M.format_topcoll.ie8 = false; + +// Namespace constants: +M.format_topcoll.TOGGLE_6 = 1; +M.format_topcoll.TOGGLE_5 = 2; +M.format_topcoll.TOGGLE_4 = 4; +M.format_topcoll.TOGGLE_3 = 8; +M.format_topcoll.TOGGLE_2 = 16; +M.format_topcoll.TOGGLE_1 = 32; + +/** + * Initialise with the information supplied from the course format 'format.php' so we can operate. + * @param {Object} Y YUI instance + * @param {String} theCourseId the id of the current course to allow for settings for each course. + * @param {String} theToggleState the current state of the toggles. + * @param {Integer} theNumSections the number of sections in the course. + * @param {Integer} theTogglePersistence Persistence on (1) or off (0). + * @param {Integer} theDefaultTogglePersistence Persistence all open (1) or all closed (0) when thetogglestate is null. + */ +M.format_topcoll.init = function(Y, theCourseId, theToggleState, theNumSections, theTogglePersistence, + theDefaultTogglePersistence) { + "use strict"; + // Init. + this.ourYUI = Y; + this.courseid = theCourseId; + this.togglestate = theToggleState; + this.numSections = parseInt(theNumSections); + this.togglePersistence = theTogglePersistence; + + // IE8 - humm! + var bodyNode = Y.one(document.body); + M.format_topcoll.ie8 = bodyNode.hasClass('ie8'); + if ((this.togglestate !== null) && (this.togglePersistence == 1)) { // Toggle persistence - 1 = on, 0 = off. + if (this.is_old_preference(this.togglestate) === true) { + // Old preference, so convert to new. + this.convert_to_new_preference(); + } + // Check we have enough digits for the number of toggles in case this has increased. + var numdigits = this.get_required_digits(this.numSections); + if (numdigits > this.togglestate.length) { + var dchar; + if (theDefaultTogglePersistence === 0) { + dchar = this.get_min_digit(); + } else { + dchar = this.get_max_digit(); + } + for (var i = this.togglestate.length; i < numdigits; i++) { + this.togglestate += dchar; + } + } else if (numdigits < this.togglestate.length) { + // Shorten to save space. + this.togglestate = this.togglestate.substring(0, numdigits); + } + } else { + // Reset to default. + if (theDefaultTogglePersistence === 0) { + this.resetState(this.get_min_digit()); + } else { + this.resetState(this.get_max_digit()); + } + } + + /* Info on http://yuilibrary.com/yui/docs/event/delegation.html + Delegated event handler for the toggles. + Inspiration thanks to Ben Kelada. + Code help thanks to the guru Andrew Nicols. */ + Y.delegate('click', this.toggleClick, Y.config.doc, 'ul.ctopics .toggle', this); + + // Event handlers for all opened / closed. + var allopen = Y.one("#toggles-all-opened"); + if (allopen) { + allopen.on('click', this.allOpenClick); + } + var allclosed = Y.one("#toggles-all-closed"); + if (allclosed) { + allclosed.on('click', this.allCloseClick); + } +}; + +M.format_topcoll.toggleClick = function(e) { + var toggleIndex = parseInt(e.currentTarget.get('id').replace("toggle-", "")); + e.preventDefault(); + this.toggle_topic(e.currentTarget, toggleIndex); +}; + +M.format_topcoll.allOpenClick = function(e) { + e.preventDefault(); + M.format_topcoll.ourYUI.all(".toggledsection").addClass('sectionopen'); + M.format_topcoll.ourYUI.all(".toggle a").addClass('toggle_open').removeClass('toggle_closed') + .setAttribute('aria-pressed', 'true'); + M.format_topcoll.resetState(M.format_topcoll.get_max_digit()); + M.format_topcoll.save_toggles(); +}; + +M.format_topcoll.allCloseClick = function(e) { + e.preventDefault(); + M.format_topcoll.ourYUI.all(".toggledsection").removeClass('sectionopen'); + M.format_topcoll.ourYUI.all(".toggle a").addClass('toggle_closed').removeClass('toggle_open') + .setAttribute('aria-pressed', 'false'); + M.format_topcoll.resetState(M.format_topcoll.get_min_digit()); + M.format_topcoll.save_toggles(); +}; + +M.format_topcoll.resetState = function(dchar) { + M.format_topcoll.togglestate = ""; + var numdigits = M.format_topcoll.get_required_digits(M.format_topcoll.numSections); + for (var i = 0; i < numdigits; i++) { + M.format_topcoll.togglestate += dchar; + } +}; + +// Toggle functions +// Args - targetNode that initiated the call, toggleNum the number of the toggle. +M.format_topcoll.toggle_topic = function(targetNode, toggleNum) { + "use strict"; + var targetLink = targetNode.one('a'); + var state; + if (!targetLink.hasClass('toggle_open')) { + targetLink.addClass('toggle_open').removeClass('toggle_closed').setAttribute('aria-pressed', 'true'); + targetNode.next('.toggledsection').addClass('sectionopen'); + state = true; + } else { + targetLink.addClass('toggle_closed').removeClass('toggle_open').setAttribute('aria-pressed', 'false'); + targetNode.next('.toggledsection').removeClass('sectionopen'); + state = false; + } + // IE 8 Hack/workaround to force IE8 to repaint everything. + if (M.format_topcoll.ie8) { + M.format_topcoll.ourYUI.all(".toggle a").addClass('ie8_hackclass_donotuseincss') + .removeClass('ie8_hackclass_donotuseincss'); + console.log('IE8 repaint.'); + } + + this.set_toggle_state(toggleNum, state); + this.save_toggles(); +}; + +/* Old maximum number of sections was 52, but as the conversion utilises integers which are 32 bit signed, + this must be broken into two string segments for the process to work. Therefore each 6 character base 36 + string will represent 26 characters for part 1 and 27 for part 2 in base 2. + This is all required to save cookie space, so instead of using 53 bytes (characters) per course, only 12 are used. + Convert from a base 36 string to a base 2 string - effectively a private function. + Args - thirtysix - a 12 character string representing a base 36 number. */ +M.format_topcoll.to2baseString = function(thirtysix) { + "use strict"; + // Break apart the string because integers are signed 32 bit and therefore can only store 31 bits, therefore a + // 53 bit number will cause overflow / carry with loss of resolution. + var firstpart = parseInt(thirtysix.substring(0,6),36); + var secondpart = parseInt(thirtysix.substring(6,12),36); + var fps = firstpart.toString(2); + var sps = secondpart.toString(2); + + // Add in preceding 0's if base 2 sub strings are not long enough. + if (fps.length < 26) { + // Need to PAD. + fps = this.thesparezeros.substring(0,(26 - fps.length)) + fps; + } + if (sps.length < 27) { + // Need to PAD. + sps = this.thesparezeros.substring(0,(27 - sps.length)) + sps; + } + + return fps + sps; +}; + +/* Save the toggles - called from togglebinary and allToggle. + AJAX call to server to save the state of the toggles for this course for the current user if on. */ +M.format_topcoll.save_toggles = function() { + "use strict"; + if (this.togglePersistence == 1) { // Toggle persistence - 1 = on, 0 = off. + M.format_topcoll.set_user_preference('topcoll_toggle_' + this.courseid, this.togglestate); + } +}; + +// New base 64 code: +M.format_topcoll.is_old_preference = function(pref) { + "use strict"; + var retr = false; + var firstchar = pref[0]; + + if ((firstchar == '0') || (firstchar == '1')) { + retr = true; + } + + return retr; +}; + +M.format_topcoll.convert_to_new_preference = function() { + "use strict"; + var toggleBinary = this.to2baseString(this.togglestate); + var bin, value; + this.togglestate = ""; + var logbintext = ""; + + for (var i = 1; i <= 43; i = i + 6) { + bin = toggleBinary.substring(i, i + 6); + value = parseInt(bin, 2); + this.togglestate += this.encode_value_to_character(value); + logbintext += bin + ' '; + } + + bin = toggleBinary.substring(49, 53); + logbintext += bin + ' '; + value = parseInt(bin, 2); + // @codingStandardsIgnoreStart + value = value << 2; // jshint ignore:line + // @codingStandardsIgnoreEnd + this.togglestate += this.encode_value_to_character(value); +}; + +/** + * Sets the state of the requested Toggle number. + * int togglenum - The toggle number. + * boolean state - true or false. + */ +M.format_topcoll.set_toggle_state = function(togglenum, state) { + "use strict"; + var togglecharpos = this.get_toggle_pos(togglenum); + var toggleflag = this.get_toggle_flag(togglenum, togglecharpos); + var value = this.decode_character_to_value(this.togglestate.charAt(togglecharpos - 1)); + if (state === true) { + // @codingStandardsIgnoreStart + value |= toggleflag; // jshint ignore:line + // @codingStandardsIgnoreEnd + } else { + // @codingStandardsIgnoreStart + value &= ~toggleflag; // jshint ignore:line + // @codingStandardsIgnoreEnd + } + var newchar = this.encode_value_to_character(value); + var start = this.togglestate.substring(0,togglecharpos - 1); + var end = this.togglestate.substring(togglecharpos); + this.togglestate = start + newchar + end; +}; + +M.format_topcoll.get_required_digits = function(numtoggles) { + "use strict"; + return this.get_toggle_pos(numtoggles); +}; + +M.format_topcoll.get_toggle_pos = function(togglenum) { + "use strict"; + return Math.ceil(togglenum / 6); +}; + +M.format_topcoll.get_min_digit = function() { + "use strict"; + return ':'; // 58 ':'; +}; + +M.format_topcoll.get_max_digit = function() { + "use strict"; + return 'y'; // 58 'y'; +}; + +M.format_topcoll.get_toggle_flag = function(togglenum, togglecharpos) { + "use strict"; + var toggleflagpos = togglenum - ((togglecharpos - 1) * 6); + var flag; + switch (toggleflagpos) { + case 1: + flag = this.TOGGLE_1; + break; + case 2: + flag = this.TOGGLE_2; + break; + case 3: + flag = this.TOGGLE_3; + break; + case 4: + flag = this.TOGGLE_4; + break; + case 5: + flag = this.TOGGLE_5; + break; + case 6: + flag = this.TOGGLE_6; + break; + } + return flag; +}; + +M.format_topcoll.decode_character_to_value = function(character) { + "use strict"; + return character.charCodeAt(0) - 58; +}; + +M.format_topcoll.encode_value_to_character = function(val) { + "use strict"; + return String.fromCharCode(val + 58); +}; + +/** + * Makes a best effort to connect back to Moodle to update a user preference, + * however, there is no mechanism for finding out if the update succeeded. + * + * Before you can use this function in your JavsScript, you must have called + * user_preference_allow_ajax_update from moodlelib.php to tell Moodle that + * the update is allowed, and how to safely clean and submitted values. + * + * @param String name the name of the setting to update. + * @param String the value to set it to. + */ +M.format_topcoll.set_user_preference = function(name, value) { + YUI().use('io', function(Y) { + var url = M.cfg.wwwroot + '/course/format/topcoll/settopcollpref.php?sesskey=' + M.cfg.sesskey + '&pref=' + encodeURI(name) + '&value=' + encodeURI(value); // jshint ignore:line + + // If we are a developer, ensure that failures are reported. + var cfg = { + method: 'get', + on: {} + }; + if (M.cfg.developerdebug) { + cfg.on.failure = function() { + console.log("Error updating topcoll preference '" + name + "' using AJAX. Almost certainly your session has timed out. Clicking this link will repeat the AJAX call that failed so you can see the error: "); // jshint ignore:line + }; + } + + // Make the request. + Y.io(url, cfg); + }); +}; diff --git a/renderer.php b/renderer.php index 25d4c4b6..d0625505 100644 --- a/renderer.php +++ b/renderer.php @@ -1,1050 +1,1050 @@ -. - -/** - * Collapsed Topics Information - * - * A topic based format that solves the issue of the 'Scroll of Death' when a course has many topics. All topics - * except zero have a toggle that displays that topic. One or more topics can be displayed at any given time. - * Toggles are persistent on a per browser session per course basis but can be made to persist longer by a small - * code change. Full installation instructions, code adaptions and credits are included in the 'Readme.txt' file. - * - * @package course/format - * @subpackage topcoll - * @version See the value of '$plugin->version' in below. - * @copyright © 2012-onwards G J Barnard in respect to modifications of standard topics format. - * @author G J Barnard - gjbarnard at gmail dot com and {@link http://moodle.org/user/profile.php?id=442195} - * @link http://docs.moodle.org/en/Collapsed_Topics_course_format - * @license http://www.gnu.org/copyleft/gpl.html GNU Public License - * - */ -defined('MOODLE_INTERNAL') || die(); -require_once($CFG->dirroot . '/course/format/renderer.php'); -require_once($CFG->dirroot . '/course/format/topcoll/lib.php'); -require_once($CFG->dirroot . '/course/format/topcoll/togglelib.php'); - -class format_topcoll_renderer extends format_section_renderer_base { - - private $tccolumnwidth = 100; // Default width in percent of the column(s). - private $tccolumnpadding = 0; // Default padding in pixels of the column(s). - private $mobiletheme = false; // As not using a mobile theme we can react to the number of columns setting. - private $tablettheme = false; // As not using a tablet theme we can react to the number of columns setting. - private $courseformat = null; // Our course format object as defined in lib.php; - private $tcsettings; // Settings for the format - array. - private $userpreference; // User toggle state preference - string. - private $defaultuserpreference; // Default user preference when none set - bool - true all open, false all closed. - private $togglelib; - private $isoldtogglepreference = false; - private $userisediting = false; - private $tctoggleiconsize; - private $formatresponsive; - private $rtl = false; - - /** - * Constructor method, calls the parent constructor - MDL-21097. - * - * @param moodle_page $page. - * @param string $target one of rendering target constants. - */ - public function __construct(moodle_page $page, $target) { - parent::__construct($page, $target); - $this->togglelib = new topcoll_togglelib; - $this->courseformat = course_get_format($page->course); // Needed for collapsed topics settings retrieval. - - /* Since format_topcoll_renderer::section_edit_control_items() only displays the 'Set current section' control when editing - mode is on we need to be sure that the link 'Turn editing mode on' is available for a user who does not have any - other managing capability. */ - $page->set_other_editing_capability('moodle/course:setcurrentsection'); - - global $PAGE; - $this->userisediting = $PAGE->user_is_editing(); - $this->tctoggleiconsize = clean_param(get_config('format_topcoll', 'defaulttoggleiconsize'), PARAM_TEXT); - $this->formatresponsive = get_config('format_topcoll', 'formatresponsive'); - - $this->rtl = right_to_left(); - } - - /** - * Generate the starting container html for a list of sections. - * @return string HTML to output. - */ - protected function start_section_list() { - return html_writer::start_tag('ul', array('class' => 'ctopics')); - } - - /** - * Generate the starting container html for a list of sections when showing a toggle. - * @return string HTML to output. - */ - protected function start_toggle_section_list() { - $classes = 'ctopics topics'; - $attributes = array(); - if (($this->mobiletheme === true) || ($this->tablettheme === true)) { - $classes .= ' ctportable'; - } - if ($this->formatresponsive) { - $style = ''; - if ($this->tcsettings['layoutcolumnorientation'] == 1) { // Vertical columns. - $style .= 'width:' . $this->tccolumnwidth . '%;'; - } else { - $style .= 'width: 100%;'; // Horizontal columns. - } - if ($this->mobiletheme === false) { - $classes .= ' ctlayout'; - } - $style .= ' padding-left: ' . $this->tccolumnpadding . 'px; padding-right: ' . $this->tccolumnpadding . 'px;'; - $attributes['style'] = $style; - } else { - if ($this->tcsettings['layoutcolumnorientation'] == 1) { // Vertical columns. - $classes .= ' ' . $this->get_column_class($this->tcsettings['layoutcolumns']); - } else { - $classes .= ' ' . $this->get_row_class(); - } - } - $attributes['class'] = $classes; - - return html_writer::start_tag('ul', $attributes); - } - - /** - * Generate the closing container html for a list of sections. - * @return string HTML to output. - */ - protected function end_section_list() { - return html_writer::end_tag('ul'); - } - - /** - * Generate the title for this section page. - * @return string the page title. - */ - protected function page_title() { - return get_string('sectionname', 'format_topcoll'); - } - - /** - * Generate the content to displayed on the right part of a section - * before course modules are included. - * - * @param stdClass $section The course_section entry from DB. - * @param stdClass $course The course entry from DB. - * @param bool $onsectionpage true if being printed on a section page. - * @return string HTML to output. - */ - protected function section_right_content($section, $course, $onsectionpage) { - $o = ''; - - if ($section->section != 0) { - $controls = $this->section_edit_control_items($course, $section, $onsectionpage); - if (!empty($controls)) { - $o .= $this->section_edit_control_menu($controls, $course, $section); - } else { - if (empty($this->tcsettings)) { - $this->tcsettings = $this->courseformat->get_settings(); - } - switch ($this->tcsettings['layoutelement']) { // Toggle section x. - case 1: - case 3: - case 5: - case 8: - // Get the specific words from the language files. - $topictext = null; - if (($this->tcsettings['layoutstructure'] == 1) || ($this->tcsettings['layoutstructure'] == 4)) { - $topictext = get_string('setlayoutstructuretopic', 'format_topcoll'); - } else if (($this->tcsettings['layoutstructure'] == 2) || ($this->tcsettings['layoutstructure'] == 3)) { - $topictext = get_string('setlayoutstructureweek', 'format_topcoll'); - } else { - $topictext = get_string('setlayoutstructureday', 'format_topcoll'); - } - - $o .= html_writer::tag('span', - $topictext . html_writer::empty_tag('br') . - $section->section, array('class' => 'cps_centre')); - break; - } - } - } - - return $o; - } - - /** - * Generate the content to displayed on the left part of a section - * before course modules are included. - * - * @param stdClass $section The course_section entry from DB. - * @param stdClass $course The course entry from DB. - * @param bool $onsectionpage true if being printed on a section page. - * @return string HTML to output. - */ - protected function section_left_content($section, $course, $onsectionpage) { - $o = ''; - - if ($section->section != 0) { - // Only in the non-general sections. - if ($this->courseformat->is_section_current($section)) { - $o .= get_accesshide(get_string('currentsection', 'format_' . $course->format)); - } - if (empty($this->tcsettings)) { - $this->tcsettings = $this->courseformat->get_settings(); - } - switch ($this->tcsettings['layoutelement']) { - case 1: - case 2: - case 5: - case 6: - $o .= html_writer::tag('span', $section->section, array('class' => 'cps_centre')); - break; - } - } - return $o; - } - - /** - * Generate the edit controls of a section. - * - * @param stdClass $course The course entry from DB. - * @param stdClass $section The course_section entry from DB. - * @param bool $onsectionpage true if being printed on a section page. - * @return array of links with edit controls. - */ - protected function section_edit_control_items($course, $section, $onsectionpage = false) { - - if (!$this->userisediting) { - return array(); - } - - $coursecontext = context_course::instance($course->id); - - if ($onsectionpage) { - $url = course_get_url($course, $section->section); - } else { - $url = course_get_url($course); - } - $url->param('sesskey', sesskey()); - - if (empty($this->tcsettings)) { - $this->tcsettings = $this->courseformat->get_settings(); - } - $isstealth = $section->section > $course->numsections; - $controls = array(); - if ((($this->tcsettings['layoutstructure'] == 1) || ($this->tcsettings['layoutstructure'] == 4)) && - !$isstealth && $section->section && has_capability('moodle/course:setcurrentsection', $coursecontext)) { - if ($course->marker == $section->section) { // Show the "light globe" on/off. - $url->param('marker', 0); - $markedthissection = get_string('markedthissection', 'format_topcoll'); - $highlightoff = get_string('highlightoff'); - $controls['highlight'] = array('url' => $url, "icon" => 'i/marked', - 'name' => $highlightoff, - 'pixattr' => array('class' => '', 'alt' => $markedthissection), - 'attr' => array('class' => 'editing_highlight', 'title' => $markedthissection)); - } else { - $url->param('marker', $section->section); - $markthissection = get_string('markthissection', 'format_topcoll'); - $highlight = get_string('highlight'); - $controls['highlight'] = array('url' => $url, "icon" => 'i/marker', - 'name' => $highlight, - 'pixattr' => array('class' => '', 'alt' => $markthissection), - 'attr' => array('class' => 'editing_highlight', 'title' => $markthissection)); - } - } - - $parentcontrols = parent::section_edit_control_items($course, $section, $onsectionpage); - - // If the edit key exists, we are going to insert our controls after it. - if (array_key_exists("edit", $parentcontrols)) { - $merged = array(); - // We can't use splice because we are using associative arrays. - // Step through the array and merge the arrays. - foreach ($parentcontrols as $key => $action) { - $merged[$key] = $action; - if ($key == "edit") { - // If we have come to the edit key, merge these controls here. - $merged = array_merge($merged, $controls); - } - } - - return $merged; - } else { - return array_merge($controls, $parentcontrols); - } - } - - /** - * Generate a summary of a section for display on the 'course index page'. - * - * @param stdClass $section The course_section entry from DB. - * @param stdClass $course The course entry from DB. - * @param array $mods (argument not used). - * @return string HTML to output. - */ - protected function section_summary($section, $course, $mods) { - $classattr = 'section main section-summary clearfix'; - $linkclasses = ''; - - // If section is hidden then display grey section link. - if (!$section->visible) { - $classattr .= ' hidden'; - $linkclasses .= ' dimmed_text'; - } else if ($this->courseformat->is_section_current($section)) { - $classattr .= ' current'; - } - - $o = ''; - $title = $this->courseformat->get_topcoll_section_name($course, $section, false); - $liattributes = array( - 'id' => 'section-' . $section->section, - 'class' => $classattr, - 'role' => 'region', - 'aria-label' => $title - ); - if (($this->formatresponsive) && ($this->tcsettings['layoutcolumnorientation'] == 2)) { // Horizontal column layout. - $liattributes['style'] = 'width: ' . $this->tccolumnwidth . '%;'; - } - $o .= html_writer::start_tag('li', $liattributes); - - $o .= html_writer::tag('div', '', array('class' => 'left side')); - $o .= html_writer::tag('div', '', array('class' => 'right side')); - $o .= html_writer::start_tag('div', array('class' => 'content')); - - if ($section->uservisible) { - $title = html_writer::tag('a', $title, - array('href' => course_get_url($course, $section->section), 'class' => $linkclasses)); - } - $o .= $this->output->heading($title, 3, 'section-title'); - - $o .= html_writer::start_tag('div', array('class' => 'summarytext')); - $o .= $this->format_summary_text($section); - $o .= html_writer::end_tag('div'); - $o .= $this->section_activity_summary($section, $course, null); - - $context = context_course::instance($course->id); - $o .= $this->section_availability_message($section, has_capability('moodle/course:viewhiddensections', $context)); - - $o .= html_writer::end_tag('div'); - $o .= html_writer::end_tag('li'); - - return $o; - } - - /** - * Generate the display of the header part of a section before - * course modules are included. - * - * @param stdClass $section The course_section entry from DB. - * @param stdClass $course The course entry from DB. - * @param bool $onsectionpage true if being printed on a section page. - * @param int $sectionreturn The section to return to after an action. - * @return string HTML to output. - */ - protected function section_header($section, $course, $onsectionpage, $sectionreturn = null) { - $o = ''; - - $sectionstyle = ''; - $rightcurrent = ''; - $context = context_course::instance($course->id); - - if ($section->section != 0) { - // Only in the non-general sections. - if (!$section->visible) { - $sectionstyle = ' hidden'; - } else if ($this->courseformat->is_section_current($section)) { - $section->toggle = true; // Open current section regardless of toggle state. - $sectionstyle = ' current'; - $rightcurrent = ' left'; - } - } - - if ((!$this->formatresponsive) && ($section->section != 0) && - ($this->tcsettings['layoutcolumnorientation'] == 2)) { // Horizontal column layout. - $sectionstyle .= ' ' . $this->get_column_class($this->tcsettings['layoutcolumns']); - } - $liattributes = array( - 'id' => 'section-' . $section->section, - 'class' => 'section main clearfix' . $sectionstyle, - 'role' => 'region', - 'aria-label' => $this->courseformat->get_topcoll_section_name($course, $section, false) - ); - if (($this->formatresponsive) && ($this->tcsettings['layoutcolumnorientation'] == 2)) { // Horizontal column layout. - $liattributes['style'] = 'width: ' . $this->tccolumnwidth . '%;'; - } - $o .= html_writer::start_tag('li', $liattributes); - - if ((($this->mobiletheme === false) && ($this->tablettheme === false)) || ($this->userisediting)) { - $leftcontent = $this->section_left_content($section, $course, $onsectionpage); - $rightcontent = ''; - if (($section->section != 0) && $this->userisediting && has_capability('moodle/course:update', $context)) { - $url = new moodle_url('/course/editsection.php', array('id' => $section->id, 'sr' => $sectionreturn)); - - $rightcontent .= html_writer::link($url, - html_writer::empty_tag('img', - array('src' => $this->output->pix_url('t/edit'), - 'class' => 'icon edit tceditsection', 'alt' => get_string('edit'))), - array('title' => get_string('editsummary'), 'class' => 'tceditsection')); - } - $rightcontent .= $this->section_right_content($section, $course, $onsectionpage); - - if ($this->rtl) { - // Swap content. - $o .= html_writer::tag('div', $rightcontent, array('class' => 'right side')); - $o .= html_writer::tag('div', $leftcontent, array('class' => 'left side')); - } else { - $o .= html_writer::tag('div', $leftcontent, array('class' => 'left side')); - $o .= html_writer::tag('div', $rightcontent, array('class' => 'right side')); - } - } - $o .= html_writer::start_tag('div', array('class' => 'content')); - - if (($onsectionpage == false) && ($section->section != 0)) { - $o .= html_writer::start_tag('div', - array('class' => 'sectionhead toggle toggle-' . $this->tcsettings['toggleiconset'], - 'id' => 'toggle-' . $section->section)); - - if ((!($section->toggle === null)) && ($section->toggle == true)) { - $toggleclass = 'toggle_open'; - $ariapressed = 'true'; - $sectionclass = ' sectionopen'; - } else { - $toggleclass = 'toggle_closed'; - $ariapressed = 'false'; - $sectionclass = ''; - } - $toggleclass .= ' the_toggle ' . $this->tctoggleiconsize; - $toggleurl = new moodle_url('/course/view.php', array('id' => $course->id)); - $o .= html_writer::start_tag('a', - array('class' => $toggleclass, 'href' => $toggleurl, 'role' => 'button', 'aria-pressed' => $ariapressed)); - - if (empty($this->tcsettings)) { - $this->tcsettings = $this->courseformat->get_settings(); - } - - $title = $this->courseformat->get_topcoll_section_name($course, $section, true); - if ((($this->mobiletheme === false) && ($this->tablettheme === false)) || ($this->userisediting)) { - $o .= $this->output->heading($title, 3, 'section-title'); - } else { - $o .= html_writer::tag('h3', $title); // Moodle H3's look bad on mobile / tablet with CT so use plain. - } - - $o .= html_writer::end_tag('a'); - $o .= html_writer::end_tag('div'); - - if ($this->tcsettings['showsectionsummary'] == 2) { - $o .= $this->section_summary_container($section); - } - - $o .= html_writer::start_tag('div', - array('class' => 'sectionbody toggledsection' . $sectionclass, - 'id' => 'toggledsection-' . $section->section)); - - if ($this->userisediting && has_capability('moodle/course:update', $context)) { - $url = new moodle_url('/course/editsection.php', array('id' => $section->id, 'sr' => $sectionreturn)); - $o .= html_writer::link($url, - html_writer::empty_tag('img', - array('src' => $this->output->pix_url('t/edit'), - 'class' => 'iconsmall edit', 'alt' => get_string('edit'))), - array('title' => get_string('editsummary'))); - } - - if ($this->tcsettings['showsectionsummary'] == 1) { - $o .= $this->section_summary_container($section); - } - - $o .= $this->section_availability_message($section, - has_capability('moodle/course:viewhiddensections', $context)); - } else { - // When on a section page, we only display the general section title, if title is not the default one. - $hasnamesecpg = ($section->section == 0 && (string) $section->name !== ''); - - if ($hasnamesecpg) { - $o .= $this->output->heading($this->section_title($section, $course), 3, 'section-title'); - } - $o .= html_writer::start_tag('div', array('class' => 'summary')); - $o .= $this->format_summary_text($section); - - if ($this->userisediting && has_capability('moodle/course:update', $context)) { - $url = new moodle_url('/course/editsection.php', array('id' => $section->id, 'sr' => $sectionreturn)); - $o .= html_writer::link($url, - html_writer::empty_tag('img', - array('src' => $this->output->pix_url('t/edit'), - 'class' => 'iconsmall edit', 'alt' => get_string('edit'))), - array('title' => get_string('editsummary'))); - } - $o .= html_writer::end_tag('div'); - - $o .= $this->section_availability_message($section, - has_capability('moodle/course:viewhiddensections', $context)); - } - return $o; - } - - protected function section_summary_container($section) { - $summarytext = $this->format_summary_text($section); - if ($summarytext) { - $classextra = ($this->tcsettings['showsectionsummary'] == 1) ? '' : ' summaryalwaysshown'; - $o = html_writer::start_tag('div', array('class' => 'summary' . $classextra)); - $o .= $this->format_summary_text($section); - $o .= html_writer::end_tag('div'); - } else { - $o = ''; - } - return $o; - } - - /** - * Generate the display of the footer part of a section. - * - * @return string HTML to output. - */ - protected function section_footer() { - $o = html_writer::end_tag('div'); - $o .= html_writer::end_tag('li'); - - return $o; - } - - /** - * Generate the header html of a stealth section. - * - * @param int $sectionno The section number in the coruse which is being dsiplayed. - * @return string HTML to output. - */ - protected function stealth_section_header($sectionno) { - $o = ''; - $sectionstyle = ''; - $course = $this->courseformat->get_course(); - // Horizontal column layout. - if ((!$this->formatresponsive) && ($sectionno != 0) && ($this->tcsettings['layoutcolumnorientation'] == 2)) { - $sectionstyle .= ' ' . $this->get_column_class($this->tcsettings['layoutcolumns']); - } - $liattributes = array( - 'id' => 'section-' . $sectionno, - 'class' => 'section main clearfix orphaned hidden' . $sectionstyle, - 'role' => 'region', - 'aria-label' => $this->courseformat->get_topcoll_section_name($course, $sectionno, false) - ); - if (($this->formatresponsive) && ($this->tcsettings['layoutcolumnorientation'] == 2)) { // Horizontal column layout. - $liattributes['style'] = 'width: ' . $this->tccolumnwidth . '%;'; - } - $o .= html_writer::start_tag('li', $liattributes); - $o .= html_writer::tag('div', '', array('class' => 'left side')); - $section = $this->courseformat->get_section($sectionno); - $rightcontent = $this->section_right_content($section, $course, false); - $o .= html_writer::tag('div', $rightcontent, array('class' => 'right side')); - $o .= html_writer::start_tag('div', array('class' => 'content')); - $o .= $this->output->heading(get_string('orphanedactivitiesinsectionno', '', $sectionno), 3, 'sectionname'); - return $o; - } - - /** - * Generate the html for a hidden section. - * - * @param stdClass $section The section in the course which is being displayed. - * @param int|stdClass $courseorid The course to get the section name for (object or just course id). - * @return string HTML to output. - */ - protected function section_hidden($section, $courseorid = null) { - $o = ''; - $course = $this->courseformat->get_course(); - $sectionstyle = 'section main clearfix hidden'; - if ((!$this->formatresponsive) && ($this->tcsettings['layoutcolumnorientation'] == 2)) { // Horizontal column layout. - $sectionstyle .= ' ' . $this->get_column_class($this->tcsettings['layoutcolumns']); - } - $liattributes = array( - 'id' => 'section-' . $section->section, - 'class' => $sectionstyle, - 'role' => 'region', - 'aria-label' => $this->courseformat->get_topcoll_section_name($course, $section, false) - ); - if (($this->formatresponsive) && ($this->tcsettings['layoutcolumnorientation'] == 2)) { // Horizontal column layout. - $liattributes['style'] = 'width: ' . $this->tccolumnwidth . '%;'; - } - - $o .= html_writer::start_tag('li', $liattributes); - if ((($this->mobiletheme === false) && ($this->tablettheme === false)) || ($this->userisediting)) { - $leftcontent = $this->section_left_content($section, $course, false); - $rightcontent = $this->section_right_content($section, $course, false); - - if ($this->rtl) { - // Swap content. - $o .= html_writer::tag('div', $leftcontent, array('class' => 'right side')); - $o .= html_writer::tag('div', $rightcontent, array('class' => 'left side')); - } else { - $o .= html_writer::tag('div', $leftcontent, array('class' => 'left side')); - $o .= html_writer::tag('div', $rightcontent, array('class' => 'right side')); - } - - } - - $o .= html_writer::start_tag('div', array('class' => 'content sectionhidden')); - - $title = get_string('notavailable'); - if ((($this->mobiletheme === false) && ($this->tablettheme === false)) || ($this->userisediting)) { - $o .= $this->output->heading($title, 3, 'section-title'); - } else { - $o .= html_writer::tag('h3', $title); // Moodle H3's look bad on mobile / tablet with CT so use plain. - } - $o .= html_writer::end_tag('div'); - $o .= html_writer::end_tag('li'); - return $o; - } - - /** - * Output the html for a multiple section page - * - * @param stdClass $course The course entry from DB - * @param array $sections (argument not used) - * @param array $mods (argument not used) - * @param array $modnames (argument not used) - * @param array $modnamesused (argument not used) - */ - public function print_multiple_section_page($course, $sections, $mods, $modnames, $modnamesused) { - $modinfo = get_fast_modinfo($course); - $course = $this->courseformat->get_course(); - if (empty($this->tcsettings)) { - $this->tcsettings = $this->courseformat->get_settings(); - } - - $context = context_course::instance($course->id); - // Title with completion help icon. - $completioninfo = new completion_info($course); - echo $completioninfo->display_help_icon(); - echo $this->output->heading($this->page_title(), 2, 'accesshide'); - - // Copy activity clipboard.. - echo $this->course_activity_clipboard($course, 0); - - // Now the list of sections.. - if ($this->formatresponsive) { - $this->tccolumnwidth = 100; // Reset to default. - } - echo $this->start_section_list(); - - $sections = $modinfo->get_section_info_all(); - // General section if non-empty. - $thissection = $sections[0]; - unset($sections[0]); - if ($thissection->summary or ! empty($modinfo->sections[0]) or $this->userisediting) { - echo $this->section_header($thissection, $course, false, 0); - echo $this->courserenderer->course_section_cm_list($course, $thissection, 0); - echo $this->courserenderer->course_section_add_cm_control($course, $thissection->section, 0, 0); - echo $this->section_footer(); - } - - if ($course->numsections > 0) { - if ($course->numsections > 1) { - if ($this->userisediting || $course->coursedisplay != COURSE_DISPLAY_MULTIPAGE) { - // Collapsed Topics all toggles. - echo $this->toggle_all(); - if ($this->tcsettings['displayinstructions'] == 2) { - // Collapsed Topics instructions. - echo $this->display_instructions(); - } - } - } - $currentsectionfirst = false; - if (($this->tcsettings['layoutstructure'] == 4) && (!$this->userisediting)) { - $currentsectionfirst = true; - } - - if (($this->tcsettings['layoutstructure'] != 3) || ($this->userisediting)) { - $section = 1; - } else { - $timenow = time(); - $weekofseconds = 604800; - $course->enddate = $course->startdate + ($weekofseconds * $course->numsections); - $section = $course->numsections; - $weekdate = $course->enddate; // This should be 0:00 Monday of that week. - $weekdate -= 7200; // Subtract two hours to avoid possible DST problems. - } - - $numsections = $course->numsections; // Because we want to manipulate this for column breakpoints. - if (($this->tcsettings['layoutstructure'] == 3) && ($this->userisediting == false)) { - $loopsection = 1; - $numsections = 0; - while ($loopsection <= $course->numsections) { - $nextweekdate = $weekdate - ($weekofseconds); - if ((($thissection->uservisible || - ($thissection->visible && !$thissection->available && !empty($thissection->availableinfo))) && - ($nextweekdate <= $timenow)) == true) { - $numsections++; // Section not shown so do not count in columns calculation. - } - $weekdate = $nextweekdate; - $section--; - $loopsection++; - } - // Reset. - $section = $course->numsections; - $weekdate = $course->enddate; // This should be 0:00 Monday of that week. - $weekdate -= 7200; // Subtract two hours to avoid possible DST problems. - } - - if ($numsections < $this->tcsettings['layoutcolumns']) { - $this->tcsettings['layoutcolumns'] = $numsections; // Help to ensure a reasonable display. - } - if (($this->tcsettings['layoutcolumns'] > 1) && ($this->mobiletheme === false)) { - if ($this->tcsettings['layoutcolumns'] > 4) { - // Default in config.php (and reset in database) or database has been changed incorrectly. - $this->tcsettings['layoutcolumns'] = 4; - - // Update.... - $this->courseformat->update_topcoll_columns_setting($this->tcsettings['layoutcolumns']); - } - - if (($this->tablettheme === true) && ($this->tcsettings['layoutcolumns'] > 2)) { - // Use a maximum of 2 for tablets. - $this->tcsettings['layoutcolumns'] = 2; - } - - if ($this->formatresponsive) { - $this->tccolumnwidth = 100 / $this->tcsettings['layoutcolumns']; - if ($this->tcsettings['layoutcolumnorientation'] == 2) { // Horizontal column layout. - $this->tccolumnwidth -= 0.5; - $this->tccolumnpadding = 0; // In 'px'. - } else { - $this->tccolumnwidth -= 0.2; - $this->tccolumnpadding = 0; // In 'px'. - } - } - } else if ($this->tcsettings['layoutcolumns'] < 1) { - // Distributed default in plugin settings (and reset in database) or database has been changed incorrectly. - $this->tcsettings['layoutcolumns'] = 1; - - // Update.... - $this->courseformat->update_topcoll_columns_setting($this->tcsettings['layoutcolumns']); - } - - echo $this->end_section_list(); - if ((!$this->formatresponsive) && ($this->tcsettings['layoutcolumnorientation'] == 1)) { // Vertical columns. - echo html_writer::start_tag('div', array('class' => $this->get_row_class())); - } - echo $this->start_toggle_section_list(); - - $loopsection = 1; - $canbreak = false; // Once the first section is shown we can decide if we break on another column. - $columncount = 1; - $columnbreakpoint = 0; - $shownsectioncount = 0; - - if ($this->userpreference != null) { - $this->isoldtogglepreference = $this->togglelib->is_old_preference($this->userpreference); - if ($this->isoldtogglepreference == true) { - $ts1 = base_convert(substr($this->userpreference, 0, 6), 36, 2); - $ts2 = base_convert(substr($this->userpreference, 6, 12), 36, 2); - $thesparezeros = "00000000000000000000000000"; - if (strlen($ts1) < 26) { - // Need to PAD. - $ts1 = substr($thesparezeros, 0, (26 - strlen($ts1))) . $ts1; - } - if (strlen($ts2) < 27) { - // Need to PAD. - $ts2 = substr($thesparezeros, 0, (27 - strlen($ts2))) . $ts2; - } - $tb = $ts1 . $ts2; - } else { - // Check we have enough digits for the number of toggles in case this has increased. - $numdigits = $this->togglelib->get_required_digits($course->numsections); - if ($numdigits > strlen($this->userpreference)) { - if ($this->defaultuserpreference == 0) { - $dchar = $this->togglelib->get_min_digit(); - } else { - $dchar = $this->togglelib->get_max_digit(); - } - for ($i = strlen($this->userpreference); $i < $numdigits; $i++) { - $this->userpreference .= $dchar; - } - } - $this->togglelib->set_toggles($this->userpreference); - } - } else { - $numdigits = $this->togglelib->get_required_digits($course->numsections); - if ($this->defaultuserpreference == 0) { - $dchar = $this->togglelib->get_min_digit(); - } else { - $dchar = $this->togglelib->get_max_digit(); - } - $this->userpreference = ''; - for ($i = 0; $i < $numdigits; $i++) { - $this->userpreference .= $dchar; - } - $this->togglelib->set_toggles($this->userpreference); - } - - while ($loopsection <= $course->numsections) { - if (($this->tcsettings['layoutstructure'] == 3) && ($this->userisediting == false)) { - $nextweekdate = $weekdate - ($weekofseconds); - } - $thissection = $modinfo->get_section_info($section); - - /* Show the section if the user is permitted to access it, OR if it's not available - but there is some available info text which explains the reason & should display. */ - if (($this->tcsettings['layoutstructure'] != 3) || ($this->userisediting)) { - $showsection = $thissection->uservisible || - ($thissection->visible && !$thissection->available && !empty($thissection->availableinfo)); - } else { - $showsection = ($thissection->uservisible || - ($thissection->visible && !$thissection->available && !empty($thissection->availableinfo))) && - ($nextweekdate <= $timenow); - } - if (($currentsectionfirst == true) && ($showsection == true)) { - // Show the section if we were meant to and it is the current section:.... - $showsection = ($course->marker == $section); - } else if (($this->tcsettings['layoutstructure'] == 4) && - ($course->marker == $section) && (!$this->userisediting)) { - $showsection = false; // Do not reshow current section. - } - if (!$showsection) { - // Hidden section message is overridden by 'unavailable' control. - $testhidden = false; - if ($this->tcsettings['layoutstructure'] != 4) { - if (($this->tcsettings['layoutstructure'] != 3) || ($this->userisediting)) { - $testhidden = true; - } else if ($nextweekdate <= $timenow) { - $testhidden = true; - } - } else { - if (($currentsectionfirst == true) && ($course->marker == $section)) { - $testhidden = true; - } else if (($currentsectionfirst == false) && ($course->marker != $section)) { - $testhidden = true; - } - } - if ($testhidden) { - if (!$course->hiddensections && $thissection->available) { - $shownsectioncount++; - echo $this->section_hidden($thissection); - } - } - } else { - $shownsectioncount++; - if (!$this->userisediting && $course->coursedisplay == COURSE_DISPLAY_MULTIPAGE) { - // Display section summary only. - echo $this->section_summary($thissection, $course, null); - } else { - if ($this->isoldtogglepreference == true) { - $togglestate = substr($tb, $section, 1); - if ($togglestate == '1') { - $thissection->toggle = true; - } else { - $thissection->toggle = false; - } - } else { - $thissection->toggle = $this->togglelib->get_toggle_state($thissection->section); - } - echo $this->section_header($thissection, $course, false, 0); - if ($thissection->uservisible) { - echo $this->courserenderer->course_section_cm_list($course, $thissection, 0); - echo $this->courserenderer->course_section_add_cm_control($course, $thissection->section, 0); - } - echo html_writer::end_tag('div'); - echo $this->section_footer(); - } - } - - if ($currentsectionfirst == false) { - /* Only need to do this on the iteration when $currentsectionfirst is not true as this iteration will always - happen. Otherwise you get duplicate entries in course_sections in the DB. */ - unset($sections[$section]); - } - if (($this->tcsettings['layoutstructure'] != 3) || ($this->userisediting)) { - $section++; - } else { - $section--; - if (($this->tcsettings['layoutstructure'] == 3) && ($this->userisediting == false)) { - $weekdate = $nextweekdate; - } - } - - // Only break in non-mobile themes or using a reponsive theme. - if ((!$this->formatresponsive) || ($this->mobiletheme === false)) { - if ($this->tcsettings['layoutcolumnorientation'] == 1) { // Only break columns in vertical mode. - if (($canbreak == false) && ($currentsectionfirst == false) && ($showsection == true)) { - $canbreak = true; - $columnbreakpoint = ($shownsectioncount + ($numsections / $this->tcsettings['layoutcolumns'])) - 1; - if ($this->tcsettings['layoutstructure'] == 4) { - $columnbreakpoint -= 1; - } - } - - if (($currentsectionfirst == false) && ($canbreak == true) && ($shownsectioncount >= $columnbreakpoint) - && - ($columncount < $this->tcsettings['layoutcolumns'])) { - echo $this->end_section_list(); - echo $this->start_toggle_section_list(); - $columncount++; - // Next breakpoint is... - $columnbreakpoint += $numsections / $this->tcsettings['layoutcolumns']; - } - } - } - - $loopsection++; - if (($currentsectionfirst == true) && ($loopsection > $course->numsections)) { - // Now show the rest. - $currentsectionfirst = false; - $loopsection = 1; - $section = 1; - } - if ($section > $course->numsections) { - // Activities inside this section are 'orphaned', this section will be printed as 'stealth' below. - break; - } - } - } - - if ($this->userisediting and has_capability('moodle/course:update', $context)) { - // Print stealth sections if present. - foreach ($modinfo->get_section_info_all() as $section => $thissection) { - if ($section <= $course->numsections or empty($modinfo->sections[$section])) { - // This is not stealth section or it is empty. - continue; - } - echo $this->stealth_section_header($section); - echo $this->courserenderer->course_section_cm_list($course, $thissection->section, 0); - echo $this->stealth_section_footer(); - } - - echo $this->end_section_list(); - if ((!$this->formatresponsive) && ($this->tcsettings['layoutcolumnorientation'] == 1)) { // Vertical columns. - echo html_writer::end_tag('div'); - } - - echo html_writer::start_tag('div', array('id' => 'changenumsections', 'class' => 'mdl-right')); - - // Increase number of sections. - $straddsection = get_string('increasesections', 'moodle'); - $url = new moodle_url('/course/changenumsections.php', - array('courseid' => $course->id, - 'increase' => true, - 'sesskey' => sesskey())); - $icon = $this->output->pix_icon('t/switch_plus', $straddsection); - echo html_writer::link($url, $icon . get_accesshide($straddsection), array('class' => 'increase-sections')); - - if ($course->numsections > 0) { - // Reduce number of sections sections. - $strremovesection = get_string('reducesections', 'moodle'); - $url = new moodle_url('/course/changenumsections.php', - array('courseid' => $course->id, - 'increase' => false, - 'sesskey' => sesskey())); - $icon = $this->output->pix_icon('t/switch_minus', $strremovesection); - echo html_writer::link($url, $icon . get_accesshide($strremovesection), - array('class' => 'reduce-sections')); - } - - echo html_writer::end_tag('div'); - } else { - echo $this->end_section_list(); - if ((!$this->formatresponsive) && ($this->tcsettings['layoutcolumnorientation'] == 1)) { // Vertical columns. - echo html_writer::end_tag('div'); - } - } - } - - /** - * Displays the toggle all functionality. - * @return string HTML to output. - */ - protected function toggle_all() { - $o = html_writer::start_tag('li', array('class' => 'tcsection main clearfix', 'id' => 'toggle-all')); - - if ((($this->mobiletheme === false) && ($this->tablettheme === false)) || ($this->userisediting)) { - $o .= html_writer::tag('div', $this->output->spacer(), array('class' => 'left side')); - $o .= html_writer::tag('div', $this->output->spacer(), array('class' => 'right side')); - } - - $o .= html_writer::start_tag('div', array('class' => 'content')); - $iconsetclass = ' toggle-' . $this->tcsettings['toggleiconset']; - if ($this->tcsettings['toggleallhover'] == 2) { - $iconsetclass .= '-hover' . $iconsetclass; - } - $o .= html_writer::start_tag('div', array('class' => 'sectionbody' . $iconsetclass)); - $o .= html_writer::start_tag('h4', null); - $o .= html_writer::tag('a', get_string('topcollopened', 'format_topcoll'), - array('class' => 'on ' . $this->tctoggleiconsize, 'href' => '#', 'id' => 'toggles-all-opened', - 'role' => 'button')); - $o .= html_writer::tag('a', get_string('topcollclosed', 'format_topcoll'), - array('class' => 'off ' . $this->tctoggleiconsize, 'href' => '#', 'id' => 'toggles-all-closed', - 'role' => 'button')); - $o .= html_writer::end_tag('h4'); - $o .= html_writer::end_tag('div'); - $o .= html_writer::end_tag('div'); - $o .= html_writer::end_tag('li'); - - return $o; - } - - /** - * Displays the instructions functionality. - * @return string HTML to output. - */ - protected function display_instructions() { - $o = html_writer::start_tag('li', - array('class' => 'tcsection main clearfix', 'id' => 'topcoll-display-instructions')); - - if ((($this->mobiletheme === false) && ($this->tablettheme === false)) || ($this->userisediting)) { - $o .= html_writer::tag('div', $this->output->spacer(), array('class' => 'left side')); - $o .= html_writer::tag('div', $this->output->spacer(), array('class' => 'right side')); - } - - $o .= html_writer::start_tag('div', array('class' => 'content')); - $o .= html_writer::start_tag('div', array('class' => 'sectionbody')); - $o .= html_writer::tag('p', get_string('instructions', 'format_topcoll'), - array('class' => 'topcoll-display-instructions')); - $o .= html_writer::end_tag('div'); - $o .= html_writer::end_tag('div'); - $o .= html_writer::end_tag('li'); - - return $o; - } - - public function set_portable($portable) { - switch ($portable) { - case 1: - $this->mobiletheme = true; - break; - case 2: - $this->tablettheme = true; - break; - default: - $this->mobiletheme = false; - $this->tablettheme = false; - break; - } - } - - public function set_user_preference($preference) { - $this->userpreference = $preference; - } - - public function set_default_user_preference($defaultpreference) { - $this->defaultuserpreference = $defaultpreference; - } - - protected function get_row_class() { - return 'row-fluid'; - } - - protected function get_column_class($columns) { - $colclasses = array(1 => 'span12', 2 => 'span6', 3 => 'span4', 4 => 'span3'); - - return $colclasses[$columns]; - } - - public function get_format_responsive() { - return $this->formatresponsive; - } - -} +. + +/** + * Collapsed Topics Information + * + * A topic based format that solves the issue of the 'Scroll of Death' when a course has many topics. All topics + * except zero have a toggle that displays that topic. One or more topics can be displayed at any given time. + * Toggles are persistent on a per browser session per course basis but can be made to persist longer by a small + * code change. Full installation instructions, code adaptions and credits are included in the 'Readme.txt' file. + * + * @package course/format + * @subpackage topcoll + * @version See the value of '$plugin->version' in below. + * @copyright © 2012-onwards G J Barnard in respect to modifications of standard topics format. + * @author G J Barnard - gjbarnard at gmail dot com and {@link http://moodle.org/user/profile.php?id=442195} + * @link http://docs.moodle.org/en/Collapsed_Topics_course_format + * @license http://www.gnu.org/copyleft/gpl.html GNU Public License + * + */ +defined('MOODLE_INTERNAL') || die(); +require_once($CFG->dirroot . '/course/format/renderer.php'); +require_once($CFG->dirroot . '/course/format/topcoll/lib.php'); +require_once($CFG->dirroot . '/course/format/topcoll/togglelib.php'); + +class format_topcoll_renderer extends format_section_renderer_base { + + private $tccolumnwidth = 100; // Default width in percent of the column(s). + private $tccolumnpadding = 0; // Default padding in pixels of the column(s). + private $mobiletheme = false; // As not using a mobile theme we can react to the number of columns setting. + private $tablettheme = false; // As not using a tablet theme we can react to the number of columns setting. + private $courseformat = null; // Our course format object as defined in lib.php; + private $tcsettings; // Settings for the format - array. + private $userpreference; // User toggle state preference - string. + private $defaultuserpreference; // Default user preference when none set - bool - true all open, false all closed. + private $togglelib; + private $isoldtogglepreference = false; + private $userisediting = false; + private $tctoggleiconsize; + private $formatresponsive; + private $rtl = false; + + /** + * Constructor method, calls the parent constructor - MDL-21097. + * + * @param moodle_page $page. + * @param string $target one of rendering target constants. + */ + public function __construct(moodle_page $page, $target) { + parent::__construct($page, $target); + $this->togglelib = new topcoll_togglelib; + $this->courseformat = course_get_format($page->course); // Needed for collapsed topics settings retrieval. + + /* Since format_topcoll_renderer::section_edit_control_items() only displays the 'Set current section' control when editing + mode is on we need to be sure that the link 'Turn editing mode on' is available for a user who does not have any + other managing capability. */ + $page->set_other_editing_capability('moodle/course:setcurrentsection'); + + global $PAGE; + $this->userisediting = $PAGE->user_is_editing(); + $this->tctoggleiconsize = clean_param(get_config('format_topcoll', 'defaulttoggleiconsize'), PARAM_TEXT); + $this->formatresponsive = get_config('format_topcoll', 'formatresponsive'); + + $this->rtl = right_to_left(); + } + + /** + * Generate the starting container html for a list of sections. + * @return string HTML to output. + */ + protected function start_section_list() { + return html_writer::start_tag('ul', array('class' => 'ctopics')); + } + + /** + * Generate the starting container html for a list of sections when showing a toggle. + * @return string HTML to output. + */ + protected function start_toggle_section_list() { + $classes = 'ctopics topics'; + $attributes = array(); + if (($this->mobiletheme === true) || ($this->tablettheme === true)) { + $classes .= ' ctportable'; + } + if ($this->formatresponsive) { + $style = ''; + if ($this->tcsettings['layoutcolumnorientation'] == 1) { // Vertical columns. + $style .= 'width:' . $this->tccolumnwidth . '%;'; + } else { + $style .= 'width: 100%;'; // Horizontal columns. + } + if ($this->mobiletheme === false) { + $classes .= ' ctlayout'; + } + $style .= ' padding-left: ' . $this->tccolumnpadding . 'px; padding-right: ' . $this->tccolumnpadding . 'px;'; + $attributes['style'] = $style; + } else { + if ($this->tcsettings['layoutcolumnorientation'] == 1) { // Vertical columns. + $classes .= ' ' . $this->get_column_class($this->tcsettings['layoutcolumns']); + } else { + $classes .= ' ' . $this->get_row_class(); + } + } + $attributes['class'] = $classes; + + return html_writer::start_tag('ul', $attributes); + } + + /** + * Generate the closing container html for a list of sections. + * @return string HTML to output. + */ + protected function end_section_list() { + return html_writer::end_tag('ul'); + } + + /** + * Generate the title for this section page. + * @return string the page title. + */ + protected function page_title() { + return get_string('sectionname', 'format_topcoll'); + } + + /** + * Generate the content to displayed on the right part of a section + * before course modules are included. + * + * @param stdClass $section The course_section entry from DB. + * @param stdClass $course The course entry from DB. + * @param bool $onsectionpage true if being printed on a section page. + * @return string HTML to output. + */ + protected function section_right_content($section, $course, $onsectionpage) { + $o = ''; + + if ($section->section != 0) { + $controls = $this->section_edit_control_items($course, $section, $onsectionpage); + if (!empty($controls)) { + $o .= $this->section_edit_control_menu($controls, $course, $section); + } else { + if (empty($this->tcsettings)) { + $this->tcsettings = $this->courseformat->get_settings(); + } + switch ($this->tcsettings['layoutelement']) { // Toggle section x. + case 1: + case 3: + case 5: + case 8: + // Get the specific words from the language files. + $topictext = null; + if (($this->tcsettings['layoutstructure'] == 1) || ($this->tcsettings['layoutstructure'] == 4)) { + $topictext = get_string('setlayoutstructuretopic', 'format_topcoll'); + } else if (($this->tcsettings['layoutstructure'] == 2) || ($this->tcsettings['layoutstructure'] == 3)) { + $topictext = get_string('setlayoutstructureweek', 'format_topcoll'); + } else { + $topictext = get_string('setlayoutstructureday', 'format_topcoll'); + } + + $o .= html_writer::tag('span', + $topictext . html_writer::empty_tag('br') . + $section->section, array('class' => 'cps_centre')); + break; + } + } + } + + return $o; + } + + /** + * Generate the content to displayed on the left part of a section + * before course modules are included. + * + * @param stdClass $section The course_section entry from DB. + * @param stdClass $course The course entry from DB. + * @param bool $onsectionpage true if being printed on a section page. + * @return string HTML to output. + */ + protected function section_left_content($section, $course, $onsectionpage) { + $o = ''; + + if ($section->section != 0) { + // Only in the non-general sections. + if ($this->courseformat->is_section_current($section)) { + $o .= get_accesshide(get_string('currentsection', 'format_' . $course->format)); + } + if (empty($this->tcsettings)) { + $this->tcsettings = $this->courseformat->get_settings(); + } + switch ($this->tcsettings['layoutelement']) { + case 1: + case 2: + case 5: + case 6: + $o .= html_writer::tag('span', $section->section, array('class' => 'cps_centre')); + break; + } + } + return $o; + } + + /** + * Generate the edit controls of a section. + * + * @param stdClass $course The course entry from DB. + * @param stdClass $section The course_section entry from DB. + * @param bool $onsectionpage true if being printed on a section page. + * @return array of links with edit controls. + */ + protected function section_edit_control_items($course, $section, $onsectionpage = false) { + + if (!$this->userisediting) { + return array(); + } + + $coursecontext = context_course::instance($course->id); + + if ($onsectionpage) { + $url = course_get_url($course, $section->section); + } else { + $url = course_get_url($course); + } + $url->param('sesskey', sesskey()); + + if (empty($this->tcsettings)) { + $this->tcsettings = $this->courseformat->get_settings(); + } + $isstealth = $section->section > $course->numsections; + $controls = array(); + if ((($this->tcsettings['layoutstructure'] == 1) || ($this->tcsettings['layoutstructure'] == 4)) && + !$isstealth && $section->section && has_capability('moodle/course:setcurrentsection', $coursecontext)) { + if ($course->marker == $section->section) { // Show the "light globe" on/off. + $url->param('marker', 0); + $markedthissection = get_string('markedthissection', 'format_topcoll'); + $highlightoff = get_string('highlightoff'); + $controls['highlight'] = array('url' => $url, "icon" => 'i/marked', + 'name' => $highlightoff, + 'pixattr' => array('class' => '', 'alt' => $markedthissection), + 'attr' => array('class' => 'editing_highlight', 'title' => $markedthissection)); + } else { + $url->param('marker', $section->section); + $markthissection = get_string('markthissection', 'format_topcoll'); + $highlight = get_string('highlight'); + $controls['highlight'] = array('url' => $url, "icon" => 'i/marker', + 'name' => $highlight, + 'pixattr' => array('class' => '', 'alt' => $markthissection), + 'attr' => array('class' => 'editing_highlight', 'title' => $markthissection)); + } + } + + $parentcontrols = parent::section_edit_control_items($course, $section, $onsectionpage); + + // If the edit key exists, we are going to insert our controls after it. + if (array_key_exists("edit", $parentcontrols)) { + $merged = array(); + // We can't use splice because we are using associative arrays. + // Step through the array and merge the arrays. + foreach ($parentcontrols as $key => $action) { + $merged[$key] = $action; + if ($key == "edit") { + // If we have come to the edit key, merge these controls here. + $merged = array_merge($merged, $controls); + } + } + + return $merged; + } else { + return array_merge($controls, $parentcontrols); + } + } + + /** + * Generate a summary of a section for display on the 'course index page'. + * + * @param stdClass $section The course_section entry from DB. + * @param stdClass $course The course entry from DB. + * @param array $mods (argument not used). + * @return string HTML to output. + */ + protected function section_summary($section, $course, $mods) { + $classattr = 'section main section-summary clearfix'; + $linkclasses = ''; + + // If section is hidden then display grey section link. + if (!$section->visible) { + $classattr .= ' hidden'; + $linkclasses .= ' dimmed_text'; + } else if ($this->courseformat->is_section_current($section)) { + $classattr .= ' current'; + } + + $o = ''; + $title = $this->courseformat->get_topcoll_section_name($course, $section, false); + $liattributes = array( + 'id' => 'section-' . $section->section, + 'class' => $classattr, + 'role' => 'region', + 'aria-label' => $title + ); + if (($this->formatresponsive) && ($this->tcsettings['layoutcolumnorientation'] == 2)) { // Horizontal column layout. + $liattributes['style'] = 'width: ' . $this->tccolumnwidth . '%;'; + } + $o .= html_writer::start_tag('li', $liattributes); + + $o .= html_writer::tag('div', '', array('class' => 'left side')); + $o .= html_writer::tag('div', '', array('class' => 'right side')); + $o .= html_writer::start_tag('div', array('class' => 'content')); + + if ($section->uservisible) { + $title = html_writer::tag('a', $title, + array('href' => course_get_url($course, $section->section), 'class' => $linkclasses)); + } + $o .= $this->output->heading($title, 3, 'section-title'); + + $o .= html_writer::start_tag('div', array('class' => 'summarytext')); + $o .= $this->format_summary_text($section); + $o .= html_writer::end_tag('div'); + $o .= $this->section_activity_summary($section, $course, null); + + $context = context_course::instance($course->id); + $o .= $this->section_availability_message($section, has_capability('moodle/course:viewhiddensections', $context)); + + $o .= html_writer::end_tag('div'); + $o .= html_writer::end_tag('li'); + + return $o; + } + + /** + * Generate the display of the header part of a section before + * course modules are included. + * + * @param stdClass $section The course_section entry from DB. + * @param stdClass $course The course entry from DB. + * @param bool $onsectionpage true if being printed on a section page. + * @param int $sectionreturn The section to return to after an action. + * @return string HTML to output. + */ + protected function section_header($section, $course, $onsectionpage, $sectionreturn = null) { + $o = ''; + + $sectionstyle = ''; + $rightcurrent = ''; + $context = context_course::instance($course->id); + + if ($section->section != 0) { + // Only in the non-general sections. + if (!$section->visible) { + $sectionstyle = ' hidden'; + } else if ($this->courseformat->is_section_current($section)) { + $section->toggle = true; // Open current section regardless of toggle state. + $sectionstyle = ' current'; + $rightcurrent = ' left'; + } + } + + if ((!$this->formatresponsive) && ($section->section != 0) && + ($this->tcsettings['layoutcolumnorientation'] == 2)) { // Horizontal column layout. + $sectionstyle .= ' ' . $this->get_column_class($this->tcsettings['layoutcolumns']); + } + $liattributes = array( + 'id' => 'section-' . $section->section, + 'class' => 'section main clearfix' . $sectionstyle, + 'role' => 'region', + 'aria-label' => $this->courseformat->get_topcoll_section_name($course, $section, false) + ); + if (($this->formatresponsive) && ($this->tcsettings['layoutcolumnorientation'] == 2)) { // Horizontal column layout. + $liattributes['style'] = 'width: ' . $this->tccolumnwidth . '%;'; + } + $o .= html_writer::start_tag('li', $liattributes); + + if ((($this->mobiletheme === false) && ($this->tablettheme === false)) || ($this->userisediting)) { + $leftcontent = $this->section_left_content($section, $course, $onsectionpage); + $rightcontent = ''; + if (($section->section != 0) && $this->userisediting && has_capability('moodle/course:update', $context)) { + $url = new moodle_url('/course/editsection.php', array('id' => $section->id, 'sr' => $sectionreturn)); + + $rightcontent .= html_writer::link($url, + html_writer::empty_tag('img', + array('src' => $this->output->pix_url('t/edit'), + 'class' => 'icon edit tceditsection', 'alt' => get_string('edit'))), + array('title' => get_string('editsummary'), 'class' => 'tceditsection')); + } + $rightcontent .= $this->section_right_content($section, $course, $onsectionpage); + + if ($this->rtl) { + // Swap content. + $o .= html_writer::tag('div', $rightcontent, array('class' => 'right side')); + $o .= html_writer::tag('div', $leftcontent, array('class' => 'left side')); + } else { + $o .= html_writer::tag('div', $leftcontent, array('class' => 'left side')); + $o .= html_writer::tag('div', $rightcontent, array('class' => 'right side')); + } + } + $o .= html_writer::start_tag('div', array('class' => 'content')); + + if (($onsectionpage == false) && ($section->section != 0)) { + $o .= html_writer::start_tag('div', + array('class' => 'sectionhead toggle toggle-' . $this->tcsettings['toggleiconset'], + 'id' => 'toggle-' . $section->section)); + + if ((!($section->toggle === null)) && ($section->toggle == true)) { + $toggleclass = 'toggle_open'; + $ariapressed = 'true'; + $sectionclass = ' sectionopen'; + } else { + $toggleclass = 'toggle_closed'; + $ariapressed = 'false'; + $sectionclass = ''; + } + $toggleclass .= ' the_toggle ' . $this->tctoggleiconsize; + $toggleurl = new moodle_url('/course/view.php', array('id' => $course->id)); + $o .= html_writer::start_tag('a', + array('class' => $toggleclass, 'href' => $toggleurl, 'role' => 'button', 'aria-pressed' => $ariapressed)); + + if (empty($this->tcsettings)) { + $this->tcsettings = $this->courseformat->get_settings(); + } + + $title = $this->courseformat->get_topcoll_section_name($course, $section, true); + if ((($this->mobiletheme === false) && ($this->tablettheme === false)) || ($this->userisediting)) { + $o .= $this->output->heading($title, 3, 'section-title'); + } else { + $o .= html_writer::tag('h3', $title); // Moodle H3's look bad on mobile / tablet with CT so use plain. + } + + $o .= html_writer::end_tag('a'); + $o .= html_writer::end_tag('div'); + + if ($this->tcsettings['showsectionsummary'] == 2) { + $o .= $this->section_summary_container($section); + } + + $o .= html_writer::start_tag('div', + array('class' => 'sectionbody toggledsection' . $sectionclass, + 'id' => 'toggledsection-' . $section->section)); + + if ($this->userisediting && has_capability('moodle/course:update', $context)) { + $url = new moodle_url('/course/editsection.php', array('id' => $section->id, 'sr' => $sectionreturn)); + $o .= html_writer::link($url, + html_writer::empty_tag('img', + array('src' => $this->output->pix_url('t/edit'), + 'class' => 'iconsmall edit', 'alt' => get_string('edit'))), + array('title' => get_string('editsummary'))); + } + + if ($this->tcsettings['showsectionsummary'] == 1) { + $o .= $this->section_summary_container($section); + } + + $o .= $this->section_availability_message($section, + has_capability('moodle/course:viewhiddensections', $context)); + } else { + // When on a section page, we only display the general section title, if title is not the default one. + $hasnamesecpg = ($section->section == 0 && (string) $section->name !== ''); + + if ($hasnamesecpg) { + $o .= $this->output->heading($this->section_title($section, $course), 3, 'section-title'); + } + $o .= html_writer::start_tag('div', array('class' => 'summary')); + $o .= $this->format_summary_text($section); + + if ($this->userisediting && has_capability('moodle/course:update', $context)) { + $url = new moodle_url('/course/editsection.php', array('id' => $section->id, 'sr' => $sectionreturn)); + $o .= html_writer::link($url, + html_writer::empty_tag('img', + array('src' => $this->output->pix_url('t/edit'), + 'class' => 'iconsmall edit', 'alt' => get_string('edit'))), + array('title' => get_string('editsummary'))); + } + $o .= html_writer::end_tag('div'); + + $o .= $this->section_availability_message($section, + has_capability('moodle/course:viewhiddensections', $context)); + } + return $o; + } + + protected function section_summary_container($section) { + $summarytext = $this->format_summary_text($section); + if ($summarytext) { + $classextra = ($this->tcsettings['showsectionsummary'] == 1) ? '' : ' summaryalwaysshown'; + $o = html_writer::start_tag('div', array('class' => 'summary' . $classextra)); + $o .= $this->format_summary_text($section); + $o .= html_writer::end_tag('div'); + } else { + $o = ''; + } + return $o; + } + + /** + * Generate the display of the footer part of a section. + * + * @return string HTML to output. + */ + protected function section_footer() { + $o = html_writer::end_tag('div'); + $o .= html_writer::end_tag('li'); + + return $o; + } + + /** + * Generate the header html of a stealth section. + * + * @param int $sectionno The section number in the coruse which is being dsiplayed. + * @return string HTML to output. + */ + protected function stealth_section_header($sectionno) { + $o = ''; + $sectionstyle = ''; + $course = $this->courseformat->get_course(); + // Horizontal column layout. + if ((!$this->formatresponsive) && ($sectionno != 0) && ($this->tcsettings['layoutcolumnorientation'] == 2)) { + $sectionstyle .= ' ' . $this->get_column_class($this->tcsettings['layoutcolumns']); + } + $liattributes = array( + 'id' => 'section-' . $sectionno, + 'class' => 'section main clearfix orphaned hidden' . $sectionstyle, + 'role' => 'region', + 'aria-label' => $this->courseformat->get_topcoll_section_name($course, $sectionno, false) + ); + if (($this->formatresponsive) && ($this->tcsettings['layoutcolumnorientation'] == 2)) { // Horizontal column layout. + $liattributes['style'] = 'width: ' . $this->tccolumnwidth . '%;'; + } + $o .= html_writer::start_tag('li', $liattributes); + $o .= html_writer::tag('div', '', array('class' => 'left side')); + $section = $this->courseformat->get_section($sectionno); + $rightcontent = $this->section_right_content($section, $course, false); + $o .= html_writer::tag('div', $rightcontent, array('class' => 'right side')); + $o .= html_writer::start_tag('div', array('class' => 'content')); + $o .= $this->output->heading(get_string('orphanedactivitiesinsectionno', '', $sectionno), 3, 'sectionname'); + return $o; + } + + /** + * Generate the html for a hidden section. + * + * @param stdClass $section The section in the course which is being displayed. + * @param int|stdClass $courseorid The course to get the section name for (object or just course id). + * @return string HTML to output. + */ + protected function section_hidden($section, $courseorid = null) { + $o = ''; + $course = $this->courseformat->get_course(); + $sectionstyle = 'section main clearfix hidden'; + if ((!$this->formatresponsive) && ($this->tcsettings['layoutcolumnorientation'] == 2)) { // Horizontal column layout. + $sectionstyle .= ' ' . $this->get_column_class($this->tcsettings['layoutcolumns']); + } + $liattributes = array( + 'id' => 'section-' . $section->section, + 'class' => $sectionstyle, + 'role' => 'region', + 'aria-label' => $this->courseformat->get_topcoll_section_name($course, $section, false) + ); + if (($this->formatresponsive) && ($this->tcsettings['layoutcolumnorientation'] == 2)) { // Horizontal column layout. + $liattributes['style'] = 'width: ' . $this->tccolumnwidth . '%;'; + } + + $o .= html_writer::start_tag('li', $liattributes); + if ((($this->mobiletheme === false) && ($this->tablettheme === false)) || ($this->userisediting)) { + $leftcontent = $this->section_left_content($section, $course, false); + $rightcontent = $this->section_right_content($section, $course, false); + + if ($this->rtl) { + // Swap content. + $o .= html_writer::tag('div', $leftcontent, array('class' => 'right side')); + $o .= html_writer::tag('div', $rightcontent, array('class' => 'left side')); + } else { + $o .= html_writer::tag('div', $leftcontent, array('class' => 'left side')); + $o .= html_writer::tag('div', $rightcontent, array('class' => 'right side')); + } + + } + + $o .= html_writer::start_tag('div', array('class' => 'content sectionhidden')); + + $title = get_string('notavailable'); + if ((($this->mobiletheme === false) && ($this->tablettheme === false)) || ($this->userisediting)) { + $o .= $this->output->heading($title, 3, 'section-title'); + } else { + $o .= html_writer::tag('h3', $title); // Moodle H3's look bad on mobile / tablet with CT so use plain. + } + $o .= html_writer::end_tag('div'); + $o .= html_writer::end_tag('li'); + return $o; + } + + /** + * Output the html for a multiple section page + * + * @param stdClass $course The course entry from DB + * @param array $sections (argument not used) + * @param array $mods (argument not used) + * @param array $modnames (argument not used) + * @param array $modnamesused (argument not used) + */ + public function print_multiple_section_page($course, $sections, $mods, $modnames, $modnamesused) { + $modinfo = get_fast_modinfo($course); + $course = $this->courseformat->get_course(); + if (empty($this->tcsettings)) { + $this->tcsettings = $this->courseformat->get_settings(); + } + + $context = context_course::instance($course->id); + // Title with completion help icon. + $completioninfo = new completion_info($course); + echo $completioninfo->display_help_icon(); + echo $this->output->heading($this->page_title(), 2, 'accesshide'); + + // Copy activity clipboard.. + echo $this->course_activity_clipboard($course, 0); + + // Now the list of sections.. + if ($this->formatresponsive) { + $this->tccolumnwidth = 100; // Reset to default. + } + echo $this->start_section_list(); + + $sections = $modinfo->get_section_info_all(); + // General section if non-empty. + $thissection = $sections[0]; + unset($sections[0]); + if ($thissection->summary or ! empty($modinfo->sections[0]) or $this->userisediting) { + echo $this->section_header($thissection, $course, false, 0); + echo $this->courserenderer->course_section_cm_list($course, $thissection, 0); + echo $this->courserenderer->course_section_add_cm_control($course, $thissection->section, 0, 0); + echo $this->section_footer(); + } + + if ($course->numsections > 0) { + if ($course->numsections > 1) { + if ($this->userisediting || $course->coursedisplay != COURSE_DISPLAY_MULTIPAGE) { + // Collapsed Topics all toggles. + echo $this->toggle_all(); + if ($this->tcsettings['displayinstructions'] == 2) { + // Collapsed Topics instructions. + echo $this->display_instructions(); + } + } + } + $currentsectionfirst = false; + if (($this->tcsettings['layoutstructure'] == 4) && (!$this->userisediting)) { + $currentsectionfirst = true; + } + + if (($this->tcsettings['layoutstructure'] != 3) || ($this->userisediting)) { + $section = 1; + } else { + $timenow = time(); + $weekofseconds = 604800; + $course->enddate = $course->startdate + ($weekofseconds * $course->numsections); + $section = $course->numsections; + $weekdate = $course->enddate; // This should be 0:00 Monday of that week. + $weekdate -= 7200; // Subtract two hours to avoid possible DST problems. + } + + $numsections = $course->numsections; // Because we want to manipulate this for column breakpoints. + if (($this->tcsettings['layoutstructure'] == 3) && ($this->userisediting == false)) { + $loopsection = 1; + $numsections = 0; + while ($loopsection <= $course->numsections) { + $nextweekdate = $weekdate - ($weekofseconds); + if ((($thissection->uservisible || + ($thissection->visible && !$thissection->available && !empty($thissection->availableinfo))) && + ($nextweekdate <= $timenow)) == true) { + $numsections++; // Section not shown so do not count in columns calculation. + } + $weekdate = $nextweekdate; + $section--; + $loopsection++; + } + // Reset. + $section = $course->numsections; + $weekdate = $course->enddate; // This should be 0:00 Monday of that week. + $weekdate -= 7200; // Subtract two hours to avoid possible DST problems. + } + + if ($numsections < $this->tcsettings['layoutcolumns']) { + $this->tcsettings['layoutcolumns'] = $numsections; // Help to ensure a reasonable display. + } + if (($this->tcsettings['layoutcolumns'] > 1) && ($this->mobiletheme === false)) { + if ($this->tcsettings['layoutcolumns'] > 4) { + // Default in config.php (and reset in database) or database has been changed incorrectly. + $this->tcsettings['layoutcolumns'] = 4; + + // Update.... + $this->courseformat->update_topcoll_columns_setting($this->tcsettings['layoutcolumns']); + } + + if (($this->tablettheme === true) && ($this->tcsettings['layoutcolumns'] > 2)) { + // Use a maximum of 2 for tablets. + $this->tcsettings['layoutcolumns'] = 2; + } + + if ($this->formatresponsive) { + $this->tccolumnwidth = 100 / $this->tcsettings['layoutcolumns']; + if ($this->tcsettings['layoutcolumnorientation'] == 2) { // Horizontal column layout. + $this->tccolumnwidth -= 0.5; + $this->tccolumnpadding = 0; // In 'px'. + } else { + $this->tccolumnwidth -= 0.2; + $this->tccolumnpadding = 0; // In 'px'. + } + } + } else if ($this->tcsettings['layoutcolumns'] < 1) { + // Distributed default in plugin settings (and reset in database) or database has been changed incorrectly. + $this->tcsettings['layoutcolumns'] = 1; + + // Update.... + $this->courseformat->update_topcoll_columns_setting($this->tcsettings['layoutcolumns']); + } + + echo $this->end_section_list(); + if ((!$this->formatresponsive) && ($this->tcsettings['layoutcolumnorientation'] == 1)) { // Vertical columns. + echo html_writer::start_tag('div', array('class' => $this->get_row_class())); + } + echo $this->start_toggle_section_list(); + + $loopsection = 1; + $canbreak = false; // Once the first section is shown we can decide if we break on another column. + $columncount = 1; + $columnbreakpoint = 0; + $shownsectioncount = 0; + + if ($this->userpreference != null) { + $this->isoldtogglepreference = $this->togglelib->is_old_preference($this->userpreference); + if ($this->isoldtogglepreference == true) { + $ts1 = base_convert(substr($this->userpreference, 0, 6), 36, 2); + $ts2 = base_convert(substr($this->userpreference, 6, 12), 36, 2); + $thesparezeros = "00000000000000000000000000"; + if (strlen($ts1) < 26) { + // Need to PAD. + $ts1 = substr($thesparezeros, 0, (26 - strlen($ts1))) . $ts1; + } + if (strlen($ts2) < 27) { + // Need to PAD. + $ts2 = substr($thesparezeros, 0, (27 - strlen($ts2))) . $ts2; + } + $tb = $ts1 . $ts2; + } else { + // Check we have enough digits for the number of toggles in case this has increased. + $numdigits = $this->togglelib->get_required_digits($course->numsections); + if ($numdigits > strlen($this->userpreference)) { + if ($this->defaultuserpreference == 0) { + $dchar = $this->togglelib->get_min_digit(); + } else { + $dchar = $this->togglelib->get_max_digit(); + } + for ($i = strlen($this->userpreference); $i < $numdigits; $i++) { + $this->userpreference .= $dchar; + } + } + $this->togglelib->set_toggles($this->userpreference); + } + } else { + $numdigits = $this->togglelib->get_required_digits($course->numsections); + if ($this->defaultuserpreference == 0) { + $dchar = $this->togglelib->get_min_digit(); + } else { + $dchar = $this->togglelib->get_max_digit(); + } + $this->userpreference = ''; + for ($i = 0; $i < $numdigits; $i++) { + $this->userpreference .= $dchar; + } + $this->togglelib->set_toggles($this->userpreference); + } + + while ($loopsection <= $course->numsections) { + if (($this->tcsettings['layoutstructure'] == 3) && ($this->userisediting == false)) { + $nextweekdate = $weekdate - ($weekofseconds); + } + $thissection = $modinfo->get_section_info($section); + + /* Show the section if the user is permitted to access it, OR if it's not available + but there is some available info text which explains the reason & should display. */ + if (($this->tcsettings['layoutstructure'] != 3) || ($this->userisediting)) { + $showsection = $thissection->uservisible || + ($thissection->visible && !$thissection->available && !empty($thissection->availableinfo)); + } else { + $showsection = ($thissection->uservisible || + ($thissection->visible && !$thissection->available && !empty($thissection->availableinfo))) && + ($nextweekdate <= $timenow); + } + if (($currentsectionfirst == true) && ($showsection == true)) { + // Show the section if we were meant to and it is the current section:.... + $showsection = ($course->marker == $section); + } else if (($this->tcsettings['layoutstructure'] == 4) && + ($course->marker == $section) && (!$this->userisediting)) { + $showsection = false; // Do not reshow current section. + } + if (!$showsection) { + // Hidden section message is overridden by 'unavailable' control. + $testhidden = false; + if ($this->tcsettings['layoutstructure'] != 4) { + if (($this->tcsettings['layoutstructure'] != 3) || ($this->userisediting)) { + $testhidden = true; + } else if ($nextweekdate <= $timenow) { + $testhidden = true; + } + } else { + if (($currentsectionfirst == true) && ($course->marker == $section)) { + $testhidden = true; + } else if (($currentsectionfirst == false) && ($course->marker != $section)) { + $testhidden = true; + } + } + if ($testhidden) { + if (!$course->hiddensections && $thissection->available) { + $shownsectioncount++; + echo $this->section_hidden($thissection); + } + } + } else { + $shownsectioncount++; + if (!$this->userisediting && $course->coursedisplay == COURSE_DISPLAY_MULTIPAGE) { + // Display section summary only. + echo $this->section_summary($thissection, $course, null); + } else { + if ($this->isoldtogglepreference == true) { + $togglestate = substr($tb, $section, 1); + if ($togglestate == '1') { + $thissection->toggle = true; + } else { + $thissection->toggle = false; + } + } else { + $thissection->toggle = $this->togglelib->get_toggle_state($thissection->section); + } + echo $this->section_header($thissection, $course, false, 0); + if ($thissection->uservisible) { + echo $this->courserenderer->course_section_cm_list($course, $thissection, 0); + echo $this->courserenderer->course_section_add_cm_control($course, $thissection->section, 0); + } + echo html_writer::end_tag('div'); + echo $this->section_footer(); + } + } + + if ($currentsectionfirst == false) { + /* Only need to do this on the iteration when $currentsectionfirst is not true as this iteration will always + happen. Otherwise you get duplicate entries in course_sections in the DB. */ + unset($sections[$section]); + } + if (($this->tcsettings['layoutstructure'] != 3) || ($this->userisediting)) { + $section++; + } else { + $section--; + if (($this->tcsettings['layoutstructure'] == 3) && ($this->userisediting == false)) { + $weekdate = $nextweekdate; + } + } + + // Only break in non-mobile themes or using a reponsive theme. + if ((!$this->formatresponsive) || ($this->mobiletheme === false)) { + if ($this->tcsettings['layoutcolumnorientation'] == 1) { // Only break columns in vertical mode. + if (($canbreak == false) && ($currentsectionfirst == false) && ($showsection == true)) { + $canbreak = true; + $columnbreakpoint = ($shownsectioncount + ($numsections / $this->tcsettings['layoutcolumns'])) - 1; + if ($this->tcsettings['layoutstructure'] == 4) { + $columnbreakpoint -= 1; + } + } + + if (($currentsectionfirst == false) && ($canbreak == true) && ($shownsectioncount >= $columnbreakpoint) + && + ($columncount < $this->tcsettings['layoutcolumns'])) { + echo $this->end_section_list(); + echo $this->start_toggle_section_list(); + $columncount++; + // Next breakpoint is... + $columnbreakpoint += $numsections / $this->tcsettings['layoutcolumns']; + } + } + } + + $loopsection++; + if (($currentsectionfirst == true) && ($loopsection > $course->numsections)) { + // Now show the rest. + $currentsectionfirst = false; + $loopsection = 1; + $section = 1; + } + if ($section > $course->numsections) { + // Activities inside this section are 'orphaned', this section will be printed as 'stealth' below. + break; + } + } + } + + if ($this->userisediting and has_capability('moodle/course:update', $context)) { + // Print stealth sections if present. + foreach ($modinfo->get_section_info_all() as $section => $thissection) { + if ($section <= $course->numsections or empty($modinfo->sections[$section])) { + // This is not stealth section or it is empty. + continue; + } + echo $this->stealth_section_header($section); + echo $this->courserenderer->course_section_cm_list($course, $thissection->section, 0); + echo $this->stealth_section_footer(); + } + + echo $this->end_section_list(); + if ((!$this->formatresponsive) && ($this->tcsettings['layoutcolumnorientation'] == 1)) { // Vertical columns. + echo html_writer::end_tag('div'); + } + + echo html_writer::start_tag('div', array('id' => 'changenumsections', 'class' => 'mdl-right')); + + // Increase number of sections. + $straddsection = get_string('increasesections', 'moodle'); + $url = new moodle_url('/course/changenumsections.php', + array('courseid' => $course->id, + 'increase' => true, + 'sesskey' => sesskey())); + $icon = $this->output->pix_icon('t/switch_plus', $straddsection); + echo html_writer::link($url, $icon . get_accesshide($straddsection), array('class' => 'increase-sections')); + + if ($course->numsections > 0) { + // Reduce number of sections sections. + $strremovesection = get_string('reducesections', 'moodle'); + $url = new moodle_url('/course/changenumsections.php', + array('courseid' => $course->id, + 'increase' => false, + 'sesskey' => sesskey())); + $icon = $this->output->pix_icon('t/switch_minus', $strremovesection); + echo html_writer::link($url, $icon . get_accesshide($strremovesection), + array('class' => 'reduce-sections')); + } + + echo html_writer::end_tag('div'); + } else { + echo $this->end_section_list(); + if ((!$this->formatresponsive) && ($this->tcsettings['layoutcolumnorientation'] == 1)) { // Vertical columns. + echo html_writer::end_tag('div'); + } + } + } + + /** + * Displays the toggle all functionality. + * @return string HTML to output. + */ + protected function toggle_all() { + $o = html_writer::start_tag('li', array('class' => 'tcsection main clearfix', 'id' => 'toggle-all')); + + if ((($this->mobiletheme === false) && ($this->tablettheme === false)) || ($this->userisediting)) { + $o .= html_writer::tag('div', $this->output->spacer(), array('class' => 'left side')); + $o .= html_writer::tag('div', $this->output->spacer(), array('class' => 'right side')); + } + + $o .= html_writer::start_tag('div', array('class' => 'content')); + $iconsetclass = ' toggle-' . $this->tcsettings['toggleiconset']; + if ($this->tcsettings['toggleallhover'] == 2) { + $iconsetclass .= '-hover' . $iconsetclass; + } + $o .= html_writer::start_tag('div', array('class' => 'sectionbody' . $iconsetclass)); + $o .= html_writer::start_tag('h4', null); + $o .= html_writer::tag('a', get_string('topcollopened', 'format_topcoll'), + array('class' => 'on ' . $this->tctoggleiconsize, 'href' => '#', 'id' => 'toggles-all-opened', + 'role' => 'button')); + $o .= html_writer::tag('a', get_string('topcollclosed', 'format_topcoll'), + array('class' => 'off ' . $this->tctoggleiconsize, 'href' => '#', 'id' => 'toggles-all-closed', + 'role' => 'button')); + $o .= html_writer::end_tag('h4'); + $o .= html_writer::end_tag('div'); + $o .= html_writer::end_tag('div'); + $o .= html_writer::end_tag('li'); + + return $o; + } + + /** + * Displays the instructions functionality. + * @return string HTML to output. + */ + protected function display_instructions() { + $o = html_writer::start_tag('li', + array('class' => 'tcsection main clearfix', 'id' => 'topcoll-display-instructions')); + + if ((($this->mobiletheme === false) && ($this->tablettheme === false)) || ($this->userisediting)) { + $o .= html_writer::tag('div', $this->output->spacer(), array('class' => 'left side')); + $o .= html_writer::tag('div', $this->output->spacer(), array('class' => 'right side')); + } + + $o .= html_writer::start_tag('div', array('class' => 'content')); + $o .= html_writer::start_tag('div', array('class' => 'sectionbody')); + $o .= html_writer::tag('p', get_string('instructions', 'format_topcoll'), + array('class' => 'topcoll-display-instructions')); + $o .= html_writer::end_tag('div'); + $o .= html_writer::end_tag('div'); + $o .= html_writer::end_tag('li'); + + return $o; + } + + public function set_portable($portable) { + switch ($portable) { + case 1: + $this->mobiletheme = true; + break; + case 2: + $this->tablettheme = true; + break; + default: + $this->mobiletheme = false; + $this->tablettheme = false; + break; + } + } + + public function set_user_preference($preference) { + $this->userpreference = $preference; + } + + public function set_default_user_preference($defaultpreference) { + $this->defaultuserpreference = $defaultpreference; + } + + protected function get_row_class() { + return 'row-fluid'; + } + + protected function get_column_class($columns) { + $colclasses = array(1 => 'span12', 2 => 'span6', 3 => 'span4', 4 => 'span3'); + + return $colclasses[$columns]; + } + + public function get_format_responsive() { + return $this->formatresponsive; + } + +} diff --git a/settings.php b/settings.php index ce89fc03..7f9e2d9e 100644 --- a/settings.php +++ b/settings.php @@ -1,513 +1,384 @@ -. - -/** - * Collapsed Topics Information - * - * A topic based format that solves the issue of the 'Scroll of Death' when a course has many topics. All topics - * except zero have a toggle that displays that topic. One or more topics can be displayed at any given time. - * Toggles are persistent on a per browser session per course basis but can be made to persist longer by a small - * code change. Full installation instructions, code adaptions and credits are included in the 'Readme.txt' file. - * - * @package course/format - * @subpackage topcoll - * @version See the value of '$plugin->version' in below. - * @copyright © 2012-onwards G J Barnard in respect to modifications of standard topics format. - * @author G J Barnard - gjbarnard at gmail dot com and {@link http://moodle.org/user/profile.php?id=442195} - * @link http://docs.moodle.org/en/Collapsed_Topics_course_format - * @license http://www.gnu.org/copyleft/gpl.html GNU Public License - * - */ -defined('MOODLE_INTERNAL') || die; - -if ($ADMIN->fulltree) { - $settings->add(new admin_setting_heading('format_topcoll_defaults', - get_string('defaultheadingsub', 'format_topcoll'), - format_text(get_string('defaultheadingsubdesc', 'format_topcoll'), FORMAT_MARKDOWN))); - - /* Default course display. - * Course display default, can be either one of: - * COURSE_DISPLAY_SINGLEPAGE or - All sections on one page. - * COURSE_DISPLAY_MULTIPAGE - One section per page. - * as defined in moodlelib.php. - */ - $name = 'format_topcoll/defaultcoursedisplay'; - $title = get_string('defaultcoursedisplay', 'format_topcoll'); - $description = get_string('defaultcoursedisplay_desc', 'format_topcoll'); - $default = COURSE_DISPLAY_SINGLEPAGE; - $choices = array( - COURSE_DISPLAY_SINGLEPAGE => new lang_string('coursedisplay_single'), - COURSE_DISPLAY_MULTIPAGE => new lang_string('coursedisplay_multi') - ); - $settings->add(new admin_setting_configselect($name, $title, $description, $default, $choices)); - - /* Toggle instructions - 1 = no, 2 = yes. */ - $name = 'format_topcoll/defaultdisplayinstructions'; - $title = get_string('defaultdisplayinstructions', 'format_topcoll'); - $description = get_string('defaultdisplayinstructions_desc', 'format_topcoll'); - $default = 2; - $choices = array( - 1 => new lang_string('no'), // No. - 2 => new lang_string('yes') // Yes. - ); - $settings->add(new admin_setting_configselect($name, $title, $description, $default, $choices)); - - /* Layout configuration. - Here you can see what numbers in the array represent what layout for setting the default value below. - 1 => Toggle word, toggle section x and section number - default. - 2 => Toggle word and section number. - 3 => Toggle word and toggle section x. - 4 => Toggle word. - 5 => Toggle section x and section number. - 6 => Section number. - 7 => No additions. - 8 => Toggle section x. - Default layout to use - used when a new Collapsed Topics course is created or an old one is accessed for the first time - after installing this functionality introduced in CONTRIB-3378. */ - $name = 'format_topcoll/defaultlayoutelement'; - $title = get_string('defaultlayoutelement', 'format_topcoll'); - $description = get_string('defaultlayoutelement_descpositive', 'format_topcoll'); - $default = 1; - $choices = array(// In insertion order and not numeric for sorting purposes. - 1 => new lang_string('setlayout_all', 'format_topcoll'), // Toggle word, toggle section x and section number - default. - 3 => new lang_string('setlayout_toggle_word_section_x', 'format_topcoll'), // Toggle word and toggle section x. - 2 => new lang_string('setlayout_toggle_word_section_number', 'format_topcoll'), // Toggle word and section number. - 5 => new lang_string('setlayout_toggle_section_x_section_number', 'format_topcoll'), // Toggle section x and section number. - 4 => new lang_string('setlayout_toggle_word', 'format_topcoll'), // Toggle word. - 8 => new lang_string('setlayout_toggle_section_x', 'format_topcoll'), // Toggle section x. - 6 => new lang_string('setlayout_section_number', 'format_topcoll'), // Section number. - 7 => new lang_string('setlayout_no_additions', 'format_topcoll') // No additions. - ); - $settings->add(new admin_setting_configselect($name, $title, $description, $default, $choices)); - - /* Structure configuration. - Here so you can see what numbers in the array represent what structure for setting the default value below. - 1 => Topic. - 2 => Week. - 3 => Latest Week First. - 4 => Current Topic First. - 5 => Day. - Default structure to use - used when a new Collapsed Topics course is created or an old one is accessed for the first time - after installing this functionality introduced in CONTRIB-3378. */ - $name = 'format_topcoll/defaultlayoutstructure'; - $title = get_string('defaultlayoutstructure', 'format_topcoll'); - $description = get_string('defaultlayoutstructure_desc', 'format_topcoll'); - $default = 1; - $choices = array( - 1 => new lang_string('setlayoutstructuretopic', 'format_topcoll'), // Topic. - 2 => new lang_string('setlayoutstructureweek', 'format_topcoll'), // Week. - 3 => new lang_string('setlayoutstructurelatweekfirst', 'format_topcoll'), // Latest Week First. - 4 => new lang_string('setlayoutstructurecurrenttopicfirst', 'format_topcoll'), // Current Topic First. - 5 => new lang_string('setlayoutstructureday', 'format_topcoll') // Day. - ); - $settings->add(new admin_setting_configselect($name, $title, $description, $default, $choices)); - - // Default number of columns between 1 and 4. - $name = 'format_topcoll/defaultlayoutcolumns'; - $title = get_string('defaultlayoutcolumns', 'format_topcoll'); - $description = get_string('defaultlayoutcolumns_desc', 'format_topcoll'); - $default = 1; - $choices = array( - 1 => new lang_string('one', 'format_topcoll'), // Default. - 2 => new lang_string('two', 'format_topcoll'), // Two. - 3 => new lang_string('three', 'format_topcoll'), // Three. - 4 => new lang_string('four', 'format_topcoll') // Four. - ); - $settings->add(new admin_setting_configselect($name, $title, $description, $default, $choices)); - - // Default column orientation - 1 = vertical and 2 = horizontal. - $name = 'format_topcoll/defaultlayoutcolumnorientation'; - $title = get_string('defaultlayoutcolumnorientation', 'format_topcoll'); - $description = get_string('defaultlayoutcolumnorientation_desc', 'format_topcoll'); - $default = 2; - $choices = array( - 1 => new lang_string('columnvertical', 'format_topcoll'), - 2 => new lang_string('columnhorizontal', 'format_topcoll') // Default. - ); - $settings->add(new admin_setting_configselect($name, $title, $description, $default, $choices)); - - // Default toggle foreground colour in hexadecimal RGB with preceding '#'. - $name = 'format_topcoll/defaulttgfgcolour'; - $title = get_string('defaulttgfgcolour', 'format_topcoll'); - $description = get_string('defaulttgfgcolour_desc', 'format_topcoll'); - $default = '#000000'; - $setting = new admin_setting_configcolourpicker($name, $title, $description, $default); - $settings->add($setting); - - // Default toggle foreground hover colour in hexadecimal RGB with preceding '#'. - $name = 'format_topcoll/defaulttgfghvrcolour'; - $title = get_string('defaulttgfghvrcolour', 'format_topcoll'); - $description = get_string('defaulttgfghvrcolour_desc', 'format_topcoll'); - $default = '#888888'; - $setting = new admin_setting_configcolourpicker($name, $title, $description, $default); - $settings->add($setting); - - // Default toggle background colour in hexadecimal RGB with preceding '#'. - $name = 'format_topcoll/defaulttgbgcolour'; - $title = get_string('defaulttgbgcolour', 'format_topcoll'); - $description = get_string('defaulttgbgcolour_desc', 'format_topcoll'); - $default = '#e2e2f2'; - $setting = new admin_setting_configcolourpicker($name, $title, $description, $default); - $settings->add($setting); - - // Default toggle background hover colour in hexadecimal RGB with preceding '#'. - $name = 'format_topcoll/defaulttgbghvrcolour'; - $title = get_string('defaulttgbghvrcolour', 'format_topcoll'); - $description = get_string('defaulttgbghvrcolour_desc', 'format_topcoll'); - $default = '#eeeeff'; - $setting = new admin_setting_configcolourpicker($name, $title, $description, $default); - $settings->add($setting); - - // Toggle text alignment. - // 1 = left, 2 = center and 3 = right - done this way to avoid typos. - $name = 'format_topcoll/defaulttogglealignment'; - $title = get_string('defaulttogglealignment', 'format_topcoll'); - $description = get_string('defaulttogglealignment_desc', 'format_topcoll'); - $default = 2; - $choices = array( - 1 => new lang_string('left', 'format_topcoll'), // Left. - 2 => new lang_string('center', 'format_topcoll'), // Centre. - 3 => new lang_string('right', 'format_topcoll') // Right. - ); - $settings->add(new admin_setting_configselect($name, $title, $description, $default, $choices)); - - // Toggle icon position. - // 1 = left and 2 = right - done this way to avoid typos. - $name = 'format_topcoll/defaulttoggleiconposition'; - $title = get_string('defaulttoggleiconposition', 'format_topcoll'); - $description = get_string('defaulttoggleiconposition_desc', 'format_topcoll'); - $default = 1; - $choices = array( - 1 => new lang_string('left', 'format_topcoll'), // Left. - 2 => new lang_string('right', 'format_topcoll') // Right. - ); - $settings->add(new admin_setting_configselect($name, $title, $description, $default, $choices)); - - // Toggle icon set. - // arrow => Arrow icon set. - // bulb => Bulb icon set. - // cloud => Cloud icon set. - // eye => Eye icon set. - // groundsignal => Ground signal set. - // led => LED icon set. - // point => Point icon set. - // power => Power icon set. - // radio => Radio icon set. - // smiley => Smiley icon set. - // square => Square icon set. - // sunmoon => Sun / Moon icon set. - // switch => Switch icon set. - $name = 'format_topcoll/defaulttoggleiconset'; - $title = get_string('defaulttoggleiconset', 'format_topcoll'); - $description = get_string('defaulttoggleiconset_desc', 'format_topcoll'); - $default = 'arrow'; - $choices = array( - 'arrow' => new lang_string('arrow', 'format_topcoll'), // Arrow icon set. - 'bulb' => new lang_string('bulb', 'format_topcoll'), // Bulb icon set. - 'cloud' => new lang_string('cloud', 'format_topcoll'), // Cloud icon set. - 'eye' => new lang_string('eye', 'format_topcoll'), // Eye icon set. - 'groundsignal' => new lang_string('groundsignal', 'format_topcoll'), // Ground signal set. - 'led' => new lang_string('led', 'format_topcoll'), // LED icon set. - 'point' => new lang_string('point', 'format_topcoll'), // Point icon set. - 'power' => new lang_string('power', 'format_topcoll'), // Power icon set. - 'radio' => new lang_string('radio', 'format_topcoll'), // Radio icon set. - 'smiley' => new lang_string('smiley', 'format_topcoll'), // Smiley icon set. - 'square' => new lang_string('square', 'format_topcoll'), // Square icon set. - 'sunmoon' => new lang_string('sunmoon', 'format_topcoll'), // Sun / Moon icon set. - 'switch' => new lang_string('switch', 'format_topcoll') // Switch icon set. - ); - $settings->add(new admin_setting_configselect($name, $title, $description, $default, $choices)); - - // Toggle all icon hovers. - // 1 => No. - // 2 => Yes. - $name = 'format_topcoll/defaulttoggleallhover'; - $title = get_string('defaulttoggleallhover', 'format_topcoll'); - $description = get_string('defaulttoggleallhover_desc', 'format_topcoll'); - $default = 2; - $choices = array( - 1 => new lang_string('no'), - 2 => new lang_string('yes') - ); - $settings->add(new admin_setting_configselect($name, $title, $description, $default, $choices)); - - // Show the section summary when collapsed. - // 1 => No. - // 2 => Yes. - $name = 'format_topcoll/defaultshowsectionsummary'; - $title = get_string('defaultshowsectionsummary', 'format_topcoll'); - $description = get_string('defaultshowsectionsummary_desc', 'format_topcoll'); - $default = 1; - $choices = array( - 1 => new lang_string('no'), - 2 => new lang_string('yes') - ); - $settings->add(new admin_setting_configselect($name, $title, $description, $default, $choices)); - - $settings->add(new admin_setting_heading('format_topcoll_configuration', - get_string('configurationheadingsub', 'format_topcoll'), - format_text(get_string('configurationheadingsubdesc', 'format_topcoll'), FORMAT_MARKDOWN))); - - /* Toggle persistence - 1 = on, 0 = off. You may wish to disable for an AJAX performance increase. - Note: If turning persistence off remove any rows containing 'topcoll_toggle_x' in the 'name' field - of the 'user_preferences' table in the database. Where the 'x' in 'topcoll_toggle_x' will be - a course id. */ - $name = 'format_topcoll/defaulttogglepersistence'; - $title = get_string('defaulttogglepersistence', 'format_topcoll'); - $description = get_string('defaulttogglepersistence_desc', 'format_topcoll'); - $default = 1; - $choices = array( - 0 => new lang_string('off', 'format_topcoll'), // Off. - 1 => new lang_string('on', 'format_topcoll') // On. - ); - $settings->add(new admin_setting_configselect($name, $title, $description, $default, $choices)); - - // Toggle preference for the first time a user accesses a course. - // 0 => All closed. - // 1 => All open. - $name = 'format_topcoll/defaultuserpreference'; - $title = get_string('defaultuserpreference', 'format_topcoll'); - $description = get_string('defaultuserpreference_desc', 'format_topcoll'); - $default = 0; - $choices = array( - 0 => new lang_string('topcollclosed', 'format_topcoll'), - 1 => new lang_string('topcollopened', 'format_topcoll') - ); - $settings->add(new admin_setting_configselect($name, $title, $description, $default, $choices)); - - // Toggle icon size. - $name = 'format_topcoll/defaulttoggleiconsize'; - $title = get_string('defaulttoggleiconsize', 'format_topcoll'); - $description = get_string('defaulttoggleiconsize_desc', 'format_topcoll'); - $default = 'tc-medium'; - $choices = array( - 'tc-small' => new lang_string('small', 'format_topcoll'), - 'tc-medium' => new lang_string('medium', 'format_topcoll'), - 'tc-large' => new lang_string('large', 'format_topcoll') - ); - $settings->add(new admin_setting_configselect($name, $title, $description, $default, $choices)); - - // Toggle border radius top left. - $name = 'format_topcoll/defaulttoggleborderradiustl'; - $title = get_string('defaulttoggleborderradiustl', 'format_topcoll'); - $description = get_string('defaulttoggleborderradiustl_desc', 'format_topcoll'); - $default = '0.7'; - $choices = array( - '0.0' => new lang_string('em0_0', 'format_topcoll'), - '0.1' => new lang_string('em0_1', 'format_topcoll'), - '0.2' => new lang_string('em0_2', 'format_topcoll'), - '0.3' => new lang_string('em0_3', 'format_topcoll'), - '0.4' => new lang_string('em0_4', 'format_topcoll'), - '0.5' => new lang_string('em0_5', 'format_topcoll'), - '0.6' => new lang_string('em0_6', 'format_topcoll'), - '0.7' => new lang_string('em0_7', 'format_topcoll'), - '0.8' => new lang_string('em0_8', 'format_topcoll'), - '0.9' => new lang_string('em0_9', 'format_topcoll'), - '1.0' => new lang_string('em1_0', 'format_topcoll'), - '1.1' => new lang_string('em1_1', 'format_topcoll'), - '1.2' => new lang_string('em1_2', 'format_topcoll'), - '1.3' => new lang_string('em1_3', 'format_topcoll'), - '1.4' => new lang_string('em1_4', 'format_topcoll'), - '1.5' => new lang_string('em1_5', 'format_topcoll'), - '1.6' => new lang_string('em1_6', 'format_topcoll'), - '1.7' => new lang_string('em1_7', 'format_topcoll'), - '1.8' => new lang_string('em1_8', 'format_topcoll'), - '1.9' => new lang_string('em1_9', 'format_topcoll'), - '2.0' => new lang_string('em2_0', 'format_topcoll'), - '2.1' => new lang_string('em2_1', 'format_topcoll'), - '2.2' => new lang_string('em2_2', 'format_topcoll'), - '2.3' => new lang_string('em2_3', 'format_topcoll'), - '2.4' => new lang_string('em2_4', 'format_topcoll'), - '2.5' => new lang_string('em2_5', 'format_topcoll'), - '2.6' => new lang_string('em2_6', 'format_topcoll'), - '2.7' => new lang_string('em2_7', 'format_topcoll'), - '2.8' => new lang_string('em2_8', 'format_topcoll'), - '2.9' => new lang_string('em2_9', 'format_topcoll'), - '3.0' => new lang_string('em3_0', 'format_topcoll'), - '3.1' => new lang_string('em3_1', 'format_topcoll'), - '3.2' => new lang_string('em3_2', 'format_topcoll'), - '3.3' => new lang_string('em3_3', 'format_topcoll'), - '3.4' => new lang_string('em3_4', 'format_topcoll'), - '3.5' => new lang_string('em3_5', 'format_topcoll'), - '3.6' => new lang_string('em3_6', 'format_topcoll'), - '3.7' => new lang_string('em3_7', 'format_topcoll'), - '3.8' => new lang_string('em3_8', 'format_topcoll'), - '3.9' => new lang_string('em3_9', 'format_topcoll'), - '4.0' => new lang_string('em4_0', 'format_topcoll') - ); - $settings->add(new admin_setting_configselect($name, $title, $description, $default, $choices)); - - // Toggle border radius top right. - $name = 'format_topcoll/defaulttoggleborderradiustr'; - $title = get_string('defaulttoggleborderradiustr', 'format_topcoll'); - $description = get_string('defaulttoggleborderradiustr_desc', 'format_topcoll'); - $default = '0.7'; - $choices = array( - '0.0' => new lang_string('em0_0', 'format_topcoll'), - '0.1' => new lang_string('em0_1', 'format_topcoll'), - '0.2' => new lang_string('em0_2', 'format_topcoll'), - '0.3' => new lang_string('em0_3', 'format_topcoll'), - '0.4' => new lang_string('em0_4', 'format_topcoll'), - '0.5' => new lang_string('em0_5', 'format_topcoll'), - '0.6' => new lang_string('em0_6', 'format_topcoll'), - '0.7' => new lang_string('em0_7', 'format_topcoll'), - '0.8' => new lang_string('em0_8', 'format_topcoll'), - '0.9' => new lang_string('em0_9', 'format_topcoll'), - '1.0' => new lang_string('em1_0', 'format_topcoll'), - '1.1' => new lang_string('em1_1', 'format_topcoll'), - '1.2' => new lang_string('em1_2', 'format_topcoll'), - '1.3' => new lang_string('em1_3', 'format_topcoll'), - '1.4' => new lang_string('em1_4', 'format_topcoll'), - '1.5' => new lang_string('em1_5', 'format_topcoll'), - '1.6' => new lang_string('em1_6', 'format_topcoll'), - '1.7' => new lang_string('em1_7', 'format_topcoll'), - '1.8' => new lang_string('em1_8', 'format_topcoll'), - '1.9' => new lang_string('em1_9', 'format_topcoll'), - '2.0' => new lang_string('em2_0', 'format_topcoll'), - '2.1' => new lang_string('em2_1', 'format_topcoll'), - '2.2' => new lang_string('em2_2', 'format_topcoll'), - '2.3' => new lang_string('em2_3', 'format_topcoll'), - '2.4' => new lang_string('em2_4', 'format_topcoll'), - '2.5' => new lang_string('em2_5', 'format_topcoll'), - '2.6' => new lang_string('em2_6', 'format_topcoll'), - '2.7' => new lang_string('em2_7', 'format_topcoll'), - '2.8' => new lang_string('em2_8', 'format_topcoll'), - '2.9' => new lang_string('em2_9', 'format_topcoll'), - '3.0' => new lang_string('em3_0', 'format_topcoll'), - '3.1' => new lang_string('em3_1', 'format_topcoll'), - '3.2' => new lang_string('em3_2', 'format_topcoll'), - '3.3' => new lang_string('em3_3', 'format_topcoll'), - '3.4' => new lang_string('em3_4', 'format_topcoll'), - '3.5' => new lang_string('em3_5', 'format_topcoll'), - '3.6' => new lang_string('em3_6', 'format_topcoll'), - '3.7' => new lang_string('em3_7', 'format_topcoll'), - '3.8' => new lang_string('em3_8', 'format_topcoll'), - '3.9' => new lang_string('em3_9', 'format_topcoll'), - '4.0' => new lang_string('em4_0', 'format_topcoll') - ); - $settings->add(new admin_setting_configselect($name, $title, $description, $default, $choices)); - - // Toggle border radius bottom right. - $name = 'format_topcoll/defaulttoggleborderradiusbr'; - $title = get_string('defaulttoggleborderradiusbr', 'format_topcoll'); - $description = get_string('defaulttoggleborderradiusbr_desc', 'format_topcoll'); - $default = '0.7'; - $choices = array( - '0.0' => new lang_string('em0_0', 'format_topcoll'), - '0.1' => new lang_string('em0_1', 'format_topcoll'), - '0.2' => new lang_string('em0_2', 'format_topcoll'), - '0.3' => new lang_string('em0_3', 'format_topcoll'), - '0.4' => new lang_string('em0_4', 'format_topcoll'), - '0.5' => new lang_string('em0_5', 'format_topcoll'), - '0.6' => new lang_string('em0_6', 'format_topcoll'), - '0.7' => new lang_string('em0_7', 'format_topcoll'), - '0.8' => new lang_string('em0_8', 'format_topcoll'), - '0.9' => new lang_string('em0_9', 'format_topcoll'), - '1.0' => new lang_string('em1_0', 'format_topcoll'), - '1.1' => new lang_string('em1_1', 'format_topcoll'), - '1.2' => new lang_string('em1_2', 'format_topcoll'), - '1.3' => new lang_string('em1_3', 'format_topcoll'), - '1.4' => new lang_string('em1_4', 'format_topcoll'), - '1.5' => new lang_string('em1_5', 'format_topcoll'), - '1.6' => new lang_string('em1_6', 'format_topcoll'), - '1.7' => new lang_string('em1_7', 'format_topcoll'), - '1.8' => new lang_string('em1_8', 'format_topcoll'), - '1.9' => new lang_string('em1_9', 'format_topcoll'), - '2.0' => new lang_string('em2_0', 'format_topcoll'), - '2.1' => new lang_string('em2_1', 'format_topcoll'), - '2.2' => new lang_string('em2_2', 'format_topcoll'), - '2.3' => new lang_string('em2_3', 'format_topcoll'), - '2.4' => new lang_string('em2_4', 'format_topcoll'), - '2.5' => new lang_string('em2_5', 'format_topcoll'), - '2.6' => new lang_string('em2_6', 'format_topcoll'), - '2.7' => new lang_string('em2_7', 'format_topcoll'), - '2.8' => new lang_string('em2_8', 'format_topcoll'), - '2.9' => new lang_string('em2_9', 'format_topcoll'), - '3.0' => new lang_string('em3_0', 'format_topcoll'), - '3.1' => new lang_string('em3_1', 'format_topcoll'), - '3.2' => new lang_string('em3_2', 'format_topcoll'), - '3.3' => new lang_string('em3_3', 'format_topcoll'), - '3.4' => new lang_string('em3_4', 'format_topcoll'), - '3.5' => new lang_string('em3_5', 'format_topcoll'), - '3.6' => new lang_string('em3_6', 'format_topcoll'), - '3.7' => new lang_string('em3_7', 'format_topcoll'), - '3.8' => new lang_string('em3_8', 'format_topcoll'), - '3.9' => new lang_string('em3_9', 'format_topcoll'), - '4.0' => new lang_string('em4_0', 'format_topcoll') - ); - $settings->add(new admin_setting_configselect($name, $title, $description, $default, $choices)); - - // Toggle border radius bottom left. - $name = 'format_topcoll/defaulttoggleborderradiusbl'; - $title = get_string('defaulttoggleborderradiusbl', 'format_topcoll'); - $description = get_string('defaulttoggleborderradiusbl_desc', 'format_topcoll'); - $default = '0.7'; - $choices = array( - '0.0' => new lang_string('em0_0', 'format_topcoll'), - '0.1' => new lang_string('em0_1', 'format_topcoll'), - '0.2' => new lang_string('em0_2', 'format_topcoll'), - '0.3' => new lang_string('em0_3', 'format_topcoll'), - '0.4' => new lang_string('em0_4', 'format_topcoll'), - '0.5' => new lang_string('em0_5', 'format_topcoll'), - '0.6' => new lang_string('em0_6', 'format_topcoll'), - '0.7' => new lang_string('em0_7', 'format_topcoll'), - '0.8' => new lang_string('em0_8', 'format_topcoll'), - '0.9' => new lang_string('em0_9', 'format_topcoll'), - '1.0' => new lang_string('em1_0', 'format_topcoll'), - '1.1' => new lang_string('em1_1', 'format_topcoll'), - '1.2' => new lang_string('em1_2', 'format_topcoll'), - '1.3' => new lang_string('em1_3', 'format_topcoll'), - '1.4' => new lang_string('em1_4', 'format_topcoll'), - '1.5' => new lang_string('em1_5', 'format_topcoll'), - '1.6' => new lang_string('em1_6', 'format_topcoll'), - '1.7' => new lang_string('em1_7', 'format_topcoll'), - '1.8' => new lang_string('em1_8', 'format_topcoll'), - '1.9' => new lang_string('em1_9', 'format_topcoll'), - '2.0' => new lang_string('em2_0', 'format_topcoll'), - '2.1' => new lang_string('em2_1', 'format_topcoll'), - '2.2' => new lang_string('em2_2', 'format_topcoll'), - '2.3' => new lang_string('em2_3', 'format_topcoll'), - '2.4' => new lang_string('em2_4', 'format_topcoll'), - '2.5' => new lang_string('em2_5', 'format_topcoll'), - '2.6' => new lang_string('em2_6', 'format_topcoll'), - '2.7' => new lang_string('em2_7', 'format_topcoll'), - '2.8' => new lang_string('em2_8', 'format_topcoll'), - '2.9' => new lang_string('em2_9', 'format_topcoll'), - '3.0' => new lang_string('em3_0', 'format_topcoll'), - '3.1' => new lang_string('em3_1', 'format_topcoll'), - '3.2' => new lang_string('em3_2', 'format_topcoll'), - '3.3' => new lang_string('em3_3', 'format_topcoll'), - '3.4' => new lang_string('em3_4', 'format_topcoll'), - '3.5' => new lang_string('em3_5', 'format_topcoll'), - '3.6' => new lang_string('em3_6', 'format_topcoll'), - '3.7' => new lang_string('em3_7', 'format_topcoll'), - '3.8' => new lang_string('em3_8', 'format_topcoll'), - '3.9' => new lang_string('em3_9', 'format_topcoll'), - '4.0' => new lang_string('em4_0', 'format_topcoll') - ); - $settings->add(new admin_setting_configselect($name, $title, $description, $default, $choices)); - - /* Format responsive. Turn on to support a non responsive theme theme. */ - $name = 'format_topcoll/formatresponsive'; - $title = get_string('formatresponsive', 'format_topcoll'); - $description = get_string('formatresponsive_desc', 'format_topcoll'); - $default = 0; - $choices = array( - 0 => new lang_string('off', 'format_topcoll'), // Off. - 1 => new lang_string('on', 'format_topcoll') // On. - ); - $settings->add(new admin_setting_configselect($name, $title, $description, $default, $choices)); -} +. + +/** + * Collapsed Topics Information + * + * A topic based format that solves the issue of the 'Scroll of Death' when a course has many topics. All topics + * except zero have a toggle that displays that topic. One or more topics can be displayed at any given time. + * Toggles are persistent on a per browser session per course basis but can be made to persist longer by a small + * code change. Full installation instructions, code adaptions and credits are included in the 'Readme.txt' file. + * + * @package course/format + * @subpackage topcoll + * @version See the value of '$plugin->version' in below. + * @copyright © 2012-onwards G J Barnard in respect to modifications of standard topics format. + * @author G J Barnard - gjbarnard at gmail dot com and {@link http://moodle.org/user/profile.php?id=442195} + * @link http://docs.moodle.org/en/Collapsed_Topics_course_format + * @license http://www.gnu.org/copyleft/gpl.html GNU Public License + * + */ +defined('MOODLE_INTERNAL') || die; + +if ($ADMIN->fulltree) { + $settings->add(new admin_setting_heading('format_topcoll_defaults', + get_string('defaultheadingsub', 'format_topcoll'), + format_text(get_string('defaultheadingsubdesc', 'format_topcoll'), FORMAT_MARKDOWN))); + + /* Default course display. + * Course display default, can be either one of: + * COURSE_DISPLAY_SINGLEPAGE or - All sections on one page. + * COURSE_DISPLAY_MULTIPAGE - One section per page. + * as defined in moodlelib.php. + */ + $name = 'format_topcoll/defaultcoursedisplay'; + $title = get_string('defaultcoursedisplay', 'format_topcoll'); + $description = get_string('defaultcoursedisplay_desc', 'format_topcoll'); + $default = COURSE_DISPLAY_SINGLEPAGE; + $choices = array( + COURSE_DISPLAY_SINGLEPAGE => new lang_string('coursedisplay_single'), + COURSE_DISPLAY_MULTIPAGE => new lang_string('coursedisplay_multi') + ); + $settings->add(new admin_setting_configselect($name, $title, $description, $default, $choices)); + + /* Toggle instructions - 1 = no, 2 = yes. */ + $name = 'format_topcoll/defaultdisplayinstructions'; + $title = get_string('defaultdisplayinstructions', 'format_topcoll'); + $description = get_string('defaultdisplayinstructions_desc', 'format_topcoll'); + $default = 2; + $choices = array( + 1 => new lang_string('no'), // No. + 2 => new lang_string('yes') // Yes. + ); + $settings->add(new admin_setting_configselect($name, $title, $description, $default, $choices)); + + /* Layout configuration. + Here you can see what numbers in the array represent what layout for setting the default value below. + 1 => Toggle word, toggle section x and section number - default. + 2 => Toggle word and section number. + 3 => Toggle word and toggle section x. + 4 => Toggle word. + 5 => Toggle section x and section number. + 6 => Section number. + 7 => No additions. + 8 => Toggle section x. + Default layout to use - used when a new Collapsed Topics course is created or an old one is accessed for the first time + after installing this functionality introduced in CONTRIB-3378. */ + $name = 'format_topcoll/defaultlayoutelement'; + $title = get_string('defaultlayoutelement', 'format_topcoll'); + $description = get_string('defaultlayoutelement_descpositive', 'format_topcoll'); + $default = 1; + $choices = array(// In insertion order and not numeric for sorting purposes. + 1 => new lang_string('setlayout_all', 'format_topcoll'), // Toggle word, toggle section x and section number - default. + 3 => new lang_string('setlayout_toggle_word_section_x', 'format_topcoll'), // Toggle word and toggle section x. + 2 => new lang_string('setlayout_toggle_word_section_number', 'format_topcoll'), // Toggle word and section number. + 5 => new lang_string('setlayout_toggle_section_x_section_number', 'format_topcoll'), // Toggle section x and section number. + 4 => new lang_string('setlayout_toggle_word', 'format_topcoll'), // Toggle word. + 8 => new lang_string('setlayout_toggle_section_x', 'format_topcoll'), // Toggle section x. + 6 => new lang_string('setlayout_section_number', 'format_topcoll'), // Section number. + 7 => new lang_string('setlayout_no_additions', 'format_topcoll') // No additions. + ); + $settings->add(new admin_setting_configselect($name, $title, $description, $default, $choices)); + + /* Structure configuration. + Here so you can see what numbers in the array represent what structure for setting the default value below. + 1 => Topic. + 2 => Week. + 3 => Latest Week First. + 4 => Current Topic First. + 5 => Day. + Default structure to use - used when a new Collapsed Topics course is created or an old one is accessed for the first time + after installing this functionality introduced in CONTRIB-3378. */ + $name = 'format_topcoll/defaultlayoutstructure'; + $title = get_string('defaultlayoutstructure', 'format_topcoll'); + $description = get_string('defaultlayoutstructure_desc', 'format_topcoll'); + $default = 1; + $choices = array( + 1 => new lang_string('setlayoutstructuretopic', 'format_topcoll'), // Topic. + 2 => new lang_string('setlayoutstructureweek', 'format_topcoll'), // Week. + 3 => new lang_string('setlayoutstructurelatweekfirst', 'format_topcoll'), // Latest Week First. + 4 => new lang_string('setlayoutstructurecurrenttopicfirst', 'format_topcoll'), // Current Topic First. + 5 => new lang_string('setlayoutstructureday', 'format_topcoll') // Day. + ); + $settings->add(new admin_setting_configselect($name, $title, $description, $default, $choices)); + + // Default number of columns between 1 and 4. + $name = 'format_topcoll/defaultlayoutcolumns'; + $title = get_string('defaultlayoutcolumns', 'format_topcoll'); + $description = get_string('defaultlayoutcolumns_desc', 'format_topcoll'); + $default = 1; + $choices = array( + 1 => new lang_string('one', 'format_topcoll'), // Default. + 2 => new lang_string('two', 'format_topcoll'), // Two. + 3 => new lang_string('three', 'format_topcoll'), // Three. + 4 => new lang_string('four', 'format_topcoll') // Four. + ); + $settings->add(new admin_setting_configselect($name, $title, $description, $default, $choices)); + + // Default column orientation - 1 = vertical and 2 = horizontal. + $name = 'format_topcoll/defaultlayoutcolumnorientation'; + $title = get_string('defaultlayoutcolumnorientation', 'format_topcoll'); + $description = get_string('defaultlayoutcolumnorientation_desc', 'format_topcoll'); + $default = 2; + $choices = array( + 1 => new lang_string('columnvertical', 'format_topcoll'), + 2 => new lang_string('columnhorizontal', 'format_topcoll') // Default. + ); + $settings->add(new admin_setting_configselect($name, $title, $description, $default, $choices)); + + // Default toggle foreground colour in hexadecimal RGB with preceding '#'. + $name = 'format_topcoll/defaulttgfgcolour'; + $title = get_string('defaulttgfgcolour', 'format_topcoll'); + $description = get_string('defaulttgfgcolour_desc', 'format_topcoll'); + $default = '#000000'; + $setting = new admin_setting_configcolourpicker($name, $title, $description, $default); + $settings->add($setting); + + // Default toggle foreground hover colour in hexadecimal RGB with preceding '#'. + $name = 'format_topcoll/defaulttgfghvrcolour'; + $title = get_string('defaulttgfghvrcolour', 'format_topcoll'); + $description = get_string('defaulttgfghvrcolour_desc', 'format_topcoll'); + $default = '#888888'; + $setting = new admin_setting_configcolourpicker($name, $title, $description, $default); + $settings->add($setting); + + // Default toggle background colour in hexadecimal RGB with preceding '#'. + $name = 'format_topcoll/defaulttgbgcolour'; + $title = get_string('defaulttgbgcolour', 'format_topcoll'); + $description = get_string('defaulttgbgcolour_desc', 'format_topcoll'); + $default = '#e2e2f2'; + $setting = new admin_setting_configcolourpicker($name, $title, $description, $default); + $settings->add($setting); + + // Default toggle background hover colour in hexadecimal RGB with preceding '#'. + $name = 'format_topcoll/defaulttgbghvrcolour'; + $title = get_string('defaulttgbghvrcolour', 'format_topcoll'); + $description = get_string('defaulttgbghvrcolour_desc', 'format_topcoll'); + $default = '#eeeeff'; + $setting = new admin_setting_configcolourpicker($name, $title, $description, $default); + $settings->add($setting); + + // Toggle text alignment. + // 1 = left, 2 = center and 3 = right - done this way to avoid typos. + $name = 'format_topcoll/defaulttogglealignment'; + $title = get_string('defaulttogglealignment', 'format_topcoll'); + $description = get_string('defaulttogglealignment_desc', 'format_topcoll'); + $default = 2; + $choices = array( + 1 => new lang_string('left', 'format_topcoll'), // Left. + 2 => new lang_string('center', 'format_topcoll'), // Centre. + 3 => new lang_string('right', 'format_topcoll') // Right. + ); + $settings->add(new admin_setting_configselect($name, $title, $description, $default, $choices)); + + // Toggle icon position. + // 1 = left and 2 = right - done this way to avoid typos. + $name = 'format_topcoll/defaulttoggleiconposition'; + $title = get_string('defaulttoggleiconposition', 'format_topcoll'); + $description = get_string('defaulttoggleiconposition_desc', 'format_topcoll'); + $default = 1; + $choices = array( + 1 => new lang_string('left', 'format_topcoll'), // Left. + 2 => new lang_string('right', 'format_topcoll') // Right. + ); + $settings->add(new admin_setting_configselect($name, $title, $description, $default, $choices)); + + // Toggle icon set. + // arrow => Arrow icon set. + // bulb => Bulb icon set. + // cloud => Cloud icon set. + // eye => Eye icon set. + // groundsignal => Ground signal set. + // led => LED icon set. + // point => Point icon set. + // power => Power icon set. + // radio => Radio icon set. + // smiley => Smiley icon set. + // square => Square icon set. + // sunmoon => Sun / Moon icon set. + // switch => Switch icon set. + $name = 'format_topcoll/defaulttoggleiconset'; + $title = get_string('defaulttoggleiconset', 'format_topcoll'); + $description = get_string('defaulttoggleiconset_desc', 'format_topcoll'); + $default = 'arrow'; + $choices = array( + 'arrow' => new lang_string('arrow', 'format_topcoll'), // Arrow icon set. + 'bulb' => new lang_string('bulb', 'format_topcoll'), // Bulb icon set. + 'cloud' => new lang_string('cloud', 'format_topcoll'), // Cloud icon set. + 'eye' => new lang_string('eye', 'format_topcoll'), // Eye icon set. + 'groundsignal' => new lang_string('groundsignal', 'format_topcoll'), // Ground signal set. + 'led' => new lang_string('led', 'format_topcoll'), // LED icon set. + 'point' => new lang_string('point', 'format_topcoll'), // Point icon set. + 'power' => new lang_string('power', 'format_topcoll'), // Power icon set. + 'radio' => new lang_string('radio', 'format_topcoll'), // Radio icon set. + 'smiley' => new lang_string('smiley', 'format_topcoll'), // Smiley icon set. + 'square' => new lang_string('square', 'format_topcoll'), // Square icon set. + 'sunmoon' => new lang_string('sunmoon', 'format_topcoll'), // Sun / Moon icon set. + 'switch' => new lang_string('switch', 'format_topcoll') // Switch icon set. + ); + $settings->add(new admin_setting_configselect($name, $title, $description, $default, $choices)); + + // Toggle all icon hovers. + // 1 => No. + // 2 => Yes. + $name = 'format_topcoll/defaulttoggleallhover'; + $title = get_string('defaulttoggleallhover', 'format_topcoll'); + $description = get_string('defaulttoggleallhover_desc', 'format_topcoll'); + $default = 2; + $choices = array( + 1 => new lang_string('no'), + 2 => new lang_string('yes') + ); + $settings->add(new admin_setting_configselect($name, $title, $description, $default, $choices)); + + // Show the section summary when collapsed. + // 1 => No. + // 2 => Yes. + $name = 'format_topcoll/defaultshowsectionsummary'; + $title = get_string('defaultshowsectionsummary', 'format_topcoll'); + $description = get_string('defaultshowsectionsummary_desc', 'format_topcoll'); + $default = 1; + $choices = array( + 1 => new lang_string('no'), + 2 => new lang_string('yes') + ); + $settings->add(new admin_setting_configselect($name, $title, $description, $default, $choices)); + + $settings->add(new admin_setting_heading('format_topcoll_configuration', + get_string('configurationheadingsub', 'format_topcoll'), + format_text(get_string('configurationheadingsubdesc', 'format_topcoll'), FORMAT_MARKDOWN))); + + /* Toggle persistence - 1 = on, 0 = off. You may wish to disable for an AJAX performance increase. + Note: If turning persistence off remove any rows containing 'topcoll_toggle_x' in the 'name' field + of the 'user_preferences' table in the database. Where the 'x' in 'topcoll_toggle_x' will be + a course id. */ + $name = 'format_topcoll/defaulttogglepersistence'; + $title = get_string('defaulttogglepersistence', 'format_topcoll'); + $description = get_string('defaulttogglepersistence_desc', 'format_topcoll'); + $default = 1; + $choices = array( + 0 => new lang_string('off', 'format_topcoll'), // Off. + 1 => new lang_string('on', 'format_topcoll') // On. + ); + $settings->add(new admin_setting_configselect($name, $title, $description, $default, $choices)); + + // Toggle preference for the first time a user accesses a course. + // 0 => All closed. + // 1 => All open. + $name = 'format_topcoll/defaultuserpreference'; + $title = get_string('defaultuserpreference', 'format_topcoll'); + $description = get_string('defaultuserpreference_desc', 'format_topcoll'); + $default = 0; + $choices = array( + 0 => new lang_string('topcollclosed', 'format_topcoll'), + 1 => new lang_string('topcollopened', 'format_topcoll') + ); + $settings->add(new admin_setting_configselect($name, $title, $description, $default, $choices)); + + // Toggle icon size. + $name = 'format_topcoll/defaulttoggleiconsize'; + $title = get_string('defaulttoggleiconsize', 'format_topcoll'); + $description = get_string('defaulttoggleiconsize_desc', 'format_topcoll'); + $default = 'tc-medium'; + $choices = array( + 'tc-small' => new lang_string('small', 'format_topcoll'), + 'tc-medium' => new lang_string('medium', 'format_topcoll'), + 'tc-large' => new lang_string('large', 'format_topcoll') + ); + $settings->add(new admin_setting_configselect($name, $title, $description, $default, $choices)); + + // Toggle border radius top left. + $name = 'format_topcoll/defaulttoggleborderradiustl'; + $title = get_string('defaulttoggleborderradiustl', 'format_topcoll'); + $description = get_string('defaulttoggleborderradiustl_desc', 'format_topcoll'); + $default = '0.7'; + $choices = array( + '0.0' => new lang_string('em0_0', 'format_topcoll'), + '0.1' => new lang_string('em0_1', 'format_topcoll'), + '0.2' => new lang_string('em0_2', 'format_topcoll'), + '0.3' => new lang_string('em0_3', 'format_topcoll'), + '0.4' => new lang_string('em0_4', 'format_topcoll'), + '0.5' => new lang_string('em0_5', 'format_topcoll'), + '0.6' => new lang_string('em0_6', 'format_topcoll'), + '0.7' => new lang_string('em0_7', 'format_topcoll'), + '0.8' => new lang_string('em0_8', 'format_topcoll'), + '0.9' => new lang_string('em0_9', 'format_topcoll'), + '1.0' => new lang_string('em1_0', 'format_topcoll'), + '1.1' => new lang_string('em1_1', 'format_topcoll'), + '1.2' => new lang_string('em1_2', 'format_topcoll'), + '1.3' => new lang_string('em1_3', 'format_topcoll'), + '1.4' => new lang_string('em1_4', 'format_topcoll'), + '1.5' => new lang_string('em1_5', 'format_topcoll'), + '1.6' => new lang_string('em1_6', 'format_topcoll'), + '1.7' => new lang_string('em1_7', 'format_topcoll'), + '1.8' => new lang_string('em1_8', 'format_topcoll'), + '1.9' => new lang_string('em1_9', 'format_topcoll'), + '2.0' => new lang_string('em2_0', 'format_topcoll'), + '2.1' => new lang_string('em2_1', 'format_topcoll'), + '2.2' => new lang_string('em2_2', 'format_topcoll'), + '2.3' => new lang_string('em2_3', 'format_topcoll'), + '2.4' => new lang_string('em2_4', 'format_topcoll'), + '2.5' => new lang_string('em2_5', 'format_topcoll'), + '2.6' => new lang_string('em2_6', 'format_topcoll'), + '2.7' => new lang_string('em2_7', 'format_topcoll'), + '2.8' => new lang_string('em2_8', 'format_topcoll'), + '2.9' => new lang_string('em2_9', 'format_topcoll'), + '3.0' => new lang_string('em3_0', 'format_topcoll'), + '3.1' => new lang_string('em3_1', 'format_topcoll'), + '3.2' => new lang_string('em3_2', 'format_topcoll'), + '3.3' => new lang_string('em3_3', 'format_topcoll'), + '3.4' => new lang_string('em3_4', 'format_topcoll'), + '3.5' => new lang_string('em3_5', 'format_topcoll'), + '3.6' => new lang_string('em3_6', 'format_topcoll'), + '3.7' => new lang_string('em3_7', 'format_topcoll'), + '3.8' => new lang_string('em3_8', 'format_topcoll'), + '3.9' => new lang_string('em3_9', 'format_topcoll'), + '4.0' => new lang_string('em4_0', 'format_topcoll') + ); + $settings->add(new admin_setting_configselect($name, $title, $description, $default, $choices)); + + // Toggle border radius top right. + $name = 'format_topcoll/defaulttoggleborderradiustr'; + $title = get_string('defaulttoggleborderradiustr', 'format_topcoll'); + $description = get_string('defaulttoggleborderradiustr_desc', 'format_topcoll'); + $default = '0.7'; + $settings->add(new admin_setting_configselect($name, $title, $description, $default, $choices)); + + // Toggle border radius bottom right. + $name = 'format_topcoll/defaulttoggleborderradiusbr'; + $title = get_string('defaulttoggleborderradiusbr', 'format_topcoll'); + $description = get_string('defaulttoggleborderradiusbr_desc', 'format_topcoll'); + $default = '0.7'; + $settings->add(new admin_setting_configselect($name, $title, $description, $default, $choices)); + + // Toggle border radius bottom left. + $name = 'format_topcoll/defaulttoggleborderradiusbl'; + $title = get_string('defaulttoggleborderradiusbl', 'format_topcoll'); + $description = get_string('defaulttoggleborderradiusbl_desc', 'format_topcoll'); + $default = '0.7'; + $settings->add(new admin_setting_configselect($name, $title, $description, $default, $choices)); + + /* Format responsive. Turn on to support a non responsive theme theme. */ + $name = 'format_topcoll/formatresponsive'; + $title = get_string('formatresponsive', 'format_topcoll'); + $description = get_string('formatresponsive_desc', 'format_topcoll'); + $default = 0; + $choices = array( + 0 => new lang_string('off', 'format_topcoll'), // Off. + 1 => new lang_string('on', 'format_topcoll') // On. + ); + $settings->add(new admin_setting_configselect($name, $title, $description, $default, $choices)); +} diff --git a/settopcollpref.php b/settopcollpref.php index 698cab36..a7258065 100644 --- a/settopcollpref.php +++ b/settopcollpref.php @@ -1,57 +1,57 @@ -. - -/** - * Code to update a user preference in response to an ajax call. - * - * You should not send requests to this script directly. Instead use the set_user_preference - * function in /course/format/topcol/module.js. - * - * @package course/format - * @subpackage topcoll - * @version See the value of '$plugin->version' in below. - * @copyright © 2014-onwards G J Barnard based upon code originally written by Tim Hunt. - * @author G J Barnard - gjbarnard at gmail dot com and {@link http://moodle.org/user/profile.php?id=442195} - * @link http://docs.moodle.org/en/Collapsed_Topics_course_format - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ - -require_once(dirname(__FILE__) . '/../../../config.php'); -require_once($CFG->dirroot . '/course/format/topcoll/togglelib.php'); - -// Check access. -if (!confirm_sesskey()) { - print_error('invalidsesskey'); -} - -// Get the name of the preference to update, and check that it is allowed. -$name = required_param('pref', PARAM_RAW); -if (!isset($USER->ajax_updatable_user_prefs[$name])) { - print_error('notallowedtoupdateprefremotely'); -} - -// Get and set the value. -$value = required_topcoll_param('value'); -// Update. -if ($value) { - if (!set_user_preference($name, $value)) { - print_error('errorsettinguserpref'); - } - echo 'OK'; -} else { - header('HTTP/1.1 406 Not Acceptable'); - echo 'Not Acceptable'; -} +. + +/** + * Code to update a user preference in response to an ajax call. + * + * You should not send requests to this script directly. Instead use the set_user_preference + * function in /course/format/topcol/module.js. + * + * @package course/format + * @subpackage topcoll + * @version See the value of '$plugin->version' in below. + * @copyright © 2014-onwards G J Barnard based upon code originally written by Tim Hunt. + * @author G J Barnard - gjbarnard at gmail dot com and {@link http://moodle.org/user/profile.php?id=442195} + * @link http://docs.moodle.org/en/Collapsed_Topics_course_format + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +require_once(dirname(__FILE__) . '/../../../config.php'); +require_once($CFG->dirroot . '/course/format/topcoll/togglelib.php'); + +// Check access. +if (!confirm_sesskey()) { + print_error('invalidsesskey'); +} + +// Get the name of the preference to update, and check that it is allowed. +$name = required_param('pref', PARAM_RAW); +if (!isset($USER->ajax_updatable_user_prefs[$name])) { + print_error('notallowedtoupdateprefremotely'); +} + +// Get and set the value. +$value = required_topcoll_param('value'); +// Update. +if ($value) { + if (!set_user_preference($name, $value)) { + print_error('errorsettinguserpref'); + } + echo 'OK'; +} else { + header('HTTP/1.1 406 Not Acceptable'); + echo 'Not Acceptable'; +} diff --git a/styles.css b/styles.css index 2ed8ef27..eeb33cbb 100644 --- a/styles.css +++ b/styles.css @@ -1,836 +1,671 @@ -/** - * Collapsed Topics Information - * - * A topic based format that solves the issue of the 'Scroll of Death' when a course has many topics. All topics - * except zero have a toggle that displays that topic. One or more topics can be displayed at any given time. - * Toggles are persistent on a per browser session per course basis but can be made to persist longer by a small - * code change. Full installation instructions, code adaptions and credits are included in the 'Readme.txt' file. - * - * @package course/format - * @subpackage topcoll - * @version See the value of '$plugin->version' in version.php. - * @copyright © 2009-onwards G J Barnard in respect to modifications of standard topics format. - * @author G J Barnard - gjbarnard at gmail dot com and {@link http://moodle.org/user/profile.php?id=442195} - * @link http://docs.moodle.org/en/Collapsed_Topics_course_format - * @license http://www.gnu.org/copyleft/gpl.html GNU Public License - * - * 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 . -*/ -.course-content ul.ctopics { - margin: 0px; - padding-left: 0px; - padding-right: 0px; -} - -.course-content ul.ctlayout { - display: inline-block; - vertical-align: top; -} - -.course-content ul.ctopics li.section.main .left, .course-content ul.ctopics li.section.main .right { - /* Fix for Bootstrap V3 based themes in less/moodle/course.less . */ - display: block; -} - -.course-content ul.ctopics li.section.main, .course-content ul.ctopics li.tcsection { - list-style: none; - margin: 4px 1px 1px 1px; - padding: 0px; -} - -/* Fix for ordered and unordered list in course topic summary & course weekly summary - from theme/base/style/core.css - * See: https://moodle.org/mod/forum/discuss.php?d=251944. - */ -.course-content ul.ctopics .content .summary ul, .course-content ul.ctopics .content .summarytext ul { - list-style: disc outside none; -} -.course-content ul.ctopics .content .summary ol, .course-content ul.ctopics .content .summarytext ol { - list-style: decimal outside none; -} - -.course-content ul.ctopics li.section.main .content, .course-content ul.ctopics li.tcsection .content { - /* Default for non tablets / mobiles. If the language file has 'topcollsidewidth' for the current language, then will be set in format.php. */ - margin: 0 40px; - padding: 0px; -} - -.course-content ul.ctopics.ctportable li.section.main .content, .course-content ul.ctopics.ctportable li.tcsection .content { - margin: 0 0px; /* Override default for tablets / mobiles. When have sides, set in format.php. */ -} - -.course-content ul.ctopics li .content .sectionhead h3 { - margin: 0em; -} - -.course-content ul.ctopics li.current .content .toggledsection { - padding: 0px 0px 5px 0px; -} - -.course-content ul.ctopics li.section.hidden .content > div { - margin-left: 0; - margin-right: 0; -} - -/* Toggle icon size */ -#toggle-all .content .sectionbody h4 a.tc-small, .course-content ul.ctopics li.section .content .toggle a.tc-small { - background-size: 16px 16px; -} - -#toggle-all .content .sectionbody h4 a.tc-medium, .course-content ul.ctopics li.section .content .toggle a.tc-medium { - background-size: 24px 24px; -} -#toggle-all .content .sectionbody h4 a.tc-large, .course-content ul.ctopics li.section .content .toggle a.tc-large { - background-size: 32px 32px; -} - -/* -- Set the clickable element of the Toggle -- */ -.course-content ul.ctopics li.section .content .toggle a { - display: block; - width: auto; - padding-top: 6px; - padding-bottom: 6px; -} - -.course-content ul.ctopics li.section .content .toggle a.tc-small { - padding-left: 16px; /* The 16px allows the arrow to be with the text next to it. */ - padding-right: 16px; -} - -.course-content ul.ctopics li.section .content .toggle a.tc-medium { - padding-left: 24px; /* The 24px allows the arrow to be with the text next to it. */ - padding-right: 24px; -} - -.course-content ul.ctopics li.section .content .toggle a.tc-large { - padding-left: 32px; /* The 32px allows the arrow to be with the text next to it. */ - padding-right: 32px; -} - -/* CONTRIB-4106 */ -.course-content ul.ctopics li.section .content .toggle a h3, -.course-content ul.ctopics li.section .content.sectionhidden h3 { - margin: 0px; - word-break: break-word; - overflow-wrap: break-word; - word-wrap: break-word; -} - -.course-content ul.ctopics li.section .content .toggle a h3.section-title, -.course-content ul.ctopics li.section .content.sectionhidden h3.section-title { - margin: 4px; - color: inherit; -} - -/* Icon set common. */ -.course-content ul.ctopics li.section .content .toggle a, #toggle-all .content h4 a { - background-repeat: no-repeat; - background-color: transparent; - margin: 0px 4px; -} - -/* Arrow icon set. */ -.course-content ul.ctopics li.section .content .toggle-arrow a.toggle_closed, .course-content ul.ctopics li.section .content .toggle-arrow a.toggle_open { /* JavaScript disabled */ - background-image: url([[pix:format_topcoll|arrow_down]]); -} - -body.jsenabled .course-content ul.ctopics li.section .content .toggle-arrow a.toggle_closed { /* JavaScript enabled */ - background-image: url([[pix:format_topcoll|arrow_right]]); -} - -body.jsenabled .course-content ul.ctopics li.section .content .toggle-arrow a.toggle_open { /* JavaScript enabled */ - background-image: url([[pix:format_topcoll|arrow_down]]); -} - -#toggle-all .content .toggle-arrow h4 a.off { - background-image: url([[pix:format_topcoll|arrow_down]]); -} - -#toggle-all .content .toggle-arrow-hover h4 a.off:hover { - background-image: url([[pix:format_topcoll|arrow_right_glow]]); -} - -#toggle-all .content .toggle-arrow h4 a.on { - background-image: url([[pix:format_topcoll|arrow_right]]); -} - -#toggle-all .content .toggle-arrow-hover h4 a.on:hover { - background-image: url([[pix:format_topcoll|arrow_down_glow]]); -} - -/* Bulb icon set. */ -.course-content ul.ctopics li.section .content .toggle-bulb a.toggle_closed, .course-content ul.ctopics li.section .content .toggle-bulb a.toggle_open { /* JavaScript disabled */ - background-image: url([[pix:format_topcoll|bulb_on]]); -} - -body.jsenabled .course-content ul.ctopics li.section .content .toggle-bulb a.toggle_closed { /* JavaScript enabled */ - background-image: url([[pix:format_topcoll|bulb_off]]); -} - -body.jsenabled .course-content ul.ctopics li.section .content .toggle-bulb a.toggle_open { /* JavaScript enabled */ - background-image: url([[pix:format_topcoll|bulb_on]]); -} - -#toggle-all .content .toggle-bulb h4 a.off { - background-image: url([[pix:format_topcoll|bulb_on]]); -} - -#toggle-all .content .toggle-bulb-hover h4 a.off:hover { - background-image: url([[pix:format_topcoll|bulb_off_glow]]); -} - -#toggle-all .content .toggle-bulb h4 a.on { - background-image: url([[pix:format_topcoll|bulb_off]]); -} - -#toggle-all .content .toggle-bulb-hover h4 a.on:hover { - background-image: url([[pix:format_topcoll|bulb_on_glow]]); -} - -/* Cloud icon set. */ -.course-content ul.ctopics li.section .content .toggle-cloud a.toggle_closed, .course-content ul.ctopics li.section .content .toggle-cloud a.toggle_open { /* JavaScript disabled */ - background-image: url([[pix:format_topcoll|cloud_on]]); -} - -body.jsenabled .course-content ul.ctopics li.section .content .toggle-cloud a.toggle_closed { /* JavaScript enabled */ - background-image: url([[pix:format_topcoll|cloud_off]]); -} - -body.jsenabled .course-content ul.ctopics li.section .content .toggle-cloud a.toggle_open { /* JavaScript enabled */ - background-image: url([[pix:format_topcoll|cloud_on]]); -} - -#toggle-all .content .toggle-cloud h4 a.off { - background-image: url([[pix:format_topcoll|cloud_on]]); -} - -#toggle-all .content .toggle-cloud-hover h4 a.off:hover { - background-image: url([[pix:format_topcoll|cloud_off_glow]]); -} - -#toggle-all .content .toggle-cloud h4 a.on { - background-image: url([[pix:format_topcoll|cloud_off]]); -} - -#toggle-all .content .toggle-cloud-hover h4 a.on:hover { - background-image: url([[pix:format_topcoll|cloud_on_glow]]); -} - -/* Eye icon set. */ -.course-content ul.ctopics li.section .content .toggle-eye a.toggle_closed, .course-content ul.ctopics li.section .content .toggle-eye a.toggle_open { /* JavaScript disabled */ - background-image: url([[pix:format_topcoll|eye_show]]); -} - -body.jsenabled .course-content ul.ctopics li.section .content .toggle-eye a.toggle_closed { /* JavaScript enabled */ - background-image: url([[pix:format_topcoll|eye_hide]]); -} - -body.jsenabled .course-content ul.ctopics li.section .content .toggle-eye a.toggle_open { /* JavaScript enabled */ - background-image: url([[pix:format_topcoll|eye_show]]); -} - -#toggle-all .content .toggle-eye h4 a.off { - background-image: url([[pix:format_topcoll|eye_show]]); -} - -#toggle-all .content .toggle-eye-hover h4 a.off:hover { - background-image: url([[pix:format_topcoll|eye_hide_glow]]); -} - -#toggle-all .content .toggle-eye h4 a.on { - background-image: url([[pix:format_topcoll|eye_hide]]); -} - -#toggle-all .content .toggle-eye-hover h4 a.on:hover { - background-image: url([[pix:format_topcoll|eye_show_glow]]); -} - -/* Ground signal set. */ -.course-content ul.ctopics li.section .content .toggle-groundsignal a.toggle_closed, .course-content ul.ctopics li.section .content .toggle-ground-signal a.toggle_open { /* JavaScript disabled */ - background-image: url([[pix:format_topcoll|ground_signal_on]]); -} - -body.jsenabled .course-content ul.ctopics li.section .content .toggle-groundsignal a.toggle_closed { /* JavaScript enabled */ - background-image: url([[pix:format_topcoll|ground_signal_off]]); -} - -body.jsenabled .course-content ul.ctopics li.section .content .toggle-groundsignal a.toggle_open { /* JavaScript enabled */ - background-image: url([[pix:format_topcoll|ground_signal_on]]); -} - -#toggle-all .content .toggle-groundsignal h4 a.off { - background-image: url([[pix:format_topcoll|ground_signal_on]]); -} - -#toggle-all .content .toggle-groundsignal-hover h4 a.off:hover { - background-image: url([[pix:format_topcoll|ground_signal_off]]); -} - -#toggle-all .content .toggle-groundsignal h4 a.on { - background-image: url([[pix:format_topcoll|ground_signal_off]]); -} - -#toggle-all .content .toggle-groundsignal-hover h4 a.on:hover { - background-image: url([[pix:format_topcoll|ground_signal_on]]); -} - -/* LED icon set. */ -.course-content ul.ctopics li.section .content .toggle-led a.toggle_closed, .course-content ul.ctopics li.section .content .toggle-led a.toggle_open { /* JavaScript disabled */ - background-image: url([[pix:format_topcoll|led_on]]); -} - -body.jsenabled .course-content ul.ctopics li.section .content .toggle-led a.toggle_closed { /* JavaScript enabled */ - background-image: url([[pix:format_topcoll|led_off]]); -} - -body.jsenabled .course-content ul.ctopics li.section .content .toggle-led a.toggle_open { /* JavaScript enabled */ - background-image: url([[pix:format_topcoll|led_on]]); -} - -#toggle-all .content .toggle-led h4 a.off { - background-image: url([[pix:format_topcoll|led_on]]); -} - -#toggle-all .content .toggle-led-hover h4 a.off:hover { - background-image: url([[pix:format_topcoll|led_off_glow]]); -} - -#toggle-all .content .toggle-led h4 a.on { - background-image: url([[pix:format_topcoll|led_off]]); -} - -#toggle-all .content .toggle-led-hover h4 a.on:hover { - background-image: url([[pix:format_topcoll|led_on_glow]]); -} - -/* Point icon set. */ -.course-content ul.ctopics li.section .content .toggle-point a.toggle_closed, .course-content ul.ctopics li.section .content .toggle-point a.toggle_open { /* JavaScript disabled */ - background-image: url([[pix:format_topcoll|point_down]]); -} - -body.jsenabled .course-content ul.ctopics li.section .content .toggle-point a.toggle_closed { /* JavaScript enabled */ - background-image: url([[pix:format_topcoll|point_right]]); -} - -body.jsenabled .course-content ul.ctopics li.section .content .toggle-point a.toggle_open { /* JavaScript enabled */ - background-image: url([[pix:format_topcoll|point_down]]); -} - -#toggle-all .content .toggle-point h4 a.off { - background-image: url([[pix:format_topcoll|point_down]]); -} - -#toggle-all .content .toggle-point-hover h4 a.off:hover { - background-image: url([[pix:format_topcoll|point_right_glow]]); -} - -#toggle-all .content .toggle-point h4 a.on { - background-image: url([[pix:format_topcoll|point_right]]); -} - -#toggle-all .content .toggle-point-hover h4 a.on:hover { - background-image: url([[pix:format_topcoll|point_down_glow]]); -} - -/* Power icon set. */ -.course-content ul.ctopics li.section .content .toggle-power a.toggle_closed, .course-content ul.ctopics li.section .content .toggle-power a.toggle_open { /* JavaScript disabled */ - background-image: url([[pix:format_topcoll|toggle_plus]]); -} - -body.jsenabled .course-content ul.ctopics li.section .content .toggle-power a.toggle_closed { /* JavaScript enabled */ - background-image: url([[pix:format_topcoll|toggle_minus]]); -} - -body.jsenabled .course-content ul.ctopics li.section .content .toggle-power a.toggle_open { /* JavaScript enabled */ - background-image: url([[pix:format_topcoll|toggle_plus]]); -} - -#toggle-all .content .toggle-power h4 a.off { - background-image: url([[pix:format_topcoll|toggle_plus]]); -} - -#toggle-all .content .toggle-power-hover h4 a.off:hover { - background-image: url([[pix:format_topcoll|toggle_minus_glow]]); -} - -#toggle-all .content .toggle-power h4 a.on { - background-image: url([[pix:format_topcoll|toggle_minus]]); -} - -#toggle-all .content .toggle-power-hover h4 a.on:hover { - background-image: url([[pix:format_topcoll|toggle_plus_glow]]); -} - -/* Radio icon set. */ -.course-content ul.ctopics li.section .content .toggle-radio a.toggle_closed, .course-content ul.ctopics li.section .content .toggle-radio a.toggle_open { /* JavaScript disabled */ - background-image: url([[pix:format_topcoll|radio_on]]); -} - -body.jsenabled .course-content ul.ctopics li.section .content .toggle-radio a.toggle_closed { /* JavaScript enabled */ - background-image: url([[pix:format_topcoll|radio_off]]); -} - -body.jsenabled .course-content ul.ctopics li.section .content .toggle-radio a.toggle_open { /* JavaScript enabled */ - background-image: url([[pix:format_topcoll|radio_on]]); -} - -#toggle-all .content .toggle-radio h4 a.off { - background-image: url([[pix:format_topcoll|radio_on]]); -} - -#toggle-all .content .toggle-radio-hover h4 a.off:hover { - background-image: url([[pix:format_topcoll|radio_off_glow]]); -} - -#toggle-all .content .toggle-radio h4 a.on { - background-image: url([[pix:format_topcoll|radio_off]]); -} - -#toggle-all .content .toggle-radio-hover h4 a.on:hover { - background-image: url([[pix:format_topcoll|radio_on_glow]]); -} - -/* Smiley icon set. */ -.course-content ul.ctopics li.section .content .toggle-smiley a.toggle_closed, .course-content ul.ctopics li.section .content .toggle-smiley a.toggle_open { /* JavaScript disabled */ - background-image: url([[pix:format_topcoll|smiley_on]]); -} - -body.jsenabled .course-content ul.ctopics li.section .content .toggle-smiley a.toggle_closed { /* JavaScript enabled */ - background-image: url([[pix:format_topcoll|smiley_off]]); -} - -body.jsenabled .course-content ul.ctopics li.section .content .toggle-smiley a.toggle_open { /* JavaScript enabled */ - background-image: url([[pix:format_topcoll|smiley_on]]); -} - -#toggle-all .content .toggle-smiley h4 a.off { - background-image: url([[pix:format_topcoll|smiley_on]]); -} - -#toggle-all .content .toggle-smiley-hover h4 a.off:hover { - background-image: url([[pix:format_topcoll|smiley_off_glow]]); -} - -#toggle-all .content .toggle-smiley h4 a.on { - background-image: url([[pix:format_topcoll|smiley_off]]); -} - -#toggle-all .content .toggle-smiley-hover h4 a.on:hover { - background-image: url([[pix:format_topcoll|smiley_on_glow]]); -} - -/* Square icon set. */ -.course-content ul.ctopics li.section .content .toggle-square a.toggle_closed, .course-content ul.ctopics li.section .content .toggle-square a.toggle_open { /* JavaScript disabled */ - background-image: url([[pix:format_topcoll|square_on]]); -} - -body.jsenabled .course-content ul.ctopics li.section .content .toggle-square a.toggle_closed { /* JavaScript enabled */ - background-image: url([[pix:format_topcoll|square_off]]); -} - -body.jsenabled .course-content ul.ctopics li.section .content .toggle-square a.toggle_open { /* JavaScript enabled */ - background-image: url([[pix:format_topcoll|square_on]]); -} - -#toggle-all .content .toggle-square h4 a.off { - background-image: url([[pix:format_topcoll|square_on]]); -} - -#toggle-all .content .toggle-square-hover h4 a.off:hover { - background-image: url([[pix:format_topcoll|square_off_glow]]); -} - -#toggle-all .content .toggle-square h4 a.on { - background-image: url([[pix:format_topcoll|square_off]]); -} - -#toggle-all .content .toggle-square-hover h4 a.on:hover { - background-image: url([[pix:format_topcoll|square_on_glow]]); -} - -/* Sun / Moon icon set. */ -.course-content ul.ctopics li.section .content .toggle-sunmoon a.toggle_closed, .course-content ul.ctopics li.section .content .toggle-sunmoon a.toggle_open { /* JavaScript disabled */ - background-image: url([[pix:format_topcoll|sunmoon_on]]); -} - -body.jsenabled .course-content ul.ctopics li.section .content .toggle-sunmoon a.toggle_closed { /* JavaScript enabled */ - background-image: url([[pix:format_topcoll|sunmoon_off]]); -} - -body.jsenabled .course-content ul.ctopics li.section .content .toggle-sunmoon a.toggle_open { /* JavaScript enabled */ - background-image: url([[pix:format_topcoll|sunmoon_on]]); -} - -#toggle-all .content .toggle-sunmoon h4 a.off { - background-image: url([[pix:format_topcoll|sunmoon_on]]); -} - -#toggle-all .content .toggle-sunmoon-hover h4 a.off:hover { - background-image: url([[pix:format_topcoll|sunmoon_off_glow]]); -} - -#toggle-all .content .toggle-sunmoon h4 a.on { - background-image: url([[pix:format_topcoll|sunmoon_off]]); -} - -#toggle-all .content .toggle-sunmoon-hover h4 a.on:hover { - background-image: url([[pix:format_topcoll|sunmoon_on_glow]]); -} - -/* Switch icon set. */ -.course-content ul.ctopics li.section .content .toggle-switch a.toggle_closed, .course-content ul.ctopics li.section .content .toggle-switch a.toggle_open { /* JavaScript disabled */ - background-image: url([[pix:format_topcoll|switch_on]]); -} - -body.jsenabled .course-content ul.ctopics li.section .content .toggle-switch a.toggle_closed { /* JavaScript enabled */ - background-image: url([[pix:format_topcoll|switch_off]]); -} - -body.jsenabled .course-content ul.ctopics li.section .content .toggle-switch a.toggle_open { /* JavaScript enabled */ - background-image: url([[pix:format_topcoll|switch_on]]); -} - -#toggle-all .content .toggle-switch h4 a.off { - background-image: url([[pix:format_topcoll|switch_on]]); -} - -#toggle-all .content .toggle-switch-hover h4 a.off:hover { - background-image: url([[pix:format_topcoll|switch_off_glow]]); -} - -#toggle-all .content .toggle-switch h4 a.on { - background-image: url([[pix:format_topcoll|switch_off]]); -} - -#toggle-all .content .toggle-switch-hover h4 a.on:hover { - background-image: url([[pix:format_topcoll|switch_on_glow]]); -} - -/* Background images for the settings - does not work in Chrome or Safari - known issue */ -body#page-admin-setting-formatsettingtopcoll select#id_s_format_topcoll_defaulttoggleiconset option[value="arrow"], body#page-course-edit select#id_toggleiconset option[value="arrow"] { - background-image: url([[pix:format_topcoll|arrow_right]]); -} - -body#page-admin-setting-formatsettingtopcoll select#id_s_format_topcoll_defaulttoggleiconset option[value="bulb"], body#page-course-edit select#id_toggleiconset option[value="bulb"] { - background-image: url([[pix:format_topcoll|bulb_off]]); -} - -body#page-admin-setting-formatsettingtopcoll select#id_s_format_topcoll_defaulttoggleiconset option[value="cloud"], body#page-course-edit select#id_toggleiconset option[value="cloud"] { - background-image: url([[pix:format_topcoll|cloud_off]]); -} - -body#page-admin-setting-formatsettingtopcoll select#id_s_format_topcoll_defaulttoggleiconset option[value="eye"], body#page-course-edit select#id_toggleiconset option[value="eye"] { - background-image: url([[pix:format_topcoll|eye_hide]]); -} - -body#page-admin-setting-formatsettingtopcoll select#id_s_format_topcoll_defaulttoggleiconset option[value="groundsignal"], body#page-course-edit select#id_toggleiconset option[value="groundsignal"] { - background-image: url([[pix:format_topcoll|ground_signal_off]]); -} - -body#page-admin-setting-formatsettingtopcoll select#id_s_format_topcoll_defaulttoggleiconset option[value="led"], body#page-course-edit select#id_toggleiconset option[value="led"] { - background-image: url([[pix:format_topcoll|led_off]]); -} - -body#page-admin-setting-formatsettingtopcoll select#id_s_format_topcoll_defaulttoggleiconset option[value="point"], body#page-course-edit select#id_toggleiconset option[value="point"] { - background-image: url([[pix:format_topcoll|point_right]]); -} - -body#page-admin-setting-formatsettingtopcoll select#id_s_format_topcoll_defaulttoggleiconset option[value="power"], body#page-course-edit select#id_toggleiconset option[value="power"] { - background-image: url([[pix:format_topcoll|toggle_minus]]); -} - -body#page-admin-setting-formatsettingtopcoll select#id_s_format_topcoll_defaulttoggleiconset option[value="radio"], body#page-course-edit select#id_toggleiconset option[value="radio"] { - background-image: url([[pix:format_topcoll|radio_off]]); -} - -body#page-admin-setting-formatsettingtopcoll select#id_s_format_topcoll_defaulttoggleiconset option[value="smiley"], body#page-course-edit select#id_toggleiconset option[value="smiley"] { - background-image: url([[pix:format_topcoll|smiley_off]]); -} - -body#page-admin-setting-formatsettingtopcoll select#id_s_format_topcoll_defaulttoggleiconset option[value="square"], body#page-course-edit select#id_toggleiconset option[value="square"] { - background-image: url([[pix:format_topcoll|square_off]]); -} - -body#page-admin-setting-formatsettingtopcoll select#id_s_format_topcoll_defaulttoggleiconset option[value="sunmoon"], body#page-course-edit select#id_toggleiconset option[value="sunmoon"] { - background-image: url([[pix:format_topcoll|sunmoon_off]]); -} - -body#page-admin-setting-formatsettingtopcoll select#id_s_format_topcoll_defaulttoggleiconset option[value="switch"], body#page-course-edit select#id_toggleiconset option[value="switch"] { - background-image: url([[pix:format_topcoll|switch_off]]); -} - -body#page-admin-setting-formatsettingtopcoll select#id_s_format_topcoll_defaulttoggleiconset option, body#page-course-edit select#id_toggleiconset option { - background-color: transparent; - background-repeat: no-repeat; - background-position: right center; /* Position the icon to the right of the selection text. */ - padding: 3px 20px 3px 3px; /* The 20px allows the image to be on the right and the text next to it. */ -} - -body#page-admin-setting-formatsettingtopcoll.lang-en_ar select#id_s_format_topcoll_defaulttoggleiconset option, body#page-course-edit.lang-en_ar select#id_toggleiconset option { - background-position: 220px 45%; /* Pirate strings are longer. */ -} - -/* Display instructions */ -.topcoll-display-instructions { - margin: 0px; -} - -/* Layout */ -.course-content ul.ctopics #section-0 .content{ - padding: 10px; -} - -.course-content ul.ctopics li.section.main .side, .course-content ul.ctopics li.tcsection .side { - width: 40px; /* Default used in editing mode or when not defined in the language file. */ - text-align: center; - padding: 0px; -} - -.course-content ul.ctopics li.section .left, .course-content ul.ctopics li.tcsection .left { - float:left; -} - -.course-content ul.ctopics li.section.main .left { - padding: 10px 0px 0px 0px; -} - -.course-content ul.ctopics li.current.main .right { - padding: 0px 0px 0px 0px; /* Cancel out effect of above when having to use 'left' side selector for getting the correct text colour on the right for the current section. This is because the selector '.course-content .current .left' defines the colour in the theme and therefore any CT specific 'right' implementation would not work for all themes. */ -} - -.course-content ul.ctopics li.section .right, .course-content ul.ctopics li.tcsection .right { - float:right; -} - -.course-content ul.ctopics li.section .right { - line-height: 1.3; -} - -.course-content ul.ctopics li.section .right a { - display: block; /* So that section_right_content() does not implode with 'br's and get too many when the up arrow is removed by JS. */ -} - -.course-content ul.ctopics li.section .right a img.hide{ - display: inline; /* CONTRIB-5817 - Align the eye icon. */ -} - -.course-content ul.ctopics li.section .left .section-handle img.icon { - padding: 0; - vertical-align: baseline; -} - -/* Assist the layout. */ -body.format-topcoll.dir-rtl .course-content ul.ctopics li.section .left { - float: right; -} - -body.format-topcoll.dir-rtl .course-content ul.ctopics li.section .right { - float: left; -} - -body.format-topcoll .ctopics .section .activity .mod-indent-outer, -body.format-topcoll.editing.dir-rtl .ctopics .section .activity .mod-indent-outer { - padding-left: 0px; -} - -body.format-topcoll.editing .ctopics .section .activity .mod-indent-outer { - padding-left: 32px; -} - -body.format-topcoll.dir-rtl .ctopics .section .activity .mod-indent-outer { - padding-right: 0px; -} - -body.format-topcoll.editing.dir-rtl .ctopics .section .activity .mod-indent-outer { - padding-right: 32px; -} - -body.format-topcoll .ctopics .section { - margin: 1em 0em; -} - -body.format-topcoll .course-content ul.ctopics li.section .summary { - margin-left: 0px; -} - -body.format-topcoll.dir-rtl .course-content ul.ctopics li.section .summary { - margin-right: 0px; -} - -body.format-topcoll .course-content ul.ctopics li.section .summary.summaryalwaysshown { - padding-top: 10px; -} - -body.format-topcoll.editing ul.ctopics .section .activity .contentwithoutlink, body.format-topcoll.editing ul.ctopics .section .activity .activityinstance { - padding-right: 0px; - display: inline; -} - -body.format-topcoll.editing.dir-rtl ul.ctopics .section .activity .contentwithoutlink, body.format-topcoll.editing.dir-rtl ul.ctopics .section .activity .activityinstance { - padding-left: 0px; -} - -body.format-topcoll.editing ul.ctopics .section .activity .actions { - position: relative; -} - -body.format-topcoll.editing #region-main ul.ctopics .moodle-actionmenu ul.menubar { - display: none; -} - -body.format-topcoll.editing.jsenabled #region-main ul.ctopics .moodle-actionmenu[data-enhance] ul.menubar { - display: inline-block; -} - -/* -- The section name in a Toggle and hidden section -- */ -.course-content ul.ctopics li.section .content .toggle, .course-content ul.ctopics li.section .content.sectionhidden { - display: block; - text-align: left; - padding: 0 0; -} - -/* -- The width of a section name in a Toggle -- */ -.course-content ul.ctopics li.section .content .toggle { - width: 100%; -} - -/* -- The padding of a hidden section -- */ -.course-content ul.ctopics li.section .content.sectionhidden { - padding: 6px 0px 6px 0px; -} - -/* -- The topic summary text -- */ -.course-content ul.ctopics li.section .content .toggle a p { - font-size: 1.2em; - font-style: italic; - text-align: left; -} - -/* -- For centring the 'Topic / Week / Day x' text -- */ -.course-content ul.ctopics li.section .right span.cps_centre, .dir-rtl .course-content ul.ctopics li.section .left span.cps_centre { - text-align: center; - font-size: 0.7em; -} - -.dir-rtl .course-content ul.ctopics li.section .right span.cps_centre { - font-size: 14px; -} - -/* -- Toggle text -- */ -.course-content ul.ctopics li.section .content .toggle a, .course-content ul.ctopics li.section .content.sectionhidden { - text-decoration: none; - font-weight: bold; -} - -.course-content ul.ctopics li.section .content .toggledsection { - min-height: 30px; -} - -/* -- Hiding / Showing the sections -- */ -body.jsenabled .toggledsection { - display: none; /* If JavaScript is enabled then this css will apply and the section will be hidden. */ -} - -body.jsenabled .toggledsection.sectionopen { - display: block; -} - -/* -- Size of the spacer row -- */ -.section .spacer { - height:0.5em; -} - -/* Toggle all */ -#toggle-all, #topcoll-display-instructions { - display: none; /* Hide when JavaScript not enabled. */ -} - -body.jsenabled #toggle-all, body.jsenabled #topcoll-display-instructions { - display: block; -} - -body.jsenabled #toggle-all { - background: none repeat scroll 0 0 transparent; -} - -#toggle-all .content .sectionbody h4 { - display: block; - padding: 6px 0px; - margin-bottom: 0em; -} - -#toggle-all .content .sectionbody h4 a { - padding-top: 7px; - padding-bottom: 7px; - width: 35px; - text-decoration: none; -} - -#toggle-all .content .sectionbody h4 a.tc-small { - padding-left: 18px; /* The 18px allows the arrow to be with the text next to it. */ - padding-right: 18px; -} - -#toggle-all .content .sectionbody h4 a.tc-medium { - padding-left: 26px; /* The 26px allows the arrow to be with the text next to it. */ - padding-right: 26px; -} - -#toggle-all .content .sectionbody h4 a.tc-large { - padding-left: 34px; /* The 34px allows the arrow to be with the text next to it. */ - padding-right: 34px; -} - -#toggle-all .content .sectionbody h4, #toggle-all .content .sectionbody h4 a { - text-align: left; -} - -.dir-rtl #toggle-all .content .sectionbody h4, .dir-rtl #toggle-all .content .sectionbody h4 a { - text-align: right; -} - -.cttoggle { - font-family: inherit; - font-size: inherit; - font-style: inherit; -} - -/* MDL-42634 */ -.course-content ul.ctopics li.section.hidden .sectionname, .course-content ul.ctopics li.section.hidden .content>div, .course-content ul.ctopics li.section.hidden .activity .activityinstance { - opacity: inherit; -} - -.course-content ul.ctopics li.section.hidden h3.section-title, -.course-content ul.ctopics li.section.hidden .content .summary { - opacity: 0.5; -} - -/* Print styles. */ -@media print { - body.jsenabled .toggledsection { - display: block; /* If JavaScript is enabled and we are printing then this css will apply and the section will be shown. */ - } - body.jsenabled #toggle-all, body.jsenabled #topcoll-display-instructions, .cttoggle { - display: none; - } - .course-content ul.ctopics li.section.main { - float: left; - } - body.format-topcoll .course-content ul.ctopics li.section.main { - padding-bottom: 0px; - } - ul.ctopics { - page-break-before: avoid; - page-break-after: avoid; - } -} +/** + * Collapsed Topics Information + * + * A topic based format that solves the issue of the 'Scroll of Death' when a course has many topics. All topics + * except zero have a toggle that displays that topic. One or more topics can be displayed at any given time. + * Toggles are persistent on a per browser session per course basis but can be made to persist longer by a small + * code change. Full installation instructions, code adaptions and credits are included in the 'Readme.txt' file. + * + * @package course/format + * @subpackage topcoll + * @version See the value of '$plugin->version' in version.php. + * @copyright © 2009-onwards G J Barnard in respect to modifications of standard topics format. + * @author G J Barnard - gjbarnard at gmail dot com and {@link http://moodle.org/user/profile.php?id=442195} + * @link http://docs.moodle.org/en/Collapsed_Topics_course_format + * @license http://www.gnu.org/copyleft/gpl.html GNU Public License + * + * 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 . +*/ +.course-content ul.ctopics { + margin: 0; + padding-left: 0; + padding-right: 0; +} + +.course-content ul.ctlayout { + display: inline-block; + vertical-align: top; +} + +.course-content ul.ctopics li.section.main .left, .course-content ul.ctopics li.section.main .right { + /* Fix for Bootstrap V3 based themes in less/moodle/course.less . */ + display: block; +} + +.course-content ul.ctopics li.section.main, .course-content ul.ctopics li.tcsection { + list-style: none; + margin: 4px 1px 1px 1px; + padding: 0; +} + +/* Fix for ordered and unordered list in course topic summary & course weekly summary - from theme/base/style/core.css + * See: https://moodle.org/mod/forum/discuss.php?d=251944. + */ +.course-content ul.ctopics .content .summary ul, .course-content ul.ctopics .content .summarytext ul { + list-style: disc outside none; +} +.course-content ul.ctopics .content .summary ol, .course-content ul.ctopics .content .summarytext ol { + list-style: decimal outside none; +} + +.course-content ul.ctopics li.section.main .content, .course-content ul.ctopics li.tcsection .content { + /* Default for non tablets / mobiles. If the language file has 'topcollsidewidth' for the current language, then will be set in format.php. */ + margin: 0 40px; + padding: 0; +} + +.course-content ul.ctopics.ctportable li.section.main .content, .course-content ul.ctopics.ctportable li.tcsection .content { + margin: 0 0; /* Override default for tablets / mobiles. When have sides, set in format.php. */ +} + +.course-content ul.ctopics li .content .sectionhead h3 { + margin: 0; +} + +.course-content ul.ctopics li.current .content .toggledsection { + padding: 0 0 5px 0; +} + +.course-content ul.ctopics li.section.hidden .content > div { + margin-left: 0; + margin-right: 0; +} + +/* Toggle icon size */ +#toggle-all .content .sectionbody h4 a.tc-small, .course-content ul.ctopics li.section .content .toggle a.tc-small { + background-size: 16px 16px; +} + +#toggle-all .content .sectionbody h4 a.tc-medium, .course-content ul.ctopics li.section .content .toggle a.tc-medium { + background-size: 24px 24px; +} +#toggle-all .content .sectionbody h4 a.tc-large, .course-content ul.ctopics li.section .content .toggle a.tc-large { + background-size: 32px 32px; +} + +/* -- Set the clickable element of the Toggle -- */ +.course-content ul.ctopics li.section .content .toggle a { + display: block; + width: auto; + padding-top: 6px; + padding-bottom: 6px; +} + +.course-content ul.ctopics li.section .content .toggle a.tc-small { + padding-left: 16px; /* The 16px allows the arrow to be with the text next to it. */ + padding-right: 16px; +} + +.course-content ul.ctopics li.section .content .toggle a.tc-medium { + padding-left: 24px; /* The 24px allows the arrow to be with the text next to it. */ + padding-right: 24px; +} + +.course-content ul.ctopics li.section .content .toggle a.tc-large { + padding-left: 32px; /* The 32px allows the arrow to be with the text next to it. */ + padding-right: 32px; +} + +/* CONTRIB-4106 */ +.course-content ul.ctopics li.section .content .toggle a h3, +.course-content ul.ctopics li.section .content.sectionhidden h3 { + margin: 0; +} + +.course-content ul.ctopics li.section .content .toggle a h3.section-title, +.course-content ul.ctopics li.section .content.sectionhidden h3.section-title { + margin: 4px; + color: inherit; +} + +/* Icon set common. */ +.course-content ul.ctopics li.section .content .toggle a, #toggle-all .content h4 a { + background-repeat: no-repeat; + background-color: transparent; + margin: 0 4px; +} + +/* Icon sets. Note: Background images for the settings - does not work in Chrome or Safari - known issue. */ +/* Arrow icon set. */ +.course-content ul.ctopics li.section .content .toggle-arrow a.toggle_closed, .course-content ul.ctopics li.section .content .toggle-arrow a.toggle_open, /* JavaScript disabled */ +body.jsenabled .course-content ul.ctopics li.section .content .toggle-arrow a.toggle_open, /* JavaScript enabled */ +#toggle-all .content .toggle-arrow h4 a.off { + background-image: url([[pix:format_topcoll|arrow_down]]); +} + +body.jsenabled .course-content ul.ctopics li.section .content .toggle-arrow a.toggle_closed, /* JavaScript enabled */ +#toggle-all .content .toggle-arrow h4 a.on, +body#page-admin-setting-formatsettingtopcoll select#id_s_format_topcoll_defaulttoggleiconset option[value="arrow"], body#page-course-edit select#id_toggleiconset option[value="arrow"] { + background-image: url([[pix:format_topcoll|arrow_right]]); +} + +#toggle-all .content .toggle-arrow-hover h4 a.off:hover { + background-image: url([[pix:format_topcoll|arrow_right_glow]]); +} + +#toggle-all .content .toggle-arrow-hover h4 a.on:hover { + background-image: url([[pix:format_topcoll|arrow_down_glow]]); +} + +/* Bulb icon set. */ +.course-content ul.ctopics li.section .content .toggle-bulb a.toggle_closed, .course-content ul.ctopics li.section .content .toggle-bulb a.toggle_open, /* JavaScript disabled */ +body.jsenabled .course-content ul.ctopics li.section .content .toggle-bulb a.toggle_open, /* JavaScript enabled */ +#toggle-all .content .toggle-bulb h4 a.off { + background-image: url([[pix:format_topcoll|bulb_on]]); +} + +body.jsenabled .course-content ul.ctopics li.section .content .toggle-bulb a.toggle_closed, /* JavaScript enabled */ +#toggle-all .content .toggle-bulb h4 a.on, +body#page-admin-setting-formatsettingtopcoll select#id_s_format_topcoll_defaulttoggleiconset option[value="bulb"], body#page-course-edit select#id_toggleiconset option[value="bulb"] { + background-image: url([[pix:format_topcoll|bulb_off]]); +} + +#toggle-all .content .toggle-bulb-hover h4 a.off:hover { + background-image: url([[pix:format_topcoll|bulb_off_glow]]); +} + +#toggle-all .content .toggle-bulb-hover h4 a.on:hover { + background-image: url([[pix:format_topcoll|bulb_on_glow]]); +} + +/* Cloud icon set. */ +.course-content ul.ctopics li.section .content .toggle-cloud a.toggle_closed, .course-content ul.ctopics li.section .content .toggle-cloud a.toggle_open, /* JavaScript disabled */ +body.jsenabled .course-content ul.ctopics li.section .content .toggle-cloud a.toggle_open, /* JavaScript enabled */ +#toggle-all .content .toggle-cloud h4 a.off { + background-image: url([[pix:format_topcoll|cloud_on]]); +} + +body.jsenabled .course-content ul.ctopics li.section .content .toggle-cloud a.toggle_closed, /* JavaScript enabled */ +#toggle-all .content .toggle-cloud h4 a.on, +body#page-admin-setting-formatsettingtopcoll select#id_s_format_topcoll_defaulttoggleiconset option[value="cloud"], body#page-course-edit select#id_toggleiconset option[value="cloud"] { + background-image: url([[pix:format_topcoll|cloud_off]]); +} + +#toggle-all .content .toggle-cloud-hover h4 a.off:hover { + background-image: url([[pix:format_topcoll|cloud_off_glow]]); +} + +#toggle-all .content .toggle-cloud-hover h4 a.on:hover { + background-image: url([[pix:format_topcoll|cloud_on_glow]]); +} + +/* Eye icon set. */ +.course-content ul.ctopics li.section .content .toggle-eye a.toggle_closed, .course-content ul.ctopics li.section .content .toggle-eye a.toggle_open, /* JavaScript disabled */ +body.jsenabled .course-content ul.ctopics li.section .content .toggle-eye a.toggle_open, /* JavaScript enabled */ +#toggle-all .content .toggle-eye h4 a.off { + background-image: url([[pix:format_topcoll|eye_show]]); +} + +body.jsenabled .course-content ul.ctopics li.section .content .toggle-eye a.toggle_closed, /* JavaScript enabled */ +#toggle-all .content .toggle-eye h4 a.on, +body#page-admin-setting-formatsettingtopcoll select#id_s_format_topcoll_defaulttoggleiconset option[value="eye"], body#page-course-edit select#id_toggleiconset option[value="eye"] { + background-image: url([[pix:format_topcoll|eye_hide]]); +} + +#toggle-all .content .toggle-eye-hover h4 a.off:hover { + background-image: url([[pix:format_topcoll|eye_hide_glow]]); +} + +#toggle-all .content .toggle-eye-hover h4 a.on:hover { + background-image: url([[pix:format_topcoll|eye_show_glow]]); +} + +/* Ground signal set. */ +.course-content ul.ctopics li.section .content .toggle-groundsignal a.toggle_closed, .course-content ul.ctopics li.section .content .toggle-ground-signal a.toggle_open, /* JavaScript disabled */ +body.jsenabled .course-content ul.ctopics li.section .content .toggle-groundsignal a.toggle_open, /* JavaScript enabled */ +#toggle-all .content .toggle-groundsignal h4 a.off, +#toggle-all .content .toggle-groundsignal-hover h4 a.on:hover { + background-image: url([[pix:format_topcoll|ground_signal_on]]); +} + +body.jsenabled .course-content ul.ctopics li.section .content .toggle-groundsignal a.toggle_closed, /* JavaScript enabled */ +#toggle-all .content .toggle-groundsignal-hover h4 a.off:hover, +#toggle-all .content .toggle-groundsignal h4 a.on, +body#page-admin-setting-formatsettingtopcoll select#id_s_format_topcoll_defaulttoggleiconset option[value="groundsignal"], body#page-course-edit select#id_toggleiconset option[value="groundsignal"] { + background-image: url([[pix:format_topcoll|ground_signal_off]]); +} + +/* LED icon set. */ +.course-content ul.ctopics li.section .content .toggle-led a.toggle_closed, .course-content ul.ctopics li.section .content .toggle-led a.toggle_open, /* JavaScript disabled */ +body.jsenabled .course-content ul.ctopics li.section .content .toggle-led a.toggle_open, /* JavaScript enabled */ +#toggle-all .content .toggle-led h4 a.off { + background-image: url([[pix:format_topcoll|led_on]]); +} + +body.jsenabled .course-content ul.ctopics li.section .content .toggle-led a.toggle_closed, /* JavaScript enabled */ +#toggle-all .content .toggle-led h4 a.on, +body#page-admin-setting-formatsettingtopcoll select#id_s_format_topcoll_defaulttoggleiconset option[value="led"], body#page-course-edit select#id_toggleiconset option[value="led"] { + background-image: url([[pix:format_topcoll|led_off]]); +} + +#toggle-all .content .toggle-led-hover h4 a.off:hover { + background-image: url([[pix:format_topcoll|led_off_glow]]); +} + +#toggle-all .content .toggle-led-hover h4 a.on:hover { + background-image: url([[pix:format_topcoll|led_on_glow]]); +} + +/* Point icon set. */ +.course-content ul.ctopics li.section .content .toggle-point a.toggle_closed, .course-content ul.ctopics li.section .content .toggle-point a.toggle_open, /* JavaScript disabled */ +body.jsenabled .course-content ul.ctopics li.section .content .toggle-point a.toggle_open, /* JavaScript enabled */ +#toggle-all .content .toggle-point h4 a.off { + background-image: url([[pix:format_topcoll|point_down]]); +} + +body.jsenabled .course-content ul.ctopics li.section .content .toggle-point a.toggle_closed, /* JavaScript enabled */ +#toggle-all .content .toggle-point h4 a.on, +body#page-admin-setting-formatsettingtopcoll select#id_s_format_topcoll_defaulttoggleiconset option[value="point"], body#page-course-edit select#id_toggleiconset option[value="point"] { + background-image: url([[pix:format_topcoll|point_right]]); +} + +#toggle-all .content .toggle-point-hover h4 a.off:hover { + background-image: url([[pix:format_topcoll|point_right_glow]]); +} + +#toggle-all .content .toggle-point-hover h4 a.on:hover { + background-image: url([[pix:format_topcoll|point_down_glow]]); +} + +/* Power icon set. */ +.course-content ul.ctopics li.section .content .toggle-power a.toggle_closed, .course-content ul.ctopics li.section .content .toggle-power a.toggle_open, /* JavaScript disabled */ +body.jsenabled .course-content ul.ctopics li.section .content .toggle-power a.toggle_open, /* JavaScript enabled */ +#toggle-all .content .toggle-power h4 a.off { + background-image: url([[pix:format_topcoll|toggle_plus]]); +} + +body.jsenabled .course-content ul.ctopics li.section .content .toggle-power a.toggle_closed, /* JavaScript enabled */ +#toggle-all .content .toggle-power h4 a.on, +body#page-admin-setting-formatsettingtopcoll select#id_s_format_topcoll_defaulttoggleiconset option[value="power"], body#page-course-edit select#id_toggleiconset option[value="power"] { + background-image: url([[pix:format_topcoll|toggle_minus]]); +} + +#toggle-all .content .toggle-power-hover h4 a.off:hover { + background-image: url([[pix:format_topcoll|toggle_minus_glow]]); +} + +#toggle-all .content .toggle-power-hover h4 a.on:hover { + background-image: url([[pix:format_topcoll|toggle_plus_glow]]); +} + +/* Radio icon set. */ +.course-content ul.ctopics li.section .content .toggle-radio a.toggle_closed, .course-content ul.ctopics li.section .content .toggle-radio a.toggle_open, /* JavaScript disabled */ +body.jsenabled .course-content ul.ctopics li.section .content .toggle-radio a.toggle_open, /* JavaScript enabled */ +#toggle-all .content .toggle-radio h4 a.off { + background-image: url([[pix:format_topcoll|radio_on]]); +} + +body.jsenabled .course-content ul.ctopics li.section .content .toggle-radio a.toggle_closed, /* JavaScript enabled */ +#toggle-all .content .toggle-radio h4 a.on, +body#page-admin-setting-formatsettingtopcoll select#id_s_format_topcoll_defaulttoggleiconset option[value="radio"], body#page-course-edit select#id_toggleiconset option[value="radio"] { + background-image: url([[pix:format_topcoll|radio_off]]); +} + +#toggle-all .content .toggle-radio-hover h4 a.off:hover { + background-image: url([[pix:format_topcoll|radio_off_glow]]); +} + +#toggle-all .content .toggle-radio-hover h4 a.on:hover { + background-image: url([[pix:format_topcoll|radio_on_glow]]); +} + +/* Smiley icon set. */ +.course-content ul.ctopics li.section .content .toggle-smiley a.toggle_closed, .course-content ul.ctopics li.section .content .toggle-smiley a.toggle_open, /* JavaScript disabled */ +body.jsenabled .course-content ul.ctopics li.section .content .toggle-smiley a.toggle_open, /* JavaScript enabled */ +#toggle-all .content .toggle-smiley h4 a.off { + background-image: url([[pix:format_topcoll|smiley_on]]); +} + +body.jsenabled .course-content ul.ctopics li.section .content .toggle-smiley a.toggle_closed , /* JavaScript enabled */ +#toggle-all .content .toggle-smiley h4 a.on, +body#page-admin-setting-formatsettingtopcoll select#id_s_format_topcoll_defaulttoggleiconset option[value="smiley"], body#page-course-edit select#id_toggleiconset option[value="smiley"] { + background-image: url([[pix:format_topcoll|smiley_off]]); +} + +#toggle-all .content .toggle-smiley-hover h4 a.off:hover { + background-image: url([[pix:format_topcoll|smiley_off_glow]]); +} + +#toggle-all .content .toggle-smiley-hover h4 a.on:hover { + background-image: url([[pix:format_topcoll|smiley_on_glow]]); +} + +/* Square icon set. */ +.course-content ul.ctopics li.section .content .toggle-square a.toggle_closed, .course-content ul.ctopics li.section .content .toggle-square a.toggle_open, /* JavaScript disabled */ +body.jsenabled .course-content ul.ctopics li.section .content .toggle-square a.toggle_open, /* JavaScript enabled */ +#toggle-all .content .toggle-square h4 a.off { + background-image: url([[pix:format_topcoll|square_on]]); +} + +body.jsenabled .course-content ul.ctopics li.section .content .toggle-square a.toggle_closed, /* JavaScript enabled */ +#toggle-all .content .toggle-square h4 a.on, +body#page-admin-setting-formatsettingtopcoll select#id_s_format_topcoll_defaulttoggleiconset option[value="square"], body#page-course-edit select#id_toggleiconset option[value="square"] { + background-image: url([[pix:format_topcoll|square_off]]); +} + +#toggle-all .content .toggle-square-hover h4 a.off:hover { + background-image: url([[pix:format_topcoll|square_off_glow]]); +} + +#toggle-all .content .toggle-square-hover h4 a.on:hover { + background-image: url([[pix:format_topcoll|square_on_glow]]); +} + +/* Sun / Moon icon set. */ +.course-content ul.ctopics li.section .content .toggle-sunmoon a.toggle_closed, .course-content ul.ctopics li.section .content .toggle-sunmoon a.toggle_open, /* JavaScript disabled */ +body.jsenabled .course-content ul.ctopics li.section .content .toggle-sunmoon a.toggle_open, /* JavaScript enabled */ +#toggle-all .content .toggle-sunmoon h4 a.off { + background-image: url([[pix:format_topcoll|sunmoon_on]]); +} + +body.jsenabled .course-content ul.ctopics li.section .content .toggle-sunmoon a.toggle_closed, /* JavaScript enabled */ +#toggle-all .content .toggle-sunmoon h4 a.on, +body#page-admin-setting-formatsettingtopcoll select#id_s_format_topcoll_defaulttoggleiconset option[value="sunmoon"], body#page-course-edit select#id_toggleiconset option[value="sunmoon"] { + background-image: url([[pix:format_topcoll|sunmoon_off]]); +} + +#toggle-all .content .toggle-sunmoon-hover h4 a.off:hover { + background-image: url([[pix:format_topcoll|sunmoon_off_glow]]); +} + +#toggle-all .content .toggle-sunmoon-hover h4 a.on:hover { + background-image: url([[pix:format_topcoll|sunmoon_on_glow]]); +} + +/* Switch icon set. */ +.course-content ul.ctopics li.section .content .toggle-switch a.toggle_closed, .course-content ul.ctopics li.section .content .toggle-switch a.toggle_open, /* JavaScript disabled */ +body.jsenabled .course-content ul.ctopics li.section .content .toggle-switch a.toggle_open, /* JavaScript enabled */ +#toggle-all .content .toggle-switch h4 a.off { + background-image: url([[pix:format_topcoll|switch_on]]); +} + +body.jsenabled .course-content ul.ctopics li.section .content .toggle-switch a.toggle_closed, /* JavaScript enabled */ +#toggle-all .content .toggle-switch h4 a.on, +body#page-admin-setting-formatsettingtopcoll select#id_s_format_topcoll_defaulttoggleiconset option[value="switch"], body#page-course-edit select#id_toggleiconset option[value="switch"] { + background-image: url([[pix:format_topcoll|switch_off]]); +} + +#toggle-all .content .toggle-switch-hover h4 a.off:hover { + background-image: url([[pix:format_topcoll|switch_off_glow]]); +} + +#toggle-all .content .toggle-switch-hover h4 a.on:hover { + background-image: url([[pix:format_topcoll|switch_on_glow]]); +} + +body#page-admin-setting-formatsettingtopcoll select#id_s_format_topcoll_defaulttoggleiconset option, body#page-course-edit select#id_toggleiconset option { + background-color: transparent; + background-repeat: no-repeat; + background-position: right center; /* Position the icon to the right of the selection text. */ + padding: 3px 20px 3px 3px; /* The 20px allows the image to be on the right and the text next to it. */ +} + +body#page-admin-setting-formatsettingtopcoll.lang-en_ar select#id_s_format_topcoll_defaulttoggleiconset option, body#page-course-edit.lang-en_ar select#id_toggleiconset option { + background-position: 220px 45%; /* Pirate strings are longer. */ +} + +/* Display instructions */ +.topcoll-display-instructions { + margin: 0; +} + +/* Layout */ +.course-content ul.ctopics #section-0 .content{ + padding: 10px; +} + +.course-content ul.ctopics li.section.main .side, .course-content ul.ctopics li.tcsection .side { + width: 40px; /* Default used in editing mode or when not defined in the language file. */ + text-align: center; + padding: 0; +} + +.course-content ul.ctopics li.section .left, .course-content ul.ctopics li.tcsection .left { + float:left; +} + +.course-content ul.ctopics li.section.main .left { + padding: 10px 0 0 0; +} + +.course-content ul.ctopics li.current.main .right { + padding: 0 0 0 0; /* Cancel out effect of above when having to use 'left' side selector for getting the correct text colour on the right for the current section. This is because the selector '.course-content .current .left' defines the colour in the theme and therefore any CT specific 'right' implementation would not work for all themes. */ +} + +.course-content ul.ctopics li.section .right, .course-content ul.ctopics li.tcsection .right { + float:right; +} + +.course-content ul.ctopics li.section .right { + line-height: 1.3; +} + +.course-content ul.ctopics li.section .right a { + display: block; /* So that section_right_content() does not implode with 'br's and get too many when the up arrow is removed by JS. */ +} + +.course-content ul.ctopics li.section .right a img.hide{ + display: inline; /* CONTRIB-5817 - Align the eye icon. */ +} + +.course-content ul.ctopics li.section .left .section-handle img.icon { + padding: 0; + vertical-align: baseline; +} + +/* Assist the layout. */ +body.format-topcoll.dir-rtl .course-content ul.ctopics li.section .left { + float: right; +} + +body.format-topcoll.dir-rtl .course-content ul.ctopics li.section .right { + float: left; +} + +body.format-topcoll .ctopics .section .activity .mod-indent-outer, +body.format-topcoll.editing.dir-rtl .ctopics .section .activity .mod-indent-outer { + padding-left: 0; +} + +body.format-topcoll.editing .ctopics .section .activity .mod-indent-outer { + padding-left: 32px; +} + +body.format-topcoll.dir-rtl .ctopics .section .activity .mod-indent-outer { + padding-right: 0; +} + +body.format-topcoll.editing.dir-rtl .ctopics .section .activity .mod-indent-outer { + padding-right: 32px; +} + +body.format-topcoll .ctopics .section { + margin: 1em 0; +} + +body.format-topcoll .course-content ul.ctopics li.section .summary { + margin-left: 0; +} + +body.format-topcoll.dir-rtl .course-content ul.ctopics li.section .summary { + margin-right: 0; +} + +body.format-topcoll .course-content ul.ctopics li.section .summary.summaryalwaysshown { + padding-top: 10px; +} + +body.format-topcoll.editing ul.ctopics .section .activity .contentwithoutlink, body.format-topcoll.editing ul.ctopics .section .activity .activityinstance { + padding-right: 0; + display: inline; +} + +body.format-topcoll.editing.dir-rtl ul.ctopics .section .activity .contentwithoutlink, body.format-topcoll.editing.dir-rtl ul.ctopics .section .activity .activityinstance { + padding-left: 0; +} + +body.format-topcoll.editing ul.ctopics .section .activity .actions { + position: relative; +} + +body.format-topcoll.editing #region-main ul.ctopics .moodle-actionmenu ul.menubar { + display: none; +} + +body.format-topcoll.editing.jsenabled #region-main ul.ctopics .moodle-actionmenu[data-enhance] ul.menubar { + display: inline-block; +} + +/* -- The section name in a Toggle and hidden section -- */ +.course-content ul.ctopics li.section .content .toggle, .course-content ul.ctopics li.section .content.sectionhidden { + display: block; + text-align: left; + padding: 0 0; +} + +/* -- The width of a section name in a Toggle -- */ +.course-content ul.ctopics li.section .content .toggle { + width: 100%; +} + +/* -- The padding of a hidden section -- */ +.course-content ul.ctopics li.section .content.sectionhidden { + padding: 6px 0 6px 0; +} + +/* -- The topic summary text -- */ +.course-content ul.ctopics li.section .content .toggle a p { + font-size: 1.2em; + font-style: italic; + text-align: left; +} + +/* -- For centring the 'Topic / Week / Day x' text -- */ +.course-content ul.ctopics li.section .right span.cps_centre, .dir-rtl .course-content ul.ctopics li.section .left span.cps_centre { + text-align: center; + font-size: 0.7em; +} + +.dir-rtl .course-content ul.ctopics li.section .right span.cps_centre { + font-size: 14px; +} + +/* -- Toggle text -- */ +.course-content ul.ctopics li.section .content .toggle a, .course-content ul.ctopics li.section .content.sectionhidden { + text-decoration: none; + font-weight: bold; +} + +.course-content ul.ctopics li.section .content .toggledsection { + min-height: 30px; +} + +/* -- Hiding / Showing the sections -- */ +body.jsenabled .toggledsection { + display: none; /* If JavaScript is enabled then this css will apply and the section will be hidden. */ +} + +body.jsenabled .toggledsection.sectionopen { + display: block; +} + +/* -- Size of the spacer row -- */ +.section .spacer { + height:0.5em; +} + +/* Toggle all */ +#toggle-all, #topcoll-display-instructions { + display: none; /* Hide when JavaScript not enabled. */ +} + +body.jsenabled #toggle-all, body.jsenabled #topcoll-display-instructions { + display: block; +} + +body.jsenabled #toggle-all { + background: none repeat scroll 0 0 transparent; +} + +#toggle-all .content .sectionbody h4 { + display: block; + padding: 6px 0; + margin-bottom: 0; +} + +#toggle-all .content .sectionbody h4 a { + padding-top: 7px; + padding-bottom: 7px; + width: 35px; + text-decoration: none; +} + +#toggle-all .content .sectionbody h4 a.tc-small { + padding-left: 18px; /* The 18px allows the arrow to be with the text next to it. */ + padding-right: 18px; +} + +#toggle-all .content .sectionbody h4 a.tc-medium { + padding-left: 26px; /* The 26px allows the arrow to be with the text next to it. */ + padding-right: 26px; +} + +#toggle-all .content .sectionbody h4 a.tc-large { + padding-left: 34px; /* The 34px allows the arrow to be with the text next to it. */ + padding-right: 34px; +} + +#toggle-all .content .sectionbody h4, #toggle-all .content .sectionbody h4 a { + text-align: left; +} + +.dir-rtl #toggle-all .content .sectionbody h4, .dir-rtl #toggle-all .content .sectionbody h4 a { + text-align: right; +} + +.cttoggle { + font-family: inherit; + font-size: inherit; + font-style: inherit; +} + +/* MDL-42634 */ +.course-content ul.ctopics li.section.hidden .sectionname, .course-content ul.ctopics li.section.hidden .content>div, .course-content ul.ctopics li.section.hidden .activity .activityinstance { + opacity: inherit; +} + +.course-content ul.ctopics li.section.hidden h3.section-title, +.course-content ul.ctopics li.section.hidden .content .summary { + opacity: 0.5; +} + +/* Print styles. */ +@media print { + body.jsenabled .toggledsection { + display: block; /* If JavaScript is enabled and we are printing then this css will apply and the section will be shown. */ + } + body.jsenabled #toggle-all, body.jsenabled #topcoll-display-instructions, .cttoggle { + display: none; + } + .course-content ul.ctopics li.section.main { + float: left; + } + body.format-topcoll .course-content ul.ctopics li.section.main { + padding-bottom: 0; + } + ul.ctopics { + page-break-before: avoid; + page-break-after: avoid; + } +} diff --git a/tests/courseformatrenderer_test.php b/tests/courseformatrenderer_test.php index 751ea02b..91e0539a 100644 --- a/tests/courseformatrenderer_test.php +++ b/tests/courseformatrenderer_test.php @@ -1,259 +1,259 @@ -. - -/** - * Collapsed Topics course format. - * - * @package course/format - * @subpackage topcoll - * @version See the value of '$plugin->version' in below. - * @copyright © 2015-onwards G J Barnard in respect to modifications of standard topics format. - * @author G J Barnard - gjbarnard at gmail dot com, {@link http://about.me/gjbarnard} and - * {@link http://moodle.org/user/profile.php?id=442195} - * @link http://docs.moodle.org/en/Collapsed_Topics_course_format - * @license http://www.gnu.org/copyleft/gpl.html GNU Public License - */ - -/** - * Renderer unit tests for the Collapsed Topics course format. - * @group format_topcoll - */ -class format_topcoll_courseformatrenderer_testcase extends advanced_testcase { - - protected $outputus; - protected $course; - protected $courseformat; - - /** - * Call protected and private methods for the purpose of testing. - * - * @param stdClass $obj The object. - * @param string $name Name of the method. - * @param array $args Array of arguments if any, like Monty Python could be no minutes, ten, or even thirty. - * @return any What the method returns if anything, go, go on, look at the specification, you know you want to. - */ - protected static function call_method($obj, $name, array $args) { - // Ref: http://stackoverflow.com/questions/249664/best-practices-to-test-protected-methods-with-phpunit. - $class = new \ReflectionClass($obj); - $method = $class->getMethod($name); - $method->setAccessible(true); - return $method->invokeArgs($obj, $args); - } - - /** - * Set protected and private attributes for the purpose of testing. - * - * @param stdClass $obj The object. - * @param string $name Name of the method. - * @param any $value Value to set. - */ - protected static function set_property($obj, $name, $value) { - // Ref: http://stackoverflow.com/questions/18558183/phpunit-mockbuilder-set-mock-object-internal-property ish. - $class = new \ReflectionClass($obj); - $property = $class->getProperty($name); - $property->setAccessible(true); - $property->setValue($obj, $value); - } - - /** - * Get protected and private methods for the purpose of testing. - * - * @param stdClass $obj The object. - * @param string $name Name of the method. - */ - protected static function get_property($obj, $name) { - // Ref: http://stackoverflow.com/questions/18558183/phpunit-mockbuilder-set-mock-object-internal-property ish. - $class = new \ReflectionClass($obj); - $property = $class->getProperty($name); - $property->setAccessible(true); - return $property; - } - - protected function setUp() { - $this->resetAfterTest(true); - - global $PAGE; - $this->outputus = $PAGE->get_renderer('format_topcoll'); - // Ref: https://docs.moodle.org/dev/Writing_PHPUnit_tests. - $this->course = $this->getDataGenerator()->create_course(array('format' => 'topcoll', 'numsections' => 1), - array('createsections' => true)); - - $this->courseformat = course_get_format($this->course); - self::set_property($this->outputus, 'courseformat', $this->courseformat); - $target = self::get_property($this->outputus, 'target'); - $ouroutput = $PAGE->get_renderer('core', null, $target); - self::set_property($this->outputus, 'output', $ouroutput); - $tcsettings = $this->courseformat->get_settings(); - self::set_property($this->outputus, 'tcsettings', $tcsettings); - } - - public function test_start_section_list() { - $theclass = self::call_method($this->outputus, 'start_section_list', - array()); - $thevalue = '
    '; - - $this->assertEquals($thevalue, $theclass); - } - - public function test_start_toggle_section_list() { - // With defaults unchanged. - $theclass = self::call_method($this->outputus, 'start_toggle_section_list', - array()); - $thevalue = '
      '; - - $this->assertEquals($thevalue, $theclass); - } - - public function test_page_title() { - // With defaults unchanged. - $theclass = self::call_method($this->outputus, 'page_title', array()); - $thevalue = 'Section'; - - $this->assertEquals($thevalue, $theclass); - } - - public function test_section_right_content() { - // With defaults unchanged. - $section = $this->courseformat->get_section(1); - $onsectionpage = false; - $theclass = self::call_method($this->outputus, 'section_right_content', - array($section, $this->course, $onsectionpage)); - $thevalue = 'Topic
      1
      '; - $this->assertEquals($thevalue, $theclass); - - $onsectionpage = true; - $theclass = self::call_method($this->outputus, 'section_right_content', - array($section, $this->course, $onsectionpage)); - $thevalue = 'Topic
      1
      '; - $this->assertEquals($thevalue, $theclass); - } - - public function test_section_left_content() { - $section = $this->courseformat->get_section(1); - $onsectionpage = false; - $theclass = self::call_method($this->outputus, 'section_left_content', - array($section, $this->course, $onsectionpage)); - $thevalue = '1'; - $this->assertEquals($thevalue, $theclass); - - $onsectionpage = true; - $theclass = self::call_method($this->outputus, 'section_left_content', - array($section, $this->course, $onsectionpage)); - $thevalue = '1'; - $this->assertEquals($thevalue, $theclass); - } - - public function test_section_summary() { - $section = $this->courseformat->get_section(1); - $theclass = self::call_method($this->outputus, 'section_summary', - array($section, $this->course, null)); - $thevalue = '
    • '; - $thevalue .= '

      Section 1

    • '; - - $this->assertEquals($thevalue, $theclass); - } - - public function test_section_header() { - $section = $this->courseformat->get_section(1); - $section->toggle = false; - - $onsectionpage = false; - $theclass = self::call_method($this->outputus, 'section_header', - array($section, $this->course, $onsectionpage)); - $thevalue = '
    • '; - $thevalue .= '
      1
      '; - $thevalue .= 'Topic
      1
      '; - $thevalue .= ''; - $thevalue .= '
      '; - $this->assertEquals($thevalue, $theclass); - - $onsectionpage = true; - $theclass = self::call_method($this->outputus, 'section_header', - array($section, $this->course, $onsectionpage)); - $thevalue = '
    • '; - $thevalue .= '
      1
      assertEquals($thevalue, $theclass); - } - - public function test_stealth_section_header() { - $theclass = self::call_method($this->outputus, 'stealth_section_header', - array(1)); - $thevalue = '
    • '; - - $this->assertEquals($thevalue, $theclass); - } - - public function test_print_multiple_section_page() { - self::call_method($this->outputus, 'print_multiple_section_page', - array($this->course, null, null, null, null, null)); - $theoutput = '

      Section

        '; - $this->expectOutputString($theoutput); - } - - public function test_toggle_all() { - $theclass = self::call_method($this->outputus, 'toggle_all', array()); - $thevalue = '
      • assertEquals($thevalue, $theclass); - } - - public function test_display_instructions() { - $theclass = self::call_method($this->outputus, 'display_instructions', array()); - $thevalue = '
      • '; - $thevalue .= '
        '; - $thevalue .= '
        '; - $thevalue .= '

        Instructions: Clicking on the section '; - $thevalue .= 'name will show / hide the section.

      • '; - - $this->assertEquals($thevalue, $theclass); - } +. + +/** + * Collapsed Topics course format. + * + * @package course/format + * @subpackage topcoll + * @version See the value of '$plugin->version' in below. + * @copyright © 2015-onwards G J Barnard in respect to modifications of standard topics format. + * @author G J Barnard - gjbarnard at gmail dot com, {@link http://about.me/gjbarnard} and + * {@link http://moodle.org/user/profile.php?id=442195} + * @link http://docs.moodle.org/en/Collapsed_Topics_course_format + * @license http://www.gnu.org/copyleft/gpl.html GNU Public License + */ + +/** + * Renderer unit tests for the Collapsed Topics course format. + * @group format_topcoll + */ +class format_topcoll_courseformatrenderer_testcase extends advanced_testcase { + + protected $outputus; + protected $course; + protected $courseformat; + + /** + * Call protected and private methods for the purpose of testing. + * + * @param stdClass $obj The object. + * @param string $name Name of the method. + * @param array $args Array of arguments if any, like Monty Python could be no minutes, ten, or even thirty. + * @return any What the method returns if anything, go, go on, look at the specification, you know you want to. + */ + protected static function call_method($obj, $name, array $args) { + // Ref: http://stackoverflow.com/questions/249664/best-practices-to-test-protected-methods-with-phpunit. + $class = new \ReflectionClass($obj); + $method = $class->getMethod($name); + $method->setAccessible(true); + return $method->invokeArgs($obj, $args); + } + + /** + * Set protected and private attributes for the purpose of testing. + * + * @param stdClass $obj The object. + * @param string $name Name of the method. + * @param any $value Value to set. + */ + protected static function set_property($obj, $name, $value) { + // Ref: http://stackoverflow.com/questions/18558183/phpunit-mockbuilder-set-mock-object-internal-property ish. + $class = new \ReflectionClass($obj); + $property = $class->getProperty($name); + $property->setAccessible(true); + $property->setValue($obj, $value); + } + + /** + * Get protected and private methods for the purpose of testing. + * + * @param stdClass $obj The object. + * @param string $name Name of the method. + */ + protected static function get_property($obj, $name) { + // Ref: http://stackoverflow.com/questions/18558183/phpunit-mockbuilder-set-mock-object-internal-property ish. + $class = new \ReflectionClass($obj); + $property = $class->getProperty($name); + $property->setAccessible(true); + return $property; + } + + protected function setUp() { + $this->resetAfterTest(true); + + global $PAGE; + $this->outputus = $PAGE->get_renderer('format_topcoll'); + // Ref: https://docs.moodle.org/dev/Writing_PHPUnit_tests. + $this->course = $this->getDataGenerator()->create_course(array('format' => 'topcoll', 'numsections' => 1), + array('createsections' => true)); + + $this->courseformat = course_get_format($this->course); + self::set_property($this->outputus, 'courseformat', $this->courseformat); + $target = self::get_property($this->outputus, 'target'); + $ouroutput = $PAGE->get_renderer('core', null, $target); + self::set_property($this->outputus, 'output', $ouroutput); + $tcsettings = $this->courseformat->get_settings(); + self::set_property($this->outputus, 'tcsettings', $tcsettings); + } + + public function test_start_section_list() { + $theclass = self::call_method($this->outputus, 'start_section_list', + array()); + $thevalue = '
          '; + + $this->assertEquals($thevalue, $theclass); + } + + public function test_start_toggle_section_list() { + // With defaults unchanged. + $theclass = self::call_method($this->outputus, 'start_toggle_section_list', + array()); + $thevalue = '
            '; + + $this->assertEquals($thevalue, $theclass); + } + + public function test_page_title() { + // With defaults unchanged. + $theclass = self::call_method($this->outputus, 'page_title', array()); + $thevalue = 'Section'; + + $this->assertEquals($thevalue, $theclass); + } + + public function test_section_right_content() { + // With defaults unchanged. + $section = $this->courseformat->get_section(1); + $onsectionpage = false; + $theclass = self::call_method($this->outputus, 'section_right_content', + array($section, $this->course, $onsectionpage)); + $thevalue = 'Topic
            1
            '; + $this->assertEquals($thevalue, $theclass); + + $onsectionpage = true; + $theclass = self::call_method($this->outputus, 'section_right_content', + array($section, $this->course, $onsectionpage)); + $thevalue = 'Topic
            1
            '; + $this->assertEquals($thevalue, $theclass); + } + + public function test_section_left_content() { + $section = $this->courseformat->get_section(1); + $onsectionpage = false; + $theclass = self::call_method($this->outputus, 'section_left_content', + array($section, $this->course, $onsectionpage)); + $thevalue = '1'; + $this->assertEquals($thevalue, $theclass); + + $onsectionpage = true; + $theclass = self::call_method($this->outputus, 'section_left_content', + array($section, $this->course, $onsectionpage)); + $thevalue = '1'; + $this->assertEquals($thevalue, $theclass); + } + + public function test_section_summary() { + $section = $this->courseformat->get_section(1); + $theclass = self::call_method($this->outputus, 'section_summary', + array($section, $this->course, null)); + $thevalue = '
          • '; + $thevalue .= '

            Section 1

          • '; + + $this->assertEquals($thevalue, $theclass); + } + + public function test_section_header() { + $section = $this->courseformat->get_section(1); + $section->toggle = false; + + $onsectionpage = false; + $theclass = self::call_method($this->outputus, 'section_header', + array($section, $this->course, $onsectionpage)); + $thevalue = '
          • '; + $thevalue .= '
            1
            '; + $thevalue .= 'Topic
            1
            '; + $thevalue .= ''; + $thevalue .= '
            '; + $this->assertEquals($thevalue, $theclass); + + $onsectionpage = true; + $theclass = self::call_method($this->outputus, 'section_header', + array($section, $this->course, $onsectionpage)); + $thevalue = '
          • '; + $thevalue .= '
            1
            assertEquals($thevalue, $theclass); + } + + public function test_stealth_section_header() { + $theclass = self::call_method($this->outputus, 'stealth_section_header', + array(1)); + $thevalue = '
          • '; + + $this->assertEquals($thevalue, $theclass); + } + + public function test_print_multiple_section_page() { + self::call_method($this->outputus, 'print_multiple_section_page', + array($this->course, null, null, null, null, null)); + $theoutput = '

            Section

              '; + $this->expectOutputString($theoutput); + } + + public function test_toggle_all() { + $theclass = self::call_method($this->outputus, 'toggle_all', array()); + $thevalue = '
            • assertEquals($thevalue, $theclass); + } + + public function test_display_instructions() { + $theclass = self::call_method($this->outputus, 'display_instructions', array()); + $thevalue = '
            • '; + $thevalue .= '
              '; + $thevalue .= '
              '; + $thevalue .= '

              Instructions: Clicking on the section '; + $thevalue .= 'name will show / hide the section.

            • '; + + $this->assertEquals($thevalue, $theclass); + } } \ No newline at end of file diff --git a/togglelib.php b/togglelib.php index 0a9a9015..ee60a345 100644 --- a/togglelib.php +++ b/togglelib.php @@ -244,8 +244,6 @@ function required_topcoll_param($parname) { * @throws coding_exception */ function clean_topcoll_param($param) { - global $CFG; - if (is_array($param)) { throw new coding_exception('clean_topcoll_param() can not process arrays.'); } else if (is_object($param)) { diff --git a/version.php b/version.php index 44fe5ca8..6011f9ed 100644 --- a/version.php +++ b/version.php @@ -34,8 +34,8 @@ */ defined('MOODLE_INTERNAL') || die(); -$plugin->version = 2015103003; +$plugin->version = 2015103004; $plugin->maturity = MATURITY_STABLE; $plugin->requires = 2015111600.00; // 3.0 (Build: 20151116). $plugin->component = 'format_topcoll'; -$plugin->release = '3.0.1'; +$plugin->release = '3.0.2';