Initial commit

This commit is contained in:
andres.sanjuan 2025-12-23 09:23:49 -06:00
commit aa68e4b117
29 changed files with 3155 additions and 0 deletions

View File

@ -0,0 +1,229 @@
<?php
// This file is part of My Certificates block for Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Class to get the user certificates
*
* @package block_mycertificates
* @copyright 2020 Willian Mano - http://conecti.me
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
/**
* Class to get the user certificates.
*
* @copyright 2020 Willian Mano - http://conecti.me
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class CertificatesInfo {
/**
* @var \stdClass $user The target user.
*/
protected $user;
/**
* @var int $courseid The course id.
*/
protected $courseid;
/**
* Certificates constructor.
*
* @param \stdClass $user
* @param int $courseid
*/
public function __construct($user, $courseid = null) {
$this->user = $user;
$this->courseid = $courseid;
}
/**
* Returns all issued certificates from all certificates modules.
*
* @return array
*
* @throws \dml_exception
* @throws \moodle_exception
*/
public function get_all_certificates() {
$simplecertificate = $this->get_from_simplecertificate();
$customcert = $this->get_from_customcert();
$allcerts = array_merge($simplecertificate, $customcert);
if (!empty($allcerts)) {
return array_values($this->group_certificates_by_course($allcerts));
}
return [];
}
/**
* Get all issued certificates from simplecertificate module.
*
* @return array
*
* @throws \dml_exception
* @throws \moodle_exception
*/
public function get_from_simplecertificate() {
global $DB;
$simplecertificate = \core_plugin_manager::instance()->get_plugin_info('mod_simplecertificate');
if (is_null($simplecertificate)) {
return [];
}
$sql = "SELECT
sci.code,
sci.pathnamehash,
sc.name,
c.id as courseid,
c.fullname,
c.shortname,
'simplecertificate' as module
FROM {simplecertificate_issues} sci
INNER JOIN {simplecertificate} sc ON sc.id = sci.certificateid
INNER JOIN {course} c ON sc.course = c.id
WHERE sci.timedeleted IS NULL AND sci.userid = :userid";
$params = ['userid' => $this->user->id];
if ($this->courseid) {
$sql .= ' AND c.id = :courseid';
$params['courseid'] = $this->courseid;
}
$sql .= ' ORDER BY c.fullname, sci.timecreated';
$certificates = $DB->get_records_sql($sql, $params);
if (empty($certificates)) {
return [];
}
$fs = get_file_storage();
$returndata = [];
foreach ($certificates as $certificate) {
if (!$fs->file_exists_by_hash($certificate->pathnamehash)) {
continue;
}
$url = new \moodle_url('/mod/simplecertificate/wmsendfile.php', [
'code' => $certificate->code
]);
$certificate->downloadurl = $url->out(false);
$returndata[] = $certificate;
}
return $returndata;
}
/**
* Get issued certificates from customcert module.
*
* @return array
*
* @throws \dml_exception
* @throws \moodle_exception
*/
public function get_from_customcert() {
global $DB;
$customcert = \core_plugin_manager::instance()->get_plugin_info('mod_customcert');
if (is_null($customcert)) {
return [];
}
$sql = "SELECT
ci.customcertid,
cc.name,
c.id as courseid,
c.fullname,
c.shortname,
'customcert' as module
FROM {customcert_issues} ci
INNER JOIN {customcert} cc ON cc.id = ci.customcertid
INNER JOIN {course} c ON c.id = cc.course
WHERE ci.userid = :userid";
$params = ['userid' => $this->user->id];
if ($this->courseid) {
$sql .= ' AND c.id = :courseid';
$params['courseid'] = $this->courseid;
}
$sql .= ' ORDER BY c.fullname, ci.timecreated';
$certificates = $DB->get_records_sql($sql, $params);
if (empty($certificates)) {
return [];
}
foreach ($certificates as $key => $certificate) {
$url = new \moodle_url('/mod/customcert/my_certificates.php', [
'downloadcert' => true,
'userid' => $this->user->id,
'certificateid' => $certificate->customcertid
]);
$certificates[$key]->downloadurl = $url->out(false);
}
return $certificates;
}
/**
* Group certificates by course.
*
* @param array $certificates
*
* @return array
*/
public static function group_certificates_by_course($certificates) {
$returndata = [];
foreach ($certificates as $certificate) {
$certs = [$certificate];
if (isset($returndata[$certificate->courseid])) {
$certs = array_merge($certs, $returndata[$certificate->courseid]['certificates']);
$returndata[$certificate->courseid]['certificates'] = $certs;
continue;
}
$returndata[$certificate->courseid] = [
'courseid' => $certificate->courseid,
'shortname' => $certificate->shortname,
'fullname' => $certificate->fullname,
'certificates' => $certs
];
}
return $returndata;
}
}

View File

@ -0,0 +1,596 @@
GNU GENERAL PUBLIC LICENSE
==========================
Version 3, 29 June 2007
Copyright &copy; 2007 Free Software Foundation, Inc. &lt;<http://fsf.org/>&gt;
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.
&ldquo;This License&rdquo; refers to version 3 of the GNU General Public License.
&ldquo;Copyright&rdquo; also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
&ldquo;The Program&rdquo; refers to any copyrightable work licensed under this
License. Each licensee is addressed as &ldquo;you&rdquo;. &ldquo;Licensees&rdquo; and
&ldquo;recipients&rdquo; may be individuals or organizations.
To &ldquo;modify&rdquo; 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 &ldquo;modified version&rdquo; of the earlier work or a
work &ldquo;based on&rdquo; the earlier work.
A &ldquo;covered work&rdquo; means either the unmodified Program or a work based on
the Program.
To &ldquo;propagate&rdquo; 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 &ldquo;convey&rdquo; 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 &ldquo;Appropriate Legal Notices&rdquo; 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 &ldquo;source code&rdquo; for a work means the preferred form of the work for
making modifications to it. &ldquo;Object code&rdquo; means any non-source form of a
work.
A &ldquo;Standard Interface&rdquo; 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 &ldquo;System Libraries&rdquo; 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 &ldquo;Major Component&rdquo;, 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 &ldquo;Corresponding Source&rdquo; 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 &ldquo;keep intact all notices&rdquo;.
* **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 &ldquo;aggregate&rdquo; 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 &ldquo;User Product&rdquo; is either (1) a &ldquo;consumer product&rdquo;, 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, &ldquo;normally used&rdquo; 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.
&ldquo;Installation Information&rdquo; 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.
&ldquo;Additional permissions&rdquo; 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 &ldquo;further
restrictions&rdquo; 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 &ldquo;entity transaction&rdquo; 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 &ldquo;contributor&rdquo; 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 &ldquo;contributor version&rdquo;.
A contributor's &ldquo;essential patent claims&rdquo; 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, &ldquo;control&rdquo; 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 &ldquo;patent license&rdquo; 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 &ldquo;grant&rdquo; 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. &ldquo;Knowingly relying&rdquo; 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 &ldquo;discriminatory&rdquo; 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 &ldquo;or any later
version&rdquo; 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 &ldquo;AS IS&rdquo; 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 &ldquo;copyright&rdquo; 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 <http://www.gnu.org/licenses/>.
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:
<program> Copyright (C) <year> <name of author>
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 &ldquo;about box&rdquo;.
You should also get your employer (if you work as a programmer) or school, if any, to
sign a &ldquo;copyright disclaimer&rdquo; for the program, if necessary. For more
information on this, and how to apply and follow the GNU GPL, see
&lt;<http://www.gnu.org/licenses/>&gt;.
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
&lt;<http://www.gnu.org/philosophy/why-not-lgpl.html>&gt;.

View File

@ -0,0 +1,123 @@
# User Profile 360 Block #
A comprehensive user profile block for Moodle that displays user statistics, course progress, certifications, and custom profile fields in an elegant card-based interface.
## Features ##
- **User Statistics**: Total enrolled courses, completed courses, courses in progress, and certifications
- **Course Progress**: Interactive modals showing detailed course information
- **Custom Profile Fields**: Configurable display of user custom fields
- **Banner Customization**: Upload custom banner images or use default gradient
- **Responsive Design**: Mobile-friendly interface with Bootstrap 4.6.2 compatibility
- **Dark Mode Support**: Full dark mode compatibility with proper contrast ratios
- **Internationalization**: Complete multilingual support (English and Spanish Mexican included)
- **Performance Optimized**: Caching system and optimized SQL queries
- **FontAwesome Integration**: Free FontAwesome icons with CDN fallback
## Configuration ##
### Global Settings ###
1. Go to **Site administration > Plugins > Blocks > User Profile 360**
2. Configure:
- **Banner Image**: Upload custom banner background image
- **Custom Fields**: Select which user profile fields to display
### Block Settings ###
1. Add the block to any page
2. Configure block title (leave empty to hide header)
3. Position and customize as needed
## Technical Specifications ##
- **Moodle Version**: 4.1+ compatible
- **PHP Version**: 7.4+
- **Database**: MySQL/PostgreSQL compatible
- **Cache**: 5-minute user data caching for performance
- **File Support**: JPG, JPEG, PNG, GIF for banner images
## Installation ##
### Via ZIP Upload ###
1. Log in as admin and go to **Site administration > Plugins > Install plugins**
2. Upload the ZIP file
3. Follow the installation wizard
### Manual Installation ###
1. Extract files to `{moodle}/blocks/profile360/`
2. Go to **Site administration > Notifications**
3. Complete the installation
### CLI Installation ###
```bash
php admin/cli/upgrade.php
```
## Usage ##
1. **Add Block**: Add "User Profile 360" block to dashboard or course pages
2. **Configure Fields**: Select custom fields to display in global settings
3. **Upload Banner**: Customize banner image in plugin settings
4. **Customize Title**: Set block title or leave empty to hide header
## Permissions ##
- `block/profile360:view` - View the block content
- `block/profile360:addinstance` - Add block to pages
- `block/profile360:myaddinstance` - Add block to dashboard
## Troubleshooting ##
### Common Issues ###
- **Images not loading**: Check file permissions and pluginfile.php access
- **Styles not applying**: Clear Moodle cache and update plugin version
- **Performance issues**: Verify cache is enabled and working
### Cache Management ###
The plugin uses application cache for user data. To clear cache:
```bash
php admin/cli/purge_caches.php
```
## Changelog ##
### Version 1.4.1 (2025-01-01) ###
- Fixed Mustache template conversion errors
- Improved performance with caching system
- Added configurable block header
- Enhanced dark mode support
- Complete internationalization
- FontAwesome free icons integration
### Version 1.3.x ###
- Added banner image configuration
- Implemented proper AMD module loading
- Fixed CSS loading issues
- Added Spanish Mexican translation
### Version 1.2.x ###
- Removed inline JavaScript
- Added dark mode support
- Updated to FontAwesome 5.15.4
- Performance optimizations
## Support ##
For support and bug reports, please contact:
- **Email**: salvador.martinez@espacio360.com.mx
- **Organization**: Espacio360
## License ##
Copyright 2023 Espacio360 <salvador.martinez@espacio360.com.mx>
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 <https://www.gnu.org/licenses/>.

View File

@ -0,0 +1,400 @@
<?php
defined('MOODLE_INTERNAL') || die();
require_once('CertificatesInfo.php');
/**
* Clase UserInfo
*
* Esta clase proporciona métodos para obtener información detallada
* sobre el usuario en sesión, incluyendo datos básicos, imagen de perfil
* y detalles relacionados con los cursos en Moodle.
*/
class UserInfo
{
/** @var \stdClass El objeto de usuario global de Moodle. */
protected $user;
/**
* Constructor de la clase UserInfo.
* Inicializa la instancia y obtiene el objeto de usuario global de Moodle.
*/
public function __construct()
{
global $USER;
$this->user = $USER;
profile_load_custom_fields($this->user);
//var_dump($this->user);
}
/**
* Obtiene el nombre de usuario del usuario en sesión.
*
* @return string El nombre de usuario.
*/
public function getUsername()
{
return $this->user->username;
}
/**
* Obtiene el nombre completo del usuario en sesión.
*
* @return string El nombre completo del usuario.
*/
public function getFullName()
{
$firstname = isset($this->user->firstname) ? $this->user->firstname : '';
$lastname = isset($this->user->lastname) ? $this->user->lastname : '';
return trim($firstname . ' ' . $lastname);
}
/**
* Obtiene la dirección de correo electrónico del usuario en sesión.
*
* @return string La dirección de correo electrónico del usuario.
*/
public function getEmail()
{
return $this->user->email;
}
/**
* Obtiene la URL de la imagen de perfil del usuario en sesión.
*
* @return string La URL de la imagen de perfil.
*/
public function getProfileImage()
{
$imageUrl = $this->getprofilepictureurl();
return $imageUrl;
}
/**
* Obtiene el total de cursos en los que está inscrito el usuario en sesión.
*
* @return int El número total de cursos inscritos.
*/
public function getTotalEnrolledCourses()
{
global $USER, $DB;
if (!empty($USER->id)) {
$totalEnrolledCourses = $DB->count_records('user_enrolments', array('userid' => $USER->id));
return $totalEnrolledCourses;
}
return 0;
}
/**
* Obtiene la lista de cursos completados por el usuario en sesión o que su avance sea del 100%
*
* @return array La lista de cursos completados.
*/
public function getCompletedCourses()
{
global $USER, $CFG, $DB;
require_once("$CFG->libdir/completionlib.php");
if (empty($USER->id)) {
return [];
}
$completedCourses = [];
$courses = enrol_get_all_users_courses($USER->id);
foreach ($courses as $course) {
$isCompleted = false;
// Método 1: Verificar completion oficial de Moodle
if (isset($course->enablecompletion) && $course->enablecompletion) {
$completionInfo = new \completion_info($course);
if ($completionInfo->is_enabled() && $completionInfo->is_course_complete($USER->id)) {
$isCompleted = true;
}
}
// Método 2: Verificar progreso del 100%
if (!$isCompleted) {
$courseProgressPercentage = \core_completion\progress::get_course_progress_percentage($course, $USER->id);
if ($courseProgressPercentage !== null && $courseProgressPercentage >= 100) {
$isCompleted = true;
}
}
// Método 3: Verificar completions en la base de datos
if (!$isCompleted) {
$sql = "SELECT COUNT(*)
FROM {course_completions} cc
WHERE cc.userid = :userid
AND cc.course = :courseid
AND cc.timecompleted IS NOT NULL";
$completionCount = $DB->count_records_sql($sql, [
'userid' => $USER->id,
'courseid' => $course->id
]);
if ($completionCount > 0) {
$isCompleted = true;
}
}
if ($isCompleted) {
$completedCourses[] = $course;
}
}
return $completedCourses;
}
/**
* Obtiene la lista de cursos en progreso del usuario en sesión.
*
* @return array La lista de cursos en progreso.
*/
public function getInProgressCourses()
{
global $USER;
if (!empty($USER->id)) {
$inProgressCourses = [];
// Obtener todos los cursos
$courses = enrol_get_all_users_courses($USER->id);
foreach ($courses as $course) {
$courseProgressPercentage = \core_completion\progress::get_course_progress_percentage($course, $USER->id);
if ($courseProgressPercentage > 0 && $courseProgressPercentage < 100) {
$inProgressCourses[] = $course;
}
}
return $inProgressCourses;
}
return [];
}
/**
* Obtiene la lista de cursos en los que el usuario en sesión ha obtenido un certificado.
*
* @return array La lista de cursos con certificado.
*/
public function getCertifiedCourses()
{
$certificatesInfo = new CertificatesInfo($this->user);
$certifiedCourses = $certificatesInfo->get_all_certificates();
return $certifiedCourses;
}
/**
* Obtiene el número de cursos en los que el usuario en sesión ha obtenido un certificado.
*
* @return int El número de cursos con certificado.
*/
public function getCertifiedCoursesCount()
{
$certificatesInfo = new CertificatesInfo($this->user);
$certifiedCourses = $certificatesInfo->get_all_certificates();
return count($certifiedCourses);
}
/**
* Retrieves the URL for the user's profile picture, if one is available.
*
*
* @return string URL to the photo image file but with $1 for the size.
*/
private function getprofilepictureurl()
{
if (isloggedin() && !isguestuser() && $this->user->picture > 0) {
$usercontext = context_user::instance($this->user->id, IGNORE_MISSING);
$url = moodle_url::make_pluginfile_url($usercontext->id, 'user', 'icon', null, '/', "f$1")
. '?rev=' . $this->user->picture;
} else {
// If the user does not have a profile picture, use the default faceless picture.
global $PAGE, $CFG;
$renderer = $PAGE->get_renderer('core');
if ($CFG->branch >= 33) {
$url = $renderer->image_url('u/f$1');
} else {
$url = $renderer->pix_url('u/f$1'); // Deprecated as of Moodle 3.3.
}
}
return str_replace('/f%24', '/f$', $url);
}
/**
* Obtiene la URL para editar el perfil del usuario en sesión.
*
* @return string La URL para editar el perfil.
*/
public function getEditProfileUrl()
{
global $CFG;
// Verificar si el usuario está autenticado y no es un usuario invitado
if (isloggedin() && !isguestuser()) {
// Crear el contexto del usuario
$userContext = context_user::instance($this->user->id, IGNORE_MISSING);
// Construir la URL para editar el perfil
$editProfileUrl = new moodle_url($CFG->wwwroot . '/user/edit.php');
$editProfileUrl->param('id', $this->user->id);
$editProfileUrl->param('course', SITEID);
$editProfileUrl->param('userprofile', $userContext->id);
return $editProfileUrl->out();
}
// Devolver una URL predeterminada o un mensaje de error si el usuario no está autenticado
return (new moodle_url($CFG->wwwroot . '/user/edit.php'))->out();
}
public function getCompletedCoursesAsString()
{
$completedCourses = $this->getCompletedCourses();
$count = count($completedCourses);
return $count > 0 ? (string)$count : "0";
}
public function getInProgressCoursesAsString()
{
$inProgressCourses = $this->getInProgressCourses();
return !empty($inProgressCourses) ? sizeof($inProgressCourses) : "0";
}
/**
* Obtiene la lista de cursos vencidos del usuario en sesión.
*
* @return array La lista de cursos vencidos.
*/
public function getExpiredCourses()
{
global $USER, $DB;
if (!empty($USER->id)) {
$expiredCourses = [];
$currentDate = new DateTime();
// Obtener todos los cursos
$courses = enrol_get_all_users_courses($USER->id);
foreach ($courses as $course) {
$courseEndDate = $this->getEndDateByCourseId($course->id);
if ($courseEndDate !== null) {
$endDate = new DateTime(date('Y-m-d', strtotime($courseEndDate)));
if ($currentDate > $endDate) {
// El curso ha vencido
$expiredCourses[] = $course;
}
}
}
return $expiredCourses;
}
return [];
}
/**
* Obtiene la lista de cursos por vencer del usuario en sesión.
*
* @param int $daysThreshold Umbral de días para considerar cursos por vencer.
* @return array La lista de cursos por vencer.
*/
public function getEndingSoonCourses($daysThreshold = 5)
{
global $USER;
if (!empty($USER->id)) {
$endingSoonCourses = [];
$currentDate = new DateTime();
// Obtener todos los cursos
$courses = enrol_get_all_users_courses($USER->id);
foreach ($courses as $course) {
$courseEndDate = $this->getEndDateByCourseId($course->id);
if ($courseEndDate !== null) {
$endDate = new DateTime($courseEndDate);
$difference = $currentDate->diff($endDate);
// Verificar si el curso vence pronto
if ($difference->days <= $daysThreshold) {
$endingSoonCourses[] = $course;
}
}
}
return $endingSoonCourses;
}
return [];
}
/**
* Obtiene la fecha de vencimiento por ID de curso.
*
* @param int $courseId ID del curso.
* @return string|null La fecha de vencimiento en formato dd-mm-Y o null si no está definida.
*/
public function getEndDateByCourseId($courseId)
{
global $USER, $DB;
// Obtén el ID del usuario actual
$userId = $USER->id;
// Consulta para obtener la fecha de vencimiento personalizada del usuario para el curso
$sql = "SELECT ue.timeend
FROM {user_enrolments} ue
WHERE ue.userid = :userid
AND ue.enrolid IN (SELECT id FROM {enrol} WHERE courseid = :courseid)
ORDER BY ue.timeend DESC
LIMIT 1";
$params = [
'userid' => $userId,
'courseid' => $courseId,
];
$userCourseEndDate = $DB->get_field_sql($sql, $params);
if ($userCourseEndDate !== null && $userCourseEndDate !== 0) {
// Convierte el timestamp a una cadena de fecha en formato dd-mm-Y
return date('d-m-Y', $userCourseEndDate);
}
return null;
// Convierte el timestamp a una cadena de fecha en formato dd-mm-Y
}
/**
* Obtiene todos los campos personalizados del usuario en sesión.
*
* @return array El array asociativo de campos personalizados.
*/
public function getCustomFields()
{
// Obtén la sección de campos personalizados
$customFields = $this->user->profile;
return $customFields;
}
}

View File

@ -0,0 +1,3 @@
define("block_profile360/profile360",["jquery","core/ajax"],(function($,Ajax){var Profile360={init:function(){this.initModals(),this.initEndingSoonModal()},initModals:function(){this.bindModalEvents()},bindModalEvents:function(){$(".completedCourses").on("click",(function(e){e.preventDefault(),Profile360.loadCoursesData("completed","#modalCompletedCourses")})),$(".inProgressCourses").on("click",(function(e){e.preventDefault(),Profile360.loadCoursesData("inprogress","#modalInProgressCourses")})),$(".certificatedCourses").on("click",(function(e){e.preventDefault(),Profile360.loadCoursesData("certified","#modalCertifiedCourses")}))},loadCoursesData:function(type,modalSelector){var modalBody=$(modalSelector).find("ol");modalBody.html("<li>Cargando...</li>"),Ajax.call([{methodname:"block_profile360_get_courses_data",args:{type:type}}])[0].done((function(data){modalBody.empty(),0!==data.length?data.forEach((function(course){var link;link="certified"===type&&course.certificates&&course.certificates[0]?'<a href="'+course.certificates[0].downloadurl+'" target="_blank">'+course.fullname+"</a>":'<a href="/course/view.php?id='+course.id+'">'+course.fullname+"</a>",modalBody.append("<li>"+link+"</li>")})):modalBody.append("<li>No hay cursos disponibles</li>")})).fail((function(){modalBody.html("<li>Error al cargar los datos</li>")}))},initEndingSoonModal:function(){var modal=$("#ModalEndingSoonCourses");!0!==modal.data("showmodal")&&"1"!==modal.data("showmodal")||(this.loadEndingSoonCourses(),modal.addClass("show").css("display","block")),modal.on("click",".btnclose, .modal",(function(e){(e.target===this||$(e.target).hasClass("btnclose"))&&modal.removeClass("show").css("display","none")}))},loadEndingSoonCourses:function(){var modalBody=$("#ModalEndingSoonCourses .modal-body ol");Ajax.call([{methodname:"block_profile360_get_courses_data",args:{type:"ending"}}])[0].done((function(data){modalBody.empty(),data.forEach((function(course){var courseUrl="/course/view.php?id="+course.id;modalBody.append('<li><a href="'+courseUrl+'">'+course.fullname+"</a></li>")}))})).fail((function(){modalBody.html("<li>Error al cargar los cursos</li>")}))}};return{init:function(){$(document).ready((function(){Profile360.init()}))}}}));
//# sourceMappingURL=profile360.min.js.map

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,103 @@
define(['jquery', 'core/ajax'], function($, Ajax) {
'use strict';
var Profile360 = {
init: function() {
this.initModals();
this.initEndingSoonModal();
},
initModals: function() {
this.bindModalEvents();
},
bindModalEvents: function() {
$('.completedCourses').on('click', function(e) {
e.preventDefault();
Profile360.loadCoursesData('completed', '#modalCompletedCourses');
});
$('.inProgressCourses').on('click', function(e) {
e.preventDefault();
Profile360.loadCoursesData('inprogress', '#modalInProgressCourses');
});
$('.certificatedCourses').on('click', function(e) {
e.preventDefault();
Profile360.loadCoursesData('certified', '#modalCertifiedCourses');
});
},
loadCoursesData: function(type, modalSelector) {
var modal = $(modalSelector);
var modalBody = modal.find('ol');
modalBody.html('<li>Cargando...</li>');
Ajax.call([{
methodname: 'block_profile360_get_courses_data',
args: { type: type }
}])[0].done(function(data) {
modalBody.empty();
if (data.length === 0) {
modalBody.append('<li>No hay cursos disponibles</li>');
return;
}
data.forEach(function(course) {
var link;
if (type === 'certified' && course.certificates && course.certificates[0]) {
link = '<a href="' + course.certificates[0].downloadurl + '" target="_blank">' + course.fullname + '</a>';
} else {
link = '<a href="/course/view.php?id=' + course.id + '">' + course.fullname + '</a>';
}
modalBody.append('<li>' + link + '</li>');
});
}).fail(function() {
modalBody.html('<li>Error al cargar los datos</li>');
});
},
initEndingSoonModal: function() {
var modal = $('#ModalEndingSoonCourses');
if (modal.data('showmodal') === true || modal.data('showmodal') === '1') {
this.loadEndingSoonCourses();
modal.addClass('show').css('display', 'block');
}
modal.on('click', '.btnclose, .modal', function(e) {
if (e.target === this || $(e.target).hasClass('btnclose')) {
modal.removeClass('show').css('display', 'none');
}
});
},
loadEndingSoonCourses: function() {
var modalBody = $('#ModalEndingSoonCourses .modal-body ol');
Ajax.call([{
methodname: 'block_profile360_get_courses_data',
args: { type: 'ending' }
}])[0].done(function(data) {
modalBody.empty();
data.forEach(function(course) {
var courseUrl = '/course/view.php?id=' + course.id;
modalBody.append('<li><a href="' + courseUrl + '">' + course.fullname + '</a></li>');
});
}).fail(function() {
modalBody.html('<li>Error al cargar los cursos</li>');
});
},
};
return {
init: function() {
$(document).ready(function() {
Profile360.init();
});
}
};
});

View File

@ -0,0 +1,299 @@
<?php
// This file is part of Moodle - https://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <https://www.gnu.org/licenses/>.
require_once ('UserInfo.php');
/**
* Block profile360 is defined here.
*
* @package block_profile360
* @copyright 2023 Espacio360 <salvador.martinez@espacio360.com.mx>
* @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class block_profile360 extends block_base
{
/**
* Initializes class member variables.
*/
public function init()
{
// Needed by Moodle to differentiate between blocks.
$this->title = get_string('pluginname', 'block_profile360');
}
/**
* {@inheritdoc}
*/
public function instance_allow_multiple()
{
return false;
}
/**
* {@inheritdoc}
*/
public function instance_allow_config()
{
return true;
}
/**
* Returns the block contents.
*
* @return stdClass The block contents.
*/
public function get_content()
{
global $USER, $CFG, $OUTPUT, $PAGE;
if ($this->content !== null) {
return $this->content;
}
if (empty($this->instance)) {
$this->content = '';
return $this->content;
}
$this->content = new stdClass();
$this->content->items = array();
$this->content->icons = array();
$this->content->footer = '';
// Get banner image hash for cache invalidation
$systemcontext = context_system::instance();
$fs = get_file_storage();
$files = $fs->get_area_files($systemcontext->id, 'block_profile360', 'bannerimage', 0, 'filename', false);
$bannerhash = '';
if (!empty($files)) {
$file = reset($files);
$bannerhash = md5($file->get_contenthash() . $file->get_timemodified());
}
// Cache key for user data with profile and banner image hashes
$profileimagehash = md5($USER->picture . $USER->timemodified);
$cachekey = 'block_profile360_user_' . $USER->id . '_' . $profileimagehash . '_' . $bannerhash;
$cache = cache::make('block_profile360', 'userdata');
$cacheddata = $cache->get($cachekey);
if ($cacheddata !== false) {
$this->content->text = $OUTPUT->render_from_template('block_profile360/profile360', $cacheddata);
return $this->content;
}
// Crear una instancia de la clase UserInfo del espacio de nombres block_profile360
$userInfo = new UserInfo();
// Obtener información del usuario
$username = $userInfo->getUsername();
$fullname = $userInfo->getFullName();
$email = $userInfo->getEmail();
$profileImage = $userInfo->getProfileImage();
$totalEnrolledCourses = $userInfo->getTotalEnrolledCourses();
$completedCoursesString = $userInfo->getCompletedCoursesAsString();
$inProgressCoursesString = $userInfo->getInProgressCoursesAsString();
$editProfileUrl = $userInfo->getEditProfileUrl();
$certifiedCoursesCount = $userInfo->getCertifiedCoursesCount();
$endingSoonCourses = $userInfo->getEndingSoonCourses(20);
// Obtén los datos personalizados
$customFields = $userInfo->getCustomFields();
//Obtener la configuracion del bloque
$blockConfig = get_config('block_profile360');
if ($blockConfig) {
// Crear un array con los nombres de los campos personalizados configurados en el bloque
$configuredFields = [];
foreach ($blockConfig as $name => $value) {
if (strpos($name, 'customfield_') === 0 && $value) {
$fieldId = substr($name, strlen('customfield_'));
$configuredFields[$fieldId] = true;
}
}
global $DB;
// Consulta para obtener campos personalizados visibles
$sql = "SELECT shortname, name FROM {user_info_field} WHERE visible > :visible ORDER BY sortorder ASC";
// Ejecutar la consulta
$namesCustomFields = $DB->get_records_sql_menu($sql, ['visible' => 0]);
// Filtrar los campos personalizados para mostrar solo los configurados en el bloque
$customFieldsToShow = [];
foreach ($customFields as $fieldName => $fieldValue) {
if (isset($configuredFields[$fieldName])) {
$fieldLabel = $namesCustomFields[$fieldName];
//$fieldLabel = 'Campo';
switch ($fieldName) {
case 'linkdc3':
$link = "Sin certificación";
// Validar que el campo esté definido y no esté vacío
if (isset($fieldValue) && !empty(trim($fieldValue))) {
$link = "<a href=\"$fieldValue\" target=\"_blank\" download>Descargar</a>";
}
$customFieldsToShow[] = array('key' => $fieldLabel, 'value' => $link);
break;
case 'ingreso':
$ingreso = '';
if (isset($customFields[$fieldName]) && $customFields[$fieldName] !== null) {
// Verificar si la fecha está definida y no es 0
if ($customFields[$fieldName] != 0) {
$ingreso = userdate($customFields[$fieldName], '%d/%m/%Y');
}
}
$customFieldsToShow[] = array('key' => $fieldLabel, 'value' => $ingreso);
break;
default:
$customFieldsToShow[] = array('key' => $fieldLabel, 'value' => $fieldValue ?? '');
break;
}
}
}
}
// Get banner image URL (reuse files from cache check)
$bannerImageUrl = '';
if (!empty($files)) {
$file = reset($files);
$bannerImageUrl = moodle_url::make_pluginfile_url(
$systemcontext->id,
'block_profile360',
'bannerimage',
0,
$file->get_filepath(),
$file->get_filename()
)->out();
}
// Configurar el objeto de datos para la plantilla
$data = new stdClass();
$data->username = $username;
$data->fullname = $fullname;
$data->email = $email;
$data->profileImage = $profileImage;
$data->totalEnrolledCourses = $totalEnrolledCourses;
$data->completedCoursesString = $completedCoursesString;
$data->inProgressCoursesString = $inProgressCoursesString;
$data->editProfileUrl = $editProfileUrl;
$data->certifiedCoursesCount = $certifiedCoursesCount;
// Get courses data once and reuse
$completedCourses = $userInfo->getCompletedCourses();
$inProgressCourses = $userInfo->getInProgressCourses();
$certifiedCourses = $userInfo->getCertifiedCourses();
// Los datos ahora se cargan via AJAX, no necesitamos JSON embebido
$data->customFieldsToShow = $customFieldsToShow;
$data->bannerImageUrl = $bannerImageUrl;
// Verifica si hay cursos por expirar
global $SESSION;
// Verifica si hay cursos por expirar
if (sizeof($endingSoonCourses) > 0) {
// Verifica si el modal ya se ha mostrado en esta sesión
$modalShown = isset($SESSION->modalShown) ? $SESSION->modalShown : false;
// Si el modal no se ha mostrado y hay cursos por expirar, marca la sesión y agrega el dato al objeto $data
if (!$modalShown) {
$SESSION->modalShown = true;
$data->showModal = true;
// Asegúrate de que jQuery esté cargado antes de agregar scripts que dependan de él
//$PAGE->requires->jquery();
//$PAGE->requires->js_call_amd('profile360/profile360', 'initialize_modal', [json_encode($endingSoonCourses, JSON_UNESCAPED_UNICODE)]);
} else {
$data->showModal = false;
$SESSION->modalShown = false;
}
} else {
$SESSION->modalShown = false;
$data->showModal = false;
}
// Load FontAwesome fallback if not available
$PAGE->requires->css(new moodle_url('https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css'));
// Cache the data for 5 minutes
$cache->set($cachekey, $data, 300);
// Agregar la información al contenido del bloque
$this->content->text = $OUTPUT->render_from_template('block_profile360/profile360', $data);
return $this->content;
}
/**
* Load required JS and CSS.
*/
public function get_required_javascript()
{
parent::get_required_javascript();
// Only load JS if block has content
if ($this->content && !empty($this->content->text)) {
$this->page->requires->js_call_amd('block_profile360/profile360', 'init');
}
}
/**
* Hide header if title is empty.
*/
public function hide_header()
{
return empty($this->config->title);
}
/**
* Defines configuration data.
*
* The function is called immediately after init().
*/
public function specialization()
{
// Load user defined title and make sure it's never empty.
if (empty($this->config->title)) {
$this->title = get_string('pluginname', 'block_profile360');
} else {
$this->title = format_string($this->config->title, true, ['context' => $this->context]);
}
}
/**
* Enables global configuration of the block in settings.php.
*
* @return bool True if the global configuration is enabled.
*/
function has_config()
{
return true;
}
/**
* Sets the applicable formats for the block.
*
* @return string[] Array of pages and permissions.
*/
public function applicable_formats()
{
//return array('my' => true, 'site' => true);
return array(
'admin' => false,
'site-index' => true,
'site' => true,
'course-view' => true,
'mod' => false,
'my' => true,
);
}
public function html_attributes()
{
// Get default values.
$attributes = parent::html_attributes();
// Append our class to class attribute.
$attributes['class'] .= ' block_' . $this->name();
return $attributes;
}
}

View File

@ -0,0 +1,95 @@
<?php
defined('MOODLE_INTERNAL') || die();
require_once($CFG->libdir . '/externallib.php');
require_once($CFG->dirroot . '/blocks/profile360/UserInfo.php');
class block_profile360_external_get_courses_data extends external_api {
public static function get_courses_data_parameters() {
return new external_function_parameters([
'type' => new external_value(PARAM_ALPHA, 'Type of courses data to retrieve')
]);
}
public static function get_courses_data($type) {
global $USER;
try {
$params = self::validate_parameters(self::get_courses_data_parameters(), ['type' => $type]);
require_login();
$userInfo = new UserInfo();
switch ($params['type']) {
case 'completed':
$courses = $userInfo->getCompletedCourses();
return self::format_courses_data($courses);
case 'inprogress':
$courses = $userInfo->getInProgressCourses();
return self::format_courses_data($courses);
case 'certified':
$certifiedCourses = $userInfo->getCertifiedCourses();
return self::format_certified_courses_data($certifiedCourses);
case 'ending':
$courses = $userInfo->getEndingSoonCourses(20);
return self::format_courses_data($courses);
default:
throw new invalid_parameter_exception('Invalid course type');
}
} catch (Exception $e) {
error_log('Error in get_courses_data: ' . $e->getMessage());
return [];
}
}
private static function format_courses_data($courses) {
$result = [];
foreach ($courses as $course) {
$courseurl = new moodle_url('/course/view.php', ['id' => $course->id]);
$result[] = [
'id' => (int)$course->id,
'fullname' => $course->fullname,
'courseurl' => $courseurl->out(false)
];
}
return $result;
}
private static function format_certified_courses_data($certifiedCourses) {
$result = [];
foreach ($certifiedCourses as $courseData) {
$certificates = [];
if (isset($courseData['certificates'])) {
foreach ($courseData['certificates'] as $cert) {
$certificates[] = [
'downloadurl' => $cert->downloadurl
];
}
}
$result[] = [
'id' => $courseData['courseid'],
'fullname' => $courseData['fullname'],
'certificates' => $certificates
];
}
return $result;
}
public static function get_courses_data_returns() {
return new external_multiple_structure(
new external_single_structure([
'id' => new external_value(PARAM_INT, 'Course ID'),
'fullname' => new external_value(PARAM_TEXT, 'Course full name'),
'courseurl' => new external_value(PARAM_URL, 'Course URL', VALUE_OPTIONAL),
'certificates' => new external_multiple_structure(
new external_single_structure([
'downloadurl' => new external_value(PARAM_URL, 'Certificate download URL')
]), 'Certificates', VALUE_OPTIONAL
)
])
);
}
}

View File

@ -0,0 +1,66 @@
<?php
// This file is part of Moodle - https://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <https://www.gnu.org/licenses/>.
/**
* Event observer for block_profile360.
*
* @package block_profile360
* @copyright 2023 Espacio360 <salvador.martinez@espacio360.com.mx>
* @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace block_profile360;
defined('MOODLE_INTERNAL') || die();
/**
* Event observer class.
*/
class observer {
/**
* Clear user cache when user is updated.
*
* @param \core\event\user_updated $event
*/
public static function user_updated(\core\event\user_updated $event) {
$cache = \cache::make('block_profile360', 'userdata');
$cachekey = 'block_profile360_user_' . $event->relateduserid;
$cache->delete($cachekey);
}
/**
* Clear user cache when user enrolment changes.
*
* @param \core\event\base $event
*/
public static function user_enrolment_changed(\core\event\base $event) {
$cache = \cache::make('block_profile360', 'userdata');
$cachekey = 'block_profile360_user_' . $event->relateduserid;
$cache->delete($cachekey);
}
/**
* Clear user cache when course is completed.
*
* @param \core\event\course_completed $event
*/
public static function course_completed(\core\event\course_completed $event) {
$cache = \cache::make('block_profile360', 'userdata');
$cachekey = 'block_profile360_user_' . $event->relateduserid;
$cache->delete($cachekey);
}
}

View File

@ -0,0 +1,44 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Privacy Subsystem implementation for block_profile360
*
* @package block_profile360
* @copyright 2018 Zig Tan <zig@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace block_profile360\privacy;
/**
* Privacy Subsystem for block_profile360 implementing null_provider.
*
* @copyright 2018 Zig Tan <zig@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class provider implements \core_privacy\local\metadata\null_provider {
/**
* Get the language string identifier with the component's language
* file to explain why this plugin stores no data.
*
* @return string
*/
public static function get_reason() : string {
return 'privacy:metadata';
}
}

View File

@ -0,0 +1,48 @@
<?php
// This file is part of Moodle - https://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <https://www.gnu.org/licenses/>.
/**
* Plugin capabilities are defined here.
*
* @package block_profile360
* @category access
* @copyright 2023 Espacio360 <salvador.martinez@espacio360.com.mx>
* @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
$capabilities = [
'block/profile360:myaddinstance' => [
'captype' => 'write',
'contextlevel' => CONTEXT_SYSTEM,
'archetypes' => [
'user' => CAP_ALLOW,
],
'clonepermissionsfrom' => 'moodle/my:manageblocks',
],
'block/profile360:addinstance' => [
'riskbitmask' => RISK_SPAM | RISK_XSS,
'captype' => 'write',
'contextlevel' => CONTEXT_BLOCK,
'archetypes' => [
'manager' => CAP_ALLOW,
],
'clonepermissionsfrom' => 'moodle/site:manageblocks',
],
];

View File

@ -0,0 +1,34 @@
<?php
// This file is part of Moodle - https://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <https://www.gnu.org/licenses/>.
/**
* Cache definitions for block_profile360.
*
* @package block_profile360
* @copyright 2023 Espacio360 <salvador.martinez@espacio360.com.mx>
* @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
$definitions = array(
'userdata' => array(
'mode' => cache_store::MODE_APPLICATION,
'simplekeys' => true,
'simpledata' => false,
'ttl' => 300, // 5 minutes
),
);

View File

@ -0,0 +1,44 @@
<?php
// This file is part of Moodle - https://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <https://www.gnu.org/licenses/>.
/**
* Event observers for block_profile360.
*
* @package block_profile360
* @copyright 2023 Espacio360 <salvador.martinez@espacio360.com.mx>
* @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
$observers = array(
array(
'eventname' => '\core\event\user_updated',
'callback' => '\block_profile360\observer::user_updated',
),
array(
'eventname' => '\core\event\user_enrolment_created',
'callback' => '\block_profile360\observer::user_enrolment_changed',
),
array(
'eventname' => '\core\event\user_enrolment_deleted',
'callback' => '\block_profile360\observer::user_enrolment_changed',
),
array(
'eventname' => '\core\event\course_completed',
'callback' => '\block_profile360\observer::course_completed',
),
);

View File

@ -0,0 +1,14 @@
<?php
defined('MOODLE_INTERNAL') || die();
$functions = [
'block_profile360_get_courses_data' => [
'classname' => 'block_profile360_external_get_courses_data',
'methodname' => 'get_courses_data',
'classpath' => 'blocks/profile360/classes/external/get_courses_data.php',
'description' => 'Get courses data for profile360 block',
'type' => 'read',
'ajax' => true,
'loginrequired' => true,
],
];

View File

@ -0,0 +1,46 @@
<?php
// This file is part of Moodle - https://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <https://www.gnu.org/licenses/>.
/**
* Plugin strings are defined here.
*
* @package block_profile360
* @category string
* @copyright 2023 Espacio360 <salvador.martinez@espacio360.com.mx>
* @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
$string['pluginname'] = 'User Profile 360';
$string['customfields'] = 'Custom fields';
$string['customfields_desc'] = 'Visible custom fields that can be shown in the profile';
$string['show'] = 'show in profile';
$string['totalcourses'] = 'Total courses';
$string['completedcourses'] = 'Completed courses';
$string['inprogresscourses'] = 'Courses in progress';
$string['certifications'] = 'Certifications';
$string['certifiedcourses'] = 'Certified courses';
$string['coursesexpiring'] = 'Courses expiring';
$string['coursesexpiringmessage'] = 'Don\'t wait until the last minute! The following courses are about to expire.';
$string['nocompletedcourses'] = 'No completed courses.';
$string['noinprogresscourses'] = 'No courses in progress.';
$string['nocertifiedcourses'] = 'No certified courses.';
$string['close'] = 'Close';
$string['bannerimage'] = 'Banner background image';
$string['bannerimage_desc'] = 'Upload an image to use as the banner background. If no image is uploaded, a default gradient will be used.';

View File

@ -0,0 +1,44 @@
<?php
// This file is part of Moodle - https://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <https://www.gnu.org/licenses/>.
/**
* Plugin strings are defined here.
*
* @package block_profile360
* @category string
* @copyright 2023 Espacio360 <salvador.martinez@espacio360.com.mx>
* @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
$string['pluginname'] = 'Perfil de usuario 360';
$string['customfields'] = 'Campos personalizados';
$string['customfields_desc'] = 'Campos personalizados visibles que se pueden mostrar en el perfil';
$string['show'] = 'mostrar en el perfil';
$string['totalcourses'] = 'Total de cursos';
$string['completedcourses'] = 'Cursos completados';
$string['inprogresscourses'] = 'Cursos en progreso';
$string['certifications'] = 'Certificaciones';
$string['certifiedcourses'] = 'Cursos certificados';
$string['coursesexpiring'] = 'Cursos por expirar';
$string['coursesexpiringmessage'] = '¡No esperes hasta el último minuto! Los siguientes cursos están a punto de expirar.';
$string['nocompletedcourses'] = 'No hay cursos completados.';
$string['noinprogresscourses'] = 'No hay cursos en progreso.';
$string['nocertifiedcourses'] = 'No hay cursos certificados.';
$string['close'] = 'Cerrar';
$string['bannerimage'] = 'Imagen de fondo del banner';
$string['bannerimage_desc'] = 'Sube una imagen para usar como fondo del banner. Si no se sube ninguna imagen, se usará un degradado por defecto.';

View File

@ -0,0 +1,44 @@
<?php
// This file is part of Moodle - https://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <https://www.gnu.org/licenses/>.
/**
* Plugin strings are defined here.
*
* @package block_profile360
* @category string
* @copyright 2023 Espacio360 <salvador.martinez@espacio360.com.mx>
* @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
$string['pluginname'] = 'Profile ng User 360';
$string['customfields'] = 'Mga customized na field';
$string['customfields_desc'] = 'Mga nakikitang customized na field na maaaring ipakita sa profile';
$string['show'] = 'ipakita sa profile';
$string['totalcourses'] = 'Kabuuang mga kurso';
$string['completedcourses'] = 'Mga natapos na kurso';
$string['inprogresscourses'] = 'Mga kasalukuyang kurso';
$string['certifications'] = 'Mga sertipikasyon';
$string['certifiedcourses'] = 'Mga sertipikadong kurso';
$string['coursesexpiring'] = 'Mga kurso na malapit matapos';
$string['coursesexpiringmessage'] = 'Huwag mag-antay hanggang sa huling minuto! Ang mga sumusunod na kurso ay malapit nang matapos.';
$string['nocompletedcourses'] = 'Walang natapos na kurso.';
$string['noinprogresscourses'] = 'Walang kasalukuyang kurso.';
$string['nocertifiedcourses'] = 'Walang sertipikadong kurso.';
$string['close'] = 'Isara';
$string['bannerimage'] = 'Background image ng banner';
$string['bannerimage_desc'] = 'Mag-upload ng isang larawan na gagamitin bilang background ng banner. Kung walang na-upload na larawan, default gradient ang gagamitin.';

View File

@ -0,0 +1,44 @@
<?php
// This file is part of Moodle - https://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <https://www.gnu.org/licenses/>.
/**
* Plugin strings are defined here.
*
* @package block_profile360
* @category string
* @copyright 2023 Espacio360 <salvador.martinez@espacio360.com.mx>
* @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
$string['pluginname'] = 'Profil Pengguna 360';
$string['customfields'] = 'Bidang kustom';
$string['customfields_desc'] = 'Bidang kustom yang terlihat yang dapat ditampilkan dalam profil';
$string['show'] = 'tampilkan di profil';
$string['totalcourses'] = 'Total kursus';
$string['completedcourses'] = 'Kursus selesai';
$string['inprogresscourses'] = 'Kursus sedang berlangsung';
$string['certifications'] = 'Sertifikasi';
$string['certifiedcourses'] = 'Kursus bersertifikat';
$string['coursesexpiring'] = 'Kursus akan berakhir';
$string['coursesexpiringmessage'] = 'Jangan menunggu hingga menit terakhir! Kursus berikut akan segera berakhir.';
$string['nocompletedcourses'] = 'Tidak ada kursus yang selesai.';
$string['noinprogresscourses'] = 'Tidak ada kursus sedang berlangsung.';
$string['nocertifiedcourses'] = 'Tidak ada kursus bersertifikat.';
$string['close'] = 'Tutup';
$string['bannerimage'] = 'Gambar latar banner';
$string['bannerimage_desc'] = 'Unggah gambar untuk digunakan sebagai latar banner. Jika tidak ada gambar yang diunggah, gradien default akan digunakan.';

View File

@ -0,0 +1,44 @@
<?php
// This file is part of Moodle - https://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <https://www.gnu.org/licenses/>.
/**
* Plugin strings are defined here.
*
* @package block_profile360
* @category string
* @copyright 2023 Espacio360 <salvador.martinez@espacio360.com.mx>
* @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
$string['pluginname'] = 'Hồ sơ người dùng 360';
$string['customfields'] = 'Trường tùy chỉnh';
$string['customfields_desc'] = 'Các trường tùy chỉnh hiển thị có thể được hiển thị trong hồ sơ';
$string['show'] = 'hiển thị trong hồ sơ';
$string['totalcourses'] = 'Tổng số khóa học';
$string['completedcourses'] = 'Khóa học đã hoàn thành';
$string['inprogresscourses'] = 'Khóa học đang thực hiện';
$string['certifications'] = 'Chứng nhận';
$string['certifiedcourses'] = 'Khóa học đã chứng nhận';
$string['coursesexpiring'] = 'Khóa học sắp hết hạn';
$string['coursesexpiringmessage'] = 'Đừng chờ đến phút cuối! Các khóa học sau sắp hết hạn.';
$string['nocompletedcourses'] = 'Không có khóa học đã hoàn thành.';
$string['noinprogresscourses'] = 'Không có khóa học đang thực hiện.';
$string['nocertifiedcourses'] = 'Không có khóa học đã chứng nhận.';
$string['close'] = 'Đóng';
$string['bannerimage'] = 'Hình ảnh nền banner';
$string['bannerimage_desc'] = 'Tải lên một hình ảnh để sử dụng làm nền banner. Nếu không tải lên hình ảnh nào, sẽ sử dụng gradient mặc định.';

View File

@ -0,0 +1,69 @@
<?php
// This file is part of Moodle - https://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <https://www.gnu.org/licenses/>.
/**
* Plugin lib functions.
*
* @package block_profile360
* @copyright 2023 Espacio360 <salvador.martinez@espacio360.com.mx>
* @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
/**
* Serves the files from the block_profile360 file areas.
*
* @param stdClass $course the course object
* @param stdClass $cm the course module object
* @param stdClass $context the context
* @param string $filearea the name of the file area
* @param array $args extra arguments (itemid, path)
* @param bool $forcedownload whether or not force download
* @param array $options additional options affecting the file serving
* @return bool false if the file not found, just send the file otherwise and do not return anything
*/
function block_profile360_pluginfile($course, $cm, $context, $filearea, $args, $forcedownload, array $options = array()) {
// Check context level
if ($context->contextlevel != CONTEXT_SYSTEM) {
return false;
}
// Check if user is logged in
require_login();
// Check filearea
if ($filearea !== 'bannerimage') {
return false;
}
// Get file details
$itemid = (int)array_shift($args);
$filename = array_pop($args);
$filepath = $args ? '/'.implode('/', $args).'/' : '/';
// Get file from storage
$fs = get_file_storage();
$file = $fs->get_file($context->id, 'block_profile360', $filearea, $itemid, $filepath, $filename);
if (!$file || $file->is_directory()) {
return false;
}
// Send the file
send_stored_file($file, 86400, 0, $forcedownload, $options);
return true;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 83 KiB

View File

@ -0,0 +1,38 @@
<?php
defined('MOODLE_INTERNAL') || die();
if ($ADMIN->fulltree) {
global $DB;
// Consulta para obtener campos personalizados visibles
$sql = "SELECT shortname, name FROM {user_info_field} WHERE visible > :visible ORDER BY sortorder ASC";
// Ejecutar la consulta
$visibleCustomFields = $DB->get_records_sql_menu($sql, ['visible' => 0]);
$settings->add(new admin_setting_heading('block_profile360_settings', 'Configuración', ''));
// Banner background image setting
$settings->add(
new admin_setting_configstoredfile(
'block_profile360/bannerimage',
get_string('bannerimage', 'block_profile360'),
get_string('bannerimage_desc', 'block_profile360'),
'bannerimage',
0,
array('maxfiles' => 1, 'accepted_types' => array('.jpg', '.jpeg', '.png', '.gif'))
)
);
// Agregar los campos personalizados visibles como opciones
foreach ($visibleCustomFields as $shortname => $fieldName) {
$settings->add(
new admin_setting_configcheckbox(
'block_profile360/customfield_' . $shortname,
$fieldName,
'Mostar en el bloque',
true
)
);
}
}

View File

@ -0,0 +1,182 @@
/* ===== PROFILE 360 (EQUAL HEIGHT CARDS) ===== */
.block_profile360 {
border: none;
box-shadow: rgba(0, 0, 0, 0.1) 0 4px 12px;
}
.block_profile360 h5.card-title { display: none; }
.block_profile360 .card-body { padding: 0; }
.block_profile360 .card-header.miniBanner {
min-height: 100px;
border-top-left-radius: 5px;
border-top-right-radius: 5px;
background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
background-size: cover;
background-position: center bottom;
}
.block_profile360 .card-header.miniBanner[style*="background-image"] { background: none; }
.block_profile360 .card {
background-color: #fff;
border: none;
}
.block_profile360 .top-container { width: 100%; }
.block_profile360 .profile-image {
border-radius: 10px;
background-color: #fff;
padding: 5px;
box-shadow: rgba(0, 0, 0, 0.05) 0 1px 2px 0;
}
.block_profile360 .profile-image-container {
margin-top: -80px;
padding-left: 25px;
}
/* ===== STATS CARDS ===== */
/* Caja base (div o <a>) */
.block_profile360 .stats-card,
.block_profile360 .stadisticsUserCourse {
position: relative;
display: flex; /* ← centra vertical/horizontal */
flex-direction: column;
justify-content: center;
align-items: center;
gap: .35rem;
text-align: center;
text-decoration: none !important;
color: #222;
background-color: #f2e7e8;
border-radius: 14px;
padding: 1rem;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
transition: transform .2s ease, box-shadow .2s ease;
border: 1px solid rgba(255, 255, 255, 0.8);
overflow: hidden;
min-height: 150px; /* ← alto uniforme (mobile) */
}
@media (min-width: 768px) {
.block_profile360 .stats-card,
.block_profile360 .stadisticsUserCourse {
min-height: 170px; /* ← alto uniforme (md+) */
}
}
@media (min-width: 1200px) {
.block_profile360 .stats-card,
.block_profile360 .stadisticsUserCourse {
min-height: 180px; /* ← alto uniforme (lg) */
}
}
/* Icono circular */
.block_profile360 .round-div.stats-icon {
width: 54px;
height: 54px;
border-radius: 50%;
background-color: rgba(255,255,255,0.95);
display: flex;
justify-content: center;
align-items: center;
box-shadow: 0 2px 4px rgba(0,0,0,.08);
}
.block_profile360 .round-div.stats-icon .icon-profile {
font-size: 20px;
line-height: 1;
}
/* Número y etiqueta */
.block_profile360 .stats-value {
margin: .2rem 0 0;
line-height: 1.1;
font-weight: 800;
background: none !important;
box-shadow: none !important;
border: 0 !important;
}
.block_profile360 .stats-value::before,
.block_profile360 .stats-value::after { content: none !important; }
.block_profile360 .stats-label {
display: block;
margin-top: .15rem;
opacity: .95;
}
/* Paletas */
.block_profile360 .totalCourses { background: linear-gradient(135deg, rgba(10, 74, 153, .12), rgba(10, 74, 153, .22)); border-left: 4px solid #0a4a99; }
.block_profile360 .completedCourses { background: linear-gradient(135deg, rgba(72, 153, 10, .12), rgba(72, 153, 10, .22)); border-left: 4px solid #48990a; }
.block_profile360 .inProgressCourses { background: linear-gradient(135deg, rgba(238, 202, 6, .12), rgba(238, 202, 6, .22)); border-left: 4px solid #d4a806; }
.block_profile360 .certificatedCourses { background: linear-gradient(135deg, rgba(120, 14, 23, .12), rgba(120, 14, 23, .22)); border-left: 4px solid #780E17; }
.block_profile360 .totalCourses .icon-profile, .block_profile360 .totalCourses .stats-value { color: #0a4a99; }
.block_profile360 .completedCourses .icon-profile, .block_profile360 .completedCourses .stats-value { color: #48990a; }
.block_profile360 .inProgressCourses .icon-profile, .block_profile360 .inProgressCourses .stats-value { color: #e0b000; }
.block_profile360 .certificatedCourses .icon-profile, .block_profile360 .certificatedCourses .stats-value { color: #780E17; }
/* Interacciones */
.block_profile360 .no-click { cursor: default; }
.block_profile360 .no-click:hover { transform: none; box-shadow: 0 2px 8px rgba(0,0,0,.08); }
.block_profile360 .completedCourses,
.block_profile360 .inProgressCourses,
.block_profile360 .certificatedCourses { cursor: pointer; }
.block_profile360 .completedCourses:hover,
.block_profile360 .inProgressCourses:hover,
.block_profile360 .certificatedCourses:hover {
transform: translateY(-2px);
box-shadow: 0 4px 16px rgba(0,0,0,.15);
}
/* Datos personalizados */
.block_profile360 .custom-profile-data { font-size: .9rem; margin: 0; }
/* Modales centrados */
.block_profile360 .modal-dialog {
min-height: calc(100vh - 60px);
display: flex;
flex-direction: column;
justify-content: center;
overflow: auto;
}
@media (max-width: 768px) {
.block_profile360 .modal-dialog { min-height: calc(100vh - 20px); }
}
.block_profile360 .modal.show {
background-color: rgba(0,0,0,.5);
font-size: 16px;
}
/* Email */
.block_profile360 .mail { font-size: .9rem !important; }
/* ===== DARK MODE ===== */
html.dark-mode .block_profile360 .card { background-color: #2d3748; color: #e2e8f0; }
html.dark-mode .block_profile360 .stats-card { border-color: rgba(255,255,255,.1); box-shadow: 0 2px 8px rgba(0,0,0,.3); color: #fff; }
html.dark-mode .block_profile360 .totalCourses { background: linear-gradient(135deg, rgba(10, 74, 153, .28), rgba(10, 74, 153, .38)); border-left-color: #4299e1; }
html.dark-mode .block_profile360 .completedCourses { background: linear-gradient(135deg, rgba(72, 153, 10, .28), rgba(72, 153, 10, .38)); border-left-color: #48bb78; }
html.dark-mode .block_profile360 .inProgressCourses{ background: linear-gradient(135deg, rgba(238, 202, 6, .28), rgba(238, 202, 6, .38)); border-left-color: #fbbf24; }
html.dark-mode .block_profile360 .certificatedCourses { background: linear-gradient(135deg, rgba(120, 14, 23, .28), rgba(120, 14, 23, .38)); border-left-color: #f87171; }
html.dark-mode .block_profile360 .totalCourses .stats-value { color: #4299e1; }
html.dark-mode .block_profile360 .completedCourses .stats-value { color: #48bb78; }
html.dark-mode .block_profile360 .inProgressCourses .stats-value { color: #fbbf24; }
html.dark-mode .block_profile360 .certificatedCourses .stats-value { color: #f87171; }
html.dark-mode .block_profile360 .round-div.stats-icon { background-color: rgba(255,255,255,.15); }
html.dark-mode .block_profile360 .modal-content { background-color: #2d3748; color: #e2e8f0; }
html.dark-mode .block_profile360 .modal-header { border-bottom-color: #4a5568; }
html.dark-mode .block_profile360 .modal-footer { border-top-color: #4a5568; }
html.dark-mode .block_profile360 .custom-profile-data { color: #cbd5e0; }
/* ===== RESETS contra adornos del tema ===== */
.block_profile360 .h1, .block_profile360 .h2, .block_profile360 .h3,
.block_profile360 h1, .block_profile360 h2, .block_profile360 h3 {
background: none !important; box-shadow: none !important;
}
.block_profile360 .h1::before, .block_profile360 .h1::after,
.block_profile360 .h2::before, .block_profile360 .h2::after,
.block_profile360 h1::before, .block_profile360 h1::after,
.block_profile360 h2::before, .block_profile360 h2::after,
.block_profile360 h3::before, .block_profile360 h3::after { content: none !important; }

View File

@ -0,0 +1,186 @@
.block_profile360 {
border: none;
box-shadow: rgba(0, 0, 0, 0.1) 0px 4px 12px;
}
.block_profile360 h5.card-title {
display: none;
}
.block_profile360 .card-body {
padding: 0;
}
.block_profile360 .card-header.miniBanner {
min-height: 100px;
border-top-left-radius: 5px;
border-top-right-radius: 5px;
background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
background-size: cover;
background-position: center bottom;
}
.block_profile360 .card-header.miniBanner[style*="background-image"] {
background: none;
}
.block_profile360 .card {
background-color: #fff;
border: none;
}
.block_profile360 .top-container {
width: 100%;
}
.block_profile360 .profile-image {
border-radius: 10px;
background-color: #fff;
padding: 5px;
box-shadow: rgba(0, 0, 0, 0.05) 0px 1px 2px 0px;
}
.block_profile360 .profile-image-container {
margin-top: -80px;
padding-left: 25px;
}
.block_profile360 .middle-container {
background-color: #eee;
border-radius: 12px;
}
.block_profile360 .round-div {
border-radius: 50%;
width: 35px;
height: 35px;
background-color: #fff;
display: flex;
justify-content: center;
align-items: center;
text-align: center;
}
.block_profile360 .stadisticsUserCourse {
color: #222;
background-color: #f2e7e8;
text-decoration: none;
border-radius: 10px;
padding: 1rem;
}
.block_profile360 .stadisticsUserCourse.totalCourses {
background-color: rgba(10, 74, 153, 0.3);
color: #0a4a99;
}
.block_profile360 .stadisticsUserCourse.totalCourses .icon-profile, .block_profile360 .stadisticsUserCourse.totalCourses .h2 {
color: #0a4a99;
}
.block_profile360 .stadisticsUserCourse.completedCourses {
background-color: rgba(72, 153, 10, 0.3);
color: #48990a;
}
.block_profile360 .stadisticsUserCourse.completedCourses .icon-profile, .block_profile360 .stadisticsUserCourse.completedCourses .h2 {
color: #48990a;
}
.block_profile360 .stadisticsUserCourse.inProgressCourses {
background-color: rgba(238, 202, 6, 0.3);
color: #eeca06;
}
.block_profile360 .stadisticsUserCourse.inProgressCourses .icon-profile, .block_profile360 .stadisticsUserCourse.inProgressCourses .h2 {
color: #eeca06;
}
.block_profile360 .stadisticsUserCourse.certificatedCourses {
/* background-color: rgba(10,74,153,.3); */
color: #780E17;
}
.block_profile360 .stadisticsUserCourse.certificatedCourses .icon-profile, .block_profile360 .stadisticsUserCourse.certificatedCourses .h2 {
color: #780E17;
}
.block_profile360 .inProgressCourses, .block_profile360 .certificatedCourses {
transition: all 0.5s ease;
cursor: pointer;
}
.block_profile360 .inProgressCourses:hover, .block_profile360 .certificatedCourses:hover {
transform: scale(0.9);
}
.block_profile360 .custom-profile-data {
font-size: small;
margin: 0;
}
.block_profile360 .modal-dialog {
min-height: calc(100vh - 60px);
display: flex;
flex-direction: column;
justify-content: center;
overflow: auto;
}
@media (max-width: 768px) {
.block_profile360 .modal-dialog {
min-height: calc(100vh - 20px);
}
}
.block_profile360 .modal.show {
background-color: rgba(0, 0, 0, 0.5);
font-size: 16px;
}
/* Dark mode support */
html.dark-mode .block_profile360 .card {
background-color: #2d3748;
color: #e2e8f0;
}
html.dark-mode .block_profile360 .stadisticsUserCourse {
color: #e2e8f0;
}
html.dark-mode .block_profile360 .stadisticsUserCourse.totalCourses {
background-color: rgba(10, 74, 153, 0.4);
color: #63b3ed;
}
html.dark-mode .block_profile360 .stadisticsUserCourse.completedCourses {
background-color: rgba(72, 153, 10, 0.4);
color: #68d391;
}
html.dark-mode .block_profile360 .stadisticsUserCourse.inProgressCourses {
background-color: rgba(238, 202, 6, 0.4);
color: #f6e05e;
}
html.dark-mode .block_profile360 .stadisticsUserCourse.certificatedCourses {
background-color: rgba(120, 14, 23, 0.4);
color: #fc8181;
}
html.dark-mode .block_profile360 .modal-content {
background-color: #2d3748;
color: #e2e8f0;
}
html.dark-mode .block_profile360 .modal-header {
border-bottom-color: #4a5568;
}
html.dark-mode .block_profile360 .modal-footer {
border-top-color: #4a5568;
}
html.dark-mode .block_profile360 .custom-profile-data {
color: #cbd5e0;
}

View File

@ -0,0 +1 @@
.block_profile360{border:none;box-shadow:rgba(0,0,0,0.1) 0px 4px 12px}.block_profile360 h5.card-title{display:none}.block_profile360 .card-body{padding:0}.block_profile360 .card-header.miniBanner{min-height:100px;border-top-left-radius:5px;border-top-right-radius:5px;background-image:url(../pix/01.png);background-size:cover;background-position:center bottom}.block_profile360 .card{background-color:#fff;border:none}.block_profile360 .top-container{width:100%}.block_profile360 .profile-image{border-radius:10px;background-color:#fff;padding:5px;box-shadow:rgba(0,0,0,0.05) 0px 1px 2px 0px}.block_profile360 .profile-image-container{margin-top:-80px;padding-left:25px}.block_profile360 .middle-container{background-color:#eee;border-radius:12px}.block_profile360 .round-div{border-radius:50%;width:35px;height:35px;background-color:#fff;display:flex;justify-content:center;align-items:center;text-align:center}.block_profile360 .stadisticsUserCourse{color:#222;background-color:#f2e7e8;text-decoration:none;border-radius:10px;padding:1rem}.block_profile360 .stadisticsUserCourse.totalCourses{background-color:rgba(10,74,153,0.3);color:#0a4a99}.block_profile360 .stadisticsUserCourse.totalCourses .icon-profile,.block_profile360 .stadisticsUserCourse.totalCourses .h2{color:#0a4a99}.block_profile360 .stadisticsUserCourse.completedCourses{background-color:rgba(72,153,10,0.3);color:#48990a}.block_profile360 .stadisticsUserCourse.completedCourses .icon-profile,.block_profile360 .stadisticsUserCourse.completedCourses .h2{color:#48990a}.block_profile360 .stadisticsUserCourse.inProgressCourses{background-color:rgba(238,202,6,0.3);color:#eeca06}.block_profile360 .stadisticsUserCourse.inProgressCourses .icon-profile,.block_profile360 .stadisticsUserCourse.inProgressCourses .h2{color:#eeca06}.block_profile360 .stadisticsUserCourse.certificatedCourses{color:#780E17}.block_profile360 .stadisticsUserCourse.certificatedCourses .icon-profile,.block_profile360 .stadisticsUserCourse.certificatedCourses .h2{color:#780E17}.block_profile360 .inProgressCourses,.block_profile360 .certificatedCourses{transition:all 0.5s ease;cursor:pointer}.block_profile360 .inProgressCourses:hover,.block_profile360 .certificatedCourses:hover{transform:scale(0.9)}.block_profile360 .custom-profile-data{font-size:small;margin:0}.block_profile360 .modal-dialog{min-height:calc(100vh - 60px);display:flex;flex-direction:column;justify-content:center;overflow:auto}@media (max-width: 768px){.block_profile360 .modal-dialog{min-height:calc(100vh - 20px)}}.block_profile360 .modal.show{background-color:rgba(0,0,0,0.5);font-size:16px}

View File

@ -0,0 +1,129 @@
.block_profile360 {
border: none;
box-shadow: rgba(0, 0, 0, 0.1) 0px 4px 12px;
}
.block_profile360 {
h5.card-title {
display: none;
}
.card-body {
padding: 0;
}
.card-header.miniBanner {
min-height: 100px;
border-top-left-radius: 5px;
border-top-right-radius: 5px;
background-image: url(../pix/01.png);
background-size: cover;
background-position: center bottom;
}
.card {
background-color: #fff;
border: none;
}
.top-container {
width: 100%;
}
.profile-image {
border-radius: 10px;
background-color: #fff;
padding: 5px;
box-shadow: rgba(0, 0, 0, 0.05) 0px 1px 2px 0px;
}
.profile-image-container {
margin-top: -80px;
padding-left: 25px;
}
.middle-container {
background-color: #eee;
border-radius: 12px;
}
.round-div {
border-radius: 50%;
width: 35px;
height: 35px;
background-color: #fff;
display: flex;
justify-content: center;
align-items: center;
text-align: center;
}
.stadisticsUserCourse {
color: #222;
background-color: #f2e7e8;
text-decoration: none;
border-radius: 10px;
padding: 1rem;
}
.stadisticsUserCourse.totalCourses {
background-color: rgba(10,74,153,.3);
color: #0a4a99;
}
.stadisticsUserCourse.totalCourses .icon-profile, .stadisticsUserCourse.totalCourses .h2{
color: #0a4a99;
}
.stadisticsUserCourse.completedCourses {
background-color: rgba(72,153,10,.3);
color: #48990a;
}
.stadisticsUserCourse.completedCourses .icon-profile, .stadisticsUserCourse.completedCourses .h2{
color: #48990a;
}
.stadisticsUserCourse.inProgressCourses {
background-color: rgba(238,202,6,.3);
color: #eeca06;
}
.stadisticsUserCourse.inProgressCourses .icon-profile, .stadisticsUserCourse.inProgressCourses .h2{
color: #eeca06;
}
.stadisticsUserCourse.certificatedCourses {
/* background-color: rgba(10,74,153,.3); */
color: #780E17;
}
.stadisticsUserCourse.certificatedCourses .icon-profile, .stadisticsUserCourse.certificatedCourses .h2{
color:#780E17;
}
.inProgressCourses, .certificatedCourses{
transition: all 0.5s ease;
cursor: pointer;
}
.inProgressCourses:hover, .certificatedCourses:hover{
transform: scale(.9);
}
.custom-profile-data{
font-size: small;
margin: 0;
}
.modal-dialog {
min-height: calc(100vh - 60px);
display: flex;
flex-direction: column;
justify-content: center;
overflow: auto;
@media(max-width: 768px) {
min-height: calc(100vh - 20px);
}
}
.modal.show{
background-color: rgba(0,0,0,.5);
font-size: 16px;
}
}

View File

@ -0,0 +1,198 @@
<div class="container-fluid profile360 my-md-0 my-3 px-0 block_profile360">
<div class="row justify-content-center">
<div class="col-12">
<div class="card">
{{#bannerImageUrl}}
<div class="card-header miniBanner" style="background-image: url({{bannerImageUrl}});"></div>
{{/bannerImageUrl}}
{{^bannerImageUrl}}
<div class="card-header miniBanner"></div>
{{/bannerImageUrl}}
<div class="profile-image-container w-100">
<img src="{{profileImage}}" class="img-fluid profile-image" width="100" alt="{{fullname}}" />
</div>
<div class="top-container">
<div class="p-3">
<div class="row align-items-center justify-content-center">
<div class="col-12 col-md-10">
<p class="name mb-1">{{fullname}}</p>
<p class="mail small mb-0"><i class="fas fa-envelope"></i> {{email}}</p>
{{#customFieldsToShow}}
<p class="custom-profile-data"><b>{{key}}</b>: {{{value}}}</p>
{{/customFieldsToShow}}
</div>
<div class="col-12 col-md-2 text-right mt-2 mt-md-0">
<a class="btn-outline-primary px-2 py-1" role="button" href="{{editProfileUrl}}">
<i class="fas fa-edit"></i>
</a>
</div>
</div>
</div>
</div>
<div class="card-body pb-3">
<div class="container-fluid">
<div class="row justify-content-center">
<!-- Total de cursos (no clic) -->
<div class="col-10 col-md-12 my-2">
<div class="stadisticsUserCourse stats-card totalCourses no-click">
<div class="round-div stats-icon">
<i class="fas fa-globe icon-profile"></i>
</div>
<h2 class="h2 stats-value mb-0">{{totalEnrolledCourses}}</h2>
<small class="stats-label">{{#str}}totalcourses, block_profile360{{/str}}</small>
</div>
</div>
<!-- Cursos completados (modal) -->
<div class="col-10 col-md-12 my-2">
<a href="#" class="stadisticsUserCourse stats-card completedCourses text-decoration-none"
data-toggle="modal" data-target="#modalCompletedCourses" role="button" aria-controls="modalCompletedCourses">
<div class="round-div stats-icon">
<i class="fas fa-check-circle icon-profile"></i>
</div>
<h2 class="h2 stats-value mb-0">{{completedCoursesString}}</h2>
<small class="stats-label">{{#str}}completedcourses, block_profile360{{/str}}</small>
</a>
</div>
<!-- Cursos en progreso (modal; lista vía data-list) -->
<div class="col-10 col-md-12 my-2">
<a href="#" class="stadisticsUserCourse stats-card inProgressCourses text-decoration-none"
data-toggle="modal" data-target="#modalInProgressCourses"
role="button" aria-controls="modalInProgressCourses">
<div class="round-div stats-icon">
<i class="fas fa-clock icon-profile"></i>
</div>
<h2 class="h2 stats-value mb-0">{{inProgressCoursesString}}</h2>
<small class="stats-label">{{#str}}inprogresscourses, block_profile360{{/str}}</small>
</a>
</div>
<!-- Certificaciones (modal; lista vía data-list) -->
<div class="col-10 col-md-12 my-2">
<a href="#" class="stadisticsUserCourse stats-card certificatedCourses text-decoration-none"
data-toggle="modal" data-target="#modalCertifiedCourses"
role="button" aria-controls="modalCertifiedCourses">
<div class="round-div stats-icon">
<i class="fa-regular fa-thumbs-up icon-profile"></i>
</div>
<h2 class="h2 stats-value mb-0">{{certifiedCoursesCount}}</h2>
<small class="stats-label">{{#str}}certifications, block_profile360{{/str}}</small>
</a>
</div>
</div> <!-- /.row -->
</div> <!-- /.container-fluid -->
</div> <!-- /.card-body -->
</div> <!-- /.card -->
</div> <!-- /.col-12 -->
</div> <!-- /.row -->
</div> <!-- /.container-fluid -->
<!-- Modals -->
<!-- Completed Courses Modal -->
<div id="modalCompletedCourses" style="display: none;" class="modal" tabindex="-1" role="dialog" aria-labelledby="completedCoursesTitle">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 id="completedCoursesTitle" class="modal-title">
<i class="fas fa-check-circle"></i> {{#str}}completedcourses, block_profile360{{/str}}
</h5>
</div>
<div class="modal-body">
{{#completedCoursesString}}
<ol></ol>
{{/completedCoursesString}}
{{^completedCoursesString}}
<p>{{#str}}nocompletedcourses, block_profile360{{/str}}</p>
{{/completedCoursesString}}
</div>
<div class="modal-footer justify-content-center text-center">
<button type="button" class="btn btn-primary" data-dismiss="modal">
{{#str}}close, block_profile360{{/str}}
</button>
</div>
</div>
</div>
</div>
<!-- In Progress Courses Modal -->
<div id="modalInProgressCourses" style="display: none;" class="modal" tabindex="-1" role="dialog" aria-labelledby="inProgressCoursesTitle">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 id="inProgressCoursesTitle" class="modal-title">
<i class="fas fa-chart-pie"></i> {{#str}}inprogresscourses, block_profile360{{/str}}
</h5>
</div>
<div class="modal-body">
{{#inProgressCoursesString}}
<ol></ol>
{{/inProgressCoursesString}}
{{^inProgressCoursesString}}
<p>{{#str}}noinprogresscourses, block_profile360{{/str}}</p>
{{/inProgressCoursesString}}
</div>
<div class="modal-footer justify-content-center text-center">
<button type="button" class="btn btn-primary" data-dismiss="modal">
{{#str}}close, block_profile360{{/str}}
</button>
</div>
</div>
</div>
</div>
<!-- Certified Courses Modal -->
<div id="modalCertifiedCourses" style="display: none;" class="modal" tabindex="-1" role="dialog" aria-labelledby="certifiedCoursesTitle">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 id="certifiedCoursesTitle" class="modal-title">
<i class="fas fa-certificate"></i> {{#str}}certifiedcourses, block_profile360{{/str}}
</h5>
</div>
<div class="modal-body">
{{#certifiedCoursesCount}}
<ol></ol>
{{/certifiedCoursesCount}}
{{^certifiedCoursesCount}}
<p>{{#str}}nocertifiedcourses, block_profile360{{/str}}</p>
{{/certifiedCoursesCount}}
</div>
<div class="modal-footer justify-content-center text-center">
<button type="button" class="btn btn-primary" data-dismiss="modal">
{{#str}}close, block_profile360{{/str}}
</button>
</div>
</div>
</div>
</div>
<!-- Ending Soon Courses Modal -->
<div class="modal fade" id="ModalEndingSoonCourses" tabindex="-1" role="dialog" aria-labelledby="ModalEndingSoonCourses" aria-hidden="true" data-showmodal="{{showModal}}">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h2 class="modal-title text-danger font-weight-bold">
<i class="fas fa-exclamation-triangle"></i> {{#str}}coursesexpiring, block_profile360{{/str}}
</h2>
</div>
<div class="modal-body">
<p>{{#str}}coursesexpiringmessage, block_profile360{{/str}}</p>
<ol></ol>
</div>
<div class="modal-footer justify-content-center text-center">
<button type="button" class="btn btn-primary btnclose" data-dismiss="modal">
{{#str}}close, block_profile360{{/str}}
</button>
</div>
</div>
</div>
</div>

View File

@ -0,0 +1,31 @@
<?php
// This file is part of Moodle - https://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <https://www.gnu.org/licenses/>.
/**
* Plugin version and other meta-data are defined here.
*
* @package block_profile360
* @copyright 2023 Espacio360 <salvador.martinez@espacio360.com.mx>
* @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
$plugin->component = 'block_profile360';
$plugin->release = '1.6.2';
$plugin->version = 2025010127;
$plugin->requires = 2021051700;
$plugin->maturity = MATURITY_STABLE;