Proyectos de Subversion Moodle

Rev

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

Rev 1 Rev 1441
Línea 43... Línea 43...
43
            ],
43
            ],
44
            'updated questions' => [
44
            'updated questions' => [
45
                'singular' => 'question',
45
                'singular' => 'question',
46
                'datagenerator' => 'updated_question',
46
                'datagenerator' => 'updated_question',
47
                'required' => ['question', 'questioncategory'],
47
                'required' => ['question', 'questioncategory'],
-
 
48
                'switchids' => [
-
 
49
                    'question' => 'id',
48
                'switchids' => ['question' => 'id', 'questioncategory' => 'category'],
50
                    'questioncategory' => 'category',
-
 
51
                    'modifiedbyuser' => 'modifiedby',
-
 
52
                    'createdbyuser' => 'createdby',
-
 
53
                ],
49
            ],
54
            ],
50
        ];
55
        ];
51
    }
56
    }
Línea 52... Línea 57...
52
 
57
 
Línea 64... Línea 69...
64
        }
69
        }
65
        return $id;
70
        return $id;
66
    }
71
    }
Línea 67... Línea 72...
67
 
72
 
-
 
73
    /**
-
 
74
     * Look up the id of the createdby user from their username
-
 
75
     *
-
 
76
     * @param string $username The username for the createdby user.
-
 
77
     * @return int The user ID.
-
 
78
     */
-
 
79
    protected function get_createdbyuser_id(string $username): int {
-
 
80
        return $this->get_user_id($username);
-
 
81
    }
-
 
82
 
-
 
83
    /**
-
 
84
     * Look up the id of the modifiedby user from their username
-
 
85
     *
-
 
86
     * @param string $username The username for the modifiedby user.
-
 
87
     * @return int The user ID.
-
 
88
     */
-
 
89
    protected function get_modifiedbyuser_id(string $username): int {
-
 
90
        return $this->get_user_id($username);
-
 
91
    }
-
 
92
 
68
    /**
93
    /**
69
     * Update a question
94
     * Update a question
70
     *
95
     *
71
     * This will update a question matching the supplied name with the provided data, creating a new version in the process.
96
     * This will update a question matching the supplied name with the provided data, creating a new version in the process.
72
     *
97
     *
73
     * @param array $data the row of data from the behat script.
98
     * @param array $data the row of data from the behat script.
74
     * @return void
99
     * @return void
75
     */
100
     */
76
    protected function process_updated_question(array $data): void {
101
    protected function process_updated_question(array $data): void {
77
        global $DB;
102
        global $DB;
-
 
103
        $question = $DB->get_record('question', ['id' => $data['id']], '*', MUST_EXIST);
78
        $question = $DB->get_record('question', ['id' => $data['id']], '*', MUST_EXIST);
104
        $overrides = [];
79
        foreach ($data as $key => $value) {
105
        foreach ($data as $key => $value) {
80
            $question->{$key} = $value;
106
            $overrides[$key] = $value;
Línea 81... Línea 107...
81
        }
107
        }
82
 
108
 
83
        $this->datagenerator->get_plugin_generator('core_question')->update_question($question);
109
        $this->datagenerator->get_plugin_generator('core_question')->update_question($question, overrides: $overrides);