Discourse Reflective Learning Plugin

Hi @angus @merefield @Eli

I thought I’d start a topic about the Discourse Reflective Learning Plugin I’ve been working on today, for a client who contracted me for this before I got involved with Pavilion. I’ve talked about this plugin with @angus before now.

The idea is that professionals who need to do Continuing Professional Development often need to ‘reflect’ on the things they have learned, as part of the appraisal process for staying certified in their profession. With this plugin they will be able to track the professional conversations they are part of in Discourse (I run several professional discussion platforms on Discourses) - and then they can reflect on the discussion after a period of time.

Today’s challenge has been to get Discourse to pick up and run my migration so I can create a model for Reflection. PluginStore and Custom User Data aren’t going to be suitable for this since a Reflection will be something like a Topic, with formatting, replies, etc, and I want a proper model I can develop over time, as I suspect it will get quite complex in time.

Not a lot of information about that on Meta, but found some useful stuff here:

Managed to get that working just now. That’s a nice point to leave it for today. :slight_smile:

=> #<Reflection:0x00007f6e490743b0
 id: 1,
 title: "testtitle",
 body: "testbody",
 user_id: 1,
 created_at: Mon, 16 Sep 2019 17:12:47 UTC +00:00,
 updated_at: Mon, 16 Sep 2019 17:12:47 UTC +00:00>

It’s going to be quite a tricky plugin to develop as I will need to monkey-patch the Composer so it says ‘Create a new Reflection’ and the buttons to match, etc. But I think I have a vague handle on how all that works having read the code.

I was originally creating this topic to ask for help with this migration stuff, but I solved it just after writing it all down (which I think is cause and effect!) so now I’ve just made this an ‘announcing’ post for this plugin, which may eventually become a Pavilion-maintained one.


Thanks for sharing this Marcus! I love this plugin.

I would recommend this topic: Adding a method `get_like` to PluginStore class - dev - Discourse Meta. Particularly David’s post: Adding a method `get_like` to PluginStore class - dev - Discourse Meta

Yeah, the composer can be tricky. Let me know if you need help with it. @fzngagan is also getting more familiar with it right now for the Events Plugin.

Actually Faizan can’t see this topic. Mind if we move it to a more open setting? Either somewhere in #open-source, or if you’d still like to keep it private, in #members:projects (which Faizan has access to).


I’m happy with either, the code and my work on it have been public so far. I wasn’t sure where best to place it


@pacharanero. Interesting. It would be lovely to see the development of the plugin.

Here’s the current embryonic stage of the plugin’s development. It has a full Rails model at the back end and communicates to Ember over REST. The data you see there is coming from the DB.

As you can see I’m also working out how to use the Composer to create Reflections, so further sources of info on using the Composer for things that are not a Post/Topic/PM would be good.

Also, anyone any recommendations on what Discourse Ember components/templates can be used to make the Reflections display a little like the User Activity style? (Ember Inspector not great at identifying the actual component/template name)

1 Like

I want to know your thoughts on this.

In many of our plugins at pavilion and maybe in others too, we use a pattern to add a category setting i.e. knowledge-base-category? events-category? etc.

Would it apply to your plugin? You can simply add a category setting on the lines of this.

Then you can utilize discourse topics for that category as reflections .

I think this could make your job simpler.

I could be totally wrong here but what do you think?

It’s a good thought @fzngagan - but Reflections are private to each User, so they can’t be in a Category where others may see them. The natural place for them seemed to be in the user Profile area.

1 Like

Yeah, that’s the deal-breaker. Now I can comprehend better why you chose that path.

Something really important

1 Like

Yep that’s the post I used to work out how to add new tables from within a Plugin. It’s mostly just straightforward Rails, but there are a few gotchas and conventions that are specific to it being a Discourse plugin.

1 Like

I see. Can you point me to your code if at all it lives on github. I’m working on a migration for events and it would really speed up my work.

I want to know where to put it actually so that it gets picked up by discourse.

Migrations go in the normal Rails place and I think Discourse picked them up upon first encountering the migration and ran it automatically. I haven’t yet gone into the thick weeds of making sure it can be removed cleanly, but as it is a completely new table it can be reversed without affecting any of the rest of Discourse

I generated the migration via rails generate migration mycoolmigration which generated a migration in core discourse. I moved it to my plugin and it works now. :wink:

@angus I will definitely need your help to get the composer bit working - I will define the problem a bit more in another post about Composer Hacking so as to help build a knowledgebase.

@angus I was originally posting to get a steer from you regarding how best to wire up the Composer to the Rails model. GitHub repo is here GitHub - pacharanero/discourse-reflective-learning-plugin: Plugin to support Reflective Learning using Discourse as a knowledge management platform

However, I was looking at the thread @merefield posted a few weeks back about curated personal learning, which is a very similar requirement, and on that page Jeff mentions that users can send themselves a PM, which of course I knew but I hadn’t thought of doing the Reflections that way. It got me thinking if I’m actually making all this much harder than I need to. Is there some way I could skin ‘PMs To Self’ and put it in that Reflective tab?

The more I think about doing it that way the more I think it would be a good idea.

  • Less overall work
  • Vastly increased functionality compared to using my own Rails model for a Reflection
  • Ability to invite other users to participate in the reflective discussion (eg inviting an appraiser or supervisor to the threads
1 Like

It’s always a good thing to leverage as much of the existing functionality as possible.

It sometimes takes you to get to Version 2.0 before it dawns on one how better to deliver something.

I was working on a plugin for one of my own sites and it wasn’t until people started using my new functionality that I realised the data should be Topic custom fields not User custom fields. It was a fair amount of rework!

hm, it depends.

The downside of adapting PMs for this purpose is that you’ll have to hook into all the existing complex functionality of the topic list, topic model and composer and you’ll be largely constrained to that structure.

Once you’ve setup your seperate model and CRUD system, you can do pretty much anything with it. I’ve made some suggestions as to how you can keep developing that system: Comparing pacharanero:master...angusmcleod:suggestions · pacharanero/discourse-reflective-learning-plugin · GitHub (Github seems to be down?? it won’t let me create a PR).

In terms of the “composer” in that system, you can just use the {{d-editor}} component, which is the generic version of the Discourse editor, without the ‘composer’ wrapper (which is specific to creating topics).

My gut here is to go with the seperate structure. It seems to fit more with the goal / flexibility you might want in this system


This is awesome thanks Angus, I’ll dig into this now

How’s this one going? Happy to help out more if you’re stuck here.

1 Like

Thanks - I didn’t get to looking at it yet, been mad busy with other stuff - it’s the Joint GP IT Committee meeting next week so am sorting out a load of stuff for that

1 Like