id
int32
0
241k
repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
215,100
moodle/moodle
lib/ddl/database_manager.php
database_manager.change_field_default
public function change_field_default(xmldb_table $xmldb_table, xmldb_field $xmldb_field) { if (!$this->table_exists($xmldb_table)) { throw new ddl_table_missing_exception($xmldb_table->getName()); } // Check the field exists if (!$this->field_exists($xmldb_table, $xmldb_field)) { throw new ddl_field_missing_exception($xmldb_field->getName(), $xmldb_table->getName()); } // Check for dependencies in the DB before performing any action $this->check_field_dependencies($xmldb_table, $xmldb_field); if (!$sqlarr = $this->generator->getModifyDefaultSQL($xmldb_table, $xmldb_field)) { return; //Empty array = nothing to do = no error } $this->execute_sql_arr($sqlarr, array($xmldb_table->getName())); }
php
public function change_field_default(xmldb_table $xmldb_table, xmldb_field $xmldb_field) { if (!$this->table_exists($xmldb_table)) { throw new ddl_table_missing_exception($xmldb_table->getName()); } // Check the field exists if (!$this->field_exists($xmldb_table, $xmldb_field)) { throw new ddl_field_missing_exception($xmldb_field->getName(), $xmldb_table->getName()); } // Check for dependencies in the DB before performing any action $this->check_field_dependencies($xmldb_table, $xmldb_field); if (!$sqlarr = $this->generator->getModifyDefaultSQL($xmldb_table, $xmldb_field)) { return; //Empty array = nothing to do = no error } $this->execute_sql_arr($sqlarr, array($xmldb_table->getName())); }
[ "public", "function", "change_field_default", "(", "xmldb_table", "$", "xmldb_table", ",", "xmldb_field", "$", "xmldb_field", ")", "{", "if", "(", "!", "$", "this", "->", "table_exists", "(", "$", "xmldb_table", ")", ")", "{", "throw", "new", "ddl_table_missing_exception", "(", "$", "xmldb_table", "->", "getName", "(", ")", ")", ";", "}", "// Check the field exists", "if", "(", "!", "$", "this", "->", "field_exists", "(", "$", "xmldb_table", ",", "$", "xmldb_field", ")", ")", "{", "throw", "new", "ddl_field_missing_exception", "(", "$", "xmldb_field", "->", "getName", "(", ")", ",", "$", "xmldb_table", "->", "getName", "(", ")", ")", ";", "}", "// Check for dependencies in the DB before performing any action", "$", "this", "->", "check_field_dependencies", "(", "$", "xmldb_table", ",", "$", "xmldb_field", ")", ";", "if", "(", "!", "$", "sqlarr", "=", "$", "this", "->", "generator", "->", "getModifyDefaultSQL", "(", "$", "xmldb_table", ",", "$", "xmldb_field", ")", ")", "{", "return", ";", "//Empty array = nothing to do = no error", "}", "$", "this", "->", "execute_sql_arr", "(", "$", "sqlarr", ",", "array", "(", "$", "xmldb_table", "->", "getName", "(", ")", ")", ")", ";", "}" ]
This function will change the default of the field in the table passed as arguments One null value in the default field means delete the default @param xmldb_table $xmldb_table Table object (just the name is mandatory). @param xmldb_field $xmldb_field Index object (full specs are required). @return void
[ "This", "function", "will", "change", "the", "default", "of", "the", "field", "in", "the", "table", "passed", "as", "arguments", "One", "null", "value", "in", "the", "default", "field", "means", "delete", "the", "default" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/ddl/database_manager.php#L643-L659
215,101
moodle/moodle
lib/ddl/database_manager.php
database_manager.rename_field
public function rename_field(xmldb_table $xmldb_table, xmldb_field $xmldb_field, $newname) { if (empty($newname)) { throw new ddl_exception('ddlunknownerror', null, 'newname can not be empty'); } if (!$this->table_exists($xmldb_table)) { throw new ddl_table_missing_exception($xmldb_table->getName()); } // Check the field exists if (!$this->field_exists($xmldb_table, $xmldb_field)) { throw new ddl_field_missing_exception($xmldb_field->getName(), $xmldb_table->getName()); } // Check we have included full field specs if (!$xmldb_field->getType()) { throw new ddl_exception('ddlunknownerror', null, 'Field ' . $xmldb_table->getName() . '->' . $xmldb_field->getName() . ' must contain full specs. Rename skipped'); } // Check field isn't id. Renaming over that field is not allowed if ($xmldb_field->getName() == 'id') { throw new ddl_exception('ddlunknownerror', null, 'Field ' . $xmldb_table->getName() . '->' . $xmldb_field->getName() . ' cannot be renamed. Rename skipped'); } if (!$sqlarr = $this->generator->getRenameFieldSQL($xmldb_table, $xmldb_field, $newname)) { return; //Empty array = nothing to do = no error } $this->execute_sql_arr($sqlarr, array($xmldb_table->getName())); }
php
public function rename_field(xmldb_table $xmldb_table, xmldb_field $xmldb_field, $newname) { if (empty($newname)) { throw new ddl_exception('ddlunknownerror', null, 'newname can not be empty'); } if (!$this->table_exists($xmldb_table)) { throw new ddl_table_missing_exception($xmldb_table->getName()); } // Check the field exists if (!$this->field_exists($xmldb_table, $xmldb_field)) { throw new ddl_field_missing_exception($xmldb_field->getName(), $xmldb_table->getName()); } // Check we have included full field specs if (!$xmldb_field->getType()) { throw new ddl_exception('ddlunknownerror', null, 'Field ' . $xmldb_table->getName() . '->' . $xmldb_field->getName() . ' must contain full specs. Rename skipped'); } // Check field isn't id. Renaming over that field is not allowed if ($xmldb_field->getName() == 'id') { throw new ddl_exception('ddlunknownerror', null, 'Field ' . $xmldb_table->getName() . '->' . $xmldb_field->getName() . ' cannot be renamed. Rename skipped'); } if (!$sqlarr = $this->generator->getRenameFieldSQL($xmldb_table, $xmldb_field, $newname)) { return; //Empty array = nothing to do = no error } $this->execute_sql_arr($sqlarr, array($xmldb_table->getName())); }
[ "public", "function", "rename_field", "(", "xmldb_table", "$", "xmldb_table", ",", "xmldb_field", "$", "xmldb_field", ",", "$", "newname", ")", "{", "if", "(", "empty", "(", "$", "newname", ")", ")", "{", "throw", "new", "ddl_exception", "(", "'ddlunknownerror'", ",", "null", ",", "'newname can not be empty'", ")", ";", "}", "if", "(", "!", "$", "this", "->", "table_exists", "(", "$", "xmldb_table", ")", ")", "{", "throw", "new", "ddl_table_missing_exception", "(", "$", "xmldb_table", "->", "getName", "(", ")", ")", ";", "}", "// Check the field exists", "if", "(", "!", "$", "this", "->", "field_exists", "(", "$", "xmldb_table", ",", "$", "xmldb_field", ")", ")", "{", "throw", "new", "ddl_field_missing_exception", "(", "$", "xmldb_field", "->", "getName", "(", ")", ",", "$", "xmldb_table", "->", "getName", "(", ")", ")", ";", "}", "// Check we have included full field specs", "if", "(", "!", "$", "xmldb_field", "->", "getType", "(", ")", ")", "{", "throw", "new", "ddl_exception", "(", "'ddlunknownerror'", ",", "null", ",", "'Field '", ".", "$", "xmldb_table", "->", "getName", "(", ")", ".", "'->'", ".", "$", "xmldb_field", "->", "getName", "(", ")", ".", "' must contain full specs. Rename skipped'", ")", ";", "}", "// Check field isn't id. Renaming over that field is not allowed", "if", "(", "$", "xmldb_field", "->", "getName", "(", ")", "==", "'id'", ")", "{", "throw", "new", "ddl_exception", "(", "'ddlunknownerror'", ",", "null", ",", "'Field '", ".", "$", "xmldb_table", "->", "getName", "(", ")", ".", "'->'", ".", "$", "xmldb_field", "->", "getName", "(", ")", ".", "' cannot be renamed. Rename skipped'", ")", ";", "}", "if", "(", "!", "$", "sqlarr", "=", "$", "this", "->", "generator", "->", "getRenameFieldSQL", "(", "$", "xmldb_table", ",", "$", "xmldb_field", ",", "$", "newname", ")", ")", "{", "return", ";", "//Empty array = nothing to do = no error", "}", "$", "this", "->", "execute_sql_arr", "(", "$", "sqlarr", ",", "array", "(", "$", "xmldb_table", "->", "getName", "(", ")", ")", ")", ";", "}" ]
This function will rename the field in the table passed as arguments Before renaming the field, the function will check it exists @param xmldb_table $xmldb_table Table object (just the name is mandatory). @param xmldb_field $xmldb_field Index object (full specs are required). @param string $newname New name of the field. @return void
[ "This", "function", "will", "rename", "the", "field", "in", "the", "table", "passed", "as", "arguments", "Before", "renaming", "the", "field", "the", "function", "will", "check", "it", "exists" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/ddl/database_manager.php#L670-L703
215,102
moodle/moodle
lib/ddl/database_manager.php
database_manager.check_field_dependencies
private function check_field_dependencies(xmldb_table $xmldb_table, xmldb_field $xmldb_field) { // Check the table exists if (!$this->table_exists($xmldb_table)) { throw new ddl_table_missing_exception($xmldb_table->getName()); } // Check the field exists if (!$this->field_exists($xmldb_table, $xmldb_field)) { throw new ddl_field_missing_exception($xmldb_field->getName(), $xmldb_table->getName()); } // Check the field isn't in use by any index in the table if ($indexes = $this->mdb->get_indexes($xmldb_table->getName(), false)) { foreach ($indexes as $indexname => $index) { $columns = $index['columns']; if (in_array($xmldb_field->getName(), $columns)) { throw new ddl_dependency_exception('column', $xmldb_table->getName() . '->' . $xmldb_field->getName(), 'index', $indexname . ' (' . implode(', ', $columns) . ')'); } } } }
php
private function check_field_dependencies(xmldb_table $xmldb_table, xmldb_field $xmldb_field) { // Check the table exists if (!$this->table_exists($xmldb_table)) { throw new ddl_table_missing_exception($xmldb_table->getName()); } // Check the field exists if (!$this->field_exists($xmldb_table, $xmldb_field)) { throw new ddl_field_missing_exception($xmldb_field->getName(), $xmldb_table->getName()); } // Check the field isn't in use by any index in the table if ($indexes = $this->mdb->get_indexes($xmldb_table->getName(), false)) { foreach ($indexes as $indexname => $index) { $columns = $index['columns']; if (in_array($xmldb_field->getName(), $columns)) { throw new ddl_dependency_exception('column', $xmldb_table->getName() . '->' . $xmldb_field->getName(), 'index', $indexname . ' (' . implode(', ', $columns) . ')'); } } } }
[ "private", "function", "check_field_dependencies", "(", "xmldb_table", "$", "xmldb_table", ",", "xmldb_field", "$", "xmldb_field", ")", "{", "// Check the table exists", "if", "(", "!", "$", "this", "->", "table_exists", "(", "$", "xmldb_table", ")", ")", "{", "throw", "new", "ddl_table_missing_exception", "(", "$", "xmldb_table", "->", "getName", "(", ")", ")", ";", "}", "// Check the field exists", "if", "(", "!", "$", "this", "->", "field_exists", "(", "$", "xmldb_table", ",", "$", "xmldb_field", ")", ")", "{", "throw", "new", "ddl_field_missing_exception", "(", "$", "xmldb_field", "->", "getName", "(", ")", ",", "$", "xmldb_table", "->", "getName", "(", ")", ")", ";", "}", "// Check the field isn't in use by any index in the table", "if", "(", "$", "indexes", "=", "$", "this", "->", "mdb", "->", "get_indexes", "(", "$", "xmldb_table", "->", "getName", "(", ")", ",", "false", ")", ")", "{", "foreach", "(", "$", "indexes", "as", "$", "indexname", "=>", "$", "index", ")", "{", "$", "columns", "=", "$", "index", "[", "'columns'", "]", ";", "if", "(", "in_array", "(", "$", "xmldb_field", "->", "getName", "(", ")", ",", "$", "columns", ")", ")", "{", "throw", "new", "ddl_dependency_exception", "(", "'column'", ",", "$", "xmldb_table", "->", "getName", "(", ")", ".", "'->'", ".", "$", "xmldb_field", "->", "getName", "(", ")", ",", "'index'", ",", "$", "indexname", ".", "' ('", ".", "implode", "(", "', '", ",", "$", "columns", ")", ".", "')'", ")", ";", "}", "}", "}", "}" ]
This function will check, for the given table and field, if there there is any dependency preventing the field to be modified. It's used by all the public methods that perform any DDL change on fields, throwing one ddl_dependency_exception if dependencies are found. @param xmldb_table $xmldb_table Table object (just the name is mandatory). @param xmldb_field $xmldb_field Index object (full specs are required). @return void @throws ddl_dependency_exception|ddl_field_missing_exception|ddl_table_missing_exception if dependency not met.
[ "This", "function", "will", "check", "for", "the", "given", "table", "and", "field", "if", "there", "there", "is", "any", "dependency", "preventing", "the", "field", "to", "be", "modified", ".", "It", "s", "used", "by", "all", "the", "public", "methods", "that", "perform", "any", "DDL", "change", "on", "fields", "throwing", "one", "ddl_dependency_exception", "if", "dependencies", "are", "found", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/ddl/database_manager.php#L715-L737
215,103
moodle/moodle
lib/ddl/database_manager.php
database_manager.add_key
public function add_key(xmldb_table $xmldb_table, xmldb_key $xmldb_key) { if ($xmldb_key->getType() == XMLDB_KEY_PRIMARY) { // Prevent PRIMARY to be added (only in create table, being serious :-P) throw new ddl_exception('ddlunknownerror', null, 'Primary Keys can be added at table create time only'); } if (!$sqlarr = $this->generator->getAddKeySQL($xmldb_table, $xmldb_key)) { return; //Empty array = nothing to do = no error } $this->execute_sql_arr($sqlarr, array($xmldb_table->getName())); }
php
public function add_key(xmldb_table $xmldb_table, xmldb_key $xmldb_key) { if ($xmldb_key->getType() == XMLDB_KEY_PRIMARY) { // Prevent PRIMARY to be added (only in create table, being serious :-P) throw new ddl_exception('ddlunknownerror', null, 'Primary Keys can be added at table create time only'); } if (!$sqlarr = $this->generator->getAddKeySQL($xmldb_table, $xmldb_key)) { return; //Empty array = nothing to do = no error } $this->execute_sql_arr($sqlarr, array($xmldb_table->getName())); }
[ "public", "function", "add_key", "(", "xmldb_table", "$", "xmldb_table", ",", "xmldb_key", "$", "xmldb_key", ")", "{", "if", "(", "$", "xmldb_key", "->", "getType", "(", ")", "==", "XMLDB_KEY_PRIMARY", ")", "{", "// Prevent PRIMARY to be added (only in create table, being serious :-P)", "throw", "new", "ddl_exception", "(", "'ddlunknownerror'", ",", "null", ",", "'Primary Keys can be added at table create time only'", ")", ";", "}", "if", "(", "!", "$", "sqlarr", "=", "$", "this", "->", "generator", "->", "getAddKeySQL", "(", "$", "xmldb_table", ",", "$", "xmldb_key", ")", ")", "{", "return", ";", "//Empty array = nothing to do = no error", "}", "$", "this", "->", "execute_sql_arr", "(", "$", "sqlarr", ",", "array", "(", "$", "xmldb_table", "->", "getName", "(", ")", ")", ")", ";", "}" ]
This function will create the key in the table passed as arguments @param xmldb_table $xmldb_table Table object (just the name is mandatory). @param xmldb_key $xmldb_key Index object (full specs are required). @return void
[ "This", "function", "will", "create", "the", "key", "in", "the", "table", "passed", "as", "arguments" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/ddl/database_manager.php#L746-L757
215,104
moodle/moodle
lib/ddl/database_manager.php
database_manager.drop_key
public function drop_key(xmldb_table $xmldb_table, xmldb_key $xmldb_key) { if ($xmldb_key->getType() == XMLDB_KEY_PRIMARY) { // Prevent PRIMARY to be dropped (only in drop table, being serious :-P) throw new ddl_exception('ddlunknownerror', null, 'Primary Keys can be deleted at table drop time only'); } if (!$sqlarr = $this->generator->getDropKeySQL($xmldb_table, $xmldb_key)) { return; //Empty array = nothing to do = no error } $this->execute_sql_arr($sqlarr, array($xmldb_table->getName())); }
php
public function drop_key(xmldb_table $xmldb_table, xmldb_key $xmldb_key) { if ($xmldb_key->getType() == XMLDB_KEY_PRIMARY) { // Prevent PRIMARY to be dropped (only in drop table, being serious :-P) throw new ddl_exception('ddlunknownerror', null, 'Primary Keys can be deleted at table drop time only'); } if (!$sqlarr = $this->generator->getDropKeySQL($xmldb_table, $xmldb_key)) { return; //Empty array = nothing to do = no error } $this->execute_sql_arr($sqlarr, array($xmldb_table->getName())); }
[ "public", "function", "drop_key", "(", "xmldb_table", "$", "xmldb_table", ",", "xmldb_key", "$", "xmldb_key", ")", "{", "if", "(", "$", "xmldb_key", "->", "getType", "(", ")", "==", "XMLDB_KEY_PRIMARY", ")", "{", "// Prevent PRIMARY to be dropped (only in drop table, being serious :-P)", "throw", "new", "ddl_exception", "(", "'ddlunknownerror'", ",", "null", ",", "'Primary Keys can be deleted at table drop time only'", ")", ";", "}", "if", "(", "!", "$", "sqlarr", "=", "$", "this", "->", "generator", "->", "getDropKeySQL", "(", "$", "xmldb_table", ",", "$", "xmldb_key", ")", ")", "{", "return", ";", "//Empty array = nothing to do = no error", "}", "$", "this", "->", "execute_sql_arr", "(", "$", "sqlarr", ",", "array", "(", "$", "xmldb_table", "->", "getName", "(", ")", ")", ")", ";", "}" ]
This function will drop the key in the table passed as arguments @param xmldb_table $xmldb_table Table object (just the name is mandatory). @param xmldb_key $xmldb_key Key object (full specs are required). @return void
[ "This", "function", "will", "drop", "the", "key", "in", "the", "table", "passed", "as", "arguments" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/ddl/database_manager.php#L766-L776
215,105
moodle/moodle
lib/ddl/database_manager.php
database_manager.add_index
public function add_index($xmldb_table, $xmldb_intex) { if (!$this->table_exists($xmldb_table)) { throw new ddl_table_missing_exception($xmldb_table->getName()); } // Check index doesn't exist if ($this->index_exists($xmldb_table, $xmldb_intex)) { throw new ddl_exception('ddlunknownerror', null, 'Index ' . $xmldb_table->getName() . '->' . $xmldb_intex->getName() . ' already exists. Create skipped'); } if (!$sqlarr = $this->generator->getAddIndexSQL($xmldb_table, $xmldb_intex)) { throw new ddl_exception('ddlunknownerror', null, 'add_index sql not generated'); } try { $this->execute_sql_arr($sqlarr, array($xmldb_table->getName())); } catch (ddl_change_structure_exception $e) { // There could be a problem with the index length related to the row format of the table. // If we are using utf8mb4 and the row format is 'compact' or 'redundant' then we need to change it over to // 'compressed' or 'dynamic'. if (method_exists($this->mdb, 'convert_table_row_format')) { $this->mdb->convert_table_row_format($xmldb_table->getName()); $this->execute_sql_arr($sqlarr, array($xmldb_table->getName())); } else { // It's some other problem that we are currently not handling. throw $e; } } }
php
public function add_index($xmldb_table, $xmldb_intex) { if (!$this->table_exists($xmldb_table)) { throw new ddl_table_missing_exception($xmldb_table->getName()); } // Check index doesn't exist if ($this->index_exists($xmldb_table, $xmldb_intex)) { throw new ddl_exception('ddlunknownerror', null, 'Index ' . $xmldb_table->getName() . '->' . $xmldb_intex->getName() . ' already exists. Create skipped'); } if (!$sqlarr = $this->generator->getAddIndexSQL($xmldb_table, $xmldb_intex)) { throw new ddl_exception('ddlunknownerror', null, 'add_index sql not generated'); } try { $this->execute_sql_arr($sqlarr, array($xmldb_table->getName())); } catch (ddl_change_structure_exception $e) { // There could be a problem with the index length related to the row format of the table. // If we are using utf8mb4 and the row format is 'compact' or 'redundant' then we need to change it over to // 'compressed' or 'dynamic'. if (method_exists($this->mdb, 'convert_table_row_format')) { $this->mdb->convert_table_row_format($xmldb_table->getName()); $this->execute_sql_arr($sqlarr, array($xmldb_table->getName())); } else { // It's some other problem that we are currently not handling. throw $e; } } }
[ "public", "function", "add_index", "(", "$", "xmldb_table", ",", "$", "xmldb_intex", ")", "{", "if", "(", "!", "$", "this", "->", "table_exists", "(", "$", "xmldb_table", ")", ")", "{", "throw", "new", "ddl_table_missing_exception", "(", "$", "xmldb_table", "->", "getName", "(", ")", ")", ";", "}", "// Check index doesn't exist", "if", "(", "$", "this", "->", "index_exists", "(", "$", "xmldb_table", ",", "$", "xmldb_intex", ")", ")", "{", "throw", "new", "ddl_exception", "(", "'ddlunknownerror'", ",", "null", ",", "'Index '", ".", "$", "xmldb_table", "->", "getName", "(", ")", ".", "'->'", ".", "$", "xmldb_intex", "->", "getName", "(", ")", ".", "' already exists. Create skipped'", ")", ";", "}", "if", "(", "!", "$", "sqlarr", "=", "$", "this", "->", "generator", "->", "getAddIndexSQL", "(", "$", "xmldb_table", ",", "$", "xmldb_intex", ")", ")", "{", "throw", "new", "ddl_exception", "(", "'ddlunknownerror'", ",", "null", ",", "'add_index sql not generated'", ")", ";", "}", "try", "{", "$", "this", "->", "execute_sql_arr", "(", "$", "sqlarr", ",", "array", "(", "$", "xmldb_table", "->", "getName", "(", ")", ")", ")", ";", "}", "catch", "(", "ddl_change_structure_exception", "$", "e", ")", "{", "// There could be a problem with the index length related to the row format of the table.", "// If we are using utf8mb4 and the row format is 'compact' or 'redundant' then we need to change it over to", "// 'compressed' or 'dynamic'.", "if", "(", "method_exists", "(", "$", "this", "->", "mdb", ",", "'convert_table_row_format'", ")", ")", "{", "$", "this", "->", "mdb", "->", "convert_table_row_format", "(", "$", "xmldb_table", "->", "getName", "(", ")", ")", ";", "$", "this", "->", "execute_sql_arr", "(", "$", "sqlarr", ",", "array", "(", "$", "xmldb_table", "->", "getName", "(", ")", ")", ")", ";", "}", "else", "{", "// It's some other problem that we are currently not handling.", "throw", "$", "e", ";", "}", "}", "}" ]
This function will create the index in the table passed as arguments Before creating the index, the function will check it doesn't exists @param xmldb_table $xmldb_table Table object (just the name is mandatory). @param xmldb_index $xmldb_intex Index object (full specs are required). @return void
[ "This", "function", "will", "create", "the", "index", "in", "the", "table", "passed", "as", "arguments", "Before", "creating", "the", "index", "the", "function", "will", "check", "it", "doesn", "t", "exists" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/ddl/database_manager.php#L810-L840
215,106
moodle/moodle
lib/ddl/database_manager.php
database_manager.drop_index
public function drop_index($xmldb_table, $xmldb_intex) { if (!$this->table_exists($xmldb_table)) { throw new ddl_table_missing_exception($xmldb_table->getName()); } // Check index exists if (!$this->index_exists($xmldb_table, $xmldb_intex)) { throw new ddl_exception('ddlunknownerror', null, 'Index ' . $xmldb_table->getName() . '->' . $xmldb_intex->getName() . ' does not exist. Drop skipped'); } if (!$sqlarr = $this->generator->getDropIndexSQL($xmldb_table, $xmldb_intex)) { throw new ddl_exception('ddlunknownerror', null, 'drop_index sql not generated'); } $this->execute_sql_arr($sqlarr, array($xmldb_table->getName())); }
php
public function drop_index($xmldb_table, $xmldb_intex) { if (!$this->table_exists($xmldb_table)) { throw new ddl_table_missing_exception($xmldb_table->getName()); } // Check index exists if (!$this->index_exists($xmldb_table, $xmldb_intex)) { throw new ddl_exception('ddlunknownerror', null, 'Index ' . $xmldb_table->getName() . '->' . $xmldb_intex->getName() . ' does not exist. Drop skipped'); } if (!$sqlarr = $this->generator->getDropIndexSQL($xmldb_table, $xmldb_intex)) { throw new ddl_exception('ddlunknownerror', null, 'drop_index sql not generated'); } $this->execute_sql_arr($sqlarr, array($xmldb_table->getName())); }
[ "public", "function", "drop_index", "(", "$", "xmldb_table", ",", "$", "xmldb_intex", ")", "{", "if", "(", "!", "$", "this", "->", "table_exists", "(", "$", "xmldb_table", ")", ")", "{", "throw", "new", "ddl_table_missing_exception", "(", "$", "xmldb_table", "->", "getName", "(", ")", ")", ";", "}", "// Check index exists", "if", "(", "!", "$", "this", "->", "index_exists", "(", "$", "xmldb_table", ",", "$", "xmldb_intex", ")", ")", "{", "throw", "new", "ddl_exception", "(", "'ddlunknownerror'", ",", "null", ",", "'Index '", ".", "$", "xmldb_table", "->", "getName", "(", ")", ".", "'->'", ".", "$", "xmldb_intex", "->", "getName", "(", ")", ".", "' does not exist. Drop skipped'", ")", ";", "}", "if", "(", "!", "$", "sqlarr", "=", "$", "this", "->", "generator", "->", "getDropIndexSQL", "(", "$", "xmldb_table", ",", "$", "xmldb_intex", ")", ")", "{", "throw", "new", "ddl_exception", "(", "'ddlunknownerror'", ",", "null", ",", "'drop_index sql not generated'", ")", ";", "}", "$", "this", "->", "execute_sql_arr", "(", "$", "sqlarr", ",", "array", "(", "$", "xmldb_table", "->", "getName", "(", ")", ")", ")", ";", "}" ]
This function will drop the index in the table passed as arguments Before dropping the index, the function will check it exists @param xmldb_table $xmldb_table Table object (just the name is mandatory). @param xmldb_index $xmldb_intex Index object (full specs are required). @return void
[ "This", "function", "will", "drop", "the", "index", "in", "the", "table", "passed", "as", "arguments", "Before", "dropping", "the", "index", "the", "function", "will", "check", "it", "exists" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/ddl/database_manager.php#L850-L867
215,107
moodle/moodle
lib/ddl/database_manager.php
database_manager.rename_index
public function rename_index($xmldb_table, $xmldb_intex, $newname) { debugging('rename_index() is one experimental feature. You must not use it in production!', DEBUG_DEVELOPER); // Check newname isn't empty if (!$newname) { throw new ddl_exception('ddlunknownerror', null, 'newname can not be empty'); } // Check index exists if (!$this->index_exists($xmldb_table, $xmldb_intex)) { throw new ddl_exception('ddlunknownerror', null, 'Index ' . $xmldb_table->getName() . '->' . $xmldb_intex->getName() . ' does not exist. Rename skipped'); } if (!$sqlarr = $this->generator->getRenameIndexSQL($xmldb_table, $xmldb_intex, $newname)) { throw new ddl_exception('ddlunknownerror', null, 'Some DBs do not support index renaming (MySQL). Rename skipped'); } $this->execute_sql_arr($sqlarr, array($xmldb_table->getName())); }
php
public function rename_index($xmldb_table, $xmldb_intex, $newname) { debugging('rename_index() is one experimental feature. You must not use it in production!', DEBUG_DEVELOPER); // Check newname isn't empty if (!$newname) { throw new ddl_exception('ddlunknownerror', null, 'newname can not be empty'); } // Check index exists if (!$this->index_exists($xmldb_table, $xmldb_intex)) { throw new ddl_exception('ddlunknownerror', null, 'Index ' . $xmldb_table->getName() . '->' . $xmldb_intex->getName() . ' does not exist. Rename skipped'); } if (!$sqlarr = $this->generator->getRenameIndexSQL($xmldb_table, $xmldb_intex, $newname)) { throw new ddl_exception('ddlunknownerror', null, 'Some DBs do not support index renaming (MySQL). Rename skipped'); } $this->execute_sql_arr($sqlarr, array($xmldb_table->getName())); }
[ "public", "function", "rename_index", "(", "$", "xmldb_table", ",", "$", "xmldb_intex", ",", "$", "newname", ")", "{", "debugging", "(", "'rename_index() is one experimental feature. You must not use it in production!'", ",", "DEBUG_DEVELOPER", ")", ";", "// Check newname isn't empty", "if", "(", "!", "$", "newname", ")", "{", "throw", "new", "ddl_exception", "(", "'ddlunknownerror'", ",", "null", ",", "'newname can not be empty'", ")", ";", "}", "// Check index exists", "if", "(", "!", "$", "this", "->", "index_exists", "(", "$", "xmldb_table", ",", "$", "xmldb_intex", ")", ")", "{", "throw", "new", "ddl_exception", "(", "'ddlunknownerror'", ",", "null", ",", "'Index '", ".", "$", "xmldb_table", "->", "getName", "(", ")", ".", "'->'", ".", "$", "xmldb_intex", "->", "getName", "(", ")", ".", "' does not exist. Rename skipped'", ")", ";", "}", "if", "(", "!", "$", "sqlarr", "=", "$", "this", "->", "generator", "->", "getRenameIndexSQL", "(", "$", "xmldb_table", ",", "$", "xmldb_intex", ",", "$", "newname", ")", ")", "{", "throw", "new", "ddl_exception", "(", "'ddlunknownerror'", ",", "null", ",", "'Some DBs do not support index renaming (MySQL). Rename skipped'", ")", ";", "}", "$", "this", "->", "execute_sql_arr", "(", "$", "sqlarr", ",", "array", "(", "$", "xmldb_table", "->", "getName", "(", ")", ")", ")", ";", "}" ]
This function will rename the index in the table passed as arguments Before renaming the index, the function will check it exists Experimental. Shouldn't be used at all! @param xmldb_table $xmldb_table Table object (just the name is mandatory). @param xmldb_index $xmldb_intex Index object (full specs are required). @param string $newname New name of the index. @return void
[ "This", "function", "will", "rename", "the", "index", "in", "the", "table", "passed", "as", "arguments", "Before", "renaming", "the", "index", "the", "function", "will", "check", "it", "exists", "Experimental", ".", "Shouldn", "t", "be", "used", "at", "all!" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/ddl/database_manager.php#L879-L899
215,108
moodle/moodle
lib/ddl/database_manager.php
database_manager.get_install_xml_files
public function get_install_xml_files(): array { global $CFG; require_once($CFG->libdir.'/adminlib.php'); $files = []; $dbdirs = get_db_directories(); foreach ($dbdirs as $dbdir) { $filename = "{$dbdir}/install.xml"; if (file_exists($filename)) { $files[] = $filename; } } return $files; }
php
public function get_install_xml_files(): array { global $CFG; require_once($CFG->libdir.'/adminlib.php'); $files = []; $dbdirs = get_db_directories(); foreach ($dbdirs as $dbdir) { $filename = "{$dbdir}/install.xml"; if (file_exists($filename)) { $files[] = $filename; } } return $files; }
[ "public", "function", "get_install_xml_files", "(", ")", ":", "array", "{", "global", "$", "CFG", ";", "require_once", "(", "$", "CFG", "->", "libdir", ".", "'/adminlib.php'", ")", ";", "$", "files", "=", "[", "]", ";", "$", "dbdirs", "=", "get_db_directories", "(", ")", ";", "foreach", "(", "$", "dbdirs", "as", "$", "dbdir", ")", "{", "$", "filename", "=", "\"{$dbdir}/install.xml\"", ";", "if", "(", "file_exists", "(", "$", "filename", ")", ")", "{", "$", "files", "[", "]", "=", "$", "filename", ";", "}", "}", "return", "$", "files", ";", "}" ]
Get the list of install.xml files. @return array
[ "Get", "the", "list", "of", "install", ".", "xml", "files", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/ddl/database_manager.php#L906-L920
215,109
moodle/moodle
lib/ddl/database_manager.php
database_manager.get_install_xml_schema
public function get_install_xml_schema() { global $CFG; require_once($CFG->libdir.'/adminlib.php'); $schema = new xmldb_structure('export'); $schema->setVersion($CFG->version); foreach ($this->get_install_xml_files() as $filename) { $xmldb_file = new xmldb_file($filename); if (!$xmldb_file->loadXMLStructure()) { continue; } $structure = $xmldb_file->getStructure(); $tables = $structure->getTables(); foreach ($tables as $table) { $table->setPrevious(null); $table->setNext(null); $schema->addTable($table); } } return $schema; }
php
public function get_install_xml_schema() { global $CFG; require_once($CFG->libdir.'/adminlib.php'); $schema = new xmldb_structure('export'); $schema->setVersion($CFG->version); foreach ($this->get_install_xml_files() as $filename) { $xmldb_file = new xmldb_file($filename); if (!$xmldb_file->loadXMLStructure()) { continue; } $structure = $xmldb_file->getStructure(); $tables = $structure->getTables(); foreach ($tables as $table) { $table->setPrevious(null); $table->setNext(null); $schema->addTable($table); } } return $schema; }
[ "public", "function", "get_install_xml_schema", "(", ")", "{", "global", "$", "CFG", ";", "require_once", "(", "$", "CFG", "->", "libdir", ".", "'/adminlib.php'", ")", ";", "$", "schema", "=", "new", "xmldb_structure", "(", "'export'", ")", ";", "$", "schema", "->", "setVersion", "(", "$", "CFG", "->", "version", ")", ";", "foreach", "(", "$", "this", "->", "get_install_xml_files", "(", ")", "as", "$", "filename", ")", "{", "$", "xmldb_file", "=", "new", "xmldb_file", "(", "$", "filename", ")", ";", "if", "(", "!", "$", "xmldb_file", "->", "loadXMLStructure", "(", ")", ")", "{", "continue", ";", "}", "$", "structure", "=", "$", "xmldb_file", "->", "getStructure", "(", ")", ";", "$", "tables", "=", "$", "structure", "->", "getTables", "(", ")", ";", "foreach", "(", "$", "tables", "as", "$", "table", ")", "{", "$", "table", "->", "setPrevious", "(", "null", ")", ";", "$", "table", "->", "setNext", "(", "null", ")", ";", "$", "schema", "->", "addTable", "(", "$", "table", ")", ";", "}", "}", "return", "$", "schema", ";", "}" ]
Reads the install.xml files for Moodle core and modules and returns an array of xmldb_structure object with xmldb_table from these files. @return xmldb_structure schema from install.xml files
[ "Reads", "the", "install", ".", "xml", "files", "for", "Moodle", "core", "and", "modules", "and", "returns", "an", "array", "of", "xmldb_structure", "object", "with", "xmldb_table", "from", "these", "files", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/ddl/database_manager.php#L927-L948
215,110
moodle/moodle
mod/forum/classes/local/vaults/discussion.php
discussion.get_first_discussion_in_forum
public function get_first_discussion_in_forum(forum_entity $forum) : ?discussion_entity { $records = $this->get_db()->get_records(self::TABLE, [ 'forum' => $forum->get_id(), ], 'timemodified ASC', '*', 0, 1); $records = $this->transform_db_records_to_entities($records); return count($records) ? array_shift($records) : null; }
php
public function get_first_discussion_in_forum(forum_entity $forum) : ?discussion_entity { $records = $this->get_db()->get_records(self::TABLE, [ 'forum' => $forum->get_id(), ], 'timemodified ASC', '*', 0, 1); $records = $this->transform_db_records_to_entities($records); return count($records) ? array_shift($records) : null; }
[ "public", "function", "get_first_discussion_in_forum", "(", "forum_entity", "$", "forum", ")", ":", "?", "discussion_entity", "{", "$", "records", "=", "$", "this", "->", "get_db", "(", ")", "->", "get_records", "(", "self", "::", "TABLE", ",", "[", "'forum'", "=>", "$", "forum", "->", "get_id", "(", ")", ",", "]", ",", "'timemodified ASC'", ",", "'*'", ",", "0", ",", "1", ")", ";", "$", "records", "=", "$", "this", "->", "transform_db_records_to_entities", "(", "$", "records", ")", ";", "return", "count", "(", "$", "records", ")", "?", "array_shift", "(", "$", "records", ")", ":", "null", ";", "}" ]
Get the first discussion in the specified forum. @param forum_entity $forum @return discussion_entity|null
[ "Get", "the", "first", "discussion", "in", "the", "specified", "forum", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/forum/classes/local/vaults/discussion.php#L95-L102
215,111
moodle/moodle
mod/forum/classes/local/vaults/discussion.php
discussion.get_count_discussions_in_forum
public function get_count_discussions_in_forum(forum_entity $forum) : ?int { return $this->get_db()->count_records(self::TABLE, [ 'forum' => $forum->get_id()]); }
php
public function get_count_discussions_in_forum(forum_entity $forum) : ?int { return $this->get_db()->count_records(self::TABLE, [ 'forum' => $forum->get_id()]); }
[ "public", "function", "get_count_discussions_in_forum", "(", "forum_entity", "$", "forum", ")", ":", "?", "int", "{", "return", "$", "this", "->", "get_db", "(", ")", "->", "count_records", "(", "self", "::", "TABLE", ",", "[", "'forum'", "=>", "$", "forum", "->", "get_id", "(", ")", "]", ")", ";", "}" ]
Get the count of the discussions in the specified forum. @param forum_entity $forum @return int
[ "Get", "the", "count", "of", "the", "discussions", "in", "the", "specified", "forum", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/forum/classes/local/vaults/discussion.php#L125-L128
215,112
moodle/moodle
mod/forum/classes/local/vaults/discussion.php
discussion.update_discussion
public function update_discussion(discussion_entity $discussion) : ?discussion_entity { $discussionrecord = $this->get_legacy_factory()->to_legacy_object($discussion); if ($this->get_db()->update_record('forum_discussions', $discussionrecord)) { $records = $this->transform_db_records_to_entities([$discussionrecord]); return count($records) ? array_shift($records) : null; } return null; }
php
public function update_discussion(discussion_entity $discussion) : ?discussion_entity { $discussionrecord = $this->get_legacy_factory()->to_legacy_object($discussion); if ($this->get_db()->update_record('forum_discussions', $discussionrecord)) { $records = $this->transform_db_records_to_entities([$discussionrecord]); return count($records) ? array_shift($records) : null; } return null; }
[ "public", "function", "update_discussion", "(", "discussion_entity", "$", "discussion", ")", ":", "?", "discussion_entity", "{", "$", "discussionrecord", "=", "$", "this", "->", "get_legacy_factory", "(", ")", "->", "to_legacy_object", "(", "$", "discussion", ")", ";", "if", "(", "$", "this", "->", "get_db", "(", ")", "->", "update_record", "(", "'forum_discussions'", ",", "$", "discussionrecord", ")", ")", "{", "$", "records", "=", "$", "this", "->", "transform_db_records_to_entities", "(", "[", "$", "discussionrecord", "]", ")", ";", "return", "count", "(", "$", "records", ")", "?", "array_shift", "(", "$", "records", ")", ":", "null", ";", "}", "return", "null", ";", "}" ]
Update the discussion @param discussion_entity $discussion @return discussion_entity|null
[ "Update", "the", "discussion" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/forum/classes/local/vaults/discussion.php#L136-L145
215,113
moodle/moodle
user/profile/field/datetime/field.class.php
profile_field_datetime.edit_field_add
public function edit_field_add($mform) { // Get the current calendar in use - see MDL-18375. $calendartype = \core_calendar\type_factory::get_calendar_instance(); // Check if the field is required. if ($this->field->required) { $optional = false; } else { $optional = true; } // Convert the year stored in the DB as gregorian to that used by the calendar type. $startdate = $calendartype->convert_from_gregorian($this->field->param1, 1, 1); $stopdate = $calendartype->convert_from_gregorian($this->field->param2, 1, 1); $attributes = array( 'startyear' => $startdate['year'], 'stopyear' => $stopdate['year'], 'optional' => $optional ); // Check if they wanted to include time as well. if (!empty($this->field->param3)) { $mform->addElement('date_time_selector', $this->inputname, format_string($this->field->name), $attributes); } else { $mform->addElement('date_selector', $this->inputname, format_string($this->field->name), $attributes); } $mform->setType($this->inputname, PARAM_INT); $mform->setDefault($this->inputname, time()); }
php
public function edit_field_add($mform) { // Get the current calendar in use - see MDL-18375. $calendartype = \core_calendar\type_factory::get_calendar_instance(); // Check if the field is required. if ($this->field->required) { $optional = false; } else { $optional = true; } // Convert the year stored in the DB as gregorian to that used by the calendar type. $startdate = $calendartype->convert_from_gregorian($this->field->param1, 1, 1); $stopdate = $calendartype->convert_from_gregorian($this->field->param2, 1, 1); $attributes = array( 'startyear' => $startdate['year'], 'stopyear' => $stopdate['year'], 'optional' => $optional ); // Check if they wanted to include time as well. if (!empty($this->field->param3)) { $mform->addElement('date_time_selector', $this->inputname, format_string($this->field->name), $attributes); } else { $mform->addElement('date_selector', $this->inputname, format_string($this->field->name), $attributes); } $mform->setType($this->inputname, PARAM_INT); $mform->setDefault($this->inputname, time()); }
[ "public", "function", "edit_field_add", "(", "$", "mform", ")", "{", "// Get the current calendar in use - see MDL-18375.", "$", "calendartype", "=", "\\", "core_calendar", "\\", "type_factory", "::", "get_calendar_instance", "(", ")", ";", "// Check if the field is required.", "if", "(", "$", "this", "->", "field", "->", "required", ")", "{", "$", "optional", "=", "false", ";", "}", "else", "{", "$", "optional", "=", "true", ";", "}", "// Convert the year stored in the DB as gregorian to that used by the calendar type.", "$", "startdate", "=", "$", "calendartype", "->", "convert_from_gregorian", "(", "$", "this", "->", "field", "->", "param1", ",", "1", ",", "1", ")", ";", "$", "stopdate", "=", "$", "calendartype", "->", "convert_from_gregorian", "(", "$", "this", "->", "field", "->", "param2", ",", "1", ",", "1", ")", ";", "$", "attributes", "=", "array", "(", "'startyear'", "=>", "$", "startdate", "[", "'year'", "]", ",", "'stopyear'", "=>", "$", "stopdate", "[", "'year'", "]", ",", "'optional'", "=>", "$", "optional", ")", ";", "// Check if they wanted to include time as well.", "if", "(", "!", "empty", "(", "$", "this", "->", "field", "->", "param3", ")", ")", "{", "$", "mform", "->", "addElement", "(", "'date_time_selector'", ",", "$", "this", "->", "inputname", ",", "format_string", "(", "$", "this", "->", "field", "->", "name", ")", ",", "$", "attributes", ")", ";", "}", "else", "{", "$", "mform", "->", "addElement", "(", "'date_selector'", ",", "$", "this", "->", "inputname", ",", "format_string", "(", "$", "this", "->", "field", "->", "name", ")", ",", "$", "attributes", ")", ";", "}", "$", "mform", "->", "setType", "(", "$", "this", "->", "inputname", ",", "PARAM_INT", ")", ";", "$", "mform", "->", "setDefault", "(", "$", "this", "->", "inputname", ",", "time", "(", ")", ")", ";", "}" ]
Handles editing datetime fields. @param moodleform $mform
[ "Handles", "editing", "datetime", "fields", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/user/profile/field/datetime/field.class.php#L38-L68
215,114
moodle/moodle
user/profile/field/datetime/field.class.php
profile_field_datetime.edit_save_data_preprocess
public function edit_save_data_preprocess($datetime, $datarecord) { if (!$datetime) { return 0; } if (is_numeric($datetime)) { $gregoriancalendar = \core_calendar\type_factory::get_calendar_instance('gregorian'); $datetime = $gregoriancalendar->timestamp_to_date_string($datetime, '%Y-%m-%d-%H-%M-%S', 99, true, true); } $datetime = explode('-', $datetime); // Bound year with start and end year. $datetime[0] = min(max($datetime[0], $this->field->param1), $this->field->param2); if (!empty($this->field->param3) && count($datetime) == 6) { return make_timestamp($datetime[0], $datetime[1], $datetime[2], $datetime[3], $datetime[4], $datetime[5]); } else { return make_timestamp($datetime[0], $datetime[1], $datetime[2]); } }
php
public function edit_save_data_preprocess($datetime, $datarecord) { if (!$datetime) { return 0; } if (is_numeric($datetime)) { $gregoriancalendar = \core_calendar\type_factory::get_calendar_instance('gregorian'); $datetime = $gregoriancalendar->timestamp_to_date_string($datetime, '%Y-%m-%d-%H-%M-%S', 99, true, true); } $datetime = explode('-', $datetime); // Bound year with start and end year. $datetime[0] = min(max($datetime[0], $this->field->param1), $this->field->param2); if (!empty($this->field->param3) && count($datetime) == 6) { return make_timestamp($datetime[0], $datetime[1], $datetime[2], $datetime[3], $datetime[4], $datetime[5]); } else { return make_timestamp($datetime[0], $datetime[1], $datetime[2]); } }
[ "public", "function", "edit_save_data_preprocess", "(", "$", "datetime", ",", "$", "datarecord", ")", "{", "if", "(", "!", "$", "datetime", ")", "{", "return", "0", ";", "}", "if", "(", "is_numeric", "(", "$", "datetime", ")", ")", "{", "$", "gregoriancalendar", "=", "\\", "core_calendar", "\\", "type_factory", "::", "get_calendar_instance", "(", "'gregorian'", ")", ";", "$", "datetime", "=", "$", "gregoriancalendar", "->", "timestamp_to_date_string", "(", "$", "datetime", ",", "'%Y-%m-%d-%H-%M-%S'", ",", "99", ",", "true", ",", "true", ")", ";", "}", "$", "datetime", "=", "explode", "(", "'-'", ",", "$", "datetime", ")", ";", "// Bound year with start and end year.", "$", "datetime", "[", "0", "]", "=", "min", "(", "max", "(", "$", "datetime", "[", "0", "]", ",", "$", "this", "->", "field", "->", "param1", ")", ",", "$", "this", "->", "field", "->", "param2", ")", ";", "if", "(", "!", "empty", "(", "$", "this", "->", "field", "->", "param3", ")", "&&", "count", "(", "$", "datetime", ")", "==", "6", ")", "{", "return", "make_timestamp", "(", "$", "datetime", "[", "0", "]", ",", "$", "datetime", "[", "1", "]", ",", "$", "datetime", "[", "2", "]", ",", "$", "datetime", "[", "3", "]", ",", "$", "datetime", "[", "4", "]", ",", "$", "datetime", "[", "5", "]", ")", ";", "}", "else", "{", "return", "make_timestamp", "(", "$", "datetime", "[", "0", "]", ",", "$", "datetime", "[", "1", "]", ",", "$", "datetime", "[", "2", "]", ")", ";", "}", "}" ]
If timestamp is in YYYY-MM-DD or YYYY-MM-DD-HH-MM-SS format, then convert it to timestamp. @param string|int $datetime datetime to be converted. @param stdClass $datarecord The object that will be used to save the record @return int timestamp @since Moodle 2.5
[ "If", "timestamp", "is", "in", "YYYY", "-", "MM", "-", "DD", "or", "YYYY", "-", "MM", "-", "DD", "-", "HH", "-", "MM", "-", "SS", "format", "then", "convert", "it", "to", "timestamp", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/user/profile/field/datetime/field.class.php#L78-L97
215,115
moodle/moodle
user/profile/field/datetime/field.class.php
profile_field_datetime.display_data
public function display_data() { // Check if time was specified. if (!empty($this->field->param3)) { $format = get_string('strftimedaydatetime', 'langconfig'); } else { $format = get_string('strftimedate', 'langconfig'); } // Check if a date has been specified. if (empty($this->data)) { return get_string('notset', 'profilefield_datetime'); } else { return userdate($this->data, $format); } }
php
public function display_data() { // Check if time was specified. if (!empty($this->field->param3)) { $format = get_string('strftimedaydatetime', 'langconfig'); } else { $format = get_string('strftimedate', 'langconfig'); } // Check if a date has been specified. if (empty($this->data)) { return get_string('notset', 'profilefield_datetime'); } else { return userdate($this->data, $format); } }
[ "public", "function", "display_data", "(", ")", "{", "// Check if time was specified.", "if", "(", "!", "empty", "(", "$", "this", "->", "field", "->", "param3", ")", ")", "{", "$", "format", "=", "get_string", "(", "'strftimedaydatetime'", ",", "'langconfig'", ")", ";", "}", "else", "{", "$", "format", "=", "get_string", "(", "'strftimedate'", ",", "'langconfig'", ")", ";", "}", "// Check if a date has been specified.", "if", "(", "empty", "(", "$", "this", "->", "data", ")", ")", "{", "return", "get_string", "(", "'notset'", ",", "'profilefield_datetime'", ")", ";", "}", "else", "{", "return", "userdate", "(", "$", "this", "->", "data", ",", "$", "format", ")", ";", "}", "}" ]
Display the data for this field.
[ "Display", "the", "data", "for", "this", "field", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/user/profile/field/datetime/field.class.php#L102-L116
215,116
moodle/moodle
cache/stores/mongodb/MongoDB/GridFS/ReadableStream.php
ReadableStream.isEOF
public function isEOF() { if ($this->chunkOffset === $this->numChunks - 1) { return $this->bufferOffset >= $this->expectedLastChunkSize; } return $this->chunkOffset >= $this->numChunks; }
php
public function isEOF() { if ($this->chunkOffset === $this->numChunks - 1) { return $this->bufferOffset >= $this->expectedLastChunkSize; } return $this->chunkOffset >= $this->numChunks; }
[ "public", "function", "isEOF", "(", ")", "{", "if", "(", "$", "this", "->", "chunkOffset", "===", "$", "this", "->", "numChunks", "-", "1", ")", "{", "return", "$", "this", "->", "bufferOffset", ">=", "$", "this", "->", "expectedLastChunkSize", ";", "}", "return", "$", "this", "->", "chunkOffset", ">=", "$", "this", "->", "numChunks", ";", "}" ]
Return whether the current read position is at the end of the stream. @return boolean
[ "Return", "whether", "the", "current", "read", "position", "is", "at", "the", "end", "of", "the", "stream", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/cache/stores/mongodb/MongoDB/GridFS/ReadableStream.php#L121-L128
215,117
moodle/moodle
cache/stores/mongodb/MongoDB/GridFS/ReadableStream.php
ReadableStream.seek
public function seek($offset) { if ($offset < 0 || $offset > $this->file->length) { throw new InvalidArgumentException(sprintf('$offset must be >= 0 and <= %d; given: %d', $this->file->length, $offset)); } /* Compute the offsets for the chunk and buffer (i.e. chunk data) from * which we will expect to read after seeking. If the chunk offset * changed, we'll also need to reset the buffer. */ $lastChunkOffset = $this->chunkOffset; $this->chunkOffset = (integer) floor($offset / $this->chunkSize); $this->bufferOffset = $offset % $this->chunkSize; if ($lastChunkOffset === $this->chunkOffset) { return; } if ($this->chunksIterator === null) { return; } // Clear the buffer since the current chunk will be changed $this->buffer = null; /* If we are seeking to a previous chunk, we need to reinitialize the * chunk iterator. */ if ($lastChunkOffset > $this->chunkOffset) { $this->chunksIterator = null; return; } /* If we are seeking to a subsequent chunk, we do not need to * reinitalize the chunk iterator. Instead, we can simply move forward * to $this->chunkOffset. */ $numChunks = $this->chunkOffset - $lastChunkOffset; for ($i = 0; $i < $numChunks; $i++) { $this->chunksIterator->next(); } }
php
public function seek($offset) { if ($offset < 0 || $offset > $this->file->length) { throw new InvalidArgumentException(sprintf('$offset must be >= 0 and <= %d; given: %d', $this->file->length, $offset)); } /* Compute the offsets for the chunk and buffer (i.e. chunk data) from * which we will expect to read after seeking. If the chunk offset * changed, we'll also need to reset the buffer. */ $lastChunkOffset = $this->chunkOffset; $this->chunkOffset = (integer) floor($offset / $this->chunkSize); $this->bufferOffset = $offset % $this->chunkSize; if ($lastChunkOffset === $this->chunkOffset) { return; } if ($this->chunksIterator === null) { return; } // Clear the buffer since the current chunk will be changed $this->buffer = null; /* If we are seeking to a previous chunk, we need to reinitialize the * chunk iterator. */ if ($lastChunkOffset > $this->chunkOffset) { $this->chunksIterator = null; return; } /* If we are seeking to a subsequent chunk, we do not need to * reinitalize the chunk iterator. Instead, we can simply move forward * to $this->chunkOffset. */ $numChunks = $this->chunkOffset - $lastChunkOffset; for ($i = 0; $i < $numChunks; $i++) { $this->chunksIterator->next(); } }
[ "public", "function", "seek", "(", "$", "offset", ")", "{", "if", "(", "$", "offset", "<", "0", "||", "$", "offset", ">", "$", "this", "->", "file", "->", "length", ")", "{", "throw", "new", "InvalidArgumentException", "(", "sprintf", "(", "'$offset must be >= 0 and <= %d; given: %d'", ",", "$", "this", "->", "file", "->", "length", ",", "$", "offset", ")", ")", ";", "}", "/* Compute the offsets for the chunk and buffer (i.e. chunk data) from\n * which we will expect to read after seeking. If the chunk offset\n * changed, we'll also need to reset the buffer.\n */", "$", "lastChunkOffset", "=", "$", "this", "->", "chunkOffset", ";", "$", "this", "->", "chunkOffset", "=", "(", "integer", ")", "floor", "(", "$", "offset", "/", "$", "this", "->", "chunkSize", ")", ";", "$", "this", "->", "bufferOffset", "=", "$", "offset", "%", "$", "this", "->", "chunkSize", ";", "if", "(", "$", "lastChunkOffset", "===", "$", "this", "->", "chunkOffset", ")", "{", "return", ";", "}", "if", "(", "$", "this", "->", "chunksIterator", "===", "null", ")", "{", "return", ";", "}", "// Clear the buffer since the current chunk will be changed", "$", "this", "->", "buffer", "=", "null", ";", "/* If we are seeking to a previous chunk, we need to reinitialize the\n * chunk iterator.\n */", "if", "(", "$", "lastChunkOffset", ">", "$", "this", "->", "chunkOffset", ")", "{", "$", "this", "->", "chunksIterator", "=", "null", ";", "return", ";", "}", "/* If we are seeking to a subsequent chunk, we do not need to\n * reinitalize the chunk iterator. Instead, we can simply move forward\n * to $this->chunkOffset.\n */", "$", "numChunks", "=", "$", "this", "->", "chunkOffset", "-", "$", "lastChunkOffset", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "$", "numChunks", ";", "$", "i", "++", ")", "{", "$", "this", "->", "chunksIterator", "->", "next", "(", ")", ";", "}", "}" ]
Seeks the chunk and buffer offsets for the next read operation. @param integer $offset @throws InvalidArgumentException if $offset is out of range
[ "Seeks", "the", "chunk", "and", "buffer", "offsets", "for", "the", "next", "read", "operation", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/cache/stores/mongodb/MongoDB/GridFS/ReadableStream.php#L175-L216
215,118
moodle/moodle
cache/stores/mongodb/MongoDB/GridFS/ReadableStream.php
ReadableStream.initBufferFromCurrentChunk
private function initBufferFromCurrentChunk() { if ($this->chunkOffset === 0 && $this->numChunks === 0) { return false; } if ( ! $this->chunksIterator->valid()) { throw CorruptFileException::missingChunk($this->chunkOffset); } $currentChunk = $this->chunksIterator->current(); if ($currentChunk->n !== $this->chunkOffset) { throw CorruptFileException::unexpectedIndex($currentChunk->n, $this->chunkOffset); } $this->buffer = $currentChunk->data->getData(); $actualChunkSize = strlen($this->buffer); $expectedChunkSize = ($this->chunkOffset === $this->numChunks - 1) ? $this->expectedLastChunkSize : $this->chunkSize; if ($actualChunkSize !== $expectedChunkSize) { throw CorruptFileException::unexpectedSize($actualChunkSize, $expectedChunkSize); } return true; }
php
private function initBufferFromCurrentChunk() { if ($this->chunkOffset === 0 && $this->numChunks === 0) { return false; } if ( ! $this->chunksIterator->valid()) { throw CorruptFileException::missingChunk($this->chunkOffset); } $currentChunk = $this->chunksIterator->current(); if ($currentChunk->n !== $this->chunkOffset) { throw CorruptFileException::unexpectedIndex($currentChunk->n, $this->chunkOffset); } $this->buffer = $currentChunk->data->getData(); $actualChunkSize = strlen($this->buffer); $expectedChunkSize = ($this->chunkOffset === $this->numChunks - 1) ? $this->expectedLastChunkSize : $this->chunkSize; if ($actualChunkSize !== $expectedChunkSize) { throw CorruptFileException::unexpectedSize($actualChunkSize, $expectedChunkSize); } return true; }
[ "private", "function", "initBufferFromCurrentChunk", "(", ")", "{", "if", "(", "$", "this", "->", "chunkOffset", "===", "0", "&&", "$", "this", "->", "numChunks", "===", "0", ")", "{", "return", "false", ";", "}", "if", "(", "!", "$", "this", "->", "chunksIterator", "->", "valid", "(", ")", ")", "{", "throw", "CorruptFileException", "::", "missingChunk", "(", "$", "this", "->", "chunkOffset", ")", ";", "}", "$", "currentChunk", "=", "$", "this", "->", "chunksIterator", "->", "current", "(", ")", ";", "if", "(", "$", "currentChunk", "->", "n", "!==", "$", "this", "->", "chunkOffset", ")", "{", "throw", "CorruptFileException", "::", "unexpectedIndex", "(", "$", "currentChunk", "->", "n", ",", "$", "this", "->", "chunkOffset", ")", ";", "}", "$", "this", "->", "buffer", "=", "$", "currentChunk", "->", "data", "->", "getData", "(", ")", ";", "$", "actualChunkSize", "=", "strlen", "(", "$", "this", "->", "buffer", ")", ";", "$", "expectedChunkSize", "=", "(", "$", "this", "->", "chunkOffset", "===", "$", "this", "->", "numChunks", "-", "1", ")", "?", "$", "this", "->", "expectedLastChunkSize", ":", "$", "this", "->", "chunkSize", ";", "if", "(", "$", "actualChunkSize", "!==", "$", "expectedChunkSize", ")", "{", "throw", "CorruptFileException", "::", "unexpectedSize", "(", "$", "actualChunkSize", ",", "$", "expectedChunkSize", ")", ";", "}", "return", "true", ";", "}" ]
Initialize the buffer to the current chunk's data. @return boolean Whether there was a current chunk to read @throws CorruptFileException if an expected chunk could not be read successfully
[ "Initialize", "the", "buffer", "to", "the", "current", "chunk", "s", "data", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/cache/stores/mongodb/MongoDB/GridFS/ReadableStream.php#L236-L265
215,119
moodle/moodle
cache/stores/mongodb/MongoDB/GridFS/ReadableStream.php
ReadableStream.initBufferFromNextChunk
private function initBufferFromNextChunk() { if ($this->chunkOffset === $this->numChunks - 1) { return false; } $this->bufferOffset = 0; $this->chunkOffset++; $this->chunksIterator->next(); return $this->initBufferFromCurrentChunk(); }
php
private function initBufferFromNextChunk() { if ($this->chunkOffset === $this->numChunks - 1) { return false; } $this->bufferOffset = 0; $this->chunkOffset++; $this->chunksIterator->next(); return $this->initBufferFromCurrentChunk(); }
[ "private", "function", "initBufferFromNextChunk", "(", ")", "{", "if", "(", "$", "this", "->", "chunkOffset", "===", "$", "this", "->", "numChunks", "-", "1", ")", "{", "return", "false", ";", "}", "$", "this", "->", "bufferOffset", "=", "0", ";", "$", "this", "->", "chunkOffset", "++", ";", "$", "this", "->", "chunksIterator", "->", "next", "(", ")", ";", "return", "$", "this", "->", "initBufferFromCurrentChunk", "(", ")", ";", "}" ]
Advance to the next chunk and initialize the buffer to its data. @return boolean Whether there was a next chunk to read @throws CorruptFileException if an expected chunk could not be read successfully
[ "Advance", "to", "the", "next", "chunk", "and", "initialize", "the", "buffer", "to", "its", "data", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/cache/stores/mongodb/MongoDB/GridFS/ReadableStream.php#L273-L284
215,120
moodle/moodle
cache/stores/mongodb/MongoDB/GridFS/ReadableStream.php
ReadableStream.initChunksIterator
private function initChunksIterator() { $cursor = $this->collectionWrapper->findChunksByFileId($this->file->_id, $this->chunkOffset); $this->chunksIterator = new IteratorIterator($cursor); $this->chunksIterator->rewind(); }
php
private function initChunksIterator() { $cursor = $this->collectionWrapper->findChunksByFileId($this->file->_id, $this->chunkOffset); $this->chunksIterator = new IteratorIterator($cursor); $this->chunksIterator->rewind(); }
[ "private", "function", "initChunksIterator", "(", ")", "{", "$", "cursor", "=", "$", "this", "->", "collectionWrapper", "->", "findChunksByFileId", "(", "$", "this", "->", "file", "->", "_id", ",", "$", "this", "->", "chunkOffset", ")", ";", "$", "this", "->", "chunksIterator", "=", "new", "IteratorIterator", "(", "$", "cursor", ")", ";", "$", "this", "->", "chunksIterator", "->", "rewind", "(", ")", ";", "}" ]
Initializes the chunk iterator starting from the current offset.
[ "Initializes", "the", "chunk", "iterator", "starting", "from", "the", "current", "offset", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/cache/stores/mongodb/MongoDB/GridFS/ReadableStream.php#L289-L295
215,121
moodle/moodle
admin/tool/xmldb/actions/view_table_php/view_table_php.class.php
view_table_php.add_field_php
function add_field_php($structure, $table, $field) { $result = ''; // Validate if we can do it if (!$table = $structure->getTable($table)) { return false; } if (!$field = $table->getField($field)) { return false; } if ($table->getAllErrors()) { return false; } // Add the standard PHP header $result .= XMLDB_PHP_HEADER; // Add contents $result .= XMLDB_LINEFEED; $result .= ' // Define field ' . $field->getName() . ' to be added to ' . $table->getName() . '.' . XMLDB_LINEFEED; $result .= ' $table = new xmldb_table(' . "'" . $table->getName() . "'" . ');' . XMLDB_LINEFEED; $result .= ' $field = new xmldb_field(' . "'" . $field->getName() . "', " . $field->getPHP(true) . ');' . XMLDB_LINEFEED; // Launch the proper DDL $result .= XMLDB_LINEFEED; $result .= ' // Conditionally launch add field ' . $field->getName() . '.' . XMLDB_LINEFEED; $result .= ' if (!$dbman->field_exists($table, $field)) {'. XMLDB_LINEFEED; $result .= ' $dbman->add_field($table, $field);' . XMLDB_LINEFEED; $result .= ' }'. XMLDB_LINEFEED; // Add the proper upgrade_xxxx_savepoint call $result .= $this->upgrade_savepoint_php ($structure); // Add standard PHP footer $result .= XMLDB_PHP_FOOTER; return $result; }
php
function add_field_php($structure, $table, $field) { $result = ''; // Validate if we can do it if (!$table = $structure->getTable($table)) { return false; } if (!$field = $table->getField($field)) { return false; } if ($table->getAllErrors()) { return false; } // Add the standard PHP header $result .= XMLDB_PHP_HEADER; // Add contents $result .= XMLDB_LINEFEED; $result .= ' // Define field ' . $field->getName() . ' to be added to ' . $table->getName() . '.' . XMLDB_LINEFEED; $result .= ' $table = new xmldb_table(' . "'" . $table->getName() . "'" . ');' . XMLDB_LINEFEED; $result .= ' $field = new xmldb_field(' . "'" . $field->getName() . "', " . $field->getPHP(true) . ');' . XMLDB_LINEFEED; // Launch the proper DDL $result .= XMLDB_LINEFEED; $result .= ' // Conditionally launch add field ' . $field->getName() . '.' . XMLDB_LINEFEED; $result .= ' if (!$dbman->field_exists($table, $field)) {'. XMLDB_LINEFEED; $result .= ' $dbman->add_field($table, $field);' . XMLDB_LINEFEED; $result .= ' }'. XMLDB_LINEFEED; // Add the proper upgrade_xxxx_savepoint call $result .= $this->upgrade_savepoint_php ($structure); // Add standard PHP footer $result .= XMLDB_PHP_FOOTER; return $result; }
[ "function", "add_field_php", "(", "$", "structure", ",", "$", "table", ",", "$", "field", ")", "{", "$", "result", "=", "''", ";", "// Validate if we can do it", "if", "(", "!", "$", "table", "=", "$", "structure", "->", "getTable", "(", "$", "table", ")", ")", "{", "return", "false", ";", "}", "if", "(", "!", "$", "field", "=", "$", "table", "->", "getField", "(", "$", "field", ")", ")", "{", "return", "false", ";", "}", "if", "(", "$", "table", "->", "getAllErrors", "(", ")", ")", "{", "return", "false", ";", "}", "// Add the standard PHP header", "$", "result", ".=", "XMLDB_PHP_HEADER", ";", "// Add contents", "$", "result", ".=", "XMLDB_LINEFEED", ";", "$", "result", ".=", "' // Define field '", ".", "$", "field", "->", "getName", "(", ")", ".", "' to be added to '", ".", "$", "table", "->", "getName", "(", ")", ".", "'.'", ".", "XMLDB_LINEFEED", ";", "$", "result", ".=", "' $table = new xmldb_table('", ".", "\"'\"", ".", "$", "table", "->", "getName", "(", ")", ".", "\"'\"", ".", "');'", ".", "XMLDB_LINEFEED", ";", "$", "result", ".=", "' $field = new xmldb_field('", ".", "\"'\"", ".", "$", "field", "->", "getName", "(", ")", ".", "\"', \"", ".", "$", "field", "->", "getPHP", "(", "true", ")", ".", "');'", ".", "XMLDB_LINEFEED", ";", "// Launch the proper DDL", "$", "result", ".=", "XMLDB_LINEFEED", ";", "$", "result", ".=", "' // Conditionally launch add field '", ".", "$", "field", "->", "getName", "(", ")", ".", "'.'", ".", "XMLDB_LINEFEED", ";", "$", "result", ".=", "' if (!$dbman->field_exists($table, $field)) {'", ".", "XMLDB_LINEFEED", ";", "$", "result", ".=", "' $dbman->add_field($table, $field);'", ".", "XMLDB_LINEFEED", ";", "$", "result", ".=", "' }'", ".", "XMLDB_LINEFEED", ";", "// Add the proper upgrade_xxxx_savepoint call", "$", "result", ".=", "$", "this", "->", "upgrade_savepoint_php", "(", "$", "structure", ")", ";", "// Add standard PHP footer", "$", "result", ".=", "XMLDB_PHP_FOOTER", ";", "return", "$", "result", ";", "}" ]
This function will generate all the PHP code needed to create one field using XMLDB objects and functions @param xmldb_structure structure object containing all the info @param string table table name @param string field field name to be created @return string PHP code to be used to create the field
[ "This", "function", "will", "generate", "all", "the", "PHP", "code", "needed", "to", "create", "one", "field", "using", "XMLDB", "objects", "and", "functions" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/admin/tool/xmldb/actions/view_table_php/view_table_php.class.php#L298-L335
215,122
moodle/moodle
admin/tool/xmldb/actions/view_table_php/view_table_php.class.php
view_table_php.drop_field_php
function drop_field_php($structure, $table, $field) { $result = ''; // Validate if we can do it if (!$table = $structure->getTable($table)) { return false; } if (!$field = $table->getField($field)) { return false; } if ($table->getAllErrors()) { return false; } // Add the standard PHP header $result .= XMLDB_PHP_HEADER; // Add contents $result .= XMLDB_LINEFEED; $result .= ' // Define field ' . $field->getName() . ' to be dropped from ' . $table->getName() . '.' . XMLDB_LINEFEED; $result .= ' $table = new xmldb_table(' . "'" . $table->getName() . "'" . ');' . XMLDB_LINEFEED; $result .= ' $field = new xmldb_field(' . "'" . $field->getName() . "'" . ');' . XMLDB_LINEFEED; // Launch the proper DDL $result .= XMLDB_LINEFEED; $result .= ' // Conditionally launch drop field ' . $field->getName() . '.' . XMLDB_LINEFEED; $result .= ' if ($dbman->field_exists($table, $field)) {' . XMLDB_LINEFEED; $result .= ' $dbman->drop_field($table, $field);' . XMLDB_LINEFEED; $result .= ' }' . XMLDB_LINEFEED; // Add the proper upgrade_xxxx_savepoint call $result .= $this->upgrade_savepoint_php ($structure); // Add standard PHP footer $result .= XMLDB_PHP_FOOTER; return $result; }
php
function drop_field_php($structure, $table, $field) { $result = ''; // Validate if we can do it if (!$table = $structure->getTable($table)) { return false; } if (!$field = $table->getField($field)) { return false; } if ($table->getAllErrors()) { return false; } // Add the standard PHP header $result .= XMLDB_PHP_HEADER; // Add contents $result .= XMLDB_LINEFEED; $result .= ' // Define field ' . $field->getName() . ' to be dropped from ' . $table->getName() . '.' . XMLDB_LINEFEED; $result .= ' $table = new xmldb_table(' . "'" . $table->getName() . "'" . ');' . XMLDB_LINEFEED; $result .= ' $field = new xmldb_field(' . "'" . $field->getName() . "'" . ');' . XMLDB_LINEFEED; // Launch the proper DDL $result .= XMLDB_LINEFEED; $result .= ' // Conditionally launch drop field ' . $field->getName() . '.' . XMLDB_LINEFEED; $result .= ' if ($dbman->field_exists($table, $field)) {' . XMLDB_LINEFEED; $result .= ' $dbman->drop_field($table, $field);' . XMLDB_LINEFEED; $result .= ' }' . XMLDB_LINEFEED; // Add the proper upgrade_xxxx_savepoint call $result .= $this->upgrade_savepoint_php ($structure); // Add standard PHP footer $result .= XMLDB_PHP_FOOTER; return $result; }
[ "function", "drop_field_php", "(", "$", "structure", ",", "$", "table", ",", "$", "field", ")", "{", "$", "result", "=", "''", ";", "// Validate if we can do it", "if", "(", "!", "$", "table", "=", "$", "structure", "->", "getTable", "(", "$", "table", ")", ")", "{", "return", "false", ";", "}", "if", "(", "!", "$", "field", "=", "$", "table", "->", "getField", "(", "$", "field", ")", ")", "{", "return", "false", ";", "}", "if", "(", "$", "table", "->", "getAllErrors", "(", ")", ")", "{", "return", "false", ";", "}", "// Add the standard PHP header", "$", "result", ".=", "XMLDB_PHP_HEADER", ";", "// Add contents", "$", "result", ".=", "XMLDB_LINEFEED", ";", "$", "result", ".=", "' // Define field '", ".", "$", "field", "->", "getName", "(", ")", ".", "' to be dropped from '", ".", "$", "table", "->", "getName", "(", ")", ".", "'.'", ".", "XMLDB_LINEFEED", ";", "$", "result", ".=", "' $table = new xmldb_table('", ".", "\"'\"", ".", "$", "table", "->", "getName", "(", ")", ".", "\"'\"", ".", "');'", ".", "XMLDB_LINEFEED", ";", "$", "result", ".=", "' $field = new xmldb_field('", ".", "\"'\"", ".", "$", "field", "->", "getName", "(", ")", ".", "\"'\"", ".", "');'", ".", "XMLDB_LINEFEED", ";", "// Launch the proper DDL", "$", "result", ".=", "XMLDB_LINEFEED", ";", "$", "result", ".=", "' // Conditionally launch drop field '", ".", "$", "field", "->", "getName", "(", ")", ".", "'.'", ".", "XMLDB_LINEFEED", ";", "$", "result", ".=", "' if ($dbman->field_exists($table, $field)) {'", ".", "XMLDB_LINEFEED", ";", "$", "result", ".=", "' $dbman->drop_field($table, $field);'", ".", "XMLDB_LINEFEED", ";", "$", "result", ".=", "' }'", ".", "XMLDB_LINEFEED", ";", "// Add the proper upgrade_xxxx_savepoint call", "$", "result", ".=", "$", "this", "->", "upgrade_savepoint_php", "(", "$", "structure", ")", ";", "// Add standard PHP footer", "$", "result", ".=", "XMLDB_PHP_FOOTER", ";", "return", "$", "result", ";", "}" ]
This function will generate all the PHP code needed to drop one field using XMLDB objects and functions @param xmldb_structure structure object containing all the info @param string table table name @param string field field name to be dropped @return string PHP code to be used to drop the field
[ "This", "function", "will", "generate", "all", "the", "PHP", "code", "needed", "to", "drop", "one", "field", "using", "XMLDB", "objects", "and", "functions" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/admin/tool/xmldb/actions/view_table_php/view_table_php.class.php#L346-L383
215,123
moodle/moodle
admin/tool/xmldb/actions/view_table_php/view_table_php.class.php
view_table_php.change_field_precision_php
function change_field_precision_php($structure, $table, $field) { $result = ''; // Validate if we can do it if (!$table = $structure->getTable($table)) { return false; } if (!$field = $table->getField($field)) { return false; } if ($table->getAllErrors()) { return false; } // Calculate the precision tip text $precision = '(' . $field->getLength(); if ($field->getDecimals()) { $precision .= ', ' . $field->getDecimals(); } $precision .= ')'; // Add the standard PHP header $result .= XMLDB_PHP_HEADER; // Add contents $result .= XMLDB_LINEFEED; $result .= ' // Changing precision of field ' . $field->getName() . ' on table ' . $table->getName() . ' to ' . $precision . '.' . XMLDB_LINEFEED; $result .= ' $table = new xmldb_table(' . "'" . $table->getName() . "'" . ');' . XMLDB_LINEFEED; $result .= ' $field = new xmldb_field(' . "'" . $field->getName() . "', " . $field->getPHP(true) . ');' . XMLDB_LINEFEED; // Launch the proper DDL $result .= XMLDB_LINEFEED; $result .= ' // Launch change of precision for field ' . $field->getName() . '.' . XMLDB_LINEFEED; $result .= ' $dbman->change_field_precision($table, $field);' . XMLDB_LINEFEED; // Add the proper upgrade_xxxx_savepoint call $result .= $this->upgrade_savepoint_php ($structure); // Add standard PHP footer $result .= XMLDB_PHP_FOOTER; return $result; }
php
function change_field_precision_php($structure, $table, $field) { $result = ''; // Validate if we can do it if (!$table = $structure->getTable($table)) { return false; } if (!$field = $table->getField($field)) { return false; } if ($table->getAllErrors()) { return false; } // Calculate the precision tip text $precision = '(' . $field->getLength(); if ($field->getDecimals()) { $precision .= ', ' . $field->getDecimals(); } $precision .= ')'; // Add the standard PHP header $result .= XMLDB_PHP_HEADER; // Add contents $result .= XMLDB_LINEFEED; $result .= ' // Changing precision of field ' . $field->getName() . ' on table ' . $table->getName() . ' to ' . $precision . '.' . XMLDB_LINEFEED; $result .= ' $table = new xmldb_table(' . "'" . $table->getName() . "'" . ');' . XMLDB_LINEFEED; $result .= ' $field = new xmldb_field(' . "'" . $field->getName() . "', " . $field->getPHP(true) . ');' . XMLDB_LINEFEED; // Launch the proper DDL $result .= XMLDB_LINEFEED; $result .= ' // Launch change of precision for field ' . $field->getName() . '.' . XMLDB_LINEFEED; $result .= ' $dbman->change_field_precision($table, $field);' . XMLDB_LINEFEED; // Add the proper upgrade_xxxx_savepoint call $result .= $this->upgrade_savepoint_php ($structure); // Add standard PHP footer $result .= XMLDB_PHP_FOOTER; return $result; }
[ "function", "change_field_precision_php", "(", "$", "structure", ",", "$", "table", ",", "$", "field", ")", "{", "$", "result", "=", "''", ";", "// Validate if we can do it", "if", "(", "!", "$", "table", "=", "$", "structure", "->", "getTable", "(", "$", "table", ")", ")", "{", "return", "false", ";", "}", "if", "(", "!", "$", "field", "=", "$", "table", "->", "getField", "(", "$", "field", ")", ")", "{", "return", "false", ";", "}", "if", "(", "$", "table", "->", "getAllErrors", "(", ")", ")", "{", "return", "false", ";", "}", "// Calculate the precision tip text", "$", "precision", "=", "'('", ".", "$", "field", "->", "getLength", "(", ")", ";", "if", "(", "$", "field", "->", "getDecimals", "(", ")", ")", "{", "$", "precision", ".=", "', '", ".", "$", "field", "->", "getDecimals", "(", ")", ";", "}", "$", "precision", ".=", "')'", ";", "// Add the standard PHP header", "$", "result", ".=", "XMLDB_PHP_HEADER", ";", "// Add contents", "$", "result", ".=", "XMLDB_LINEFEED", ";", "$", "result", ".=", "' // Changing precision of field '", ".", "$", "field", "->", "getName", "(", ")", ".", "' on table '", ".", "$", "table", "->", "getName", "(", ")", ".", "' to '", ".", "$", "precision", ".", "'.'", ".", "XMLDB_LINEFEED", ";", "$", "result", ".=", "' $table = new xmldb_table('", ".", "\"'\"", ".", "$", "table", "->", "getName", "(", ")", ".", "\"'\"", ".", "');'", ".", "XMLDB_LINEFEED", ";", "$", "result", ".=", "' $field = new xmldb_field('", ".", "\"'\"", ".", "$", "field", "->", "getName", "(", ")", ".", "\"', \"", ".", "$", "field", "->", "getPHP", "(", "true", ")", ".", "');'", ".", "XMLDB_LINEFEED", ";", "// Launch the proper DDL", "$", "result", ".=", "XMLDB_LINEFEED", ";", "$", "result", ".=", "' // Launch change of precision for field '", ".", "$", "field", "->", "getName", "(", ")", ".", "'.'", ".", "XMLDB_LINEFEED", ";", "$", "result", ".=", "' $dbman->change_field_precision($table, $field);'", ".", "XMLDB_LINEFEED", ";", "// Add the proper upgrade_xxxx_savepoint call", "$", "result", ".=", "$", "this", "->", "upgrade_savepoint_php", "(", "$", "structure", ")", ";", "// Add standard PHP footer", "$", "result", ".=", "XMLDB_PHP_FOOTER", ";", "return", "$", "result", ";", "}" ]
This function will generate all the PHP code needed to change the precision of one field using XMLDB objects and functions @param xmldb_structure structure object containing all the info @param string table table name @param string field field name to change precision
[ "This", "function", "will", "generate", "all", "the", "PHP", "code", "needed", "to", "change", "the", "precision", "of", "one", "field", "using", "XMLDB", "objects", "and", "functions" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/admin/tool/xmldb/actions/view_table_php/view_table_php.class.php#L494-L536
215,124
moodle/moodle
admin/tool/xmldb/actions/view_table_php/view_table_php.class.php
view_table_php.drop_key_php
function drop_key_php($structure, $table, $key) { $result = ''; // Validate if we can do it if (!$table = $structure->getTable($table)) { return false; } if (!$key = $table->getKey($key)) { return false; } if ($table->getAllErrors()) { return false; } // Add the standard PHP header $result .= XMLDB_PHP_HEADER; // Add contents $result .= XMLDB_LINEFEED; $result .= ' // Define key ' . $key->getName() . ' ('. $key->getXMLDBKeyName($key->getType()) . ') to be dropped form ' . $table->getName() . '.' . XMLDB_LINEFEED; $result .= ' $table = new xmldb_table(' . "'" . $table->getName() . "'" . ');' . XMLDB_LINEFEED; $result .= ' $key = new xmldb_key(' . "'" . $key->getName() . "', " . $key->getPHP(true) . ');' . XMLDB_LINEFEED; // Launch the proper DDL $result .= XMLDB_LINEFEED; $result .= ' // Launch drop key ' . $key->getName() . '.' . XMLDB_LINEFEED; $result .= ' $dbman->drop_key($table, $key);' . XMLDB_LINEFEED; // Add the proper upgrade_xxxx_savepoint call $result .= $this->upgrade_savepoint_php ($structure); // Add standard PHP footer $result .= XMLDB_PHP_FOOTER; return $result; }
php
function drop_key_php($structure, $table, $key) { $result = ''; // Validate if we can do it if (!$table = $structure->getTable($table)) { return false; } if (!$key = $table->getKey($key)) { return false; } if ($table->getAllErrors()) { return false; } // Add the standard PHP header $result .= XMLDB_PHP_HEADER; // Add contents $result .= XMLDB_LINEFEED; $result .= ' // Define key ' . $key->getName() . ' ('. $key->getXMLDBKeyName($key->getType()) . ') to be dropped form ' . $table->getName() . '.' . XMLDB_LINEFEED; $result .= ' $table = new xmldb_table(' . "'" . $table->getName() . "'" . ');' . XMLDB_LINEFEED; $result .= ' $key = new xmldb_key(' . "'" . $key->getName() . "', " . $key->getPHP(true) . ');' . XMLDB_LINEFEED; // Launch the proper DDL $result .= XMLDB_LINEFEED; $result .= ' // Launch drop key ' . $key->getName() . '.' . XMLDB_LINEFEED; $result .= ' $dbman->drop_key($table, $key);' . XMLDB_LINEFEED; // Add the proper upgrade_xxxx_savepoint call $result .= $this->upgrade_savepoint_php ($structure); // Add standard PHP footer $result .= XMLDB_PHP_FOOTER; return $result; }
[ "function", "drop_key_php", "(", "$", "structure", ",", "$", "table", ",", "$", "key", ")", "{", "$", "result", "=", "''", ";", "// Validate if we can do it", "if", "(", "!", "$", "table", "=", "$", "structure", "->", "getTable", "(", "$", "table", ")", ")", "{", "return", "false", ";", "}", "if", "(", "!", "$", "key", "=", "$", "table", "->", "getKey", "(", "$", "key", ")", ")", "{", "return", "false", ";", "}", "if", "(", "$", "table", "->", "getAllErrors", "(", ")", ")", "{", "return", "false", ";", "}", "// Add the standard PHP header", "$", "result", ".=", "XMLDB_PHP_HEADER", ";", "// Add contents", "$", "result", ".=", "XMLDB_LINEFEED", ";", "$", "result", ".=", "' // Define key '", ".", "$", "key", "->", "getName", "(", ")", ".", "' ('", ".", "$", "key", "->", "getXMLDBKeyName", "(", "$", "key", "->", "getType", "(", ")", ")", ".", "') to be dropped form '", ".", "$", "table", "->", "getName", "(", ")", ".", "'.'", ".", "XMLDB_LINEFEED", ";", "$", "result", ".=", "' $table = new xmldb_table('", ".", "\"'\"", ".", "$", "table", "->", "getName", "(", ")", ".", "\"'\"", ".", "');'", ".", "XMLDB_LINEFEED", ";", "$", "result", ".=", "' $key = new xmldb_key('", ".", "\"'\"", ".", "$", "key", "->", "getName", "(", ")", ".", "\"', \"", ".", "$", "key", "->", "getPHP", "(", "true", ")", ".", "');'", ".", "XMLDB_LINEFEED", ";", "// Launch the proper DDL", "$", "result", ".=", "XMLDB_LINEFEED", ";", "$", "result", ".=", "' // Launch drop key '", ".", "$", "key", "->", "getName", "(", ")", ".", "'.'", ".", "XMLDB_LINEFEED", ";", "$", "result", ".=", "' $dbman->drop_key($table, $key);'", ".", "XMLDB_LINEFEED", ";", "// Add the proper upgrade_xxxx_savepoint call", "$", "result", ".=", "$", "this", "->", "upgrade_savepoint_php", "(", "$", "structure", ")", ";", "// Add standard PHP footer", "$", "result", ".=", "XMLDB_PHP_FOOTER", ";", "return", "$", "result", ";", "}" ]
This function will generate all the PHP code needed to drop one key using XMLDB objects and functions @param xmldb_structure structure object containing all the info @param string table table name @param string key key name to be dropped @return string PHP code to be used to drop the key
[ "This", "function", "will", "generate", "all", "the", "PHP", "code", "needed", "to", "drop", "one", "key", "using", "XMLDB", "objects", "and", "functions" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/admin/tool/xmldb/actions/view_table_php/view_table_php.class.php#L689-L724
215,125
moodle/moodle
admin/tool/xmldb/actions/view_table_php/view_table_php.class.php
view_table_php.add_index_php
function add_index_php($structure, $table, $index) { $result = ''; // Validate if we can do it if (!$table = $structure->getTable($table)) { return false; } if (!$index = $table->getIndex($index)) { return false; } if ($table->getAllErrors()) { return false; } // Add the standard PHP header $result .= XMLDB_PHP_HEADER; // Add contents $result .= XMLDB_LINEFEED; $result .= ' // Define index ' . $index->getName() . ' ('. ($index->getUnique() ? 'unique' : 'not unique') . ') to be added to ' . $table->getName() . '.' . XMLDB_LINEFEED; $result .= ' $table = new xmldb_table(' . "'" . $table->getName() . "'" . ');' . XMLDB_LINEFEED; $result .= ' $index = new xmldb_index(' . "'" . $index->getName() . "', " . $index->getPHP(true) . ');' . XMLDB_LINEFEED; // Launch the proper DDL $result .= XMLDB_LINEFEED; $result .= ' // Conditionally launch add index ' . $index->getName() . '.' . XMLDB_LINEFEED; $result .= ' if (!$dbman->index_exists($table, $index)) {' . XMLDB_LINEFEED; $result .= ' $dbman->add_index($table, $index);' . XMLDB_LINEFEED; $result .= ' }' . XMLDB_LINEFEED; // Add the proper upgrade_xxxx_savepoint call $result .= $this->upgrade_savepoint_php ($structure); // Add standard PHP footer $result .= XMLDB_PHP_FOOTER; return $result; }
php
function add_index_php($structure, $table, $index) { $result = ''; // Validate if we can do it if (!$table = $structure->getTable($table)) { return false; } if (!$index = $table->getIndex($index)) { return false; } if ($table->getAllErrors()) { return false; } // Add the standard PHP header $result .= XMLDB_PHP_HEADER; // Add contents $result .= XMLDB_LINEFEED; $result .= ' // Define index ' . $index->getName() . ' ('. ($index->getUnique() ? 'unique' : 'not unique') . ') to be added to ' . $table->getName() . '.' . XMLDB_LINEFEED; $result .= ' $table = new xmldb_table(' . "'" . $table->getName() . "'" . ');' . XMLDB_LINEFEED; $result .= ' $index = new xmldb_index(' . "'" . $index->getName() . "', " . $index->getPHP(true) . ');' . XMLDB_LINEFEED; // Launch the proper DDL $result .= XMLDB_LINEFEED; $result .= ' // Conditionally launch add index ' . $index->getName() . '.' . XMLDB_LINEFEED; $result .= ' if (!$dbman->index_exists($table, $index)) {' . XMLDB_LINEFEED; $result .= ' $dbman->add_index($table, $index);' . XMLDB_LINEFEED; $result .= ' }' . XMLDB_LINEFEED; // Add the proper upgrade_xxxx_savepoint call $result .= $this->upgrade_savepoint_php ($structure); // Add standard PHP footer $result .= XMLDB_PHP_FOOTER; return $result; }
[ "function", "add_index_php", "(", "$", "structure", ",", "$", "table", ",", "$", "index", ")", "{", "$", "result", "=", "''", ";", "// Validate if we can do it", "if", "(", "!", "$", "table", "=", "$", "structure", "->", "getTable", "(", "$", "table", ")", ")", "{", "return", "false", ";", "}", "if", "(", "!", "$", "index", "=", "$", "table", "->", "getIndex", "(", "$", "index", ")", ")", "{", "return", "false", ";", "}", "if", "(", "$", "table", "->", "getAllErrors", "(", ")", ")", "{", "return", "false", ";", "}", "// Add the standard PHP header", "$", "result", ".=", "XMLDB_PHP_HEADER", ";", "// Add contents", "$", "result", ".=", "XMLDB_LINEFEED", ";", "$", "result", ".=", "' // Define index '", ".", "$", "index", "->", "getName", "(", ")", ".", "' ('", ".", "(", "$", "index", "->", "getUnique", "(", ")", "?", "'unique'", ":", "'not unique'", ")", ".", "') to be added to '", ".", "$", "table", "->", "getName", "(", ")", ".", "'.'", ".", "XMLDB_LINEFEED", ";", "$", "result", ".=", "' $table = new xmldb_table('", ".", "\"'\"", ".", "$", "table", "->", "getName", "(", ")", ".", "\"'\"", ".", "');'", ".", "XMLDB_LINEFEED", ";", "$", "result", ".=", "' $index = new xmldb_index('", ".", "\"'\"", ".", "$", "index", "->", "getName", "(", ")", ".", "\"', \"", ".", "$", "index", "->", "getPHP", "(", "true", ")", ".", "');'", ".", "XMLDB_LINEFEED", ";", "// Launch the proper DDL", "$", "result", ".=", "XMLDB_LINEFEED", ";", "$", "result", ".=", "' // Conditionally launch add index '", ".", "$", "index", "->", "getName", "(", ")", ".", "'.'", ".", "XMLDB_LINEFEED", ";", "$", "result", ".=", "' if (!$dbman->index_exists($table, $index)) {'", ".", "XMLDB_LINEFEED", ";", "$", "result", ".=", "' $dbman->add_index($table, $index);'", ".", "XMLDB_LINEFEED", ";", "$", "result", ".=", "' }'", ".", "XMLDB_LINEFEED", ";", "// Add the proper upgrade_xxxx_savepoint call", "$", "result", ".=", "$", "this", "->", "upgrade_savepoint_php", "(", "$", "structure", ")", ";", "// Add standard PHP footer", "$", "result", ".=", "XMLDB_PHP_FOOTER", ";", "return", "$", "result", ";", "}" ]
This function will generate all the PHP code needed to create one index using XMLDB objects and functions @param xmldb_structure structure object containing all the info @param string table table name @param string index index name to be created @return string PHP code to be used to create the index
[ "This", "function", "will", "generate", "all", "the", "PHP", "code", "needed", "to", "create", "one", "index", "using", "XMLDB", "objects", "and", "functions" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/admin/tool/xmldb/actions/view_table_php/view_table_php.class.php#L784-L821
215,126
moodle/moodle
course/format/singleactivity/renderer.php
format_singleactivity_renderer.display
public function display($course, $orphaned) { $courserenderer = $this->page->get_renderer('core', 'course'); $output = ''; $modinfo = get_fast_modinfo($course); if ($orphaned) { if (!empty($modinfo->sections[1])) { $output .= $this->output->heading(get_string('orphaned', 'format_singleactivity'), 3, 'sectionname'); $output .= $this->output->box(get_string('orphanedwarning', 'format_singleactivity')); $output .= $courserenderer->course_section_cm_list($course, 1, 1); } } else { $output .= $courserenderer->course_section_cm_list($course, 0, 0); if (empty($modinfo->sections[0]) && course_get_format($course)->activity_has_subtypes()) { // Course format was unable to automatically redirect to add module page. $output .= $courserenderer->course_section_add_cm_control($course, 0, 0); } } return $output; }
php
public function display($course, $orphaned) { $courserenderer = $this->page->get_renderer('core', 'course'); $output = ''; $modinfo = get_fast_modinfo($course); if ($orphaned) { if (!empty($modinfo->sections[1])) { $output .= $this->output->heading(get_string('orphaned', 'format_singleactivity'), 3, 'sectionname'); $output .= $this->output->box(get_string('orphanedwarning', 'format_singleactivity')); $output .= $courserenderer->course_section_cm_list($course, 1, 1); } } else { $output .= $courserenderer->course_section_cm_list($course, 0, 0); if (empty($modinfo->sections[0]) && course_get_format($course)->activity_has_subtypes()) { // Course format was unable to automatically redirect to add module page. $output .= $courserenderer->course_section_add_cm_control($course, 0, 0); } } return $output; }
[ "public", "function", "display", "(", "$", "course", ",", "$", "orphaned", ")", "{", "$", "courserenderer", "=", "$", "this", "->", "page", "->", "get_renderer", "(", "'core'", ",", "'course'", ")", ";", "$", "output", "=", "''", ";", "$", "modinfo", "=", "get_fast_modinfo", "(", "$", "course", ")", ";", "if", "(", "$", "orphaned", ")", "{", "if", "(", "!", "empty", "(", "$", "modinfo", "->", "sections", "[", "1", "]", ")", ")", "{", "$", "output", ".=", "$", "this", "->", "output", "->", "heading", "(", "get_string", "(", "'orphaned'", ",", "'format_singleactivity'", ")", ",", "3", ",", "'sectionname'", ")", ";", "$", "output", ".=", "$", "this", "->", "output", "->", "box", "(", "get_string", "(", "'orphanedwarning'", ",", "'format_singleactivity'", ")", ")", ";", "$", "output", ".=", "$", "courserenderer", "->", "course_section_cm_list", "(", "$", "course", ",", "1", ",", "1", ")", ";", "}", "}", "else", "{", "$", "output", ".=", "$", "courserenderer", "->", "course_section_cm_list", "(", "$", "course", ",", "0", ",", "0", ")", ";", "if", "(", "empty", "(", "$", "modinfo", "->", "sections", "[", "0", "]", ")", "&&", "course_get_format", "(", "$", "course", ")", "->", "activity_has_subtypes", "(", ")", ")", "{", "// Course format was unable to automatically redirect to add module page.", "$", "output", ".=", "$", "courserenderer", "->", "course_section_add_cm_control", "(", "$", "course", ",", "0", ",", "0", ")", ";", "}", "}", "return", "$", "output", ";", "}" ]
Displays the activities list in cases when course view page is not redirected to the activity page. @param stdClass $course record from table course @param bool $orphaned if false displays the main activity (if present) if true displays all other activities
[ "Displays", "the", "activities", "list", "in", "cases", "when", "course", "view", "page", "is", "not", "redirected", "to", "the", "activity", "page", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/course/format/singleactivity/renderer.php#L44-L62
215,127
moodle/moodle
lib/horde/framework/Horde/Crypt/Blowfish/Php/Base.php
Horde_Crypt_Blowfish_Php_Base._binxor
protected function _binxor($l, $r) { $x = (($l < 0) ? (float)($l + 4294967296) : (float)$l) ^ (($r < 0) ? (float)($r + 4294967296) : (float)$r); return (float)(($x < 0) ? $x + 4294967296 : $x); }
php
protected function _binxor($l, $r) { $x = (($l < 0) ? (float)($l + 4294967296) : (float)$l) ^ (($r < 0) ? (float)($r + 4294967296) : (float)$r); return (float)(($x < 0) ? $x + 4294967296 : $x); }
[ "protected", "function", "_binxor", "(", "$", "l", ",", "$", "r", ")", "{", "$", "x", "=", "(", "(", "$", "l", "<", "0", ")", "?", "(", "float", ")", "(", "$", "l", "+", "4294967296", ")", ":", "(", "float", ")", "$", "l", ")", "^", "(", "(", "$", "r", "<", "0", ")", "?", "(", "float", ")", "(", "$", "r", "+", "4294967296", ")", ":", "(", "float", ")", "$", "r", ")", ";", "return", "(", "float", ")", "(", "(", "$", "x", "<", "0", ")", "?", "$", "x", "+", "4294967296", ":", "$", "x", ")", ";", "}" ]
Workaround for XOR on certain systems. @param integer|float $l @param integer|float $r @return float
[ "Workaround", "for", "XOR", "on", "certain", "systems", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/horde/framework/Horde/Crypt/Blowfish/Php/Base.php#L386-L392
215,128
moodle/moodle
lib/horde/framework/Horde/Crypt/Blowfish/Php/Base.php
Horde_Crypt_Blowfish_Php_Base._decipher
protected function _decipher(&$Xl, &$Xr) { if ($Xl < 0) { $Xl += 4294967296; } if ($Xr < 0) { $Xr += 4294967296; } for ($i = 17; $i > 1; --$i) { $temp = $Xl ^ $this->_P[$i]; if ($temp < 0) { $temp += 4294967296; } $Xl = fmod((fmod($this->_S[0][($temp >> 24) & 255] + $this->_S[1][($temp >> 16) & 255], 4294967296) ^ $this->_S[2][($temp >> 8) & 255]) + $this->_S[3][$temp & 255], 4294967296) ^ $Xr; $Xr = $temp; } $Xr = $this->_binxor($Xl, $this->_P[1]); $Xl = $this->_binxor($temp, $this->_P[0]); }
php
protected function _decipher(&$Xl, &$Xr) { if ($Xl < 0) { $Xl += 4294967296; } if ($Xr < 0) { $Xr += 4294967296; } for ($i = 17; $i > 1; --$i) { $temp = $Xl ^ $this->_P[$i]; if ($temp < 0) { $temp += 4294967296; } $Xl = fmod((fmod($this->_S[0][($temp >> 24) & 255] + $this->_S[1][($temp >> 16) & 255], 4294967296) ^ $this->_S[2][($temp >> 8) & 255]) + $this->_S[3][$temp & 255], 4294967296) ^ $Xr; $Xr = $temp; } $Xr = $this->_binxor($Xl, $this->_P[1]); $Xl = $this->_binxor($temp, $this->_P[0]); }
[ "protected", "function", "_decipher", "(", "&", "$", "Xl", ",", "&", "$", "Xr", ")", "{", "if", "(", "$", "Xl", "<", "0", ")", "{", "$", "Xl", "+=", "4294967296", ";", "}", "if", "(", "$", "Xr", "<", "0", ")", "{", "$", "Xr", "+=", "4294967296", ";", "}", "for", "(", "$", "i", "=", "17", ";", "$", "i", ">", "1", ";", "--", "$", "i", ")", "{", "$", "temp", "=", "$", "Xl", "^", "$", "this", "->", "_P", "[", "$", "i", "]", ";", "if", "(", "$", "temp", "<", "0", ")", "{", "$", "temp", "+=", "4294967296", ";", "}", "$", "Xl", "=", "fmod", "(", "(", "fmod", "(", "$", "this", "->", "_S", "[", "0", "]", "[", "(", "$", "temp", ">>", "24", ")", "&", "255", "]", "+", "$", "this", "->", "_S", "[", "1", "]", "[", "(", "$", "temp", ">>", "16", ")", "&", "255", "]", ",", "4294967296", ")", "^", "$", "this", "->", "_S", "[", "2", "]", "[", "(", "$", "temp", ">>", "8", ")", "&", "255", "]", ")", "+", "$", "this", "->", "_S", "[", "3", "]", "[", "$", "temp", "&", "255", "]", ",", "4294967296", ")", "^", "$", "Xr", ";", "$", "Xr", "=", "$", "temp", ";", "}", "$", "Xr", "=", "$", "this", "->", "_binxor", "(", "$", "Xl", ",", "$", "this", "->", "_P", "[", "1", "]", ")", ";", "$", "Xl", "=", "$", "this", "->", "_binxor", "(", "$", "temp", ",", "$", "this", "->", "_P", "[", "0", "]", ")", ";", "}" ]
Deciphers a single 64-bit block. @param int &$Xl @param int &$Xr
[ "Deciphers", "a", "single", "64", "-", "bit", "block", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/horde/framework/Horde/Crypt/Blowfish/Php/Base.php#L433-L457
215,129
moodle/moodle
lib/google/src/Google/IO/Curl.php
Google_IO_Curl.setTimeout
public function setTimeout($timeout) { // Since this timeout is really for putting a bound on the time // we'll set them both to the same. If you need to specify a longer // CURLOPT_TIMEOUT, or a higher CONNECTTIMEOUT, the best thing to // do is use the setOptions method for the values individually. $this->options[CURLOPT_CONNECTTIMEOUT] = $timeout; $this->options[CURLOPT_TIMEOUT] = $timeout; }
php
public function setTimeout($timeout) { // Since this timeout is really for putting a bound on the time // we'll set them both to the same. If you need to specify a longer // CURLOPT_TIMEOUT, or a higher CONNECTTIMEOUT, the best thing to // do is use the setOptions method for the values individually. $this->options[CURLOPT_CONNECTTIMEOUT] = $timeout; $this->options[CURLOPT_TIMEOUT] = $timeout; }
[ "public", "function", "setTimeout", "(", "$", "timeout", ")", "{", "// Since this timeout is really for putting a bound on the time", "// we'll set them both to the same. If you need to specify a longer", "// CURLOPT_TIMEOUT, or a higher CONNECTTIMEOUT, the best thing to", "// do is use the setOptions method for the values individually.", "$", "this", "->", "options", "[", "CURLOPT_CONNECTTIMEOUT", "]", "=", "$", "timeout", ";", "$", "this", "->", "options", "[", "CURLOPT_TIMEOUT", "]", "=", "$", "timeout", ";", "}" ]
Set the maximum request time in seconds. @param $timeout in seconds
[ "Set", "the", "maximum", "request", "time", "in", "seconds", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/google/src/Google/IO/Curl.php#L158-L166
215,130
moodle/moodle
course/classes/analytics/target/course_completion.php
course_completion.calculate_sample
protected function calculate_sample($sampleid, \core_analytics\analysable $course, $starttime = false, $endtime = false) { $userenrol = $this->retrieve('user_enrolments', $sampleid); // We use completion as a success metric. $ccompletion = new \completion_completion(array('userid' => $userenrol->userid, 'course' => $course->get_id())); if ($ccompletion->is_complete()) { return 0; } else { return 1; } }
php
protected function calculate_sample($sampleid, \core_analytics\analysable $course, $starttime = false, $endtime = false) { $userenrol = $this->retrieve('user_enrolments', $sampleid); // We use completion as a success metric. $ccompletion = new \completion_completion(array('userid' => $userenrol->userid, 'course' => $course->get_id())); if ($ccompletion->is_complete()) { return 0; } else { return 1; } }
[ "protected", "function", "calculate_sample", "(", "$", "sampleid", ",", "\\", "core_analytics", "\\", "analysable", "$", "course", ",", "$", "starttime", "=", "false", ",", "$", "endtime", "=", "false", ")", "{", "$", "userenrol", "=", "$", "this", "->", "retrieve", "(", "'user_enrolments'", ",", "$", "sampleid", ")", ";", "// We use completion as a success metric.", "$", "ccompletion", "=", "new", "\\", "completion_completion", "(", "array", "(", "'userid'", "=>", "$", "userenrol", "->", "userid", ",", "'course'", "=>", "$", "course", "->", "get_id", "(", ")", ")", ")", ";", "if", "(", "$", "ccompletion", "->", "is_complete", "(", ")", ")", "{", "return", "0", ";", "}", "else", "{", "return", "1", ";", "}", "}" ]
Course completion sets the target value. @param int $sampleid @param \core_analytics\analysable $course @param int $starttime @param int $endtime @return float 0 -> course not completed, 1 -> course completed
[ "Course", "completion", "sets", "the", "target", "value", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/course/classes/analytics/target/course_completion.php#L97-L108
215,131
moodle/moodle
question/type/shortanswer/question.php
qtype_shortanswer_question.safe_normalize
protected static function safe_normalize($string) { if ($string === '') { return ''; } if (!function_exists('normalizer_normalize')) { return $string; } $normalised = normalizer_normalize($string, Normalizer::FORM_C); if (is_null($normalised)) { // An error occurred in normalizer_normalize, but we have no idea what. debugging('Failed to normalise string: ' . $string, DEBUG_DEVELOPER); return $string; // Return the original string, since it is the best we have. } return $normalised; }
php
protected static function safe_normalize($string) { if ($string === '') { return ''; } if (!function_exists('normalizer_normalize')) { return $string; } $normalised = normalizer_normalize($string, Normalizer::FORM_C); if (is_null($normalised)) { // An error occurred in normalizer_normalize, but we have no idea what. debugging('Failed to normalise string: ' . $string, DEBUG_DEVELOPER); return $string; // Return the original string, since it is the best we have. } return $normalised; }
[ "protected", "static", "function", "safe_normalize", "(", "$", "string", ")", "{", "if", "(", "$", "string", "===", "''", ")", "{", "return", "''", ";", "}", "if", "(", "!", "function_exists", "(", "'normalizer_normalize'", ")", ")", "{", "return", "$", "string", ";", "}", "$", "normalised", "=", "normalizer_normalize", "(", "$", "string", ",", "Normalizer", "::", "FORM_C", ")", ";", "if", "(", "is_null", "(", "$", "normalised", ")", ")", "{", "// An error occurred in normalizer_normalize, but we have no idea what.", "debugging", "(", "'Failed to normalise string: '", ".", "$", "string", ",", "DEBUG_DEVELOPER", ")", ";", "return", "$", "string", ";", "// Return the original string, since it is the best we have.", "}", "return", "$", "normalised", ";", "}" ]
Normalise a UTf-8 string to FORM_C, avoiding the pitfalls in PHP's normalizer_normalize function. @param string $string the input string. @return string the normalised string.
[ "Normalise", "a", "UTf", "-", "8", "string", "to", "FORM_C", "avoiding", "the", "pitfalls", "in", "PHP", "s", "normalizer_normalize", "function", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/question/type/shortanswer/question.php#L130-L147
215,132
moodle/moodle
lib/spout/src/Spout/Reader/ReaderFactory.php
ReaderFactory.create
public static function create($readerType) { $reader = null; switch ($readerType) { case Type::CSV: $reader = new CSV\Reader(); break; case Type::XLSX: $reader = new XLSX\Reader(); break; case Type::ODS: $reader = new ODS\Reader(); break; default: throw new UnsupportedTypeException('No readers supporting the given type: ' . $readerType); } $reader->setGlobalFunctionsHelper(new GlobalFunctionsHelper()); return $reader; }
php
public static function create($readerType) { $reader = null; switch ($readerType) { case Type::CSV: $reader = new CSV\Reader(); break; case Type::XLSX: $reader = new XLSX\Reader(); break; case Type::ODS: $reader = new ODS\Reader(); break; default: throw new UnsupportedTypeException('No readers supporting the given type: ' . $readerType); } $reader->setGlobalFunctionsHelper(new GlobalFunctionsHelper()); return $reader; }
[ "public", "static", "function", "create", "(", "$", "readerType", ")", "{", "$", "reader", "=", "null", ";", "switch", "(", "$", "readerType", ")", "{", "case", "Type", "::", "CSV", ":", "$", "reader", "=", "new", "CSV", "\\", "Reader", "(", ")", ";", "break", ";", "case", "Type", "::", "XLSX", ":", "$", "reader", "=", "new", "XLSX", "\\", "Reader", "(", ")", ";", "break", ";", "case", "Type", "::", "ODS", ":", "$", "reader", "=", "new", "ODS", "\\", "Reader", "(", ")", ";", "break", ";", "default", ":", "throw", "new", "UnsupportedTypeException", "(", "'No readers supporting the given type: '", ".", "$", "readerType", ")", ";", "}", "$", "reader", "->", "setGlobalFunctionsHelper", "(", "new", "GlobalFunctionsHelper", "(", ")", ")", ";", "return", "$", "reader", ";", "}" ]
This creates an instance of the appropriate reader, given the type of the file to be read @api @param string $readerType Type of the reader to instantiate @return ReaderInterface @throws \Box\Spout\Common\Exception\UnsupportedTypeException
[ "This", "creates", "an", "instance", "of", "the", "appropriate", "reader", "given", "the", "type", "of", "the", "file", "to", "be", "read" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/spout/src/Spout/Reader/ReaderFactory.php#L26-L47
215,133
moodle/moodle
mod/forum/renderer.php
mod_forum_renderer.neighbouring_discussion_navigation
public function neighbouring_discussion_navigation($prev, $next) { $html = ''; if ($prev || $next) { $html .= html_writer::start_tag('div', array('class' => 'discussion-nav clearfix')); $html .= html_writer::start_tag('ul'); if ($prev) { $url = new moodle_url('/mod/forum/discuss.php', array('d' => $prev->id)); $html .= html_writer::start_tag('li', array('class' => 'prev-discussion')); $html .= html_writer::link($url, format_string($prev->name), array('aria-label' => get_string('prevdiscussiona', 'mod_forum', format_string($prev->name)))); $html .= html_writer::end_tag('li'); } if ($next) { $url = new moodle_url('/mod/forum/discuss.php', array('d' => $next->id)); $html .= html_writer::start_tag('li', array('class' => 'next-discussion')); $html .= html_writer::link($url, format_string($next->name), array('aria-label' => get_string('nextdiscussiona', 'mod_forum', format_string($next->name)))); $html .= html_writer::end_tag('li'); } $html .= html_writer::end_tag('ul'); $html .= html_writer::end_tag('div'); } return $html; }
php
public function neighbouring_discussion_navigation($prev, $next) { $html = ''; if ($prev || $next) { $html .= html_writer::start_tag('div', array('class' => 'discussion-nav clearfix')); $html .= html_writer::start_tag('ul'); if ($prev) { $url = new moodle_url('/mod/forum/discuss.php', array('d' => $prev->id)); $html .= html_writer::start_tag('li', array('class' => 'prev-discussion')); $html .= html_writer::link($url, format_string($prev->name), array('aria-label' => get_string('prevdiscussiona', 'mod_forum', format_string($prev->name)))); $html .= html_writer::end_tag('li'); } if ($next) { $url = new moodle_url('/mod/forum/discuss.php', array('d' => $next->id)); $html .= html_writer::start_tag('li', array('class' => 'next-discussion')); $html .= html_writer::link($url, format_string($next->name), array('aria-label' => get_string('nextdiscussiona', 'mod_forum', format_string($next->name)))); $html .= html_writer::end_tag('li'); } $html .= html_writer::end_tag('ul'); $html .= html_writer::end_tag('div'); } return $html; }
[ "public", "function", "neighbouring_discussion_navigation", "(", "$", "prev", ",", "$", "next", ")", "{", "$", "html", "=", "''", ";", "if", "(", "$", "prev", "||", "$", "next", ")", "{", "$", "html", ".=", "html_writer", "::", "start_tag", "(", "'div'", ",", "array", "(", "'class'", "=>", "'discussion-nav clearfix'", ")", ")", ";", "$", "html", ".=", "html_writer", "::", "start_tag", "(", "'ul'", ")", ";", "if", "(", "$", "prev", ")", "{", "$", "url", "=", "new", "moodle_url", "(", "'/mod/forum/discuss.php'", ",", "array", "(", "'d'", "=>", "$", "prev", "->", "id", ")", ")", ";", "$", "html", ".=", "html_writer", "::", "start_tag", "(", "'li'", ",", "array", "(", "'class'", "=>", "'prev-discussion'", ")", ")", ";", "$", "html", ".=", "html_writer", "::", "link", "(", "$", "url", ",", "format_string", "(", "$", "prev", "->", "name", ")", ",", "array", "(", "'aria-label'", "=>", "get_string", "(", "'prevdiscussiona'", ",", "'mod_forum'", ",", "format_string", "(", "$", "prev", "->", "name", ")", ")", ")", ")", ";", "$", "html", ".=", "html_writer", "::", "end_tag", "(", "'li'", ")", ";", "}", "if", "(", "$", "next", ")", "{", "$", "url", "=", "new", "moodle_url", "(", "'/mod/forum/discuss.php'", ",", "array", "(", "'d'", "=>", "$", "next", "->", "id", ")", ")", ";", "$", "html", ".=", "html_writer", "::", "start_tag", "(", "'li'", ",", "array", "(", "'class'", "=>", "'next-discussion'", ")", ")", ";", "$", "html", ".=", "html_writer", "::", "link", "(", "$", "url", ",", "format_string", "(", "$", "next", "->", "name", ")", ",", "array", "(", "'aria-label'", "=>", "get_string", "(", "'nextdiscussiona'", ",", "'mod_forum'", ",", "format_string", "(", "$", "next", "->", "name", ")", ")", ")", ")", ";", "$", "html", ".=", "html_writer", "::", "end_tag", "(", "'li'", ")", ";", "}", "$", "html", ".=", "html_writer", "::", "end_tag", "(", "'ul'", ")", ";", "$", "html", ".=", "html_writer", "::", "end_tag", "(", "'div'", ")", ";", "}", "return", "$", "html", ";", "}" ]
Returns the navigation to the previous and next discussion. @param mixed $prev Previous discussion record, or false. @param mixed $next Next discussion record, or false. @return string The output.
[ "Returns", "the", "navigation", "to", "the", "previous", "and", "next", "discussion", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/forum/renderer.php#L43-L66
215,134
moodle/moodle
mod/forum/renderer.php
mod_forum_renderer.subscriber_selection_form
public function subscriber_selection_form(user_selector_base $existinguc, user_selector_base $potentialuc) { $output = ''; $formattributes = array(); $formattributes['id'] = 'subscriberform'; $formattributes['action'] = ''; $formattributes['method'] = 'post'; $output .= html_writer::start_tag('form', $formattributes); $output .= html_writer::empty_tag('input', array('type'=>'hidden', 'name'=>'sesskey', 'value'=>sesskey())); $existingcell = new html_table_cell(); $existingcell->text = $existinguc->display(true); $existingcell->attributes['class'] = 'existing'; $actioncell = new html_table_cell(); $actioncell->text = html_writer::start_tag('div', array()); $actioncell->text .= html_writer::empty_tag('input', array('type'=>'submit', 'name'=>'subscribe', 'value'=>$this->page->theme->larrow.' '.get_string('add'), 'class'=>'actionbutton')); $actioncell->text .= html_writer::empty_tag('br', array()); $actioncell->text .= html_writer::empty_tag('input', array('type'=>'submit', 'name'=>'unsubscribe', 'value'=>$this->page->theme->rarrow.' '.get_string('remove'), 'class'=>'actionbutton')); $actioncell->text .= html_writer::end_tag('div', array()); $actioncell->attributes['class'] = 'actions'; $potentialcell = new html_table_cell(); $potentialcell->text = $potentialuc->display(true); $potentialcell->attributes['class'] = 'potential'; $table = new html_table(); $table->attributes['class'] = 'subscribertable boxaligncenter'; $table->data = array(new html_table_row(array($existingcell, $actioncell, $potentialcell))); $output .= html_writer::table($table); $output .= html_writer::end_tag('form'); return $output; }
php
public function subscriber_selection_form(user_selector_base $existinguc, user_selector_base $potentialuc) { $output = ''; $formattributes = array(); $formattributes['id'] = 'subscriberform'; $formattributes['action'] = ''; $formattributes['method'] = 'post'; $output .= html_writer::start_tag('form', $formattributes); $output .= html_writer::empty_tag('input', array('type'=>'hidden', 'name'=>'sesskey', 'value'=>sesskey())); $existingcell = new html_table_cell(); $existingcell->text = $existinguc->display(true); $existingcell->attributes['class'] = 'existing'; $actioncell = new html_table_cell(); $actioncell->text = html_writer::start_tag('div', array()); $actioncell->text .= html_writer::empty_tag('input', array('type'=>'submit', 'name'=>'subscribe', 'value'=>$this->page->theme->larrow.' '.get_string('add'), 'class'=>'actionbutton')); $actioncell->text .= html_writer::empty_tag('br', array()); $actioncell->text .= html_writer::empty_tag('input', array('type'=>'submit', 'name'=>'unsubscribe', 'value'=>$this->page->theme->rarrow.' '.get_string('remove'), 'class'=>'actionbutton')); $actioncell->text .= html_writer::end_tag('div', array()); $actioncell->attributes['class'] = 'actions'; $potentialcell = new html_table_cell(); $potentialcell->text = $potentialuc->display(true); $potentialcell->attributes['class'] = 'potential'; $table = new html_table(); $table->attributes['class'] = 'subscribertable boxaligncenter'; $table->data = array(new html_table_row(array($existingcell, $actioncell, $potentialcell))); $output .= html_writer::table($table); $output .= html_writer::end_tag('form'); return $output; }
[ "public", "function", "subscriber_selection_form", "(", "user_selector_base", "$", "existinguc", ",", "user_selector_base", "$", "potentialuc", ")", "{", "$", "output", "=", "''", ";", "$", "formattributes", "=", "array", "(", ")", ";", "$", "formattributes", "[", "'id'", "]", "=", "'subscriberform'", ";", "$", "formattributes", "[", "'action'", "]", "=", "''", ";", "$", "formattributes", "[", "'method'", "]", "=", "'post'", ";", "$", "output", ".=", "html_writer", "::", "start_tag", "(", "'form'", ",", "$", "formattributes", ")", ";", "$", "output", ".=", "html_writer", "::", "empty_tag", "(", "'input'", ",", "array", "(", "'type'", "=>", "'hidden'", ",", "'name'", "=>", "'sesskey'", ",", "'value'", "=>", "sesskey", "(", ")", ")", ")", ";", "$", "existingcell", "=", "new", "html_table_cell", "(", ")", ";", "$", "existingcell", "->", "text", "=", "$", "existinguc", "->", "display", "(", "true", ")", ";", "$", "existingcell", "->", "attributes", "[", "'class'", "]", "=", "'existing'", ";", "$", "actioncell", "=", "new", "html_table_cell", "(", ")", ";", "$", "actioncell", "->", "text", "=", "html_writer", "::", "start_tag", "(", "'div'", ",", "array", "(", ")", ")", ";", "$", "actioncell", "->", "text", ".=", "html_writer", "::", "empty_tag", "(", "'input'", ",", "array", "(", "'type'", "=>", "'submit'", ",", "'name'", "=>", "'subscribe'", ",", "'value'", "=>", "$", "this", "->", "page", "->", "theme", "->", "larrow", ".", "' '", ".", "get_string", "(", "'add'", ")", ",", "'class'", "=>", "'actionbutton'", ")", ")", ";", "$", "actioncell", "->", "text", ".=", "html_writer", "::", "empty_tag", "(", "'br'", ",", "array", "(", ")", ")", ";", "$", "actioncell", "->", "text", ".=", "html_writer", "::", "empty_tag", "(", "'input'", ",", "array", "(", "'type'", "=>", "'submit'", ",", "'name'", "=>", "'unsubscribe'", ",", "'value'", "=>", "$", "this", "->", "page", "->", "theme", "->", "rarrow", ".", "' '", ".", "get_string", "(", "'remove'", ")", ",", "'class'", "=>", "'actionbutton'", ")", ")", ";", "$", "actioncell", "->", "text", ".=", "html_writer", "::", "end_tag", "(", "'div'", ",", "array", "(", ")", ")", ";", "$", "actioncell", "->", "attributes", "[", "'class'", "]", "=", "'actions'", ";", "$", "potentialcell", "=", "new", "html_table_cell", "(", ")", ";", "$", "potentialcell", "->", "text", "=", "$", "potentialuc", "->", "display", "(", "true", ")", ";", "$", "potentialcell", "->", "attributes", "[", "'class'", "]", "=", "'potential'", ";", "$", "table", "=", "new", "html_table", "(", ")", ";", "$", "table", "->", "attributes", "[", "'class'", "]", "=", "'subscribertable boxaligncenter'", ";", "$", "table", "->", "data", "=", "array", "(", "new", "html_table_row", "(", "array", "(", "$", "existingcell", ",", "$", "actioncell", ",", "$", "potentialcell", ")", ")", ")", ";", "$", "output", ".=", "html_writer", "::", "table", "(", "$", "table", ")", ";", "$", "output", ".=", "html_writer", "::", "end_tag", "(", "'form'", ")", ";", "return", "$", "output", ";", "}" ]
This method is used to generate HTML for a subscriber selection form that uses two user_selector controls @param user_selector_base $existinguc @param user_selector_base $potentialuc @return string
[ "This", "method", "is", "used", "to", "generate", "HTML", "for", "a", "subscriber", "selection", "form", "that", "uses", "two", "user_selector", "controls" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/forum/renderer.php#L76-L106
215,135
moodle/moodle
mod/forum/renderer.php
mod_forum_renderer.subscriber_overview
public function subscriber_overview($users, $forum , $course) { $output = ''; $modinfo = get_fast_modinfo($course); if (!$users || !is_array($users) || count($users)===0) { $output .= $this->output->heading(get_string("nosubscribers", "forum")); } else if (!isset($modinfo->instances['forum'][$forum->id])) { $output .= $this->output->heading(get_string("invalidmodule", "error")); } else { $cm = $modinfo->instances['forum'][$forum->id]; $canviewemail = in_array('email', get_extra_user_fields(context_module::instance($cm->id))); $strparams = new stdclass(); $strparams->name = format_string($forum->name); $strparams->count = count($users); $output .= $this->output->heading(get_string("subscriberstowithcount", "forum", $strparams)); $table = new html_table(); $table->cellpadding = 5; $table->cellspacing = 5; $table->tablealign = 'center'; $table->data = array(); foreach ($users as $user) { $info = array($this->output->user_picture($user, array('courseid'=>$course->id)), fullname($user)); if ($canviewemail) { array_push($info, $user->email); } $table->data[] = $info; } $output .= html_writer::table($table); } return $output; }
php
public function subscriber_overview($users, $forum , $course) { $output = ''; $modinfo = get_fast_modinfo($course); if (!$users || !is_array($users) || count($users)===0) { $output .= $this->output->heading(get_string("nosubscribers", "forum")); } else if (!isset($modinfo->instances['forum'][$forum->id])) { $output .= $this->output->heading(get_string("invalidmodule", "error")); } else { $cm = $modinfo->instances['forum'][$forum->id]; $canviewemail = in_array('email', get_extra_user_fields(context_module::instance($cm->id))); $strparams = new stdclass(); $strparams->name = format_string($forum->name); $strparams->count = count($users); $output .= $this->output->heading(get_string("subscriberstowithcount", "forum", $strparams)); $table = new html_table(); $table->cellpadding = 5; $table->cellspacing = 5; $table->tablealign = 'center'; $table->data = array(); foreach ($users as $user) { $info = array($this->output->user_picture($user, array('courseid'=>$course->id)), fullname($user)); if ($canviewemail) { array_push($info, $user->email); } $table->data[] = $info; } $output .= html_writer::table($table); } return $output; }
[ "public", "function", "subscriber_overview", "(", "$", "users", ",", "$", "forum", ",", "$", "course", ")", "{", "$", "output", "=", "''", ";", "$", "modinfo", "=", "get_fast_modinfo", "(", "$", "course", ")", ";", "if", "(", "!", "$", "users", "||", "!", "is_array", "(", "$", "users", ")", "||", "count", "(", "$", "users", ")", "===", "0", ")", "{", "$", "output", ".=", "$", "this", "->", "output", "->", "heading", "(", "get_string", "(", "\"nosubscribers\"", ",", "\"forum\"", ")", ")", ";", "}", "else", "if", "(", "!", "isset", "(", "$", "modinfo", "->", "instances", "[", "'forum'", "]", "[", "$", "forum", "->", "id", "]", ")", ")", "{", "$", "output", ".=", "$", "this", "->", "output", "->", "heading", "(", "get_string", "(", "\"invalidmodule\"", ",", "\"error\"", ")", ")", ";", "}", "else", "{", "$", "cm", "=", "$", "modinfo", "->", "instances", "[", "'forum'", "]", "[", "$", "forum", "->", "id", "]", ";", "$", "canviewemail", "=", "in_array", "(", "'email'", ",", "get_extra_user_fields", "(", "context_module", "::", "instance", "(", "$", "cm", "->", "id", ")", ")", ")", ";", "$", "strparams", "=", "new", "stdclass", "(", ")", ";", "$", "strparams", "->", "name", "=", "format_string", "(", "$", "forum", "->", "name", ")", ";", "$", "strparams", "->", "count", "=", "count", "(", "$", "users", ")", ";", "$", "output", ".=", "$", "this", "->", "output", "->", "heading", "(", "get_string", "(", "\"subscriberstowithcount\"", ",", "\"forum\"", ",", "$", "strparams", ")", ")", ";", "$", "table", "=", "new", "html_table", "(", ")", ";", "$", "table", "->", "cellpadding", "=", "5", ";", "$", "table", "->", "cellspacing", "=", "5", ";", "$", "table", "->", "tablealign", "=", "'center'", ";", "$", "table", "->", "data", "=", "array", "(", ")", ";", "foreach", "(", "$", "users", "as", "$", "user", ")", "{", "$", "info", "=", "array", "(", "$", "this", "->", "output", "->", "user_picture", "(", "$", "user", ",", "array", "(", "'courseid'", "=>", "$", "course", "->", "id", ")", ")", ",", "fullname", "(", "$", "user", ")", ")", ";", "if", "(", "$", "canviewemail", ")", "{", "array_push", "(", "$", "info", ",", "$", "user", "->", "email", ")", ";", "}", "$", "table", "->", "data", "[", "]", "=", "$", "info", ";", "}", "$", "output", ".=", "html_writer", "::", "table", "(", "$", "table", ")", ";", "}", "return", "$", "output", ";", "}" ]
This function generates HTML to display a subscriber overview, primarily used on the subscribers page if editing was turned off @param array $users @param object $forum @param object $course @return string
[ "This", "function", "generates", "HTML", "to", "display", "a", "subscriber", "overview", "primarily", "used", "on", "the", "subscribers", "page", "if", "editing", "was", "turned", "off" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/forum/renderer.php#L117-L146
215,136
moodle/moodle
mod/forum/renderer.php
mod_forum_renderer.subscribed_users
public function subscribed_users(user_selector_base $existingusers) { $output = $this->output->box_start('subscriberdiv boxaligncenter'); $output .= html_writer::tag('p', get_string('forcesubscribed', 'forum')); $output .= $existingusers->display(true); $output .= $this->output->box_end(); return $output; }
php
public function subscribed_users(user_selector_base $existingusers) { $output = $this->output->box_start('subscriberdiv boxaligncenter'); $output .= html_writer::tag('p', get_string('forcesubscribed', 'forum')); $output .= $existingusers->display(true); $output .= $this->output->box_end(); return $output; }
[ "public", "function", "subscribed_users", "(", "user_selector_base", "$", "existingusers", ")", "{", "$", "output", "=", "$", "this", "->", "output", "->", "box_start", "(", "'subscriberdiv boxaligncenter'", ")", ";", "$", "output", ".=", "html_writer", "::", "tag", "(", "'p'", ",", "get_string", "(", "'forcesubscribed'", ",", "'forum'", ")", ")", ";", "$", "output", ".=", "$", "existingusers", "->", "display", "(", "true", ")", ";", "$", "output", ".=", "$", "this", "->", "output", "->", "box_end", "(", ")", ";", "return", "$", "output", ";", "}" ]
This is used to display a control containing all of the subscribed users so that it can be searched @param user_selector_base $existingusers @return string
[ "This", "is", "used", "to", "display", "a", "control", "containing", "all", "of", "the", "subscribed", "users", "so", "that", "it", "can", "be", "searched" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/forum/renderer.php#L155-L161
215,137
moodle/moodle
mod/forum/renderer.php
mod_forum_renderer.timed_discussion_tooltip
public function timed_discussion_tooltip($discussion, $visiblenow) { $dates = array(); if ($discussion->timestart) { $dates[] = get_string('displaystart', 'mod_forum').': '.userdate($discussion->timestart); } if ($discussion->timeend) { $dates[] = get_string('displayend', 'mod_forum').': '.userdate($discussion->timeend); } $str = $visiblenow ? 'timedvisible' : 'timedhidden'; $dates[] = get_string($str, 'mod_forum'); $tooltip = implode("\n", $dates); return $this->pix_icon('i/calendar', $tooltip, 'moodle', array('class' => 'smallicon timedpost')); }
php
public function timed_discussion_tooltip($discussion, $visiblenow) { $dates = array(); if ($discussion->timestart) { $dates[] = get_string('displaystart', 'mod_forum').': '.userdate($discussion->timestart); } if ($discussion->timeend) { $dates[] = get_string('displayend', 'mod_forum').': '.userdate($discussion->timeend); } $str = $visiblenow ? 'timedvisible' : 'timedhidden'; $dates[] = get_string($str, 'mod_forum'); $tooltip = implode("\n", $dates); return $this->pix_icon('i/calendar', $tooltip, 'moodle', array('class' => 'smallicon timedpost')); }
[ "public", "function", "timed_discussion_tooltip", "(", "$", "discussion", ",", "$", "visiblenow", ")", "{", "$", "dates", "=", "array", "(", ")", ";", "if", "(", "$", "discussion", "->", "timestart", ")", "{", "$", "dates", "[", "]", "=", "get_string", "(", "'displaystart'", ",", "'mod_forum'", ")", ".", "': '", ".", "userdate", "(", "$", "discussion", "->", "timestart", ")", ";", "}", "if", "(", "$", "discussion", "->", "timeend", ")", "{", "$", "dates", "[", "]", "=", "get_string", "(", "'displayend'", ",", "'mod_forum'", ")", ".", "': '", ".", "userdate", "(", "$", "discussion", "->", "timeend", ")", ";", "}", "$", "str", "=", "$", "visiblenow", "?", "'timedvisible'", ":", "'timedhidden'", ";", "$", "dates", "[", "]", "=", "get_string", "(", "$", "str", ",", "'mod_forum'", ")", ";", "$", "tooltip", "=", "implode", "(", "\"\\n\"", ",", "$", "dates", ")", ";", "return", "$", "this", "->", "pix_icon", "(", "'i/calendar'", ",", "$", "tooltip", ",", "'moodle'", ",", "array", "(", "'class'", "=>", "'smallicon timedpost'", ")", ")", ";", "}" ]
Generate the HTML for an icon to be displayed beside the subject of a timed discussion. @param object $discussion @param bool $visiblenow Indicicates that the discussion is currently visible to all users. @return string
[ "Generate", "the", "HTML", "for", "an", "icon", "to", "be", "displayed", "beside", "the", "subject", "of", "a", "timed", "discussion", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/forum/renderer.php#L171-L185
215,138
moodle/moodle
mod/forum/renderer.php
mod_forum_renderer.render_forum_post_email
public function render_forum_post_email(\mod_forum\output\forum_post_email $post) { $data = $post->export_for_template($this, $this->target === RENDERER_TARGET_TEXTEMAIL); return $this->render_from_template('mod_forum/' . $this->forum_post_template(), $data); }
php
public function render_forum_post_email(\mod_forum\output\forum_post_email $post) { $data = $post->export_for_template($this, $this->target === RENDERER_TARGET_TEXTEMAIL); return $this->render_from_template('mod_forum/' . $this->forum_post_template(), $data); }
[ "public", "function", "render_forum_post_email", "(", "\\", "mod_forum", "\\", "output", "\\", "forum_post_email", "$", "post", ")", "{", "$", "data", "=", "$", "post", "->", "export_for_template", "(", "$", "this", ",", "$", "this", "->", "target", "===", "RENDERER_TARGET_TEXTEMAIL", ")", ";", "return", "$", "this", "->", "render_from_template", "(", "'mod_forum/'", ".", "$", "this", "->", "forum_post_template", "(", ")", ",", "$", "data", ")", ";", "}" ]
Display a forum post in the relevant context. @param \mod_forum\output\forum_post $post The post to display. @return string
[ "Display", "a", "forum", "post", "in", "the", "relevant", "context", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/forum/renderer.php#L193-L196
215,139
moodle/moodle
mod/forum/renderer.php
mod_forum_renderer.render_digest_options
public function render_digest_options($forum, $value) { $options = forum_get_user_digest_options(); $editable = new \core\output\inplace_editable( 'mod_forum', 'digestoptions', $forum->id, true, $options[$value], $value ); $editable->set_type_select($options); return $editable; }
php
public function render_digest_options($forum, $value) { $options = forum_get_user_digest_options(); $editable = new \core\output\inplace_editable( 'mod_forum', 'digestoptions', $forum->id, true, $options[$value], $value ); $editable->set_type_select($options); return $editable; }
[ "public", "function", "render_digest_options", "(", "$", "forum", ",", "$", "value", ")", "{", "$", "options", "=", "forum_get_user_digest_options", "(", ")", ";", "$", "editable", "=", "new", "\\", "core", "\\", "output", "\\", "inplace_editable", "(", "'mod_forum'", ",", "'digestoptions'", ",", "$", "forum", "->", "id", ",", "true", ",", "$", "options", "[", "$", "value", "]", ",", "$", "value", ")", ";", "$", "editable", "->", "set_type_select", "(", "$", "options", ")", ";", "return", "$", "editable", ";", "}" ]
Create the inplace_editable used to select forum digest options. @param stdClass $forum The forum to create the editable for. @param int $value The current value for this user @return inplace_editable
[ "Create", "the", "inplace_editable", "used", "to", "select", "forum", "digest", "options", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/forum/renderer.php#L214-L228
215,140
moodle/moodle
mod/forum/renderer.php
mod_forum_renderer.render_quick_search_form
public function render_quick_search_form(\mod_forum\output\quick_search_form $form) { return $this->render_from_template('mod_forum/quick_search_form', $form->export_for_template($this)); }
php
public function render_quick_search_form(\mod_forum\output\quick_search_form $form) { return $this->render_from_template('mod_forum/quick_search_form', $form->export_for_template($this)); }
[ "public", "function", "render_quick_search_form", "(", "\\", "mod_forum", "\\", "output", "\\", "quick_search_form", "$", "form", ")", "{", "return", "$", "this", "->", "render_from_template", "(", "'mod_forum/quick_search_form'", ",", "$", "form", "->", "export_for_template", "(", "$", "this", ")", ")", ";", "}" ]
Render quick search form. @param \mod_forum\output\quick_search_form $form The renderable. @return string
[ "Render", "quick", "search", "form", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/forum/renderer.php#L236-L238
215,141
moodle/moodle
mod/forum/renderer.php
mod_forum_renderer.render_big_search_form
public function render_big_search_form(\mod_forum\output\big_search_form $form) { return $this->render_from_template('mod_forum/big_search_form', $form->export_for_template($this)); }
php
public function render_big_search_form(\mod_forum\output\big_search_form $form) { return $this->render_from_template('mod_forum/big_search_form', $form->export_for_template($this)); }
[ "public", "function", "render_big_search_form", "(", "\\", "mod_forum", "\\", "output", "\\", "big_search_form", "$", "form", ")", "{", "return", "$", "this", "->", "render_from_template", "(", "'mod_forum/big_search_form'", ",", "$", "form", "->", "export_for_template", "(", "$", "this", ")", ")", ";", "}" ]
Render big search form. @param \mod_forum\output\big_search_form $form The renderable. @return string
[ "Render", "big", "search", "form", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/forum/renderer.php#L246-L248
215,142
moodle/moodle
cache/stores/mongodb/MongoDB/Operation/ListCollections.php
ListCollections.executeCommand
private function executeCommand(Server $server) { $cmd = ['listCollections' => 1]; if ( ! empty($this->options['filter'])) { $cmd['filter'] = (object) $this->options['filter']; } if (isset($this->options['maxTimeMS'])) { $cmd['maxTimeMS'] = $this->options['maxTimeMS']; } $cursor = $server->executeCommand($this->databaseName, new Command($cmd), $this->createOptions()); $cursor->setTypeMap(['root' => 'array', 'document' => 'array']); return new CollectionInfoCommandIterator(new CachingIterator($cursor)); }
php
private function executeCommand(Server $server) { $cmd = ['listCollections' => 1]; if ( ! empty($this->options['filter'])) { $cmd['filter'] = (object) $this->options['filter']; } if (isset($this->options['maxTimeMS'])) { $cmd['maxTimeMS'] = $this->options['maxTimeMS']; } $cursor = $server->executeCommand($this->databaseName, new Command($cmd), $this->createOptions()); $cursor->setTypeMap(['root' => 'array', 'document' => 'array']); return new CollectionInfoCommandIterator(new CachingIterator($cursor)); }
[ "private", "function", "executeCommand", "(", "Server", "$", "server", ")", "{", "$", "cmd", "=", "[", "'listCollections'", "=>", "1", "]", ";", "if", "(", "!", "empty", "(", "$", "this", "->", "options", "[", "'filter'", "]", ")", ")", "{", "$", "cmd", "[", "'filter'", "]", "=", "(", "object", ")", "$", "this", "->", "options", "[", "'filter'", "]", ";", "}", "if", "(", "isset", "(", "$", "this", "->", "options", "[", "'maxTimeMS'", "]", ")", ")", "{", "$", "cmd", "[", "'maxTimeMS'", "]", "=", "$", "this", "->", "options", "[", "'maxTimeMS'", "]", ";", "}", "$", "cursor", "=", "$", "server", "->", "executeCommand", "(", "$", "this", "->", "databaseName", ",", "new", "Command", "(", "$", "cmd", ")", ",", "$", "this", "->", "createOptions", "(", ")", ")", ";", "$", "cursor", "->", "setTypeMap", "(", "[", "'root'", "=>", "'array'", ",", "'document'", "=>", "'array'", "]", ")", ";", "return", "new", "CollectionInfoCommandIterator", "(", "new", "CachingIterator", "(", "$", "cursor", ")", ")", ";", "}" ]
Returns information for all collections in this database using the listCollections command. @param Server $server @return CollectionInfoCommandIterator @throws DriverRuntimeException for other driver errors (e.g. connection errors)
[ "Returns", "information", "for", "all", "collections", "in", "this", "database", "using", "the", "listCollections", "command", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/cache/stores/mongodb/MongoDB/Operation/ListCollections.php#L120-L136
215,143
moodle/moodle
mod/workshop/locallib.php
workshop.installed_allocators
public static function installed_allocators() { $installed = core_component::get_plugin_list('workshopallocation'); $forms = array(); foreach ($installed as $allocation => $allocationpath) { if (file_exists($allocationpath . '/lib.php')) { $forms[$allocation] = get_string('pluginname', 'workshopallocation_' . $allocation); } } // usability - make sure that manual allocation appears the first if (isset($forms['manual'])) { $m = array('manual' => $forms['manual']); unset($forms['manual']); $forms = array_merge($m, $forms); } return $forms; }
php
public static function installed_allocators() { $installed = core_component::get_plugin_list('workshopallocation'); $forms = array(); foreach ($installed as $allocation => $allocationpath) { if (file_exists($allocationpath . '/lib.php')) { $forms[$allocation] = get_string('pluginname', 'workshopallocation_' . $allocation); } } // usability - make sure that manual allocation appears the first if (isset($forms['manual'])) { $m = array('manual' => $forms['manual']); unset($forms['manual']); $forms = array_merge($m, $forms); } return $forms; }
[ "public", "static", "function", "installed_allocators", "(", ")", "{", "$", "installed", "=", "core_component", "::", "get_plugin_list", "(", "'workshopallocation'", ")", ";", "$", "forms", "=", "array", "(", ")", ";", "foreach", "(", "$", "installed", "as", "$", "allocation", "=>", "$", "allocationpath", ")", "{", "if", "(", "file_exists", "(", "$", "allocationpath", ".", "'/lib.php'", ")", ")", "{", "$", "forms", "[", "$", "allocation", "]", "=", "get_string", "(", "'pluginname'", ",", "'workshopallocation_'", ".", "$", "allocation", ")", ";", "}", "}", "// usability - make sure that manual allocation appears the first", "if", "(", "isset", "(", "$", "forms", "[", "'manual'", "]", ")", ")", "{", "$", "m", "=", "array", "(", "'manual'", "=>", "$", "forms", "[", "'manual'", "]", ")", ";", "unset", "(", "$", "forms", "[", "'manual'", "]", ")", ";", "$", "forms", "=", "array_merge", "(", "$", "m", ",", "$", "forms", ")", ";", "}", "return", "$", "forms", ";", "}" ]
Return list of available allocation methods @return array Array ['string' => 'string'] of localized allocation method names
[ "Return", "list", "of", "available", "allocation", "methods" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/workshop/locallib.php#L239-L254
215,144
moodle/moodle
mod/workshop/locallib.php
workshop.available_example_modes_list
public static function available_example_modes_list() { $options = array(); $options[self::EXAMPLES_VOLUNTARY] = get_string('examplesvoluntary', 'workshop'); $options[self::EXAMPLES_BEFORE_SUBMISSION] = get_string('examplesbeforesubmission', 'workshop'); $options[self::EXAMPLES_BEFORE_ASSESSMENT] = get_string('examplesbeforeassessment', 'workshop'); return $options; }
php
public static function available_example_modes_list() { $options = array(); $options[self::EXAMPLES_VOLUNTARY] = get_string('examplesvoluntary', 'workshop'); $options[self::EXAMPLES_BEFORE_SUBMISSION] = get_string('examplesbeforesubmission', 'workshop'); $options[self::EXAMPLES_BEFORE_ASSESSMENT] = get_string('examplesbeforeassessment', 'workshop'); return $options; }
[ "public", "static", "function", "available_example_modes_list", "(", ")", "{", "$", "options", "=", "array", "(", ")", ";", "$", "options", "[", "self", "::", "EXAMPLES_VOLUNTARY", "]", "=", "get_string", "(", "'examplesvoluntary'", ",", "'workshop'", ")", ";", "$", "options", "[", "self", "::", "EXAMPLES_BEFORE_SUBMISSION", "]", "=", "get_string", "(", "'examplesbeforesubmission'", ",", "'workshop'", ")", ";", "$", "options", "[", "self", "::", "EXAMPLES_BEFORE_ASSESSMENT", "]", "=", "get_string", "(", "'examplesbeforeassessment'", ",", "'workshop'", ")", ";", "return", "$", "options", ";", "}" ]
Returns the localized list of supported examples modes @return array
[ "Returns", "the", "localized", "list", "of", "supported", "examples", "modes" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/workshop/locallib.php#L301-L307
215,145
moodle/moodle
mod/workshop/locallib.php
workshop.available_strategies_list
public static function available_strategies_list() { $installed = core_component::get_plugin_list('workshopform'); $forms = array(); foreach ($installed as $strategy => $strategypath) { if (file_exists($strategypath . '/lib.php')) { $forms[$strategy] = get_string('pluginname', 'workshopform_' . $strategy); } } return $forms; }
php
public static function available_strategies_list() { $installed = core_component::get_plugin_list('workshopform'); $forms = array(); foreach ($installed as $strategy => $strategypath) { if (file_exists($strategypath . '/lib.php')) { $forms[$strategy] = get_string('pluginname', 'workshopform_' . $strategy); } } return $forms; }
[ "public", "static", "function", "available_strategies_list", "(", ")", "{", "$", "installed", "=", "core_component", "::", "get_plugin_list", "(", "'workshopform'", ")", ";", "$", "forms", "=", "array", "(", ")", ";", "foreach", "(", "$", "installed", "as", "$", "strategy", "=>", "$", "strategypath", ")", "{", "if", "(", "file_exists", "(", "$", "strategypath", ".", "'/lib.php'", ")", ")", "{", "$", "forms", "[", "$", "strategy", "]", "=", "get_string", "(", "'pluginname'", ",", "'workshopform_'", ".", "$", "strategy", ")", ";", "}", "}", "return", "$", "forms", ";", "}" ]
Returns the list of available grading strategy methods @return array ['string' => 'string']
[ "Returns", "the", "list", "of", "available", "grading", "strategy", "methods" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/workshop/locallib.php#L314-L323
215,146
moodle/moodle
mod/workshop/locallib.php
workshop.available_evaluators_list
public static function available_evaluators_list() { $evals = array(); foreach (core_component::get_plugin_list_with_file('workshopeval', 'lib.php', false) as $eval => $evalpath) { $evals[$eval] = get_string('pluginname', 'workshopeval_' . $eval); } return $evals; }
php
public static function available_evaluators_list() { $evals = array(); foreach (core_component::get_plugin_list_with_file('workshopeval', 'lib.php', false) as $eval => $evalpath) { $evals[$eval] = get_string('pluginname', 'workshopeval_' . $eval); } return $evals; }
[ "public", "static", "function", "available_evaluators_list", "(", ")", "{", "$", "evals", "=", "array", "(", ")", ";", "foreach", "(", "core_component", "::", "get_plugin_list_with_file", "(", "'workshopeval'", ",", "'lib.php'", ",", "false", ")", "as", "$", "eval", "=>", "$", "evalpath", ")", "{", "$", "evals", "[", "$", "eval", "]", "=", "get_string", "(", "'pluginname'", ",", "'workshopeval_'", ".", "$", "eval", ")", ";", "}", "return", "$", "evals", ";", "}" ]
Returns the list of available grading evaluation methods @return array of (string)name => (string)localized title
[ "Returns", "the", "list", "of", "available", "grading", "evaluation", "methods" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/workshop/locallib.php#L330-L336
215,147
moodle/moodle
mod/workshop/locallib.php
workshop.gcd
public static function gcd($a, $b) { return ($b == 0) ? ($a):(self::gcd($b, $a % $b)); }
php
public static function gcd($a, $b) { return ($b == 0) ? ($a):(self::gcd($b, $a % $b)); }
[ "public", "static", "function", "gcd", "(", "$", "a", ",", "$", "b", ")", "{", "return", "(", "$", "b", "==", "0", ")", "?", "(", "$", "a", ")", ":", "(", "self", "::", "gcd", "(", "$", "b", ",", "$", "a", "%", "$", "b", ")", ")", ";", "}" ]
Helper function returning the greatest common divisor @param int $a @param int $b @return int
[ "Helper", "function", "returning", "the", "greatest", "common", "divisor" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/workshop/locallib.php#L377-L379
215,148
moodle/moodle
mod/workshop/locallib.php
workshop.clean_file_extensions
public static function clean_file_extensions($extensions) { debugging('The method workshop::clean_file_extensions() is deprecated. Please use the methods provided by the \core_form\filetypes_util class.', DEBUG_DEVELOPER); $extensions = self::normalize_file_extensions($extensions); foreach ($extensions as $i => $extension) { $extensions[$i] = ltrim($extension, '.'); } return implode(', ', $extensions); }
php
public static function clean_file_extensions($extensions) { debugging('The method workshop::clean_file_extensions() is deprecated. Please use the methods provided by the \core_form\filetypes_util class.', DEBUG_DEVELOPER); $extensions = self::normalize_file_extensions($extensions); foreach ($extensions as $i => $extension) { $extensions[$i] = ltrim($extension, '.'); } return implode(', ', $extensions); }
[ "public", "static", "function", "clean_file_extensions", "(", "$", "extensions", ")", "{", "debugging", "(", "'The method workshop::clean_file_extensions() is deprecated.\n Please use the methods provided by the \\core_form\\filetypes_util class.'", ",", "DEBUG_DEVELOPER", ")", ";", "$", "extensions", "=", "self", "::", "normalize_file_extensions", "(", "$", "extensions", ")", ";", "foreach", "(", "$", "extensions", "as", "$", "i", "=>", "$", "extension", ")", "{", "$", "extensions", "[", "$", "i", "]", "=", "ltrim", "(", "$", "extension", ",", "'.'", ")", ";", "}", "return", "implode", "(", "', '", ",", "$", "extensions", ")", ";", "}" ]
Cleans the user provided list of file extensions. @deprecated since Moodle 3.4 MDL-56486 - please use the {@link core_form\filetypes_util} @param string $extensions @return string
[ "Cleans", "the", "user", "provided", "list", "of", "file", "extensions", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/workshop/locallib.php#L485-L497
215,149
moodle/moodle
mod/workshop/locallib.php
workshop.is_allowed_file_type
public static function is_allowed_file_type($filename, $whitelist) { debugging('The method workshop::is_allowed_file_type() is deprecated. Please use the methods provided by the \core_form\filetypes_util class.', DEBUG_DEVELOPER); $whitelist = self::normalize_file_extensions($whitelist); if (empty($whitelist)) { return true; } $haystack = strrev(trim(strtolower($filename))); foreach ($whitelist as $extension) { if (strpos($haystack, strrev($extension)) === 0) { // The file name ends with the extension. return true; } } return false; }
php
public static function is_allowed_file_type($filename, $whitelist) { debugging('The method workshop::is_allowed_file_type() is deprecated. Please use the methods provided by the \core_form\filetypes_util class.', DEBUG_DEVELOPER); $whitelist = self::normalize_file_extensions($whitelist); if (empty($whitelist)) { return true; } $haystack = strrev(trim(strtolower($filename))); foreach ($whitelist as $extension) { if (strpos($haystack, strrev($extension)) === 0) { // The file name ends with the extension. return true; } } return false; }
[ "public", "static", "function", "is_allowed_file_type", "(", "$", "filename", ",", "$", "whitelist", ")", "{", "debugging", "(", "'The method workshop::is_allowed_file_type() is deprecated.\n Please use the methods provided by the \\core_form\\filetypes_util class.'", ",", "DEBUG_DEVELOPER", ")", ";", "$", "whitelist", "=", "self", "::", "normalize_file_extensions", "(", "$", "whitelist", ")", ";", "if", "(", "empty", "(", "$", "whitelist", ")", ")", "{", "return", "true", ";", "}", "$", "haystack", "=", "strrev", "(", "trim", "(", "strtolower", "(", "$", "filename", ")", ")", ")", ";", "foreach", "(", "$", "whitelist", "as", "$", "extension", ")", "{", "if", "(", "strpos", "(", "$", "haystack", ",", "strrev", "(", "$", "extension", ")", ")", "===", "0", ")", "{", "// The file name ends with the extension.", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
Is the file have allowed to be uploaded to the workshop? Empty whitelist is interpretted as "any file type is allowed" rather than "no file can be uploaded". @deprecated since Moodle 3.4 MDL-56486 - please use the {@link core_form\filetypes_util} @param string $filename the file name @param string|array $whitelist list of allowed file extensions @return false
[ "Is", "the", "file", "have", "allowed", "to", "be", "uploaded", "to", "the", "workshop?" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/workshop/locallib.php#L536-L557
215,150
moodle/moodle
mod/workshop/locallib.php
workshop.is_participant
public function is_participant($userid=null) { global $USER, $DB; if (is_null($userid)) { $userid = $USER->id; } list($sql, $params) = $this->get_participants_sql(); if (empty($sql)) { return false; } $sql = "SELECT COUNT(*) FROM {user} uxx JOIN ({$sql}) pxx ON uxx.id = pxx.id WHERE uxx.id = :uxxid"; $params['uxxid'] = $userid; if ($DB->count_records_sql($sql, $params)) { return true; } return false; }
php
public function is_participant($userid=null) { global $USER, $DB; if (is_null($userid)) { $userid = $USER->id; } list($sql, $params) = $this->get_participants_sql(); if (empty($sql)) { return false; } $sql = "SELECT COUNT(*) FROM {user} uxx JOIN ({$sql}) pxx ON uxx.id = pxx.id WHERE uxx.id = :uxxid"; $params['uxxid'] = $userid; if ($DB->count_records_sql($sql, $params)) { return true; } return false; }
[ "public", "function", "is_participant", "(", "$", "userid", "=", "null", ")", "{", "global", "$", "USER", ",", "$", "DB", ";", "if", "(", "is_null", "(", "$", "userid", ")", ")", "{", "$", "userid", "=", "$", "USER", "->", "id", ";", "}", "list", "(", "$", "sql", ",", "$", "params", ")", "=", "$", "this", "->", "get_participants_sql", "(", ")", ";", "if", "(", "empty", "(", "$", "sql", ")", ")", "{", "return", "false", ";", "}", "$", "sql", "=", "\"SELECT COUNT(*)\n FROM {user} uxx\n JOIN ({$sql}) pxx ON uxx.id = pxx.id\n WHERE uxx.id = :uxxid\"", ";", "$", "params", "[", "'uxxid'", "]", "=", "$", "userid", ";", "if", "(", "$", "DB", "->", "count_records_sql", "(", "$", "sql", ",", "$", "params", ")", ")", "{", "return", "true", ";", "}", "return", "false", ";", "}" ]
Checks if the given user is an actively enrolled participant in the workshop @param int $userid, defaults to the current $USER @return boolean
[ "Checks", "if", "the", "given", "user", "is", "an", "actively", "enrolled", "participant", "in", "the", "workshop" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/workshop/locallib.php#L724-L748
215,151
moodle/moodle
mod/workshop/locallib.php
workshop.get_grouped
public function get_grouped($users) { global $DB; global $CFG; $grouped = array(); // grouped users to be returned if (empty($users)) { return $grouped; } if ($this->cm->groupingid) { // Group workshop set to specified grouping - only consider groups // within this grouping, and leave out users who aren't members of // this grouping. $groupingid = $this->cm->groupingid; // All users that are members of at least one group will be // added into a virtual group id 0 $grouped[0] = array(); } else { $groupingid = 0; // there is no need to be member of a group so $grouped[0] will contain // all users $grouped[0] = $users; } $gmemberships = groups_get_all_groups($this->cm->course, array_keys($users), $groupingid, 'gm.id,gm.groupid,gm.userid'); foreach ($gmemberships as $gmembership) { if (!isset($grouped[$gmembership->groupid])) { $grouped[$gmembership->groupid] = array(); } $grouped[$gmembership->groupid][$gmembership->userid] = $users[$gmembership->userid]; $grouped[0][$gmembership->userid] = $users[$gmembership->userid]; } return $grouped; }
php
public function get_grouped($users) { global $DB; global $CFG; $grouped = array(); // grouped users to be returned if (empty($users)) { return $grouped; } if ($this->cm->groupingid) { // Group workshop set to specified grouping - only consider groups // within this grouping, and leave out users who aren't members of // this grouping. $groupingid = $this->cm->groupingid; // All users that are members of at least one group will be // added into a virtual group id 0 $grouped[0] = array(); } else { $groupingid = 0; // there is no need to be member of a group so $grouped[0] will contain // all users $grouped[0] = $users; } $gmemberships = groups_get_all_groups($this->cm->course, array_keys($users), $groupingid, 'gm.id,gm.groupid,gm.userid'); foreach ($gmemberships as $gmembership) { if (!isset($grouped[$gmembership->groupid])) { $grouped[$gmembership->groupid] = array(); } $grouped[$gmembership->groupid][$gmembership->userid] = $users[$gmembership->userid]; $grouped[0][$gmembership->userid] = $users[$gmembership->userid]; } return $grouped; }
[ "public", "function", "get_grouped", "(", "$", "users", ")", "{", "global", "$", "DB", ";", "global", "$", "CFG", ";", "$", "grouped", "=", "array", "(", ")", ";", "// grouped users to be returned", "if", "(", "empty", "(", "$", "users", ")", ")", "{", "return", "$", "grouped", ";", "}", "if", "(", "$", "this", "->", "cm", "->", "groupingid", ")", "{", "// Group workshop set to specified grouping - only consider groups", "// within this grouping, and leave out users who aren't members of", "// this grouping.", "$", "groupingid", "=", "$", "this", "->", "cm", "->", "groupingid", ";", "// All users that are members of at least one group will be", "// added into a virtual group id 0", "$", "grouped", "[", "0", "]", "=", "array", "(", ")", ";", "}", "else", "{", "$", "groupingid", "=", "0", ";", "// there is no need to be member of a group so $grouped[0] will contain", "// all users", "$", "grouped", "[", "0", "]", "=", "$", "users", ";", "}", "$", "gmemberships", "=", "groups_get_all_groups", "(", "$", "this", "->", "cm", "->", "course", ",", "array_keys", "(", "$", "users", ")", ",", "$", "groupingid", ",", "'gm.id,gm.groupid,gm.userid'", ")", ";", "foreach", "(", "$", "gmemberships", "as", "$", "gmembership", ")", "{", "if", "(", "!", "isset", "(", "$", "grouped", "[", "$", "gmembership", "->", "groupid", "]", ")", ")", "{", "$", "grouped", "[", "$", "gmembership", "->", "groupid", "]", "=", "array", "(", ")", ";", "}", "$", "grouped", "[", "$", "gmembership", "->", "groupid", "]", "[", "$", "gmembership", "->", "userid", "]", "=", "$", "users", "[", "$", "gmembership", "->", "userid", "]", ";", "$", "grouped", "[", "0", "]", "[", "$", "gmembership", "->", "userid", "]", "=", "$", "users", "[", "$", "gmembership", "->", "userid", "]", ";", "}", "return", "$", "grouped", ";", "}" ]
Groups the given users by the group membership This takes the module grouping settings into account. If a grouping is set, returns only groups withing the course module grouping. Always returns group [0] with all the given users. @param array $users array[userid] => stdclass{->id ->lastname ->firstname} @return array array[groupid][userid] => stdclass{->id ->lastname ->firstname}
[ "Groups", "the", "given", "users", "by", "the", "group", "membership" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/workshop/locallib.php#L760-L792
215,152
moodle/moodle
mod/workshop/locallib.php
workshop.get_submissions
public function get_submissions($authorid='all', $groupid=0, $limitfrom=0, $limitnum=0) { global $DB; $authorfields = user_picture::fields('u', null, 'authoridx', 'author'); $gradeoverbyfields = user_picture::fields('t', null, 'gradeoverbyx', 'over'); $params = array('workshopid' => $this->id); $sql = "SELECT s.id, s.workshopid, s.example, s.authorid, s.timecreated, s.timemodified, s.title, s.grade, s.gradeover, s.gradeoverby, s.published, $authorfields, $gradeoverbyfields FROM {workshop_submissions} s JOIN {user} u ON (s.authorid = u.id)"; if ($groupid) { $sql .= " JOIN {groups_members} gm ON (gm.userid = u.id AND gm.groupid = :groupid)"; $params['groupid'] = $groupid; } $sql .= " LEFT JOIN {user} t ON (s.gradeoverby = t.id) WHERE s.example = 0 AND s.workshopid = :workshopid"; if ('all' === $authorid) { // no additional conditions } elseif (!empty($authorid)) { list($usql, $uparams) = $DB->get_in_or_equal($authorid, SQL_PARAMS_NAMED); $sql .= " AND authorid $usql"; $params = array_merge($params, $uparams); } else { // $authorid is empty return array(); } list($sort, $sortparams) = users_order_by_sql('u'); $sql .= " ORDER BY $sort"; return $DB->get_records_sql($sql, array_merge($params, $sortparams), $limitfrom, $limitnum); }
php
public function get_submissions($authorid='all', $groupid=0, $limitfrom=0, $limitnum=0) { global $DB; $authorfields = user_picture::fields('u', null, 'authoridx', 'author'); $gradeoverbyfields = user_picture::fields('t', null, 'gradeoverbyx', 'over'); $params = array('workshopid' => $this->id); $sql = "SELECT s.id, s.workshopid, s.example, s.authorid, s.timecreated, s.timemodified, s.title, s.grade, s.gradeover, s.gradeoverby, s.published, $authorfields, $gradeoverbyfields FROM {workshop_submissions} s JOIN {user} u ON (s.authorid = u.id)"; if ($groupid) { $sql .= " JOIN {groups_members} gm ON (gm.userid = u.id AND gm.groupid = :groupid)"; $params['groupid'] = $groupid; } $sql .= " LEFT JOIN {user} t ON (s.gradeoverby = t.id) WHERE s.example = 0 AND s.workshopid = :workshopid"; if ('all' === $authorid) { // no additional conditions } elseif (!empty($authorid)) { list($usql, $uparams) = $DB->get_in_or_equal($authorid, SQL_PARAMS_NAMED); $sql .= " AND authorid $usql"; $params = array_merge($params, $uparams); } else { // $authorid is empty return array(); } list($sort, $sortparams) = users_order_by_sql('u'); $sql .= " ORDER BY $sort"; return $DB->get_records_sql($sql, array_merge($params, $sortparams), $limitfrom, $limitnum); }
[ "public", "function", "get_submissions", "(", "$", "authorid", "=", "'all'", ",", "$", "groupid", "=", "0", ",", "$", "limitfrom", "=", "0", ",", "$", "limitnum", "=", "0", ")", "{", "global", "$", "DB", ";", "$", "authorfields", "=", "user_picture", "::", "fields", "(", "'u'", ",", "null", ",", "'authoridx'", ",", "'author'", ")", ";", "$", "gradeoverbyfields", "=", "user_picture", "::", "fields", "(", "'t'", ",", "null", ",", "'gradeoverbyx'", ",", "'over'", ")", ";", "$", "params", "=", "array", "(", "'workshopid'", "=>", "$", "this", "->", "id", ")", ";", "$", "sql", "=", "\"SELECT s.id, s.workshopid, s.example, s.authorid, s.timecreated, s.timemodified,\n s.title, s.grade, s.gradeover, s.gradeoverby, s.published,\n $authorfields, $gradeoverbyfields\n FROM {workshop_submissions} s\n JOIN {user} u ON (s.authorid = u.id)\"", ";", "if", "(", "$", "groupid", ")", "{", "$", "sql", ".=", "\" JOIN {groups_members} gm ON (gm.userid = u.id AND gm.groupid = :groupid)\"", ";", "$", "params", "[", "'groupid'", "]", "=", "$", "groupid", ";", "}", "$", "sql", ".=", "\" LEFT JOIN {user} t ON (s.gradeoverby = t.id)\n WHERE s.example = 0 AND s.workshopid = :workshopid\"", ";", "if", "(", "'all'", "===", "$", "authorid", ")", "{", "// no additional conditions", "}", "elseif", "(", "!", "empty", "(", "$", "authorid", ")", ")", "{", "list", "(", "$", "usql", ",", "$", "uparams", ")", "=", "$", "DB", "->", "get_in_or_equal", "(", "$", "authorid", ",", "SQL_PARAMS_NAMED", ")", ";", "$", "sql", ".=", "\" AND authorid $usql\"", ";", "$", "params", "=", "array_merge", "(", "$", "params", ",", "$", "uparams", ")", ";", "}", "else", "{", "// $authorid is empty", "return", "array", "(", ")", ";", "}", "list", "(", "$", "sort", ",", "$", "sortparams", ")", "=", "users_order_by_sql", "(", "'u'", ")", ";", "$", "sql", ".=", "\" ORDER BY $sort\"", ";", "return", "$", "DB", "->", "get_records_sql", "(", "$", "sql", ",", "array_merge", "(", "$", "params", ",", "$", "sortparams", ")", ",", "$", "limitfrom", ",", "$", "limitnum", ")", ";", "}" ]
Returns submissions from this workshop Fetches data from {workshop_submissions} and adds some useful information from other tables. Does not return textual fields to prevent possible memory lack issues. @see self::count_submissions() @param mixed $authorid int|array|'all' If set to [array of] integer, return submission[s] of the given user[s] only @param int $groupid If non-zero, return only submissions by authors in the specified group @param int $limitfrom Return a subset of records, starting at this point (optional) @param int $limitnum Return a subset containing this many records in total (optional, required if $limitfrom is set) @return array of records or an empty array
[ "Returns", "submissions", "from", "this", "workshop" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/workshop/locallib.php#L861-L893
215,153
moodle/moodle
mod/workshop/locallib.php
workshop.get_submission_by_id
public function get_submission_by_id($id) { global $DB; // we intentionally check the workshopid here, too, so the workshop can't touch submissions // from other instances $authorfields = user_picture::fields('u', null, 'authoridx', 'author'); $gradeoverbyfields = user_picture::fields('g', null, 'gradeoverbyx', 'gradeoverby'); $sql = "SELECT s.*, $authorfields, $gradeoverbyfields FROM {workshop_submissions} s INNER JOIN {user} u ON (s.authorid = u.id) LEFT JOIN {user} g ON (s.gradeoverby = g.id) WHERE s.example = 0 AND s.workshopid = :workshopid AND s.id = :id"; $params = array('workshopid' => $this->id, 'id' => $id); return $DB->get_record_sql($sql, $params, MUST_EXIST); }
php
public function get_submission_by_id($id) { global $DB; // we intentionally check the workshopid here, too, so the workshop can't touch submissions // from other instances $authorfields = user_picture::fields('u', null, 'authoridx', 'author'); $gradeoverbyfields = user_picture::fields('g', null, 'gradeoverbyx', 'gradeoverby'); $sql = "SELECT s.*, $authorfields, $gradeoverbyfields FROM {workshop_submissions} s INNER JOIN {user} u ON (s.authorid = u.id) LEFT JOIN {user} g ON (s.gradeoverby = g.id) WHERE s.example = 0 AND s.workshopid = :workshopid AND s.id = :id"; $params = array('workshopid' => $this->id, 'id' => $id); return $DB->get_record_sql($sql, $params, MUST_EXIST); }
[ "public", "function", "get_submission_by_id", "(", "$", "id", ")", "{", "global", "$", "DB", ";", "// we intentionally check the workshopid here, too, so the workshop can't touch submissions", "// from other instances", "$", "authorfields", "=", "user_picture", "::", "fields", "(", "'u'", ",", "null", ",", "'authoridx'", ",", "'author'", ")", ";", "$", "gradeoverbyfields", "=", "user_picture", "::", "fields", "(", "'g'", ",", "null", ",", "'gradeoverbyx'", ",", "'gradeoverby'", ")", ";", "$", "sql", "=", "\"SELECT s.*, $authorfields, $gradeoverbyfields\n FROM {workshop_submissions} s\n INNER JOIN {user} u ON (s.authorid = u.id)\n LEFT JOIN {user} g ON (s.gradeoverby = g.id)\n WHERE s.example = 0 AND s.workshopid = :workshopid AND s.id = :id\"", ";", "$", "params", "=", "array", "(", "'workshopid'", "=>", "$", "this", "->", "id", ",", "'id'", "=>", "$", "id", ")", ";", "return", "$", "DB", "->", "get_record_sql", "(", "$", "sql", ",", "$", "params", ",", "MUST_EXIST", ")", ";", "}" ]
Returns a submission record with the author's data @param int $id submission id @return stdclass
[ "Returns", "a", "submission", "record", "with", "the", "author", "s", "data" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/workshop/locallib.php#L964-L978
215,154
moodle/moodle
mod/workshop/locallib.php
workshop.get_submission_by_author
public function get_submission_by_author($authorid) { global $DB; if (empty($authorid)) { return false; } $authorfields = user_picture::fields('u', null, 'authoridx', 'author'); $gradeoverbyfields = user_picture::fields('g', null, 'gradeoverbyx', 'gradeoverby'); $sql = "SELECT s.*, $authorfields, $gradeoverbyfields FROM {workshop_submissions} s INNER JOIN {user} u ON (s.authorid = u.id) LEFT JOIN {user} g ON (s.gradeoverby = g.id) WHERE s.example = 0 AND s.workshopid = :workshopid AND s.authorid = :authorid"; $params = array('workshopid' => $this->id, 'authorid' => $authorid); return $DB->get_record_sql($sql, $params); }
php
public function get_submission_by_author($authorid) { global $DB; if (empty($authorid)) { return false; } $authorfields = user_picture::fields('u', null, 'authoridx', 'author'); $gradeoverbyfields = user_picture::fields('g', null, 'gradeoverbyx', 'gradeoverby'); $sql = "SELECT s.*, $authorfields, $gradeoverbyfields FROM {workshop_submissions} s INNER JOIN {user} u ON (s.authorid = u.id) LEFT JOIN {user} g ON (s.gradeoverby = g.id) WHERE s.example = 0 AND s.workshopid = :workshopid AND s.authorid = :authorid"; $params = array('workshopid' => $this->id, 'authorid' => $authorid); return $DB->get_record_sql($sql, $params); }
[ "public", "function", "get_submission_by_author", "(", "$", "authorid", ")", "{", "global", "$", "DB", ";", "if", "(", "empty", "(", "$", "authorid", ")", ")", "{", "return", "false", ";", "}", "$", "authorfields", "=", "user_picture", "::", "fields", "(", "'u'", ",", "null", ",", "'authoridx'", ",", "'author'", ")", ";", "$", "gradeoverbyfields", "=", "user_picture", "::", "fields", "(", "'g'", ",", "null", ",", "'gradeoverbyx'", ",", "'gradeoverby'", ")", ";", "$", "sql", "=", "\"SELECT s.*, $authorfields, $gradeoverbyfields\n FROM {workshop_submissions} s\n INNER JOIN {user} u ON (s.authorid = u.id)\n LEFT JOIN {user} g ON (s.gradeoverby = g.id)\n WHERE s.example = 0 AND s.workshopid = :workshopid AND s.authorid = :authorid\"", ";", "$", "params", "=", "array", "(", "'workshopid'", "=>", "$", "this", "->", "id", ",", "'authorid'", "=>", "$", "authorid", ")", ";", "return", "$", "DB", "->", "get_record_sql", "(", "$", "sql", ",", "$", "params", ")", ";", "}" ]
Returns a submission submitted by the given author @param int $id author id @return stdclass|false
[ "Returns", "a", "submission", "submitted", "by", "the", "given", "author" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/workshop/locallib.php#L986-L1001
215,155
moodle/moodle
mod/workshop/locallib.php
workshop.get_published_submissions
public function get_published_submissions($orderby='finalgrade DESC') { global $DB; $authorfields = user_picture::fields('u', null, 'authoridx', 'author'); $sql = "SELECT s.id, s.authorid, s.timecreated, s.timemodified, s.title, s.grade, s.gradeover, COALESCE(s.gradeover,s.grade) AS finalgrade, $authorfields FROM {workshop_submissions} s INNER JOIN {user} u ON (s.authorid = u.id) WHERE s.example = 0 AND s.workshopid = :workshopid AND s.published = 1 ORDER BY $orderby"; $params = array('workshopid' => $this->id); return $DB->get_records_sql($sql, $params); }
php
public function get_published_submissions($orderby='finalgrade DESC') { global $DB; $authorfields = user_picture::fields('u', null, 'authoridx', 'author'); $sql = "SELECT s.id, s.authorid, s.timecreated, s.timemodified, s.title, s.grade, s.gradeover, COALESCE(s.gradeover,s.grade) AS finalgrade, $authorfields FROM {workshop_submissions} s INNER JOIN {user} u ON (s.authorid = u.id) WHERE s.example = 0 AND s.workshopid = :workshopid AND s.published = 1 ORDER BY $orderby"; $params = array('workshopid' => $this->id); return $DB->get_records_sql($sql, $params); }
[ "public", "function", "get_published_submissions", "(", "$", "orderby", "=", "'finalgrade DESC'", ")", "{", "global", "$", "DB", ";", "$", "authorfields", "=", "user_picture", "::", "fields", "(", "'u'", ",", "null", ",", "'authoridx'", ",", "'author'", ")", ";", "$", "sql", "=", "\"SELECT s.id, s.authorid, s.timecreated, s.timemodified,\n s.title, s.grade, s.gradeover, COALESCE(s.gradeover,s.grade) AS finalgrade,\n $authorfields\n FROM {workshop_submissions} s\n INNER JOIN {user} u ON (s.authorid = u.id)\n WHERE s.example = 0 AND s.workshopid = :workshopid AND s.published = 1\n ORDER BY $orderby\"", ";", "$", "params", "=", "array", "(", "'workshopid'", "=>", "$", "this", "->", "id", ")", ";", "return", "$", "DB", "->", "get_records_sql", "(", "$", "sql", ",", "$", "params", ")", ";", "}" ]
Returns published submissions with their authors data @return array of stdclass
[ "Returns", "published", "submissions", "with", "their", "authors", "data" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/workshop/locallib.php#L1008-L1021
215,156
moodle/moodle
mod/workshop/locallib.php
workshop.get_examples_for_reviewer
public function get_examples_for_reviewer($reviewerid) { global $DB; if (empty($reviewerid)) { return false; } $sql = 'SELECT s.id, s.title, a.id AS assessmentid, a.grade, a.gradinggrade FROM {workshop_submissions} s LEFT JOIN {workshop_assessments} a ON (a.submissionid = s.id AND a.reviewerid = :reviewerid AND a.weight = 0) WHERE s.example = 1 AND s.workshopid = :workshopid ORDER BY s.title'; return $DB->get_records_sql($sql, array('workshopid' => $this->id, 'reviewerid' => $reviewerid)); }
php
public function get_examples_for_reviewer($reviewerid) { global $DB; if (empty($reviewerid)) { return false; } $sql = 'SELECT s.id, s.title, a.id AS assessmentid, a.grade, a.gradinggrade FROM {workshop_submissions} s LEFT JOIN {workshop_assessments} a ON (a.submissionid = s.id AND a.reviewerid = :reviewerid AND a.weight = 0) WHERE s.example = 1 AND s.workshopid = :workshopid ORDER BY s.title'; return $DB->get_records_sql($sql, array('workshopid' => $this->id, 'reviewerid' => $reviewerid)); }
[ "public", "function", "get_examples_for_reviewer", "(", "$", "reviewerid", ")", "{", "global", "$", "DB", ";", "if", "(", "empty", "(", "$", "reviewerid", ")", ")", "{", "return", "false", ";", "}", "$", "sql", "=", "'SELECT s.id, s.title,\n a.id AS assessmentid, a.grade, a.gradinggrade\n FROM {workshop_submissions} s\n LEFT JOIN {workshop_assessments} a ON (a.submissionid = s.id AND a.reviewerid = :reviewerid AND a.weight = 0)\n WHERE s.example = 1 AND s.workshopid = :workshopid\n ORDER BY s.title'", ";", "return", "$", "DB", "->", "get_records_sql", "(", "$", "sql", ",", "array", "(", "'workshopid'", "=>", "$", "this", "->", "id", ",", "'reviewerid'", "=>", "$", "reviewerid", ")", ")", ";", "}" ]
Returns the list of all example submissions in this workshop with the information of assessments done by the given user @param int $reviewerid user id @return array of objects, indexed by example submission id @see workshop::prepare_example_summary()
[ "Returns", "the", "list", "of", "all", "example", "submissions", "in", "this", "workshop", "with", "the", "information", "of", "assessments", "done", "by", "the", "given", "user" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/workshop/locallib.php#L1060-L1073
215,157
moodle/moodle
mod/workshop/locallib.php
workshop.prepare_submission
public function prepare_submission(stdClass $record, $showauthor = false) { $submission = new workshop_submission($this, $record, $showauthor); $submission->url = $this->submission_url($record->id); return $submission; }
php
public function prepare_submission(stdClass $record, $showauthor = false) { $submission = new workshop_submission($this, $record, $showauthor); $submission->url = $this->submission_url($record->id); return $submission; }
[ "public", "function", "prepare_submission", "(", "stdClass", "$", "record", ",", "$", "showauthor", "=", "false", ")", "{", "$", "submission", "=", "new", "workshop_submission", "(", "$", "this", ",", "$", "record", ",", "$", "showauthor", ")", ";", "$", "submission", "->", "url", "=", "$", "this", "->", "submission_url", "(", "$", "record", "->", "id", ")", ";", "return", "$", "submission", ";", "}" ]
Prepares renderable submission component @param stdClass $record required by {@see workshop_submission} @param bool $showauthor show the author-related information @return workshop_submission
[ "Prepares", "renderable", "submission", "component" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/workshop/locallib.php#L1082-L1088
215,158
moodle/moodle
mod/workshop/locallib.php
workshop.prepare_submission_summary
public function prepare_submission_summary(stdClass $record, $showauthor = false) { $summary = new workshop_submission_summary($this, $record, $showauthor); $summary->url = $this->submission_url($record->id); return $summary; }
php
public function prepare_submission_summary(stdClass $record, $showauthor = false) { $summary = new workshop_submission_summary($this, $record, $showauthor); $summary->url = $this->submission_url($record->id); return $summary; }
[ "public", "function", "prepare_submission_summary", "(", "stdClass", "$", "record", ",", "$", "showauthor", "=", "false", ")", "{", "$", "summary", "=", "new", "workshop_submission_summary", "(", "$", "this", ",", "$", "record", ",", "$", "showauthor", ")", ";", "$", "summary", "->", "url", "=", "$", "this", "->", "submission_url", "(", "$", "record", "->", "id", ")", ";", "return", "$", "summary", ";", "}" ]
Prepares renderable submission summary component @param stdClass $record required by {@see workshop_submission_summary} @param bool $showauthor show the author-related information @return workshop_submission_summary
[ "Prepares", "renderable", "submission", "summary", "component" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/workshop/locallib.php#L1097-L1103
215,159
moodle/moodle
mod/workshop/locallib.php
workshop.prepare_example_summary
public function prepare_example_summary(stdClass $example) { $summary = new workshop_example_submission_summary($this, $example); if (is_null($example->grade)) { $summary->status = 'notgraded'; $summary->assesslabel = get_string('assess', 'workshop'); } else { $summary->status = 'graded'; $summary->assesslabel = get_string('reassess', 'workshop'); } $summary->gradeinfo = new stdclass(); $summary->gradeinfo->received = $this->real_grade($example->grade); $summary->gradeinfo->max = $this->real_grade(100); $summary->url = new moodle_url($this->exsubmission_url($example->id)); $summary->editurl = new moodle_url($this->exsubmission_url($example->id), array('edit' => 'on')); $summary->assessurl = new moodle_url($this->exsubmission_url($example->id), array('assess' => 'on', 'sesskey' => sesskey())); return $summary; }
php
public function prepare_example_summary(stdClass $example) { $summary = new workshop_example_submission_summary($this, $example); if (is_null($example->grade)) { $summary->status = 'notgraded'; $summary->assesslabel = get_string('assess', 'workshop'); } else { $summary->status = 'graded'; $summary->assesslabel = get_string('reassess', 'workshop'); } $summary->gradeinfo = new stdclass(); $summary->gradeinfo->received = $this->real_grade($example->grade); $summary->gradeinfo->max = $this->real_grade(100); $summary->url = new moodle_url($this->exsubmission_url($example->id)); $summary->editurl = new moodle_url($this->exsubmission_url($example->id), array('edit' => 'on')); $summary->assessurl = new moodle_url($this->exsubmission_url($example->id), array('assess' => 'on', 'sesskey' => sesskey())); return $summary; }
[ "public", "function", "prepare_example_summary", "(", "stdClass", "$", "example", ")", "{", "$", "summary", "=", "new", "workshop_example_submission_summary", "(", "$", "this", ",", "$", "example", ")", ";", "if", "(", "is_null", "(", "$", "example", "->", "grade", ")", ")", "{", "$", "summary", "->", "status", "=", "'notgraded'", ";", "$", "summary", "->", "assesslabel", "=", "get_string", "(", "'assess'", ",", "'workshop'", ")", ";", "}", "else", "{", "$", "summary", "->", "status", "=", "'graded'", ";", "$", "summary", "->", "assesslabel", "=", "get_string", "(", "'reassess'", ",", "'workshop'", ")", ";", "}", "$", "summary", "->", "gradeinfo", "=", "new", "stdclass", "(", ")", ";", "$", "summary", "->", "gradeinfo", "->", "received", "=", "$", "this", "->", "real_grade", "(", "$", "example", "->", "grade", ")", ";", "$", "summary", "->", "gradeinfo", "->", "max", "=", "$", "this", "->", "real_grade", "(", "100", ")", ";", "$", "summary", "->", "url", "=", "new", "moodle_url", "(", "$", "this", "->", "exsubmission_url", "(", "$", "example", "->", "id", ")", ")", ";", "$", "summary", "->", "editurl", "=", "new", "moodle_url", "(", "$", "this", "->", "exsubmission_url", "(", "$", "example", "->", "id", ")", ",", "array", "(", "'edit'", "=>", "'on'", ")", ")", ";", "$", "summary", "->", "assessurl", "=", "new", "moodle_url", "(", "$", "this", "->", "exsubmission_url", "(", "$", "example", "->", "id", ")", ",", "array", "(", "'assess'", "=>", "'on'", ",", "'sesskey'", "=>", "sesskey", "(", ")", ")", ")", ";", "return", "$", "summary", ";", "}" ]
Prepares renderable example submission summary component If the example is editable, the caller must set the 'editable' flag explicitly. @param stdClass $example as returned by {@link workshop::get_examples_for_manager()} or {@link workshop::get_examples_for_reviewer()} @return workshop_example_submission_summary to be rendered
[ "Prepares", "renderable", "example", "submission", "summary", "component" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/workshop/locallib.php#L1126-L1147
215,160
moodle/moodle
mod/workshop/locallib.php
workshop.prepare_assessment
public function prepare_assessment(stdClass $record, $form, array $options = array()) { $assessment = new workshop_assessment($this, $record, $options); $assessment->url = $this->assess_url($record->id); $assessment->maxgrade = $this->real_grade(100); if (!empty($options['showform']) and !($form instanceof workshop_assessment_form)) { debugging('Not a valid instance of workshop_assessment_form supplied', DEBUG_DEVELOPER); } if (!empty($options['showform']) and ($form instanceof workshop_assessment_form)) { $assessment->form = $form; } if (empty($options['showweight'])) { $assessment->weight = null; } if (!is_null($record->grade)) { $assessment->realgrade = $this->real_grade($record->grade); } return $assessment; }
php
public function prepare_assessment(stdClass $record, $form, array $options = array()) { $assessment = new workshop_assessment($this, $record, $options); $assessment->url = $this->assess_url($record->id); $assessment->maxgrade = $this->real_grade(100); if (!empty($options['showform']) and !($form instanceof workshop_assessment_form)) { debugging('Not a valid instance of workshop_assessment_form supplied', DEBUG_DEVELOPER); } if (!empty($options['showform']) and ($form instanceof workshop_assessment_form)) { $assessment->form = $form; } if (empty($options['showweight'])) { $assessment->weight = null; } if (!is_null($record->grade)) { $assessment->realgrade = $this->real_grade($record->grade); } return $assessment; }
[ "public", "function", "prepare_assessment", "(", "stdClass", "$", "record", ",", "$", "form", ",", "array", "$", "options", "=", "array", "(", ")", ")", "{", "$", "assessment", "=", "new", "workshop_assessment", "(", "$", "this", ",", "$", "record", ",", "$", "options", ")", ";", "$", "assessment", "->", "url", "=", "$", "this", "->", "assess_url", "(", "$", "record", "->", "id", ")", ";", "$", "assessment", "->", "maxgrade", "=", "$", "this", "->", "real_grade", "(", "100", ")", ";", "if", "(", "!", "empty", "(", "$", "options", "[", "'showform'", "]", ")", "and", "!", "(", "$", "form", "instanceof", "workshop_assessment_form", ")", ")", "{", "debugging", "(", "'Not a valid instance of workshop_assessment_form supplied'", ",", "DEBUG_DEVELOPER", ")", ";", "}", "if", "(", "!", "empty", "(", "$", "options", "[", "'showform'", "]", ")", "and", "(", "$", "form", "instanceof", "workshop_assessment_form", ")", ")", "{", "$", "assessment", "->", "form", "=", "$", "form", ";", "}", "if", "(", "empty", "(", "$", "options", "[", "'showweight'", "]", ")", ")", "{", "$", "assessment", "->", "weight", "=", "null", ";", "}", "if", "(", "!", "is_null", "(", "$", "record", "->", "grade", ")", ")", "{", "$", "assessment", "->", "realgrade", "=", "$", "this", "->", "real_grade", "(", "$", "record", "->", "grade", ")", ";", "}", "return", "$", "assessment", ";", "}" ]
Prepares renderable assessment component The $options array supports the following keys: showauthor - should the author user info be available for the renderer showreviewer - should the reviewer user info be available for the renderer showform - show the assessment form if it is available showweight - should the assessment weight be available for the renderer @param stdClass $record as returned by eg {@link self::get_assessment_by_id()} @param workshop_assessment_form|null $form as returned by {@link workshop_strategy::get_assessment_form()} @param array $options @return workshop_assessment
[ "Prepares", "renderable", "assessment", "component" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/workshop/locallib.php#L1163-L1186
215,161
moodle/moodle
mod/workshop/locallib.php
workshop.prepare_example_assessment
public function prepare_example_assessment(stdClass $record, $form = null, array $options = array()) { $assessment = new workshop_example_assessment($this, $record, $options); $assessment->url = $this->exassess_url($record->id); $assessment->maxgrade = $this->real_grade(100); if (!empty($options['showform']) and !($form instanceof workshop_assessment_form)) { debugging('Not a valid instance of workshop_assessment_form supplied', DEBUG_DEVELOPER); } if (!empty($options['showform']) and ($form instanceof workshop_assessment_form)) { $assessment->form = $form; } if (!is_null($record->grade)) { $assessment->realgrade = $this->real_grade($record->grade); } $assessment->weight = null; return $assessment; }
php
public function prepare_example_assessment(stdClass $record, $form = null, array $options = array()) { $assessment = new workshop_example_assessment($this, $record, $options); $assessment->url = $this->exassess_url($record->id); $assessment->maxgrade = $this->real_grade(100); if (!empty($options['showform']) and !($form instanceof workshop_assessment_form)) { debugging('Not a valid instance of workshop_assessment_form supplied', DEBUG_DEVELOPER); } if (!empty($options['showform']) and ($form instanceof workshop_assessment_form)) { $assessment->form = $form; } if (!is_null($record->grade)) { $assessment->realgrade = $this->real_grade($record->grade); } $assessment->weight = null; return $assessment; }
[ "public", "function", "prepare_example_assessment", "(", "stdClass", "$", "record", ",", "$", "form", "=", "null", ",", "array", "$", "options", "=", "array", "(", ")", ")", "{", "$", "assessment", "=", "new", "workshop_example_assessment", "(", "$", "this", ",", "$", "record", ",", "$", "options", ")", ";", "$", "assessment", "->", "url", "=", "$", "this", "->", "exassess_url", "(", "$", "record", "->", "id", ")", ";", "$", "assessment", "->", "maxgrade", "=", "$", "this", "->", "real_grade", "(", "100", ")", ";", "if", "(", "!", "empty", "(", "$", "options", "[", "'showform'", "]", ")", "and", "!", "(", "$", "form", "instanceof", "workshop_assessment_form", ")", ")", "{", "debugging", "(", "'Not a valid instance of workshop_assessment_form supplied'", ",", "DEBUG_DEVELOPER", ")", ";", "}", "if", "(", "!", "empty", "(", "$", "options", "[", "'showform'", "]", ")", "and", "(", "$", "form", "instanceof", "workshop_assessment_form", ")", ")", "{", "$", "assessment", "->", "form", "=", "$", "form", ";", "}", "if", "(", "!", "is_null", "(", "$", "record", "->", "grade", ")", ")", "{", "$", "assessment", "->", "realgrade", "=", "$", "this", "->", "real_grade", "(", "$", "record", "->", "grade", ")", ";", "}", "$", "assessment", "->", "weight", "=", "null", ";", "return", "$", "assessment", ";", "}" ]
Prepares renderable example submission's assessment component The $options array supports the following keys: showauthor - should the author user info be available for the renderer showreviewer - should the reviewer user info be available for the renderer showform - show the assessment form if it is available @param stdClass $record as returned by eg {@link self::get_assessment_by_id()} @param workshop_assessment_form|null $form as returned by {@link workshop_strategy::get_assessment_form()} @param array $options @return workshop_example_assessment
[ "Prepares", "renderable", "example", "submission", "s", "assessment", "component" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/workshop/locallib.php#L1201-L1222
215,162
moodle/moodle
mod/workshop/locallib.php
workshop.prepare_example_reference_assessment
public function prepare_example_reference_assessment(stdClass $record, $form = null, array $options = array()) { $assessment = new workshop_example_reference_assessment($this, $record, $options); $assessment->maxgrade = $this->real_grade(100); if (!empty($options['showform']) and !($form instanceof workshop_assessment_form)) { debugging('Not a valid instance of workshop_assessment_form supplied', DEBUG_DEVELOPER); } if (!empty($options['showform']) and ($form instanceof workshop_assessment_form)) { $assessment->form = $form; } if (!is_null($record->grade)) { $assessment->realgrade = $this->real_grade($record->grade); } $assessment->weight = null; return $assessment; }
php
public function prepare_example_reference_assessment(stdClass $record, $form = null, array $options = array()) { $assessment = new workshop_example_reference_assessment($this, $record, $options); $assessment->maxgrade = $this->real_grade(100); if (!empty($options['showform']) and !($form instanceof workshop_assessment_form)) { debugging('Not a valid instance of workshop_assessment_form supplied', DEBUG_DEVELOPER); } if (!empty($options['showform']) and ($form instanceof workshop_assessment_form)) { $assessment->form = $form; } if (!is_null($record->grade)) { $assessment->realgrade = $this->real_grade($record->grade); } $assessment->weight = null; return $assessment; }
[ "public", "function", "prepare_example_reference_assessment", "(", "stdClass", "$", "record", ",", "$", "form", "=", "null", ",", "array", "$", "options", "=", "array", "(", ")", ")", "{", "$", "assessment", "=", "new", "workshop_example_reference_assessment", "(", "$", "this", ",", "$", "record", ",", "$", "options", ")", ";", "$", "assessment", "->", "maxgrade", "=", "$", "this", "->", "real_grade", "(", "100", ")", ";", "if", "(", "!", "empty", "(", "$", "options", "[", "'showform'", "]", ")", "and", "!", "(", "$", "form", "instanceof", "workshop_assessment_form", ")", ")", "{", "debugging", "(", "'Not a valid instance of workshop_assessment_form supplied'", ",", "DEBUG_DEVELOPER", ")", ";", "}", "if", "(", "!", "empty", "(", "$", "options", "[", "'showform'", "]", ")", "and", "(", "$", "form", "instanceof", "workshop_assessment_form", ")", ")", "{", "$", "assessment", "->", "form", "=", "$", "form", ";", "}", "if", "(", "!", "is_null", "(", "$", "record", "->", "grade", ")", ")", "{", "$", "assessment", "->", "realgrade", "=", "$", "this", "->", "real_grade", "(", "$", "record", "->", "grade", ")", ";", "}", "$", "assessment", "->", "weight", "=", "null", ";", "return", "$", "assessment", ";", "}" ]
Prepares renderable example submission's reference assessment component The $options array supports the following keys: showauthor - should the author user info be available for the renderer showreviewer - should the reviewer user info be available for the renderer showform - show the assessment form if it is available @param stdClass $record as returned by eg {@link self::get_assessment_by_id()} @param workshop_assessment_form|null $form as returned by {@link workshop_strategy::get_assessment_form()} @param array $options @return workshop_example_reference_assessment
[ "Prepares", "renderable", "example", "submission", "s", "reference", "assessment", "component" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/workshop/locallib.php#L1237-L1257
215,163
moodle/moodle
mod/workshop/locallib.php
workshop.delete_submission
public function delete_submission(stdclass $submission) { global $DB; $assessments = $DB->get_records('workshop_assessments', array('submissionid' => $submission->id), '', 'id'); $this->delete_assessment(array_keys($assessments)); $fs = get_file_storage(); $fs->delete_area_files($this->context->id, 'mod_workshop', 'submission_content', $submission->id); $fs->delete_area_files($this->context->id, 'mod_workshop', 'submission_attachment', $submission->id); $DB->delete_records('workshop_submissions', array('id' => $submission->id)); // Event information. $params = array( 'context' => $this->context, 'courseid' => $this->course->id, 'relateduserid' => $submission->authorid, 'other' => array( 'submissiontitle' => $submission->title ) ); $params['objectid'] = $submission->id; $event = \mod_workshop\event\submission_deleted::create($params); $event->add_record_snapshot('workshop', $this->dbrecord); $event->trigger(); }
php
public function delete_submission(stdclass $submission) { global $DB; $assessments = $DB->get_records('workshop_assessments', array('submissionid' => $submission->id), '', 'id'); $this->delete_assessment(array_keys($assessments)); $fs = get_file_storage(); $fs->delete_area_files($this->context->id, 'mod_workshop', 'submission_content', $submission->id); $fs->delete_area_files($this->context->id, 'mod_workshop', 'submission_attachment', $submission->id); $DB->delete_records('workshop_submissions', array('id' => $submission->id)); // Event information. $params = array( 'context' => $this->context, 'courseid' => $this->course->id, 'relateduserid' => $submission->authorid, 'other' => array( 'submissiontitle' => $submission->title ) ); $params['objectid'] = $submission->id; $event = \mod_workshop\event\submission_deleted::create($params); $event->add_record_snapshot('workshop', $this->dbrecord); $event->trigger(); }
[ "public", "function", "delete_submission", "(", "stdclass", "$", "submission", ")", "{", "global", "$", "DB", ";", "$", "assessments", "=", "$", "DB", "->", "get_records", "(", "'workshop_assessments'", ",", "array", "(", "'submissionid'", "=>", "$", "submission", "->", "id", ")", ",", "''", ",", "'id'", ")", ";", "$", "this", "->", "delete_assessment", "(", "array_keys", "(", "$", "assessments", ")", ")", ";", "$", "fs", "=", "get_file_storage", "(", ")", ";", "$", "fs", "->", "delete_area_files", "(", "$", "this", "->", "context", "->", "id", ",", "'mod_workshop'", ",", "'submission_content'", ",", "$", "submission", "->", "id", ")", ";", "$", "fs", "->", "delete_area_files", "(", "$", "this", "->", "context", "->", "id", ",", "'mod_workshop'", ",", "'submission_attachment'", ",", "$", "submission", "->", "id", ")", ";", "$", "DB", "->", "delete_records", "(", "'workshop_submissions'", ",", "array", "(", "'id'", "=>", "$", "submission", "->", "id", ")", ")", ";", "// Event information.", "$", "params", "=", "array", "(", "'context'", "=>", "$", "this", "->", "context", ",", "'courseid'", "=>", "$", "this", "->", "course", "->", "id", ",", "'relateduserid'", "=>", "$", "submission", "->", "authorid", ",", "'other'", "=>", "array", "(", "'submissiontitle'", "=>", "$", "submission", "->", "title", ")", ")", ";", "$", "params", "[", "'objectid'", "]", "=", "$", "submission", "->", "id", ";", "$", "event", "=", "\\", "mod_workshop", "\\", "event", "\\", "submission_deleted", "::", "create", "(", "$", "params", ")", ";", "$", "event", "->", "add_record_snapshot", "(", "'workshop'", ",", "$", "this", "->", "dbrecord", ")", ";", "$", "event", "->", "trigger", "(", ")", ";", "}" ]
Removes the submission and all relevant data @param stdClass $submission record to delete @return void
[ "Removes", "the", "submission", "and", "all", "relevant", "data" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/workshop/locallib.php#L1265-L1290
215,164
moodle/moodle
mod/workshop/locallib.php
workshop.get_all_assessments
public function get_all_assessments() { global $DB; $reviewerfields = user_picture::fields('reviewer', null, 'revieweridx', 'reviewer'); $authorfields = user_picture::fields('author', null, 'authorid', 'author'); $overbyfields = user_picture::fields('overby', null, 'gradinggradeoverbyx', 'overby'); list($sort, $params) = users_order_by_sql('reviewer'); $sql = "SELECT a.id, a.submissionid, a.reviewerid, a.timecreated, a.timemodified, a.grade, a.gradinggrade, a.gradinggradeover, a.gradinggradeoverby, $reviewerfields, $authorfields, $overbyfields, s.title FROM {workshop_assessments} a INNER JOIN {user} reviewer ON (a.reviewerid = reviewer.id) INNER JOIN {workshop_submissions} s ON (a.submissionid = s.id) INNER JOIN {user} author ON (s.authorid = author.id) LEFT JOIN {user} overby ON (a.gradinggradeoverby = overby.id) WHERE s.workshopid = :workshopid AND s.example = 0 ORDER BY $sort"; $params['workshopid'] = $this->id; return $DB->get_records_sql($sql, $params); }
php
public function get_all_assessments() { global $DB; $reviewerfields = user_picture::fields('reviewer', null, 'revieweridx', 'reviewer'); $authorfields = user_picture::fields('author', null, 'authorid', 'author'); $overbyfields = user_picture::fields('overby', null, 'gradinggradeoverbyx', 'overby'); list($sort, $params) = users_order_by_sql('reviewer'); $sql = "SELECT a.id, a.submissionid, a.reviewerid, a.timecreated, a.timemodified, a.grade, a.gradinggrade, a.gradinggradeover, a.gradinggradeoverby, $reviewerfields, $authorfields, $overbyfields, s.title FROM {workshop_assessments} a INNER JOIN {user} reviewer ON (a.reviewerid = reviewer.id) INNER JOIN {workshop_submissions} s ON (a.submissionid = s.id) INNER JOIN {user} author ON (s.authorid = author.id) LEFT JOIN {user} overby ON (a.gradinggradeoverby = overby.id) WHERE s.workshopid = :workshopid AND s.example = 0 ORDER BY $sort"; $params['workshopid'] = $this->id; return $DB->get_records_sql($sql, $params); }
[ "public", "function", "get_all_assessments", "(", ")", "{", "global", "$", "DB", ";", "$", "reviewerfields", "=", "user_picture", "::", "fields", "(", "'reviewer'", ",", "null", ",", "'revieweridx'", ",", "'reviewer'", ")", ";", "$", "authorfields", "=", "user_picture", "::", "fields", "(", "'author'", ",", "null", ",", "'authorid'", ",", "'author'", ")", ";", "$", "overbyfields", "=", "user_picture", "::", "fields", "(", "'overby'", ",", "null", ",", "'gradinggradeoverbyx'", ",", "'overby'", ")", ";", "list", "(", "$", "sort", ",", "$", "params", ")", "=", "users_order_by_sql", "(", "'reviewer'", ")", ";", "$", "sql", "=", "\"SELECT a.id, a.submissionid, a.reviewerid, a.timecreated, a.timemodified,\n a.grade, a.gradinggrade, a.gradinggradeover, a.gradinggradeoverby,\n $reviewerfields, $authorfields, $overbyfields,\n s.title\n FROM {workshop_assessments} a\n INNER JOIN {user} reviewer ON (a.reviewerid = reviewer.id)\n INNER JOIN {workshop_submissions} s ON (a.submissionid = s.id)\n INNER JOIN {user} author ON (s.authorid = author.id)\n LEFT JOIN {user} overby ON (a.gradinggradeoverby = overby.id)\n WHERE s.workshopid = :workshopid AND s.example = 0\n ORDER BY $sort\"", ";", "$", "params", "[", "'workshopid'", "]", "=", "$", "this", "->", "id", ";", "return", "$", "DB", "->", "get_records_sql", "(", "$", "sql", ",", "$", "params", ")", ";", "}" ]
Returns the list of all assessments in the workshop with some data added Fetches data from {workshop_assessments} and adds some useful information from other tables. The returned object does not contain textual fields (i.e. comments) to prevent memory lack issues. @return array [assessmentid] => assessment stdclass
[ "Returns", "the", "list", "of", "all", "assessments", "in", "the", "workshop", "with", "some", "data", "added" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/workshop/locallib.php#L1301-L1322
215,165
moodle/moodle
mod/workshop/locallib.php
workshop.get_assessment_by_id
public function get_assessment_by_id($id) { global $DB; $reviewerfields = user_picture::fields('reviewer', null, 'revieweridx', 'reviewer'); $authorfields = user_picture::fields('author', null, 'authorid', 'author'); $overbyfields = user_picture::fields('overby', null, 'gradinggradeoverbyx', 'overby'); $sql = "SELECT a.*, s.title, $reviewerfields, $authorfields, $overbyfields FROM {workshop_assessments} a INNER JOIN {user} reviewer ON (a.reviewerid = reviewer.id) INNER JOIN {workshop_submissions} s ON (a.submissionid = s.id) INNER JOIN {user} author ON (s.authorid = author.id) LEFT JOIN {user} overby ON (a.gradinggradeoverby = overby.id) WHERE a.id = :id AND s.workshopid = :workshopid"; $params = array('id' => $id, 'workshopid' => $this->id); return $DB->get_record_sql($sql, $params, MUST_EXIST); }
php
public function get_assessment_by_id($id) { global $DB; $reviewerfields = user_picture::fields('reviewer', null, 'revieweridx', 'reviewer'); $authorfields = user_picture::fields('author', null, 'authorid', 'author'); $overbyfields = user_picture::fields('overby', null, 'gradinggradeoverbyx', 'overby'); $sql = "SELECT a.*, s.title, $reviewerfields, $authorfields, $overbyfields FROM {workshop_assessments} a INNER JOIN {user} reviewer ON (a.reviewerid = reviewer.id) INNER JOIN {workshop_submissions} s ON (a.submissionid = s.id) INNER JOIN {user} author ON (s.authorid = author.id) LEFT JOIN {user} overby ON (a.gradinggradeoverby = overby.id) WHERE a.id = :id AND s.workshopid = :workshopid"; $params = array('id' => $id, 'workshopid' => $this->id); return $DB->get_record_sql($sql, $params, MUST_EXIST); }
[ "public", "function", "get_assessment_by_id", "(", "$", "id", ")", "{", "global", "$", "DB", ";", "$", "reviewerfields", "=", "user_picture", "::", "fields", "(", "'reviewer'", ",", "null", ",", "'revieweridx'", ",", "'reviewer'", ")", ";", "$", "authorfields", "=", "user_picture", "::", "fields", "(", "'author'", ",", "null", ",", "'authorid'", ",", "'author'", ")", ";", "$", "overbyfields", "=", "user_picture", "::", "fields", "(", "'overby'", ",", "null", ",", "'gradinggradeoverbyx'", ",", "'overby'", ")", ";", "$", "sql", "=", "\"SELECT a.*, s.title, $reviewerfields, $authorfields, $overbyfields\n FROM {workshop_assessments} a\n INNER JOIN {user} reviewer ON (a.reviewerid = reviewer.id)\n INNER JOIN {workshop_submissions} s ON (a.submissionid = s.id)\n INNER JOIN {user} author ON (s.authorid = author.id)\n LEFT JOIN {user} overby ON (a.gradinggradeoverby = overby.id)\n WHERE a.id = :id AND s.workshopid = :workshopid\"", ";", "$", "params", "=", "array", "(", "'id'", "=>", "$", "id", ",", "'workshopid'", "=>", "$", "this", "->", "id", ")", ";", "return", "$", "DB", "->", "get_record_sql", "(", "$", "sql", ",", "$", "params", ",", "MUST_EXIST", ")", ";", "}" ]
Get the complete information about the given assessment @param int $id Assessment ID @return stdclass
[ "Get", "the", "complete", "information", "about", "the", "given", "assessment" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/workshop/locallib.php#L1330-L1346
215,166
moodle/moodle
mod/workshop/locallib.php
workshop.get_assessment_of_submission_by_user
public function get_assessment_of_submission_by_user($submissionid, $reviewerid) { global $DB; $reviewerfields = user_picture::fields('reviewer', null, 'revieweridx', 'reviewer'); $authorfields = user_picture::fields('author', null, 'authorid', 'author'); $overbyfields = user_picture::fields('overby', null, 'gradinggradeoverbyx', 'overby'); $sql = "SELECT a.*, s.title, $reviewerfields, $authorfields, $overbyfields FROM {workshop_assessments} a INNER JOIN {user} reviewer ON (a.reviewerid = reviewer.id) INNER JOIN {workshop_submissions} s ON (a.submissionid = s.id AND s.example = 0) INNER JOIN {user} author ON (s.authorid = author.id) LEFT JOIN {user} overby ON (a.gradinggradeoverby = overby.id) WHERE s.id = :sid AND reviewer.id = :rid AND s.workshopid = :workshopid"; $params = array('sid' => $submissionid, 'rid' => $reviewerid, 'workshopid' => $this->id); return $DB->get_record_sql($sql, $params, IGNORE_MISSING); }
php
public function get_assessment_of_submission_by_user($submissionid, $reviewerid) { global $DB; $reviewerfields = user_picture::fields('reviewer', null, 'revieweridx', 'reviewer'); $authorfields = user_picture::fields('author', null, 'authorid', 'author'); $overbyfields = user_picture::fields('overby', null, 'gradinggradeoverbyx', 'overby'); $sql = "SELECT a.*, s.title, $reviewerfields, $authorfields, $overbyfields FROM {workshop_assessments} a INNER JOIN {user} reviewer ON (a.reviewerid = reviewer.id) INNER JOIN {workshop_submissions} s ON (a.submissionid = s.id AND s.example = 0) INNER JOIN {user} author ON (s.authorid = author.id) LEFT JOIN {user} overby ON (a.gradinggradeoverby = overby.id) WHERE s.id = :sid AND reviewer.id = :rid AND s.workshopid = :workshopid"; $params = array('sid' => $submissionid, 'rid' => $reviewerid, 'workshopid' => $this->id); return $DB->get_record_sql($sql, $params, IGNORE_MISSING); }
[ "public", "function", "get_assessment_of_submission_by_user", "(", "$", "submissionid", ",", "$", "reviewerid", ")", "{", "global", "$", "DB", ";", "$", "reviewerfields", "=", "user_picture", "::", "fields", "(", "'reviewer'", ",", "null", ",", "'revieweridx'", ",", "'reviewer'", ")", ";", "$", "authorfields", "=", "user_picture", "::", "fields", "(", "'author'", ",", "null", ",", "'authorid'", ",", "'author'", ")", ";", "$", "overbyfields", "=", "user_picture", "::", "fields", "(", "'overby'", ",", "null", ",", "'gradinggradeoverbyx'", ",", "'overby'", ")", ";", "$", "sql", "=", "\"SELECT a.*, s.title, $reviewerfields, $authorfields, $overbyfields\n FROM {workshop_assessments} a\n INNER JOIN {user} reviewer ON (a.reviewerid = reviewer.id)\n INNER JOIN {workshop_submissions} s ON (a.submissionid = s.id AND s.example = 0)\n INNER JOIN {user} author ON (s.authorid = author.id)\n LEFT JOIN {user} overby ON (a.gradinggradeoverby = overby.id)\n WHERE s.id = :sid AND reviewer.id = :rid AND s.workshopid = :workshopid\"", ";", "$", "params", "=", "array", "(", "'sid'", "=>", "$", "submissionid", ",", "'rid'", "=>", "$", "reviewerid", ",", "'workshopid'", "=>", "$", "this", "->", "id", ")", ";", "return", "$", "DB", "->", "get_record_sql", "(", "$", "sql", ",", "$", "params", ",", "IGNORE_MISSING", ")", ";", "}" ]
Get the complete information about the user's assessment of the given submission @param int $sid submission ID @param int $uid user ID of the reviewer @return false|stdclass false if not found, stdclass otherwise
[ "Get", "the", "complete", "information", "about", "the", "user", "s", "assessment", "of", "the", "given", "submission" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/workshop/locallib.php#L1355-L1371
215,167
moodle/moodle
mod/workshop/locallib.php
workshop.get_assessments_of_submission
public function get_assessments_of_submission($submissionid) { global $DB; $reviewerfields = user_picture::fields('reviewer', null, 'revieweridx', 'reviewer'); $overbyfields = user_picture::fields('overby', null, 'gradinggradeoverbyx', 'overby'); list($sort, $params) = users_order_by_sql('reviewer'); $sql = "SELECT a.*, s.title, $reviewerfields, $overbyfields FROM {workshop_assessments} a INNER JOIN {user} reviewer ON (a.reviewerid = reviewer.id) INNER JOIN {workshop_submissions} s ON (a.submissionid = s.id) LEFT JOIN {user} overby ON (a.gradinggradeoverby = overby.id) WHERE s.example = 0 AND s.id = :submissionid AND s.workshopid = :workshopid ORDER BY $sort"; $params['submissionid'] = $submissionid; $params['workshopid'] = $this->id; return $DB->get_records_sql($sql, $params); }
php
public function get_assessments_of_submission($submissionid) { global $DB; $reviewerfields = user_picture::fields('reviewer', null, 'revieweridx', 'reviewer'); $overbyfields = user_picture::fields('overby', null, 'gradinggradeoverbyx', 'overby'); list($sort, $params) = users_order_by_sql('reviewer'); $sql = "SELECT a.*, s.title, $reviewerfields, $overbyfields FROM {workshop_assessments} a INNER JOIN {user} reviewer ON (a.reviewerid = reviewer.id) INNER JOIN {workshop_submissions} s ON (a.submissionid = s.id) LEFT JOIN {user} overby ON (a.gradinggradeoverby = overby.id) WHERE s.example = 0 AND s.id = :submissionid AND s.workshopid = :workshopid ORDER BY $sort"; $params['submissionid'] = $submissionid; $params['workshopid'] = $this->id; return $DB->get_records_sql($sql, $params); }
[ "public", "function", "get_assessments_of_submission", "(", "$", "submissionid", ")", "{", "global", "$", "DB", ";", "$", "reviewerfields", "=", "user_picture", "::", "fields", "(", "'reviewer'", ",", "null", ",", "'revieweridx'", ",", "'reviewer'", ")", ";", "$", "overbyfields", "=", "user_picture", "::", "fields", "(", "'overby'", ",", "null", ",", "'gradinggradeoverbyx'", ",", "'overby'", ")", ";", "list", "(", "$", "sort", ",", "$", "params", ")", "=", "users_order_by_sql", "(", "'reviewer'", ")", ";", "$", "sql", "=", "\"SELECT a.*, s.title, $reviewerfields, $overbyfields\n FROM {workshop_assessments} a\n INNER JOIN {user} reviewer ON (a.reviewerid = reviewer.id)\n INNER JOIN {workshop_submissions} s ON (a.submissionid = s.id)\n LEFT JOIN {user} overby ON (a.gradinggradeoverby = overby.id)\n WHERE s.example = 0 AND s.id = :submissionid AND s.workshopid = :workshopid\n ORDER BY $sort\"", ";", "$", "params", "[", "'submissionid'", "]", "=", "$", "submissionid", ";", "$", "params", "[", "'workshopid'", "]", "=", "$", "this", "->", "id", ";", "return", "$", "DB", "->", "get_records_sql", "(", "$", "sql", ",", "$", "params", ")", ";", "}" ]
Get the complete information about all assessments of the given submission @param int $submissionid @return array
[ "Get", "the", "complete", "information", "about", "all", "assessments", "of", "the", "given", "submission" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/workshop/locallib.php#L1379-L1396
215,168
moodle/moodle
mod/workshop/locallib.php
workshop.get_assessments_by_reviewer
public function get_assessments_by_reviewer($reviewerid) { global $DB; $reviewerfields = user_picture::fields('reviewer', null, 'revieweridx', 'reviewer'); $authorfields = user_picture::fields('author', null, 'authorid', 'author'); $overbyfields = user_picture::fields('overby', null, 'gradinggradeoverbyx', 'overby'); $sql = "SELECT a.*, $reviewerfields, $authorfields, $overbyfields, s.id AS submissionid, s.title AS submissiontitle, s.timecreated AS submissioncreated, s.timemodified AS submissionmodified FROM {workshop_assessments} a INNER JOIN {user} reviewer ON (a.reviewerid = reviewer.id) INNER JOIN {workshop_submissions} s ON (a.submissionid = s.id) INNER JOIN {user} author ON (s.authorid = author.id) LEFT JOIN {user} overby ON (a.gradinggradeoverby = overby.id) WHERE s.example = 0 AND reviewer.id = :reviewerid AND s.workshopid = :workshopid"; $params = array('reviewerid' => $reviewerid, 'workshopid' => $this->id); return $DB->get_records_sql($sql, $params); }
php
public function get_assessments_by_reviewer($reviewerid) { global $DB; $reviewerfields = user_picture::fields('reviewer', null, 'revieweridx', 'reviewer'); $authorfields = user_picture::fields('author', null, 'authorid', 'author'); $overbyfields = user_picture::fields('overby', null, 'gradinggradeoverbyx', 'overby'); $sql = "SELECT a.*, $reviewerfields, $authorfields, $overbyfields, s.id AS submissionid, s.title AS submissiontitle, s.timecreated AS submissioncreated, s.timemodified AS submissionmodified FROM {workshop_assessments} a INNER JOIN {user} reviewer ON (a.reviewerid = reviewer.id) INNER JOIN {workshop_submissions} s ON (a.submissionid = s.id) INNER JOIN {user} author ON (s.authorid = author.id) LEFT JOIN {user} overby ON (a.gradinggradeoverby = overby.id) WHERE s.example = 0 AND reviewer.id = :reviewerid AND s.workshopid = :workshopid"; $params = array('reviewerid' => $reviewerid, 'workshopid' => $this->id); return $DB->get_records_sql($sql, $params); }
[ "public", "function", "get_assessments_by_reviewer", "(", "$", "reviewerid", ")", "{", "global", "$", "DB", ";", "$", "reviewerfields", "=", "user_picture", "::", "fields", "(", "'reviewer'", ",", "null", ",", "'revieweridx'", ",", "'reviewer'", ")", ";", "$", "authorfields", "=", "user_picture", "::", "fields", "(", "'author'", ",", "null", ",", "'authorid'", ",", "'author'", ")", ";", "$", "overbyfields", "=", "user_picture", "::", "fields", "(", "'overby'", ",", "null", ",", "'gradinggradeoverbyx'", ",", "'overby'", ")", ";", "$", "sql", "=", "\"SELECT a.*, $reviewerfields, $authorfields, $overbyfields,\n s.id AS submissionid, s.title AS submissiontitle, s.timecreated AS submissioncreated,\n s.timemodified AS submissionmodified\n FROM {workshop_assessments} a\n INNER JOIN {user} reviewer ON (a.reviewerid = reviewer.id)\n INNER JOIN {workshop_submissions} s ON (a.submissionid = s.id)\n INNER JOIN {user} author ON (s.authorid = author.id)\n LEFT JOIN {user} overby ON (a.gradinggradeoverby = overby.id)\n WHERE s.example = 0 AND reviewer.id = :reviewerid AND s.workshopid = :workshopid\"", ";", "$", "params", "=", "array", "(", "'reviewerid'", "=>", "$", "reviewerid", ",", "'workshopid'", "=>", "$", "this", "->", "id", ")", ";", "return", "$", "DB", "->", "get_records_sql", "(", "$", "sql", ",", "$", "params", ")", ";", "}" ]
Get the complete information about all assessments allocated to the given reviewer @param int $reviewerid @return array
[ "Get", "the", "complete", "information", "about", "all", "assessments", "allocated", "to", "the", "given", "reviewer" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/workshop/locallib.php#L1404-L1422
215,169
moodle/moodle
mod/workshop/locallib.php
workshop.get_pending_assessments_by_reviewer
public function get_pending_assessments_by_reviewer($reviewerid, $exclude = null) { $assessments = $this->get_assessments_by_reviewer($reviewerid); foreach ($assessments as $id => $assessment) { if (!is_null($assessment->grade)) { unset($assessments[$id]); continue; } if (!empty($exclude)) { if (is_array($exclude) and in_array($id, $exclude)) { unset($assessments[$id]); continue; } else if ($id == $exclude) { unset($assessments[$id]); continue; } } } return $assessments; }
php
public function get_pending_assessments_by_reviewer($reviewerid, $exclude = null) { $assessments = $this->get_assessments_by_reviewer($reviewerid); foreach ($assessments as $id => $assessment) { if (!is_null($assessment->grade)) { unset($assessments[$id]); continue; } if (!empty($exclude)) { if (is_array($exclude) and in_array($id, $exclude)) { unset($assessments[$id]); continue; } else if ($id == $exclude) { unset($assessments[$id]); continue; } } } return $assessments; }
[ "public", "function", "get_pending_assessments_by_reviewer", "(", "$", "reviewerid", ",", "$", "exclude", "=", "null", ")", "{", "$", "assessments", "=", "$", "this", "->", "get_assessments_by_reviewer", "(", "$", "reviewerid", ")", ";", "foreach", "(", "$", "assessments", "as", "$", "id", "=>", "$", "assessment", ")", "{", "if", "(", "!", "is_null", "(", "$", "assessment", "->", "grade", ")", ")", "{", "unset", "(", "$", "assessments", "[", "$", "id", "]", ")", ";", "continue", ";", "}", "if", "(", "!", "empty", "(", "$", "exclude", ")", ")", "{", "if", "(", "is_array", "(", "$", "exclude", ")", "and", "in_array", "(", "$", "id", ",", "$", "exclude", ")", ")", "{", "unset", "(", "$", "assessments", "[", "$", "id", "]", ")", ";", "continue", ";", "}", "else", "if", "(", "$", "id", "==", "$", "exclude", ")", "{", "unset", "(", "$", "assessments", "[", "$", "id", "]", ")", ";", "continue", ";", "}", "}", "}", "return", "$", "assessments", ";", "}" ]
Get allocated assessments not graded yet by the given reviewer @see self::get_assessments_by_reviewer() @param int $reviewerid the reviewer id @param null|int|array $exclude optional assessment id (or list of them) to be excluded @return array
[ "Get", "allocated", "assessments", "not", "graded", "yet", "by", "the", "given", "reviewer" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/workshop/locallib.php#L1432-L1453
215,170
moodle/moodle
mod/workshop/locallib.php
workshop.add_allocation
public function add_allocation(stdclass $submission, $reviewerid, $weight=1, $bulk=false) { global $DB; if ($DB->record_exists('workshop_assessments', array('submissionid' => $submission->id, 'reviewerid' => $reviewerid))) { return self::ALLOCATION_EXISTS; } $weight = (int)$weight; if ($weight < 0) { $weight = 0; } if ($weight > 16) { $weight = 16; } $now = time(); $assessment = new stdclass(); $assessment->submissionid = $submission->id; $assessment->reviewerid = $reviewerid; $assessment->timecreated = $now; // do not set timemodified here $assessment->weight = $weight; $assessment->feedbackauthorformat = editors_get_preferred_format(); $assessment->feedbackreviewerformat = editors_get_preferred_format(); return $DB->insert_record('workshop_assessments', $assessment, true, $bulk); }
php
public function add_allocation(stdclass $submission, $reviewerid, $weight=1, $bulk=false) { global $DB; if ($DB->record_exists('workshop_assessments', array('submissionid' => $submission->id, 'reviewerid' => $reviewerid))) { return self::ALLOCATION_EXISTS; } $weight = (int)$weight; if ($weight < 0) { $weight = 0; } if ($weight > 16) { $weight = 16; } $now = time(); $assessment = new stdclass(); $assessment->submissionid = $submission->id; $assessment->reviewerid = $reviewerid; $assessment->timecreated = $now; // do not set timemodified here $assessment->weight = $weight; $assessment->feedbackauthorformat = editors_get_preferred_format(); $assessment->feedbackreviewerformat = editors_get_preferred_format(); return $DB->insert_record('workshop_assessments', $assessment, true, $bulk); }
[ "public", "function", "add_allocation", "(", "stdclass", "$", "submission", ",", "$", "reviewerid", ",", "$", "weight", "=", "1", ",", "$", "bulk", "=", "false", ")", "{", "global", "$", "DB", ";", "if", "(", "$", "DB", "->", "record_exists", "(", "'workshop_assessments'", ",", "array", "(", "'submissionid'", "=>", "$", "submission", "->", "id", ",", "'reviewerid'", "=>", "$", "reviewerid", ")", ")", ")", "{", "return", "self", "::", "ALLOCATION_EXISTS", ";", "}", "$", "weight", "=", "(", "int", ")", "$", "weight", ";", "if", "(", "$", "weight", "<", "0", ")", "{", "$", "weight", "=", "0", ";", "}", "if", "(", "$", "weight", ">", "16", ")", "{", "$", "weight", "=", "16", ";", "}", "$", "now", "=", "time", "(", ")", ";", "$", "assessment", "=", "new", "stdclass", "(", ")", ";", "$", "assessment", "->", "submissionid", "=", "$", "submission", "->", "id", ";", "$", "assessment", "->", "reviewerid", "=", "$", "reviewerid", ";", "$", "assessment", "->", "timecreated", "=", "$", "now", ";", "// do not set timemodified here", "$", "assessment", "->", "weight", "=", "$", "weight", ";", "$", "assessment", "->", "feedbackauthorformat", "=", "editors_get_preferred_format", "(", ")", ";", "$", "assessment", "->", "feedbackreviewerformat", "=", "editors_get_preferred_format", "(", ")", ";", "return", "$", "DB", "->", "insert_record", "(", "'workshop_assessments'", ",", "$", "assessment", ",", "true", ",", "$", "bulk", ")", ";", "}" ]
Allocate a submission to a user for review @param stdClass $submission Submission object with at least id property @param int $reviewerid User ID @param int $weight of the new assessment, from 0 to 16 @param bool $bulk repeated inserts into DB expected @return int ID of the new assessment or an error code {@link self::ALLOCATION_EXISTS} if the allocation already exists
[ "Allocate", "a", "submission", "to", "a", "user", "for", "review" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/workshop/locallib.php#L1464-L1489
215,171
moodle/moodle
mod/workshop/locallib.php
workshop.delete_assessment
public function delete_assessment($id) { global $DB; if (empty($id)) { return true; } $fs = get_file_storage(); if (is_array($id)) { $DB->delete_records_list('workshop_grades', 'assessmentid', $id); foreach ($id as $itemid) { $fs->delete_area_files($this->context->id, 'mod_workshop', 'overallfeedback_content', $itemid); $fs->delete_area_files($this->context->id, 'mod_workshop', 'overallfeedback_attachment', $itemid); } $DB->delete_records_list('workshop_assessments', 'id', $id); } else { $DB->delete_records('workshop_grades', array('assessmentid' => $id)); $fs->delete_area_files($this->context->id, 'mod_workshop', 'overallfeedback_content', $id); $fs->delete_area_files($this->context->id, 'mod_workshop', 'overallfeedback_attachment', $id); $DB->delete_records('workshop_assessments', array('id' => $id)); } return true; }
php
public function delete_assessment($id) { global $DB; if (empty($id)) { return true; } $fs = get_file_storage(); if (is_array($id)) { $DB->delete_records_list('workshop_grades', 'assessmentid', $id); foreach ($id as $itemid) { $fs->delete_area_files($this->context->id, 'mod_workshop', 'overallfeedback_content', $itemid); $fs->delete_area_files($this->context->id, 'mod_workshop', 'overallfeedback_attachment', $itemid); } $DB->delete_records_list('workshop_assessments', 'id', $id); } else { $DB->delete_records('workshop_grades', array('assessmentid' => $id)); $fs->delete_area_files($this->context->id, 'mod_workshop', 'overallfeedback_content', $id); $fs->delete_area_files($this->context->id, 'mod_workshop', 'overallfeedback_attachment', $id); $DB->delete_records('workshop_assessments', array('id' => $id)); } return true; }
[ "public", "function", "delete_assessment", "(", "$", "id", ")", "{", "global", "$", "DB", ";", "if", "(", "empty", "(", "$", "id", ")", ")", "{", "return", "true", ";", "}", "$", "fs", "=", "get_file_storage", "(", ")", ";", "if", "(", "is_array", "(", "$", "id", ")", ")", "{", "$", "DB", "->", "delete_records_list", "(", "'workshop_grades'", ",", "'assessmentid'", ",", "$", "id", ")", ";", "foreach", "(", "$", "id", "as", "$", "itemid", ")", "{", "$", "fs", "->", "delete_area_files", "(", "$", "this", "->", "context", "->", "id", ",", "'mod_workshop'", ",", "'overallfeedback_content'", ",", "$", "itemid", ")", ";", "$", "fs", "->", "delete_area_files", "(", "$", "this", "->", "context", "->", "id", ",", "'mod_workshop'", ",", "'overallfeedback_attachment'", ",", "$", "itemid", ")", ";", "}", "$", "DB", "->", "delete_records_list", "(", "'workshop_assessments'", ",", "'id'", ",", "$", "id", ")", ";", "}", "else", "{", "$", "DB", "->", "delete_records", "(", "'workshop_grades'", ",", "array", "(", "'assessmentid'", "=>", "$", "id", ")", ")", ";", "$", "fs", "->", "delete_area_files", "(", "$", "this", "->", "context", "->", "id", ",", "'mod_workshop'", ",", "'overallfeedback_content'", ",", "$", "id", ")", ";", "$", "fs", "->", "delete_area_files", "(", "$", "this", "->", "context", "->", "id", ",", "'mod_workshop'", ",", "'overallfeedback_attachment'", ",", "$", "id", ")", ";", "$", "DB", "->", "delete_records", "(", "'workshop_assessments'", ",", "array", "(", "'id'", "=>", "$", "id", ")", ")", ";", "}", "return", "true", ";", "}" ]
Delete assessment record or records. Removes associated records from the workshop_grades table, too. @param int|array $id assessment id or array of assessments ids @todo Give grading strategy plugins a chance to clean up their data, too. @return bool true
[ "Delete", "assessment", "record", "or", "records", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/workshop/locallib.php#L1500-L1525
215,172
moodle/moodle
mod/workshop/locallib.php
workshop.grading_strategy_instance
public function grading_strategy_instance() { global $CFG; // because we require other libs here if (is_null($this->strategyinstance)) { $strategylib = __DIR__ . '/form/' . $this->strategy . '/lib.php'; if (is_readable($strategylib)) { require_once($strategylib); } else { throw new coding_exception('the grading forms subplugin must contain library ' . $strategylib); } $classname = 'workshop_' . $this->strategy . '_strategy'; $this->strategyinstance = new $classname($this); if (!in_array('workshop_strategy', class_implements($this->strategyinstance))) { throw new coding_exception($classname . ' does not implement workshop_strategy interface'); } } return $this->strategyinstance; }
php
public function grading_strategy_instance() { global $CFG; // because we require other libs here if (is_null($this->strategyinstance)) { $strategylib = __DIR__ . '/form/' . $this->strategy . '/lib.php'; if (is_readable($strategylib)) { require_once($strategylib); } else { throw new coding_exception('the grading forms subplugin must contain library ' . $strategylib); } $classname = 'workshop_' . $this->strategy . '_strategy'; $this->strategyinstance = new $classname($this); if (!in_array('workshop_strategy', class_implements($this->strategyinstance))) { throw new coding_exception($classname . ' does not implement workshop_strategy interface'); } } return $this->strategyinstance; }
[ "public", "function", "grading_strategy_instance", "(", ")", "{", "global", "$", "CFG", ";", "// because we require other libs here", "if", "(", "is_null", "(", "$", "this", "->", "strategyinstance", ")", ")", "{", "$", "strategylib", "=", "__DIR__", ".", "'/form/'", ".", "$", "this", "->", "strategy", ".", "'/lib.php'", ";", "if", "(", "is_readable", "(", "$", "strategylib", ")", ")", "{", "require_once", "(", "$", "strategylib", ")", ";", "}", "else", "{", "throw", "new", "coding_exception", "(", "'the grading forms subplugin must contain library '", ".", "$", "strategylib", ")", ";", "}", "$", "classname", "=", "'workshop_'", ".", "$", "this", "->", "strategy", ".", "'_strategy'", ";", "$", "this", "->", "strategyinstance", "=", "new", "$", "classname", "(", "$", "this", ")", ";", "if", "(", "!", "in_array", "(", "'workshop_strategy'", ",", "class_implements", "(", "$", "this", "->", "strategyinstance", ")", ")", ")", "{", "throw", "new", "coding_exception", "(", "$", "classname", ".", "' does not implement workshop_strategy interface'", ")", ";", "}", "}", "return", "$", "this", "->", "strategyinstance", ";", "}" ]
Returns instance of grading strategy class @return stdclass Instance of a grading strategy
[ "Returns", "instance", "of", "grading", "strategy", "class" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/workshop/locallib.php#L1532-L1549
215,173
moodle/moodle
mod/workshop/locallib.php
workshop.set_grading_evaluation_method
public function set_grading_evaluation_method($method) { global $DB; $evaluationlib = __DIR__ . '/eval/' . $method . '/lib.php'; if (is_readable($evaluationlib)) { $this->evaluationinstance = null; $this->evaluation = $method; $DB->set_field('workshop', 'evaluation', $method, array('id' => $this->id)); return true; } throw new coding_exception('Attempt to set a non-existing evaluation method.'); }
php
public function set_grading_evaluation_method($method) { global $DB; $evaluationlib = __DIR__ . '/eval/' . $method . '/lib.php'; if (is_readable($evaluationlib)) { $this->evaluationinstance = null; $this->evaluation = $method; $DB->set_field('workshop', 'evaluation', $method, array('id' => $this->id)); return true; } throw new coding_exception('Attempt to set a non-existing evaluation method.'); }
[ "public", "function", "set_grading_evaluation_method", "(", "$", "method", ")", "{", "global", "$", "DB", ";", "$", "evaluationlib", "=", "__DIR__", ".", "'/eval/'", ".", "$", "method", ".", "'/lib.php'", ";", "if", "(", "is_readable", "(", "$", "evaluationlib", ")", ")", "{", "$", "this", "->", "evaluationinstance", "=", "null", ";", "$", "this", "->", "evaluation", "=", "$", "method", ";", "$", "DB", "->", "set_field", "(", "'workshop'", ",", "'evaluation'", ",", "$", "method", ",", "array", "(", "'id'", "=>", "$", "this", "->", "id", ")", ")", ";", "return", "true", ";", "}", "throw", "new", "coding_exception", "(", "'Attempt to set a non-existing evaluation method.'", ")", ";", "}" ]
Sets the current evaluation method to the given plugin. @param string $method the name of the workshopeval subplugin @return bool true if successfully set @throws coding_exception if attempting to set a non-installed evaluation method
[ "Sets", "the", "current", "evaluation", "method", "to", "the", "given", "plugin", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/workshop/locallib.php#L1558-L1571
215,174
moodle/moodle
mod/workshop/locallib.php
workshop.grading_evaluation_instance
public function grading_evaluation_instance() { global $CFG; // because we require other libs here if (is_null($this->evaluationinstance)) { if (empty($this->evaluation)) { $this->evaluation = 'best'; } $evaluationlib = __DIR__ . '/eval/' . $this->evaluation . '/lib.php'; if (is_readable($evaluationlib)) { require_once($evaluationlib); } else { // Fall back in case the subplugin is not available. $this->evaluation = 'best'; $evaluationlib = __DIR__ . '/eval/' . $this->evaluation . '/lib.php'; if (is_readable($evaluationlib)) { require_once($evaluationlib); } else { // Fall back in case the subplugin is not available any more. throw new coding_exception('Missing default grading evaluation library ' . $evaluationlib); } } $classname = 'workshop_' . $this->evaluation . '_evaluation'; $this->evaluationinstance = new $classname($this); if (!in_array('workshop_evaluation', class_parents($this->evaluationinstance))) { throw new coding_exception($classname . ' does not extend workshop_evaluation class'); } } return $this->evaluationinstance; }
php
public function grading_evaluation_instance() { global $CFG; // because we require other libs here if (is_null($this->evaluationinstance)) { if (empty($this->evaluation)) { $this->evaluation = 'best'; } $evaluationlib = __DIR__ . '/eval/' . $this->evaluation . '/lib.php'; if (is_readable($evaluationlib)) { require_once($evaluationlib); } else { // Fall back in case the subplugin is not available. $this->evaluation = 'best'; $evaluationlib = __DIR__ . '/eval/' . $this->evaluation . '/lib.php'; if (is_readable($evaluationlib)) { require_once($evaluationlib); } else { // Fall back in case the subplugin is not available any more. throw new coding_exception('Missing default grading evaluation library ' . $evaluationlib); } } $classname = 'workshop_' . $this->evaluation . '_evaluation'; $this->evaluationinstance = new $classname($this); if (!in_array('workshop_evaluation', class_parents($this->evaluationinstance))) { throw new coding_exception($classname . ' does not extend workshop_evaluation class'); } } return $this->evaluationinstance; }
[ "public", "function", "grading_evaluation_instance", "(", ")", "{", "global", "$", "CFG", ";", "// because we require other libs here", "if", "(", "is_null", "(", "$", "this", "->", "evaluationinstance", ")", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "evaluation", ")", ")", "{", "$", "this", "->", "evaluation", "=", "'best'", ";", "}", "$", "evaluationlib", "=", "__DIR__", ".", "'/eval/'", ".", "$", "this", "->", "evaluation", ".", "'/lib.php'", ";", "if", "(", "is_readable", "(", "$", "evaluationlib", ")", ")", "{", "require_once", "(", "$", "evaluationlib", ")", ";", "}", "else", "{", "// Fall back in case the subplugin is not available.", "$", "this", "->", "evaluation", "=", "'best'", ";", "$", "evaluationlib", "=", "__DIR__", ".", "'/eval/'", ".", "$", "this", "->", "evaluation", ".", "'/lib.php'", ";", "if", "(", "is_readable", "(", "$", "evaluationlib", ")", ")", "{", "require_once", "(", "$", "evaluationlib", ")", ";", "}", "else", "{", "// Fall back in case the subplugin is not available any more.", "throw", "new", "coding_exception", "(", "'Missing default grading evaluation library '", ".", "$", "evaluationlib", ")", ";", "}", "}", "$", "classname", "=", "'workshop_'", ".", "$", "this", "->", "evaluation", ".", "'_evaluation'", ";", "$", "this", "->", "evaluationinstance", "=", "new", "$", "classname", "(", "$", "this", ")", ";", "if", "(", "!", "in_array", "(", "'workshop_evaluation'", ",", "class_parents", "(", "$", "this", "->", "evaluationinstance", ")", ")", ")", "{", "throw", "new", "coding_exception", "(", "$", "classname", ".", "' does not extend workshop_evaluation class'", ")", ";", "}", "}", "return", "$", "this", "->", "evaluationinstance", ";", "}" ]
Returns instance of grading evaluation class @return stdclass Instance of a grading evaluation
[ "Returns", "instance", "of", "grading", "evaluation", "class" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/workshop/locallib.php#L1578-L1606
215,175
moodle/moodle
mod/workshop/locallib.php
workshop.allocator_instance
public function allocator_instance($method) { global $CFG; // because we require other libs here $allocationlib = __DIR__ . '/allocation/' . $method . '/lib.php'; if (is_readable($allocationlib)) { require_once($allocationlib); } else { throw new coding_exception('Unable to find the allocation library ' . $allocationlib); } $classname = 'workshop_' . $method . '_allocator'; return new $classname($this); }
php
public function allocator_instance($method) { global $CFG; // because we require other libs here $allocationlib = __DIR__ . '/allocation/' . $method . '/lib.php'; if (is_readable($allocationlib)) { require_once($allocationlib); } else { throw new coding_exception('Unable to find the allocation library ' . $allocationlib); } $classname = 'workshop_' . $method . '_allocator'; return new $classname($this); }
[ "public", "function", "allocator_instance", "(", "$", "method", ")", "{", "global", "$", "CFG", ";", "// because we require other libs here", "$", "allocationlib", "=", "__DIR__", ".", "'/allocation/'", ".", "$", "method", ".", "'/lib.php'", ";", "if", "(", "is_readable", "(", "$", "allocationlib", ")", ")", "{", "require_once", "(", "$", "allocationlib", ")", ";", "}", "else", "{", "throw", "new", "coding_exception", "(", "'Unable to find the allocation library '", ".", "$", "allocationlib", ")", ";", "}", "$", "classname", "=", "'workshop_'", ".", "$", "method", ".", "'_allocator'", ";", "return", "new", "$", "classname", "(", "$", "this", ")", ";", "}" ]
Returns instance of submissions allocator @param string $method The name of the allocation method, must be PARAM_ALPHA @return stdclass Instance of submissions allocator
[ "Returns", "instance", "of", "submissions", "allocator" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/workshop/locallib.php#L1614-L1625
215,176
moodle/moodle
mod/workshop/locallib.php
workshop.creating_submission_allowed
public function creating_submission_allowed($userid) { $now = time(); $ignoredeadlines = has_capability('mod/workshop:ignoredeadlines', $this->context, $userid); if ($this->latesubmissions) { if ($this->phase != self::PHASE_SUBMISSION and $this->phase != self::PHASE_ASSESSMENT) { // late submissions are allowed in the submission and assessment phase only return false; } if (!$ignoredeadlines and !empty($this->submissionstart) and $this->submissionstart > $now) { // late submissions are not allowed before the submission start return false; } return true; } else { if ($this->phase != self::PHASE_SUBMISSION) { // submissions are allowed during the submission phase only return false; } if (!$ignoredeadlines and !empty($this->submissionstart) and $this->submissionstart > $now) { // if enabled, submitting is not allowed before the date/time defined in the mod_form return false; } if (!$ignoredeadlines and !empty($this->submissionend) and $now > $this->submissionend ) { // if enabled, submitting is not allowed after the date/time defined in the mod_form unless late submission is allowed return false; } return true; } }
php
public function creating_submission_allowed($userid) { $now = time(); $ignoredeadlines = has_capability('mod/workshop:ignoredeadlines', $this->context, $userid); if ($this->latesubmissions) { if ($this->phase != self::PHASE_SUBMISSION and $this->phase != self::PHASE_ASSESSMENT) { // late submissions are allowed in the submission and assessment phase only return false; } if (!$ignoredeadlines and !empty($this->submissionstart) and $this->submissionstart > $now) { // late submissions are not allowed before the submission start return false; } return true; } else { if ($this->phase != self::PHASE_SUBMISSION) { // submissions are allowed during the submission phase only return false; } if (!$ignoredeadlines and !empty($this->submissionstart) and $this->submissionstart > $now) { // if enabled, submitting is not allowed before the date/time defined in the mod_form return false; } if (!$ignoredeadlines and !empty($this->submissionend) and $now > $this->submissionend ) { // if enabled, submitting is not allowed after the date/time defined in the mod_form unless late submission is allowed return false; } return true; } }
[ "public", "function", "creating_submission_allowed", "(", "$", "userid", ")", "{", "$", "now", "=", "time", "(", ")", ";", "$", "ignoredeadlines", "=", "has_capability", "(", "'mod/workshop:ignoredeadlines'", ",", "$", "this", "->", "context", ",", "$", "userid", ")", ";", "if", "(", "$", "this", "->", "latesubmissions", ")", "{", "if", "(", "$", "this", "->", "phase", "!=", "self", "::", "PHASE_SUBMISSION", "and", "$", "this", "->", "phase", "!=", "self", "::", "PHASE_ASSESSMENT", ")", "{", "// late submissions are allowed in the submission and assessment phase only", "return", "false", ";", "}", "if", "(", "!", "$", "ignoredeadlines", "and", "!", "empty", "(", "$", "this", "->", "submissionstart", ")", "and", "$", "this", "->", "submissionstart", ">", "$", "now", ")", "{", "// late submissions are not allowed before the submission start", "return", "false", ";", "}", "return", "true", ";", "}", "else", "{", "if", "(", "$", "this", "->", "phase", "!=", "self", "::", "PHASE_SUBMISSION", ")", "{", "// submissions are allowed during the submission phase only", "return", "false", ";", "}", "if", "(", "!", "$", "ignoredeadlines", "and", "!", "empty", "(", "$", "this", "->", "submissionstart", ")", "and", "$", "this", "->", "submissionstart", ">", "$", "now", ")", "{", "// if enabled, submitting is not allowed before the date/time defined in the mod_form", "return", "false", ";", "}", "if", "(", "!", "$", "ignoredeadlines", "and", "!", "empty", "(", "$", "this", "->", "submissionend", ")", "and", "$", "now", ">", "$", "this", "->", "submissionend", ")", "{", "// if enabled, submitting is not allowed after the date/time defined in the mod_form unless late submission is allowed", "return", "false", ";", "}", "return", "true", ";", "}", "}" ]
Is the given user allowed to create their submission? @param int $userid @return bool
[ "Is", "the", "given", "user", "allowed", "to", "create", "their", "submission?" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/workshop/locallib.php#L1797-L1828
215,177
moodle/moodle
mod/workshop/locallib.php
workshop.modifying_submission_allowed
public function modifying_submission_allowed($userid) { $now = time(); $ignoredeadlines = has_capability('mod/workshop:ignoredeadlines', $this->context, $userid); if ($this->phase != self::PHASE_SUBMISSION) { // submissions can be edited during the submission phase only return false; } if (!$ignoredeadlines and !empty($this->submissionstart) and $this->submissionstart > $now) { // if enabled, re-submitting is not allowed before the date/time defined in the mod_form return false; } if (!$ignoredeadlines and !empty($this->submissionend) and $now > $this->submissionend) { // if enabled, re-submitting is not allowed after the date/time defined in the mod_form even if late submission is allowed return false; } return true; }
php
public function modifying_submission_allowed($userid) { $now = time(); $ignoredeadlines = has_capability('mod/workshop:ignoredeadlines', $this->context, $userid); if ($this->phase != self::PHASE_SUBMISSION) { // submissions can be edited during the submission phase only return false; } if (!$ignoredeadlines and !empty($this->submissionstart) and $this->submissionstart > $now) { // if enabled, re-submitting is not allowed before the date/time defined in the mod_form return false; } if (!$ignoredeadlines and !empty($this->submissionend) and $now > $this->submissionend) { // if enabled, re-submitting is not allowed after the date/time defined in the mod_form even if late submission is allowed return false; } return true; }
[ "public", "function", "modifying_submission_allowed", "(", "$", "userid", ")", "{", "$", "now", "=", "time", "(", ")", ";", "$", "ignoredeadlines", "=", "has_capability", "(", "'mod/workshop:ignoredeadlines'", ",", "$", "this", "->", "context", ",", "$", "userid", ")", ";", "if", "(", "$", "this", "->", "phase", "!=", "self", "::", "PHASE_SUBMISSION", ")", "{", "// submissions can be edited during the submission phase only", "return", "false", ";", "}", "if", "(", "!", "$", "ignoredeadlines", "and", "!", "empty", "(", "$", "this", "->", "submissionstart", ")", "and", "$", "this", "->", "submissionstart", ">", "$", "now", ")", "{", "// if enabled, re-submitting is not allowed before the date/time defined in the mod_form", "return", "false", ";", "}", "if", "(", "!", "$", "ignoredeadlines", "and", "!", "empty", "(", "$", "this", "->", "submissionend", ")", "and", "$", "now", ">", "$", "this", "->", "submissionend", ")", "{", "// if enabled, re-submitting is not allowed after the date/time defined in the mod_form even if late submission is allowed", "return", "false", ";", "}", "return", "true", ";", "}" ]
Is the given user allowed to modify their existing submission? @param int $userid @return bool
[ "Is", "the", "given", "user", "allowed", "to", "modify", "their", "existing", "submission?" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/workshop/locallib.php#L1836-L1854
215,178
moodle/moodle
mod/workshop/locallib.php
workshop.switch_phase
public function switch_phase($newphase) { global $DB; $known = $this->available_phases_list(); if (!isset($known[$newphase])) { return false; } if (self::PHASE_CLOSED == $newphase) { // push the grades into the gradebook $workshop = new stdclass(); foreach ($this as $property => $value) { $workshop->{$property} = $value; } $workshop->course = $this->course->id; $workshop->cmidnumber = $this->cm->id; $workshop->modname = 'workshop'; workshop_update_grades($workshop); } $DB->set_field('workshop', 'phase', $newphase, array('id' => $this->id)); $this->phase = $newphase; $eventdata = array( 'objectid' => $this->id, 'context' => $this->context, 'other' => array( 'workshopphase' => $this->phase ) ); $event = \mod_workshop\event\phase_switched::create($eventdata); $event->trigger(); return true; }
php
public function switch_phase($newphase) { global $DB; $known = $this->available_phases_list(); if (!isset($known[$newphase])) { return false; } if (self::PHASE_CLOSED == $newphase) { // push the grades into the gradebook $workshop = new stdclass(); foreach ($this as $property => $value) { $workshop->{$property} = $value; } $workshop->course = $this->course->id; $workshop->cmidnumber = $this->cm->id; $workshop->modname = 'workshop'; workshop_update_grades($workshop); } $DB->set_field('workshop', 'phase', $newphase, array('id' => $this->id)); $this->phase = $newphase; $eventdata = array( 'objectid' => $this->id, 'context' => $this->context, 'other' => array( 'workshopphase' => $this->phase ) ); $event = \mod_workshop\event\phase_switched::create($eventdata); $event->trigger(); return true; }
[ "public", "function", "switch_phase", "(", "$", "newphase", ")", "{", "global", "$", "DB", ";", "$", "known", "=", "$", "this", "->", "available_phases_list", "(", ")", ";", "if", "(", "!", "isset", "(", "$", "known", "[", "$", "newphase", "]", ")", ")", "{", "return", "false", ";", "}", "if", "(", "self", "::", "PHASE_CLOSED", "==", "$", "newphase", ")", "{", "// push the grades into the gradebook", "$", "workshop", "=", "new", "stdclass", "(", ")", ";", "foreach", "(", "$", "this", "as", "$", "property", "=>", "$", "value", ")", "{", "$", "workshop", "->", "{", "$", "property", "}", "=", "$", "value", ";", "}", "$", "workshop", "->", "course", "=", "$", "this", "->", "course", "->", "id", ";", "$", "workshop", "->", "cmidnumber", "=", "$", "this", "->", "cm", "->", "id", ";", "$", "workshop", "->", "modname", "=", "'workshop'", ";", "workshop_update_grades", "(", "$", "workshop", ")", ";", "}", "$", "DB", "->", "set_field", "(", "'workshop'", ",", "'phase'", ",", "$", "newphase", ",", "array", "(", "'id'", "=>", "$", "this", "->", "id", ")", ")", ";", "$", "this", "->", "phase", "=", "$", "newphase", ";", "$", "eventdata", "=", "array", "(", "'objectid'", "=>", "$", "this", "->", "id", ",", "'context'", "=>", "$", "this", "->", "context", ",", "'other'", "=>", "array", "(", "'workshopphase'", "=>", "$", "this", "->", "phase", ")", ")", ";", "$", "event", "=", "\\", "mod_workshop", "\\", "event", "\\", "phase_switched", "::", "create", "(", "$", "eventdata", ")", ";", "$", "event", "->", "trigger", "(", ")", ";", "return", "true", ";", "}" ]
Switch to a new workshop phase Modifies the underlying database record. You should terminate the script shortly after calling this. @param int $newphase new phase code @return bool true if success, false otherwise
[ "Switch", "to", "a", "new", "workshop", "phase" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/workshop/locallib.php#L1929-L1961
215,179
moodle/moodle
mod/workshop/locallib.php
workshop.set_peer_grade
public function set_peer_grade($assessmentid, $grade) { global $DB; if (is_null($grade)) { return false; } $data = new stdclass(); $data->id = $assessmentid; $data->grade = $grade; $data->timemodified = time(); $DB->update_record('workshop_assessments', $data); return $grade; }
php
public function set_peer_grade($assessmentid, $grade) { global $DB; if (is_null($grade)) { return false; } $data = new stdclass(); $data->id = $assessmentid; $data->grade = $grade; $data->timemodified = time(); $DB->update_record('workshop_assessments', $data); return $grade; }
[ "public", "function", "set_peer_grade", "(", "$", "assessmentid", ",", "$", "grade", ")", "{", "global", "$", "DB", ";", "if", "(", "is_null", "(", "$", "grade", ")", ")", "{", "return", "false", ";", "}", "$", "data", "=", "new", "stdclass", "(", ")", ";", "$", "data", "->", "id", "=", "$", "assessmentid", ";", "$", "data", "->", "grade", "=", "$", "grade", ";", "$", "data", "->", "timemodified", "=", "time", "(", ")", ";", "$", "DB", "->", "update_record", "(", "'workshop_assessments'", ",", "$", "data", ")", ";", "return", "$", "grade", ";", "}" ]
Saves a raw grade for submission as calculated from the assessment form fields @param array $assessmentid assessment record id, must exists @param mixed $grade raw percentual grade from 0.00000 to 100.00000 @return false|float the saved grade
[ "Saves", "a", "raw", "grade", "for", "submission", "as", "calculated", "from", "the", "assessment", "form", "fields" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/workshop/locallib.php#L1970-L1982
215,180
moodle/moodle
mod/workshop/locallib.php
workshop.real_grade_value
public function real_grade_value($value, $max) { $localized = true; if (is_null($value) or $value === '') { return null; } elseif ($max == 0) { return 0; } else { return format_float($max * $value / 100, $this->gradedecimals, $localized); } }
php
public function real_grade_value($value, $max) { $localized = true; if (is_null($value) or $value === '') { return null; } elseif ($max == 0) { return 0; } else { return format_float($max * $value / 100, $this->gradedecimals, $localized); } }
[ "public", "function", "real_grade_value", "(", "$", "value", ",", "$", "max", ")", "{", "$", "localized", "=", "true", ";", "if", "(", "is_null", "(", "$", "value", ")", "or", "$", "value", "===", "''", ")", "{", "return", "null", ";", "}", "elseif", "(", "$", "max", "==", "0", ")", "{", "return", "0", ";", "}", "else", "{", "return", "format_float", "(", "$", "max", "*", "$", "value", "/", "100", ",", "$", "this", "->", "gradedecimals", ",", "$", "localized", ")", ";", "}", "}" ]
Calculates the real value of a grade @param float $value percentual value from 0 to 100 @param float $max the maximal grade @return string
[ "Calculates", "the", "real", "value", "of", "a", "grade" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/workshop/locallib.php#L2221-L2230
215,181
moodle/moodle
mod/workshop/locallib.php
workshop.clear_assessments
public function clear_assessments() { global $DB; $submissions = $this->get_submissions(); if (empty($submissions)) { // no money, no love return; } $submissions = array_keys($submissions); list($sql, $params) = $DB->get_in_or_equal($submissions, SQL_PARAMS_NAMED); $sql = "submissionid $sql"; $DB->set_field_select('workshop_assessments', 'grade', null, $sql, $params); $DB->set_field_select('workshop_assessments', 'gradinggrade', null, $sql, $params); }
php
public function clear_assessments() { global $DB; $submissions = $this->get_submissions(); if (empty($submissions)) { // no money, no love return; } $submissions = array_keys($submissions); list($sql, $params) = $DB->get_in_or_equal($submissions, SQL_PARAMS_NAMED); $sql = "submissionid $sql"; $DB->set_field_select('workshop_assessments', 'grade', null, $sql, $params); $DB->set_field_select('workshop_assessments', 'gradinggrade', null, $sql, $params); }
[ "public", "function", "clear_assessments", "(", ")", "{", "global", "$", "DB", ";", "$", "submissions", "=", "$", "this", "->", "get_submissions", "(", ")", ";", "if", "(", "empty", "(", "$", "submissions", ")", ")", "{", "// no money, no love", "return", ";", "}", "$", "submissions", "=", "array_keys", "(", "$", "submissions", ")", ";", "list", "(", "$", "sql", ",", "$", "params", ")", "=", "$", "DB", "->", "get_in_or_equal", "(", "$", "submissions", ",", "SQL_PARAMS_NAMED", ")", ";", "$", "sql", "=", "\"submissionid $sql\"", ";", "$", "DB", "->", "set_field_select", "(", "'workshop_assessments'", ",", "'grade'", ",", "null", ",", "$", "sql", ",", "$", "params", ")", ";", "$", "DB", "->", "set_field_select", "(", "'workshop_assessments'", ",", "'gradinggrade'", ",", "null", ",", "$", "sql", ",", "$", "params", ")", ";", "}" ]
Sets the given grades and received grading grades to null This does not clear the information about how the peers filled the assessment forms, but clears the calculated grades in workshop_assessments. Therefore reviewers have to re-assess the allocated submissions. @return void
[ "Sets", "the", "given", "grades", "and", "received", "grading", "grades", "to", "null" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/workshop/locallib.php#L2284-L2297
215,182
moodle/moodle
mod/workshop/locallib.php
workshop.clear_grading_grades
public function clear_grading_grades($restrict=null) { global $DB; $sql = "workshopid = :workshopid"; $params = array('workshopid' => $this->id); if (is_null($restrict)) { // update all users - no more conditions } elseif (!empty($restrict)) { list($usql, $uparams) = $DB->get_in_or_equal($restrict, SQL_PARAMS_NAMED); $sql .= " AND userid $usql"; $params = array_merge($params, $uparams); } else { throw new coding_exception('Empty value is not a valid parameter here'); } $DB->set_field_select('workshop_aggregations', 'gradinggrade', null, $sql, $params); }
php
public function clear_grading_grades($restrict=null) { global $DB; $sql = "workshopid = :workshopid"; $params = array('workshopid' => $this->id); if (is_null($restrict)) { // update all users - no more conditions } elseif (!empty($restrict)) { list($usql, $uparams) = $DB->get_in_or_equal($restrict, SQL_PARAMS_NAMED); $sql .= " AND userid $usql"; $params = array_merge($params, $uparams); } else { throw new coding_exception('Empty value is not a valid parameter here'); } $DB->set_field_select('workshop_aggregations', 'gradinggrade', null, $sql, $params); }
[ "public", "function", "clear_grading_grades", "(", "$", "restrict", "=", "null", ")", "{", "global", "$", "DB", ";", "$", "sql", "=", "\"workshopid = :workshopid\"", ";", "$", "params", "=", "array", "(", "'workshopid'", "=>", "$", "this", "->", "id", ")", ";", "if", "(", "is_null", "(", "$", "restrict", ")", ")", "{", "// update all users - no more conditions", "}", "elseif", "(", "!", "empty", "(", "$", "restrict", ")", ")", "{", "list", "(", "$", "usql", ",", "$", "uparams", ")", "=", "$", "DB", "->", "get_in_or_equal", "(", "$", "restrict", ",", "SQL_PARAMS_NAMED", ")", ";", "$", "sql", ".=", "\" AND userid $usql\"", ";", "$", "params", "=", "array_merge", "(", "$", "params", ",", "$", "uparams", ")", ";", "}", "else", "{", "throw", "new", "coding_exception", "(", "'Empty value is not a valid parameter here'", ")", ";", "}", "$", "DB", "->", "set_field_select", "(", "'workshop_aggregations'", ",", "'gradinggrade'", ",", "null", ",", "$", "sql", ",", "$", "params", ")", ";", "}" ]
Sets the aggregated grades for assessment to null @param null|int|array $restrict If null, update all reviewers, otherwise update just grades for the given reviewer(s) @return void
[ "Sets", "the", "aggregated", "grades", "for", "assessment", "to", "null" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/workshop/locallib.php#L2384-L2401
215,183
moodle/moodle
mod/workshop/locallib.php
workshop.get_feedbackreviewer_form
public function get_feedbackreviewer_form($actionurl, stdclass $assessment, $options=array()) { global $CFG; require_once(__DIR__ . '/feedbackreviewer_form.php'); $current = new stdclass(); $current->asid = $assessment->id; $current->weight = $assessment->weight; $current->gradinggrade = $this->real_grading_grade($assessment->gradinggrade); $current->gradinggradeover = $this->real_grading_grade($assessment->gradinggradeover); $current->feedbackreviewer = $assessment->feedbackreviewer; $current->feedbackreviewerformat = $assessment->feedbackreviewerformat; if (is_null($current->gradinggrade)) { $current->gradinggrade = get_string('nullgrade', 'workshop'); } if (!isset($options['editable'])) { $editable = true; // by default } else { $editable = (bool)$options['editable']; } // prepare wysiwyg editor $current = file_prepare_standard_editor($current, 'feedbackreviewer', array()); return new workshop_feedbackreviewer_form($actionurl, array('workshop' => $this, 'current' => $current, 'editoropts' => array(), 'options' => $options), 'post', '', null, $editable); }
php
public function get_feedbackreviewer_form($actionurl, stdclass $assessment, $options=array()) { global $CFG; require_once(__DIR__ . '/feedbackreviewer_form.php'); $current = new stdclass(); $current->asid = $assessment->id; $current->weight = $assessment->weight; $current->gradinggrade = $this->real_grading_grade($assessment->gradinggrade); $current->gradinggradeover = $this->real_grading_grade($assessment->gradinggradeover); $current->feedbackreviewer = $assessment->feedbackreviewer; $current->feedbackreviewerformat = $assessment->feedbackreviewerformat; if (is_null($current->gradinggrade)) { $current->gradinggrade = get_string('nullgrade', 'workshop'); } if (!isset($options['editable'])) { $editable = true; // by default } else { $editable = (bool)$options['editable']; } // prepare wysiwyg editor $current = file_prepare_standard_editor($current, 'feedbackreviewer', array()); return new workshop_feedbackreviewer_form($actionurl, array('workshop' => $this, 'current' => $current, 'editoropts' => array(), 'options' => $options), 'post', '', null, $editable); }
[ "public", "function", "get_feedbackreviewer_form", "(", "$", "actionurl", ",", "stdclass", "$", "assessment", ",", "$", "options", "=", "array", "(", ")", ")", "{", "global", "$", "CFG", ";", "require_once", "(", "__DIR__", ".", "'/feedbackreviewer_form.php'", ")", ";", "$", "current", "=", "new", "stdclass", "(", ")", ";", "$", "current", "->", "asid", "=", "$", "assessment", "->", "id", ";", "$", "current", "->", "weight", "=", "$", "assessment", "->", "weight", ";", "$", "current", "->", "gradinggrade", "=", "$", "this", "->", "real_grading_grade", "(", "$", "assessment", "->", "gradinggrade", ")", ";", "$", "current", "->", "gradinggradeover", "=", "$", "this", "->", "real_grading_grade", "(", "$", "assessment", "->", "gradinggradeover", ")", ";", "$", "current", "->", "feedbackreviewer", "=", "$", "assessment", "->", "feedbackreviewer", ";", "$", "current", "->", "feedbackreviewerformat", "=", "$", "assessment", "->", "feedbackreviewerformat", ";", "if", "(", "is_null", "(", "$", "current", "->", "gradinggrade", ")", ")", "{", "$", "current", "->", "gradinggrade", "=", "get_string", "(", "'nullgrade'", ",", "'workshop'", ")", ";", "}", "if", "(", "!", "isset", "(", "$", "options", "[", "'editable'", "]", ")", ")", "{", "$", "editable", "=", "true", ";", "// by default", "}", "else", "{", "$", "editable", "=", "(", "bool", ")", "$", "options", "[", "'editable'", "]", ";", "}", "// prepare wysiwyg editor", "$", "current", "=", "file_prepare_standard_editor", "(", "$", "current", ",", "'feedbackreviewer'", ",", "array", "(", ")", ")", ";", "return", "new", "workshop_feedbackreviewer_form", "(", "$", "actionurl", ",", "array", "(", "'workshop'", "=>", "$", "this", ",", "'current'", "=>", "$", "current", ",", "'editoropts'", "=>", "array", "(", ")", ",", "'options'", "=>", "$", "options", ")", ",", "'post'", ",", "''", ",", "null", ",", "$", "editable", ")", ";", "}" ]
Returns the mform the teachers use to put a feedback for the reviewer @param mixed moodle_url|null $actionurl @param stdClass $assessment @param array $options editable, editableweight, overridablegradinggrade @return workshop_feedbackreviewer_form
[ "Returns", "the", "mform", "the", "teachers", "use", "to", "put", "a", "feedback", "for", "the", "reviewer" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/workshop/locallib.php#L2469-L2495
215,184
moodle/moodle
mod/workshop/locallib.php
workshop.get_feedbackauthor_form
public function get_feedbackauthor_form($actionurl, stdclass $submission, $options=array()) { global $CFG; require_once(__DIR__ . '/feedbackauthor_form.php'); $current = new stdclass(); $current->submissionid = $submission->id; $current->published = $submission->published; $current->grade = $this->real_grade($submission->grade); $current->gradeover = $this->real_grade($submission->gradeover); $current->feedbackauthor = $submission->feedbackauthor; $current->feedbackauthorformat = $submission->feedbackauthorformat; if (is_null($current->grade)) { $current->grade = get_string('nullgrade', 'workshop'); } if (!isset($options['editable'])) { $editable = true; // by default } else { $editable = (bool)$options['editable']; } // prepare wysiwyg editor $current = file_prepare_standard_editor($current, 'feedbackauthor', array()); return new workshop_feedbackauthor_form($actionurl, array('workshop' => $this, 'current' => $current, 'editoropts' => array(), 'options' => $options), 'post', '', null, $editable); }
php
public function get_feedbackauthor_form($actionurl, stdclass $submission, $options=array()) { global $CFG; require_once(__DIR__ . '/feedbackauthor_form.php'); $current = new stdclass(); $current->submissionid = $submission->id; $current->published = $submission->published; $current->grade = $this->real_grade($submission->grade); $current->gradeover = $this->real_grade($submission->gradeover); $current->feedbackauthor = $submission->feedbackauthor; $current->feedbackauthorformat = $submission->feedbackauthorformat; if (is_null($current->grade)) { $current->grade = get_string('nullgrade', 'workshop'); } if (!isset($options['editable'])) { $editable = true; // by default } else { $editable = (bool)$options['editable']; } // prepare wysiwyg editor $current = file_prepare_standard_editor($current, 'feedbackauthor', array()); return new workshop_feedbackauthor_form($actionurl, array('workshop' => $this, 'current' => $current, 'editoropts' => array(), 'options' => $options), 'post', '', null, $editable); }
[ "public", "function", "get_feedbackauthor_form", "(", "$", "actionurl", ",", "stdclass", "$", "submission", ",", "$", "options", "=", "array", "(", ")", ")", "{", "global", "$", "CFG", ";", "require_once", "(", "__DIR__", ".", "'/feedbackauthor_form.php'", ")", ";", "$", "current", "=", "new", "stdclass", "(", ")", ";", "$", "current", "->", "submissionid", "=", "$", "submission", "->", "id", ";", "$", "current", "->", "published", "=", "$", "submission", "->", "published", ";", "$", "current", "->", "grade", "=", "$", "this", "->", "real_grade", "(", "$", "submission", "->", "grade", ")", ";", "$", "current", "->", "gradeover", "=", "$", "this", "->", "real_grade", "(", "$", "submission", "->", "gradeover", ")", ";", "$", "current", "->", "feedbackauthor", "=", "$", "submission", "->", "feedbackauthor", ";", "$", "current", "->", "feedbackauthorformat", "=", "$", "submission", "->", "feedbackauthorformat", ";", "if", "(", "is_null", "(", "$", "current", "->", "grade", ")", ")", "{", "$", "current", "->", "grade", "=", "get_string", "(", "'nullgrade'", ",", "'workshop'", ")", ";", "}", "if", "(", "!", "isset", "(", "$", "options", "[", "'editable'", "]", ")", ")", "{", "$", "editable", "=", "true", ";", "// by default", "}", "else", "{", "$", "editable", "=", "(", "bool", ")", "$", "options", "[", "'editable'", "]", ";", "}", "// prepare wysiwyg editor", "$", "current", "=", "file_prepare_standard_editor", "(", "$", "current", ",", "'feedbackauthor'", ",", "array", "(", ")", ")", ";", "return", "new", "workshop_feedbackauthor_form", "(", "$", "actionurl", ",", "array", "(", "'workshop'", "=>", "$", "this", ",", "'current'", "=>", "$", "current", ",", "'editoropts'", "=>", "array", "(", ")", ",", "'options'", "=>", "$", "options", ")", ",", "'post'", ",", "''", ",", "null", ",", "$", "editable", ")", ";", "}" ]
Returns the mform the teachers use to put a feedback for the author on their submission @mixed moodle_url|null $actionurl @param stdClass $submission @param array $options editable @return workshop_feedbackauthor_form
[ "Returns", "the", "mform", "the", "teachers", "use", "to", "put", "a", "feedback", "for", "the", "author", "on", "their", "submission" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/workshop/locallib.php#L2505-L2531
215,185
moodle/moodle
mod/workshop/locallib.php
workshop.get_gradebook_grades
public function get_gradebook_grades($userid) { global $CFG; require_once($CFG->libdir.'/gradelib.php'); if (empty($userid)) { throw new coding_exception('User id expected, empty value given.'); } // Read data via the Gradebook API $gradebook = grade_get_grades($this->course->id, 'mod', 'workshop', $this->id, $userid); $grades = new workshop_final_grades(); if (has_capability('mod/workshop:submit', $this->context, $userid)) { if (!empty($gradebook->items[0]->grades)) { $submissiongrade = reset($gradebook->items[0]->grades); if (!is_null($submissiongrade->grade)) { if (!$submissiongrade->hidden or has_capability('moodle/grade:viewhidden', $this->context, $userid)) { $grades->submissiongrade = $submissiongrade; } } } } if (has_capability('mod/workshop:peerassess', $this->context, $userid)) { if (!empty($gradebook->items[1]->grades)) { $assessmentgrade = reset($gradebook->items[1]->grades); if (!is_null($assessmentgrade->grade)) { if (!$assessmentgrade->hidden or has_capability('moodle/grade:viewhidden', $this->context, $userid)) { $grades->assessmentgrade = $assessmentgrade; } } } } if (!is_null($grades->submissiongrade) or !is_null($grades->assessmentgrade)) { return $grades; } return false; }
php
public function get_gradebook_grades($userid) { global $CFG; require_once($CFG->libdir.'/gradelib.php'); if (empty($userid)) { throw new coding_exception('User id expected, empty value given.'); } // Read data via the Gradebook API $gradebook = grade_get_grades($this->course->id, 'mod', 'workshop', $this->id, $userid); $grades = new workshop_final_grades(); if (has_capability('mod/workshop:submit', $this->context, $userid)) { if (!empty($gradebook->items[0]->grades)) { $submissiongrade = reset($gradebook->items[0]->grades); if (!is_null($submissiongrade->grade)) { if (!$submissiongrade->hidden or has_capability('moodle/grade:viewhidden', $this->context, $userid)) { $grades->submissiongrade = $submissiongrade; } } } } if (has_capability('mod/workshop:peerassess', $this->context, $userid)) { if (!empty($gradebook->items[1]->grades)) { $assessmentgrade = reset($gradebook->items[1]->grades); if (!is_null($assessmentgrade->grade)) { if (!$assessmentgrade->hidden or has_capability('moodle/grade:viewhidden', $this->context, $userid)) { $grades->assessmentgrade = $assessmentgrade; } } } } if (!is_null($grades->submissiongrade) or !is_null($grades->assessmentgrade)) { return $grades; } return false; }
[ "public", "function", "get_gradebook_grades", "(", "$", "userid", ")", "{", "global", "$", "CFG", ";", "require_once", "(", "$", "CFG", "->", "libdir", ".", "'/gradelib.php'", ")", ";", "if", "(", "empty", "(", "$", "userid", ")", ")", "{", "throw", "new", "coding_exception", "(", "'User id expected, empty value given.'", ")", ";", "}", "// Read data via the Gradebook API", "$", "gradebook", "=", "grade_get_grades", "(", "$", "this", "->", "course", "->", "id", ",", "'mod'", ",", "'workshop'", ",", "$", "this", "->", "id", ",", "$", "userid", ")", ";", "$", "grades", "=", "new", "workshop_final_grades", "(", ")", ";", "if", "(", "has_capability", "(", "'mod/workshop:submit'", ",", "$", "this", "->", "context", ",", "$", "userid", ")", ")", "{", "if", "(", "!", "empty", "(", "$", "gradebook", "->", "items", "[", "0", "]", "->", "grades", ")", ")", "{", "$", "submissiongrade", "=", "reset", "(", "$", "gradebook", "->", "items", "[", "0", "]", "->", "grades", ")", ";", "if", "(", "!", "is_null", "(", "$", "submissiongrade", "->", "grade", ")", ")", "{", "if", "(", "!", "$", "submissiongrade", "->", "hidden", "or", "has_capability", "(", "'moodle/grade:viewhidden'", ",", "$", "this", "->", "context", ",", "$", "userid", ")", ")", "{", "$", "grades", "->", "submissiongrade", "=", "$", "submissiongrade", ";", "}", "}", "}", "}", "if", "(", "has_capability", "(", "'mod/workshop:peerassess'", ",", "$", "this", "->", "context", ",", "$", "userid", ")", ")", "{", "if", "(", "!", "empty", "(", "$", "gradebook", "->", "items", "[", "1", "]", "->", "grades", ")", ")", "{", "$", "assessmentgrade", "=", "reset", "(", "$", "gradebook", "->", "items", "[", "1", "]", "->", "grades", ")", ";", "if", "(", "!", "is_null", "(", "$", "assessmentgrade", "->", "grade", ")", ")", "{", "if", "(", "!", "$", "assessmentgrade", "->", "hidden", "or", "has_capability", "(", "'moodle/grade:viewhidden'", ",", "$", "this", "->", "context", ",", "$", "userid", ")", ")", "{", "$", "grades", "->", "assessmentgrade", "=", "$", "assessmentgrade", ";", "}", "}", "}", "}", "if", "(", "!", "is_null", "(", "$", "grades", "->", "submissiongrade", ")", "or", "!", "is_null", "(", "$", "grades", "->", "assessmentgrade", ")", ")", "{", "return", "$", "grades", ";", "}", "return", "false", ";", "}" ]
Returns the information about the user's grades as they are stored in the gradebook The submission grade is returned for users with the capability mod/workshop:submit and the assessment grade is returned for users with the capability mod/workshop:peerassess. Unless the user has the capability to view hidden grades, grades must be visible to be returned. Null grades are not returned. If none grade is to be returned, this method returns false. @param int $userid the user's id @return workshop_final_grades|false
[ "Returns", "the", "information", "about", "the", "user", "s", "grades", "as", "they", "are", "stored", "in", "the", "gradebook" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/workshop/locallib.php#L2544-L2584
215,186
moodle/moodle
mod/workshop/locallib.php
workshop.submission_content_options
public function submission_content_options() { global $CFG; require_once($CFG->dirroot.'/repository/lib.php'); return array( 'trusttext' => true, 'subdirs' => false, 'maxfiles' => $this->nattachments, 'maxbytes' => $this->maxbytes, 'context' => $this->context, 'return_types' => FILE_INTERNAL | FILE_EXTERNAL, ); }
php
public function submission_content_options() { global $CFG; require_once($CFG->dirroot.'/repository/lib.php'); return array( 'trusttext' => true, 'subdirs' => false, 'maxfiles' => $this->nattachments, 'maxbytes' => $this->maxbytes, 'context' => $this->context, 'return_types' => FILE_INTERNAL | FILE_EXTERNAL, ); }
[ "public", "function", "submission_content_options", "(", ")", "{", "global", "$", "CFG", ";", "require_once", "(", "$", "CFG", "->", "dirroot", ".", "'/repository/lib.php'", ")", ";", "return", "array", "(", "'trusttext'", "=>", "true", ",", "'subdirs'", "=>", "false", ",", "'maxfiles'", "=>", "$", "this", "->", "nattachments", ",", "'maxbytes'", "=>", "$", "this", "->", "maxbytes", ",", "'context'", "=>", "$", "this", "->", "context", ",", "'return_types'", "=>", "FILE_INTERNAL", "|", "FILE_EXTERNAL", ",", ")", ";", "}" ]
Return the editor options for the submission content field. @return array
[ "Return", "the", "editor", "options", "for", "the", "submission", "content", "field", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/workshop/locallib.php#L2591-L2603
215,187
moodle/moodle
mod/workshop/locallib.php
workshop.submission_attachment_options
public function submission_attachment_options() { global $CFG; require_once($CFG->dirroot.'/repository/lib.php'); $options = array( 'subdirs' => true, 'maxfiles' => $this->nattachments, 'maxbytes' => $this->maxbytes, 'return_types' => FILE_INTERNAL | FILE_CONTROLLED_LINK, ); $filetypesutil = new \core_form\filetypes_util(); $options['accepted_types'] = $filetypesutil->normalize_file_types($this->submissionfiletypes); return $options; }
php
public function submission_attachment_options() { global $CFG; require_once($CFG->dirroot.'/repository/lib.php'); $options = array( 'subdirs' => true, 'maxfiles' => $this->nattachments, 'maxbytes' => $this->maxbytes, 'return_types' => FILE_INTERNAL | FILE_CONTROLLED_LINK, ); $filetypesutil = new \core_form\filetypes_util(); $options['accepted_types'] = $filetypesutil->normalize_file_types($this->submissionfiletypes); return $options; }
[ "public", "function", "submission_attachment_options", "(", ")", "{", "global", "$", "CFG", ";", "require_once", "(", "$", "CFG", "->", "dirroot", ".", "'/repository/lib.php'", ")", ";", "$", "options", "=", "array", "(", "'subdirs'", "=>", "true", ",", "'maxfiles'", "=>", "$", "this", "->", "nattachments", ",", "'maxbytes'", "=>", "$", "this", "->", "maxbytes", ",", "'return_types'", "=>", "FILE_INTERNAL", "|", "FILE_CONTROLLED_LINK", ",", ")", ";", "$", "filetypesutil", "=", "new", "\\", "core_form", "\\", "filetypes_util", "(", ")", ";", "$", "options", "[", "'accepted_types'", "]", "=", "$", "filetypesutil", "->", "normalize_file_types", "(", "$", "this", "->", "submissionfiletypes", ")", ";", "return", "$", "options", ";", "}" ]
Return the filemanager options for the submission attachments field. @return array
[ "Return", "the", "filemanager", "options", "for", "the", "submission", "attachments", "field", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/workshop/locallib.php#L2610-L2625
215,188
moodle/moodle
mod/workshop/locallib.php
workshop.overall_feedback_content_options
public function overall_feedback_content_options() { global $CFG; require_once($CFG->dirroot.'/repository/lib.php'); return array( 'subdirs' => 0, 'maxbytes' => $this->overallfeedbackmaxbytes, 'maxfiles' => $this->overallfeedbackfiles, 'changeformat' => 1, 'context' => $this->context, 'return_types' => FILE_INTERNAL, ); }
php
public function overall_feedback_content_options() { global $CFG; require_once($CFG->dirroot.'/repository/lib.php'); return array( 'subdirs' => 0, 'maxbytes' => $this->overallfeedbackmaxbytes, 'maxfiles' => $this->overallfeedbackfiles, 'changeformat' => 1, 'context' => $this->context, 'return_types' => FILE_INTERNAL, ); }
[ "public", "function", "overall_feedback_content_options", "(", ")", "{", "global", "$", "CFG", ";", "require_once", "(", "$", "CFG", "->", "dirroot", ".", "'/repository/lib.php'", ")", ";", "return", "array", "(", "'subdirs'", "=>", "0", ",", "'maxbytes'", "=>", "$", "this", "->", "overallfeedbackmaxbytes", ",", "'maxfiles'", "=>", "$", "this", "->", "overallfeedbackfiles", ",", "'changeformat'", "=>", "1", ",", "'context'", "=>", "$", "this", "->", "context", ",", "'return_types'", "=>", "FILE_INTERNAL", ",", ")", ";", "}" ]
Return the editor options for the overall feedback for the author. @return array
[ "Return", "the", "editor", "options", "for", "the", "overall", "feedback", "for", "the", "author", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/workshop/locallib.php#L2632-L2644
215,189
moodle/moodle
mod/workshop/locallib.php
workshop.overall_feedback_attachment_options
public function overall_feedback_attachment_options() { global $CFG; require_once($CFG->dirroot.'/repository/lib.php'); $options = array( 'subdirs' => 1, 'maxbytes' => $this->overallfeedbackmaxbytes, 'maxfiles' => $this->overallfeedbackfiles, 'return_types' => FILE_INTERNAL | FILE_CONTROLLED_LINK, ); $filetypesutil = new \core_form\filetypes_util(); $options['accepted_types'] = $filetypesutil->normalize_file_types($this->overallfeedbackfiletypes); return $options; }
php
public function overall_feedback_attachment_options() { global $CFG; require_once($CFG->dirroot.'/repository/lib.php'); $options = array( 'subdirs' => 1, 'maxbytes' => $this->overallfeedbackmaxbytes, 'maxfiles' => $this->overallfeedbackfiles, 'return_types' => FILE_INTERNAL | FILE_CONTROLLED_LINK, ); $filetypesutil = new \core_form\filetypes_util(); $options['accepted_types'] = $filetypesutil->normalize_file_types($this->overallfeedbackfiletypes); return $options; }
[ "public", "function", "overall_feedback_attachment_options", "(", ")", "{", "global", "$", "CFG", ";", "require_once", "(", "$", "CFG", "->", "dirroot", ".", "'/repository/lib.php'", ")", ";", "$", "options", "=", "array", "(", "'subdirs'", "=>", "1", ",", "'maxbytes'", "=>", "$", "this", "->", "overallfeedbackmaxbytes", ",", "'maxfiles'", "=>", "$", "this", "->", "overallfeedbackfiles", ",", "'return_types'", "=>", "FILE_INTERNAL", "|", "FILE_CONTROLLED_LINK", ",", ")", ";", "$", "filetypesutil", "=", "new", "\\", "core_form", "\\", "filetypes_util", "(", ")", ";", "$", "options", "[", "'accepted_types'", "]", "=", "$", "filetypesutil", "->", "normalize_file_types", "(", "$", "this", "->", "overallfeedbackfiletypes", ")", ";", "return", "$", "options", ";", "}" ]
Return the filemanager options for the overall feedback for the author. @return array
[ "Return", "the", "filemanager", "options", "for", "the", "overall", "feedback", "for", "the", "author", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/workshop/locallib.php#L2651-L2666
215,190
moodle/moodle
mod/workshop/locallib.php
workshop.reset_userdata
public function reset_userdata(stdClass $data) { $componentstr = get_string('pluginname', 'workshop').': '.format_string($this->name); $status = array(); if (!empty($data->reset_workshop_assessments) or !empty($data->reset_workshop_submissions)) { // Reset all data related to assessments, including assessments of // example submissions. $result = $this->reset_userdata_assessments($data); if ($result === true) { $status[] = array( 'component' => $componentstr, 'item' => get_string('resetassessments', 'mod_workshop'), 'error' => false, ); } else { $status[] = array( 'component' => $componentstr, 'item' => get_string('resetassessments', 'mod_workshop'), 'error' => $result, ); } } if (!empty($data->reset_workshop_submissions)) { // Reset all remaining data related to submissions. $result = $this->reset_userdata_submissions($data); if ($result === true) { $status[] = array( 'component' => $componentstr, 'item' => get_string('resetsubmissions', 'mod_workshop'), 'error' => false, ); } else { $status[] = array( 'component' => $componentstr, 'item' => get_string('resetsubmissions', 'mod_workshop'), 'error' => $result, ); } } if (!empty($data->reset_workshop_phase)) { // Do not use the {@link workshop::switch_phase()} here, we do not // want to trigger events. $this->reset_phase(); $status[] = array( 'component' => $componentstr, 'item' => get_string('resetsubmissions', 'mod_workshop'), 'error' => false, ); } return $status; }
php
public function reset_userdata(stdClass $data) { $componentstr = get_string('pluginname', 'workshop').': '.format_string($this->name); $status = array(); if (!empty($data->reset_workshop_assessments) or !empty($data->reset_workshop_submissions)) { // Reset all data related to assessments, including assessments of // example submissions. $result = $this->reset_userdata_assessments($data); if ($result === true) { $status[] = array( 'component' => $componentstr, 'item' => get_string('resetassessments', 'mod_workshop'), 'error' => false, ); } else { $status[] = array( 'component' => $componentstr, 'item' => get_string('resetassessments', 'mod_workshop'), 'error' => $result, ); } } if (!empty($data->reset_workshop_submissions)) { // Reset all remaining data related to submissions. $result = $this->reset_userdata_submissions($data); if ($result === true) { $status[] = array( 'component' => $componentstr, 'item' => get_string('resetsubmissions', 'mod_workshop'), 'error' => false, ); } else { $status[] = array( 'component' => $componentstr, 'item' => get_string('resetsubmissions', 'mod_workshop'), 'error' => $result, ); } } if (!empty($data->reset_workshop_phase)) { // Do not use the {@link workshop::switch_phase()} here, we do not // want to trigger events. $this->reset_phase(); $status[] = array( 'component' => $componentstr, 'item' => get_string('resetsubmissions', 'mod_workshop'), 'error' => false, ); } return $status; }
[ "public", "function", "reset_userdata", "(", "stdClass", "$", "data", ")", "{", "$", "componentstr", "=", "get_string", "(", "'pluginname'", ",", "'workshop'", ")", ".", "': '", ".", "format_string", "(", "$", "this", "->", "name", ")", ";", "$", "status", "=", "array", "(", ")", ";", "if", "(", "!", "empty", "(", "$", "data", "->", "reset_workshop_assessments", ")", "or", "!", "empty", "(", "$", "data", "->", "reset_workshop_submissions", ")", ")", "{", "// Reset all data related to assessments, including assessments of", "// example submissions.", "$", "result", "=", "$", "this", "->", "reset_userdata_assessments", "(", "$", "data", ")", ";", "if", "(", "$", "result", "===", "true", ")", "{", "$", "status", "[", "]", "=", "array", "(", "'component'", "=>", "$", "componentstr", ",", "'item'", "=>", "get_string", "(", "'resetassessments'", ",", "'mod_workshop'", ")", ",", "'error'", "=>", "false", ",", ")", ";", "}", "else", "{", "$", "status", "[", "]", "=", "array", "(", "'component'", "=>", "$", "componentstr", ",", "'item'", "=>", "get_string", "(", "'resetassessments'", ",", "'mod_workshop'", ")", ",", "'error'", "=>", "$", "result", ",", ")", ";", "}", "}", "if", "(", "!", "empty", "(", "$", "data", "->", "reset_workshop_submissions", ")", ")", "{", "// Reset all remaining data related to submissions.", "$", "result", "=", "$", "this", "->", "reset_userdata_submissions", "(", "$", "data", ")", ";", "if", "(", "$", "result", "===", "true", ")", "{", "$", "status", "[", "]", "=", "array", "(", "'component'", "=>", "$", "componentstr", ",", "'item'", "=>", "get_string", "(", "'resetsubmissions'", ",", "'mod_workshop'", ")", ",", "'error'", "=>", "false", ",", ")", ";", "}", "else", "{", "$", "status", "[", "]", "=", "array", "(", "'component'", "=>", "$", "componentstr", ",", "'item'", "=>", "get_string", "(", "'resetsubmissions'", ",", "'mod_workshop'", ")", ",", "'error'", "=>", "$", "result", ",", ")", ";", "}", "}", "if", "(", "!", "empty", "(", "$", "data", "->", "reset_workshop_phase", ")", ")", "{", "// Do not use the {@link workshop::switch_phase()} here, we do not", "// want to trigger events.", "$", "this", "->", "reset_phase", "(", ")", ";", "$", "status", "[", "]", "=", "array", "(", "'component'", "=>", "$", "componentstr", ",", "'item'", "=>", "get_string", "(", "'resetsubmissions'", ",", "'mod_workshop'", ")", ",", "'error'", "=>", "false", ",", ")", ";", "}", "return", "$", "status", ";", "}" ]
Performs the reset of this workshop instance. @param stdClass $data The actual course reset settings. @return array List of results, each being array[(string)component, (string)item, (string)error]
[ "Performs", "the", "reset", "of", "this", "workshop", "instance", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/workshop/locallib.php#L2674-L2728
215,191
moodle/moodle
mod/workshop/locallib.php
workshop.check_group_membership
public function check_group_membership($otheruserid) { global $USER; if (groups_get_activity_groupmode($this->cm) != SEPARATEGROUPS) { // The workshop is not in a group mode, or it is in a visible group mode. return true; } else if (has_capability('moodle/site:accessallgroups', $this->context)) { // The current user can access all groups. return true; } else { $thisusersgroups = groups_get_all_groups($this->course->id, $USER->id, $this->cm->groupingid, 'g.id'); $otherusersgroups = groups_get_all_groups($this->course->id, $otheruserid, $this->cm->groupingid, 'g.id'); $commongroups = array_intersect_key($thisusersgroups, $otherusersgroups); if (empty($commongroups)) { // The current user has no group common with the other user. return false; } else { // The current user has a group common with the other user. return true; } } }
php
public function check_group_membership($otheruserid) { global $USER; if (groups_get_activity_groupmode($this->cm) != SEPARATEGROUPS) { // The workshop is not in a group mode, or it is in a visible group mode. return true; } else if (has_capability('moodle/site:accessallgroups', $this->context)) { // The current user can access all groups. return true; } else { $thisusersgroups = groups_get_all_groups($this->course->id, $USER->id, $this->cm->groupingid, 'g.id'); $otherusersgroups = groups_get_all_groups($this->course->id, $otheruserid, $this->cm->groupingid, 'g.id'); $commongroups = array_intersect_key($thisusersgroups, $otherusersgroups); if (empty($commongroups)) { // The current user has no group common with the other user. return false; } else { // The current user has a group common with the other user. return true; } } }
[ "public", "function", "check_group_membership", "(", "$", "otheruserid", ")", "{", "global", "$", "USER", ";", "if", "(", "groups_get_activity_groupmode", "(", "$", "this", "->", "cm", ")", "!=", "SEPARATEGROUPS", ")", "{", "// The workshop is not in a group mode, or it is in a visible group mode.", "return", "true", ";", "}", "else", "if", "(", "has_capability", "(", "'moodle/site:accessallgroups'", ",", "$", "this", "->", "context", ")", ")", "{", "// The current user can access all groups.", "return", "true", ";", "}", "else", "{", "$", "thisusersgroups", "=", "groups_get_all_groups", "(", "$", "this", "->", "course", "->", "id", ",", "$", "USER", "->", "id", ",", "$", "this", "->", "cm", "->", "groupingid", ",", "'g.id'", ")", ";", "$", "otherusersgroups", "=", "groups_get_all_groups", "(", "$", "this", "->", "course", "->", "id", ",", "$", "otheruserid", ",", "$", "this", "->", "cm", "->", "groupingid", ",", "'g.id'", ")", ";", "$", "commongroups", "=", "array_intersect_key", "(", "$", "thisusersgroups", ",", "$", "otherusersgroups", ")", ";", "if", "(", "empty", "(", "$", "commongroups", ")", ")", "{", "// The current user has no group common with the other user.", "return", "false", ";", "}", "else", "{", "// The current user has a group common with the other user.", "return", "true", ";", "}", "}", "}" ]
Check if the current user can access the other user's group. This is typically used for teacher roles that have permissions like 'view all submissions'. Even with such a permission granted, we have to check the workshop activity group mode. If the workshop is not in a group mode, or if it is in the visible group mode, this method returns true. This is consistent with how the {@link groups_get_activity_allowed_groups()} behaves. If the workshop is in a separate group mode, the current user has to have the 'access all groups' permission, or share at least one accessible group with the other user. @param int $otheruserid The ID of the other user, e.g. the author of a submission. @return bool False if the current user cannot access the other user's group.
[ "Check", "if", "the", "current", "user", "can", "access", "the", "other", "user", "s", "group", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/workshop/locallib.php#L2748-L2773
215,192
moodle/moodle
mod/workshop/locallib.php
workshop.check_examples_assessed_before_submission
public function check_examples_assessed_before_submission($userid) { if ($this->useexamples and $this->examplesmode == self::EXAMPLES_BEFORE_SUBMISSION and !has_capability('mod/workshop:manageexamples', $this->context)) { // Check that all required examples have been assessed by the user. $examples = $this->get_examples_for_reviewer($userid); foreach ($examples as $exampleid => $example) { if (is_null($example->assessmentid)) { $examples[$exampleid]->assessmentid = $this->add_allocation($example, $userid, 0); } if (is_null($example->grade)) { return false; } } } return true; }
php
public function check_examples_assessed_before_submission($userid) { if ($this->useexamples and $this->examplesmode == self::EXAMPLES_BEFORE_SUBMISSION and !has_capability('mod/workshop:manageexamples', $this->context)) { // Check that all required examples have been assessed by the user. $examples = $this->get_examples_for_reviewer($userid); foreach ($examples as $exampleid => $example) { if (is_null($example->assessmentid)) { $examples[$exampleid]->assessmentid = $this->add_allocation($example, $userid, 0); } if (is_null($example->grade)) { return false; } } } return true; }
[ "public", "function", "check_examples_assessed_before_submission", "(", "$", "userid", ")", "{", "if", "(", "$", "this", "->", "useexamples", "and", "$", "this", "->", "examplesmode", "==", "self", "::", "EXAMPLES_BEFORE_SUBMISSION", "and", "!", "has_capability", "(", "'mod/workshop:manageexamples'", ",", "$", "this", "->", "context", ")", ")", "{", "// Check that all required examples have been assessed by the user.", "$", "examples", "=", "$", "this", "->", "get_examples_for_reviewer", "(", "$", "userid", ")", ";", "foreach", "(", "$", "examples", "as", "$", "exampleid", "=>", "$", "example", ")", "{", "if", "(", "is_null", "(", "$", "example", "->", "assessmentid", ")", ")", "{", "$", "examples", "[", "$", "exampleid", "]", "->", "assessmentid", "=", "$", "this", "->", "add_allocation", "(", "$", "example", ",", "$", "userid", ",", "0", ")", ";", "}", "if", "(", "is_null", "(", "$", "example", "->", "grade", ")", ")", "{", "return", "false", ";", "}", "}", "}", "return", "true", ";", "}" ]
Check whether the given user has assessed all his required examples before submission. @param int $userid the user to check @return bool false if there are examples missing assessment, true otherwise. @since Moodle 3.4
[ "Check", "whether", "the", "given", "user", "has", "assessed", "all", "his", "required", "examples", "before", "submission", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/workshop/locallib.php#L2782-L2799
215,193
moodle/moodle
mod/workshop/locallib.php
workshop.check_examples_assessed_before_assessment
public function check_examples_assessed_before_assessment($userid) { if ($this->useexamples and $this->examplesmode == self::EXAMPLES_BEFORE_ASSESSMENT and !has_capability('mod/workshop:manageexamples', $this->context)) { // The reviewer must have submitted their own submission. $reviewersubmission = $this->get_submission_by_author($userid); if (!$reviewersubmission) { // No money, no love. return array(false, 'exampleneedsubmission'); } else { $examples = $this->get_examples_for_reviewer($userid); foreach ($examples as $exampleid => $example) { if (is_null($example->grade)) { return array(false, 'exampleneedassessed'); } } } } return array(true, null); }
php
public function check_examples_assessed_before_assessment($userid) { if ($this->useexamples and $this->examplesmode == self::EXAMPLES_BEFORE_ASSESSMENT and !has_capability('mod/workshop:manageexamples', $this->context)) { // The reviewer must have submitted their own submission. $reviewersubmission = $this->get_submission_by_author($userid); if (!$reviewersubmission) { // No money, no love. return array(false, 'exampleneedsubmission'); } else { $examples = $this->get_examples_for_reviewer($userid); foreach ($examples as $exampleid => $example) { if (is_null($example->grade)) { return array(false, 'exampleneedassessed'); } } } } return array(true, null); }
[ "public", "function", "check_examples_assessed_before_assessment", "(", "$", "userid", ")", "{", "if", "(", "$", "this", "->", "useexamples", "and", "$", "this", "->", "examplesmode", "==", "self", "::", "EXAMPLES_BEFORE_ASSESSMENT", "and", "!", "has_capability", "(", "'mod/workshop:manageexamples'", ",", "$", "this", "->", "context", ")", ")", "{", "// The reviewer must have submitted their own submission.", "$", "reviewersubmission", "=", "$", "this", "->", "get_submission_by_author", "(", "$", "userid", ")", ";", "if", "(", "!", "$", "reviewersubmission", ")", "{", "// No money, no love.", "return", "array", "(", "false", ",", "'exampleneedsubmission'", ")", ";", "}", "else", "{", "$", "examples", "=", "$", "this", "->", "get_examples_for_reviewer", "(", "$", "userid", ")", ";", "foreach", "(", "$", "examples", "as", "$", "exampleid", "=>", "$", "example", ")", "{", "if", "(", "is_null", "(", "$", "example", "->", "grade", ")", ")", "{", "return", "array", "(", "false", ",", "'exampleneedassessed'", ")", ";", "}", "}", "}", "}", "return", "array", "(", "true", ",", "null", ")", ";", "}" ]
Check that all required examples have been assessed by the given user. @param stdClass $userid the user (reviewer) to check @return mixed bool|state false and notice code if there are examples missing assessment, true otherwise. @since Moodle 3.4
[ "Check", "that", "all", "required", "examples", "have", "been", "assessed", "by", "the", "given", "user", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/workshop/locallib.php#L2808-L2828
215,194
moodle/moodle
mod/workshop/locallib.php
workshop.validate_submission_data
public function validate_submission_data($data) { global $DB, $USER; $errors = array(); if (empty($data['id']) and empty($data['example'])) { // Make sure there is no submission saved meanwhile from another browser window. $sql = "SELECT COUNT(s.id) FROM {workshop_submissions} s JOIN {workshop} w ON (s.workshopid = w.id) JOIN {course_modules} cm ON (w.id = cm.instance) JOIN {modules} m ON (m.name = 'workshop' AND m.id = cm.module) WHERE cm.id = ? AND s.authorid = ? AND s.example = 0"; if ($DB->count_records_sql($sql, array($data['cmid'], $USER->id))) { $errors['title'] = get_string('err_multiplesubmissions', 'mod_workshop'); } } // Get the workshop record by id or cmid, depending on whether we're creating or editing a submission. if (empty($data['workshopid'])) { $workshop = $DB->get_record_select('workshop', 'id = (SELECT instance FROM {course_modules} WHERE id = ?)', [$data['cmid']]); } else { $workshop = $DB->get_record('workshop', ['id' => $data['workshopid']]); } if (isset($data['attachment_filemanager'])) { $getfiles = file_get_drafarea_files($data['attachment_filemanager']); $attachments = $getfiles->list; } else { $attachments = array(); } if ($workshop->submissiontypefile == WORKSHOP_SUBMISSION_TYPE_REQUIRED) { if (empty($attachments)) { $errors['attachment_filemanager'] = get_string('err_required', 'form'); } } else if ($workshop->submissiontypefile == WORKSHOP_SUBMISSION_TYPE_DISABLED && !empty($data['attachment_filemanager'])) { $errors['attachment_filemanager'] = get_string('submissiontypedisabled', 'mod_workshop'); } if ($workshop->submissiontypetext == WORKSHOP_SUBMISSION_TYPE_REQUIRED && html_is_blank($data['content_editor']['text'])) { $errors['content_editor'] = get_string('err_required', 'form'); } else if ($workshop->submissiontypetext == WORKSHOP_SUBMISSION_TYPE_DISABLED && !empty($data['content_editor']['text'])) { $errors['content_editor'] = get_string('submissiontypedisabled', 'mod_workshop'); } // If neither type is explicitly required, one or the other must be submitted. if ($workshop->submissiontypetext != WORKSHOP_SUBMISSION_TYPE_REQUIRED && $workshop->submissiontypefile != WORKSHOP_SUBMISSION_TYPE_REQUIRED && empty($attachments) && html_is_blank($data['content_editor']['text'])) { $errors['content_editor'] = get_string('submissionrequiredcontent', 'mod_workshop'); $errors['attachment_filemanager'] = get_string('submissionrequiredfile', 'mod_workshop'); } return $errors; }
php
public function validate_submission_data($data) { global $DB, $USER; $errors = array(); if (empty($data['id']) and empty($data['example'])) { // Make sure there is no submission saved meanwhile from another browser window. $sql = "SELECT COUNT(s.id) FROM {workshop_submissions} s JOIN {workshop} w ON (s.workshopid = w.id) JOIN {course_modules} cm ON (w.id = cm.instance) JOIN {modules} m ON (m.name = 'workshop' AND m.id = cm.module) WHERE cm.id = ? AND s.authorid = ? AND s.example = 0"; if ($DB->count_records_sql($sql, array($data['cmid'], $USER->id))) { $errors['title'] = get_string('err_multiplesubmissions', 'mod_workshop'); } } // Get the workshop record by id or cmid, depending on whether we're creating or editing a submission. if (empty($data['workshopid'])) { $workshop = $DB->get_record_select('workshop', 'id = (SELECT instance FROM {course_modules} WHERE id = ?)', [$data['cmid']]); } else { $workshop = $DB->get_record('workshop', ['id' => $data['workshopid']]); } if (isset($data['attachment_filemanager'])) { $getfiles = file_get_drafarea_files($data['attachment_filemanager']); $attachments = $getfiles->list; } else { $attachments = array(); } if ($workshop->submissiontypefile == WORKSHOP_SUBMISSION_TYPE_REQUIRED) { if (empty($attachments)) { $errors['attachment_filemanager'] = get_string('err_required', 'form'); } } else if ($workshop->submissiontypefile == WORKSHOP_SUBMISSION_TYPE_DISABLED && !empty($data['attachment_filemanager'])) { $errors['attachment_filemanager'] = get_string('submissiontypedisabled', 'mod_workshop'); } if ($workshop->submissiontypetext == WORKSHOP_SUBMISSION_TYPE_REQUIRED && html_is_blank($data['content_editor']['text'])) { $errors['content_editor'] = get_string('err_required', 'form'); } else if ($workshop->submissiontypetext == WORKSHOP_SUBMISSION_TYPE_DISABLED && !empty($data['content_editor']['text'])) { $errors['content_editor'] = get_string('submissiontypedisabled', 'mod_workshop'); } // If neither type is explicitly required, one or the other must be submitted. if ($workshop->submissiontypetext != WORKSHOP_SUBMISSION_TYPE_REQUIRED && $workshop->submissiontypefile != WORKSHOP_SUBMISSION_TYPE_REQUIRED && empty($attachments) && html_is_blank($data['content_editor']['text'])) { $errors['content_editor'] = get_string('submissionrequiredcontent', 'mod_workshop'); $errors['attachment_filemanager'] = get_string('submissionrequiredfile', 'mod_workshop'); } return $errors; }
[ "public", "function", "validate_submission_data", "(", "$", "data", ")", "{", "global", "$", "DB", ",", "$", "USER", ";", "$", "errors", "=", "array", "(", ")", ";", "if", "(", "empty", "(", "$", "data", "[", "'id'", "]", ")", "and", "empty", "(", "$", "data", "[", "'example'", "]", ")", ")", "{", "// Make sure there is no submission saved meanwhile from another browser window.", "$", "sql", "=", "\"SELECT COUNT(s.id)\n FROM {workshop_submissions} s\n JOIN {workshop} w ON (s.workshopid = w.id)\n JOIN {course_modules} cm ON (w.id = cm.instance)\n JOIN {modules} m ON (m.name = 'workshop' AND m.id = cm.module)\n WHERE cm.id = ? AND s.authorid = ? AND s.example = 0\"", ";", "if", "(", "$", "DB", "->", "count_records_sql", "(", "$", "sql", ",", "array", "(", "$", "data", "[", "'cmid'", "]", ",", "$", "USER", "->", "id", ")", ")", ")", "{", "$", "errors", "[", "'title'", "]", "=", "get_string", "(", "'err_multiplesubmissions'", ",", "'mod_workshop'", ")", ";", "}", "}", "// Get the workshop record by id or cmid, depending on whether we're creating or editing a submission.", "if", "(", "empty", "(", "$", "data", "[", "'workshopid'", "]", ")", ")", "{", "$", "workshop", "=", "$", "DB", "->", "get_record_select", "(", "'workshop'", ",", "'id = (SELECT instance FROM {course_modules} WHERE id = ?)'", ",", "[", "$", "data", "[", "'cmid'", "]", "]", ")", ";", "}", "else", "{", "$", "workshop", "=", "$", "DB", "->", "get_record", "(", "'workshop'", ",", "[", "'id'", "=>", "$", "data", "[", "'workshopid'", "]", "]", ")", ";", "}", "if", "(", "isset", "(", "$", "data", "[", "'attachment_filemanager'", "]", ")", ")", "{", "$", "getfiles", "=", "file_get_drafarea_files", "(", "$", "data", "[", "'attachment_filemanager'", "]", ")", ";", "$", "attachments", "=", "$", "getfiles", "->", "list", ";", "}", "else", "{", "$", "attachments", "=", "array", "(", ")", ";", "}", "if", "(", "$", "workshop", "->", "submissiontypefile", "==", "WORKSHOP_SUBMISSION_TYPE_REQUIRED", ")", "{", "if", "(", "empty", "(", "$", "attachments", ")", ")", "{", "$", "errors", "[", "'attachment_filemanager'", "]", "=", "get_string", "(", "'err_required'", ",", "'form'", ")", ";", "}", "}", "else", "if", "(", "$", "workshop", "->", "submissiontypefile", "==", "WORKSHOP_SUBMISSION_TYPE_DISABLED", "&&", "!", "empty", "(", "$", "data", "[", "'attachment_filemanager'", "]", ")", ")", "{", "$", "errors", "[", "'attachment_filemanager'", "]", "=", "get_string", "(", "'submissiontypedisabled'", ",", "'mod_workshop'", ")", ";", "}", "if", "(", "$", "workshop", "->", "submissiontypetext", "==", "WORKSHOP_SUBMISSION_TYPE_REQUIRED", "&&", "html_is_blank", "(", "$", "data", "[", "'content_editor'", "]", "[", "'text'", "]", ")", ")", "{", "$", "errors", "[", "'content_editor'", "]", "=", "get_string", "(", "'err_required'", ",", "'form'", ")", ";", "}", "else", "if", "(", "$", "workshop", "->", "submissiontypetext", "==", "WORKSHOP_SUBMISSION_TYPE_DISABLED", "&&", "!", "empty", "(", "$", "data", "[", "'content_editor'", "]", "[", "'text'", "]", ")", ")", "{", "$", "errors", "[", "'content_editor'", "]", "=", "get_string", "(", "'submissiontypedisabled'", ",", "'mod_workshop'", ")", ";", "}", "// If neither type is explicitly required, one or the other must be submitted.", "if", "(", "$", "workshop", "->", "submissiontypetext", "!=", "WORKSHOP_SUBMISSION_TYPE_REQUIRED", "&&", "$", "workshop", "->", "submissiontypefile", "!=", "WORKSHOP_SUBMISSION_TYPE_REQUIRED", "&&", "empty", "(", "$", "attachments", ")", "&&", "html_is_blank", "(", "$", "data", "[", "'content_editor'", "]", "[", "'text'", "]", ")", ")", "{", "$", "errors", "[", "'content_editor'", "]", "=", "get_string", "(", "'submissionrequiredcontent'", ",", "'mod_workshop'", ")", ";", "$", "errors", "[", "'attachment_filemanager'", "]", "=", "get_string", "(", "'submissionrequiredfile'", ",", "'mod_workshop'", ")", ";", "}", "return", "$", "errors", ";", "}" ]
Validates the submission form or WS data. @param array $data the data to be validated @return array the validation errors (if any) @since Moodle 3.4
[ "Validates", "the", "submission", "form", "or", "WS", "data", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/workshop/locallib.php#L2862-L2917
215,195
moodle/moodle
mod/workshop/locallib.php
workshop.check_view_assessment
public function check_view_assessment($assessment, $submission) { global $USER; $isauthor = $submission->authorid == $USER->id; $isreviewer = $assessment->reviewerid == $USER->id; $canviewallassessments = has_capability('mod/workshop:viewallassessments', $this->context); $canviewallsubmissions = has_capability('mod/workshop:viewallsubmissions', $this->context); $canviewallsubmissions = $canviewallsubmissions && $this->check_group_membership($submission->authorid); if (!$isreviewer and !$isauthor and !($canviewallassessments and $canviewallsubmissions)) { print_error('nopermissions', 'error', $this->view_url(), 'view this assessment'); } if ($isauthor and !$isreviewer and !$canviewallassessments and $this->phase != self::PHASE_CLOSED) { // Authors can see assessments of their work at the end of workshop only. print_error('nopermissions', 'error', $this->view_url(), 'view assessment of own work before workshop is closed'); } }
php
public function check_view_assessment($assessment, $submission) { global $USER; $isauthor = $submission->authorid == $USER->id; $isreviewer = $assessment->reviewerid == $USER->id; $canviewallassessments = has_capability('mod/workshop:viewallassessments', $this->context); $canviewallsubmissions = has_capability('mod/workshop:viewallsubmissions', $this->context); $canviewallsubmissions = $canviewallsubmissions && $this->check_group_membership($submission->authorid); if (!$isreviewer and !$isauthor and !($canviewallassessments and $canviewallsubmissions)) { print_error('nopermissions', 'error', $this->view_url(), 'view this assessment'); } if ($isauthor and !$isreviewer and !$canviewallassessments and $this->phase != self::PHASE_CLOSED) { // Authors can see assessments of their work at the end of workshop only. print_error('nopermissions', 'error', $this->view_url(), 'view assessment of own work before workshop is closed'); } }
[ "public", "function", "check_view_assessment", "(", "$", "assessment", ",", "$", "submission", ")", "{", "global", "$", "USER", ";", "$", "isauthor", "=", "$", "submission", "->", "authorid", "==", "$", "USER", "->", "id", ";", "$", "isreviewer", "=", "$", "assessment", "->", "reviewerid", "==", "$", "USER", "->", "id", ";", "$", "canviewallassessments", "=", "has_capability", "(", "'mod/workshop:viewallassessments'", ",", "$", "this", "->", "context", ")", ";", "$", "canviewallsubmissions", "=", "has_capability", "(", "'mod/workshop:viewallsubmissions'", ",", "$", "this", "->", "context", ")", ";", "$", "canviewallsubmissions", "=", "$", "canviewallsubmissions", "&&", "$", "this", "->", "check_group_membership", "(", "$", "submission", "->", "authorid", ")", ";", "if", "(", "!", "$", "isreviewer", "and", "!", "$", "isauthor", "and", "!", "(", "$", "canviewallassessments", "and", "$", "canviewallsubmissions", ")", ")", "{", "print_error", "(", "'nopermissions'", ",", "'error'", ",", "$", "this", "->", "view_url", "(", ")", ",", "'view this assessment'", ")", ";", "}", "if", "(", "$", "isauthor", "and", "!", "$", "isreviewer", "and", "!", "$", "canviewallassessments", "and", "$", "this", "->", "phase", "!=", "self", "::", "PHASE_CLOSED", ")", "{", "// Authors can see assessments of their work at the end of workshop only.", "print_error", "(", "'nopermissions'", ",", "'error'", ",", "$", "this", "->", "view_url", "(", ")", ",", "'view assessment of own work before workshop is closed'", ")", ";", "}", "}" ]
Helper method for validating if the current user can view the given assessment. @param stdClass $assessment assessment object @param stdClass $submission submission object @return void @throws moodle_exception @since Moodle 3.4
[ "Helper", "method", "for", "validating", "if", "the", "current", "user", "can", "view", "the", "given", "assessment", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/workshop/locallib.php#L3019-L3037
215,196
moodle/moodle
mod/workshop/locallib.php
workshop.check_edit_assessment
public function check_edit_assessment($assessment, $submission) { global $USER; $this->check_view_assessment($assessment, $submission); // Further checks. $isreviewer = ($USER->id == $assessment->reviewerid); $assessmenteditable = $isreviewer && $this->assessing_allowed($USER->id); if (!$assessmenteditable) { throw new moodle_exception('nopermissions', 'error', '', 'edit assessments'); } list($assessed, $notice) = $this->check_examples_assessed_before_assessment($assessment->reviewerid); if (!$assessed) { throw new moodle_exception($notice, 'mod_workshop'); } }
php
public function check_edit_assessment($assessment, $submission) { global $USER; $this->check_view_assessment($assessment, $submission); // Further checks. $isreviewer = ($USER->id == $assessment->reviewerid); $assessmenteditable = $isreviewer && $this->assessing_allowed($USER->id); if (!$assessmenteditable) { throw new moodle_exception('nopermissions', 'error', '', 'edit assessments'); } list($assessed, $notice) = $this->check_examples_assessed_before_assessment($assessment->reviewerid); if (!$assessed) { throw new moodle_exception($notice, 'mod_workshop'); } }
[ "public", "function", "check_edit_assessment", "(", "$", "assessment", ",", "$", "submission", ")", "{", "global", "$", "USER", ";", "$", "this", "->", "check_view_assessment", "(", "$", "assessment", ",", "$", "submission", ")", ";", "// Further checks.", "$", "isreviewer", "=", "(", "$", "USER", "->", "id", "==", "$", "assessment", "->", "reviewerid", ")", ";", "$", "assessmenteditable", "=", "$", "isreviewer", "&&", "$", "this", "->", "assessing_allowed", "(", "$", "USER", "->", "id", ")", ";", "if", "(", "!", "$", "assessmenteditable", ")", "{", "throw", "new", "moodle_exception", "(", "'nopermissions'", ",", "'error'", ",", "''", ",", "'edit assessments'", ")", ";", "}", "list", "(", "$", "assessed", ",", "$", "notice", ")", "=", "$", "this", "->", "check_examples_assessed_before_assessment", "(", "$", "assessment", "->", "reviewerid", ")", ";", "if", "(", "!", "$", "assessed", ")", "{", "throw", "new", "moodle_exception", "(", "$", "notice", ",", "'mod_workshop'", ")", ";", "}", "}" ]
Helper method for validating if the current user can edit the given assessment. @param stdClass $assessment assessment object @param stdClass $submission submission object @return void @throws moodle_exception @since Moodle 3.4
[ "Helper", "method", "for", "validating", "if", "the", "current", "user", "can", "edit", "the", "given", "assessment", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/workshop/locallib.php#L3048-L3064
215,197
moodle/moodle
mod/workshop/locallib.php
workshop.evaluate_assessment
public function evaluate_assessment($assessment, $data, $cansetassessmentweight, $canoverridegrades) { global $DB, $USER; $data = file_postupdate_standard_editor($data, 'feedbackreviewer', array(), $this->context); $record = new stdclass(); $record->id = $assessment->id; if ($cansetassessmentweight) { $record->weight = $data->weight; } if ($canoverridegrades) { $record->gradinggradeover = $this->raw_grade_value($data->gradinggradeover, $this->gradinggrade); $record->gradinggradeoverby = $USER->id; $record->feedbackreviewer = $data->feedbackreviewer; $record->feedbackreviewerformat = $data->feedbackreviewerformat; } $DB->update_record('workshop_assessments', $record); }
php
public function evaluate_assessment($assessment, $data, $cansetassessmentweight, $canoverridegrades) { global $DB, $USER; $data = file_postupdate_standard_editor($data, 'feedbackreviewer', array(), $this->context); $record = new stdclass(); $record->id = $assessment->id; if ($cansetassessmentweight) { $record->weight = $data->weight; } if ($canoverridegrades) { $record->gradinggradeover = $this->raw_grade_value($data->gradinggradeover, $this->gradinggrade); $record->gradinggradeoverby = $USER->id; $record->feedbackreviewer = $data->feedbackreviewer; $record->feedbackreviewerformat = $data->feedbackreviewerformat; } $DB->update_record('workshop_assessments', $record); }
[ "public", "function", "evaluate_assessment", "(", "$", "assessment", ",", "$", "data", ",", "$", "cansetassessmentweight", ",", "$", "canoverridegrades", ")", "{", "global", "$", "DB", ",", "$", "USER", ";", "$", "data", "=", "file_postupdate_standard_editor", "(", "$", "data", ",", "'feedbackreviewer'", ",", "array", "(", ")", ",", "$", "this", "->", "context", ")", ";", "$", "record", "=", "new", "stdclass", "(", ")", ";", "$", "record", "->", "id", "=", "$", "assessment", "->", "id", ";", "if", "(", "$", "cansetassessmentweight", ")", "{", "$", "record", "->", "weight", "=", "$", "data", "->", "weight", ";", "}", "if", "(", "$", "canoverridegrades", ")", "{", "$", "record", "->", "gradinggradeover", "=", "$", "this", "->", "raw_grade_value", "(", "$", "data", "->", "gradinggradeover", ",", "$", "this", "->", "gradinggrade", ")", ";", "$", "record", "->", "gradinggradeoverby", "=", "$", "USER", "->", "id", ";", "$", "record", "->", "feedbackreviewer", "=", "$", "data", "->", "feedbackreviewer", ";", "$", "record", "->", "feedbackreviewerformat", "=", "$", "data", "->", "feedbackreviewerformat", ";", "}", "$", "DB", "->", "update_record", "(", "'workshop_assessments'", ",", "$", "record", ")", ";", "}" ]
Evaluates an assessment. @param stdClass $assessment the assessment @param stdClass $data the assessment data to be updated @param bool $cansetassessmentweight whether the user can change the assessment weight @param bool $canoverridegrades whether the user can override the assessment grades @return void @since Moodle 3.4
[ "Evaluates", "an", "assessment", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/workshop/locallib.php#L3141-L3157
215,198
moodle/moodle
mod/workshop/locallib.php
workshop.set_submission_viewed
public function set_submission_viewed($submission) { $params = array( 'objectid' => $submission->id, 'context' => $this->context, 'courseid' => $this->course->id, 'relateduserid' => $submission->authorid, 'other' => array( 'workshopid' => $this->id ) ); $event = \mod_workshop\event\submission_viewed::create($params); $event->trigger(); }
php
public function set_submission_viewed($submission) { $params = array( 'objectid' => $submission->id, 'context' => $this->context, 'courseid' => $this->course->id, 'relateduserid' => $submission->authorid, 'other' => array( 'workshopid' => $this->id ) ); $event = \mod_workshop\event\submission_viewed::create($params); $event->trigger(); }
[ "public", "function", "set_submission_viewed", "(", "$", "submission", ")", "{", "$", "params", "=", "array", "(", "'objectid'", "=>", "$", "submission", "->", "id", ",", "'context'", "=>", "$", "this", "->", "context", ",", "'courseid'", "=>", "$", "this", "->", "course", "->", "id", ",", "'relateduserid'", "=>", "$", "submission", "->", "authorid", ",", "'other'", "=>", "array", "(", "'workshopid'", "=>", "$", "this", "->", "id", ")", ")", ";", "$", "event", "=", "\\", "mod_workshop", "\\", "event", "\\", "submission_viewed", "::", "create", "(", "$", "params", ")", ";", "$", "event", "->", "trigger", "(", ")", ";", "}" ]
Trigger submission viewed event. @param stdClass $submission submission object @since Moodle 3.4
[ "Trigger", "submission", "viewed", "event", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/workshop/locallib.php#L3165-L3178
215,199
moodle/moodle
mod/workshop/locallib.php
workshop.evaluate_submission
public function evaluate_submission($submission, $data, $canpublish, $canoverride) { global $DB, $USER; $data = file_postupdate_standard_editor($data, 'feedbackauthor', array(), $this->context); $record = new stdclass(); $record->id = $submission->id; if ($canoverride) { $record->gradeover = $this->raw_grade_value($data->gradeover, $this->grade); $record->gradeoverby = $USER->id; $record->feedbackauthor = $data->feedbackauthor; $record->feedbackauthorformat = $data->feedbackauthorformat; } if ($canpublish) { $record->published = !empty($data->published); } $DB->update_record('workshop_submissions', $record); }
php
public function evaluate_submission($submission, $data, $canpublish, $canoverride) { global $DB, $USER; $data = file_postupdate_standard_editor($data, 'feedbackauthor', array(), $this->context); $record = new stdclass(); $record->id = $submission->id; if ($canoverride) { $record->gradeover = $this->raw_grade_value($data->gradeover, $this->grade); $record->gradeoverby = $USER->id; $record->feedbackauthor = $data->feedbackauthor; $record->feedbackauthorformat = $data->feedbackauthorformat; } if ($canpublish) { $record->published = !empty($data->published); } $DB->update_record('workshop_submissions', $record); }
[ "public", "function", "evaluate_submission", "(", "$", "submission", ",", "$", "data", ",", "$", "canpublish", ",", "$", "canoverride", ")", "{", "global", "$", "DB", ",", "$", "USER", ";", "$", "data", "=", "file_postupdate_standard_editor", "(", "$", "data", ",", "'feedbackauthor'", ",", "array", "(", ")", ",", "$", "this", "->", "context", ")", ";", "$", "record", "=", "new", "stdclass", "(", ")", ";", "$", "record", "->", "id", "=", "$", "submission", "->", "id", ";", "if", "(", "$", "canoverride", ")", "{", "$", "record", "->", "gradeover", "=", "$", "this", "->", "raw_grade_value", "(", "$", "data", "->", "gradeover", ",", "$", "this", "->", "grade", ")", ";", "$", "record", "->", "gradeoverby", "=", "$", "USER", "->", "id", ";", "$", "record", "->", "feedbackauthor", "=", "$", "data", "->", "feedbackauthor", ";", "$", "record", "->", "feedbackauthorformat", "=", "$", "data", "->", "feedbackauthorformat", ";", "}", "if", "(", "$", "canpublish", ")", "{", "$", "record", "->", "published", "=", "!", "empty", "(", "$", "data", "->", "published", ")", ";", "}", "$", "DB", "->", "update_record", "(", "'workshop_submissions'", ",", "$", "record", ")", ";", "}" ]
Evaluates a submission. @param stdClass $submission the submission @param stdClass $data the submission data to be updated @param bool $canpublish whether the user can publish the submission @param bool $canoverride whether the user can override the submission grade @return void @since Moodle 3.4
[ "Evaluates", "a", "submission", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/workshop/locallib.php#L3190-L3206