Proyectos de Subversion Moodle

Rev

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

Rev 1 Rev 1441
Línea 200... Línea 200...
200
     *      used if one is not passed.
200
     *      used if one is not passed.
201
     * @param number $maxmark the maximum grade for this question_attempt. If not
201
     * @param number $maxmark the maximum grade for this question_attempt. If not
202
     * passed, $question->defaultmark is used.
202
     * passed, $question->defaultmark is used.
203
     */
203
     */
204
    public function __construct(question_definition $question, $usageid,
204
    public function __construct(question_definition $question, $usageid,
205
            question_usage_observer $observer = null, $maxmark = null) {
205
            ?question_usage_observer $observer = null, $maxmark = null) {
206
        $this->question = $question;
206
        $this->question = $question;
207
        $this->questioninitialised = self::QUESTION_STATE_NOT_APPLIED;
207
        $this->questioninitialised = self::QUESTION_STATE_NOT_APPLIED;
208
        $this->usageid = $usageid;
208
        $this->usageid = $usageid;
209
        if (is_null($observer)) {
209
        if (is_null($observer)) {
210
            $observer = new question_usage_null_observer();
210
            $observer = new question_usage_null_observer();
Línea 898... Línea 898...
898
     *      (Optional. Defaults to $PAGE.)
898
     *      (Optional. Defaults to $PAGE.)
899
     * @return string HTML fragment representing the question.
899
     * @return string HTML fragment representing the question.
900
     */
900
     */
901
    public function render($options, $number, $page = null) {
901
    public function render($options, $number, $page = null) {
902
        $this->ensure_question_initialised();
902
        $this->ensure_question_initialised();
-
 
903
        $this->set_first_step_timecreated();
903
        if (is_null($page)) {
904
        if (is_null($page)) {
904
            global $PAGE;
905
            global $PAGE;
905
            $page = $PAGE;
906
            $page = $PAGE;
906
        }
907
        }
907
        if (is_null($options->versioninfo)) {
908
        if (is_null($options->versioninfo)) {
Línea 1711... Línea 1712...
1711
     *                                                      allow multiple submissions that count towards grade, per attempt.
1712
     *                                                      allow multiple submissions that count towards grade, per attempt.
1712
     */
1713
     */
1713
    public function get_steps_with_submitted_response_iterator() {
1714
    public function get_steps_with_submitted_response_iterator() {
1714
        return new question_attempt_steps_with_submitted_response_iterator($this);
1715
        return new question_attempt_steps_with_submitted_response_iterator($this);
1715
    }
1716
    }
-
 
1717
 
-
 
1718
    /**
-
 
1719
     * If the first step has a timecreated set to TIMECREATED_ON_FIRST_RENDER, set it to the current time.
-
 
1720
     *
-
 
1721
     * @return void
-
 
1722
     */
-
 
1723
    protected function set_first_step_timecreated(): void {
-
 
1724
        global $DB;
-
 
1725
        $firststep = $this->get_step(0);
-
 
1726
        if ((int)$firststep->get_timecreated() === question_attempt_step::TIMECREATED_ON_FIRST_RENDER) {
-
 
1727
            $timenow = time();
-
 
1728
            $firststep->set_timecreated($timenow);
-
 
1729
            $this->observer->notify_step_modified($firststep, $this, 0);
-
 
1730
            $DB->set_field('question_attempt_steps', 'timecreated', $timenow, ['id' => $firststep->get_id()]);
-
 
1731
        }
-
 
1732
    }
1716
}
1733
}
Línea 1717... Línea 1734...
1717
 
1734
 
1718
 
1735