Weeks 9-10: Completing basic calls in the GSoC

Last week was marked by travel plans, which is why I have decided to merge report of the work of two of these weeks together.

The first thing was to change the code as per the comments from my mentor. This involved primarily cleaning up the code, which can be seen in this commit. It was basically about cleaning up redundant code. For instance, look at the following —

    $clause = create_SQL_clause(array(
        "c.title" => $_GET["title"],
            "c.cat_id" => $_GET["category_id"],
        "c.primary_language" => $_GET["primary_language"]

    $clause_with_id = create_SQL_clause(array(
        "c.course_id" => $course_id

— was reduced to something like this.

    if ($course_id) {
        $sql_array = array(
            "c.course_id" => $course_id
    } else {
        $sql_array = array(
            "c.title" => $_GET["title"],
            "c.cat_id" => $_GET["category_id"],
            "c.primary_language" => $_GET["primary_language"]
    $clause = create_SQL_clause($sql_array);

I wonder why I hadn't thought of this before!

Moving on, I started working on the last set of APIs on tests, questions and question categories.

The list of calls accomplished in Week 9 were the following —


GET /api/tests
GET /api/tests/[test_id]
GET /api/tests?title=[title]&start_date=[start_date]&end_date=[end_date]
GET /api/instructor/[instructor_id]/courses/[courseid]/tests/
GET /api/student/[student_id]/courses/[courseid]/tests/


GET /api/questions/
GET /api/questions/[question_id]
GET /api/questions/?question=[question]&category_id=[category_id]&type=[type]
GET /api/tests/[test_id]/questions/ 

GET /api/instructor/[instructor_id]/courses/[course_id]/tests/[test_id]/questions
GET /api/student/[student_id]/courses/[course_id]/tests/[test_id]/questions

Question Categories

GET /api/questions/categories/
GET /api/questions/categories/[category_id]
GET /api/questions/categories?name=[name]

POST /api/questions/categories/

PUT /api/questions/categories/[category_id]

DELETE /api/questions/categories/[category_id]

After traveling back to college and shifting to a new room, I finally got to resuming my GSoC work.

The first thing that I did was to changed the SQL queries. My queries were unreadable up until now and I decided to work on them after reading a book Simply SQL. The refactoring took a few days, but with the increased readability, I guess it was worth the effort.

The next part was to complete the rest of the calls. I completed the PUT, POST and DELETE calls for tests, and the only remaining calls are that of questions from our initial list.