Can anyone tell me what "activityinstance" does?

Can anyone tell me what "activityinstance" does?

Mary Evans發表於
Number of replies: 9

...other than add a transparent block at the top of a label making the label even bigger than it needs to be...see image

activityinstance

But why is it there?

I'm fixing MDL-33569 and found. while testing. that there is an empty div container with class activityinstance assigned to it inside a label.

Looking in base/style/course.css I found this...

.course-content .section .activity .activityinstance { padding-right: 3em; }

which in turn adds a spacer to the label...see the red blob.

Git bashing at the mo...

git-bash

評比平均分數: -
In reply to Mary Evans

Re: Can anyone tell me what "activityinstance" does?

Gareth J Barnard發表於
Core developers的相片 Particularly helpful Moodlers的相片 Plugin developers的相片

Hi Mary,

I don't know about the CSS but I did a search and it appears at a guess to be a part of the drag and drop functionality in a course when moving things.  Please see the attached screen shot showing the places it is used, the other hidden results are just CSS entries.

Cheers,

Gareth

附件 activityinstance.jpg
In reply to Gareth J Barnard

Re: Can anyone tell me what "activityinstance" does?

Mary Evans發表於

But why add an empty container?

..besides I thought AJAX/JS used id's and not classes?

In reply to Mary Evans

Re: Can anyone tell me what "activityinstance" does?

Gareth J Barnard發表於
Core developers的相片 Particularly helpful Moodlers的相片 Plugin developers的相片

Off the top of my head I believe that an empty container in AJAX is used as an anchor point to contain the markup that it places there, so when initially rendered at the server end will be empty.  I would have thought that AJAX (which encapsulates JavaScipt within it's terminology) will use whatever it needs to use to solve the problem, such as a 'class' for creating a list (or array) of potential drop points.  Perhaps it's doing a YUI 'all' method - http://yuilibrary.com/yui/docs/node/ - to get them.

To be honest I don't really know without looking deeply at the code, but I suspect it's using a class for a reason.  Perhaps ask on the developers forum or dev chat?

In reply to Gareth J Barnard

Re: Can anyone tell me what "activityinstance" does?

Mary Evans發表於

I'll ask Andrew he will probably know.

I still cannot understand what the padding right: 3em is doing there though, as it is just creating unwanted space in the front page and course pages. If it's an empty div, fine which should be styled margin: 0; padding: 0; line-height: 0;

OK...end of rant!

In reply to Mary Evans

Re: Can anyone tell me what "activityinstance" does?

Gareth J Barnard發表於
Core developers的相片 Particularly helpful Moodlers的相片 Plugin developers的相片

No worries.  I would have thought you could do anything with the style in CSS as long as the style still existed for D&D etc.

In reply to Mary Evans

Re: Can anyone tell me what "activityinstance" does?

David Scotson發表於
It's not for drag and drop. It's just the class for wrapping the icon and name/link for activity instances. Labels have been kind of shoe-horned in to where there would normally be an activity item so there's a few weird things in the CSS that'll catch you out as you try to style one or the other (since they are two quite different things) and accidentally affect both.

The other weird thing is some of the CSS is also shared between editing mode and non-editing mode. This 3em padding seems designed to put some space between the activity name and the activity editing icons. So it should really only be applied on the editing page I think.
In reply to David Scotson

Re: Can anyone tell me what "activityinstance" does?

Mary Evans發表於

Not according to Andrew Nicols in his comment to me HERE

[Quote...

As I recall, this is present to make the JS simpler. It's primarily used by drag and drop content - that's:

    • moving existing activities to an empty section; and
    • dropping new files into Moodle.

Without it, we have to work out whether there is such a section, and then add it if it's not there. Adding it can be quite expensive and has to be done at page load whenever editing is on.

I do wonder whether we can simplify the structure of that - e.g. moving the modindent class to the same as the activityinstance. We may have to make some JS changes in order to do so.

Andrew

...end Quote]

In reply to Mary Evans

Re: Can anyone tell me what "activityinstance" does?

David Scotson發表於
Hi Mary,

just saw that. Still not clear to me why javascript is to blame for this?

If dragging and dropping into new sections was responsible then it would have to be present regardless of whether a label was there or not. All I see is the empty ul tag in that situation.
In reply to David Scotson

Re: Can anyone tell me what "activityinstance" does?

Mary Evans發表於

It's a <div> not a <ul> but even so it would not be so bad if it wasn't styled. At the moment it acting like a transparent spacer which in this case is making the label area bigger than it needs to be.