Proyectos de Subversion Moodle

Rev

Rev 4 | Ir a la última revisión | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 4 Rev 5
Línea 24... Línea 24...
24
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
24
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
25
 */
25
 */
Línea 26... Línea 26...
26
 
26
 
Línea 27... Línea 27...
27
namespace block_point_view\privacy;
27
namespace block_point_view\privacy;
28
 
28
 
29
use core_privacy\local\metadata\collection;
29
use \core_privacy\local\metadata\collection;
30
use core_privacy\local\request\approved_userlist;
30
use core_privacy\local\request\approved_userlist;
31
use core_privacy\local\request\contextlist;
31
use \core_privacy\local\request\contextlist;
Línea 32... Línea 32...
32
use core_privacy\local\request\approved_contextlist;
32
use \core_privacy\local\request\approved_contextlist;
33
use core_privacy\local\request\userlist;
33
use core_privacy\local\request\userlist;
34
 
34
 
Línea 54... Línea 54...
54
     * Point of View Metadata
54
     * Point of View Metadata
55
     *
55
     *
56
     * @param collection $collection
56
     * @param collection $collection
57
     * @return collection
57
     * @return collection
58
     */
58
     */
59
    public static function get_metadata(collection $collection): collection {
59
    public static function get_metadata(collection $collection) : collection {
60
        $collection->add_database_table(
60
        $collection->add_database_table(
61
            'block_point_view',
61
            'block_point_view',
62
            [
62
            [
63
                'courseid' => 'privacy:metadata:activity_votes_database:courseid',
63
                'courseid' => 'privacy:metadata:activity_votes_database:courseid',
64
                'cmid' => 'privacy:metadata:activity_votes_database:cmid',
64
                'cmid' => 'privacy:metadata:activity_votes_database:cmid',
65
                'userid' => 'privacy:metadata:activity_votes_database:userid',
65
                'userid' => 'privacy:metadata:activity_votes_database:userid',
66
                'vote' => 'privacy:metadata:activity_votes_database:vote',
66
                'vote' => 'privacy:metadata:activity_votes_database:vote'
-
 
67
 
67
            ],
68
            ],
68
            'privacy:metadata:block_point_view'
69
            'privacy:metadata:block_point_view'
69
        );
70
        );
Línea 70... Línea 71...
70
 
71
 
Línea 75... Línea 76...
75
     * Get the list of contexts that contain user information for the specified user.
76
     * Get the list of contexts that contain user information for the specified user.
76
     *
77
     *
77
     * @param   int $userid The user to search.
78
     * @param   int $userid The user to search.
78
     * @return  contextlist   $contextlist  The contextlist containing the list of contexts used in this plugin.
79
     * @return  contextlist   $contextlist  The contextlist containing the list of contexts used in this plugin.
79
     */
80
     */
80
    public static function get_contexts_for_userid(int $userid): contextlist {
81
    public static function get_contexts_for_userid(int $userid) : contextlist {
81
        $sql = 'SELECT DISTINCT ctx.id
82
        $sql = 'SELECT DISTINCT ctx.id
82
                FROM {block_point_view} bpv
83
                FROM {block_point_view} bpv
83
                JOIN {context} ctx
84
                JOIN {context} ctx
84
                    ON ctx.instanceid = bpv.userid
85
                    ON ctx.instanceid = bpv.userid
85
                        AND ctx.contextlevel = :contextlevel
86
                        AND ctx.contextlevel = :contextlevel
Línea 104... Línea 105...
104
        $results = static::get_records($contextlist->get_user()->id);
105
        $results = static::get_records($contextlist->get_user()->id);
105
        foreach ($results as $result) {
106
        foreach ($results as $result) {
106
            $pointviewdata[] = (object) [
107
            $pointviewdata[] = (object) [
107
                'courseid' => $result->courseid,
108
                'courseid' => $result->courseid,
108
                'cmid' => $result->cmid,
109
                'cmid' => $result->cmid,
109
                'vote' => $result->vote,
110
                'vote' => $result->vote
110
            ];
111
            ];
111
        }
112
        }
112
        if (!empty($pointviewdata)) {
113
        if (!empty($pointviewdata)) {
113
            $data = (object) [
114
            $data = (object) [
114
                'votes' => $pointviewdata,
115
                'votes' => $pointviewdata,