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

command to download all the courses the user can see #6

Closed
sds100 opened this issue Feb 5, 2020 · 7 comments
Closed

command to download all the courses the user can see #6

sds100 opened this issue Feb 5, 2020 · 7 comments
Labels
Elaborate enhancement New feature or request (But it is costly, PR is seen with pleasure.)

Comments

@sds100
Copy link

sds100 commented Feb 5, 2020

Could you add a command to download all the courses the user can SEE and not just ones they are enrolled in since I can see other courses on my moodle, which I'm not enrolled in?

@C0D3D3V
Copy link
Owner

C0D3D3V commented Feb 7, 2020

That would be fine, but it is very unusual to download courses in which you are not enrolled.

Especially because by default you can't see the course content without registering, the admin has to change some settings to make this possible.

Currently I don't have time to implement this, but you can currently try to force the downloader to download a course by modifying the following code.
In this file moodle_connector/moodle_service.py

There, in line 90, all courses you are enrolled in are selected.
courses = results_handler.fetch_courses(userid)

You can add courses manually immediately afterwards.

Like this:

courses = results_handler.fetch_courses(userid)
courses.append(Course(2342, 'Ein Kurs', []))

Where the first parameter of Course is the id of the course, the second the name of the course and the 3rd must be an empty list.

This should work as long as you have read access to the course.

@sds100
Copy link
Author

sds100 commented Feb 7, 2020 via email

@C0D3D3V
Copy link
Owner

C0D3D3V commented Feb 7, 2020

You can have a look in results_handler.fetch_courses and make a similar function for all courses...

You get a list of all courses in your moodle by calling:

https://moodle.uni.de/webservice/rest/server.php?moodlewsrestformat=json&wsfunction=core_course_get_courses_by_field&wstoken=c3703dcyour_token2e2eb46ba942a0

If there are a lot of courses on your moodle, it will not make you happy... because it takes a very long time.

To filter the list, you should first ask for the catagories... and then filter by category.

https://moodle.uni.de/webservice/rest/server.php?moodlewsrestformat=json&wsfunction=core_course_get_categories&wstoken=c3703dcyour_token2e2eb46ba942a0

https://moodle.uni.de/webservice/rest/server.php?moodlewsrestformat=json&wsfunction=core_course_get_courses_by_field&wstoken=c3703dcyour_token2e2eb46ba942a0&field=category&value=437

With the help of the enrollmentmethods you can see if you can read the course content.

@C0D3D3V C0D3D3V added the Elaborate enhancement New feature or request (But it is costly, PR is seen with pleasure.) label Feb 19, 2020
@C0D3D3V
Copy link
Owner

C0D3D3V commented Jan 12, 2021

First steps have been taken for this issue :D
Check out Issue #71 for related work.

@sds100
Copy link
Author

sds100 commented Jan 12, 2021

Cool! 😀

C0D3D3V added a commit that referenced this issue Oct 21, 2021
@C0D3D3V
Copy link
Owner

C0D3D3V commented Oct 21, 2021

you can now use moodle-dl --add-all-visible-courses
It is released, you are welcome :)

@C0D3D3V C0D3D3V closed this as completed Oct 22, 2021
@C0D3D3V
Copy link
Owner

C0D3D3V commented Oct 27, 2021

Is that okay or did you imagine it differently?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Elaborate enhancement New feature or request (But it is costly, PR is seen with pleasure.)
Projects
No open projects
Development

No branches or pull requests

2 participants