
from restclients.catalyst import Catalyst
from restclients.exceptions import DataFailureException
from restclients.dao import Catalyst_DAO

class GradeBook(object):

    def get_grades_for_student_and_term(self, netid, year, quarter):
        """
        returns a restclients.models.catalyst.CourseGradeData object
        """
        url = "/rest/gradebook/v1/grades/%s/%s/%s" % (netid, year, quarter)
        dao = Catalyst_DAO()
        response = dao.getURL(url, { "Accept": "application/json" })

        if response.status != 200:
            raise DataFailureException(url, response.status, response.data)

        return Catalyst().parse_grade_data("GradeBook", response.data)


from restclients.catalyst import Catalyst
from restclients.exceptions import DataFailureException
from restclients.dao import Catalyst_DAO

class GradeBook(object):

    def get_grades_for_student_and_term(self, netid, year, quarter):
        """
        returns a restclients.models.catalyst.CourseGradeData object
        """
        quarter = quarter.capitalize()
        url = "/rest/gradebook/v1/grades/%s/%s/%s" % (netid, year, quarter)
        dao = Catalyst_DAO()
        response = dao.getURL(url, { "Accept": "application/json" })

        if response.status != 200:
            raise DataFailureException(url, response.status, response.data)

        return Catalyst().parse_grade_data("GradeBook", response.data)

Make sure quarters are in the format catalyst wants
Make sure quarters are in the format catalyst wants


git-svn-id: 24222aecec59d6833d1342da1ba59f27d6df2b08@636 3f86a6b1-f777-4bc2-bf3d-37c8dbe90857

  
  from restclients.catalyst import Catalyst
  from restclients.exceptions import DataFailureException
  from restclients.dao import Catalyst_DAO
  
  class GradeBook(object):
  
      def get_grades_for_student_and_term(self, netid, year, quarter):
          """
          returns a restclients.models.catalyst.CourseGradeData object
          """
+         quarter = quarter.capitalize()
          url = "/rest/gradebook/v1/grades/%s/%s/%s" % (netid, year, quarter)
          dao = Catalyst_DAO()
          response = dao.getURL(url, { "Accept": "application/json" })
  
          if response.status != 200:
              raise DataFailureException(url, response.status, response.data)
  
          return Catalyst().parse_grade_data("GradeBook", response.data)
  
Make sure quarters are in the format catalyst wants
## Code Before:

from restclients.catalyst import Catalyst
from restclients.exceptions import DataFailureException
from restclients.dao import Catalyst_DAO

class GradeBook(object):

    def get_grades_for_student_and_term(self, netid, year, quarter):
        """
        returns a restclients.models.catalyst.CourseGradeData object
        """
        url = "/rest/gradebook/v1/grades/%s/%s/%s" % (netid, year, quarter)
        dao = Catalyst_DAO()
        response = dao.getURL(url, { "Accept": "application/json" })

        if response.status != 200:
            raise DataFailureException(url, response.status, response.data)

        return Catalyst().parse_grade_data("GradeBook", response.data)

## Instruction:
Make sure quarters are in the format catalyst wants
## Code After:

from restclients.catalyst import Catalyst
from restclients.exceptions import DataFailureException
from restclients.dao import Catalyst_DAO

class GradeBook(object):

    def get_grades_for_student_and_term(self, netid, year, quarter):
        """
        returns a restclients.models.catalyst.CourseGradeData object
        """
        quarter = quarter.capitalize()
        url = "/rest/gradebook/v1/grades/%s/%s/%s" % (netid, year, quarter)
        dao = Catalyst_DAO()
        response = dao.getURL(url, { "Accept": "application/json" })

        if response.status != 200:
            raise DataFailureException(url, response.status, response.data)

        return Catalyst().parse_grade_data("GradeBook", response.data)
