diff --git a/ATL/CHANGEDB.php b/ATL/CHANGEDB.php index 8b0abe5..7ce010c 100644 --- a/ATL/CHANGEDB.php +++ b/ATL/CHANGEDB.php @@ -1,143 +1,173 @@ - - 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. - - {one line to give the program's name and a brief idea of what it does.} - Copyright (C) {year} {name of author} - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 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: - - {project} Copyright (C) {year} {fullname} - 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. + + {one line to give the program's name and a brief idea of what it does.} + Copyright (C) {year} {name of author} + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 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: + + {project} Copyright (C) {year} {fullname} + 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/ATL/README.md b/ATL/README.md index 973c4ea..2b7d8fd 100644 --- a/ATL/README.md +++ b/ATL/README.md @@ -1,29 +1,29 @@ -# ATL (Approaches To Learning) - -Module of [Gibbon][gibbon]. Allows schools to run a program of Approaches To -Learning assessments, based on a rubric. - -[gibbon]: https://gibbonedu.org - -## Installation & Support - -To install, just copy this folder into `GIBBON_HOME/modules` so that this file -exists: `GIBBON_HOME/modules/Alumni/manifest.php`. - -For support visit [https://gibbonedu.org/support](https://gibbonedu.org/support). - -## Compatibility - -* v1.4.00 only supports Gibbon v17+ -* v1.3.00 supports Gibbon v16 - -## Latest Source Code - -This module is developed on [GitHub][repo-url]. - -[repo-url]: https://github.com/GibbonEdu/module-ATL - -## License - -This module is licensed to the GPLv3. You may obtain a copy of the license in -this repository [here](LICENSE). +# ATL (Approaches To Learning) + +Module of [Gibbon][gibbon]. Allows schools to run a program of Approaches To +Learning assessments, based on a rubric. + +[gibbon]: https://gibbonedu.org + +## Installation & Support + +To install, just copy this folder into `GIBBON_HOME/modules` so that this file +exists: `GIBBON_HOME/modules/Alumni/manifest.php`. + +For support visit [https://gibbonedu.org/support](https://gibbonedu.org/support). + +## Compatibility + +* v1.4.00 only supports Gibbon v17+ +* v1.3.00 supports Gibbon v16 + +## Latest Source Code + +This module is developed on [GitHub][repo-url]. + +[repo-url]: https://github.com/GibbonEdu/module-ATL + +## License + +This module is licensed to the GPLv3. You may obtain a copy of the license in +this repository [here](LICENSE). diff --git a/ATL/atl_manage.php b/ATL/atl_manage.php index 30dfb84..8d007c3 100644 --- a/ATL/atl_manage.php +++ b/ATL/atl_manage.php @@ -1,163 +1,123 @@ -. -*/ - -use Gibbon\Services\Format; -use Gibbon\Module\ATL\Domain\ATLColumnGateway; -use Gibbon\Domain\DataSet; -use Gibbon\Tables\DataTable; - -//Module includes -include './modules/'.$session->get('module').'/moduleFunctions.php'; - -if (isActionAccessible($guid, $connection2, '/modules/ATL/atl_manage.php') == false) { - //Acess denied - $page->addError(__('You do not have access to this action.')); -} else { - //Get action with highest precendence - $highestAction = getHighestGroupedAction($guid, $_GET['q'], $connection2); - if ($highestAction == false) { - $page->addError(__('The highest grouped action cannot be determined.')); - } else { - //Get class variable - $gibbonCourseClassID = null; - if (isset($_GET['gibbonCourseClassID'])) { - $gibbonCourseClassID = $_GET['gibbonCourseClassID']; - } else { - try { - $data = array('gibbonPersonID' => $session->get('gibbonPersonID')); - $sql = "SELECT gibbonCourse.nameShort AS course, gibbonCourseClass.nameShort AS class, gibbonCourseClass.gibbonCourseClassID FROM gibbonCourse, gibbonCourseClass, gibbonCourseClassPerson WHERE gibbonCourse.gibbonCourseID=gibbonCourseClass.gibbonCourseID AND gibbonCourseClass.gibbonCourseClassID=gibbonCourseClassPerson.gibbonCourseClassID AND gibbonCourseClassPerson.gibbonPersonID=:gibbonPersonID AND gibbonCourse.gibbonSchoolYearID=(SELECT gibbonSchoolYearID FROM gibbonSchoolYear WHERE status='Current') AND gibbonCourseClass.reportable='Y' ORDER BY course, class"; - $result = $connection2->prepare($sql); - $result->execute($data); - } catch (PDOException $e) { - echo "
".$e->getMessage().'
'; - } - if ($result->rowCount() > 0) { - $row = $result->fetch(); - $gibbonCourseClassID = $row['gibbonCourseClassID']; - } - } - if ($gibbonCourseClassID == '') { - echo '

'; - echo 'Manage ATL'; - echo '

'; - echo "
"; - echo __('Use the class listing on the right to choose a ATL to edit.'); - echo '
'; - } else { - //Check existence of and access to this class. - try { - $data = array('gibbonCourseClassID' => $gibbonCourseClassID); - $sql = 'SELECT gibbonCourse.nameShort AS course, gibbonCourseClass.nameShort AS class, gibbonCourseClass.gibbonCourseClassID FROM gibbonCourse, gibbonCourseClass WHERE gibbonCourse.gibbonCourseID=gibbonCourseClass.gibbonCourseID AND gibbonCourseClass.gibbonCourseClassID=:gibbonCourseClassID ORDER BY course, class'; - $result = $connection2->prepare($sql); - $result->execute($data); - } catch (PDOException $e) { - echo "
".$e->getMessage().'
'; - } - - if ($result->rowCount() != 1) { - echo '

'; - echo __('Manage ATL'); - echo '

'; - echo "
"; - echo __('The selected record does not exist, or you do not have access to it.'); - echo '
'; - } else { - $row = $result->fetch(); - $page->breadcrumbs->add(__('Manage {courseClass} ATLs', ['courseClass' => $row['course'].'.'.$row['class']])); - - if (isset($_GET['deleteReturn'])) { - $deleteReturn = $_GET['deleteReturn']; - } else { - $deleteReturn = ''; - } - $deleteReturnMessage = ''; - $class = 'error'; - if (!($deleteReturn == '')) { - if ($deleteReturn == 'success0') { - $deleteReturnMessage = __('Your request was completed successfully.'); - $class = 'success'; - } - echo "
"; - echo $deleteReturnMessage; - echo '
'; - } - - //Add multiple columns - echo "'; - - //Get teacher list - $teaching = false; - try { - $data = array('gibbonCourseClassID' => $gibbonCourseClassID); - $sql = "SELECT gibbonPerson.gibbonPersonID, title, surname, preferredName, gibbonCourseClassPerson.reportable FROM gibbonCourseClassPerson JOIN gibbonPerson ON (gibbonCourseClassPerson.gibbonPersonID=gibbonPerson.gibbonPersonID) WHERE (role='Teacher' OR role='Assistant') AND gibbonCourseClassID=:gibbonCourseClassID ORDER BY surname, preferredName"; - $result = $connection2->prepare($sql); - $result->execute($data); - } catch (PDOException $e) { - echo "
".$e->getMessage().'
'; - } - if ($result->rowCount() > 0) { - echo '

'; - echo __('Teachers'); - echo '

'; - echo '
    '; - while ($row = $result->fetch()) { - if ($row['reportable'] != 'Y') continue; - - echo '
  • '.Format::name($row['title'], $row['preferredName'], $row['surname'], 'Staff').'
  • '; - if ($row['gibbonPersonID'] == $session->get('gibbonPersonID')) { - $teaching = true; - } - } - echo '
'; - } - //TABLE - $atlColumnGateway = $container->get(ATLColumnGateway::class); - $atlColumnData = $atlColumnGateway->selectBy(['gibbonCourseClassID' => $gibbonCourseClassID])->fetchAll(); - - $table = DataTable::create('atlColumns'); - $table->setTitle('ATL Columns'); - - $table->addColumn('name', __('Name')); - $table->addColumn('completeDate', __('Date Complete')); - $table->addActionColumn() - ->addParam('gibbonCourseClassID', $gibbonCourseClassID) - ->addParam('atlColumnID') - ->format(function ($row, $actions) use ($session) { - $actions->addAction('edit', __('Edit')) - ->setURL('/modules/' . $session->get('module') . '/atl_manage_edit.php'); - - $actions->addAction('delete', __('Delete')) - ->setURL('/modules/' . $session->get('module') . '/atl_manage_delete.php'); - - $actions->addAction('enterData', __('Enter Data')) - ->setURL('/modules/' . $session->get('module') . '/atl_write_data.php') - ->setIcon('markbook'); - - }); - - echo $table->render($atlColumnData); - } - } - } - - //Print sidebar - $session->set('sidebarExtra', sidebarExtra($guid, $connection2, $gibbonCourseClassID, 'manage', $highestAction)); -} +. +*/ + +use Gibbon\Services\Format; +use Gibbon\Module\ATL\Domain\ATLColumnGateway; +use Gibbon\Domain\Timetable\CourseGateway; +use Gibbon\Domain\DataSet; +use Gibbon\Tables\DataTable; + +//Module includes +require_once __DIR__ . '/moduleFunctions.php'; + +if (isActionAccessible($guid, $connection2, '/modules/ATL/atl_manage.php') == false) { + //Acess denied + $page->addError(__('You do not have access to this action.')); +} else { + //Get class variable + $gibbonCourseClassID = $_GET['gibbonCourseClassID'] ?? ''; + if (empty($gibbonCourseClassID)) { + try { + $data = array('gibbonPersonID' => $session->get('gibbonPersonID')); + $sql = "SELECT gibbonCourse.nameShort AS course, gibbonCourseClass.nameShort AS class, gibbonCourseClass.gibbonCourseClassID FROM gibbonCourse, gibbonCourseClass, gibbonCourseClassPerson WHERE gibbonCourse.gibbonCourseID=gibbonCourseClass.gibbonCourseID AND gibbonCourseClass.gibbonCourseClassID=gibbonCourseClassPerson.gibbonCourseClassID AND gibbonCourseClassPerson.gibbonPersonID=:gibbonPersonID AND gibbonCourse.gibbonSchoolYearID=(SELECT gibbonSchoolYearID FROM gibbonSchoolYear WHERE status='Current') AND gibbonCourseClass.reportable='Y' ORDER BY course, class"; + $result = $connection2->prepare($sql); + $result->execute($data); + } catch (PDOException $e) { + echo "
".$e->getMessage().'
'; + } + if ($result->rowCount() > 0) { + $row = $result->fetch(); + $gibbonCourseClassID = $row['gibbonCourseClassID']; + } + } + + echo '

'; + echo __('Manage ATLs'); + echo '

'; + + $courseGateway = $container->get(CourseGateway::class); + $class = $courseGateway->getCourseClassByID($gibbonCourseClassID); + if (empty($class)) { + $page->breadcrumbs->add(__('Manage ATLs')); + echo Format::alert(__('Use the class listing on the right to choose a ATL to edit.'), 'warning'); + } else { + $page->breadcrumbs->add(__('Manage {courseClass} ATLs', ['courseClass' => $class['courseName'].'.'.$class['name']])); + + //Get teacher list + try { + $data = array('gibbonCourseClassID' => $gibbonCourseClassID); + $sql = "SELECT gibbonPerson.gibbonPersonID, title, surname, preferredName, gibbonCourseClassPerson.reportable FROM gibbonCourseClassPerson JOIN gibbonPerson ON (gibbonCourseClassPerson.gibbonPersonID=gibbonPerson.gibbonPersonID) WHERE (role='Teacher' OR role='Assistant') AND gibbonCourseClassID=:gibbonCourseClassID ORDER BY surname, preferredName"; + $result = $connection2->prepare($sql); + $result->execute($data); + } catch (PDOException $e) { + echo "
".$e->getMessage().'
'; + } + if ($result->rowCount() > 0) { + echo '

'; + echo __('Teachers'); + echo '

'; + echo '
    '; + while ($row = $result->fetch()) { + if ($row['reportable'] != 'Y') continue; + + echo '
  • '.Format::name($row['title'], $row['preferredName'], $row['surname'], 'Staff').'
  • '; + } + echo '
'; + } + //TABLE + $atlColumnGateway = $container->get(ATLColumnGateway::class); + $atlColumnData = $atlColumnGateway->selectBy(['gibbonCourseClassID' => $gibbonCourseClassID])->fetchAll(); + + $table = DataTable::create('atlColumns'); + $table->setTitle('ATL Columns'); + + $table->addHeaderAction('add', __('Add Multiple Columns')) + ->displayLabel() + ->addParam('gibbonCourseClassID', $gibbonCourseClassID) + ->setURL('/modules/ATL/atl_manage_add.php') + ->setIcon('page_new_multi'); + + $table->addColumn('name', __('Name')); + $table->addColumn('completeDate', __('Date Complete')); + $table->addColumn('forStudents', __('For Students?')) + ->format(Format::using('yesNo', ['forStudents'])); + $table->addActionColumn() + ->addParam('gibbonCourseClassID', $gibbonCourseClassID) + ->addParam('atlColumnID') + ->format(function ($row, $actions) use ($session) { + $actions->addAction('edit', __('Edit')) + ->setURL('/modules/' . $session->get('module') . '/atl_manage_edit.php'); + + $actions->addAction('delete', __('Delete')) + ->setURL('/modules/' . $session->get('module') . '/atl_manage_delete.php'); + + if ($row['forStudents'] == 'N') { + $actions->addAction('enterData', __('Enter Data')) + ->setURL('/modules/' . $session->get('module') . '/atl_write_data.php') + ->setIcon('markbook'); + } + + }); + + echo $table->render($atlColumnData); + } + + //Print sidebar + $session->set('sidebarExtra', sidebarExtra($gibbonCourseClassID, 'manage')); +} diff --git a/ATL/atl_manage_add.php b/ATL/atl_manage_add.php index e6bb90f..27fd49f 100644 --- a/ATL/atl_manage_add.php +++ b/ATL/atl_manage_add.php @@ -1,119 +1,124 @@ -. -*/ - -use Gibbon\Forms\Form; - -//Module includes -include './modules/'.$session->get('module').'/moduleFunctions.php'; - -if (isActionAccessible($guid, $connection2, '/modules/ATL/atl_manage_add.php') == false) { - //Acess denied - $page->addError(__('You do not have access to this action.')); -} else { - $gibbonCourseClassID = $_GET['gibbonCourseClassID'] ?? ''; - if ($gibbonCourseClassID == '') { - $page->addError(__('You have not specified one or more required parameters.')); - } else { - try { - $data = array('gibbonCourseClassID' => $gibbonCourseClassID); - $sql = "SELECT gibbonCourse.nameShort AS course, gibbonCourseClass.nameShort AS class, gibbonCourseClass.gibbonCourseClassID, gibbonCourse.gibbonDepartmentID, gibbonYearGroupIDList FROM gibbonCourse, gibbonCourseClass WHERE gibbonCourse.gibbonCourseID=gibbonCourseClass.gibbonCourseID AND gibbonCourseClass.gibbonCourseClassID=:gibbonCourseClassID AND gibbonCourseClass.reportable='Y' ORDER BY course, class"; - $result = $connection2->prepare($sql); - $result->execute($data); - } catch (PDOException $e) { - echo "
".$e->getMessage().'
'; - } - - if ($result->rowCount() != 1) { - $page->addError(__('The selected record does not exist, or you do not have access to it.')); - } else { - $class = $result->fetch(); - - $page->breadcrumbs - ->add(__('Manage {courseClass} ATLs', ['courseClass' => $class['course'].'.'.$class['class']]), 'atl_manage.php', ['gibbonCourseClassID' => $gibbonCourseClassID]) - ->add(__('Add Multiple Columns')); - - if (isset($_GET['return'])) { - returnProcess($guid, $_GET['return'], null, null); - } - - $form = Form::create('ATL', $session->get('absoluteURL').'/modules/ATL/atl_manage_addProcess.php?gibbonCourseClassID='.$gibbonCourseClassID.'&address='.$session->get('address')); - $form->addHiddenValue('address', $session->get('address')); - - $form->addRow()->addHeading(__('Basic Information')); - - $data = array('gibbonSchoolYearID' => $session->get('gibbonSchoolYearID')); - $sql = "SELECT gibbonYearGroup.name as groupBy, gibbonCourseClassID as value, CONCAT(gibbonCourse.nameShort, '.', gibbonCourseClass.nameShort) AS name FROM gibbonCourseClass JOIN gibbonCourse ON (gibbonCourseClass.gibbonCourseID=gibbonCourse.gibbonCourseID) JOIN gibbonYearGroup ON (gibbonCourse.gibbonYearGroupIDList LIKE concat( '%', gibbonYearGroup.gibbonYearGroupID, '%' )) WHERE gibbonSchoolYearID=:gibbonSchoolYearID AND gibbonCourseClass.reportable='Y' ORDER BY gibbonYearGroup.sequenceNumber, name"; - - $row = $form->addRow(); - $row->addLabel('gibbonCourseClassIDMulti', __('Class')); - $row->addSelect('gibbonCourseClassIDMulti') - ->fromQuery($pdo, $sql, $data, 'groupBy') - ->selectMultiple() - ->isRequired() - ->selected($gibbonCourseClassID); - - $row = $form->addRow(); - $row->addLabel('name', __('Name')); - $row->addTextField('name')->isRequired()->maxLength(20); - - $row = $form->addRow(); - $row->addLabel('description', __('Description')); - $row->addTextField('description')->isRequired()->maxLength(1000); - - $form->addRow()->addHeading(__('Assessment')); - - $data = array('gibbonYearGroupIDList' => $class['gibbonYearGroupIDList'], 'gibbonDepartmentID' => $class['gibbonDepartmentID'], 'rubrics' => __('Rubrics')); - $sql = "SELECT CONCAT(scope, ' ', :rubrics) as groupBy, gibbonRubricID as value, - (CASE WHEN category <> '' THEN CONCAT(category, ' - ', gibbonRubric.name) ELSE gibbonRubric.name END) as name - FROM gibbonRubric - JOIN gibbonYearGroup ON (FIND_IN_SET(gibbonYearGroup.gibbonYearGroupID, gibbonRubric.gibbonYearGroupIDList)) - WHERE gibbonRubric.active='Y' - AND FIND_IN_SET(gibbonYearGroup.gibbonYearGroupID, :gibbonYearGroupIDList) - AND (scope='School' OR (scope='Learning Area' AND gibbonDepartmentID=:gibbonDepartmentID)) - GROUP BY gibbonRubric.gibbonRubricID - ORDER BY scope, category, name"; - - $row = $form->addRow(); - $row->addLabel('gibbonRubricID', __('Rubric')); - $rubrics = $row->addSelect('gibbonRubricID')->fromQuery($pdo, $sql, $data, 'groupBy')->placeholder(); - - // Look for and select an Approach to Learning rubric - $rubrics->selected(array_reduce($rubrics->getOptions(), function ($result, $items) { - foreach ($items as $key => $value) { - $result = (stripos($value, 'Approach to Learning') === false) ? $result : $key; - } - return $result; - }, false)); - - $form->addRow()->addHeading(__('Access')); - - $row = $form->addRow(); - $row->addLabel('completeDate', __('Go Live Date'))->prepend('1. ')->append('
'.__('2. Column is hidden until date is reached.')); - $row->addDate('completeDate'); - - $row = $form->addRow(); - $row->addFooter(); - $row->addSubmit(); - - echo $form->getOutput(); - } - } - //Print sidebar - $session->set('sidebarExtra', sidebarExtra($guid, $connection2, $gibbonCourseClassID, 'manage', 'Manage ATLs_all')); -} +. +*/ + +use Gibbon\Domain\Timetable\CourseGateway; +use Gibbon\Forms\DatabaseFormFactory; +use Gibbon\Forms\Form; +use Gibbon\Services\Format; + +//Module includes +require_once __DIR__ . '/moduleFunctions.php'; + +if (isActionAccessible($guid, $connection2, '/modules/ATL/atl_manage_add.php') == false) { + //Acess denied + $page->addError(__('You do not have access to this action.')); +} else { + $gibbonCourseClassID = $_GET['gibbonCourseClassID'] ?? ''; + if ($gibbonCourseClassID == '') { + $page->addError(__('You have not specified one or more required parameters.')); + } else { + //TODO: Implement this when the function returns reportable, or has reportable flag + //$courseGateway = $container->get(CourseGateway::class); + //$class = $courseGateway->getCourseClassByID($gibbonCourseClassID); + try { + $data = array('gibbonCourseClassID' => $gibbonCourseClassID); + $sql = "SELECT gibbonCourse.nameShort AS course, gibbonCourseClass.nameShort AS class, gibbonCourseClass.gibbonCourseClassID, gibbonCourse.gibbonDepartmentID, gibbonYearGroupIDList FROM gibbonCourse, gibbonCourseClass WHERE gibbonCourse.gibbonCourseID=gibbonCourseClass.gibbonCourseID AND gibbonCourseClass.gibbonCourseClassID=:gibbonCourseClassID AND gibbonCourseClass.reportable='Y' ORDER BY course, class"; + $result = $connection2->prepare($sql); + $result->execute($data); + } catch (PDOException $e) { + $page->addError(__('A database error has occured.')); + } + + if ($result->rowCount() != 1) { + $page->addError(__('The selected record does not exist, or you do not have access to it.')); + } else { + $class = $result->fetch(); + + $page->breadcrumbs + ->add(__('Manage {courseClass} ATLs', ['courseClass' => Format::courseClassName($class['course'], $class['class'])]), 'atl_manage.php', ['gibbonCourseClassID' => $gibbonCourseClassID]) + ->add(__('Add Multiple Columns')); + + $form = Form::create('ATL', $session->get('absoluteURL').'/modules/ATL/atl_manage_addProcess.php'); + $form->setFactory(DatabaseFormFactory::create($pdo)); + $form->addHiddenValue('address', $session->get('address')); + $form->addHiddenValue('gibbonCourseClassID', $gibbonCourseClassID); + + $form->addRow()->addHeading(__('Basic Information')); + + $data = array('gibbonSchoolYearID' => $session->get('gibbonSchoolYearID')); + $sql = "SELECT gibbonYearGroup.name as groupBy, gibbonCourseClassID as value, CONCAT(gibbonCourse.nameShort, '.', gibbonCourseClass.nameShort) AS name FROM gibbonCourseClass JOIN gibbonCourse ON (gibbonCourseClass.gibbonCourseID=gibbonCourse.gibbonCourseID) JOIN gibbonYearGroup ON (gibbonCourse.gibbonYearGroupIDList LIKE concat( '%', gibbonYearGroup.gibbonYearGroupID, '%' )) WHERE gibbonSchoolYearID=:gibbonSchoolYearID AND gibbonCourseClass.reportable='Y' ORDER BY name"; + + $row = $form->addRow(); + $col = $row->addColumn(); + $col->addLabel('gibbonCourseClassIDMulti', __('Class')); + $multiSelect = $col->addMultiSelect('gibbonCourseClassIDMulti') + ->isRequired(); + + $multiSelect + ->source() + ->fromQuery($pdo, $sql, $data, 'nogroupBy') + ->selected($gibbonCourseClassID); + + //TODO: This should probably be core functionality + $multiSelect->destination()->fromArray(array_fill_keys(array_keys($multiSelect->source()->getOptions()), [])); + + $row = $form->addRow(); + $row->addLabel('name', __('Name')); + $row->addTextField('name')->isRequired()->maxLength(20); + + $row = $form->addRow(); + $row->addLabel('description', __('Description')); + $row->addTextField('description')->isRequired()->maxLength(1000); + + $form->addRow()->addHeading(__('Assessment')); + + $row = $form->addRow(); + $row->addLabel('gibbonRubricID', __('Rubric')); + $rubrics = $row->addSelectRubric('gibbonRubricID', $class['gibbonYearGroupIDList'], $class['gibbonDepartmentID']); + + // Look for and select an Approach to Learning rubric + $rubrics->selected(array_reduce($rubrics->getOptions(), function ($result, $items) { + foreach ($items as $key => $value) { + $result = (stripos($value, 'Approach to Learning') === false) ? $result : $key; + } + return $result; + }, false)); + + $form->addRow()->addHeading(__('Access')); + + $row = $form->addRow(); + $row->addLabel('completeDate', __('Go Live Date'))->prepend('1. ')->append('
'.__('2. Column is hidden until date is reached.'))->append('
'.__('3. This will act as a due date if for students.')); + $row->addDate('completeDate'); + + $row = $form->addRow(); + $row->addLabel('forStudents', __('For Students?'))->description(__('Is this column meant to be filled out by students?')); + $row->addYesNo('forStudents') + ->selected('N') + ->required(); + + $row = $form->addRow(); + $row->addFooter(); + $row->addSubmit(); + + echo $form->getOutput(); + } + } + //Print sidebar + $session->set('sidebarExtra', sidebarExtra($gibbonCourseClassID, 'manage')); +} diff --git a/ATL/atl_manage_addProcess.php b/ATL/atl_manage_addProcess.php index 18bc895..427db6c 100644 --- a/ATL/atl_manage_addProcess.php +++ b/ATL/atl_manage_addProcess.php @@ -1,123 +1,95 @@ -. -*/ - -include '../../gibbon.php'; - - -$gibbonCourseClassID = $_GET['gibbonCourseClassID']; -$URL = $session->get('absoluteURL').'/index.php?q=/modules/'.getModuleName($_GET['address'])."/atl_manage_add.php&gibbonCourseClassID=$gibbonCourseClassID"; - -if (isActionAccessible($guid, $connection2, '/modules/ATL/atl_manage_add.php') == false) { - //Fail 0 - $URL .= '&return=error0'; - header("Location: {$URL}"); -} else { - if (empty($_POST)) { - $URL .= '&return=error5'; - header("Location: {$URL}"); - } else { - //Proceed! - //Validate Inputs - $gibbonCourseClassIDMulti = null; - if (isset($_POST['gibbonCourseClassIDMulti'])) { - $gibbonCourseClassIDMulti = $_POST['gibbonCourseClassIDMulti']; - $gibbonCourseClassIDMulti = array_unique($gibbonCourseClassIDMulti); - } - $name = $_POST['name']; - $description = $_POST['description']; - $gibbonRubricID = $_POST['gibbonRubricID']; - $completeDate = $_POST['completeDate']; - if ($completeDate == '') { - $completeDate = null; - $complete = 'N'; - } else { - $completeDate = dateConvert($guid, $completeDate); - $complete = 'Y'; - } - $gibbonPersonIDCreator = $session->get('gibbonPersonID'); - $gibbonPersonIDLastEdit = $session->get('gibbonPersonID'); - - //Lock markbook column table - try { - $sqlLock = 'LOCK TABLES atlColumn WRITE'; - $resultLock = $connection2->query($sqlLock); - } catch (PDOException $e) { - //Fail 2 - $URL .= '&return=error2'; - header("Location: {$URL}"); - exit(); - } - - //Get next groupingID - try { - $sqlGrouping = 'SELECT DISTINCT groupingID FROM atlColumn WHERE NOT groupingID IS NULL ORDER BY groupingID DESC'; - $resultGrouping = $connection2->query($sqlGrouping); - } catch (PDOException $e) { - //Fail 2 - $URL .= '&return=error2'; - header("Location: {$URL}"); - exit(); - } - - $rowGrouping = $resultGrouping->fetch(); - if (is_null($rowGrouping['groupingID'])) { - $groupingID = 1; - } else { - $groupingID = ($rowGrouping['groupingID'] + 1); - } - - if (is_array($gibbonCourseClassIDMulti) == false or is_numeric($groupingID) == false or $groupingID < 1 or $name == '' or $description == '') { - //Fail 3 - $URL .= '&return=error3'; - header("Location: {$URL}"); - } else { - $partialFail = false; - - foreach ($gibbonCourseClassIDMulti as $gibbonCourseClassIDSingle) { - //Write to database - try { - $data = array('groupingID' => $groupingID, 'gibbonCourseClassID' => $gibbonCourseClassIDSingle, 'name' => $name, 'description' => $description, 'gibbonRubricID' => $gibbonRubricID, 'completeDate' => $completeDate, 'complete' => $complete, 'gibbonPersonIDCreator' => $gibbonPersonIDCreator, 'gibbonPersonIDLastEdit' => $gibbonPersonIDLastEdit); - $sql = 'INSERT INTO atlColumn SET groupingID=:groupingID, gibbonCourseClassID=:gibbonCourseClassID, name=:name, description=:description, gibbonRubricID=:gibbonRubricID, completeDate=:completeDate, complete=:complete, gibbonPersonIDCreator=:gibbonPersonIDCreator, gibbonPersonIDLastEdit=:gibbonPersonIDLastEdit'; - $result = $connection2->prepare($sql); - $result->execute($data); - } catch (PDOException $e) { - //Fail 2 - $partialFail = true; - } - } - - //Unlock module table - try { - $sql = 'UNLOCK TABLES'; - $result = $connection2->query($sql); - } catch (PDOException $e) { - } - - if ($partialFail != false) { - //Success 0 - $URL .= '&return=error6'; - header("Location: {$URL}"); - } else { - //Success 0 - $URL .= '&return=success0'; - header("Location: {$URL}"); - } - } - } -} +. +*/ + +use Gibbon\Module\ATL\Domain\ATLColumnGateway; +use Gibbon\Module\ATL\Domain\ATLEntryGateway; +use Gibbon\Services\Format; + +include '../../gibbon.php'; + +$gibbonCourseClassID = $_POST['gibbonCourseClassID']; +$URL = $session->get('absoluteURL').'/index.php?q=/modules/ATL/'; + +if (isActionAccessible($guid, $connection2, '/modules/ATL/atl_manage_add.php') == false) { + //Fail 0 + $URL .= 'atl_manage.php&return=error0'; + header("Location: {$URL}"); +} else { + //Proceed! + $URL .= "atl_manage_add.php&gibbonCourseClassID=$gibbonCourseClassID"; + + //Validate Inputs + $gibbonCourseClassIDMulti = array_unique($_POST['gibbonCourseClassIDMulti']) ?? ''; + $name = $_POST['name'] ?? ''; + $description = $_POST['description'] ?? ''; + $gibbonRubricID = $_POST['gibbonRubricID'] ?? ''; + $completeDate = $_POST['completeDate'] ?? ''; + if ($completeDate == '') { + $completeDate = null; + $complete = 'N'; + } else { + $completeDate = Format::dateConvert($completeDate); + $complete = 'Y'; + } + $forStudents = $_POST['forStudents'] ?? ''; + $gibbonPersonIDCreator = $session->get('gibbonPersonID'); + $gibbonPersonIDLastEdit = $session->get('gibbonPersonID'); + + if (!is_array($gibbonCourseClassIDMulti) || empty($gibbonCourseClassIDMulti) || empty($name) || empty($description) || empty($forStudents)) { + //Fail 3 + $URL .= '&return=error1'; + header("Location: {$URL}"); + exit(); + } else { + $partialFail = false; + + $atlColumnGateway = $container->get(ATLColumnGateway::class); + $atlEntryGateway = $container->get(ATLEntryGateway::class); + + $data = [ + 'name' => $name, + 'description' => $description, + 'gibbonRubricID' => $gibbonRubricID, + 'completeDate' => $completeDate, + 'forStudents' => $forStudents, + 'complete' => $complete, + 'gibbonPersonIDCreator' => $gibbonPersonIDCreator, + 'gibbonPersonIDLastEdit' => $gibbonPersonIDLastEdit + ]; + + foreach ($gibbonCourseClassIDMulti as $gibbonCourseClassIDSingle) { + //Write to database + $data['gibbonCourseClassID'] = $gibbonCourseClassIDSingle; + $atlColumnID = $atlColumnGateway->insert($data); + if (!$atlColumnID) { + $partialFail = true; + } else { + $atlEntryGateway->createATLEntries($atlColumnID, $gibbonCourseClassIDSingle, $gibbonPersonIDCreator); + } + } + + if ($partialFail) { + $URL .= '&return=warning1'; + } else { + $URL .= '&return=success0'; + } + header("Location: {$URL}"); + exit(); + } +} diff --git a/ATL/atl_manage_delete.php b/ATL/atl_manage_delete.php index 7d5ae57..bcf3047 100644 --- a/ATL/atl_manage_delete.php +++ b/ATL/atl_manage_delete.php @@ -1,80 +1,47 @@ -. -*/ - -use Gibbon\Forms\Prefab\DeleteForm; - -//Module includes -include './modules/'.$session->get('module').'/moduleFunctions.php'; - -if (isActionAccessible($guid, $connection2, '/modules/ATL/atl_manage_delete.php') == false) { - //Acess denied - $page->addError(__('You do not have access to this action.')); -} else { - //Check if school year specified - $gibbonCourseClassID = $_GET['gibbonCourseClassID']; - $atlColumnID = $_GET['atlColumnID']; - if ($gibbonCourseClassID == '' or $atlColumnID == '') { - $page->addError(__('You have not specified one or more required parameters.'));; - } else { - try { - $data = array('gibbonCourseClassID' => $gibbonCourseClassID); - $sql = "SELECT gibbonCourse.nameShort AS course, gibbonCourseClass.nameShort AS class, gibbonCourseClass.gibbonCourseClassID, gibbonCourse.gibbonDepartmentID, gibbonYearGroupIDList FROM gibbonCourse, gibbonCourseClass WHERE gibbonCourse.gibbonCourseID=gibbonCourseClass.gibbonCourseID AND gibbonCourseClass.gibbonCourseClassID=:gibbonCourseClassID AND gibbonCourseClass.reportable='Y' ORDER BY course, class"; - $result = $connection2->prepare($sql); - $result->execute($data); - } catch (PDOException $e) { - echo "
".$e->getMessage().'
'; - } - - if ($result->rowCount() != 1) { - $page->addError(__('The selected record does not exist, or you do not have access to it.')); - } else { - try { - $data2 = array('atlColumnID' => $atlColumnID); - $sql2 = 'SELECT * FROM atlColumn WHERE atlColumnID=:atlColumnID'; - $result2 = $connection2->prepare($sql2); - $result2->execute($data2); - } catch (PDOException $e) { - echo "
".$e->getMessage().'
'; - } - - if ($result2->rowCount() != 1) { - $page->addError(__('The selected record does not exist, or you do not have access to it.')); - } else { - //Let's go! - $row = $result->fetch(); - $row2 = $result2->fetch(); - - $page->breadcrumbs - ->add(__('Manage {courseClass} ATLs', ['courseClass' => $row['course'].'.'.$row['class']]), 'atl_manage.php', ['gibbonCourseClassID' => $gibbonCourseClassID]) - ->add(__('Delete Column')); - - if (isset($_GET['return'])) { - returnProcess($guid, $_GET['return'], null, null); - } - - $form = DeleteForm::createForm($session->get('absoluteURL').'/modules/'.$session->get('module').'/atl_manage_deleteProcess.php?atlColumnID='.$atlColumnID); - $form->addHiddenValue('gibbonCourseClassID', $gibbonCourseClassID); - echo $form->getOutput(); - } - } - - //Print sidebar - $session->set('sidebarExtra', sidebarExtra($guid, $connection2, $gibbonCourseClassID, 'manage', 'Manage ATLs_all')); - } -} +. +*/ + +use Gibbon\Forms\Prefab\DeleteForm; +use Gibbon\Module\ATL\Domain\ATLColumnGateway; + +//Module includes +require_once __DIR__ . '/moduleFunctions.php'; + +if (isActionAccessible($guid, $connection2, '/modules/ATL/atl_manage_delete.php') == false) { + //Acess denied + $page->addError(__('You do not have access to this action.')); +} else { + //Check if school year specified + $gibbonCourseClassID = $_GET['gibbonCourseClassID'] ?? ''; + $atlColumnID = $_GET['atlColumnID'] ?? ''; + $atlColumnGateway = $container->get(ATLColumnGateway::class); + + if (!$atlColumnGateway->exists($atlColumnID)) { + $page->addError(__('The selected record does not exist, or you do not have access to it.')); + } else { + //Let's go! + $form = DeleteForm::createForm($session->get('absoluteURL').'/modules/'.$session->get('module').'/atl_manage_deleteProcess.php'); + $form->addHiddenValue('atlColumnID', $atlColumnID); + $form->addHiddenValue('gibbonCourseClassID', $gibbonCourseClassID); + echo $form->getOutput(); + + //Print sidebar + $session->set('sidebarExtra', sidebarExtra($gibbonCourseClassID, 'manage')); + } +} diff --git a/ATL/atl_manage_deleteProcess.php b/ATL/atl_manage_deleteProcess.php index e441ead..b0fd6ca 100644 --- a/ATL/atl_manage_deleteProcess.php +++ b/ATL/atl_manage_deleteProcess.php @@ -1,75 +1,62 @@ -. -*/ - -include '../../gibbon.php'; - - -$gibbonCourseClassID = $_POST['gibbonCourseClassID']; -$atlColumnID = $_GET['atlColumnID']; -$URL = $session->get('absoluteURL').'/index.php?q=/modules/'.getModuleName($_POST['address'])."/atl_manage_delete.php&atlColumnID=$atlColumnID&gibbonCourseClassID=$gibbonCourseClassID"; -$URLDelete = $session->get('absoluteURL').'/index.php?q=/modules/'.getModuleName($_POST['address'])."/atl_manage.php&gibbonCourseClassID=$gibbonCourseClassID"; - -if (isActionAccessible($guid, $connection2, '/modules/ATL/atl_manage_delete.php') == false) { - //Fail 0 - $URL .= '&return=error0'; - header("Location: {$URL}"); -} else { - //Proceed! - //Check if school year specified - if ($atlColumnID == '' or $gibbonCourseClassID == '') { - //Fail1 - $URL .= '&return=error1'; - header("Location: {$URL}"); - } else { - try { - $data = array('atlColumnID' => $atlColumnID, 'gibbonCourseClassID' => $gibbonCourseClassID); - $sql = 'SELECT * FROM atlColumn WHERE atlColumnID=:atlColumnID AND gibbonCourseClassID=:gibbonCourseClassID'; - $result = $connection2->prepare($sql); - $result->execute($data); - } catch (PDOException $e) { - //Fail2 - $URL .= '&return=error2'; - header("Location: {$URL}"); - exit(); - } - - if ($result->rowCount() != 1) { - //Fail 2 - $URL .= '&return=error2'; - header("Location: {$URL}"); - } else { - //Write to database - try { - $data = array('atlColumnID' => $atlColumnID); - $sql = 'DELETE FROM atlColumn WHERE atlColumnID=:atlColumnID'; - $result = $connection2->prepare($sql); - $result->execute($data); - } catch (PDOException $e) { - //Fail 2 - $URL .= '&return=error2'; - header("Location: {$URL}"); - exit(); - } - - //Success 0 - $URLDelete = $URLDelete.'&return=success0'; - header("Location: {$URLDelete}"); - } - } -} +. +*/ + +use Gibbon\Module\ATL\Domain\ATLColumnGateway; +use Gibbon\Module\ATL\Domain\ATLEntryGateway; + +include '../../gibbon.php'; + +$gibbonCourseClassID = $_POST['gibbonCourseClassID'] ?? ''; +$atlColumnID = $_POST['atlColumnID'] ?? ''; +$URL = $session->get('absoluteURL').'/index.php?q=/modules/ATL/atl_manage.php&gibbonCourseClassID=' . $gibbonCourseClassID; + +if (isActionAccessible($guid, $connection2, '/modules/ATL/atl_manage_delete.php') == false) { + //Fail 0 + $URL .= '&return=error0'; + header("Location: {$URL}"); + exit(); +} else { + //Proceed! + $atlColumnGateway = $container->get(ATLColumnGateway::class); + + if (!$atlColumnGateway->exists($atlColumnID)) { + $URL .= '&return=error1'; + header("Location: {$URL}"); + exit(); + } else { + //Write to database + if (!$atlColumnGateway->delete($atlColumnID)) { + $URL .= '&return=error2'; + header("Location: {$URL}"); + exit(); + } + + $atlEntryGateway = $container->get(ATLEntryGateway::class); + if (!$atlEntryGateway->deleteWhere(['atlColumnID' => $atlColumnID])) { + $URL .= '&return=warning1'; + header("Location: {$URL}"); + exit(); + } + + //Success 0 + $URL .= '&return=success0'; + header("Location: {$URL}"); + exit(); + } +} diff --git a/ATL/atl_manage_edit.php b/ATL/atl_manage_edit.php index 96f47d6..6e2699a 100644 --- a/ATL/atl_manage_edit.php +++ b/ATL/atl_manage_edit.php @@ -1,130 +1,123 @@ -. -*/ - -use Gibbon\Forms\Form; - -//Module includes -include './modules/'.$session->get('module').'/moduleFunctions.php'; - -if (isActionAccessible($guid, $connection2, '/modules/ATL/atl_manage_edit.php') == false) { - //Acess denied - $page->addError(__('You do not have access to this action.')); -} else { - //Get action with highest precendence - $highestAction = getHighestGroupedAction($guid, $_GET['q'], $connection2); - if ($highestAction == false) { - $page->addError(__('The highest grouped action cannot be determined.')); - } else { - //Check if school year specified - $gibbonCourseClassID = $_GET['gibbonCourseClassID'] ?? ''; - $atlColumnID = $_GET['atlColumnID'] ?? ''; - if ($gibbonCourseClassID == '' or $atlColumnID == '') { - $page->addError(__('You have not specified one or more required parameters.')); - } else { - try { - $data = array('gibbonCourseClassID' => $gibbonCourseClassID); - $sql = "SELECT gibbonCourse.nameShort AS course, gibbonCourseClass.nameShort AS class, gibbonCourseClass.gibbonCourseClassID, gibbonCourse.gibbonDepartmentID, gibbonYearGroupIDList FROM gibbonCourse, gibbonCourseClass WHERE gibbonCourse.gibbonCourseID=gibbonCourseClass.gibbonCourseID AND gibbonCourseClass.gibbonCourseClassID=:gibbonCourseClassID AND gibbonCourseClass.reportable='Y' ORDER BY course, class"; - $result = $connection2->prepare($sql); - $result->execute($data); - } catch (PDOException $e) { - echo "
".$e->getMessage().'
'; - } - - if ($result->rowCount() != 1) { - $page->addError(__('The selected record does not exist, or you do not have access to it.')); - } else { - try { - $data2 = array('atlColumnID' => $atlColumnID); - $sql2 = 'SELECT * FROM atlColumn WHERE atlColumnID=:atlColumnID'; - $result2 = $connection2->prepare($sql2); - $result2->execute($data2); - } catch (PDOException $e) { - echo "
".$e->getMessage().'
'; - } - - if ($result2->rowCount() != 1) { - $page->addError(__('The selected record does not exist, or you do not have access to it.')); - } else { - //Let's go! - $class = $result->fetch(); - $values = $result2->fetch(); - - $page->breadcrumbs - ->add(__('Manage {courseClass} ATLs', ['courseClass' => $class['course'].'.'.$class['class']]), 'atl_manage.php', ['gibbonCourseClassID' => $gibbonCourseClassID]) - ->add(__('Edit Column')); - - if (isset($_GET['return'])) { - returnProcess($guid, $_GET['return'], null, null); - } - - $form = Form::create('ATL', $session->get('absoluteURL').'/modules/ATL/atl_manage_editProcess.php?atlColumnID='.$atlColumnID.'&gibbonCourseClassID='.$gibbonCourseClassID.'&address='.$session->get('address')); - $form->addHiddenValue('address', $session->get('address')); - - $form->addRow()->addHeading(__('Basic Information')); - - $row = $form->addRow(); - $row->addLabel('className', __('Class')); - $row->addTextField('className')->readonly()->setValue(htmlPrep($class['course']).'.'.htmlPrep($class['class'])); - - $row = $form->addRow(); - $row->addLabel('name', __('Name')); - $row->addTextField('name')->isRequired()->maxLength(20); - - $row = $form->addRow(); - $row->addLabel('description', __('Description')); - $row->addTextField('description')->isRequired()->maxLength(1000); - - $form->addRow()->addHeading(__('Assessment')); - - $data = array('gibbonYearGroupIDList' => $class['gibbonYearGroupIDList'], 'gibbonDepartmentID' => $class['gibbonDepartmentID'], 'rubrics' => __('Rubrics')); - $sql = "SELECT CONCAT(scope, ' ', :rubrics) as groupBy, gibbonRubricID as value, - (CASE WHEN category <> '' THEN CONCAT(category, ' - ', gibbonRubric.name) ELSE gibbonRubric.name END) as name - FROM gibbonRubric - JOIN gibbonYearGroup ON (FIND_IN_SET(gibbonYearGroup.gibbonYearGroupID, gibbonRubric.gibbonYearGroupIDList)) - WHERE gibbonRubric.active='Y' - AND FIND_IN_SET(gibbonYearGroup.gibbonYearGroupID, :gibbonYearGroupIDList) - AND (scope='School' OR (scope='Learning Area' AND gibbonDepartmentID=:gibbonDepartmentID)) - GROUP BY gibbonRubric.gibbonRubricID - ORDER BY scope, category, name"; - - $row = $form->addRow(); - $row->addLabel('gibbonRubricID', __('Rubric')); - $row->addSelect('gibbonRubricID')->fromQuery($pdo, $sql, $data, 'groupBy')->placeholder(); - - $form->addRow()->addHeading(__('Access')); - - $row = $form->addRow(); - $row->addLabel('completeDate', __('Go Live Date'))->prepend('1. ')->append('
'.__('2. Column is hidden until date is reached.')); - $row->addDate('completeDate'); - - $row = $form->addRow(); - $row->addFooter(); - $row->addSubmit(); - - $form->loadAllValuesFrom($values); - - echo $form->getOutput(); - } - } - - //Print sidebar - $session->set('sidebarExtra', sidebarExtra($guid, $connection2, $gibbonCourseClassID, 'manage', $highestAction)); - } - } -} +. +*/ + +use Gibbon\Forms\Form; +use Gibbon\Module\ATL\Domain\ATLColumnGateway; +use Gibbon\Services\Format; + +//Module includes +require_once __DIR__ . '/moduleFunctions.php'; + +if (isActionAccessible($guid, $connection2, '/modules/ATL/atl_manage_edit.php') == false) { + //Acess denied + $page->addError(__('You do not have access to this action.')); +} else { + //Check if school year specified + $gibbonCourseClassID = $_GET['gibbonCourseClassID'] ?? ''; + $atlColumnID = $_GET['atlColumnID'] ?? ''; + try { + $data = array('gibbonCourseClassID' => $gibbonCourseClassID); + $sql = "SELECT gibbonCourse.nameShort AS course, gibbonCourseClass.nameShort AS class, gibbonCourseClass.gibbonCourseClassID, gibbonCourse.gibbonDepartmentID, gibbonYearGroupIDList FROM gibbonCourse, gibbonCourseClass WHERE gibbonCourse.gibbonCourseID=gibbonCourseClass.gibbonCourseID AND gibbonCourseClass.gibbonCourseClassID=:gibbonCourseClassID AND gibbonCourseClass.reportable='Y' ORDER BY course, class"; + $result = $connection2->prepare($sql); + $result->execute($data); + } catch (PDOException $e) { + $page->addError(__('A database error has occured.')); + } + + if ($result->rowCount() != 1) { + $page->addError(__('The selected record does not exist, or you do not have access to it.')); + } else { + $atlColumnGateway = $container->get(ATLColumnGateway::class); + $atlColumn = $atlColumnGateway->getByID($atlColumnID); + if (empty($atlColumn)) { + $page->addError(__('The selected record does not exist, or you do not have access to it.')); + } else { + //Let's go! + $class = $result->fetch(); + + $page->breadcrumbs + ->add(__('Manage {courseClass} ATLs', ['courseClass' => Format::courseClassName($class['course'], $class['class'])]), 'atl_manage.php', ['gibbonCourseClassID' => $gibbonCourseClassID]) + ->add(__('Edit Column')); + + $form = Form::create('ATL', $session->get('absoluteURL').'/modules/ATL/atl_manage_editProcess.php'); + $form->addHiddenValue('address', $session->get('address')); + $form->addHiddenValue('atlColumnID', $atlColumnID); + $form->addHiddenValue('gibbonCourseClassID', $gibbonCourseClassID); + + $form->addRow()->addHeading(__('Basic Information')); + + $row = $form->addRow(); + $row->addLabel('className', __('Class')); + $row->addTextField('className') + ->readonly() + ->setValue(htmlPrep(Format::courseClassName($class['course'], $class['class']))); + + $row = $form->addRow(); + $row->addLabel('name', __('Name')); + $row->addTextField('name') + ->isRequired() + ->maxLength(20); + + $row = $form->addRow(); + $row->addLabel('description', __('Description')); + $row->addTextField('description') + ->isRequired() + ->maxLength(1000); + + $form->addRow()->addHeading(__('Assessment')); + + $data = array('gibbonYearGroupIDList' => $class['gibbonYearGroupIDList'], 'gibbonDepartmentID' => $class['gibbonDepartmentID'], 'rubrics' => __('Rubrics')); + $sql = "SELECT CONCAT(scope, ' ', :rubrics) as groupBy, gibbonRubricID as value, + (CASE WHEN category <> '' THEN CONCAT(category, ' - ', gibbonRubric.name) ELSE gibbonRubric.name END) as name + FROM gibbonRubric + JOIN gibbonYearGroup ON (FIND_IN_SET(gibbonYearGroup.gibbonYearGroupID, gibbonRubric.gibbonYearGroupIDList)) + WHERE gibbonRubric.active='Y' + AND FIND_IN_SET(gibbonYearGroup.gibbonYearGroupID, :gibbonYearGroupIDList) + AND (scope='School' OR (scope='Learning Area' AND gibbonDepartmentID=:gibbonDepartmentID)) + GROUP BY gibbonRubric.gibbonRubricID + ORDER BY scope, category, name"; + + $row = $form->addRow(); + $row->addLabel('gibbonRubricID', __('Rubric')); + $row->addSelect('gibbonRubricID')->fromQuery($pdo, $sql, $data, 'groupBy')->placeholder(); + + $form->addRow()->addHeading(__('Access')); + + $row = $form->addRow(); + $row->addLabel('completeDate', __('Go Live Date'))->prepend('1. ')->append('
'.__('2. Column is hidden until date is reached.')); + $row->addDate('completeDate'); + + $row = $form->addRow(); + $row->addLabel('forStudents', __('For Students?'))->description(__('Is this column meant to be filled out by students?')); + $row->addYesNo('forStudents') + ->required(); + + $row = $form->addRow(); + $row->addFooter(); + $row->addSubmit(); + + $form->loadAllValuesFrom($atlColumn); + + echo $form->getOutput(); + } + } + + //Print sidebar + $session->set('sidebarExtra', sidebarExtra($gibbonCourseClassID, 'manage')); +} diff --git a/ATL/atl_manage_editProcess.php b/ATL/atl_manage_editProcess.php index 555e582..22a5199 100644 --- a/ATL/atl_manage_editProcess.php +++ b/ATL/atl_manage_editProcess.php @@ -1,136 +1,103 @@ -. -*/ - -include '../../gibbon.php'; - - -$gibbonCourseClassID = $_GET['gibbonCourseClassID']; -$atlColumnID = $_GET['atlColumnID']; -$URL = $session->get('absoluteURL').'/index.php?q=/modules/'.getModuleName($_GET['address'])."/atl_manage_edit.php&atlColumnID=$atlColumnID&gibbonCourseClassID=$gibbonCourseClassID"; - -if (isActionAccessible($guid, $connection2, '/modules/ATL/atl_manage_edit.php') == false) { - //Fail 0 - $URL .= '&return=error0'; - header("Location: {$URL}"); -} else { - $highestAction = getHighestGroupedAction($guid, $_GET['address'], $connection2); - if ($highestAction == false) { - //Fail 0 - $URL .= '&return=error0'; - header("Location: {$URL}"); - } else { - if (empty($_POST)) { - $URL .= '&return=error5'; - header("Location: {$URL}"); - } else { - //Proceed! - //Check if school year specified - if ($atlColumnID == '' or $gibbonCourseClassID == '') { - //Fail1 - $URL .= '&return=error1'; - header("Location: {$URL}"); - } else { - try { - $data = array('atlColumnID' => $atlColumnID, 'gibbonCourseClassID' => $gibbonCourseClassID); - $sql = 'SELECT * FROM atlColumn WHERE atlColumnID=:atlColumnID AND gibbonCourseClassID=:gibbonCourseClassID'; - $result = $connection2->prepare($sql); - $result->execute($data); - } catch (PDOException $e) { - //Fail2 - $URL .= '&return=error2'; - header("Location: {$URL}"); - exit(); - } - - if ($result->rowCount() != 1) { - //Fail 2 - $URL .= '&return=error2'; - header("Location: {$URL}"); - } else { - $row = $result->fetch(); - - //Validate Inputs - $name = $_POST['name']; - $description = $_POST['description']; - $gibbonRubricID = $_POST['gibbonRubricID']; - $completeDate = $_POST['completeDate']; - if ($completeDate == '') { - $completeDate = null; - $complete = 'N'; - } else { - $completeDate = dateConvert($guid, $completeDate); - $complete = 'Y'; - } - $gibbonPersonIDLastEdit = $session->get('gibbonPersonID'); - $groupingID = $row['groupingID']; - - if ($name == '' or $description == '') { - //Fail 3 - $URL .= '&return=error3'; - header("Location: {$URL}"); - } else { - //ATTEMPT TO UPDATE LINKED COLUMNS - $partialFail = false; - if (isset($_POST['gibbonCourseClassID'])) { - if (is_array($_POST['gibbonCourseClassID'])) { - $gibbonCourseClassIDs = $_POST['gibbonCourseClassID']; - foreach ($gibbonCourseClassIDs as $gibbonCourseClassID2) { - //Write to database - try { - $data = array('name' => $name, 'description' => $description, 'gibbonRubricID' => $gibbonRubricID, 'completeDate' => $completeDate, 'complete' => $complete, 'gibbonPersonIDLastEdit' => $session->get('gibbonPersonID'), 'groupingID' => $groupingID, 'gibbonCourseClassID' => $gibbonCourseClassID2); - $sql = 'UPDATE atlColumn SET name=:name, description=:description, gibbonRubricID=:gibbonRubricID, completeDate=:completeDate, complete=:complete, gibbonPersonIDLastEdit=:gibbonPersonIDLastEdit WHERE groupingID=:groupingID AND gibbonCourseClassID=:gibbonCourseClassID'; - $result = $connection2->prepare($sql); - $result->execute($data); - } catch (PDOException $e) { - $partialFail = true; - echo $e->getMessage(); - } - - } - } - } - - //Write to database - try { - $data = array('gibbonCourseClassID' => $gibbonCourseClassID, 'name' => $name, 'description' => $description, 'gibbonRubricID' => $gibbonRubricID, 'completeDate' => $completeDate, 'complete' => $complete, 'gibbonPersonIDLastEdit' => $gibbonPersonIDLastEdit, 'atlColumnID' => $atlColumnID); - $sql = 'UPDATE atlColumn SET gibbonCourseClassID=:gibbonCourseClassID, name=:name, description=:description, gibbonRubricID=:gibbonRubricID, completeDate=:completeDate, complete=:complete, gibbonPersonIDLastEdit=:gibbonPersonIDLastEdit WHERE atlColumnID=:atlColumnID'; - $result = $connection2->prepare($sql); - $result->execute($data); - } catch (PDOException $e) { - //Fail 2 - $URL .= '&return=error2'; - header("Location: {$URL}"); - exit(); - } - - if ($partialFail == true) { - //Fail 6 - $URL .= '&return=warning1'; - header("Location: {$URL}"); - } else { - //Success 0 - $URL .= '&return=success0'; - header("Location: {$URL}"); - } - } - } - } - } - } -} +. +*/ + +use Gibbon\Module\ATL\Domain\ATLColumnGateway; +use Gibbon\Module\ATL\Domain\ATLEntryGateway; +use Gibbon\Services\Format; + +include '../../gibbon.php'; + +$URL = $session->get('absoluteURL').'/index.php?q=/modules/ATL/'; + +if (isActionAccessible($guid, $connection2, '/modules/ATL/atl_manage_edit.php') == false) { + //Fail 0 + $URL .= 'atl_manage.php&return=error0'; + header("Location: {$URL}"); + exit(); +} else { + $gibbonCourseClassID = $_POST['gibbonCourseClassID'] ?? ''; + $atlColumnID = $_POST['atlColumnID'] ?? ''; + + $atlColumnGateway = $container->get(ATLColumnGateway::class); + $atlColumn = $atlColumnGateway->getByID($atlColumnID); + //Proceed! + //Check if school year specified + if (empty($atlColumn) || $atlColumn['gibbonCourseClassID'] != $gibbonCourseClassID) { + //Fail1 + $URL .= 'atl_manage.php&return=error1'; + header("Location: {$URL}"); + exit(); + } else { + $URL .= "atl_manage_edit.php&atlColumnID=$atlColumnID&gibbonCourseClassID=$gibbonCourseClassID"; + + //Validate Inputs + $name = $_POST['name'] ?? ''; + $description = $_POST['description'] ?? ''; + $gibbonRubricID = $_POST['gibbonRubricID'] ?? $atlColumn['gibbonRubricID']; + $completeDate = $_POST['completeDate'] ?? ''; + if ($completeDate == '') { + $completeDate = null; + $complete = 'N'; + } else { + $completeDate = Format::dateConvert($completeDate); + $complete = 'Y'; + } + $forStudents = $_POST['forStudents'] ?? $atlColumn['forStudents']; + $gibbonPersonIDLastEdit = $session->get('gibbonPersonID'); + + if (empty($name) || empty($description) || empty($forStudents)) { + //Fail 3 + $URL .= '&return=error1'; + header("Location: {$URL}"); + exit(); + } else { + $data = [ + 'name' => $name, + 'description' => $description, + 'gibbonRubricID' => $gibbonRubricID, + 'completeDate' => $completeDate, + 'forStudents' => $forStudents, + 'complete' => $complete, + 'gibbonPersonIDLastEdit' => $gibbonPersonIDLastEdit + ]; + + if (!$atlColumnGateway->update($atlColumnID, $data)) { + //Fail 6 + $URL .= '&return=error2'; + header("Location: {$URL}"); + exit(); + } + + + if ($gibbonRubricID != $atlColumn['gibbonRubricID']) { + $atlEntryGateway = $container->get(ATLEntryGateway::class); + if (!$atlEntryGateway->updateWhere(['atlColumnID' => $atlColumnID], ['complete' => 'N'])) { + $URL .= '&return=warning1'; + header("Location: {$URL}"); + exit(); + } + } + + //Success 0 + $URL .= '&return=success0'; + header("Location: {$URL}"); + exit(); + } + } +} diff --git a/ATL/atl_view.php b/ATL/atl_view.php index 25c7432..96e8054 100644 --- a/ATL/atl_view.php +++ b/ATL/atl_view.php @@ -1,185 +1,179 @@ -. -*/ - -use Gibbon\Forms\DatabaseFormFactory; -use Gibbon\Forms\Form; -use Gibbon\Services\Format; - -//Module includes -include './modules/'.$session->get('module').'/moduleFunctions.php'; - -if (isActionAccessible($guid, $connection2, '/modules/ATL/atl_view.php') == false) { - //Acess denied - $page->addError(__('You do not have access to this action.')); -} else { - // Register scripts available to the core, but not included by default - $page->scripts->add('chart'); - - //Get action with highest precendence - $highestAction = getHighestGroupedAction($guid, $_GET['q'], $connection2); - if ($highestAction == false) { - $page->addError(__('The highest grouped action cannot be determined.')); - } else { - if ($highestAction == 'View ATLs_all') { //ALL STUDENTS - $page->breadcrumbs->add(__('View All ATLs')); - - $gibbonPersonID = null; - if (isset($_GET['gibbonPersonID'])) { - $gibbonPersonID = $_GET['gibbonPersonID']; - } - - echo '

'; - echo __('Choose A Student'); - echo '

'; - - $form = Form::create("filter", $session->get('absoluteURL')."/index.php", "get", "noIntBorder fullWidth standardForm"); - $form->setFactory(DatabaseFormFactory::create($pdo)); - - $form->addHiddenValue('q', '/modules/ATL/atl_view.php'); - $form->addHiddenValue('address', $session->get('address')); - - $row = $form->addRow(); - $row->addLabel('gibbonPersonID', __('Student')); - $row->addSelectStudent('gibbonPersonID', $session->get("gibbonSchoolYearID"), array())->selected($gibbonPersonID)->placeholder(); - - $row = $form->addRow(); - $row->addSearchSubmit($gibbon->session); - - echo $form->getOutput(); - - if (!empty($gibbonPersonID)) { - echo '

'; - echo __('ATLs'); - echo '

'; - - //Check for access - try { - $dataCheck = array('gibbonPersonID' => $gibbonPersonID); - $sqlCheck = "SELECT DISTINCT gibbonPerson.* FROM gibbonPerson LEFT JOIN gibbonStudentEnrolment ON (gibbonPerson.gibbonPersonID=gibbonStudentEnrolment.gibbonPersonID) WHERE gibbonPerson.gibbonPersonID=:gibbonPersonID AND status='Full' AND (dateStart IS NULL OR dateStart<='".date('Y-m-d')."') AND (dateEnd IS NULL OR dateEnd>='".date('Y-m-d')."')"; - $resultCheck = $connection2->prepare($sqlCheck); - $resultCheck->execute($dataCheck); - } catch (PDOException $e) { - echo "
".$e->getMessage().'
'; - } - - if ($resultCheck->rowCount() != 1) { - echo "
"; - echo __('The selected record does not exist, or you do not have access to it.'); - echo '
'; - } else { - echo getATLRecord($guid, $connection2, $gibbonPersonID); - } - } - } elseif ($highestAction == 'View ATLs_myChildrens') { //MY CHILDREN - $page->breadcrumbs->add(__('View My Childrens\'s ATLs')); - - //Test data access field for permission - try { - $data = array('gibbonPersonID' => $session->get('gibbonPersonID')); - $sql = "SELECT * FROM gibbonFamilyAdult WHERE gibbonPersonID=:gibbonPersonID AND childDataAccess='Y'"; - $result = $connection2->prepare($sql); - $result->execute($data); - } catch (PDOException $e) { - echo "
".$e->getMessage().'
'; - } - - if ($result->rowCount() < 1) { - echo "
"; - echo __('Access denied.'); - echo '
'; - } else { - //Get child list - $gibbonPersonID = null; - $options = array(); - while ($row = $result->fetch()) { - try { - $dataChild = array('gibbonFamilyID' => $row['gibbonFamilyID'], 'gibbonSchoolYearID' => $session->get('gibbonSchoolYearID'), 'today' => date('Y-m-d')); - $sqlChild = "SELECT * FROM gibbonFamilyChild JOIN gibbonPerson ON (gibbonFamilyChild.gibbonPersonID=gibbonPerson.gibbonPersonID) JOIN gibbonStudentEnrolment ON (gibbonPerson.gibbonPersonID=gibbonStudentEnrolment.gibbonPersonID) JOIN gibbonFormGroup ON (gibbonStudentEnrolment.gibbonFormGroupID=gibbonFormGroup.gibbonFormGroupID) WHERE gibbonFamilyID=:gibbonFamilyID AND gibbonPerson.status='Full' AND (dateStart IS NULL OR dateStart<=:today) AND (dateEnd IS NULL OR dateEnd>=:today) AND gibbonStudentEnrolment.gibbonSchoolYearID=:gibbonSchoolYearID ORDER BY surname, preferredName "; - $resultChild = $connection2->prepare($sqlChild); - $resultChild->execute($dataChild); - } catch (PDOException $e) { - echo "
".$e->getMessage().'
'; - } - while ($rowChild = $resultChild->fetch()) { - $options[$rowChild['gibbonPersonID']]=Format::name('', $rowChild['preferredName'], $rowChild['surname'], 'Student', true); - } - } - - if (count($options) == 0) { - echo "
"; - echo __('Access denied.'); - echo '
'; - } elseif (count($options) == 1) { - $gibbonPersonID = key($options); - } else { - echo '

'; - echo __('Choose Student'); - echo '

'; - - $gibbonPersonID = (isset($_GET['gibbonPersonID']))? $_GET['gibbonPersonID'] : null; - - $form = Form::create("filter", $session->get('absoluteURL')."/index.php", "get", "noIntBorder fullWidth standardForm"); - $form->setFactory(DatabaseFormFactory::create($pdo)); - - $form->addHiddenValue('q', '/modules/ATL/atl_view.php'); - - $row = $form->addRow(); - $row->addLabel('gibbonPersonID', __('Child'))->description('Choose the child you are registering for.'); - $row->addSelect('gibbonPersonID')->fromArray($options)->selected($gibbonPersonID); - - $row = $form->addRow(); - $row->addSearchSubmit($gibbon->session); - - echo $form->getOutput(); - } - - $showParentAttainmentWarning = getSettingByScope($connection2, 'Markbook', 'showParentAttainmentWarning'); - $showParentEffortWarning = getSettingByScope($connection2, 'Markbook', 'showParentEffortWarning'); - - if (!empty($gibbonPersonID) and count($options) > 0) { - //Confirm access to this student - try { - $dataChild = array(); - $sqlChild = "SELECT * FROM gibbonFamilyChild JOIN gibbonFamily ON (gibbonFamilyChild.gibbonFamilyID=gibbonFamily.gibbonFamilyID) JOIN gibbonFamilyAdult ON (gibbonFamilyAdult.gibbonFamilyID=gibbonFamily.gibbonFamilyID) JOIN gibbonPerson ON (gibbonFamilyChild.gibbonPersonID=gibbonPerson.gibbonPersonID) WHERE gibbonPerson.status='Full' AND (dateStart IS NULL OR dateStart<='".date('Y-m-d')."') AND (dateEnd IS NULL OR dateEnd>='".date('Y-m-d')."') AND gibbonFamilyChild.gibbonPersonID=$gibbonPersonID AND gibbonFamilyAdult.gibbonPersonID=".$session->get('gibbonPersonID')." AND childDataAccess='Y'"; - $resultChild = $connection2->prepare($sqlChild); - $resultChild->execute($dataChild); - } catch (PDOException $e) { - echo "
".$e->getMessage().'
'; - } - if ($resultChild->rowCount() < 1) { - echo "
"; - echo __('The selected record does not exist, or you do not have access to it.'); - echo '
'; - } else { - $rowChild = $resultChild->fetch(); - echo getATLRecord($guid, $connection2, $gibbonPersonID); - } - } - } - } else { //My ATLS - $page->breadcrumbs->add(__('View My ATLs')); - - echo '

'; - echo __('ATLs'); - echo '

'; - - echo getATLRecord($guid, $connection2, $session->get('gibbonPersonID')); - } - } -} +. +*/ + +use Gibbon\Domain\System\SettingGateway; +use Gibbon\Domain\User\FamilyAdultGateway; +use Gibbon\Forms\DatabaseFormFactory; +use Gibbon\Forms\Form; +use Gibbon\Services\Format; + +//Module includes +require_once __DIR__ . '/moduleFunctions.php'; + +if (isActionAccessible($guid, $connection2, '/modules/ATL/atl_view.php') == false) { + //Acess denied + $page->addError(__('You do not have access to this action.')); +} else { + // Register scripts available to the core, but not included by default + $page->scripts->add('chart'); + + //Get action with highest precendence + $highestAction = getHighestGroupedAction($guid, $_GET['q'], $connection2); + if ($highestAction == false) { + $page->addError(__('The highest grouped action cannot be determined.')); + } else { + if ($highestAction == 'View ATLs_all') { //ALL STUDENTS + $page->breadcrumbs->add(__('View All ATLs')); + + $gibbonPersonID = $_GET['gibbonPersonID'] ?? ''; + + $form = Form::create("filter", $session->get('absoluteURL').'/index.php', 'get', 'noIntBorder fullWidth standardForm'); + $form->setFactory(DatabaseFormFactory::create($pdo)); + + $form->setTitle(__('Choose A Student')); + + $form->addHiddenValue('q', '/modules/ATL/atl_view.php'); + $form->addHiddenValue('address', $session->get('address')); + + $row = $form->addRow(); + $row->addLabel('gibbonPersonID', __('Student')); + $row->addSelectStudent('gibbonPersonID', $session->get('gibbonSchoolYearID'), []) + ->selected($gibbonPersonID) + ->placeholder(); + + $row = $form->addRow(); + $row->addSearchSubmit($session); + + echo $form->getOutput(); + + if (!empty($gibbonPersonID)) { + echo '

'; + echo __('ATLs'); + echo '

'; + + //Check for access + try { + $dataCheck = array('gibbonPersonID' => $gibbonPersonID, 'today' => date('Y-m-d')); + $sqlCheck = "SELECT DISTINCT gibbonPerson.* FROM gibbonPerson LEFT JOIN gibbonStudentEnrolment ON (gibbonPerson.gibbonPersonID=gibbonStudentEnrolment.gibbonPersonID) WHERE gibbonPerson.gibbonPersonID=:gibbonPersonID AND status='Full' AND (dateStart IS NULL OR dateStart<= :today) AND (dateEnd IS NULL OR dateEnd>= :today)"; + $resultCheck = $connection2->prepare($sqlCheck); + $resultCheck->execute($dataCheck); + } catch (PDOException $e) { + } + + if ($resultCheck->rowCount() != 1) { + echo Format::alert(__('The selected record does not exist, or you do not have access to it.')); + } else { + echo '
'; + echo visualiseATL($container, $gibbonPersonID); + + echo getATLRecord($gibbonPersonID); + } + } + } elseif ($highestAction == 'View ATLs_myChildrens') { //MY CHILDREN + $page->breadcrumbs->add(__('View My Childrens\'s ATLs')); + + //Test data access field for permission + $familyAdultGateway = $container->get(FamilyAdultGateway::class); + $adult = $familyAdultGateway->selectBy(['gibbonPersonID' => $session->get('gibbonPersonID'), 'childDataAccess' => 'Y']); + + if ($adult->isEmpty()) { + echo Format::alert(__('Access denied.')); + } else { + //Get child list + $adult = $adult->fetch(); + $gibbonPersonID = ''; + $options = []; + + try { + $dataChild = array('gibbonFamilyID' => $adult['gibbonFamilyID'], 'gibbonSchoolYearID' => $session->get('gibbonSchoolYearID'), 'today' => date('Y-m-d')); + $sqlChild = "SELECT * FROM gibbonFamilyChild JOIN gibbonPerson ON (gibbonFamilyChild.gibbonPersonID=gibbonPerson.gibbonPersonID) JOIN gibbonStudentEnrolment ON (gibbonPerson.gibbonPersonID=gibbonStudentEnrolment.gibbonPersonID) JOIN gibbonFormGroup ON (gibbonStudentEnrolment.gibbonFormGroupID=gibbonFormGroup.gibbonFormGroupID) WHERE gibbonFamilyID=:gibbonFamilyID AND gibbonPerson.status='Full' AND (dateStart IS NULL OR dateStart<=:today) AND (dateEnd IS NULL OR dateEnd>=:today) AND gibbonStudentEnrolment.gibbonSchoolYearID=:gibbonSchoolYearID ORDER BY surname, preferredName "; + $resultChild = $connection2->prepare($sqlChild); + $resultChild->execute($dataChild); + } catch (PDOException $e) { + echo "
".$e->getMessage().'
'; + } + while ($rowChild = $resultChild->fetch()) { + $options[$rowChild['gibbonPersonID']]=Format::name('', $rowChild['preferredName'], $rowChild['surname'], 'Student', true); + } + + if (empty($options)) { + echo Format::alert(__('Access denied.')); + } elseif (count($options) == 1) { + $gibbonPersonID = key($options); + } else { + echo '

'; + echo __('Choose Student'); + echo '

'; + + $gibbonPersonID = $_GET['gibbonPersonID'] ?? ''; + + $form = Form::create("filter", $session->get('absoluteURL').'/index.php', 'get', 'noIntBorder fullWidth standardForm'); + $form->setFactory(DatabaseFormFactory::create($pdo)); + + $form->addHiddenValue('q', '/modules/ATL/atl_view.php'); + + $row = $form->addRow(); + $row->addLabel('gibbonPersonID', __('Child'))->description('Choose the child you are registering for.'); + $row->addSelect('gibbonPersonID') + ->fromArray($options) + ->selected($gibbonPersonID); + + $row = $form->addRow(); + $row->addSearchSubmit($session); + + echo $form->getOutput(); + } + + $settingGateway = $container->get(SettingGateway::class); + $showParentAttainmentWarning = $settingGateway->getSettingByScope('Markbook', 'showParentAttainmentWarning'); + $showParentEffortWarning = $settingGateway->getSettingByScope('Markbook', 'showParentEffortWarning'); + + if (!empty($gibbonPersonID) && !empty($options)) { + //Confirm access to this student + try { + $dataChild = array(); + $sqlChild = "SELECT * FROM gibbonFamilyChild JOIN gibbonFamily ON (gibbonFamilyChild.gibbonFamilyID=gibbonFamily.gibbonFamilyID) JOIN gibbonFamilyAdult ON (gibbonFamilyAdult.gibbonFamilyID=gibbonFamily.gibbonFamilyID) JOIN gibbonPerson ON (gibbonFamilyChild.gibbonPersonID=gibbonPerson.gibbonPersonID) WHERE gibbonPerson.status='Full' AND (dateStart IS NULL OR dateStart<='".date('Y-m-d')."') AND (dateEnd IS NULL OR dateEnd>='".date('Y-m-d')."') AND gibbonFamilyChild.gibbonPersonID=$gibbonPersonID AND gibbonFamilyAdult.gibbonPersonID=".$session->get('gibbonPersonID')." AND childDataAccess='Y'"; + $resultChild = $connection2->prepare($sqlChild); + $resultChild->execute($dataChild); + } catch (PDOException $e) { + } + if ($resultChild->rowCount() < 1) { + echo Format::alert(__('The selected record does not exist, or you do not have access to it.')); + } else { + $rowChild = $resultChild->fetch(); + echo '
'; + echo visualiseATL($container, $gibbonPersonID); + + echo getATLRecord($gibbonPersonID); + } + } + } + } else { //My ATLS + $page->breadcrumbs->add(__('View My ATLs')); + + echo '

'; + echo __('ATLs'); + echo '

'; + + echo visualiseATL($container, $session->get('gibbonPersonID')); + + echo getATLRecord($session->get('gibbonPersonID')); + } + } +} diff --git a/ATL/atl_view_rubric.php b/ATL/atl_view_rubric.php index 1842b70..755f4e4 100644 --- a/ATL/atl_view_rubric.php +++ b/ATL/atl_view_rubric.php @@ -1,120 +1,106 @@ -. -*/ - -use Gibbon\Services\Format; - -//Rubric includes -include './modules/Rubrics/moduleFunctions.php'; - -if (isActionAccessible($guid, $connection2, '/modules/ATL/atl_view.php') == false) { - //Acess denied - $page->addError(__('You do not have access to this action.')); -} else { - //Proceed! - //Check if school year specified - $gibbonCourseClassID = $_GET['gibbonCourseClassID']; - $atlColumnID = $_GET['atlColumnID']; - $gibbonPersonID = $_GET['gibbonPersonID']; - $gibbonRubricID = $_GET['gibbonRubricID']; - if ($gibbonCourseClassID == '' or $atlColumnID == '' or $gibbonPersonID == '' or $gibbonRubricID == '') { echo "
"; - echo __('You have not specified one or more required parameters.'); - echo '
'; - } else { - $roleCategory = getRoleCategory($session->get('gibbonRoleIDPrimary'), $connection2); - $contextDBTableGibbonRubricIDField = 'gibbonRubricID'; - if ($_GET['type'] == 'attainment') { - $contextDBTableGibbonRubricIDField = 'gibbonRubricIDAttainment'; - } elseif ($_GET['type'] == 'effort') { - $contextDBTableGibbonRubricIDField = 'gibbonRubricID'; - } - - try { - if ($roleCategory == 'Staff') { - $data = array('gibbonCourseClassID' => $gibbonCourseClassID); - $sql = 'SELECT gibbonCourse.nameShort AS course, gibbonCourseClass.nameShort AS class, gibbonCourseClass.gibbonCourseClassID FROM gibbonCourse, gibbonCourseClass WHERE gibbonCourse.gibbonCourseID=gibbonCourseClass.gibbonCourseID AND gibbonCourseClass.gibbonCourseClassID=:gibbonCourseClassID ORDER BY course, class'; - } elseif ($roleCategory == 'Student') { - $data = array('gibbonPersonID' => $gibbonPersonID, 'gibbonCourseClassID' => $gibbonCourseClassID); - $sql = "SELECT gibbonCourse.nameShort AS course, gibbonCourseClass.nameShort AS class, gibbonCourseClass.gibbonCourseClassID FROM gibbonCourse, gibbonCourseClass, gibbonCourseClassPerson WHERE gibbonCourse.gibbonCourseID=gibbonCourseClass.gibbonCourseID AND gibbonCourseClass.gibbonCourseClassID=gibbonCourseClassPerson.gibbonCourseClassID AND gibbonCourseClassPerson.gibbonPersonID=:gibbonPersonID AND role='Student' AND gibbonCourseClass.gibbonCourseClassID=:gibbonCourseClassID ORDER BY course, class"; - } elseif ($roleCategory == 'Parent') { - $data = array('gibbonPersonID' => $gibbonPersonID, 'gibbonCourseClassID' => $gibbonCourseClassID); - $sql = "SELECT gibbonCourse.nameShort AS course, gibbonCourseClass.nameShort AS class, gibbonCourseClass.gibbonCourseClassID FROM gibbonCourse, gibbonCourseClass, gibbonCourseClassPerson WHERE gibbonCourse.gibbonCourseID=gibbonCourseClass.gibbonCourseID AND gibbonCourseClass.gibbonCourseClassID=gibbonCourseClassPerson.gibbonCourseClassID AND gibbonCourseClassPerson.gibbonPersonID=:gibbonPersonID AND role='Student' AND gibbonCourseClass.gibbonCourseClassID=:gibbonCourseClassID ORDER BY course, class"; - } - $result = $connection2->prepare($sql); - $result->execute($data); - } catch (PDOException $e) { - echo "
".$e->getMessage().'
'; - } - - if ($result->rowCount() != 1) { - $page->addError(__('The selected record does not exist, or you do not have access to it.')); - } else { - try { - $data2 = array('atlColumnID' => $atlColumnID); - $sql2 = 'SELECT * FROM atlColumn WHERE atlColumnID=:atlColumnID'; - $result2 = $connection2->prepare($sql2); - $result2->execute($data2); - } catch (PDOException $e) { - echo "
".$e->getMessage().'
'; - } - - if ($result2->rowCount() != 1) { - $page->addError(__('The selected record does not exist, or you do not have access to it.')); - } else { - try { - $data3 = array('gibbonRubricID' => $gibbonRubricID); - $sql3 = 'SELECT * FROM gibbonRubric WHERE gibbonRubricID=:gibbonRubricID'; - $result3 = $connection2->prepare($sql3); - $result3->execute($data3); - } catch (PDOException $e) { - echo "
".$e->getMessage().'
'; - } - - if ($result3->rowCount() != 1) { - $page->addError(__('The selected record does not exist.')); - } else { - try { - $data4 = array('gibbonPersonID' => $gibbonPersonID, 'gibbonCourseClassID' => $gibbonCourseClassID); - $sql4 = "SELECT DISTINCT surname, preferredName, gibbonPerson.gibbonPersonID FROM gibbonPerson JOIN gibbonCourseClassPerson ON (gibbonCourseClassPerson.gibbonPersonID=gibbonPerson.gibbonPersonID) WHERE gibbonPerson.gibbonPersonID=:gibbonPersonID AND gibbonCourseClassID=:gibbonCourseClassID AND status='Full' AND (dateStart IS NULL OR dateStart<='".date('Y-m-d')."') AND (dateEnd IS NULL OR dateEnd>='".date('Y-m-d')."') AND (role='Student' OR role='Student - Left')"; - $result4 = $connection2->prepare($sql4); - $result4->execute($data4); - } catch (PDOException $e) { - echo "
".$e->getMessage().'
'; - } - - if ($result4->rowCount() != 1) { - $page->addError(__('The selected record does not exist, or you do not have access to it.')); - } else { - //Let's go! - $row = $result->fetch(); - $row2 = $result2->fetch(); - $row3 = $result3->fetch(); - $row4 = $result4->fetch(); - - echo "

"; - echo $row3['name'].'
'; - echo "".Format::name('', $row4['preferredName'], $row4['surname'], 'Student', true).''; - echo '

'; - - echo rubricView($guid, $connection2, $gibbonRubricID, false, $row4['gibbonPersonID'], 'atlColumn', 'atlColumnID', $atlColumnID, $contextDBTableGibbonRubricIDField, 'name', 'completeDate'); - } - } - } - } - } -} +. +*/ + +use Gibbon\Domain\Rubrics\RubricGateway; +use Gibbon\Domain\Timetable\CourseEnrolmentGateway; +use Gibbon\Domain\Timetable\CourseGateway; +use Gibbon\Domain\User\RoleGateway; +use Gibbon\Module\ATL\Domain\ATLColumnGateway; +use Gibbon\Module\ATL\Domain\ATLEntryGateway; +use Gibbon\Services\Format; + +//Rubric includes +include './modules/Rubrics/moduleFunctions.php'; + +if (isActionAccessible($guid, $connection2, '/modules/ATL/atl_view.php') == false) { + $page->addError(__('You do not have access to this action.')); +} else { + //Proceed! + //Check if school year specified + $gibbonCourseClassID = $_GET['gibbonCourseClassID'] ?? ''; + $atlColumnID = $_GET['atlColumnID'] ?? ''; + $gibbonPersonID = $_GET['gibbonPersonID'] ?? ''; + $gibbonRubricID = $_GET['gibbonRubricID'] ?? ''; + if (empty($gibbonCourseClassID) || empty($atlColumnID) || empty($gibbonPersonID) || empty($gibbonRubricID)) { + $page->addError(__('You have not specified one or more required parameters.')); + } else { + $type = $_GET['type'] ?? ''; + $contextDBTableGibbonRubricIDField = ''; + if ($type == 'attainment') { + $contextDBTableGibbonRubricIDField = 'gibbonRubricIDAttainment'; + } else { + $contextDBTableGibbonRubricIDField = 'gibbonRubricID'; + } + + $allowed = false; + $roleGateway = $container->get(RoleGateway::class); + $roleCategory = $roleGateway->getByID($session->get('gibbonRoleIDPrimary'))['category'] ?? ''; + + if ($roleCategory == 'Staff') { + $courseGateway = $container->get(CourseGateway::class); + $result = $courseGateway->getCourseClassByID($gibbonCourseClassID); + $allowed = !empty($result); + } elseif ($roleCategory == 'Student' || $roleCategory == 'Parent') { + $courseEnrolmentGateway = $container->get(CourseEnrolmentGateway::class); + $result = $courseEnrolmentGateway->selectBy(['gibbonPersonID' => $gibbonPersonID, 'gibbonCourseClassID' => $gibbonCourseClassID, 'role' => 'Student']); + $allowed = $result->isNotEmpty(); + } + + if (!$allowed) { + $page->addError(__('The selected record does not exist, or you do not have access to it.')); + } else { + $atlColumnGateway = $container->get(ATLColumnGateway::class); + if (!$atlColumnGateway->exists($atlColumnID)) { + $page->addError(__('The selected record does not exist, or you do not have access to it.')); + } else { + $rubricGateway = $container->get(RubricGateway::class); + $rubric = $rubricGateway->getByID($gibbonRubricID); + + if (empty($rubric)) { + $page->addError(__('The specified record does not exist.')); + } else { + try { + $data4 = array('gibbonPersonID' => $gibbonPersonID, 'gibbonCourseClassID' => $gibbonCourseClassID); + $sql4 = "SELECT DISTINCT surname, preferredName, gibbonPerson.gibbonPersonID, image_240 FROM gibbonPerson JOIN gibbonCourseClassPerson ON (gibbonCourseClassPerson.gibbonPersonID=gibbonPerson.gibbonPersonID) WHERE gibbonPerson.gibbonPersonID=:gibbonPersonID AND gibbonCourseClassID=:gibbonCourseClassID AND status='Full' AND (dateStart IS NULL OR dateStart<='".date('Y-m-d')."') AND (dateEnd IS NULL OR dateEnd>='".date('Y-m-d')."') AND (role='Student' OR role='Student - Left')"; + $result4 = $connection2->prepare($sql4); + $result4->execute($data4); + } catch (PDOException $e) { + echo "
".$e->getMessage().'
'; + } + + if ($result4->rowCount() != 1) { + $page->addError(__('The selected record does not exist, or you do not have access to it.')); + } else { + //Let's go! + $row4 = $result4->fetch(); + + echo "

"; + echo $rubric['name'].'
'; + echo "".Format::name('', $row4['preferredName'], $row4['surname'], 'Student', true).''; + echo '

'; + + echo Format::photo($row4['image_240'], 75, 'inline-block align-top mt-1'); + + echo rubricView($guid, $connection2, $gibbonRubricID, false, $row4['gibbonPersonID'], 'atlColumn', 'atlColumnID', $atlColumnID, $contextDBTableGibbonRubricIDField, 'name', 'completeDate'); + } + } + } + } + } +} diff --git a/ATL/atl_write.php b/ATL/atl_write.php index 97d41a0..5ab6843 100644 --- a/ATL/atl_write.php +++ b/ATL/atl_write.php @@ -1,541 +1,446 @@ -. -*/ - -use Gibbon\Services\Format; - -//Module includes -include './modules/'.$session->get('module').'/moduleFunctions.php'; - -//Get gibbonHookID -$gibbonHookID = null; -try { - $data = array(); - $sql = "SELECT gibbonHookID FROM gibbonHook WHERE type='Student Profile' AND name='ATL'"; - $result = $connection2->prepare($sql); - $result->execute($data); -} catch (PDOException $e) { -} -if ($result->rowCount() == 1) { - $row = $result->fetch(); - $gibbonHookID = $row['gibbonHookID']; -} - -if (isActionAccessible($guid, $connection2, '/modules/ATL/atl_write.php') == false) { - //Acess denied - echo "
"; - echo __('Your request failed because you do not have access to this action.'); - echo '
'; -} else { - // Register scripts available to the core, but not included by default - $page->scripts->add('chart'); - - //Get action with highest precendence - $highestAction = getHighestGroupedAction($guid, $_GET['q'], $connection2); - if ($highestAction == false) { - echo "
"; - echo __('The highest grouped action cannot be determined.'); - echo '
'; - } else { - $alert = getAlert($guid, $connection2, 002); - - //Proceed! - //Get class variable - $gibbonCourseClassID = null; - if (isset($_GET['gibbonCourseClassID'])) { - $gibbonCourseClassID = $_GET['gibbonCourseClassID']; - } - if ($gibbonCourseClassID == '') { - try { - $data = array('gibbonSchoolYearID' => $session->get('gibbonSchoolYearID'), 'gibbonPersonID' => $session->get('gibbonPersonID')); - $sql = 'SELECT gibbonCourse.nameShort AS course, gibbonCourseClass.nameShort AS class, gibbonCourseClass.gibbonCourseClassID FROM gibbonCourse, gibbonCourseClass, gibbonCourseClassPerson WHERE gibbonSchoolYearID=:gibbonSchoolYearID AND gibbonCourse.gibbonCourseID=gibbonCourseClass.gibbonCourseID AND gibbonCourseClass.gibbonCourseClassID=gibbonCourseClassPerson.gibbonCourseClassID AND gibbonCourseClassPerson.gibbonPersonID=:gibbonPersonID ORDER BY course, class'; - $result = $connection2->prepare($sql); - $result->execute($data); - } catch (PDOException $e) { - echo "
".$e->getMessage().'
'; - } - if ($result->rowCount() > 0) { - $row = $result->fetch(); - $gibbonCourseClassID = $row['gibbonCourseClassID']; - } - } - if ($gibbonCourseClassID == '') { - $page->breadcrumbs->add(__('Write ATLs')); - echo "
"; - echo 'Use the class listing on the right to choose an ATL to write.'; - echo '
'; - } else { - //Check existence of and access to this class. - try { - if ($highestAction == 'Write ATLs_all') { - $data = array('gibbonCourseClassID' => $gibbonCourseClassID); - $sql = "SELECT gibbonCourse.nameShort AS course, gibbonCourse.name AS courseName, gibbonCourseClass.nameShort AS class, gibbonYearGroupIDList FROM gibbonCourse JOIN gibbonCourseClass ON (gibbonCourse.gibbonCourseID=gibbonCourseClass.gibbonCourseID) WHERE gibbonCourseClassID=:gibbonCourseClassID AND gibbonCourseClass.reportable='Y' "; - } else { - $data = array('gibbonCourseClassID' => $gibbonCourseClassID, 'gibbonPersonID' => $session->get('gibbonPersonID'), 'gibbonCourseClassID2' => $gibbonCourseClassID, 'gibbonPersonID2' => $session->get('gibbonPersonID'), 'gibbonSchoolYearID' => $session->get('gibbonSchoolYearID')); - $sql = "(SELECT gibbonCourse.nameShort AS course, gibbonCourse.name AS courseName, gibbonCourseClass.nameShort AS class, gibbonYearGroupIDList FROM gibbonCourse JOIN gibbonCourseClass ON (gibbonCourse.gibbonCourseID=gibbonCourseClass.gibbonCourseID) JOIN gibbonCourseClassPerson ON (gibbonCourseClassPerson.gibbonCourseClassID=gibbonCourseClass.gibbonCourseClassID) WHERE gibbonCourseClass.gibbonCourseClassID=:gibbonCourseClassID AND gibbonPersonID=:gibbonPersonID AND (role='Teacher' OR role='Assistant') AND gibbonCourseClass.reportable='Y') - UNION - (SELECT gibbonCourse.nameShort AS course, gibbonCourse.name AS courseName, gibbonCourseClass.nameShort AS class, gibbonYearGroupIDList FROM gibbonCourseClass JOIN gibbonCourse ON (gibbonCourseClass.gibbonCourseID=gibbonCourse.gibbonCourseID) JOIN gibbonDepartment ON (gibbonCourse.gibbonDepartmentID=gibbonDepartment.gibbonDepartmentID) JOIN gibbonDepartmentStaff ON (gibbonDepartmentStaff.gibbonDepartmentID=gibbonDepartment.gibbonDepartmentID) WHERE gibbonCourseClass.gibbonCourseClassID=:gibbonCourseClassID2 AND gibbonDepartmentStaff.gibbonPersonID=:gibbonPersonID2 AND gibbonDepartmentStaff.role='Coordinator' AND gibbonCourse.gibbonSchoolYearID=:gibbonSchoolYearID AND gibbonCourseClass.reportable='Y')"; - } - $result = $connection2->prepare($sql); - $result->execute($data); - } catch (PDOException $e) { - echo "
".$e->getMessage().'
'; - } - if ($result->rowCount() != 1) { - $page->breadcrumbs->add(__('Write ATLs')); - echo "
"; - echo __('The specified record does not exist or you do not have access to it.'); - echo '
'; - } else { - $row = $result->fetch(); - $courseName = $row['courseName']; - $gibbonYearGroupIDList = $row['gibbonYearGroupIDList']; - - $page->breadcrumbs->add(__('Write {courseClass} ATLs', ['courseClass' => $row['course'].'.'.$row['class']])); - - if (isset($_GET['deleteReturn'])) { - $deleteReturn = $_GET['deleteReturn']; - } else { - $deleteReturn = ''; - } - $deleteReturnMessage = ''; - $class = 'error'; - if (!($deleteReturn == '')) { - if ($deleteReturn == 'success0') { - $deleteReturnMessage = __('Your request was completed successfully.'); - $class = 'success'; - } - echo "
"; - echo $deleteReturnMessage; - echo '
'; - } - - //Get teacher list - $teaching = false; - try { - $data = array('gibbonCourseClassID' => $gibbonCourseClassID); - $sql = "SELECT gibbonPerson.gibbonPersonID, title, surname, preferredName, gibbonCourseClassPerson.reportable FROM gibbonCourseClassPerson JOIN gibbonPerson ON (gibbonCourseClassPerson.gibbonPersonID=gibbonPerson.gibbonPersonID) WHERE (role='Teacher' OR role='Assistant') AND gibbonCourseClassID=:gibbonCourseClassID ORDER BY surname, preferredName"; - $result = $connection2->prepare($sql); - $result->execute($data); - } catch (PDOException $e) { - echo "
".$e->getMessage().'
'; - } - - if ($result->rowCount() > 0) { - echo "

"; - echo __('Teachers'); - echo '

'; - echo '
    '; - while ($row = $result->fetch()) { - if ($row['reportable'] != 'Y') continue; - - echo '
  • '.Format::name($row['title'], $row['preferredName'], $row['surname'], 'Staff').'
  • '; - if ($row['gibbonPersonID'] == $session->get('gibbonPersonID')) { - $teaching = true; - } - } - echo '
'; - } - - //Print marks - echo '

'; - echo __('Marks'); - echo '

'; - - //Count number of columns - try { - $data = array('gibbonCourseClassID' => $gibbonCourseClassID); - $sql = 'SELECT * FROM atlColumn WHERE gibbonCourseClassID=:gibbonCourseClassID ORDER BY complete, completeDate DESC'; - $result = $connection2->prepare($sql); - $result->execute($data); - } catch (PDOException $e) { - echo "
".$e->getMessage().'
'; - } - $columns = $result->rowCount(); - if ($columns < 1) { - echo "
"; - echo __('There are no records to display.'); - echo '
'; - } else { - $x = null; - if (isset($_GET['page'])) { - $x = $_GET['page']; - } - if ($x == '') { - $x = 0; - } - $columnsPerPage = 3; - $columnsThisPage = 3; - - if ($columns < 1) { - echo "
"; - echo __('There are no records to display.'); - echo '
'; - } else { - if ($columns < 3) { - $columnsThisPage = $columns; - } - if ($columns - ($x * $columnsPerPage) < 3) { - $columnsThisPage = $columns - ($x * $columnsPerPage); - } - try { - $data = array('gibbonCourseClassID' => $gibbonCourseClassID); - $sql = 'SELECT * FROM atlColumn WHERE gibbonCourseClassID=:gibbonCourseClassID ORDER BY complete, completeDate DESC LIMIT '.($x * $columnsPerPage).', '.$columnsPerPage; - $result = $connection2->prepare($sql); - $result->execute($data); - } catch (PDOException $e) { - echo "
".$e->getMessage().'
'; - } - - //Work out details for external assessment display - $externalAssessment = false; - if (isActionAccessible($guid, $connection2, '/modules/External Assessment/externalAssessment_details.php')) { - $gibbonYearGroupIDListArray = (explode(',', $gibbonYearGroupIDList)); - if (count($gibbonYearGroupIDListArray) == 1) { - $primaryExternalAssessmentByYearGroup = unserialize(getSettingByScope($connection2, 'School Admin', 'primaryExternalAssessmentByYearGroup')); - if ($primaryExternalAssessmentByYearGroup[$gibbonYearGroupIDListArray[0]] != '' and $primaryExternalAssessmentByYearGroup[$gibbonYearGroupIDListArray[0]] != '-') { - $gibbonExternalAssessmentID = substr($primaryExternalAssessmentByYearGroup[$gibbonYearGroupIDListArray[0]], 0, strpos($primaryExternalAssessmentByYearGroup[$gibbonYearGroupIDListArray[0]], '-')); - $gibbonExternalAssessmentIDCategory = substr($primaryExternalAssessmentByYearGroup[$gibbonYearGroupIDListArray[0]], (strpos($primaryExternalAssessmentByYearGroup[$gibbonYearGroupIDListArray[0]], '-') + 1)); - - try { - $dataExternalAssessment = array('gibbonExternalAssessmentID' => $gibbonExternalAssessmentID, 'category' => $gibbonExternalAssessmentIDCategory); - $courseNameTokens = explode(' ', $courseName); - $courseWhere = ' AND ('; - $whereCount = 1; - foreach ($courseNameTokens as $courseNameToken) { - if (strlen($courseNameToken) > 3) { - $dataExternalAssessment['token'.$whereCount] = '%'.$courseNameToken.'%'; - $courseWhere .= "gibbonExternalAssessmentField.name LIKE :token$whereCount OR "; - ++$whereCount; - } - } - if ($whereCount < 1) { - $courseWhere = ''; - } else { - $courseWhere = substr($courseWhere, 0, -4).')'; - } - $sqlExternalAssessment = "SELECT gibbonExternalAssessment.name AS assessment, gibbonExternalAssessmentField.name, gibbonExternalAssessmentFieldID, category FROM gibbonExternalAssessmentField JOIN gibbonExternalAssessment ON (gibbonExternalAssessmentField.gibbonExternalAssessmentID=gibbonExternalAssessment.gibbonExternalAssessmentID) WHERE gibbonExternalAssessmentField.gibbonExternalAssessmentID=:gibbonExternalAssessmentID AND category=:category $courseWhere ORDER BY name"; - $resultExternalAssessment = $connection2->prepare($sqlExternalAssessment); - $resultExternalAssessment->execute($dataExternalAssessment); - } catch (PDOException $e) { - echo "
".$e->getMessage().'
'; - } - if ($resultExternalAssessment->rowCount() >= 1) { - $rowExternalAssessment = $resultExternalAssessment->fetch(); - $externalAssessment = true; - $externalAssessmentFields = array(); - $externalAssessmentFields[0] = $rowExternalAssessment['gibbonExternalAssessmentFieldID']; - $externalAssessmentFields[1] = $rowExternalAssessment['name']; - $externalAssessmentFields[2] = $rowExternalAssessment['assessment']; - $externalAssessmentFields[3] = $rowExternalAssessment['category']; - } - } - } - } - - //Print table header - echo "
"; - echo "
"; - if ($x <= 0) { - echo __('Newer'); - } else { - echo "".__('Newer').''; - } - echo ' | '; - if ((($x + 1) * $columnsPerPage) >= $columns) { - echo __('Older'); - } else { - echo "".__('Older').''; - } - echo '
'; - echo '
'; - - echo ""; - echo ""; - echo "'; - - //Show Baseline data header - if ($externalAssessment == true) { - echo "'; - } - - $columnID = array(); - for ($i = 0; $i < $columnsThisPage; ++$i) { - $row = $result->fetch(); - if ($row === false) { - $columnID[$i] = false; - } else { - $columnID[$i] = $row['atlColumnID']; - $gibbonRubricID[$i] = $row['gibbonRubricID']; - } - - //Column count - $span = 1; - $contents = true; - if ($gibbonRubricID[$i] != '') { - ++$span; - } - if ($span == 1) { - $contents = false; - } - - echo "'; - } - echo ''; - - echo ""; - for ($i = 0; $i < $columnsThisPage; ++$i) { - if ($columnID[$i] == false or $contents == false) { - echo "'; - } else { - $leftBorder = false; - //Set up complete checkbox - $leftBorderStyle = ''; - if ($leftBorder == false) { - $leftBorder = true; - $leftBorderStyle = 'border-left: 2px solid #666;'; - } - echo "'; - //Set up rubric box - if ($gibbonRubricID[$i] != '') { - $leftBorderStyle = ''; - if ($leftBorder == false) { - $leftBorder = true; - $leftBorderStyle = 'border-left: 2px solid #666;'; - } - echo "'; - } - } - } - echo ''; - - $count = 0; - $rowNum = 'odd'; - - try { - $dataStudents = array('gibbonCourseClassID' => $gibbonCourseClassID); - $sqlStudents = "SELECT title, surname, preferredName, gibbonPerson.gibbonPersonID, dateStart FROM gibbonCourseClassPerson JOIN gibbonPerson ON (gibbonCourseClassPerson.gibbonPersonID=gibbonPerson.gibbonPersonID) WHERE role='Student' AND gibbonCourseClassID=:gibbonCourseClassID AND status='Full' AND (dateStart IS NULL OR dateStart<='".date('Y-m-d')."') AND (dateEnd IS NULL OR dateEnd>='".date('Y-m-d')."') AND gibbonCourseClassPerson.reportable='Y' ORDER BY surname, preferredName"; - $resultStudents = $connection2->prepare($sqlStudents); - $resultStudents->execute($dataStudents); - } catch (PDOException $e) { - echo "
".$e->getMessage().'
'; - } - if ($resultStudents->rowCount() < 1) { - echo ''; - echo ''; - echo ''; - } else { - while ($rowStudents = $resultStudents->fetch()) { - if ($count % 2 == 0) { - $rowNum = 'even'; - } else { - $rowNum = 'odd'; - } - ++$count; - - //COLOR ROW BY STATUS! - echo ""; - echo ''; - - if ($externalAssessment == true) { - echo "'; - } - - for ($i = 0; $i < $columnsThisPage; ++$i) { - $row = $result->fetch(); - try { - $dataEntry = array('atlColumnID' => $columnID[($i)], 'gibbonPersonIDStudent' => $rowStudents['gibbonPersonID']); - $sqlEntry = 'SELECT atlEntry.* FROM atlEntry JOIN atlColumn ON (atlEntry.atlColumnID=atlColumn.atlColumnID) WHERE atlEntry.atlColumnID=:atlColumnID AND gibbonPersonIDStudent=:gibbonPersonIDStudent'; - $resultEntry = $connection2->prepare($sqlEntry); - $resultEntry->execute($dataEntry); - } catch (PDOException $e) { - echo "
".$e->getMessage().'
'; - } - if ($resultEntry->rowCount() == 1) { - $rowEntry = $resultEntry->fetch(); - $leftBorder = false; - - //Complete - $leftBorderStyle = ''; - if ($leftBorder == false) { - $leftBorder = true; - $leftBorderStyle = 'border-left: 2px solid #666;'; - } - echo "'; - //Rubric - if ($gibbonRubricID[$i] != '') { - $leftBorderStyle = ''; - if ($leftBorder == false) { - $leftBorder = true; - $leftBorderStyle = 'border-left: 2px solid #666;'; - } - echo "'; - } - } else { - $emptySpan = 1; - if ($gibbonRubricID[$i] != '') { - ++$emptySpan; - } - if ($emptySpan > 0) { - echo ""; - } - } - if (isset($submission[$i])) { - if ($submission[$i] == true) { - $leftBorderStyle = ''; - if ($leftBorder == false) { - $leftBorder = true; - $leftBorderStyle = 'border-left: 2px solid #666;'; - } - echo "'; - } - } - } - echo ''; - } - } - echo '
"; - echo __('Student'); - echo '"; - $title = __($externalAssessmentFields[2]).' | '; - $title .= __(substr($externalAssessmentFields[3], (strpos($externalAssessmentFields[3], '_') + 1))).' | '; - $title .= __($externalAssessmentFields[1]); - - //Get PAS - $PAS = getSettingByScope($connection2, 'System', 'primaryAssessmentScale'); - try { - $dataPAS = array('gibbonScaleID' => $PAS); - $sqlPAS = 'SELECT * FROM gibbonScale WHERE gibbonScaleID=:gibbonScaleID'; - $resultPAS = $connection2->prepare($sqlPAS); - $resultPAS->execute($dataPAS); - } catch (PDOException $e) { - } - if ($resultPAS->rowCount() == 1) { - $rowPAS = $resultPAS->fetch(); - $title .= ' | '.$rowPAS['name'].' '.__('Scale').' '; - } - - echo "
"; - echo __('Baseline').'
'; - echo '
'; - echo '
"; - echo "".$row['name'].'
'; - echo ""; - if ($row['completeDate'] != '') { - echo __('Marked on').' '.dateConvertBack($guid, $row['completeDate']).'
'; - } else { - echo __('Unmarked').'
'; - } - echo '

'; - if (isActionAccessible($guid, $connection2, '/modules/ATL/atl_write_data.php')) { - echo " "; - } - echo '
"; - - echo '"; - echo "".__('Complete').''; - echo '"; - echo "".__('Rubric').''; - echo '
'; - echo ''.__('There are no records to display.').''; - echo '
'; - echo "'; - echo '"; - try { - $dataEntry = array('gibbonPersonID' => $rowStudents['gibbonPersonID'], 'gibbonExternalAssessmentFieldID' => $externalAssessmentFields[0]); - $sqlEntry = "SELECT gibbonScaleGrade.value, gibbonScaleGrade.descriptor, gibbonExternalAssessmentStudent.date FROM gibbonExternalAssessmentStudentEntry JOIN gibbonExternalAssessmentStudent ON (gibbonExternalAssessmentStudentEntry.gibbonExternalAssessmentStudentID=gibbonExternalAssessmentStudent.gibbonExternalAssessmentStudentID) JOIN gibbonScaleGrade ON (gibbonExternalAssessmentStudentEntry.gibbonScaleGradeIDPrimaryAssessmentScale=gibbonScaleGrade.gibbonScaleGradeID) WHERE gibbonPersonID=:gibbonPersonID AND gibbonExternalAssessmentFieldID=:gibbonExternalAssessmentFieldID AND NOT gibbonScaleGradeIDPrimaryAssessmentScale='' ORDER BY date DESC"; - $resultEntry = $connection2->prepare($sqlEntry); - $resultEntry->execute($dataEntry); - } catch (PDOException $e) { - echo "
".$e->getMessage().'
'; - } - if ($resultEntry->rowCount() >= 1) { - $rowEntry = $resultEntry->fetch(); - echo "".__($rowEntry['value']).''; - } - echo '
"; - $checked = ''; - if ($rowEntry['complete'] == 'Y') { - $checked = 'checked'; - } - echo ''; - echo '"; - if ($gibbonRubricID[$i] != '') { - echo ""; - } - echo '"; - try { - $dataWork = array('gibbonPlannerEntryID' => $rowEntry['gibbonPlannerEntryID'], 'gibbonPersonID' => $rowStudents['gibbonPersonID']); - $sqlWork = 'SELECT * FROM gibbonPlannerEntryHomework WHERE gibbonPlannerEntryID=:gibbonPlannerEntryID AND gibbonPersonID=:gibbonPersonID ORDER BY count DESC'; - $resultWork = $connection2->prepare($sqlWork); - $resultWork->execute($dataWork); - } catch (PDOException $e) { - echo "
".$e->getMessage().'
'; - } - if ($resultWork->rowCount() > 0) { - $rowWork = $resultWork->fetch(); - - if ($rowWork['status'] == 'Exemption') { - $linkText = __('Exe'); - } elseif ($rowWork['version'] == 'Final') { - $linkText = __('Fin'); - } else { - $linkText = __('Dra').$rowWork['count']; - } - - $style = ''; - $status = 'On Time'; - if ($rowWork['status'] == 'Exemption') { - $status = __('Exemption'); - } elseif ($rowWork['status'] == 'Late') { - $style = "style='color: #ff0000; font-weight: bold; border: 2px solid #ff0000; padding: 2px 4px'"; - $status = __('Late'); - } - - if ($rowWork['type'] == 'File') { - echo "$linkText"; - } elseif ($rowWork['type'] == 'Link') { - echo "$linkText"; - } else { - echo "$linkText"; - } - } else { - if (date('Y-m-d H:i:s') < $homeworkDueDateTime[$i]) { - echo "Pen"; - } else { - if ($rowStudents['dateStart'] > $lessonDate[$i]) { - echo "".__('NA').''; - } else { - if ($rowSub['homeworkSubmissionRequired'] == 'Compulsory') { - echo "".__('Inc').''; - } else { - echo "".__('NA').''; - } - } - } - } - echo '
'; - } - } - } - } - - //Print sidebar - $session->set('sidebarExtra', sidebarExtra($guid, $connection2, $gibbonCourseClassID, 'write', $highestAction)); - } -} +. +*/ + +use Gibbon\Domain\School\GradeScaleGateway; +use Gibbon\Domain\System\HookGateway; +use Gibbon\Domain\System\SettingGateway; +use Gibbon\Services\Format; + +//Module includes +require_once __DIR__ . '/moduleFunctions.php'; + +if (isActionAccessible($guid, $connection2, '/modules/ATL/atl_write.php') == false) { + //Acess denied + $page->addError(__('Your request failed because you do not have access to this action.')); +} else { + //Get gibbonHookID + $hookGateway = $container->get(HookGateway::class); + $hook = $hookGateway->selectBy(['type' => 'Student Profile', 'name' => 'ATL']); + if ($hook->isNotEmpty()) { + $row = $hook->fetch(); + $gibbonHookID = $row['gibbonHookID']; + } + + $settingGateway = $container->get(SettingGateway::class); + + // Register scripts available to the core, but not included by default + $page->scripts->add('chart'); + + //Get action with highest precendence + $highestAction = getHighestGroupedAction($guid, $_GET['q'], $connection2); + if ($highestAction == false) { + $page->addError(__('The highest grouped action cannot be determined.')); + } else { + //Proceed! + //Get class variable + $gibbonCourseClassID = $_GET['gibbonCourseClassID'] ?? ''; + if ($gibbonCourseClassID == '') { + try { + $data = array('gibbonSchoolYearID' => $session->get('gibbonSchoolYearID'), 'gibbonPersonID' => $session->get('gibbonPersonID')); + $sql = 'SELECT gibbonCourse.nameShort AS course, gibbonCourseClass.nameShort AS class, gibbonCourseClass.gibbonCourseClassID FROM gibbonCourse, gibbonCourseClass, gibbonCourseClassPerson WHERE gibbonSchoolYearID=:gibbonSchoolYearID AND gibbonCourse.gibbonCourseID=gibbonCourseClass.gibbonCourseID AND gibbonCourseClass.gibbonCourseClassID=gibbonCourseClassPerson.gibbonCourseClassID AND gibbonCourseClassPerson.gibbonPersonID=:gibbonPersonID ORDER BY course, class'; + $result = $connection2->prepare($sql); + $result->execute($data); + } catch (PDOException $e) { + } + + if ($result->rowCount() > 0) { + $row = $result->fetch(); + $gibbonCourseClassID = $row['gibbonCourseClassID']; + } + } + if ($gibbonCourseClassID == '') { + $page->breadcrumbs->add(__('Write ATLs')); + $page->addWarning(__('Use the class listing on the right to choose an ATL to write.')); + } else { + //Check existence of and access to this class. + try { + if ($highestAction == 'Write ATLs_all') { + $data = array('gibbonCourseClassID' => $gibbonCourseClassID); + $sql = "SELECT gibbonCourse.nameShort AS course, gibbonCourse.name AS courseName, gibbonCourseClass.nameShort AS class, gibbonYearGroupIDList FROM gibbonCourse JOIN gibbonCourseClass ON (gibbonCourse.gibbonCourseID=gibbonCourseClass.gibbonCourseID) WHERE gibbonCourseClassID=:gibbonCourseClassID AND gibbonCourseClass.reportable='Y' "; + } else { + $data = array('gibbonCourseClassID' => $gibbonCourseClassID, 'gibbonPersonID' => $session->get('gibbonPersonID'), 'gibbonCourseClassID2' => $gibbonCourseClassID, 'gibbonPersonID2' => $session->get('gibbonPersonID'), 'gibbonSchoolYearID' => $session->get('gibbonSchoolYearID')); + $sql = "(SELECT gibbonCourse.nameShort AS course, gibbonCourse.name AS courseName, gibbonCourseClass.nameShort AS class, gibbonYearGroupIDList FROM gibbonCourse JOIN gibbonCourseClass ON (gibbonCourse.gibbonCourseID=gibbonCourseClass.gibbonCourseID) JOIN gibbonCourseClassPerson ON (gibbonCourseClassPerson.gibbonCourseClassID=gibbonCourseClass.gibbonCourseClassID) WHERE gibbonCourseClass.gibbonCourseClassID=:gibbonCourseClassID AND gibbonPersonID=:gibbonPersonID AND (role='Teacher' OR role='Assistant') AND gibbonCourseClass.reportable='Y') + UNION + (SELECT gibbonCourse.nameShort AS course, gibbonCourse.name AS courseName, gibbonCourseClass.nameShort AS class, gibbonYearGroupIDList FROM gibbonCourseClass JOIN gibbonCourse ON (gibbonCourseClass.gibbonCourseID=gibbonCourse.gibbonCourseID) JOIN gibbonDepartment ON (gibbonCourse.gibbonDepartmentID=gibbonDepartment.gibbonDepartmentID) JOIN gibbonDepartmentStaff ON (gibbonDepartmentStaff.gibbonDepartmentID=gibbonDepartment.gibbonDepartmentID) WHERE gibbonCourseClass.gibbonCourseClassID=:gibbonCourseClassID2 AND gibbonDepartmentStaff.gibbonPersonID=:gibbonPersonID2 AND gibbonDepartmentStaff.role='Coordinator' AND gibbonCourse.gibbonSchoolYearID=:gibbonSchoolYearID AND gibbonCourseClass.reportable='Y')"; + } + $result = $connection2->prepare($sql); + $result->execute($data); + } catch (PDOException $e) { + } + if ($result->rowCount() != 1) { + $page->breadcrumbs->add(__('Write ATLs')); + $page->addError(__('The specified record does not exist or you do not have access to it.')); + } else { + $row = $result->fetch(); + $courseName = $row['courseName']; + $gibbonYearGroupIDList = $row['gibbonYearGroupIDList']; + + $page->breadcrumbs->add(__('Write {courseClass} ATLs', ['courseClass' => $row['course'].'.'.$row['class']])); + + //Get teacher list + $teaching = false; + try { + $data = array('gibbonCourseClassID' => $gibbonCourseClassID); + $sql = "SELECT gibbonPerson.gibbonPersonID, title, surname, preferredName, gibbonCourseClassPerson.reportable FROM gibbonCourseClassPerson JOIN gibbonPerson ON (gibbonCourseClassPerson.gibbonPersonID=gibbonPerson.gibbonPersonID) WHERE (role='Teacher' OR role='Assistant') AND gibbonCourseClassID=:gibbonCourseClassID ORDER BY surname, preferredName"; + $result = $connection2->prepare($sql); + $result->execute($data); + } catch (PDOException $e) { + } + + if ($result->rowCount() > 0) { + echo "

"; + echo __('Teachers'); + echo '

'; + echo '
    '; + while ($row = $result->fetch()) { + if ($row['reportable'] != 'Y') continue; + + echo '
  • '.Format::name($row['title'], $row['preferredName'], $row['surname'], 'Staff').'
  • '; + if ($row['gibbonPersonID'] == $session->get('gibbonPersonID')) { + $teaching = true; + } + } + echo '
'; + } + + //Print marks + echo '

'; + echo __('Marks'); + echo '

'; + + //Count number of columns + try { + $data = array('gibbonCourseClassID' => $gibbonCourseClassID); + $sql = 'SELECT * FROM atlColumn WHERE gibbonCourseClassID=:gibbonCourseClassID ORDER BY complete, completeDate DESC'; + $result = $connection2->prepare($sql); + $result->execute($data); + } catch (PDOException $e) { + echo "
".$e->getMessage().'
'; + } + $columns = $result->rowCount(); + if ($columns < 1) { + echo "
"; + echo __('There are no records to display.'); + echo '
'; + } else { + $x = null; + if (isset($_GET['page'])) { + $x = $_GET['page']; + } + if ($x == '') { + $x = 0; + } + $columnsPerPage = 3; + $columnsThisPage = 3; + + if ($columns < 1) { + echo "
"; + echo __('There are no records to display.'); + echo '
'; + } else { + if ($columns < 3) { + $columnsThisPage = $columns; + } + if ($columns - ($x * $columnsPerPage) < 3) { + $columnsThisPage = $columns - ($x * $columnsPerPage); + } + try { + $data = array('gibbonCourseClassID' => $gibbonCourseClassID); + $sql = 'SELECT * FROM atlColumn WHERE gibbonCourseClassID=:gibbonCourseClassID ORDER BY complete, completeDate DESC LIMIT '.($x * $columnsPerPage).', '.$columnsPerPage; + $result = $connection2->prepare($sql); + $result->execute($data); + } catch (PDOException $e) { + echo "
".$e->getMessage().'
'; + } + + //Work out details for external assessment display + $externalAssessment = false; + if (isActionAccessible($guid, $connection2, '/modules/External Assessment/externalAssessment_details.php')) { + $gibbonYearGroupIDListArray = (explode(',', $gibbonYearGroupIDList)); + if (count($gibbonYearGroupIDListArray) == 1) { + $primaryExternalAssessmentByYearGroup = unserialize($settingGateway->getSettingByScope('School Admin', 'primaryExternalAssessmentByYearGroup')); + if ($primaryExternalAssessmentByYearGroup[$gibbonYearGroupIDListArray[0]] != '' and $primaryExternalAssessmentByYearGroup[$gibbonYearGroupIDListArray[0]] != '-') { + $gibbonExternalAssessmentID = substr($primaryExternalAssessmentByYearGroup[$gibbonYearGroupIDListArray[0]], 0, strpos($primaryExternalAssessmentByYearGroup[$gibbonYearGroupIDListArray[0]], '-')); + $gibbonExternalAssessmentIDCategory = substr($primaryExternalAssessmentByYearGroup[$gibbonYearGroupIDListArray[0]], (strpos($primaryExternalAssessmentByYearGroup[$gibbonYearGroupIDListArray[0]], '-') + 1)); + + try { + $dataExternalAssessment = array('gibbonExternalAssessmentID' => $gibbonExternalAssessmentID, 'category' => $gibbonExternalAssessmentIDCategory); + $courseNameTokens = explode(' ', $courseName); + $courseWhere = ' AND ('; + $whereCount = 1; + foreach ($courseNameTokens as $courseNameToken) { + if (strlen($courseNameToken) > 3) { + $dataExternalAssessment['token'.$whereCount] = '%'.$courseNameToken.'%'; + $courseWhere .= "gibbonExternalAssessmentField.name LIKE :token$whereCount OR "; + ++$whereCount; + } + } + if ($whereCount < 1) { + $courseWhere = ''; + } else { + $courseWhere = substr($courseWhere, 0, -4).')'; + } + $sqlExternalAssessment = "SELECT gibbonExternalAssessment.name AS assessment, gibbonExternalAssessmentField.name, gibbonExternalAssessmentFieldID, category FROM gibbonExternalAssessmentField JOIN gibbonExternalAssessment ON (gibbonExternalAssessmentField.gibbonExternalAssessmentID=gibbonExternalAssessment.gibbonExternalAssessmentID) WHERE gibbonExternalAssessmentField.gibbonExternalAssessmentID=:gibbonExternalAssessmentID AND category=:category $courseWhere ORDER BY name"; + $resultExternalAssessment = $connection2->prepare($sqlExternalAssessment); + $resultExternalAssessment->execute($dataExternalAssessment); + } catch (PDOException $e) { + echo "
".$e->getMessage().'
'; + } + if ($resultExternalAssessment->rowCount() >= 1) { + $rowExternalAssessment = $resultExternalAssessment->fetch(); + $externalAssessment = true; + $externalAssessmentFields = array(); + $externalAssessmentFields[0] = $rowExternalAssessment['gibbonExternalAssessmentFieldID']; + $externalAssessmentFields[1] = $rowExternalAssessment['name']; + $externalAssessmentFields[2] = $rowExternalAssessment['assessment']; + $externalAssessmentFields[3] = $rowExternalAssessment['category']; + } + } + } + } + + //Print table header + echo "
"; + echo "
"; + if ($x <= 0) { + echo __('Newer'); + } else { + echo "".__('Newer').''; + } + echo ' | '; + if ((($x + 1) * $columnsPerPage) >= $columns) { + echo __('Older'); + } else { + echo "".__('Older').''; + } + echo '
'; + echo '
'; + + echo ""; + echo ""; + echo "'; + + //Show Baseline data header + if ($externalAssessment == true) { + echo "'; + } + + $columnID = []; + for ($i = 0; $i < $columnsThisPage; ++$i) { + $row = $result->fetch(); + if ($row === false) { + $columnID[$i] = false; + } else { + $columnID[$i] = $row['atlColumnID']; + $gibbonRubricID[$i] = $row['gibbonRubricID']; + } + + //Column count + $span = 1; + $contents = true; + if ($gibbonRubricID[$i] != '') { + ++$span; + } + if ($span == 1) { + $contents = false; + } + + echo "'; + } + echo ''; + + echo ""; + for ($i = 0; $i < $columnsThisPage; ++$i) { + if ($columnID[$i] == false or $contents == false) { + echo "'; + } else { + $leftBorder = false; + //Set up complete checkbox + $leftBorderStyle = ''; + if ($leftBorder == false) { + $leftBorder = true; + $leftBorderStyle = 'border-left: 2px solid #666;'; + } + echo "'; + //Set up rubric box + if ($gibbonRubricID[$i] != '') { + $leftBorderStyle = ''; + if ($leftBorder == false) { + $leftBorder = true; + $leftBorderStyle = 'border-left: 2px solid #666;'; + } + echo "'; + } + } + } + echo ''; + + $count = 0; + $rowNum = 'odd'; + + try { + $dataStudents = array('gibbonCourseClassID' => $gibbonCourseClassID); + $sqlStudents = "SELECT title, surname, preferredName, gibbonPerson.gibbonPersonID, dateStart FROM gibbonCourseClassPerson JOIN gibbonPerson ON (gibbonCourseClassPerson.gibbonPersonID=gibbonPerson.gibbonPersonID) WHERE role='Student' AND gibbonCourseClassID=:gibbonCourseClassID AND status='Full' AND (dateStart IS NULL OR dateStart<='".date('Y-m-d')."') AND (dateEnd IS NULL OR dateEnd>='".date('Y-m-d')."') AND gibbonCourseClassPerson.reportable='Y' ORDER BY surname, preferredName"; + $resultStudents = $connection2->prepare($sqlStudents); + $resultStudents->execute($dataStudents); + } catch (PDOException $e) { + } + if ($resultStudents->rowCount() < 1) { + echo ''; + echo ''; + echo ''; + } else { + while ($rowStudents = $resultStudents->fetch()) { + if ($count % 2 == 0) { + $rowNum = 'even'; + } else { + $rowNum = 'odd'; + } + ++$count; + + //COLOR ROW BY STATUS! + echo ""; + echo ''; + + if ($externalAssessment == true) { + echo "'; + } + + for ($i = 0; $i < $columnsThisPage; ++$i) { + $row = $result->fetch(); + try { + $dataEntry = array('atlColumnID' => $columnID[($i)], 'gibbonPersonIDStudent' => $rowStudents['gibbonPersonID']); + $sqlEntry = 'SELECT atlEntry.* FROM atlEntry JOIN atlColumn ON (atlEntry.atlColumnID=atlColumn.atlColumnID) WHERE atlEntry.atlColumnID=:atlColumnID AND gibbonPersonIDStudent=:gibbonPersonIDStudent'; + $resultEntry = $connection2->prepare($sqlEntry); + $resultEntry->execute($dataEntry); + } catch (PDOException $e) { + echo "
".$e->getMessage().'
'; + } + if ($resultEntry->rowCount() == 1) { + $rowEntry = $resultEntry->fetch(); + $leftBorder = false; + + //Complete + $leftBorderStyle = ''; + if ($leftBorder == false) { + $leftBorder = true; + $leftBorderStyle = 'border-left: 2px solid #666;'; + } + echo "'; + //Rubric + if ($gibbonRubricID[$i] != '') { + $leftBorderStyle = ''; + if ($leftBorder == false) { + $leftBorder = true; + $leftBorderStyle = 'border-left: 2px solid #666;'; + } + echo "'; + } + } else { + $emptySpan = 1; + if ($gibbonRubricID[$i] != '') { + ++$emptySpan; + } + if ($emptySpan > 0) { + echo ""; + } + } + } + echo ''; + } + } + echo '
"; + echo __('Student'); + echo '"; + $title = __($externalAssessmentFields[2]).' | '; + $title .= __(substr($externalAssessmentFields[3], (strpos($externalAssessmentFields[3], '_') + 1))).' | '; + $title .= __($externalAssessmentFields[1]); + + //Get PAS + $PAS = $settingGateway->getSettingByScope('System', 'primaryAssessmentScale'); + $gradeScaleGateway = $container->get(GradeScaleGateway::class); + $gradeScale = $gradeScaleGateway->getByID($PAS); + + if (!isempty($gradeScale)) { + $title .= ' | '.$gradeScale['name'].' '.__('Scale').' '; + } + + echo "
"; + echo __('Baseline').'
'; + echo '
'; + echo '
"; + echo "".$row['name'].'
'; + echo ""; + if ($row['forStudents'] == 'Y') { + if ($row['completeDate'] != '') { + echo __('Due on').' '.Format::date($row['completeDate']).'
'; + } else { + echo __('No Due Date').'
'; + } + } else { + if ($row['completeDate'] != '') { + echo __('Marked on').' '.Format::date($row['completeDate']).'
'; + } else { + echo __('Unmarked').'
'; + } + } + echo '

'; + if (isActionAccessible($guid, $connection2, '/modules/ATL/atl_write_data.php') && $row['forStudents'] == 'N') { //TODO: Change for students check to be more sensible + echo " "; + } + echo '
"; + + echo '"; + echo "".__('Complete').''; + echo '"; + echo "".__('Rubric').''; + echo '
'; + echo ''.__('There are no records to display.').''; + echo '
'; + echo "'; + echo '"; + try { + $dataEntry = array('gibbonPersonID' => $rowStudents['gibbonPersonID'], 'gibbonExternalAssessmentFieldID' => $externalAssessmentFields[0]); + $sqlEntry = "SELECT gibbonScaleGrade.value, gibbonScaleGrade.descriptor, gibbonExternalAssessmentStudent.date FROM gibbonExternalAssessmentStudentEntry JOIN gibbonExternalAssessmentStudent ON (gibbonExternalAssessmentStudentEntry.gibbonExternalAssessmentStudentID=gibbonExternalAssessmentStudent.gibbonExternalAssessmentStudentID) JOIN gibbonScaleGrade ON (gibbonExternalAssessmentStudentEntry.gibbonScaleGradeIDPrimaryAssessmentScale=gibbonScaleGrade.gibbonScaleGradeID) WHERE gibbonPersonID=:gibbonPersonID AND gibbonExternalAssessmentFieldID=:gibbonExternalAssessmentFieldID AND NOT gibbonScaleGradeIDPrimaryAssessmentScale='' ORDER BY date DESC"; + $resultEntry = $connection2->prepare($sqlEntry); + $resultEntry->execute($dataEntry); + } catch (PDOException $e) { + echo "
".$e->getMessage().'
'; + } + if ($resultEntry->rowCount() >= 1) { + $rowEntry = $resultEntry->fetch(); + echo "".__($rowEntry['value']).''; + } + echo '
"; + $checked = ($rowEntry['complete'] == 'Y') ? 'checked' : ''; + echo ''; + echo '"; + if ($gibbonRubricID[$i] != '') { + echo ""; + } + echo '
'; + } + } + } + } + + //Print sidebar + $session->set('sidebarExtra', sidebarExtra($gibbonCourseClassID, 'write')); + } +} diff --git a/ATL/atl_write_data.php b/ATL/atl_write_data.php index c455d26..44f0f9d 100644 --- a/ATL/atl_write_data.php +++ b/ATL/atl_write_data.php @@ -1,190 +1,173 @@ -. -*/ - -use Gibbon\Forms\DatabaseFormFactory; -use Gibbon\Forms\Form; -use Gibbon\Services\Format; - -//Module includes -include './modules/'.$session->get('module').'/moduleFunctions.php'; - -echo "'; - -if (isActionAccessible($guid, $connection2, '/modules/ATL/atl_write_data.php') == false) { - //Acess denied - echo "
"; - echo __('You do not have access to this action.'); - echo '
'; -} else { - // Register scripts available to the core, but not included by default - $page->scripts->add('chart'); - - $highestAction = getHighestGroupedAction($guid, $_GET['q'], $connection2); - if ($highestAction == false) { - echo "
"; - echo __('The highest grouped action cannot be determined.'); - echo '
'; - } else { - //Check if school year specified - $gibbonCourseClassID = $_GET['gibbonCourseClassID'] ?? ''; - $atlColumnID = $_GET['atlColumnID']; - if ($gibbonCourseClassID == '' or $atlColumnID == '') { - echo "
"; - echo __('You have not specified one or more required parameters.'); - echo '
'; - } else { - try { - if ($highestAction == 'Write ATLs_all') { - $data = array('gibbonCourseClassID' => $gibbonCourseClassID); - $sql = "SELECT gibbonCourse.nameShort AS course, gibbonCourse.name AS courseName, gibbonCourseClass.nameShort AS class, gibbonYearGroupIDList FROM gibbonCourse JOIN gibbonCourseClass ON (gibbonCourse.gibbonCourseID=gibbonCourseClass.gibbonCourseID) WHERE gibbonCourseClassID=:gibbonCourseClassID AND gibbonCourseClass.reportable='Y' "; - } else { - $data = array('gibbonCourseClassID' => $gibbonCourseClassID, 'gibbonPersonID' => $session->get('gibbonPersonID'), 'gibbonCourseClassID2' => $gibbonCourseClassID, 'gibbonPersonID2' => $session->get('gibbonPersonID'), 'gibbonSchoolYearID' => $session->get('gibbonSchoolYearID')); - $sql = "(SELECT gibbonCourse.nameShort AS course, gibbonCourse.name AS courseName, gibbonCourseClass.nameShort AS class, gibbonYearGroupIDList FROM gibbonCourse JOIN gibbonCourseClass ON (gibbonCourse.gibbonCourseID=gibbonCourseClass.gibbonCourseID) JOIN gibbonCourseClassPerson ON (gibbonCourseClassPerson.gibbonCourseClassID=gibbonCourseClass.gibbonCourseClassID) WHERE gibbonCourseClass.gibbonCourseClassID=:gibbonCourseClassID AND gibbonPersonID=:gibbonPersonID AND (role='Teacher' OR role='Assistant') AND gibbonCourseClass.reportable='Y') - UNION - (SELECT gibbonCourse.nameShort AS course, gibbonCourse.name AS courseName, gibbonCourseClass.nameShort AS class, gibbonYearGroupIDList FROM gibbonCourseClass JOIN gibbonCourse ON (gibbonCourseClass.gibbonCourseID=gibbonCourse.gibbonCourseID) JOIN gibbonDepartment ON (gibbonCourse.gibbonDepartmentID=gibbonDepartment.gibbonDepartmentID) JOIN gibbonDepartmentStaff ON (gibbonDepartmentStaff.gibbonDepartmentID=gibbonDepartment.gibbonDepartmentID) WHERE gibbonCourseClass.gibbonCourseClassID=:gibbonCourseClassID2 AND gibbonDepartmentStaff.gibbonPersonID=:gibbonPersonID2 AND gibbonDepartmentStaff.role='Coordinator' AND gibbonCourse.gibbonSchoolYearID=:gibbonSchoolYearID AND gibbonCourseClass.reportable='Y')"; - } - $result = $connection2->prepare($sql); - $result->execute($data); - } catch (PDOException $e) { - echo "
".$e->getMessage().'
'; - } - - if ($result->rowCount() != 1) { - echo "
"; - echo __('The selected record does not exist, or you do not have access to it.'); - echo '
'; - } else { - try { - $data2 = array('atlColumnID' => $atlColumnID); - $sql2 = 'SELECT * FROM atlColumn WHERE atlColumnID=:atlColumnID'; - $result2 = $connection2->prepare($sql2); - $result2->execute($data2); - } catch (PDOException $e) { - echo "
".$e->getMessage().'
'; - } - - if ($result2->rowCount() != 1) { - echo "
"; - echo 'The selected column does not exist, or you do not have access to it.'; - echo '
'; - } else { - //Let's go! - $class = $result->fetch(); - $values = $result2->fetch(); - - $page->breadcrumbs - ->add(__('Write {courseClass} ATLs', ['courseClass' => $class['course'].'.'.$class['class']]), 'atl_write.php', ['gibbonCourseClassID' => $gibbonCourseClassID]) - ->add(__('Enter ATL Results')); - - if (isset($_GET['return'])) { - returnProcess($guid, $_GET['return'], null, null); - } - - $data = array('gibbonCourseClassID' => $gibbonCourseClassID, 'atlColumnID' => $atlColumnID, 'today' => date('Y-m-d')); - $sql = "SELECT gibbonPerson.gibbonPersonID, gibbonPerson.title, gibbonPerson.surname, gibbonPerson.preferredName, gibbonPerson.dateStart, atlEntry.* - FROM gibbonCourseClassPerson - JOIN gibbonPerson ON (gibbonCourseClassPerson.gibbonPersonID=gibbonPerson.gibbonPersonID) - LEFT JOIN atlEntry ON (atlEntry.gibbonPersonIDStudent=gibbonPerson.gibbonPersonID AND atlEntry.atlColumnID=:atlColumnID) - WHERE gibbonCourseClassPerson.gibbonCourseClassID=:gibbonCourseClassID - AND gibbonCourseClassPerson.reportable='Y' AND gibbonCourseClassPerson.role='Student' - AND gibbonPerson.status='Full' AND (dateStart IS NULL OR dateStart<=:today) AND (dateEnd IS NULL OR dateEnd>=:today) - ORDER BY gibbonPerson.surname, gibbonPerson.preferredName"; - $result = $pdo->executeQuery($data, $sql); - $students = ($result->rowCount() > 0)? $result->fetchAll() : array(); - - $form = Form::create('internalAssessment', $session->get('absoluteURL').'/modules/'.$session->get('module').'/atl_write_dataProcess.php?gibbonCourseClassID='.$gibbonCourseClassID.'&atlColumnID='.$atlColumnID.'&address='.$session->get('address')); - $form->setFactory(DatabaseFormFactory::create($pdo)); - $form->addHiddenValue('address', $session->get('address')); - - $form->addRow()->addHeading(__('Assessment Details')); - - if (count($students) == 0) { - $form->addRow()->addHeading(__('Students')); - $form->addRow()->addAlert(__('There are no records to display.'), 'error'); - } else { - $table = $form->addRow()->addTable()->setClass('smallIntBorder fullWidth colorOddEven noMargin noPadding noBorder'); - - $completeText = !empty($values['completeDate'])? __('Marked on').' '.dateConvertBack($guid, $values['completeDate']) : __('Unmarked'); - - $header = $table->addHeaderRow(); - $header->addTableCell(__('Student'))->rowSpan(2); - $header->addTableCell($values['name']) - ->setTitle($values['description']) - ->append('
'.$completeText.'') - ->setClass('textCenter') - ->colSpan(3); - - $header = $table->addHeaderRow(); - $header->addContent(__('Complete'))->setClass('textCenter'); - $header->addContent(__('Rubric'))->setClass('textCenter'); - } - - foreach ($students as $index => $student) { - $count = $index+1; - $row = $table->addRow(); - - $row->addWebLink(Format::name('', $student['preferredName'], $student['surname'], 'Student', true)) - ->setURL($session->get('absoluteURL').'/index.php?q=/modules/Students/student_view_details.php') - ->addParam('gibbonPersonID', $student['gibbonPersonID']) - ->addParam('subpage', 'Markbook') - ->wrap('', '') - ->prepend($count.') '); - - $row->addCheckbox('complete'.$count)->setValue('Y')->checked($student['complete'])->setClass('textCenter'); - - $row->addWebLink('') - ->setURL($session->get('absoluteURL').'/fullscreen.php?q=/modules/'.$session->get('module').'/atl_write_rubric.php') - ->setClass('thickbox textCenter') - ->addParam('gibbonRubricID', $values['gibbonRubricID']) - ->addParam('gibbonCourseClassID', $gibbonCourseClassID) - ->addParam('gibbonPersonID', $student['gibbonPersonID']) - ->addParam('atlColumnID', $atlColumnID) - ->addParam('type', 'effort') - ->addParam('width', '1100') - ->addParam('height', '550'); - - $form->addHiddenValue($count.'-gibbonPersonID', $student['gibbonPersonID']); - } - - $form->addHiddenValue('count', $count); - - $form->addRow()->addHeading(__('Assessment Complete?')); - - $row = $form->addRow(); - $row->addLabel('completeDate', __('Go Live Date'))->prepend('1. ')->append('
'.__('2. Column is hidden until date is reached.')); - $row->addDate('completeDate'); - - $row = $form->addRow(); - $row->addSubmit(); - - $form->loadAllValuesFrom($values); - - echo $form->getOutput(); - } - } - } - - //Print sidebar - $session->set('sidebarExtra', sidebarExtra($guid, $connection2, $gibbonCourseClassID, 'write', $highestAction)); - } -} +. +*/ + +use Gibbon\Forms\DatabaseFormFactory; +use Gibbon\Forms\Form; +use Gibbon\Module\ATL\Domain\ATLColumnGateway; +use Gibbon\Services\Format; + +//Module includes +require_once __DIR__ . '/moduleFunctions.php'; + +echo "'; + +if (isActionAccessible($guid, $connection2, '/modules/ATL/atl_write_data.php') == false) { + //Acess denied + $page->addError(__('You do not have access to this action.')); +} else { + // Register scripts available to the core, but not included by default + $page->scripts->add('chart'); + + $highestAction = getHighestGroupedAction($guid, $_GET['q'], $connection2); + if ($highestAction == false) { + $page->addError(__('The highest grouped action cannot be determined.')); + } else { + //Check if school year specified + $gibbonCourseClassID = $_GET['gibbonCourseClassID'] ?? ''; + $atlColumnID = $_GET['atlColumnID'] ?? ''; + if ($gibbonCourseClassID == '' || $atlColumnID == '') { + $page->addError(__('You have not specified one or more required parameters.')); + } else { + try { + if ($highestAction == 'Write ATLs_all') { + $data = array('gibbonCourseClassID' => $gibbonCourseClassID); + $sql = "SELECT gibbonCourse.nameShort AS course, gibbonCourse.name AS courseName, gibbonCourseClass.nameShort AS class, gibbonYearGroupIDList FROM gibbonCourse JOIN gibbonCourseClass ON (gibbonCourse.gibbonCourseID=gibbonCourseClass.gibbonCourseID) WHERE gibbonCourseClassID=:gibbonCourseClassID AND gibbonCourseClass.reportable='Y' "; + } else { + $data = array('gibbonCourseClassID' => $gibbonCourseClassID, 'gibbonPersonID' => $session->get('gibbonPersonID'), 'gibbonCourseClassID2' => $gibbonCourseClassID, 'gibbonPersonID2' => $session->get('gibbonPersonID'), 'gibbonSchoolYearID' => $session->get('gibbonSchoolYearID')); + $sql = "(SELECT gibbonCourse.nameShort AS course, gibbonCourse.name AS courseName, gibbonCourseClass.nameShort AS class, gibbonYearGroupIDList FROM gibbonCourse JOIN gibbonCourseClass ON (gibbonCourse.gibbonCourseID=gibbonCourseClass.gibbonCourseID) JOIN gibbonCourseClassPerson ON (gibbonCourseClassPerson.gibbonCourseClassID=gibbonCourseClass.gibbonCourseClassID) WHERE gibbonCourseClass.gibbonCourseClassID=:gibbonCourseClassID AND gibbonPersonID=:gibbonPersonID AND (role='Teacher' OR role='Assistant') AND gibbonCourseClass.reportable='Y') + UNION + (SELECT gibbonCourse.nameShort AS course, gibbonCourse.name AS courseName, gibbonCourseClass.nameShort AS class, gibbonYearGroupIDList FROM gibbonCourseClass JOIN gibbonCourse ON (gibbonCourseClass.gibbonCourseID=gibbonCourse.gibbonCourseID) JOIN gibbonDepartment ON (gibbonCourse.gibbonDepartmentID=gibbonDepartment.gibbonDepartmentID) JOIN gibbonDepartmentStaff ON (gibbonDepartmentStaff.gibbonDepartmentID=gibbonDepartment.gibbonDepartmentID) WHERE gibbonCourseClass.gibbonCourseClassID=:gibbonCourseClassID2 AND gibbonDepartmentStaff.gibbonPersonID=:gibbonPersonID2 AND gibbonDepartmentStaff.role='Coordinator' AND gibbonCourse.gibbonSchoolYearID=:gibbonSchoolYearID AND gibbonCourseClass.reportable='Y')"; + } + $result = $connection2->prepare($sql); + $result->execute($data); + } catch (PDOException $e) { + } + + if ($result->rowCount() != 1) { + $page->addError(__('The selected record does not exist, or you do not have access to it.')); + } else { + $atlColumnGateway = $container->get(ATLColumnGateway::class); + $atlColumn = $atlColumnGateway->getByID($atlColumnID); + + if (empty($atlColumn)) { + $page->addError(__('The selected column does not exist, or you do not have access to it.')); + } else { + //Let's go! + $class = $result->fetch(); + + $page->breadcrumbs + ->add(__('Write {courseClass} ATLs', ['courseClass' => $class['course'].'.'.$class['class']]), 'atl_write.php', ['gibbonCourseClassID' => $gibbonCourseClassID]) + ->add(__('Enter ATL Results')); + + if ($atlColumn['forStudents'] == 'Y') { + $page->addError(__('You cannot mark this ATL')); + } else { + $data = array('gibbonCourseClassID' => $gibbonCourseClassID, 'atlColumnID' => $atlColumnID, 'today' => date('Y-m-d')); + $sql = "SELECT gibbonPerson.gibbonPersonID, gibbonPerson.title, gibbonPerson.surname, gibbonPerson.preferredName, gibbonPerson.dateStart, atlEntry.* + FROM gibbonCourseClassPerson + JOIN gibbonPerson ON (gibbonCourseClassPerson.gibbonPersonID=gibbonPerson.gibbonPersonID) + LEFT JOIN atlEntry ON (atlEntry.gibbonPersonIDStudent=gibbonPerson.gibbonPersonID AND atlEntry.atlColumnID=:atlColumnID) + WHERE gibbonCourseClassPerson.gibbonCourseClassID=:gibbonCourseClassID + AND gibbonCourseClassPerson.reportable='Y' AND gibbonCourseClassPerson.role='Student' + AND gibbonPerson.status='Full' AND (dateStart IS NULL OR dateStart<=:today) AND (dateEnd IS NULL OR dateEnd>=:today) + ORDER BY gibbonPerson.surname, gibbonPerson.preferredName"; + $result = $connection2->prepare($sql); + $result->execute($data); + $students = ($result->rowCount() > 0) ? $result->fetchAll() : []; + + $form = Form::create('internalAssessment', $session->get('absoluteURL').'/modules/'.$session->get('module').'/atl_write_dataProcess.php?gibbonCourseClassID='.$gibbonCourseClassID.'&atlColumnID='.$atlColumnID); + $form->setFactory(DatabaseFormFactory::create($pdo)); + $form->addHiddenValue('address', $session->get('address')); + + $form->addRow()->addHeading(__('Assessment Details')); + if (empty($students)) { + $form->addRow()->addHeading(__('Students')); + $form->addRow()->addAlert(__('There are no records to display.'), 'error'); + } else { + $table = $form->addRow()->addTable()->setClass('smallIntBorder fullWidth colorOddEven noMargin noPadding noBorder'); + + $completeText = !empty($atlColumn['completeDate']) ? __('Marked on') . ' ' . Format::date($atlColumn['completeDate']) : __('Unmarked'); + + $header = $table->addHeaderRow(); + $header->addTableCell(__('Student'))->rowSpan(2); + $header->addTableCell($atlColumn['name']) + ->setTitle($atlColumn['description']) + ->append('
'.$completeText.'') + ->setClass('textCenter') + ->colSpan(3); + + $header = $table->addHeaderRow(); + $header->addContent(__('Complete'))->setClass('textCenter'); + $header->addContent(__('Rubric'))->setClass('textCenter'); + } + + foreach ($students as $index => $student) { + $count = $index+1; + $row = $table->addRow(); + + $row->addWebLink(Format::name('', $student['preferredName'], $student['surname'], 'Student', true)) + ->setURL($session->get('absoluteURL').'/index.php?q=/modules/Students/student_view_details.php') + ->addParam('gibbonPersonID', $student['gibbonPersonID']) + ->addParam('subpage', 'Markbook') + ->wrap('', '') + ->prepend($count.') '); + + $row->addCheckbox('complete'.$count)->setValue('Y')->checked($student['complete'])->setClass('textCenter'); + + $row->addWebLink('') + ->setURL($session->get('absoluteURL').'/fullscreen.php?q=/modules/'.$session->get('module').'/atl_write_rubric.php') + ->setClass('thickbox textCenter') + ->addParam('gibbonRubricID', $atlColumn['gibbonRubricID']) + ->addParam('gibbonCourseClassID', $gibbonCourseClassID) + ->addParam('gibbonPersonID', $student['gibbonPersonID']) + ->addParam('atlColumnID', $atlColumnID) + ->addParam('type', 'effort') + ->addParam('width', '1100') + ->addParam('height', '550'); + + $form->addHiddenValue($count.'-gibbonPersonID', $student['gibbonPersonID']); + } + + $form->addHiddenValue('count', $count); + + $form->addRow()->addHeading(__('Assessment Complete?')); + + $row = $form->addRow(); + $row->addLabel('completeDate', __('Go Live Date'))->prepend('1. ')->append('
'.__('2. Column is hidden until date is reached.')); + $row->addDate('completeDate'); + + $row = $form->addRow(); + $row->addSubmit(); + + $form->loadAllValuesFrom($atlColumn); + + echo $form->getOutput(); + } + } + } + } + + //Print sidebar + $session->set('sidebarExtra', sidebarExtra($gibbonCourseClassID, 'write')); + } +} \ No newline at end of file diff --git a/ATL/atl_write_dataProcess.php b/ATL/atl_write_dataProcess.php index 3da26e3..855ef25 100644 --- a/ATL/atl_write_dataProcess.php +++ b/ATL/atl_write_dataProcess.php @@ -1,137 +1,108 @@ -. -*/ - -include '../../gibbon.php'; - - -$gibbonCourseClassID = $_GET['gibbonCourseClassID']; -$atlColumnID = $_GET['atlColumnID']; -$URL = $session->get('absoluteURL').'/index.php?q=/modules/'.getModuleName($_GET['address'])."/atl_write_data.php&atlColumnID=$atlColumnID&gibbonCourseClassID=$gibbonCourseClassID"; - -if (isActionAccessible($guid, $connection2, '/modules/ATL/atl_write_data.php') == false) { - //Fail 0 - $URL .= '&return=error0'; - header("Location: {$URL}"); -} else { - if (empty($_POST)) { - $URL .= '&return=error5'; - header("Location: {$URL}"); - } else { - //Proceed! - //Check if school year specified - if ($atlColumnID == '' or $gibbonCourseClassID == '') { - //Fail1 - $URL .= '&return=error1'; - header("Location: {$URL}"); - } else { - try { - $data = array('atlColumnID' => $atlColumnID, 'gibbonCourseClassID' => $gibbonCourseClassID); - $sql = 'SELECT * FROM atlColumn WHERE atlColumnID=:atlColumnID AND gibbonCourseClassID=:gibbonCourseClassID'; - $result = $connection2->prepare($sql); - $result->execute($data); - } catch (PDOException $e) { - //Fail2 - $URL .= '&return=error2'; - header("Location: {$URL}"); - exit(); - } - - if ($result->rowCount() != 1) { - //Fail 2 - $URL .= '&return=error2'; - header("Location: {$URL}"); - } else { - $row = $result->fetch(); - $name = $row['name' ]; - $count = $_POST['count']; - $partialFail = false; - - for ($i = 1;$i <= $count;++$i) { - $gibbonPersonIDStudent = $_POST["$i-gibbonPersonID"]; - //Complete - $completeValue = isset($_POST["complete$i"])? $_POST["complete$i"] : 'N'; - $gibbonPersonIDLastEdit = $session->get('gibbonPersonID'); - - $selectFail = false; - try { - $data = array('atlColumnID' => $atlColumnID, 'gibbonPersonIDStudent' => $gibbonPersonIDStudent); - $sql = 'SELECT * FROM atlEntry WHERE atlColumnID=:atlColumnID AND gibbonPersonIDStudent=:gibbonPersonIDStudent'; - $result = $connection2->prepare($sql); - $result->execute($data); - } catch (PDOException $e) { - $partialFail = true; - $selectFail = true; - } - if (!($selectFail)) { - if ($result->rowCount() < 1) { - try { - $data = array('atlColumnID' => $atlColumnID, 'gibbonPersonIDStudent' => $gibbonPersonIDStudent, 'complete' => $completeValue, 'gibbonPersonIDLastEdit' => $gibbonPersonIDLastEdit); - $sql = 'INSERT INTO atlEntry SET atlColumnID=:atlColumnID, gibbonPersonIDStudent=:gibbonPersonIDStudent, complete=:complete, gibbonPersonIDLastEdit=:gibbonPersonIDLastEdit'; - $result = $connection2->prepare($sql); - $result->execute($data); - } catch (PDOException $e) { - $partialFail = true; - } - } else { - $row = $result->fetch(); - //Update - try { - $data = array('atlColumnID' => $atlColumnID, 'gibbonPersonIDStudent' => $gibbonPersonIDStudent, 'complete' => $completeValue, 'gibbonPersonIDLastEdit' => $gibbonPersonIDLastEdit, 'atlEntryID' => $row['atlEntryID']); - $sql = 'UPDATE atlEntry SET atlColumnID=:atlColumnID, gibbonPersonIDStudent=:gibbonPersonIDStudent, complete=:complete, gibbonPersonIDLastEdit=:gibbonPersonIDLastEdit WHERE atlEntryID=:atlEntryID'; - $result = $connection2->prepare($sql); - $result->execute($data); - } catch (PDOException $e) { - $partialFail = true; - } - } - } - } - - //Update column - $completeDate = $_POST['completeDate']; - if ($completeDate == '') { - $completeDate = null; - $complete = 'N'; - } else { - $completeDate = dateConvert($guid, $completeDate); - $complete = 'Y'; - } - try { - $data = array('completeDate' => $completeDate, 'complete' => $complete, 'atlColumnID' => $atlColumnID); - $sql = 'UPDATE atlColumn SET completeDate=:completeDate, complete=:complete WHERE atlColumnID=:atlColumnID'; - $result = $connection2->prepare($sql); - $result->execute($data); - } catch (PDOException $e) { - $partialFail = true; - } - - //Return! - if ($partialFail == true) { - //Fail 3 - $URL .= '&return=error3'; - header("Location: {$URL}"); - } else { - //Success 0 - $URL .= '&return=success0'; - header("Location: {$URL}"); - } - } - } - } -} +. +*/ + +use Gibbon\Module\ATL\Domain\ATLColumnGateway; +use Gibbon\Module\ATL\Domain\ATLEntryGateway; +use Gibbon\Services\Format; + +include '../../gibbon.php'; + +$URL = $session->get('absoluteURL').'/index.php?q=/modules/ATL/'; + +if (isActionAccessible($guid, $connection2, '/modules/ATL/atl_write_data.php') == false) { + //Fail 0 + $URL .= 'atl_manage.php&return=error0'; + header("Location: {$URL}"); +} else { + $gibbonCourseClassID = $_GET['gibbonCourseClassID'] ?? ''; + $atlColumnID = $_GET['atlColumnID'] ?? ''; + + $atlColumnGateway = $container->get(ATLColumnGateway::class); + $atlColumn = $atlColumnGateway->getByID($atlColumnID); + + if (empty($atlColumn)) { + //Fail 2 + $URL .= 'atl_manage.php&return=error2'; + header("Location: {$URL}"); + exit(); + } else { + $URL .= "atl_write_data.php&atlColumnID=$atlColumnID&gibbonCourseClassID=$gibbonCourseClassID"; + $name = $atlColumn['name']; + $count = $_POST['count']; + $partialFail = false; + + if ($atlColumn['forStudents'] == 'Y') { + $URL .= '&return=error1'; + header("Location: {$URL}"); + exit(); + } + + $atlEntryGateway = $container->get(ATLEntryGateway::class); + + for ($i = 1; $i <= $count; ++$i) { + $gibbonPersonIDStudent = $_POST["$i-gibbonPersonID"]; + //Complete + $completeValue = $_POST["complete$i"] ?? 'N'; + $gibbonPersonIDLastEdit = $session->get('gibbonPersonID'); + + $data = [ + 'atlColumnID' => $atlColumnID, + 'gibbonPersonIDStudent' => $gibbonPersonIDStudent, + 'complete' => $completeValue, + 'gibbonPersonIDLastEdit' => $gibbonPersonIDLastEdit, + ]; + + $atlEntry = $atlEntryGateway->selectBy(['atlColumnID' => $atlColumnID, 'gibbonPersonIDStudent' => $gibbonPersonIDStudent]); + + if ($atlEntry->isNotEmpty()) { + $atlEntry = $atlEntry->fetch(); + $partialFail |= !$atlEntryGateway->update($atlEntry['atlEntryID'], $data); + } else { + $partialFail |= !$atlEntryGateway->insert($data); + } + } + + //Update column + $completeDate = $_POST['completeDate']; + if (empty($completeDate)) { + $data = [ + 'completeDate' => null, + 'complete' => 'N' + ]; + } else { + $data = [ + 'completeDate' => Format::dateConvert($completeDate), + 'complete' => 'Y' + ]; + } + + $partialFail |= !$atlColumnGateway->update($atlColumnID, $data); + + //Return! + if ($partialFail) { + //Fail 3 + $URL .= '&return=error3'; + } else { + //Success 0 + $URL .= '&return=success0'; + } + header("Location: {$URL}"); + exit(); + } +} diff --git a/ATL/atl_write_rubric.php b/ATL/atl_write_rubric.php index f0326fb..864f740 100644 --- a/ATL/atl_write_rubric.php +++ b/ATL/atl_write_rubric.php @@ -1,136 +1,144 @@ -. -*/ - -use Gibbon\Services\Format; - -//Rubric includes -include './modules/Rubrics/moduleFunctions.php'; - -if (isActionAccessible($guid, $connection2, '/modules/ATL/atl_write.php') == false) { - //Acess denied - echo "
"; - echo __('Your request failed because you do not have access to this action.'); - echo '
'; -} else { - //Proceed! - //Check if school year specified - $gibbonCourseClassID = $_GET['gibbonCourseClassID']; - $atlColumnID = $_GET['atlColumnID']; - $gibbonPersonID = $_GET['gibbonPersonID']; - $gibbonRubricID = $_GET['gibbonRubricID']; - if ($gibbonCourseClassID == '' or $atlColumnID == '' or $gibbonPersonID == '' or $gibbonRubricID == '') { echo "
"; - echo __('You have not specified one or more required parameters.'); - echo '
'; - } else { - $roleCategory = getRoleCategory($session->get('gibbonRoleIDPrimary'), $connection2); - $contextDBTableGibbonRubricIDField = 'gibbonRubricID'; - if ($_GET['type'] == 'attainment') { - $contextDBTableGibbonRubricIDField = 'gibbonRubricIDAttainment'; - } elseif ($_GET['type'] == 'effort') { - $contextDBTableGibbonRubricIDField = 'gibbonRubricID'; - } - - try { - if ($roleCategory == 'Staff') { - $data = array('gibbonCourseClassID' => $gibbonCourseClassID); - $sql = 'SELECT gibbonCourse.nameShort AS course, gibbonCourseClass.nameShort AS class, gibbonCourseClass.gibbonCourseClassID FROM gibbonCourse, gibbonCourseClass WHERE gibbonCourse.gibbonCourseID=gibbonCourseClass.gibbonCourseID AND gibbonCourseClass.gibbonCourseClassID=:gibbonCourseClassID ORDER BY course, class'; - } elseif ($roleCategory == 'Student') { - $data = array('gibbonPersonID' => $gibbonPersonID, 'gibbonCourseClassID' => $gibbonCourseClassID); - $sql = "SELECT gibbonCourse.nameShort AS course, gibbonCourseClass.nameShort AS class, gibbonCourseClass.gibbonCourseClassID FROM gibbonCourse, gibbonCourseClass, gibbonCourseClassPerson WHERE gibbonCourse.gibbonCourseID=gibbonCourseClass.gibbonCourseID AND gibbonCourseClass.gibbonCourseClassID=gibbonCourseClassPerson.gibbonCourseClassID AND gibbonCourseClassPerson.gibbonPersonID=:gibbonPersonID AND role='Student' AND gibbonCourseClass.gibbonCourseClassID=:gibbonCourseClassID ORDER BY course, class"; - } elseif ($roleCategory == 'Parent') { - $data = array('gibbonPersonID' => $gibbonPersonID, 'gibbonCourseClassID' => $gibbonCourseClassID); - $sql = "SELECT gibbonCourse.nameShort AS course, gibbonCourseClass.nameShort AS class, gibbonCourseClass.gibbonCourseClassID FROM gibbonCourse, gibbonCourseClass, gibbonCourseClassPerson WHERE gibbonCourse.gibbonCourseID=gibbonCourseClass.gibbonCourseID AND gibbonCourseClass.gibbonCourseClassID=gibbonCourseClassPerson.gibbonCourseClassID AND gibbonCourseClassPerson.gibbonPersonID=:gibbonPersonID AND role='Student' AND gibbonCourseClass.gibbonCourseClassID=:gibbonCourseClassID ORDER BY course, class"; - } - $result = $connection2->prepare($sql); - $result->execute($data); - } catch (PDOException $e) { - echo "
".$e->getMessage().'
'; - } - - if ($result->rowCount() != 1) { - echo "
"; - echo __('The selected record does not exist, or you do not have access to it.'); - echo '
'; - } else { - try { - $data2 = array('atlColumnID' => $atlColumnID); - $sql2 = 'SELECT * FROM atlColumn WHERE atlColumnID=:atlColumnID'; - $result2 = $connection2->prepare($sql2); - $result2->execute($data2); - } catch (PDOException $e) { - echo "
".$e->getMessage().'
'; - } - - if ($result2->rowCount() != 1) { - echo "
"; - echo __('The selected record does not exist, or you do not have access to it.'); - echo '
'; - } else { - try { - $data3 = array('gibbonRubricID' => $gibbonRubricID); - $sql3 = 'SELECT * FROM gibbonRubric WHERE gibbonRubricID=:gibbonRubricID'; - $result3 = $connection2->prepare($sql3); - $result3->execute($data3); - } catch (PDOException $e) { - echo "
".$e->getMessage().'
'; - } - - if ($result3->rowCount() != 1) { - echo "
"; - echo __('The specified record does not exist.'); - echo '
'; - } else { - try { - $data4 = array('gibbonPersonID' => $gibbonPersonID, 'gibbonCourseClassID' => $gibbonCourseClassID); - $sql4 = "SELECT DISTINCT surname, preferredName, gibbonPerson.gibbonPersonID FROM gibbonPerson JOIN gibbonCourseClassPerson ON (gibbonCourseClassPerson.gibbonPersonID=gibbonPerson.gibbonPersonID) WHERE gibbonPerson.gibbonPersonID=:gibbonPersonID AND gibbonCourseClassID=:gibbonCourseClassID AND status='Full' AND (dateStart IS NULL OR dateStart<='".date('Y-m-d')."') AND (dateEnd IS NULL OR dateEnd>='".date('Y-m-d')."') AND (role='Student' OR role='Student - Left')"; - $result4 = $connection2->prepare($sql4); - $result4->execute($data4); - } catch (PDOException $e) { - echo "
".$e->getMessage().'
'; - } - - if ($result4->rowCount() != 1) { - echo "
"; - echo __('The selected record does not exist, or you do not have access to it.'); - echo '
'; - } else { - //Let's go! - $row = $result->fetch(); - $row2 = $result2->fetch(); - $row3 = $result3->fetch(); - $row4 = $result4->fetch(); - - echo "

"; - echo $row3['name'].'
'; - echo "".Format::name('', $row4['preferredName'], $row4['surname'], 'Student', true).''; - echo '

'; - - $mark = true; - if (isset($_GET['mark'])) { - if ($_GET['mark'] == 'FALSE') { - $mark = false; - } - } - echo rubricView($guid, $connection2, $gibbonRubricID, $mark, $row4['gibbonPersonID'], 'atlColumn', 'atlColumnID', $atlColumnID, $contextDBTableGibbonRubricIDField, 'name', 'completeDate'); - } - } - } - } - } -} +. +*/ + +use Gibbon\Domain\Rubrics\RubricGateway; +use Gibbon\Domain\Timetable\CourseEnrolmentGateway; +use Gibbon\Domain\Timetable\CourseGateway; +use Gibbon\Domain\User\RoleGateway; +use Gibbon\Module\ATL\Domain\ATLColumnGateway; +use Gibbon\Module\ATL\Domain\ATLEntryGateway; +use Gibbon\Services\Format; + +//Rubric includes +include './modules/Rubrics/moduleFunctions.php'; + +if (isActionAccessible($guid, $connection2, '/modules/ATL/atl_write.php') == false + && isActionAccessible($guid, $connection2, '/modules/ATL/atl_write_student.php') == false) { + //Acess denied + $page->addError(__('Your request failed because you do not have access to this action.')); +} else { + //Proceed! + //Check if school year specified + $gibbonCourseClassID = $_GET['gibbonCourseClassID'] ?? ''; + $atlColumnID = $_GET['atlColumnID'] ?? ''; + $gibbonPersonID = $_GET['gibbonPersonID'] ?? ''; + $gibbonRubricID = $_GET['gibbonRubricID'] ?? ''; + if (empty($gibbonCourseClassID) || empty($atlColumnID) || empty($gibbonPersonID) || empty($gibbonRubricID)) { + $page->addError(__('You have not specified one or more required parameters.')); + } else { + $type = $_GET['type'] ?? ''; + $contextDBTableGibbonRubricIDField = ''; + if ($type == 'attainment') { + $contextDBTableGibbonRubricIDField = 'gibbonRubricIDAttainment'; + } else { + $contextDBTableGibbonRubricIDField = 'gibbonRubricID'; + } + + $allowed = false; + $roleGateway = $container->get(RoleGateway::class); + $roleCategory = $roleGateway->getByID($session->get('gibbonRoleIDPrimary'))['category'] ?? ''; + + if ($roleCategory == 'Staff') { + $courseGateway = $container->get(CourseGateway::class); + $result = $courseGateway->getCourseClassByID($gibbonCourseClassID); + $allowed = !empty($result); + } elseif ($roleCategory == 'Student' || $roleCategory == 'Parent') { + $courseEnrolmentGateway = $container->get(CourseEnrolmentGateway::class); + $result = $courseEnrolmentGateway->selectBy(['gibbonPersonID' => $gibbonPersonID, 'gibbonCourseClassID' => $gibbonCourseClassID, 'role' => 'Student']); + $allowed = $result->isNotEmpty(); + + } + + if (!$allowed) { + $page->addError(__('The selected record does not exist, or you do not have access to it.')); + } else { + $atlColumnGateway = $container->get(ATLColumnGateway::class); + if (!$atlColumnGateway->exists($atlColumnID)) { + $page->addError(__('The selected record does not exist, or you do not have access to it.')); + } else { + $rubricGateway = $container->get(RubricGateway::class); + $rubric = $rubricGateway->getByID($gibbonRubricID); + + if (empty($rubric)) { + $page->addError(__('The specified record does not exist.')); + } else { + try { + $data4 = array('gibbonPersonID' => $gibbonPersonID, 'gibbonCourseClassID' => $gibbonCourseClassID); + $sql4 = "SELECT DISTINCT surname, preferredName, gibbonPerson.gibbonPersonID, image_240 FROM gibbonPerson JOIN gibbonCourseClassPerson ON (gibbonCourseClassPerson.gibbonPersonID=gibbonPerson.gibbonPersonID) WHERE gibbonPerson.gibbonPersonID=:gibbonPersonID AND gibbonCourseClassID=:gibbonCourseClassID AND status='Full' AND (dateStart IS NULL OR dateStart<='".date('Y-m-d')."') AND (dateEnd IS NULL OR dateEnd>='".date('Y-m-d')."') AND (role='Student' OR role='Student - Left')"; + $result4 = $connection2->prepare($sql4); + $result4->execute($data4); + } catch (PDOException $e) { + echo "
".$e->getMessage().'
'; + } + + if ($result4->rowCount() != 1) { + $page->addError(__('The selected record does not exist, or you do not have access to it.')); + } else { + //Let's go! + $row4 = $result4->fetch(); + + echo "

"; + echo $rubric['name'].'
'; + echo "".Format::name('', $row4['preferredName'], $row4['surname'], 'Student', true).''; + echo '

'; + + echo Format::photo($row4['image_240'], 75, 'inline-block align-top mt-1'); + + $mark = ($_GET['mark'] ?? '') !== 'FALSE'; + echo rubricView($guid, $connection2, $gibbonRubricID, $mark, $row4['gibbonPersonID'], 'atlColumn', 'atlColumnID', $atlColumnID, $contextDBTableGibbonRubricIDField, 'name', $gibbonPersonID == $session->get('gibbonPersonID') ? '' : 'completeDate'); + + if ($mark && $gibbonPersonID !== $session->get('gibbonPersonID')) { + try { + $dataStudents = array('gibbonCourseClassID' => $gibbonCourseClassID); + $sqlStudents = "SELECT gibbonPerson.gibbonPersonID, dateStart FROM gibbonCourseClassPerson JOIN gibbonPerson ON (gibbonCourseClassPerson.gibbonPersonID=gibbonPerson.gibbonPersonID) WHERE role='Student' AND gibbonCourseClassID=:gibbonCourseClassID AND status='Full' AND (dateStart IS NULL OR dateStart<='".date('Y-m-d')."') AND (dateEnd IS NULL OR dateEnd>='".date('Y-m-d')."') AND gibbonCourseClassPerson.reportable='Y' ORDER BY surname, preferredName"; + $resultStudents = $connection2->prepare($sqlStudents); + $resultStudents->execute($dataStudents); + } catch (PDOException $e) { + } + + $prev = ''; + $next = ''; + while (($rowStudent = $resultStudents->fetch()) != null) { + if ($rowStudent['gibbonPersonID'] == $gibbonPersonID) { + $nextRowStudent = $resultStudents->fetch(); + if ($nextRowStudent != null) { + $next = $nextRowStudent['gibbonPersonID']; + } + break; + } else { + $prev = $rowStudent['gibbonPersonID']; + } + } + + echo ''; + } + } + } + } + } + } +} diff --git a/ATL/atl_write_student.php b/ATL/atl_write_student.php new file mode 100644 index 0000000..22b28c4 --- /dev/null +++ b/ATL/atl_write_student.php @@ -0,0 +1,69 @@ +. +*/ + +use Gibbon\Module\ATL\Domain\ATLColumnGateway; +use Gibbon\Services\Format; +use Gibbon\Tables\DataTable; + +//Module includes +require_once __DIR__ . '/moduleFunctions.php'; + +$page->breadcrumbs->add('Fill ATLs'); +if (isActionAccessible($guid, $connection2, '/modules/ATL/atl_write_student.php') == false) { + //Acess denied + $page->addError(__('Your request failed because you do not have access to this action.')); +} else { + $page->scripts->add('chart'); + $atlColumnGateway = $container->get(ATLColumnGateway::class); + $criteria = $atlColumnGateway->newQueryCriteria() + ->sortBy('completeDate'); + + $gibbonPersonID = $session->get('gibbonPersonID'); + $atlColumns = $atlColumnGateway->queryATLColumnsByStudent($criteria, $session->get('gibbonSchoolYearID'), $gibbonPersonID, 'N'); + + $table = DataTable::createPaginated('studentATLs', $criteria); + + $table->addColumn('course', __('Class')) + ->format(Format::using('courseClassName', ['course', 'class'])); + + $table->addColumn('name', __('ATL')); + + $table->addColumn('completeDate', __('Due Date')) + ->format(Format::using('date', ['completeDate'])); + + $table->addActionColumn() + ->addParam('gibbonRubricID') + ->addParam('gibbonCourseClassID') + ->addParam('gibbonPersonID', $gibbonPersonID) + ->addParam('atlColumnID') + ->addParam('type', 'effort') + ->format(function ($column, $actions) { + $actions->addAction('data', __('Enter Data')) + ->setURL('/modules/ATL/atl_write_rubric.php') + ->setIcon('markbook') + ->modalWindow(1100, 550); + + $actions->addAction('complete', __('Complete')) + ->setURL('/modules/ATL/atl_write_student_complete.php') + ->setIcon('iconTick') + ->modalWindow(); + }); + + echo $table->render($atlColumns); +} \ No newline at end of file diff --git a/ATL/atl_write_student_complete.php b/ATL/atl_write_student_complete.php new file mode 100644 index 0000000..c3bede2 --- /dev/null +++ b/ATL/atl_write_student_complete.php @@ -0,0 +1,62 @@ +. +*/ + +use Gibbon\Forms\Form; +use Gibbon\Module\ATL\Domain\ATLColumnGateway; +use Gibbon\Module\ATL\Domain\ATLEntryGateway; + +//Module includes +require_once __DIR__ . '/moduleFunctions.php'; + +if (isActionAccessible($guid, $connection2, '/modules/ATL/atl_write_student.php') == false) { + //Acess denied + $page->addError(__('Your request failed because you do not have access to this action.')); +} else { + $atlColumnGateway = $container->get(ATLColumnGateway::class); + $atlEntryGateway = $container->get(ATLEntryGateway::class); + + $atlColumnID = $_GET['atlColumnID'] ?? ''; + $gibbonPersonID = $session->get('gibbonPersonID'); + $gibbonSchoolYearID = $session->get('gibbonSchoolYearID'); + + //Check if atl column is for student + if ($atlColumnGateway->isForStudent($atlColumnID, $gibbonPersonID, $gibbonSchoolYearID)) { + //Check if student has already completed atl + $atlEntry = $atlEntryGateway->selectBy(['gibbonPersonIDStudent' => $gibbonPersonID, 'atlColumnID' => $atlColumnID, 'complete' => 'Y']); + if ($atlEntry->isNotEmpty()) { + $page->addError(__('You have already completed this ATL.')); + } else { + $form = Form::create('ATL', $session->get('absoluteURL').'/modules/ATL/atl_write_student_completeProcess.php'); + $form->addHiddenValue('address', $session->get('address')); + $form->addHiddenValue('atlColumnID', $atlColumnID); + + $row = $form->addRow(); + $col = $row->addColumn(); + $col->addContent(__('Are you sure you want to mark this ATL as complete?'))->wrap('', ''); + $col->addContent(__('Once marked as complete, you will not be able to edit your ATL.')) + ->wrap('', ''); + + $form->addRow()->addConfirmSubmit(); + + echo $form->getOutput(); + } + } else { + $page->addError(__('Your request failed because you do not have access to this action.')); + } +} \ No newline at end of file diff --git a/ATL/atl_write_student_completeProcess.php b/ATL/atl_write_student_completeProcess.php new file mode 100644 index 0000000..e021803 --- /dev/null +++ b/ATL/atl_write_student_completeProcess.php @@ -0,0 +1,74 @@ +. +*/ + +include '../../gibbon.php'; + +use Gibbon\Module\ATL\Domain\ATLColumnGateway; +use Gibbon\Module\ATL\Domain\ATLEntryGateway; + +$URL = $session->get('absoluteURL').'/index.php?q=/modules/ATL/atl_write_student.php'; + +if (isActionAccessible($guid, $connection2, '/modules/ATL/atl_write_student.php') == false) { + //Fail 0 + $URL .= '&return=error0'; + header("Location: {$URL}"); + exit(); +} else { + $atlColumnGateway = $container->get(ATLColumnGateway::class); + $atlEntryGateway = $container->get(ATLEntryGateway::class); + + $atlColumnID = $_POST['atlColumnID'] ?? ''; + $gibbonPersonID = $session->get('gibbonPersonID'); + $gibbonSchoolYearID = $session->get('gibbonSchoolYearID'); + + //Check if atl column is for student + if ($atlColumnGateway->isForStudent($atlColumnID, $gibbonPersonID, $gibbonSchoolYearID)) { + $data = [ + 'atlColumnID' => $atlColumnID, + 'gibbonPersonIDStudent' => $gibbonPersonID, + 'complete' => 'Y', + 'gibbonPersonIDLastEdit' => $gibbonPersonID + ]; + + $atlEntry = $atlEntryGateway->selectBy(['gibbonPersonIDStudent' => $gibbonPersonID, 'atlColumnID' => $atlColumnID]); + $atlEntry = $atlEntry->isNotEmpty() ? $atlEntry->fetch() : []; + + if (empty($atlEntry)) { + if (!$atlEntryGateway->insert($data)) { + $URL .= '&return=error2'; + header("Location: {$URL}"); + exit(); + } + } else { + if (!$atlEntryGateway->update($atlEntry['atlEntryID'], $data)) { + $URL .= '&return=error2'; + header("Location: {$URL}"); + exit(); + } + } + + $URL .= '&return=success0'; + header("Location: {$URL}"); + exit(); + } else { + $URL .= '&return=error0'; + header("Location: {$URL}"); + exit(); + } +} diff --git a/ATL/cli/goLiveNotifications.php b/ATL/cli/goLiveNotifications.php index 91ff255..aaf911c 100644 --- a/ATL/cli/goLiveNotifications.php +++ b/ATL/cli/goLiveNotifications.php @@ -1,79 +1,78 @@ -. -*/ - -//USAGE -//Ideally this script should be run shortly after midnight, to alert users to columns that have just gone live - -require getcwd().'/../../../gibbon.php'; - -getSystemSettings($guid, $connection2); - -setCurrentSchoolYear($guid, $connection2); - -//Set up for i18n via gettext -if (isset($_SESSION[$guid]['i18n']['code'])) { if ($_SESSION[$guid]['i18n']['code'] != null) { - putenv('LC_ALL='.$_SESSION[$guid]['i18n']['code']); - setlocale(LC_ALL, $_SESSION[$guid]['i18n']['code']); - bindtextdomain('gibbon', getcwd().'/../i18n'); - textdomain('gibbon'); - } -} - - -//Check for CLI, so this cannot be run through browser -if (php_sapi_name() != 'cli') { - echo __('This script cannot be run from a browser, only via CLI.')."\n\n"; -} else { - //SCAN THROUGH ALL ATLS GOING LIVE TODAY - try { - $data = array('completeDate' => date('Y-m-d')); - $sql = 'SELECT atlColumn.*, gibbonCourseClass.nameShort AS class, gibbonCourse.nameShort AS course FROM atlColumn JOIN gibbonCourseClass ON (atlColumn.gibbonCourseClassID=gibbonCourseClass.gibbonCourseClassID) JOIN gibbonCourse ON (gibbonCourseClass.gibbonCourseID=gibbonCourse.gibbonCourseID) WHERE completeDate=:completeDate'; - $result = $connection2->prepare($sql); - $result->execute($data); - } catch (PDOException $e) { - } - - while ($row = $result->fetch()) { - try { - $dataPerson = array('gibbonCourseClassID' => $row['gibbonCourseClassID'], 'today' => date('Y-m-d')); - $sqlPerson = "SELECT gibbonCourseClassPerson.* - FROM gibbonCourseClassPerson - JOIN gibbonPerson ON (gibbonCourseClassPerson.gibbonPersonID=gibbonPerson.gibbonPersonID) - JOIN gibbonCourseClass ON (gibbonCourseClassPerson.gibbonCourseClassID=gibbonCourseClass.gibbonCourseClassID) - WHERE (role='Teacher' OR role='Assistant' OR role='Student') - AND gibbonCourseClassPerson.gibbonCourseClassID=:gibbonCourseClassID - AND gibbonPerson.status='Full' AND (dateStart IS NULL OR dateStart<=:today) AND (dateEnd IS NULL OR dateEnd>=:today) - AND gibbonCourseClass.reportable='Y' - AND gibbonCourseClassPerson.reportable='Y'"; - $resultPerson = $connection2->prepare($sqlPerson); - $resultPerson->execute($dataPerson); - } catch (PDOException $e) { - } - - while ($rowPerson = $resultPerson->fetch()) { - if ($rowPerson['role'] == 'Teacher' || $rowPerson['role'] == 'Assistant') { - $notificationText = sprintf(__('Your ATL column for class %1$s has gone live today.'), $row['course'].'.'.$row['class']); - setNotification($connection2, $guid, $rowPerson['gibbonPersonID'], $notificationText, 'ATL', '/index.php?q=/modules/ATL/atl_write.php&gibbonCourseClassID='.$row['gibbonCourseClassID']); - } else { - $notificationText = sprintf(__('You have new ATL assessment feedback for class %1$s.'), $row['course'].'.'.$row['class']); - setNotification($connection2, $guid, $rowPerson['gibbonPersonID'], $notificationText, 'ATL', '/index.php?q=/modules/ATL/atl_view.php'); - } - } - } -} +. +*/ + +//USAGE +//Ideally this script should be run shortly after midnight, to alert users to columns that have just gone live + +require getcwd().'/../../../gibbon.php'; + +getSystemSettings($guid, $connection2); + +setCurrentSchoolYear($guid, $connection2); + +//Set up for i18n via gettext +if (!empty($session->get('i18n')['code'])) { + putenv('LC_ALL='.$session->get('i18n')['code']); + setlocale(LC_ALL, $session->get('i18n')['code']); + bindtextdomain('gibbon', getcwd().'/../i18n'); + textdomain('gibbon'); +} + + +//Check for CLI, so this cannot be run through browser +if (php_sapi_name() != 'cli') { + echo __('This script cannot be run from a browser, only via CLI.')."\n\n"; +} else { + //SCAN THROUGH ALL ATLS GOING LIVE TODAY + $data = array('completeDate' => date('Y-m-d')); + $sql = 'SELECT atlColumn.*, gibbonCourseClass.nameShort AS class, gibbonCourse.nameShort AS course FROM atlColumn JOIN gibbonCourseClass ON (atlColumn.gibbonCourseClassID=gibbonCourseClass.gibbonCourseClassID) JOIN gibbonCourse ON (gibbonCourseClass.gibbonCourseID=gibbonCourse.gibbonCourseID) WHERE completeDate=:completeDate'; + $result = $connection2->prepare($sql); + $result->execute($data); + + while ($row = $result->fetch()) { + $dataPerson = array('gibbonCourseClassID' => $row['gibbonCourseClassID'], 'today' => date('Y-m-d')); + $sqlPerson = "SELECT gibbonCourseClassPerson.* + FROM gibbonCourseClassPerson + JOIN gibbonPerson ON (gibbonCourseClassPerson.gibbonPersonID=gibbonPerson.gibbonPersonID) + JOIN gibbonCourseClass ON (gibbonCourseClassPerson.gibbonCourseClassID=gibbonCourseClass.gibbonCourseClassID) + WHERE (role='Teacher' OR role='Assistant' OR role='Student') + AND gibbonCourseClassPerson.gibbonCourseClassID=:gibbonCourseClassID + AND gibbonPerson.status='Full' AND (dateStart IS NULL OR dateStart<=:today) AND (dateEnd IS NULL OR dateEnd>=:today) + AND gibbonCourseClass.reportable='Y' + AND gibbonCourseClassPerson.reportable='Y'"; + $resultPerson = $connection2->prepare($sqlPerson); + $resultPerson->execute($dataPerson); + + $notificationGateway = new \Gibbon\Domain\System\NotificationGateway($pdo); + + while ($rowPerson = $resultPerson->fetch()) { + if ($rowPerson['role'] == 'Teacher' || $rowPerson['role'] == 'Assistant') { + $notificationSender = new \Gibbon\Comms\NotificationSender($notificationGateway, $session); + $notificationText = sprintf(__('Your ATL column for class %1$s has gone live today.'), $row['course'].'.'.$row['class']); + $notificationSender->addNotification($rowPerson['gibbonPersonID'], $notificationText, 'ATL', '/index.php?q=/modules/ATL/atl_write.php&gibbonCourseClassID='.$row['gibbonCourseClassID']); + $notificationSender->sendNotifications(); + } else { + $notificationSender = new \Gibbon\Comms\NotificationSender($notificationGateway, $session); + $notificationText = sprintf(__('You have new ATL assessment feedback for class %1$s.'), $row['course'].'.'.$row['class']); + $notificationSender->addNotification($rowPerson['gibbonPersonID'], $notificationText, 'ATL', '/index.php?q=/modules/ATL/atl_view.php'); + $notificationSender->sendNotifications(); + } + } + } +} diff --git a/ATL/hook_parentalDashboard_atlView.php b/ATL/hook_parentalDashboard_atlView.php index 2beed15..c36d86b 100644 --- a/ATL/hook_parentalDashboard_atlView.php +++ b/ATL/hook_parentalDashboard_atlView.php @@ -1,38 +1,42 @@ -. -*/ - -global $page; - -$returnInt = null; - -require_once './modules/ATL/moduleFunctions.php'; - -if (isActionAccessible($guid, $connection2, '/modules/ATL/atl_view.php') == false) { - //Acess denied - $returnInt .= "
"; - $returnInt .= 'You do not have access to this action.'; - $returnInt .= '
'; -} else { - // Register scripts available to the core, but not included by default - $page->scripts->add('chart'); - - $returnInt .= getATLRecord($guid, $connection2, $gibbonPersonID); -} - -return $returnInt; +. +*/ + +use Gibbon\Services\Format; + +global $page, $container; + +$returnInt = null; + +require_once __DIR__ . '/moduleFunctions.php'; + +if (isActionAccessible($guid, $connection2, '/modules/ATL/atl_view.php') == false) { + //Acess denied + $returnInt .= Format::alert(__('You do not have access to this action.')); +} else { + // Register scripts available to the core, but not included by default + $page->scripts->add('chart'); + //TODO: This is a hack to make sure that the ATLEntryGateway is loaded and should be fixed properly somehow. + $container->get('autoloader')->addPsr4('Gibbon\\Module\\ATL\\', $session->get('absolutePath') . '/modules/ATL/src'); + + $returnInt .= visualiseATL($container, $gibbonPersonID); + + $returnInt .= getATLRecord($gibbonPersonID); +} + +return $returnInt; diff --git a/ATL/hook_studentDashboard_atlView.php b/ATL/hook_studentDashboard_atlView.php index ea1926b..e30f0e4 100644 --- a/ATL/hook_studentDashboard_atlView.php +++ b/ATL/hook_studentDashboard_atlView.php @@ -1,38 +1,42 @@ -. -*/ - -global $page; - -$returnInt = null; - -require_once './modules/ATL/moduleFunctions.php'; - -if (isActionAccessible($guid, $connection2, '/modules/ATL/atl_view.php') == false) { - //Acess denied - $returnInt .= "
"; - $returnInt .= 'You do not have access to this action.'; - $returnInt .= '
'; -} else { - // Register scripts available to the core, but not included by default - $page->scripts->add('chart'); - - $returnInt .= getATLRecord($guid, $connection2, $session->get('gibbonPersonID')); -} - -return $returnInt; +. +*/ + +use Gibbon\Services\Format; + +global $page, $container; + +$returnInt = null; + +require_once __DIR__ . '/moduleFunctions.php'; + +if (isActionAccessible($guid, $connection2, '/modules/ATL/atl_view.php') == false) { + //Acess denied + $returnInt .= Format::alert(__('You do not have access to this action.')); +} else { + // Register scripts available to the core, but not included by default + $page->scripts->add('chart'); + //TODO: This is a hack to make sure that the ATLEntryGateway is loaded and should be fixed properly somehow. + $container->get('autoloader')->addPsr4('Gibbon\\Module\\ATL\\', $session->get('absolutePath') . '/modules/ATL/src'); + + $returnInt .= visualiseATL($container, $session->get('gibbonPersonID')); + + $returnInt .= getATLRecord($session->get('gibbonPersonID')); +} + +return $returnInt; diff --git a/ATL/hook_studentProfile_atlView.php b/ATL/hook_studentProfile_atlView.php index ba3ab5e..c165b85 100644 --- a/ATL/hook_studentProfile_atlView.php +++ b/ATL/hook_studentProfile_atlView.php @@ -1,33 +1,43 @@ -. -*/ - -//Module includes -require_once './modules/ATL/moduleFunctions.php'; - -if (isActionAccessible($guid, $connection2, '/modules/ATL/atl_view.php') == false) { - //Acess denied - echo "
"; - echo 'You do not have access to this action.'; - echo '
'; -} else { - // Register scripts available to the core, but not included by default - $page->scripts->add('chart'); - - echo getATLRecord($guid, $connection2, $gibbonPersonID); -} +. +*/ + +use Gibbon\Services\Format; + +global $page, $container; + +use Gibbon\Module\Rubrics\Visualise; +use Gibbon\Domain\Rubrics\RubricGateway; +use Gibbon\Module\ATL\Domain\ATLColumnGateway; + +//Module includes +require_once __DIR__ . '/moduleFunctions.php'; + +if (isActionAccessible($guid, $connection2, '/modules/ATL/atl_view.php') == false) { + //Acess denied + echo Format::alert(__('You do not have access to this action.')); +} else { + // Register scripts available to the core, but not included by default + $page->scripts->add('chart'); + //TODO: This is a hack to make sure that the ATLEntryGateway is loaded and should be fixed properly somehow. + $container->get('autoloader')->addPsr4('Gibbon\\Module\\ATL\\', $session->get('absolutePath') . '/modules/ATL/src'); + + echo visualiseATL($container, $gibbonPersonID); + + echo getATLRecord($gibbonPersonID); +} diff --git a/ATL/manifest.php b/ATL/manifest.php index 7357ebf..95f9656 100644 --- a/ATL/manifest.php +++ b/ATL/manifest.php @@ -1,173 +1,208 @@ -. -*/ - -//This file describes the module, including database tables - -//Basica variables -$name = 'ATL'; -$description = 'The ATL module allows schools to run a program of Approaches To Learning assessments, based on a rubric.'; -$entryURL = 'atl_write.php'; -$type = 'Additional'; -$category = 'Assess'; -$version = '1.5.02'; -$author = 'Ross Parker'; -$url = 'http://rossparker.org'; - -//Module tables -$moduleTables[0] = "CREATE TABLE `atlColumn` ( - `atlColumnID` int(10) unsigned zerofill NOT NULL AUTO_INCREMENT, - `gibbonCourseClassID` int(8) unsigned zerofill NOT NULL, - `groupingID` int(8) unsigned zerofill DEFAULT NULL COMMENT 'A value used to group multiple ATL columns.', - `name` varchar(20) NOT NULL, - `description` text NOT NULL, - `gibbonRubricID` int(8) unsigned zerofill DEFAULT NULL, - `complete` enum('N','Y') NOT NULL, - `completeDate` date DEFAULT NULL, - `gibbonPersonIDCreator` int(10) unsigned zerofill NOT NULL, - `gibbonPersonIDLastEdit` int(10) unsigned zerofill NOT NULL, - PRIMARY KEY (`atlColumnID`), - KEY `gibbonCourseClassID` (`gibbonCourseClassID`), - KEY `gibbonRubricID` (`gibbonRubricID`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8;"; - -$moduleTables[1] = "CREATE TABLE `atlEntry` ( - `atlEntryID` int(12) unsigned zerofill NOT NULL AUTO_INCREMENT, - `atlColumnID` int(10) unsigned zerofill NOT NULL, - `gibbonPersonIDStudent` int(10) unsigned zerofill NOT NULL, - `complete` enum('Y','N') NOT NULL DEFAULT 'N', - `gibbonPersonIDLastEdit` int(10) unsigned zerofill NOT NULL, - PRIMARY KEY (`atlEntryID`), - KEY (`atlColumnID`), - KEY (`gibbonPersonIDStudent`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8;"; - -//Action rows -$actionRows[0]['name'] = 'Manage ATLs_all'; -$actionRows[0]['precedence'] = '0'; -$actionRows[0]['category'] = 'Manage & Assess'; -$actionRows[0]['description'] = 'Allows privileged users to create and manage ATL columns.'; -$actionRows[0]['URLList'] = 'atl_manage.php, atl_manage_add.php, atl_manage_edit.php, atl_manage_delete.php'; -$actionRows[0]['entryURL'] = 'atl_manage.php'; -$actionRows[0]['defaultPermissionAdmin'] = 'Y'; -$actionRows[0]['defaultPermissionTeacher'] = 'N'; -$actionRows[0]['defaultPermissionStudent'] = 'N'; -$actionRows[0]['defaultPermissionParent'] = 'N'; -$actionRows[0]['defaultPermissionSupport'] = 'N'; -$actionRows[0]['categoryPermissionStaff'] = 'Y'; -$actionRows[0]['categoryPermissionStudent'] = 'N'; -$actionRows[0]['categoryPermissionParent'] = 'N'; -$actionRows[0]['categoryPermissionOther'] = 'N'; - -$actionRows[1]['name'] = 'Write ATLs_myClasses'; -$actionRows[1]['precedence'] = '0'; -$actionRows[1]['category'] = 'Manage & Assess'; -$actionRows[1]['description'] = 'Allows teachers to enter ATL assessment data to columns in their classes.'; -$actionRows[1]['URLList'] = 'atl_write.php, atl_write_data.php'; -$actionRows[1]['entryURL'] = 'atl_write.php'; -$actionRows[1]['defaultPermissionAdmin'] = 'N'; -$actionRows[1]['defaultPermissionTeacher'] = 'Y'; -$actionRows[1]['defaultPermissionStudent'] = 'N'; -$actionRows[1]['defaultPermissionParent'] = 'N'; -$actionRows[1]['defaultPermissionSupport'] = 'N'; -$actionRows[1]['categoryPermissionStaff'] = 'Y'; -$actionRows[1]['categoryPermissionStudent'] = 'N'; -$actionRows[1]['categoryPermissionParent'] = 'N'; -$actionRows[1]['categoryPermissionOther'] = 'N'; - -$actionRows[2]['name'] = 'Write ATLs_all'; -$actionRows[2]['precedence'] = '1'; -$actionRows[2]['category'] = 'Manage & Assess'; -$actionRows[2]['description'] = 'Allows privileged users to enter ATL assessment data to columns in all classes.'; -$actionRows[2]['URLList'] = 'atl_write.php, atl_write_data.php'; -$actionRows[2]['entryURL'] = 'atl_write.php'; -$actionRows[2]['defaultPermissionAdmin'] = 'Y'; -$actionRows[2]['defaultPermissionTeacher'] = 'N'; -$actionRows[2]['defaultPermissionStudent'] = 'N'; -$actionRows[2]['defaultPermissionParent'] = 'N'; -$actionRows[2]['defaultPermissionSupport'] = 'N'; -$actionRows[2]['categoryPermissionStaff'] = 'Y'; -$actionRows[2]['categoryPermissionStudent'] = 'N'; -$actionRows[2]['categoryPermissionParent'] = 'N'; -$actionRows[2]['categoryPermissionOther'] = 'N'; - -$actionRows[3]['name'] = 'View ATLs_mine'; -$actionRows[3]['precedence'] = '0'; -$actionRows[3]['category'] = 'View'; -$actionRows[3]['description'] = 'Allows students to view their own ATL results.'; -$actionRows[3]['URLList'] = 'atl_view.php'; -$actionRows[3]['entryURL'] = 'atl_view.php'; -$actionRows[3]['defaultPermissionAdmin'] = 'N'; -$actionRows[3]['defaultPermissionTeacher'] = 'N'; -$actionRows[3]['defaultPermissionStudent'] = 'Y'; -$actionRows[3]['defaultPermissionParent'] = 'N'; -$actionRows[3]['defaultPermissionSupport'] = 'N'; -$actionRows[3]['categoryPermissionStaff'] = 'N'; -$actionRows[3]['categoryPermissionStudent'] = 'Y'; -$actionRows[3]['categoryPermissionParent'] = 'N'; -$actionRows[3]['categoryPermissionOther'] = 'N'; - -$actionRows[4]['name'] = 'View ATLs_myChildrens'; -$actionRows[4]['precedence'] = '1'; -$actionRows[4]['category'] = 'View'; -$actionRows[4]['description'] = "Allows parents to view their childrens' ATL results."; -$actionRows[4]['URLList'] = 'atl_view.php'; -$actionRows[4]['entryURL'] = 'atl_view.php'; -$actionRows[4]['defaultPermissionAdmin'] = 'N'; -$actionRows[4]['defaultPermissionTeacher'] = 'N'; -$actionRows[4]['defaultPermissionStudent'] = 'N'; -$actionRows[4]['defaultPermissionParent'] = 'Y'; -$actionRows[4]['defaultPermissionSupport'] = 'N'; -$actionRows[4]['categoryPermissionStaff'] = 'N'; -$actionRows[4]['categoryPermissionStudent'] = 'N'; -$actionRows[4]['categoryPermissionParent'] = 'Y'; -$actionRows[4]['categoryPermissionOther'] = 'N'; - -$actionRows[5]['name'] = 'View ATLs_all'; -$actionRows[5]['precedence'] = '2'; -$actionRows[5]['category'] = 'View'; -$actionRows[5]['description'] = 'Allows staff to see ATL results for all children.'; -$actionRows[5]['URLList'] = 'atl_view.php'; -$actionRows[5]['entryURL'] = 'atl_view.php'; -$actionRows[5]['defaultPermissionAdmin'] = 'Y'; -$actionRows[5]['defaultPermissionTeacher'] = 'Y'; -$actionRows[5]['defaultPermissionStudent'] = 'N'; -$actionRows[5]['defaultPermissionParent'] = 'N'; -$actionRows[5]['defaultPermissionSupport'] = 'N'; -$actionRows[5]['categoryPermissionStaff'] = 'Y'; -$actionRows[5]['categoryPermissionStudent'] = 'N'; -$actionRows[5]['categoryPermissionParent'] = 'N'; -$actionRows[5]['categoryPermissionOther'] = 'N'; - -$array = array(); -$array['sourceModuleName'] = 'ATL'; -$array['sourceModuleAction'] = 'View ATLs_all'; -$array['sourceModuleInclude'] = 'hook_studentProfile_atlView.php'; -$hooks[0] = "INSERT INTO `gibbonHook` (`gibbonHookID`, `name`, `type`, `options`, gibbonModuleID) VALUES (NULL, 'ATL', 'Student Profile', '".serialize($array)."', (SELECT gibbonModuleID FROM gibbonModule WHERE name='$name'));"; - -$array = array(); -$array['sourceModuleName'] = 'ATL'; -$array['sourceModuleAction'] = 'View ATLs_myChildrens'; -$array['sourceModuleInclude'] = 'hook_parentalDashboard_atlView.php'; -$hooks[1] = "INSERT INTO `gibbonHook` (`gibbonHookID`, `name`, `type`, `options`, gibbonModuleID) VALUES (NULL, 'ATL', 'Parental Dashboard', '".serialize($array)."', (SELECT gibbonModuleID FROM gibbonModule WHERE name='$name'));"; - -$array = array(); -$array['sourceModuleName'] = 'ATL'; -$array['sourceModuleAction'] = 'View ATLs_mine'; -$array['sourceModuleInclude'] = 'hook_studentDashboard_atlView.php'; -$hooks[2] = "INSERT INTO `gibbonHook` (`gibbonHookID`, `name`, `type`, `options`, gibbonModuleID) VALUES (NULL, 'ATL', 'Student Dashboard', '".serialize($array)."', (SELECT gibbonModuleID FROM gibbonModule WHERE name='$name'));"; +. +*/ + +//This file describes the module, including database tables + +//Basic variables +$name = 'ATL'; +$description = 'The ATL module allows schools to run a program of Approaches To Learning assessments, based on a rubric.'; +$entryURL = 'atl_write.php'; +$type = 'Additional'; +$category = 'Assess'; +$version = '1.6.00'; +$author = 'Ross Parker'; +$url = 'http://rossparker.org'; + +//Module tables +$moduleTables[] = "CREATE TABLE `atlColumn` ( + `atlColumnID` int(10) unsigned zerofill NOT NULL AUTO_INCREMENT, + `gibbonCourseClassID` int(8) unsigned zerofill NOT NULL, + `name` varchar(20) NOT NULL, + `description` text NOT NULL, + `gibbonRubricID` int(8) unsigned zerofill DEFAULT NULL, + `complete` enum('N','Y') NOT NULL, + `completeDate` date DEFAULT NULL, + `forStudents` enum('Y','N') NOT NULL DEFAULT 'N', + `gibbonPersonIDCreator` int(10) unsigned zerofill NOT NULL, + `gibbonPersonIDLastEdit` int(10) unsigned zerofill NOT NULL, + PRIMARY KEY (`atlColumnID`), + KEY `gibbonCourseClassID` (`gibbonCourseClassID`), + KEY `gibbonRubricID` (`gibbonRubricID`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8;"; + +$moduleTables[] = "CREATE TABLE `atlEntry` ( + `atlEntryID` int(12) unsigned zerofill NOT NULL AUTO_INCREMENT, + `atlColumnID` int(10) unsigned zerofill NOT NULL, + `gibbonPersonIDStudent` int(10) unsigned zerofill NOT NULL, + `complete` enum('Y','N') NOT NULL DEFAULT 'N', + `gibbonPersonIDLastEdit` int(10) unsigned zerofill NOT NULL, + PRIMARY KEY (`atlEntryID`), + KEY (`atlColumnID`), + KEY (`gibbonPersonIDStudent`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8;"; + +//Action rows +$actionRows[] = [ + 'name' => 'Manage ATLs_all', + 'precedence' => '0', + 'category' => 'Manage & Assess', + 'description' => 'Allows privileged users to create and manage ATL columns.', + 'URLList' => 'atl_manage.php, atl_manage_add.php, atl_manage_edit.php, atl_manage_delete.php', + 'entryURL' => 'atl_manage.php', + 'defaultPermissionAdmin' => 'Y', + 'defaultPermissionTeacher' => 'N', + 'defaultPermissionStudent' => 'N', + 'defaultPermissionParent' => 'N', + 'defaultPermissionSupport' => 'N', + 'categoryPermissionStaff' => 'Y', + 'categoryPermissionStudent' => 'N', + 'categoryPermissionParent' => 'N', + 'categoryPermissionOther' => 'N' +]; + +$actionRows[] = [ + 'name' => 'Write ATLs_myClasses', + 'precedence' => '0', + 'category' => 'Manage & Assess', + 'description' => 'Allows teachers to enter ATL assessment data to columns in their classes.', + 'URLList' => 'atl_write.php, atl_write_data.php', + 'entryURL' => 'atl_write.php', + 'defaultPermissionAdmin' => 'N', + 'defaultPermissionTeacher' => 'Y', + 'defaultPermissionStudent' => 'N', + 'defaultPermissionParent' => 'N', + 'defaultPermissionSupport' => 'N', + 'categoryPermissionStaff' => 'Y', + 'categoryPermissionStudent' => 'N', + 'categoryPermissionParent' => 'N', + 'categoryPermissionOther' => 'N' +]; + +$actionRows[] = [ + 'name' => 'Write ATLs_all', + 'precedence' => '1', + 'category' => 'Manage & Assess', + 'description' => 'Allows privileged users to enter ATL assessment data to columns in all classes.', + 'URLList' => 'atl_write.php, atl_write_data.php', + 'entryURL' => 'atl_write.php', + 'defaultPermissionAdmin' => 'Y', + 'defaultPermissionTeacher' => 'N', + 'defaultPermissionStudent' => 'N', + 'defaultPermissionParent' => 'N', + 'defaultPermissionSupport' => 'N', + 'categoryPermissionStaff' => 'Y', + 'categoryPermissionStudent' => 'N', + 'categoryPermissionParent' => 'N', + 'categoryPermissionOther' => 'N' +]; + +$actionRows[] = [ + 'name' => 'View ATLs_mine', + 'precedence' => '0', + 'category' => 'View', + 'description' => 'Allows students to view their own ATL results.', + 'URLList' => 'atl_view.php', + 'entryURL' => 'atl_view.php', + 'defaultPermissionAdmin' => 'N', + 'defaultPermissionTeacher' => 'N', + 'defaultPermissionStudent' => 'Y', + 'defaultPermissionParent' => 'N', + 'defaultPermissionSupport' => 'N', + 'categoryPermissionStaff' => 'N', + 'categoryPermissionStudent' => 'Y', + 'categoryPermissionParent' => 'N', + 'categoryPermissionOther' => 'N' +]; + +$actionRows[] = [ + 'name' => 'View ATLs_myChildrens', + 'precedence' => '1', + 'category' => 'View', + 'description' => "Allows parents to view their childrens' ATL results.", + 'URLList' => 'atl_view.php', + 'entryURL' => 'atl_view.php', + 'defaultPermissionAdmin' => 'N', + 'defaultPermissionTeacher' => 'N', + 'defaultPermissionStudent' => 'N', + 'defaultPermissionParent' => 'Y', + 'defaultPermissionSupport' => 'N', + 'categoryPermissionStaff' => 'N', + 'categoryPermissionStudent' => 'N', + 'categoryPermissionParent' => 'Y', + 'categoryPermissionOther' => 'N' +]; + +$actionRows[] = [ + 'name' => 'View ATLs_all', + 'precedence' => '2', + 'category' => 'View', + 'description' => 'Allows staff to see ATL results for all children.', + 'URLList' => 'atl_view.php', + 'entryURL' => 'atl_view.php', + 'defaultPermissionAdmin' => 'Y', + 'defaultPermissionTeacher' => 'Y', + 'defaultPermissionStudent' => 'N', + 'defaultPermissionParent' => 'N', + 'defaultPermissionSupport' => 'N', + 'categoryPermissionStaff' => 'Y', + 'categoryPermissionStudent' => 'N', + 'categoryPermissionParent' => 'N', + 'categoryPermissionOther' => 'N' +]; + +$actionRows[] = [ + 'name' => 'Fill ATLs', + 'precedence' => '0', + 'category' => 'View', + 'description' => 'Allows students to enter ATL assessment data to columns in their classes.', + 'URLList' => 'atl_write_student.php', + 'entryURL' => 'atl_write_student.php', + 'defaultPermissionAdmin' => 'N', + 'defaultPermissionTeacher' => 'N', + 'defaultPermissionStudent' => 'Y', + 'defaultPermissionParent' => 'N', + 'defaultPermissionSupport' => 'N', + 'categoryPermissionStaff' => 'N', + 'categoryPermissionStudent' => 'Y', + 'categoryPermissionParent' => 'N', + 'categoryPermissionOther' => 'N' +]; + +//Hooks +$array = [ + 'sourceModuleName' => 'ATL', + 'sourceModuleAction' => 'View ATLs_all', + 'sourceModuleInclude' => 'hook_studentProfile_atlView.php' +]; +$hooks[] = "INSERT INTO `gibbonHook` (`gibbonHookID`, `name`, `type`, `options`, gibbonModuleID) VALUES (NULL, 'ATL', 'Student Profile', '".serialize($array)."', (SELECT gibbonModuleID FROM gibbonModule WHERE name='$name'));"; + +$array = [ + 'sourceModuleName' => 'ATL', + 'sourceModuleAction' => 'View ATLs_myChildrens', + 'sourceModuleInclude' => 'hook_parentalDashboard_atlView.php' +]; +$hooks[] = "INSERT INTO `gibbonHook` (`gibbonHookID`, `name`, `type`, `options`, gibbonModuleID) VALUES (NULL, 'ATL', 'Parental Dashboard', '".serialize($array)."', (SELECT gibbonModuleID FROM gibbonModule WHERE name='$name'));"; + +$array = [ + 'sourceModuleName' => 'ATL' + 'sourceModuleAction' => 'View ATLs_mine', + 'sourceModuleInclude' => 'hook_studentDashboard_atlView.php' +]; +$hooks[] = "INSERT INTO `gibbonHook` (`gibbonHookID`, `name`, `type`, `options`, gibbonModuleID) VALUES (NULL, 'ATL', 'Student Dashboard', '".serialize($array)."', (SELECT gibbonModuleID FROM gibbonModule WHERE name='$name'));"; + diff --git a/ATL/moduleFunctions.php b/ATL/moduleFunctions.php index cfeb394..cc448ac 100644 --- a/ATL/moduleFunctions.php +++ b/ATL/moduleFunctions.php @@ -1,145 +1,205 @@ -. -*/ - -use Gibbon\Forms\Form; -use Gibbon\Forms\DatabaseFormFactory; - -function getATLRecord($guid, $connection2, $gibbonPersonID) -{ - $output = ''; - - //Get school years in reverse order - try { - $dataYears = array('gibbonPersonID' => $gibbonPersonID); - $sqlYears = "SELECT * FROM gibbonSchoolYear JOIN gibbonStudentEnrolment ON (gibbonStudentEnrolment.gibbonSchoolYearID=gibbonSchoolYear.gibbonSchoolYearID) WHERE (status='Current' OR status='Past') AND gibbonPersonID=:gibbonPersonID ORDER BY sequenceNumber DESC"; - $resultYears = $connection2->prepare($sqlYears); - $resultYears->execute($dataYears); - } catch (PDOException $e) { - $output .= "
".$e->getMessage().'
'; - } - - if ($resultYears->rowCount() < 1) { - $output .= "
"; - $output .= __('There are no records to display.'); - $output .= '
'; - } else { - $results = false; - while ($rowYears = $resultYears->fetch()) { - //Get and output ATLs - try { - $dataATL = array('gibbonPersonID1' => $gibbonPersonID, 'gibbonPersonID2' => $gibbonPersonID, 'gibbonSchoolYearID' => $rowYears['gibbonSchoolYearID']); - $sqlATL = "SELECT DISTINCT atlColumn.*, atlEntry.*, gibbonCourse.name AS course, gibbonCourseClass.nameShort AS class, gibbonPerson.dateStart FROM gibbonCourse JOIN gibbonCourseClass ON (gibbonCourseClass.gibbonCourseID=gibbonCourse.gibbonCourseID) JOIN gibbonCourseClassPerson ON (gibbonCourseClassPerson.gibbonCourseClassID=gibbonCourseClass.gibbonCourseClassID) JOIN atlColumn ON (atlColumn.gibbonCourseClassID=gibbonCourseClass.gibbonCourseClassID) JOIN atlEntry ON (atlEntry.atlColumnID=atlColumn.atlColumnID) JOIN gibbonPerson ON (atlEntry.gibbonPersonIDStudent=gibbonPerson.gibbonPersonID) WHERE gibbonCourseClassPerson.gibbonPersonID=:gibbonPersonID1 AND atlEntry.gibbonPersonIDStudent=:gibbonPersonID2 AND gibbonSchoolYearID=:gibbonSchoolYearID AND completeDate<='".date('Y-m-d')."' AND gibbonCourseClass.reportable='Y' AND gibbonCourseClassPerson.reportable='Y' ORDER BY completeDate DESC, gibbonCourse.nameShort, gibbonCourseClass.nameShort"; - $resultATL = $connection2->prepare($sqlATL); - $resultATL->execute($dataATL); - } catch (PDOException $e) { - $output .= "
".$e->getMessage().'
'; - } - - if ($resultATL->rowCount() > 0) { - $results = true; - $output .= '

'; - $output .= $rowYears['name']; - $output .= '

'; - $output .= ""; - $output .= ""; - $output .= "'; - $output .= ''; - $output .= "'; - $output .= ''; - - $count = 0; - while ($rowATL = $resultATL->fetch()) { - if ($count % 2 == 0) { - $rowNum = 'even'; - } else { - $rowNum = 'odd'; - } - ++$count; - - $output .= ""; - $output .= ''; - if ($rowATL['gibbonRubricID'] == '') { - $output .= "'; - } else { - $output .= "'; - } - - $output .= ''; - } - - $output .= '
"; - $output .= 'Assessment'; - $output .= '"; - $output .= __('Rubric'); - $output .= '
'; - $output .= "".$rowATL['course'].'
'.$rowATL['name'].'

'; - $output .= ""; - if ($rowATL['completeDate'] != '') { - $output .= 'Marked on '.dateConvertBack($guid, $rowATL['completeDate']).'
'; - } else { - $output .= 'Unmarked
'; - } - $output .= '

'; - $output .= '
"; - $output .= __('N/A'); - $output .= '"; - $output .= ""; - $output .= '
'; - } - } - if ($results == false) { - $output .= "
"; - $output .= __('There are no records to display.'); - $output .= '
'; - } - } - - return $output; -} - -function sidebarExtra($guid, $connection2, $gibbonCourseClassID, $mode = 'manage', $highestAction = '') -{ - $output = ''; - - $output .= '
'; - $output .= '

'; - $output .= __('View Classes'); - $output .= '

'; - - $selectCount = 0; - - global $pdo; - - $form = Form::create('classSelect', $_SESSION[$guid]['absoluteURL'].'/index.php', 'get'); - $form->setFactory(DatabaseFormFactory::create($pdo)); - $form->addHiddenValue('q', '/modules/'.$_SESSION[$guid]['module'].'/'.($mode == 'write'? 'atl_write.php' : 'atl_manage.php')); - $form->setClass('smallIntBorder w-full'); - - $row = $form->addRow(); - $row->addSelectClass('gibbonCourseClassID', $_SESSION[$guid]['gibbonSchoolYearID'], $_SESSION[$guid]['gibbonPersonID']) - ->selected($gibbonCourseClassID) - ->placeholder() - ->setClass('fullWidth'); - $row->addSubmit(__('Go')); - - $output .= $form->getOutput(); - $output .= '
'; - - return $output; -} +. +*/ + +use Gibbon\Contracts\Database\Connection; +use Gibbon\Contracts\Services\Session; +use Gibbon\Domain\Rubrics\RubricGateway; +use Gibbon\Forms\DatabaseFormFactory; +use Gibbon\Forms\Form; +use Gibbon\Module\ATL\Domain\ATLColumnGateway; +use Gibbon\Module\ATL\Domain\ATLEntryGateway; +use Gibbon\Module\Rubrics\Visualise; +use Gibbon\Services\Format; +use Gibbon\Tables\DataTable; + + +function getATLRecord($gibbonPersonID) +{ + global $container, $session; + + $output = ''; + + $atlEntryGateway = $container->get(ATLEntryGateway::class); + $criteria = $atlEntryGateway->newQueryCriteria(true) + ->sortBy('gibbonSchoolYear.sequenceNumber', 'DESC') + ->sortBy('completeDate', 'DESC') + ->sortBy(['courseName']) + ->fromPOST(); + + $atls = $atlEntryGateway->queryATLsByStudent($criteria, $gibbonPersonID); + + $gibbonSchoolYearFilter = array_reduce($atls->toArray(), function ($group, $atl) { + $group['gibbonSchoolYearID' . $atl['gibbonSchoolYearID']] = __('School Year') . ': ' . $atl['yearName']; + return $group; + }, []); + + $table = DataTable::createPaginated('atlView', $criteria); + + $table->addMetaData('filterOptions', $gibbonSchoolYearFilter); + + $table->addColumn('yearName', __('School Year')) + ->sortable('gibbonSchoolYear.sequenceNumber'); + + $table->addColumn('courseName', __('Course')); + + $table->addColumn('assessment', __('Assessment')) + ->sortable('completeDate') + ->description(__('Marked on')) + ->format(function($atl) { + $output = ''; + + $output .= Format::tag($atl['ATLName'], '', $atl['ATLDescription']); + $output .= '
'; + if (empty($atl['completeDate'])) { + $output .= __('N/A'); + } else { + $output .= Format::small(Format::dateReadable($atl['completeDate'])); + } + return $output; + }); + + $table->addActionColumn() + ->addParam('gibbonCourseClassID') + ->addParam('atlColumnID') + ->addParam('gibbonRubricID') + ->addParam('gibbonPersonID', $gibbonPersonID) + ->format(function($atl, $actions) use ($session) { + $actions->addAction('enterData', __('View Rubric')) + ->addParam('type', 'effort') + ->modalWindow(1100, 500) + ->setURL('/modules/ATL/atl_view_rubric.php') + ->setIcon('markbook'); + }); + + + $output .= $table->render($atls); + + return $output; +} + +function sidebarExtra($gibbonCourseClassID, $mode = 'manage') +{ + global $pdo, $session; + + $output = ''; + + $output .= '
'; + $output .= '

'; + $output .= __('View Classes'); + $output .= '

'; + + $selectCount = 0; + + $form = Form::create('classSelect', $session->get('absoluteURL').'/index.php', 'get'); + $form->setFactory(DatabaseFormFactory::create($pdo)); + $form->addHiddenValue('q', '/modules/'.$session->get('module').'/'.($mode == 'write'? 'atl_write.php' : 'atl_manage.php')); + $form->setClass('smallIntBorder w-full'); + + $row = $form->addRow(); + $row->addSelectClass('gibbonCourseClassID', $session->get('gibbonSchoolYearID'), $session->get('gibbonPersonID')) + ->selected($gibbonCourseClassID) + ->placeholder() + ->setClass('fullWidth'); + $row->addSubmit(__('Go')); + + $output .= $form->getOutput(); + $output .= '
'; + + return $output; +} + +function visualiseATL($container, $gibbonPersonID) { + $session = $container->get(Session::class); + $pdo = $container->get(Connection::class); + + require_once $session->get('absolutePath').'/modules/ATL/src/Domain/ATLColumnGateway.php'; + + // Display the visualization of all ATLs + $contextDBTable = 'atlColumn'; + $contextDBTableID = $gibbonPersonID; + $contextDBTableIDField = 'atlColumnID'; + $contextDBTableGibbonRubricIDField = 'gibbonRubricID'; + $contextDBTableNameField = 'name'; + $contextDBTableDateField = 'completeDate'; + + $rubricGateway = $container->get(RubricGateway::class); + $studentRubricInfo = $container->get(ATLColumnGateway::class)->getATLRubricByStudent($session->get('gibbonSchoolYearID'), $gibbonPersonID); + $gibbonRubricID = $studentRubricInfo['gibbonRubricID'] ?? ''; + $rubric = $rubricGateway->getByID($gibbonRubricID); + + if ($gibbonRubricID && $rubric) { + // Get rows, columns and cells + $rows = $rubricGateway->selectRowsByRubric($gibbonRubricID)->fetchAll(); + $columns = $rubricGateway->selectColumnsByRubric($gibbonRubricID)->fetchAll(); + $gradeScales = $rubricGateway->selectGradeScalesByRubric($gibbonRubricID)->fetchGroupedUnique(); + + if (empty($rows) or empty($columns)) { + $col->addAlert(__('The rubric is missing data and cannot be drawn.')); + } else { + $cells = []; + $resultCells = $rubricGateway->selectCellsByRubric($gibbonRubricID); + while ($rowCells = $resultCells->fetch()) { + $cells[$rowCells['gibbonRubricRowID']][$rowCells['gibbonRubricColumnID']] = $rowCells; + } + + // Get other uses of this rubric in this context, and store for use in visualisation + $contexts = []; + + $dataContext = array('gibbonPersonID' => $gibbonPersonID, 'gibbonSchoolYearID' => $session->get('gibbonSchoolYearID')); + $sqlContext = "SELECT gibbonRubricEntry.*, $contextDBTable.*, gibbonRubricEntry.*, gibbonRubricCell.*, gibbonCourse.nameShort AS course, gibbonCourseClass.nameShort AS class + FROM gibbonRubricEntry + JOIN $contextDBTable ON (gibbonRubricEntry.contextDBTableID=$contextDBTable.$contextDBTableIDField + AND gibbonRubricEntry.gibbonRubricID=$contextDBTable.$contextDBTableGibbonRubricIDField) + JOIN gibbonRubricCell ON (gibbonRubricEntry.gibbonRubricCellID=gibbonRubricCell.gibbonRubricCellID) + JOIN gibbonCourseClass ON ($contextDBTable.gibbonCourseClassID=gibbonCourseClass.gibbonCourseClassID) + JOIN gibbonCourse ON (gibbonCourseClass.gibbonCourseID=gibbonCourse.gibbonCourseID) + WHERE contextDBTable='$contextDBTable' + AND gibbonRubricEntry.gibbonPersonID=:gibbonPersonID + AND gibbonSchoolYearID=:gibbonSchoolYearID + AND NOT $contextDBTableDateField IS NULL + ORDER BY $contextDBTableDateField DESC"; + $resultContext = $pdo->select($sqlContext, $dataContext); + + if ($resultContext->rowCount() > 0) { + while ($rowContext = $resultContext->fetch()) { + $context = $rowContext['course'].'.'.$rowContext['class'].' - '.$rowContext[$contextDBTableNameField].' ('.Format::date($rowContext[$contextDBTableDateField]).')'; + $cells[$rowContext['gibbonRubricRowID']][$rowContext['gibbonRubricColumnID']]['context'][] = $context; + + $contexts[] = [ + 'gibbonRubricEntry' => $rowContext['gibbonRubricEntry'], + 'gibbonRubricID' => $rowContext['gibbonRubricID'], + 'gibbonPersonID' => $rowContext['gibbonPersonID'], + 'gibbonRubricCellID' => $rowContext['gibbonRubricCellID'], + 'contextDBTable' => $rowContext['contextDBTable'], + 'contextDBTableID' => $rowContext['contextDBTableID'] + ]; + } + } + + } + + if (!empty($contexts) && !empty($columns) && !empty($rows) && !empty($cells)) { + require_once $session->get('absolutePath').'/modules/Rubrics/src/Visualise.php'; + $visualise = new Visualise($session->get('absoluteURL'), $container->get('page'), $gibbonPersonID.'All', $columns, $rows, $cells, $contexts); + return $visualise->renderVisualise(); + } + + return ''; + } +} diff --git a/ATL/src/Domain/ATLColumnGateway.php b/ATL/src/Domain/ATLColumnGateway.php index 566be22..e830758 100644 --- a/ATL/src/Domain/ATLColumnGateway.php +++ b/ATL/src/Domain/ATLColumnGateway.php @@ -1,24 +1,122 @@ -newQuery() + ->from($this->getTableName()) + ->cols([ + 'atlColumnID', 'gibbonCourseClassID', 'name', 'description', 'gibbonRubricID', 'complete', 'completeDate', 'gibbonPersonIDCreator', 'gibbonPersonIDLastEdit' + ]) + ->where('atlColumn.gibbonCourseClassID = :gibbonCourseClassID') + ->bindValue('gibbonCourseClassID', $gibbonCourseClassID); + + return $this->runQuery($query, $criteria); + } + + /** + * @param QueryCriteria $criteria + * @return DataSet + */ + public function queryATLColumnsByStudent(QueryCriteria $criteria, $gibbonSchoolYearID, $gibbonPersonID, $notComplete = false) + { + $query = $this + ->newQuery() + ->from($this->getTableName()) + ->cols([ + 'atlColumn.atlColumnID', 'atlColumn.gibbonRubricID', 'atlColumn.gibbonCourseClassID', 'atlEntry.atlEntryID', 'atlColumn.name', 'atlColumn.description', 'atlColumn.complete', 'atlColumn.completeDate', 'gibbonCourse.nameShort AS course', 'gibbonCourseClass.nameShort AS class', 'atlEntry.complete as entryComplete' + ]) + ->leftJoin('atlEntry', 'atlColumn.atlColumnID=atlEntry.atlColumnID AND atlEntry.gibbonPersonIDStudent = :gibbonPersonID') + ->leftJoin('gibbonCourseClass', 'atlColumn.gibbonCourseClassID = gibbonCourseClass.gibbonCourseClassID') + ->leftJoin('gibbonCourseClassPerson', 'gibbonCourseClass.gibbonCourseClassID = gibbonCourseClassPerson.gibbonCourseClassID') + ->leftJoin('gibbonCourse', 'gibbonCourseClass.gibbonCourseID = gibbonCourse.gibbonCourseID') + ->where("atlColumn.forStudents = 'Y'") + ->where('atlColumn.completeDate >= :today') + ->where('gibbonCourseClassPerson.gibbonPersonID = :gibbonPersonID') + ->where("gibbonCourseClassPerson.role = 'Student'") + ->where('gibbonCourse.gibbonSchoolYearID = :gibbonSchoolYearID') + ->bindValue('today', date('Y-m-d')) + ->bindValue('gibbonPersonID', $gibbonPersonID) + ->bindValue('gibbonSchoolYearID', $gibbonSchoolYearID); + + if ($notComplete) { + $query->where("(atlEntry.complete = 'N' OR atlEntry.complete IS NULL)"); + } + + return $this->runQuery($query, $criteria); + } + + public function getATLRubricByStudent($gibbonSchoolYearID, $gibbonPersonID) + { + $data = array('gibbonSchoolYearID' => $gibbonSchoolYearID, 'gibbonPersonID' => $gibbonPersonID); + $sql = "SELECT + gibbonPerson.gibbonPersonID, + surname, + preferredName, + gibbonCourseClass.gibbonCourseClassID, + gibbonRubricID + FROM gibbonPerson + JOIN gibbonStudentEnrolment ON (gibbonPerson.gibbonPersonID=gibbonStudentEnrolment.gibbonPersonID) + JOIN gibbonFormGroup ON (gibbonStudentEnrolment.gibbonFormGroupID=gibbonFormGroup.gibbonFormGroupID) + JOIN gibbonCourseClassPerson ON (gibbonCourseClassPerson.gibbonPersonID=gibbonPerson.gibbonPersonID) + JOIN gibbonCourseClass ON (gibbonCourseClassPerson.gibbonCourseClassID=gibbonCourseClass.gibbonCourseClassID) + JOIN gibbonCourse ON (gibbonCourse.gibbonCourseID=gibbonCourseClass.gibbonCourseID AND gibbonCourse.gibbonSchoolYearID=gibbonStudentEnrolment.gibbonSchoolYearID) + JOIN atlColumn ON (atlColumn.gibbonCourseClassID=gibbonCourseClass.gibbonCourseClassID) + WHERE status='Full' + AND gibbonStudentEnrolment.gibbonSchoolYearID=:gibbonSchoolYearID + AND gibbonPerson.gibbonPersonID=:gibbonPersonID + AND gibbonCourseClassPerson.role='Student' + ORDER BY surname, preferredName + LIMIT 0, 1"; + + return $this->db()->selectOne($sql, $data); + } + + public function isForStudent($atlColumnID, $gibbonPersonID, $gibbonSchoolYearID) { + $select = $this + ->newSelect() + ->from($this->getTableName()) + ->cols([ + 'atlColumn.atlColumnID' + ]) + ->leftJoin('gibbonCourseClass', 'atlColumn.gibbonCourseClassID = gibbonCourseClass.gibbonCourseClassID') + ->leftJoin('gibbonCourseClassPerson', 'gibbonCourseClass.gibbonCourseClassID = gibbonCourseClassPerson.gibbonCourseClassID') + ->leftJoin('gibbonCourse', 'gibbonCourseClass.gibbonCourseID = gibbonCourse.gibbonCourseID') + ->where('atlColumn.atlColumnID = :atlColumnID') + ->where("atlColumn.forStudents = 'Y'") + ->where('gibbonCourseClassPerson.gibbonPersonID = :gibbonPersonID') + ->where("gibbonCourseClassPerson.role = 'Student'") + ->where('gibbonCourse.gibbonSchoolYearID = :gibbonSchoolYearID') + ->bindValue('atlColumnID', $atlColumnID) + ->bindValue('gibbonPersonID', $gibbonPersonID) + ->bindValue('gibbonSchoolYearID', $gibbonSchoolYearID); + + $result = $this->runSelect($select); + return $result->isNotEmpty(); + } + +} diff --git a/ATL/src/Domain/ATLEntryGateway.php b/ATL/src/Domain/ATLEntryGateway.php new file mode 100644 index 0000000..533440c --- /dev/null +++ b/ATL/src/Domain/ATLEntryGateway.php @@ -0,0 +1,73 @@ +newQuery() + ->from($this->getTableName()) + ->cols([ + 'gibbonSchoolYear.name as yearName', 'gibbonCourse.gibbonSchoolYearID', 'gibbonCourse.name as courseName', 'atlColumn.name as ATLName', 'atlColumn.description as ATLDescription', 'atlColumn.completeDate', 'atlColumn.gibbonRubricID', 'atlColumn.gibbonCourseClassID', 'atlColumn.atlColumnID' + ]) + ->leftJoin('atlColumn', 'atlEntry.atlColumnID=atlColumn.atlColumnID') + ->leftJoin('gibbonCourseClass', 'atlColumn.gibbonCourseClassID = gibbonCourseClass.gibbonCourseClassID') + ->leftJoin('gibbonCourseClassPerson', 'gibbonCourseClass.gibbonCourseClassID = gibbonCourseClassPerson.gibbonCourseClassID AND atlEntry.gibbonPersonIDStudent = gibbonCourseClassPerson.gibbonPersonID') + ->leftJoin('gibbonCourse', 'gibbonCourseClass.gibbonCourseID = gibbonCourse.gibbonCourseID') + ->leftJoin('gibbonSchoolYear', 'gibbonCourse.gibbonSchoolYearID = gibbonSchoolYear.gibbonSchoolYearID') + ->where('atlEntry.gibbonPersonIDStudent = :gibbonPersonID') + ->where('completeDate <= :today') + ->where("gibbonCourseClass.reportable = 'Y'") + ->where("gibbonCourseClassPerson.reportable = 'Y'") + ->bindValue('gibbonPersonID', $gibbonPersonID) + ->bindValue('today', date('Y-m-d')); + + $criteria->addFilterRules([ + 'gibbonSchoolYearID' => function($query, $gibbonSchoolYearID) { + return $query->where('gibbonCourse.gibbonSchoolYearID = :gibbonSchoolYearID') + ->bindValue('gibbonSchoolYearID', $gibbonSchoolYearID); + } + ]); + + return $this->runQuery($query, $criteria); + } + + public function createATLEntries($atlColumnID, $gibbonCourseClassID, $gibbonPersonID) { + $data = ['atlColumnID' => $atlColumnID, 'gibbonCourseClassID' => $gibbonCourseClassID, 'gibbonPersonID' => $gibbonPersonID, 'today' => date('Y-m-d')]; + $sql = "INSERT INTO atlEntry (atlColumnID, gibbonPersonIDStudent, complete, gibbonPersonIDLastEdit) + SELECT :atlColumnID as atlColumnID, gibbonPerson.gibbonPersonID, 'N' as complete, :gibbonPersonID as gibbonPersonIDLastEdit + FROM gibbonCourseClassPerson + INNER JOIN gibbonPerson ON (gibbonCourseClassPerson.gibbonPersonID = gibbonPerson.gibbonPersonID) + WHERE gibbonCourseClassPerson.gibbonCourseClassID=:gibbonCourseClassID + AND gibbonPerson.status='Full' + AND (dateStart IS NULL OR dateStart<=:today) + AND (dateEnd IS NULL OR dateEnd>=:today) + AND role = 'Student' + "; + + return $this->db()->insert($sql, $data); + } + +} diff --git a/ATL/version.php b/ATL/version.php index db5a184..051b09b 100644 --- a/ATL/version.php +++ b/ATL/version.php @@ -1,24 +1,24 @@ -. -*/ - -/** - * Sets version information. - */ -$moduleVersion = '1.5.02'; -$coreVersion = '22.0.00'; +. +*/ + +/** + * Sets version information. + */ +$moduleVersion = '1.6.00'; +$coreVersion = '22.0.00';