cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
cesbrandt
Community Champion

Force Default Dashboard Display (New UI)

Jump to solution

I've been asked to look into making the activity list the default display for the new UI at my institution. As far as I've found, there is no setting for changing this and no one has asked about it, either. Investigating the toggle that swaps the display, I was able to create a simple JavaScript to create and submit a form sending the same information as is submitted when using the toggle switch (just trying to recreate the functionality of the trigger). The problem is I only get an error:

There was a problem with your last request. You may have tried to perform an action after a long period of inactivity. If that's the case, try going back, reloading the page you were working on, and resubmitting. If not, please let us know what you were doing when the error happened.

At this point, I have no idea how-to pursue this. I'm asking here because, as far as I'm aware, it's not a bug that this isn't changeable. Here's the snippet I've written to emulate the functionality (no control to prevent continuous switching):

function post(path, params, method) {

  method = method || 'post';

  var form = document.createElement('form');

  form.setAttribute('method', method);

  form.setAttribute('action', path);

  for(var key in params) {

    if(params.hasOwnProperty(key)) {

      var hiddenField = document.createElement('input');

      hiddenField.setAttribute('type', 'hidden');

      hiddenField.setAttribute('name', key);

      hiddenField.setAttribute('value', params[key]);

      form.appendChild(hiddenField);

    }

  }

  document.body.appendChild(form);

  form.submit();

}

var token = document.cookie.match(/\_csrf\_token\=[^;]+/)[0].replace(/\_csrf\_token\=/, '');

var view = document.getElementById('page_view_id');

post(('/users/toggle_recent_activity_dashboard'), { _post: 'POST', authenticity_token: token, page_view_id: view });

Any help would be greatly appreciated.

1 Solution

Accepted Solutions
James
Community Champion

I'm glad it's no longer an issue. I was just trying to address the technical side of it, but the human side of me says it should be up to the user to decide what they want to see. The teacher in me dislikes the recent activity stream because students live and die by the To Do list, which is incomplete, and so encouraging that behavior is detrimental to success in the course. Most of my students don't work on things until the night they are due rather than realizing it's a week-long discussion, not an assignment to turn in before it's due. Or they wait too late to begin the quiz to ask questions if they have it.

Personal thoughts aside, I'll try to address the issues in case someone else has a similar issue. I'll also reiterate much of what you wrote so other can have the details.

There is no API that I know of that will tell you that information. This is consistent with the iOS App on the iPad that has the two views as separate rather than a simple toggle. What I mean by that is that if the app will do it, there's an API call for it. If the App won't do it when the web interface will, it may be because there is no API call. I use that check when trying to track down an API -- if the app does it, then I'm fairly sure there's an API call somewhere, I just may not know where, but I know I should look harder. If the app won't do it, I won't look so hard for the API call because it may not exist.

There are ways to get the default (saved) setting and the current (displayed) setting from the page without an API call.

The initial status of the dashboard is contained inside in ENV variable that is loaded with the page. It's ENV.PREFERENCES.recent_activity_dashboard. It is false when the course cards are the default and true when the recent activity is the default.

If you want to know the current status of the toggle, then you can look at the button with the id="dashboardToggleButton". When the button is to the left and you're viewing course cards, then it will have class="dashboard-toggle-button dashboard-toggle-button--toggle-left" and when it is to the right and you're viewing the activity list, it will have class="dashboard-toggle-button dashboard-toggle-button--toggle-right".

Another way to tell is to look at two divs, one id="dashboard-activity" and the other id="DashboardCard_Container". The display will either be "none" or "block" depending on which one you have toggled.

Here is Course Cards

189791_pastedImage_4.png

Here is recent activity

189790_pastedImage_3.png

The setting included in the ENV variable is used to determine which is displayed. Information for both the Course Card list and the Recent Activity list are obtained through GET API calls. but neither one of those controls which is displayed.

As you mentioned, none of those tell you whether the setting is the result of a user choice or a default setting. It is impossible to tell unless the default state is the recent activity list, in which case you know they've changed it at some point, or if the currently displayed one does not match the one in the ENV variable, which is not updated within the existing page when changes are made (it is updated on the next reload). If, however, the ENV variable says to display the course cards, you don't know whether the user had looked at recent activity and changed it back or whether it was just never set in the first place.


Changing it on the fly when they log in is not going to persistent. If they change it, then the next time they visit the page, even if it's in the same session, it will send the new settings with that page without any history that it has changed. If someone wanted to track that, they would need to store those results somewhere like the custom data for the user.  Pick a name like dashboard_overridden or make it part of a bigger package. Your custom data can be a JSON object and include subgroups.

Begin by checking to see if the variable exists in the customer user data and if it is, then don't do anything because they've manually changed it. If the variable is unset, then add an eventListener to the button. When they click it, then you update the custom user data and then have it execute the existing listeners which will do the Canvas end of things.

You can't really use a cookie or local storage because that will be specific to a machine and a browser, so the custom data is the only place I can think of, short of storing it on your own server, where it would persist.

On the other hand, setting the default to be the recent activity list outside of a browser as the individual user would be difficult and time consuming. I would probably try to automate it using a headless browser like CasperJS or PhantomJS (there may be others) can provide. I could log in as an administrator and send the commands to masquerade as a user. Once I'm masquerading, I would get the main Canvas page and check the ENV.PREFERENCES.recent_activity_dashboard variable. If it is false, then I would set it to true using an AJAX call (which is way simpler than trying to create a form to force it). Then I would stop masquerading and repeat the process with the next student.


I still think that would be confusing to students to change things from the defaults because that interfere with the documentation and the guides about what they should expect to see. However, I can see a benefit to overriding buggy behavior in some places. For example, there was a point at the beginning of the Spring 2016 term where the student's new courses weren't showing up because they had previously chosen favorites. Students weren't going into their courses because they weren't showing up. There was talk of writing code that would go through and reset the favorites for every student. It didn't happen, but it had merit.

If the request to make the activity stream the default was made at our institution, I would try to convey why it was a bad decision and then indicate that, yes, it could be done, but go through and explain the difficulty versus the perceived benefit and how it would take time away from doing other things that might have more benefit. One thing I kept stressing during our switch over almost 4 years ago was to stop trying to make Canvas into your previous LMS and let it work for you. Of course, I hadn't used an LMS prior to Canvas, so all those silly things people wanted it to do didn't make sense to me. It turned out that most of the time, it wasn't really that they wanted a particular thing to happen, it's just that's what they were used to and comfortable with and they didn't want change.

View solution in original post

13 Replies
Renee_Carney
Community Team
Community Team

cesbrandt

I'm sorry, I do not have the expertise to help you, but I'm hoping someone in the Canvas Developers​ group does.  I'll share this idea with them and we'll see if they can help you out.

Thank you. I was beginning to think no one else had any interest in having some control over which layout would want to be encouraged for student use. Many of our faculty have expressed a preference to the older layout due to its putting information out there to students, rather than hiding it behind a slicker design.

I didn't think it would be appropriate to ask it to the developers group, since this wouldn't fall in the category of SIS, LTI, and API manipulation. ^^'

cesbrandt​, have you found a satisfactory resolution to this?

I have not found any solution to this. I'm not particularly fluent in JSON, but near as I can tell there is a level of authentication on the trigger that I can't duplicate through JavaScript.

cesbrandt​,

As there has not been any additional information added to the question, I am going to go ahead and mark this as assumed answered.  This will not prevent other users form finding it or from additional comments being added.

Robbie

jtorres1
Community Contributor

Hi Christopher,

Were you able to find a solution? We recently had a start where students were not accessing their courses because they thought they weren't there when the toggle switch on the dashboard was the problem the entire time. It was very frustrating. I'd love to hear any work arounds you've discovered!

Jenn

cesbrandt
Community Champion

I'm afraid not. From what I've found, the extent of code needed to make it work is a security concern in JavaScript. This results in most browsers simply not supporting the functions. Internet Explorer is the one that has the most support for the level of access needed, but it's also one of the worst browsers to use with Canvas, in my opinion.

Another problem is the inability to readily manipulate the selection value. If it were manipulable via the API, that'd be another story, though I'd have to advise against it, also. There is no such thing as "secure" when it comes to configuration data in JavaScript. Using API calls via JavaScript, though I've toyed with the idea, makes the configuration information available to all users, which is blatant security violation.

jtorres1
Community Contributor

Thanks, Chris! Hopefully, Canvas will create a setting that allows us to "fix" the position of the toggle switch for students.

James
Community Champion

Am I missing something? When I first read this, it didn't match my experiences. Then I reread it and now I'm confused about what exactly you're trying to do.

This sounds like an "undocumented feature" and I've used it in other places like obtaining the Access Report data for an entire course. I believe that the cookies were handled by the browser, so unless you're trying to go through all of the accounts and proactively set them one way, as opposed to setting them on the fly once people log in, then it should work out -- but even that may be overkill (see below).

If you're trying to do it for the students as a backend process without making them login, then yeah, there's going to be some major difficulty because Canvas generally tries to prevent people from doing things as other people except through masquerading.

However, if you're trying to do it within Canvas itself, then the following may help:

If I execute either one of these statements: pure JavaScript (line 1) or jQuery (line 2), from the Dashboard then it automatically toggles the button

document.getElementById('dashboardToggleButton').click();

$('#dashboardToggleButton').click();

Furthermore, that toggle writes the changes to the back end, so although I issued the JavaScript in Firefox, as soon as I refreshed the page in Chrome (I was logged into both), it switched as well.

You can detect what the current state is by looking at the classes on the button. The problem is the value isn't there initially, so you may need to add a Mutation Observer to wait until the page is loaded. But even then, it would reset itself each time they reload the page, which would be frustrating to the user. This could be avoided by storing something, perhaps in the custom user data, that indicates the state and whether it's been overridden. If that custom user data doesn't contain a value, then set it to the preferred setting and then, when they click (you'll have to add an eventListener) the button, you write to the custom user data that it has been updated and to not touch it again.

An alternative might be to contact your CSM and see if they can get Canvas to set something on the backend for your instance. Not saying they can, just saying it might be worth asking.