Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Units with "/" in the course name won't sync #21

Open
jarkinber opened this issue Aug 7, 2020 · 2 comments
Open

Units with "/" in the course name won't sync #21

jarkinber opened this issue Aug 7, 2020 · 2 comments

Comments

@jarkinber
Copy link

jarkinber commented Aug 7, 2020

First things first - I love CanvasSync and really appreciate the work put in to make such a great time-saving tool. Cheers!

The are a number of single courses at my uni which are run for different majors and as such, a single course may have numerous course codes associated with it. Instructors will often delimit these with forward slashes (ie "courseCode1/courseCode2/courseName") - as such there are a number of my courses which seem to be skipped even if I've selected them for syncing; each of these skipped courses has a forward slash in the name.

I've attempted to look at the source code and I've noticed a couple places where "/" is supposed to be removed in order to ensure it doesn't mess with the creation of directories, however I'm not sure why in my case instead of the course name string being cleansed, these units are just being skipped.

Please let me know if you need more info. Thanks!

@Luckinber
Copy link

Hey @jarkinber your issue comes from the settings module, when initiating the settings CanvasSync makes an array stating the courses to sync called courses_to_sync, this array doesn't ever have the get_corrected_name() function run on it's elements so later when the code tries to check the courses to be synced and the corrected courses they don't line up and it assumes they should be skipped, a proper solution would be to correct the courses as they're added to the array in the settings module but I couldn't really organise it neatly so instead I cleaned it up in the main canvas.py, code below, could be neater but this should work for most, if not all of the edge cases that CanvasSync was already correcting for.

TLDR:
Throw this code in the do_sync() function in canvas.py before synchronizer = Synchronizer(settings=settings, api=api), I have it at line 171, indentation is done with a (Indent) because I've never answered a question on Github and I can't figure out how to indent:

# Correct settings.courses_to_sync
corrected_names = []
for x in settings.courses_to_sync:
(Indent)corrected_name = helpers.get_corrected_name(x)
(indent)corrected_names.append(corrected_name)
settings.courses_to_sync = []
settings.courses_to_sync = corrected_names[:]

Goodluck!

@jarkinber
Copy link
Author

Thanks for that @Luckinber, yeah that definitely works for now, much appreciated!
@perslev would this fix or some variant thereof be worth merging into a new release?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants