Proyectos de Subversion Moodle

Rev

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

Rev 1 Rev 1441
Línea 51... Línea 51...
51
        // Instance variable is used by the form validation function.
51
        // Instance variable is used by the form validation function.
52
        $instance = $params['instance'];
52
        $instance = $params['instance'];
53
        $this->instance = $instance;
53
        $this->instance = $instance;
Línea 54... Línea 54...
54
 
54
 
-
 
55
        // Get the assignment class.
55
        // Get the assignment class.
56
        /** @var assign $assign */
56
        $assign = $params['assign'];
57
        $assign = $params['assign'];
57
        $userlist = $params['userlist'];
-
 
58
        $usercount = 0;
-
 
Línea -... Línea 58...
-
 
58
        $userlist = $params['userlist'];
-
 
59
 
-
 
60
        // Load current extensions for all selected users.
-
 
61
        [$usercondition, $params] = $DB->get_in_or_equal($userlist);
-
 
62
        array_unshift($params, $assign->get_instance()->id);
-
 
63
        $userinfo = $DB->get_records_sql("
-
 
64
                SELECT u.*, auf.extensionduedate
-
 
65
                  FROM {user} u
-
 
66
             LEFT JOIN {assign_user_flags} auf ON auf.userid = u.id AND auf.assignment = ?
-
 
67
                 WHERE u.id $usercondition
-
 
68
            ", $params);
59
        $usershtml = '';
69
 
60
 
70
        // Prepare display of up to 5 users.
-
 
71
        // TODO Does not support custom user profile fields (MDL-70456).
-
 
72
        $extrauserfields = \core_user\fields::get_identity_fields($assign->get_context(), false);
61
        // TODO Does not support custom user profile fields (MDL-70456).
73
        $displayedusercount = 0;
-
 
74
        $usershtml = '';
62
        $extrauserfields = \core_user\fields::get_identity_fields($assign->get_context(), false);
75
        foreach ($userlist as $userid) {
63
        foreach ($userlist as $userid) {
76
            $displayedusercount += 1;
64
            if ($usercount >= 5) {
77
            if ($displayedusercount > 5) {
65
                $usershtml .= get_string('moreusers', 'assign', count($userlist) - 5);
78
                $usershtml .= get_string('moreusers', 'assign', count($userlist) - 5);
66
                break;
-
 
Línea -... Línea 79...
-
 
79
                break;
67
            }
80
            }
-
 
81
 
68
            $user = $DB->get_record('user', array('id' => $userid), '*', MUST_EXIST);
82
            $user = $userinfo[$userid];
69
 
83
            $usershtml .= $assign->get_renderer()->render(
70
            $usershtml .= $assign->get_renderer()->render(new assign_user_summary($user,
84
                new assign_user_summary($user,
71
                                                                    $assign->get_course()->id,
85
                    $assign->get_course()->id,
72
                                                                    has_capability('moodle/site:viewfullnames',
86
                    has_capability('moodle/site:viewfullnames',
73
                                                                    $assign->get_course_context()),
87
                        $assign->get_course_context()),
74
                                                                    $assign->is_blind_marking(),
88
                    $assign->is_blind_marking(),
75
                                                                    $assign->get_uniqueid_for_user($user->id),
89
                    $assign->get_uniqueid_for_user($user->id),
-
 
90
                    $extrauserfields,
76
                                                                    $extrauserfields,
91
                    !$assign->is_active_user($userid)
Línea -... Línea 92...
-
 
92
                ),
-
 
93
            );
-
 
94
        }
-
 
95
 
-
 
96
        // Find the range of extensions that currently exist for these users.
77
                                                                    !$assign->is_active_user($userid)));
97
        $earliestextension = null;
-
 
98
        $lateststextension = 0;
-
 
99
        $userswithoutanextension = 0;
-
 
100
        foreach ($userlist as $userid) {
-
 
101
            $user = $userinfo[$userid];
-
 
102
 
-
 
103
            if ($user->extensionduedate) {
-
 
104
                $lateststextension = max($lateststextension, $user->extensionduedate);
-
 
105
                if ($earliestextension !== null) {
-
 
106
                    $earliestextension = min($earliestextension, $user->extensionduedate);
-
 
107
                } else {
-
 
108
                    $earliestextension = $user->extensionduedate;
-
 
109
                }
Línea 78... Línea 110...
78
                $usercount += 1;
110
            } else {
79
        }
111
                $userswithoutanextension += 1;
80
 
112
            }
Línea 81... Línea 113...
81
        $userscount = count($userlist);
113
        }
82
 
114
 
Línea 96... Línea 128...
96
        }
128
        }
97
        if ($instance->cutoffdate) {
129
        if ($instance->cutoffdate) {
98
            $mform->addElement('static', 'cutoffdate', get_string('cutoffdate', 'assign'), userdate($instance->cutoffdate));
130
            $mform->addElement('static', 'cutoffdate', get_string('cutoffdate', 'assign'), userdate($instance->cutoffdate));
99
            $finaldate = $instance->cutoffdate;
131
            $finaldate = $instance->cutoffdate;
100
        }
132
        }
-
 
133
 
-
 
134
        if ($userswithoutanextension == count($userlist)) {
-
 
135
            // All users don't have an extension yet.
-
 
136
            $currentdatesdisplay = get_string('extensionduedatenone', 'assign');
-
 
137
 
-
 
138
        } else {
-
 
139
            if ($earliestextension == $lateststextension) {
-
 
140
                $currentdatesdisplay = userdate($lateststextension);
-
 
141
            } else {
-
 
142
                $currentdatesdisplay = get_string('extensionduedaterange', 'assign', (object) [
-
 
143
                    'earliest' => userdate($earliestextension),
-
 
144
                    'latest' => userdate($lateststextension),
-
 
145
                ]);
-
 
146
            }
-
 
147
            if ($userswithoutanextension) {
-
 
148
                $currentdatesdisplay .= '<br>' . get_string('extensionduedatewithout', 'assign', $userswithoutanextension);
-
 
149
            }
-
 
150
        }
-
 
151
 
-
 
152
        $mform->addElement('static', 'currentextension', get_string('extensionduedatecurrent', 'assign'),
-
 
153
            $currentdatesdisplay);
-
 
154
 
-
 
155
        if ($lateststextension) {
-
 
156
            // If there are existing extensions, edit based on the current (latest) value.
-
 
157
            $defaultdate = $lateststextension;
-
 
158
        } else {
-
 
159
            // Otherwise take the later of the deadline and one minute before midnight tonight (server time).
-
 
160
            $endoftoday = new DateTimeImmutable('today 23:59', core_date::get_server_timezone_object());
-
 
161
            $defaultdate = max($finaldate, $endoftoday->getTimestamp());
-
 
162
        }
101
        $mform->addElement('date_time_selector', 'extensionduedate',
163
        $mform->addElement('date_time_selector', 'extensionduedate',
102
                           get_string('extensionduedate', 'assign'), array('optional'=>true));
164
                           get_string('extensionduedate', 'assign'), array('optional'=>true));
103
        $mform->setDefault('extensionduedate', $finaldate);
165
        $mform->setDefault('extensionduedate', $defaultdate);
Línea 104... Línea 166...
104
 
166
 
105
        $mform->addElement('hidden', 'id');
167
        $mform->addElement('hidden', 'id');
106
        $mform->setType('id', PARAM_INT);
168
        $mform->setType('id', PARAM_INT);
107
        $mform->addElement('hidden', 'userid');
169
        $mform->addElement('hidden', 'userid');