0

I am using core_course_get_contents I want to know the activity restriction criteria.

I am getting something like this in availability

{\"op\":\"&\",\"showc\":[true],\"c\":[{\"type\":\"completion\",\"cm\":10889,\"e\":1}]}

{\"op\":\"&\",\"showc\":[true],\"c\":[{\"type\":\"completion\",\"cm\":9989,\"e\":1}]}

{\"op\":\"&\",\"c\":[{\"type\":\"grade\",\"id\":3410,\"min\":100}

How to read this? What does this mean?

Is this always different parameters in others?

What is the common structure of availability parameter?

1 Answer 1

1

What you get is a JSON string, with key/value pairs. This string tells you what are the availability conditions to be satisfied.

The first pair is "op": & It means: the boolean operator is an AND. Another value could have been OR.

The operator tells you how the availability conditions should relate each other: either should all of them be valid (AND) or at least one of them (OR).

The second pair is "showc": true. It means, I suppose (not sure): Show the availability conditions: true. Another value could have been, of course, false.

The third pair is: "c" (condition): array The "c" key gives you, as far as I understand, a detailed description of the availability conditions. Let's go into details, here:

The "type" key tells you what type of field you are going to evaluate: in your first and second example it is a course module id ("cm"), with values, respectively, of 10889 and 9989. It means: "what follows has to do with course module 10889".

I do not know what the key/value pair "e":1 means, though. It could mean: "this course-module should be completed". Try yourself: you could change the availability conditions of some course-module and see what happens.

By the way, you can read this JSON object directly from the field availability of your DB table mdl_course_modules (or your_prefix_course_modules).

In your third example the type is a grade ("grade"), the ID of the grade is "3410", and the "min" (I suppose the minimum value) is "100".

Note that there could be other types: for example: "type": "date", or "type": "grouping". I am not aware of a list of possible types available, though.

3
  • And what does this mean "&!\" ?
    – n....
    Commented Apr 20, 2017 at 14:26
  • I presume, it means the negation of & (AND), that is: AND NOT. Commented Apr 20, 2017 at 15:49
  • Great. Are there enough reasons for you to accept the answer? Commented May 3, 2017 at 14:41

Not the answer you're looking for? Browse other questions tagged or ask your own question.