Week 6 - Creating admin functions

After making the api_backbone function more effective and efficient, this week saw some basic API calls followed by making admin functionaities. The week started with the mid term evaluations, which I passed.

I started off with a few calls for member lists from the table AT_members. A few API calls that were implemented are as follows-

GET /api/instructors/[instructor_id]/courses/[course_id]/instructors  
GET /api/instructors/[instructor_id]/courses/[course_id]/students  

The first call returns the list of instructors for a particular course. The second one is for a list of students enrolled in a course. The access levels for these calls are admin and instructor, respectively.

Before we move on to the admin functionalities, let us discuss two more things that were implemented- logging level and token expiry.

Till last week, all API calls were being logged. Now, we have defined three logging levels- No logging, logging except GET calls and all logging. These are self explanatory, except the second, which would log all errors, even if it was a GET call.

Again, the token expiry date was set at one day from the date of creation or modification. However, this setting is now set by the admin to a certain number of days.

These settings are stored in the table AT_config with a name and value. These settings can be accessed anywhere in ATutor with the help of the array $_config[]. For instance, the settings that I am concerned with right now are $_config['api_logging_level'] and $_config['api_token_expiry'].

The admin functionality was created within the module that was created for the purpose. The first functions were the ability to change the logging level and token expiry.

Secondly, the admin could download the API log as a JSON file. I am currently thinking of creating the ability to download it as CSV. Lastly, the admin can clear the API log. This essentialy clears the AT_api_logs table.

This rounds up another productive week. Let's hope we have a great second half ahead!