Diferencia entre revisiones de «Desarrollador FAQ»

De MoodleDocs
mSin resumen de edición
Línea 2: Línea 2:
{{FAQ}}
{{FAQ}}


==Help for new coders==
==Ayuda para nuevos codificadores==


===Where can "newbies" to Moodle get help?===
===Dónde pueden los novatos de Moodle obtener ayuda?===


The [http://moodle.org/mod/forum/view.php?f=33 General developer forum]! Feel free to ask any question, no matter how basic or advanced. Many people ask different levels of question every day, and the community is generally welcoming and quick to respond.
El [http://moodle.org/mod/forum/view.php?f=33 Foro General de desarrolladores]! Siéntase libre de realizar cualquier pregunta, no importa que tan básica o avanzada sea. Muchas personas hacen diferentes niveles de preguntas todos los días, y al comunidad da la bienvenida y responde rápido.


==Moodle's database==
==Moodle's database==

Revisión del 02:47 17 sep 2006

Nota: Pendiente de Traducir. ¡Anímese a traducir esta página!.     ( y otras páginas pendientes)


Ayuda para nuevos codificadores

Dónde pueden los novatos de Moodle obtener ayuda?

El Foro General de desarrolladores! Siéntase libre de realizar cualquier pregunta, no importa que tan básica o avanzada sea. Muchas personas hacen diferentes niveles de preguntas todos los días, y al comunidad da la bienvenida y responde rápido.

Moodle's database

Where can I see a schema for the structure of the Moodle database?

When installing Moodle, the database tables are generated and updated by various db-handling scripts located in various places. There is no canonical schema representation, although the coding guidelines for database structure give an outline of the general approach.

The reason that the database information isn't stored in one place is because of Moodle's modular structure. Each activity module, for example, comes as a folder with script files inside. If the module needs to store information in the database, it must include scripts in a "db" subfolder which define and update the database structure.

How to get/set information when writing new Moodle code

How do I find out the currently-logged-on user?

The global object $USER, which contains the numeric $USER->id among other things.

How do I find out the current course?

The global object $COURSE, which contains the numeric $COURSE->id

How do I insert/retrieve records in the database, without creating my own database connections?

Always use the "datalib" functions, such as insert_record() or get_record(). This helps with database abstraction (e.g. running on either MySQL or Postgres) as well as maintaining a single database connection. Moodle uses ADODB for database abstraction.

Look at the documentation for datalib.php for the list of functions and details of use.

How do I get/set configuration settings?

To get config values you would typically access the global $CFG object directly, which is automatically created by the core Moodle scripts. To set these "main" config values use set_config($name, $value). The values are stored in the Moodle "config" database table, but these functions take care of cacheing on your behalf, so you should always use these rather than fetching the records directly.

There is also a second table of config settings specifically for plugins ("config_plugin"). These are not automatically loaded into the $CFG object, so to fetch these you would use get_config($plugin, $name). To set them use set_config($name, $value, $plugin).