ErikBoesen / schoolopy

:school: Python wrapper for Schoology's REST API.
MIT License
47 stars 19 forks source link

User Count Limit #10

Open fjmoon1 opened 6 years ago

fjmoon1 commented 6 years ago

Hello again, Thanks for your feedback on my previous issues. I am able to pull "user actions" by using "_get()" however, I am unable to pull more than 200 users. I've tried setting the limit to 5000 but it will only return 200. My code below generates a dataframe called "schActivity" and it never has a length greater than 200 although there are over 4000 users in our schoology account. I have admin-level access to our schoology account. Any assistance would be greatly appreciated. Thanks!

Here is my code:

import schoolopy import time import datetime import pandas as pd import json

sc = schoolopy.Schoology(schoolopy.Auth('xxxxxxxxxxxxxxxxxxxx', 'yyyyyyyyyyyyyyyyyyy')) sc.limit = 5000 # Only retrieve 10 objects max sc.start = 1

d = datetime.date(2018,3,7) unixtime = time.mktime(d.timetuple()) print(unixtime)

end = 1520406000 start = end - 86400

print('Start_time: ' + time.ctime(start)) print('End_time: ' + time.ctime(end))

schActivity = []

cnt = 0 cnt2 = 0

for i in sc.get_users():

print(i)

schActivity.append(i['uid'])

studentActions = []

for k in schActivity: k=int(k) m = sc._get('analytics/users/%s?start_time=%s&end_time=%s&start=0' % (k, start, end))['actions'] if len(m) > 0: studentActions.append(m)

ErikBoesen commented 6 years ago

Are you able to make this request as expected elsewhere? It sounds like this could be an issue with Schoology's API.

fjmoon1 commented 6 years ago

Thanks for the quick response! I'm able to pull all the records from the Schoology website's "School Analytics" page via "Export All Users." However, I'm not having much luck getting the "get_user"actions()" to work as I expressed in my previous issues. I am relatively new to working with APIs and I'm not sure how to proceed without using your python wrapper. Thank you for your patience.

jedieaston commented 6 years ago

Schoology isn't responding to my ticket about this -- can anyone get a hold of someone over there and ask them what's up?

ErikBoesen commented 6 years ago

@jedieaston This project is completely unofficial, we have no more access to Schoology than you do. Is this issue present when making direct requests to the API?

jedieaston commented 6 years ago

@ErikBoesen I'm about to check, just thought someone who's a schoology admin might be able to contact support for us and ask if they happened to see this issue. I'm going to try again and see, but I did once before and it wasn't different whether or not I was using the library.

ErikBoesen commented 6 years ago

@jedieaston Understood, sorry if I misinterpreted your question. Unfortunately there's not much I can do as I'm just a student and am not really able to debug these issues. It's not the greatest situation, I confess.

jedieaston commented 6 years ago

@ErikBoesen No worries, I'm a student too. Hopefully they get back to me soon, because otherwise this library works great for what I'm doing with it.

jedieaston commented 6 years ago

A little update, Schoology just got back to me.

If this problem is affecting you, at the end of a request you will get something like this: ], "total": "300", "links": { "prev": "https://api.schoology.com/v1/groups/000000000/enrollments?start=0&limit=200", "self": "https://api.schoology.com/v1/groups/000000000/enrollments?start=1&limit=200", "next": "https://api.schoology.com/v1/groups/00000000/enrollments?start=201&limit=200" } }

So, the library would have to implement a multi-get, where if the total exceeded 200, then it would make requests for every 200 and then return the whole result.

They left my ticket open if you need more information, @ErikBoesen

BraydenKO commented 2 years ago

I know this is a little late (four years!!) but for those who run into this issue as well: I couldn't figure out how to implement a multiget, it kept returning an empty list, but you could simply just add a start=x parameter for Schoology._get, and call it for every 200.

However, if anyone got a multiget working, could you show me what you did?