catalyst / moodle-local_cohortauto

Automatically add users into cohorts. (Previously moodle-auth_mcae.)
https://moodle.org/plugins/local_cohortauto
11 stars 14 forks source link

Looking for a way to create cohort based on user creation time #12

Open swinster opened 3 years ago

swinster commented 3 years ago

Hi,

I guess the field to reference is {{ timecreated }}, but then I'm not entirely sure how.

What is required is to create cohorts based on Month or bi-min they were created e.g.:

etc

Some pointesr would be awsome

danmarsden commented 3 years ago

It uses mustache templating so this page is probably a good place to look for ideas - I wonder if userdate might work: https://docs.moodle.org/dev/Templates#.7B.7B.23_userdate_.7D.7D_.28Moodle_3.3_onwards.29

I don't think we've tried anything like this before so let us know if you figure it out!

swinster commented 3 years ago

Well, I used this pattern in the Main Template section, but nothing happened:

{{#userdate}} {{ timecreated }}, %B %Y {{/userdate}}

so I then tried adding spaces:

{{ #userdate }} {{ timecreated }}, %B %Y {{ /userdate }}

Which resulted in a cohort:

 1605290540, %B %Y 

Obviously, the epoch time and string literals, so the helper syntax must be incorrect.

Just as a look/see (as per the other helper documentation) I also tried:

{{# userdate }} {{ timecreated }}, %B %Y {{/ userdate }}

But again, nothing.

I looked at the "Replace array" but it simply looks to use a static text pattern.

swinster commented 3 years ago

Does it look as if the plugin ignores helpers?

danmarsden commented 3 years ago

sounds like it - you might need to look to see how Moodle adds those helpers to the templates and see if you can hack that into the way the plugin manages templates.

swinster commented 3 years ago

I suspect this is beyond what I would be able to achieve :(.

Just for a giggle, I might look at the code, but this is not really my area.

swinster commented 3 years ago

Yep - not giggling... Unfortunately, I don't really know where to start.