How can i add custom fields to moodle course like user - csv

How can i add custom fields to course detail? just like user. Is there any plugin to do? I tried moodle-course_meta.And i can add additional fields to course,but when i try to use in upload course with and without adding profile_field_ as prefix,It doesn't take the value from the csv file.
Eg. i created custom field for a course using the plugin and call it note
And upload csv file which has field name note and also tried like what we do on user profile_field_note. On both no luck. but the rest course fields such as shortname,fullname... are imported properly.
I am on moodle version 2.8.3

There is no easy way to do it at the moment.
Some options are listed on tracker issue https://tracker.moodle.org/browse/MDL-34634
They include writing your own course format plugin or using the contributed local/admintool plugin, there are several links on this issue. The second option may be not properly compatible with backup/restore.

Related

Include categories custom fields in REST api

I am working with Advanced custom fields, where I add an image selector for categories in wp - But I can't see the data in my JSON response for categories?
I have tried to use several plugins to do the same, but That haven't worked either -
I am using ACF to rest plugin to include acf fields in the response, which works fine on custom post types - where it creates an array field called "acf"
This field is not created in my categories though - Am i missing a function to use it in taxonomies?
examples.
domain.com/wp-json/wp/v2/recipies (a custom post type)
returns everything including acf.
domain.com/wp-json/v2/categories (a texonomy)
returns all of the categories, but nothing about acf
domain.com/wp-json/wp/v2/categories/37 (a single category)
returns the category but nothing about acf.
domain.com/wp-json/wp/v2/categories/37?_embed[0] (way of getting all embedded stuff)
Does not show acf
Hope that you can put me on the right path.
To anybody who is interested, and runs into this problem.
I talked to the developer of acf-to-rest, and there is a bug in version 2, where it doesn't save taxonomies correctly - It is fixed in version 3, but you can't update it yet through wordpress, since it is still in beta -
Redownload the plugin and go into your wp-config file
here you need to define that you are going to use version 3. paste this line into the wp-config file
define('ACF_TO_REST_API_REQUEST_VERSION', 3);
The endpoints has been rewritten, so you also need to read up on that if you are using the acf endpoints for updating etc.
To read more about the bug, go github page
To read about the end points - go here
I hope that this will help somebody in the future.

Rename Taxonomy label in editor bolt-cms

I would like to rename the default tab value of Taxonomy in the backend page editor. I didn't find anything in the twig or yml files that would address this. Any ideas?
I checked with bolt developers and there is no way currently to do this. One potential option was to use the messages file but it was not recommended.
As you can imagine, since this isn't supported via the public configs, this will need a bit more advanced plugging together.
Here is a way to add an additional resource to the stack of translations.
https://gist.github.com/rossriley/c74fdee4fec3eaffb12f
This is a technique to add your own messages onto the translation stack without touching the underlying core files.
After creating this, you'll need to add your new service provider to the app, which you normally will bootstrap either in your index.php or a custom bootstrap file.

can't create module in bonfire using existing tables

For some reason, I can't seem to create a bonfire module using the "existing" table option.
Earlier, it wasn't even displaying the list of fields from my database table when I selected the option to use existing table vs. creating a new one.
BUt I figured out that it was a permissions thing and so as a test I did the following:
chmod -R 777 /var/www/myapp
Now, it is querying the database and displaying all the correct fields from the table but when I click on the build button, it just keeps redisplaying the same form.
what I've done so far:
I created a test database in my database with just 2 fields. I tried to create a module using that table... but I get the same results.
I've ensured that all my tables are prefixed with "bf_". If they weren't, the system wouldn't be able to find and list all the correct fields... I think.
I've tested creating a new module using a new table. That seems to work just fine. Bonfire creates a new table in my database without any issues and also creates the correct folder structure for the module.
I've tried to ensure that all fields have a proper name validation rules specified.
In most cases, I just accepted defaults and tried to click on build.
changed logging settings to log everything. but after trying to create a module and going back to the logs, there's nothing listed.
If you have any suggestions, I'd appreciate it.
EDIT 1
Figured out how the profiler works - i didn't realize that you had to click on the flame icon on the bottom left corner of the screen.
found the issue. there's a bug with code igniter. found a bug report on their github site.
the post that i found was: https://github.com/ci-bonfire/Bonfire/issues/733

Adding forms to joomla's front end component view

I'm developing a component using joomla 3.0. I'm trying to add forms in my component. I saw that joomla has the JHTML class for adding forms in backend.
what is the recommendation for creating forms in frontend. should I use JHTML or clean html markup ? and where can I find docs for that class.
JForm
JModelForm
JControllerForm
Forms which save data in the databas in Joomla 1.6 + mainly use the JForm package which manages forms (xml or xml strings), fields (the actual fields) and rules (validation).
The normal way simple way to manage it is to extend JModelForm and JControllerForm. If you look in the core you'll see these extended in places you might not expect such as the single contact view but basically that's because those classes provide the basic set up you need to manage a form on any part of your page even if the rest of it has nothing to do with forms.
Alternatively you can always create a new JForm object.
If you have a models folder usually you would have a forms folder and then if needed fields and rules folders. THe latter two contain any custom fields or rules you may need for your extension. These will be found by default when building a form in your extension but if you want them from somewhere else you would need to use addFieldPath or addRulePath or addFormPath as needed in you form xml.
Jform provides a standard set of fields and rules as well as a standard list of filters. Rules means validation while filters will change the saved values. You can also use any filter available in JFilterInput.
If you give a field the same name as a field in the current table object the data will automatically be saved in that field. if you use a fields tag with an name that matches a field by default the fields listed inside the tag will be saves as a JSON string within that field.
That's pretty much the basics, though there is a lot more.
One important thing for me is that if you use JForm the default filtering is very good and you selectively allow html etc so by default it is very secure.

How to save WP widget instances to options

I'm a little confused about this, even though I have read all of the API and searched for hours.
When I activate my plugin I add some values to the options database, e.g.
add_option('code','24');
How do I update that value or use it in the widget? I only see "instances" now, like the example on this page:
http://wpcoderz.com/creating-a-multi-instance-widget-with-wordpress-2-8/
You can get an option using get_option and update it using update_option. But you should use instances instead of options for widget settings (like title) because that's the purpose of instances. You don't have to care about storing instance value - WP does it for you. If you don't understand instances well, look at codex.wordpress.org/Widgets_API.