How to add custom meta fields to moodle course elements? - moodle

I have a question: I'm trying to connect interrelated elements between two courses (calculus and physics) for students, and first step I'm going to do is to add custom fields for course materials and assignments, on which I'm going to keep id's for the elements of the correlated course element.
For example: student fails the test on Classical Mechanics and he's redirected on materials about derivatives on Calculus.
So, two question here:
1) how to add custom fields in Moodle.
2) how to request them via REST API in Moodle?
Thanks!

how to add custom fields in Moodle.
You should develop your own plugin, and it is not what can be explained in two words.
how to request them via REST API in Moodle?
This is also part of custom development

Related

Can a product's structured data be split into separate sections?

I'm working on a site optimizing their structured data and noticed they use YotPo to pull in ratings and reviews. YotPo is defining the Product and only has a couple of values for AggregateRating that are being injected via JavaScript.
I have all of the other product data coming from the CMS, so I defined all the other information there, but when I run Google's testing tool on the page, it sees it as 2 products and says it's missing fields for the YotPo markup that are already defined in my markup.
Is there some way to let Google know that they're both chunks of data for the same product so it only sees it as a single product with the combined data?
You need to make sure both Yotpo and your CMS use the same format. e.g. json-ld or microdata.
You can then indicate that they relate to the same product by setting both up to use the same id.

Suggestions on Framework/API to create social graph and cross reference relationships

Short Question Description
I have to develop an application for a security company that will store cases of harassment to their clients and cross reference any case with other cases if it detects it is the same person that is attacking them.
These relationships will be used to create a social graph of criminals and victims.
Initially I thought about managing it as a Social Network with some CMS or maybe Elastic Search with some frontend JS Framework but I have only experience with PHP and some basic React/Node.js so I wonder if there is something better that let me make the queries live as users fill in the forms.
Long Question with Use Case Example
Lets say they have two clients: ProtectedPerson1 and ProtectedPerson2
and there is a case saying BadGuy1 threatened PP1 in twitter with the handle #badguy1.
Then another agent that does not know anything about this case enters a new case for PP2, because someone in facebook is posting private photos of the client.
If they start to put the social information and they type #badguy1 or faceboo.com/badguy1 or anything similar the system should ask "is this the same person?" and if the agent selects Yes then both records of two separate cases are related to the same "criminal".
In the end the final objective is to gather all precedents possible to take legal action against someone if is necessary.
Is there any existing Framework, CMS or API that I can use to manage this relationships and create the desired suggestions and graphs?
After further investigation I found that what I really need is a graph database and the one that stands out as the most used one and with better support and integrations is Neo4j (https://neo4j.com) with a front end in React possibly as they offer official driver for javascript.

REST, getting additional information for an SPA

I'm trying to understand this from a REST theoretical perspective.
You have a book collection, it's an entity you can get, delete, etc.
You have an individual book, you get it with an id, delete it with an id, etc
You have an Angular app where you can add new books. So you get the book collection, add a book locally, haven't sent it to the server yet
You need additional info on the book before you add it, for example you need to know if there are any other books with the same title
Can you have multiple GET calls in a RESTful architecture for the same entity? i.e. one with id and another with a name? So you could try to GET the book with the name to see if it already exists
Where does 'get additional info for an as of yet uncreated entity' fit into this? Lets say you need an image for the book and you have stock images, I'm assuming that the images are entities in and of themselves so they have their own REST APIs
If I understand your question correctly, you basically want to do a search on some criteria (name, etc) to check that the book does not already exist. You can use GET for book which would not include id as a path variable but would include the criteria filter params as request parameters(query string). Something like this:
/book?name=bookname -- List book with name as bookname
/book/{id} -- List book with given id
Multiple GET calls for the same entity is not encouraged in a RESTful architecture.
Can you have multiple GET calls in a RESTful architecture for the same entity?
Jim Webber: You should expect to have many many more resources in your integration domain than you do business objects in your business domain.
So sure, why not? How could the client possibly know?
Where does 'get additional info for an as of yet uncreated entity' fit into this?
When in doubt, try to envision what you are doing as a web page. Would be be reasonable to send to ask the web server for a form to add a new book with a particular title, and have it return the form, a list of known books with similar titles, a set of stock images, etc? Of course. So it's going to be fine for your API to do the same thing.
Or perhaps the form should be a separate idea, and the search results should look like a link to the form, and a bunch of links to representations of existing books. That's also fine.
Using links from unstable things to stable things is often a good idea, because it affords caching.

Scala Play Framework - Dynamic Forms

I'm currently in the process of trying to define a dynamic form in Play (Scala). What I mean by a "dynamic" form is one which presents different form elements (and POSTs different data) depending on the state of some runtime (specifically database-side) data.
A brief illustrative example: on a to-do list application, how could one create a form which creates a "delete" check box next to each of the list elements? I realize this could be done with GET links or with AJAX/javascript, but I want this to be a standard POST form with a "submit" button.
I'm aware of the repeated mapping form functionality, but is it possible to define an even more dynamically generated form, where the structure is less strict than just single+repeated elements?
Thanks for any suggestions you might have. I realize this might just be more than POST is cut out for.
The closest thing that I have to an answer for this is that POST and any sane web framework supports "array" inputs. Hence, if you can get your data into any regularized format, you can serialize/deserialize via that. You may be able to support semiexotic data patterns by using this method as well.

Developing a very nonstandard Drupal form

I'm creating a site for a local retail shop using Drupal. Everything's been going very smoothly up until this current bit.
It's a comic shop, and I want to make a place where people can manage their own subscriptions. Since the number of different titles a customer subscribes to can vary pretty widely, I want a way to make a completely dynamic form, with people able to add as many new lines as they need and I'm really struggling with Drupal's documentation.
Essentially, I'd like the final version of the page to look something like this: http://www.monksp.org/foo.html
Anyone have any experience building a drupal form like this?
Could you not achieve something similar using Taxonomy and free tagging? Take a look at http://drupal.org/handbook/modules/taxonomy
So in theory you would have a content type called "Subscription", each user would only be able to create one node of this type, it would have the taxonomy applied to it. The user can then edit the node and add more subscriptions. The great thing about this is that you can also use auto-complete. So say a user is already subscribed to X-Men another user can edit their subscription and start typing "X" this would then auto populate with suggested terms already in the taxonomy. e.g:
X-men: Origins
X-men: Apocalypse Saga
X-men: Noir
I think this is the functionality you've described.