Proyectos de Subversion Moodle

Rev

Rev 5 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 5 Rev 6
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
 
-
 
68
            ],
67
            ],
69
            'privacy:metadata:block_point_view'
68
            'privacy:metadata:block_point_view'
70
        );
69
        );
Línea 71... Línea 70...
71
 
70
 
Línea 76... Línea 75...
76
     * Get the list of contexts that contain user information for the specified user.
75
     * Get the list of contexts that contain user information for the specified user.
77
     *
76
     *
78
     * @param   int $userid The user to search.
77
     * @param   int $userid The user to search.
79
     * @return  contextlist   $contextlist  The contextlist containing the list of contexts used in this plugin.
78
     * @return  contextlist   $contextlist  The contextlist containing the list of contexts used in this plugin.
80
     */
79
     */
81
    public static function get_contexts_for_userid(int $userid) : contextlist {
80
    public static function get_contexts_for_userid(int $userid): contextlist {
82
        $sql = 'SELECT DISTINCT ctx.id
81
        $sql = 'SELECT DISTINCT ctx.id
83
                FROM {block_point_view} bpv
82
                FROM {block_point_view} bpv
84
                JOIN {context} ctx
83
                JOIN {context} ctx
85
                    ON ctx.instanceid = bpv.userid
84
                    ON ctx.instanceid = bpv.userid
86
                        AND ctx.contextlevel = :contextlevel
85
                        AND ctx.contextlevel = :contextlevel
Línea 105... Línea 104...
105
        $results = static::get_records($contextlist->get_user()->id);
104
        $results = static::get_records($contextlist->get_user()->id);
106
        foreach ($results as $result) {
105
        foreach ($results as $result) {
107
            $pointviewdata[] = (object) [
106
            $pointviewdata[] = (object) [
108
                'courseid' => $result->courseid,
107
                'courseid' => $result->courseid,
109
                'cmid' => $result->cmid,
108
                'cmid' => $result->cmid,
110
                'vote' => $result->vote
109
                'vote' => $result->vote,
111
            ];
110
            ];
112
        }
111
        }
113
        if (!empty($pointviewdata)) {
112
        if (!empty($pointviewdata)) {
114
            $data = (object) [
113
            $data = (object) [
115
                'votes' => $pointviewdata,
114
                'votes' => $pointviewdata,