carroll-ccsd and @Landmark_Coll ,
I'm starting back over at the top level to break the deep indentation
So, I created a course with these pages. I tried to do various combinations of spellings and spacings. What you cannot see is that Week 2 has about 5 spaces between the week and the 2 and that's why Canvas put it first.
I'm click-phobic. I would rather spend a couple of hours writing code that will save me some repetitive clicks. I scraped the Page index page and wrote an unordered list of what would be added to the page if a person went through and manually added the Week* pages. It writes it to the console. I then copied and pasted it into the HTML editor on the Course Home Page.
This made my Course Home Page look like this.
Interesting, the <Lodash> got cut off, so the page name and URL stops with "and".
Now I'm ready to do some discussion.
Going back to Robert's code from May 10 ...
The return() inside the Object.keys(links).forEach() doesn't break out of the forEach(). forEach() goes through all iterations. The return returns from the function that is called by the forEach(): 3 things you didn't know about the forEach loop in JS.
Is there a reason why we need to add a class to every link that we want to consider? Is there a time that /^Week \d+\b/ would not be a link to a page for that week? By looking inside the div.user-content, we should be able to make sure that it's just the stuff the user has put on the page.
Going back to Michael's statements about automatic vs manual and Spring Break beginning April 26 ...
As I was looking at the code generated by Canvas for the page index and trying to figure out how to extract the information so I could save adding 16 pages to a content page, I had an epiphany. Or at least I think I did.
There is a way to encode information into a web page that won't get stripped by the Canvas HTML Whitelist. That's by using the data-* attributes.
We could add a header to the start of the page and then add data-start, data-end, and data-skip. For example it might look like this:
<div data-start="2019-01-14" data-end="2019-05-18" data-skip="8" id="week_count"></div>
If you did the start and end, you wouldn't have to make the extra API call. That doesn't take very long, so you may just want to still make the API call to get the start and finish dates and just put the skip in there for spring courses. On the other hand, if you're having trouble getting mobile to recognize it, it may be able to recognize the data attributes. I have not tested this, so it still may not work.
If I was doing a lot of this, I would still automate it, but it might be by running a script that iterates through the list of candidate courses, fetches the front page, checks for the existence of that header, adds and saves the page if it's missing or needs updated.
Edit: After sleeping on it, maybe it's not such an epiphany. It may be easier to hard-code the calendar weeks of spring break for the next several years into the custom JavaScript directly as an object. Aside from this project, the use of the data- attributes may help with some of the mobile questions Robert and I have tossed around in the past.
Going back to the original question ...
I finally looked at the New England Tech (NEIT) Canvas site that you mentioned.
They're modifying the global navigation menu rather than trying to navigate content on specific pages. Did we decide that was not the way we wanted to go? It looks like Robert jumped in with something at the top of the page, rather than on the side in the navigation menu and it just progressed from there (sorry if I missed the discussion, this is getting to be a long thread)
That would have it available on every page for every student and you wouldn't need to do any customization to the individual courses. You wouldn't have to customize the front page of each course. You wouldn't be able to jump directly to the same place with a link in the "this is week 10" line at the top, but it also wouldn't take up space at the top.
Of course, that would only work if your entire institution was on the same schedule. That would never work for us as we have different length courses that start and stop at different times.
I also noticed when I looked at the JavaScript that NEIT was using and it appears that they do some similar things with content pages, similar to what Robert is so I may be missing what you were talking about. I don't see it on their course home page, but it looks like it should be doing something. Also, they have a script that pulls the week number from a text file on a server they maintain, rather than trying to figure it out through Canvas. It also looks like they're using it to handle some kind of featured content based on the week number.
I've got other ideas on the code and I still think there's some promise-related issues to work through. It may not matter in the web, but I know that Node was hanging and not exiting the program when I don't get it right. I'm using the fetch library for node, which is supposed to mimic what happens in the browser. There are some other issues, like the forEach() that keep executing, even after finding a match.
This discussion post is outdated and has been archived. Please use the Community question forums and official documentation for the most current and accurate information.