Ejemplo n.º 1
0
 def __get_classmates(self, clazz_id: str) -> ExtendedList[StuPerson]:
     classmates = StuPersonList()
     r = self._session.get(Url.GET_CLASSMATES_URL,
                           params={
                               "r": f"{self.id}student",
                               "clazzId": clazz_id
                           })
     json_data = r.json()
     for classmate_data in json_data:
         birthday = int(int(classmate_data.get("birthday", 0)) / 1000)
         classmate = StuPerson(
             name=classmate_data["name"],
             id=classmate_data["id"],
             clazz=StuClass(
                 id=classmate_data["clazz"]["id"],
                 name=classmate_data["clazz"]["name"],
                 grade=self.clazz.grade,
                 school=School(
                     id=classmate_data["clazz"]["school"]["id"],
                     name=classmate_data["clazz"]["school"]["name"])),
             code=classmate_data.get("code"),
             email=classmate_data["email"],
             qq_number=classmate_data["im"],
             gender=Sex.BOY
             if classmate_data["gender"] == "1" else Sex.GIRL,
             mobile=classmate_data["mobile"])
         classmate.birthday = birthday
         classmates.append(classmate)
     return classmates
Ejemplo n.º 2
0
 def get_friends(self) -> ExtendedList[StuPerson]:
     """获取朋友列表"""
     friends = StuPersonList()
     r = self._session.get(Url.GET_FRIEND_URL,
                           params={"d": int(time.time())})
     json_data = r.json()
     for friend in json_data["friendList"]:
         friends.append(
             StuPerson(name=friend["friendName"], id=friend["friendId"]))
     return friends
Ejemplo n.º 3
0
 def __get_self_mark(self, exam: Exam, has_total_score: bool) -> Mark:
     mark = Mark(exam=exam, person=self)
     r = self._session.get(Url.GET_MARK_URL,
                           params={"examId": exam.id},
                           headers=self.__get_auth_header())
     json_data = r.json()
     if json_data["errorCode"] != 0:
         raise Exception(json_data["errorInfo"])
     json_data = json_data["result"]
     # exam.name = json_data["total_score"]["examName"]
     # exam.id = json_data["total_score"]["examId"]
     for subject in json_data["paperList"]:
         subject_score = SubjectScore(
             score=subject["userScore"],
             subject=Subject(id=subject["paperId"],
                             name=subject["subjectName"],
                             code=subject["subjectCode"],
                             standard_score=subject["standardScore"],
                             exam=exam),
             person=StuPerson())
         # subject_score.create_time = 0
         mark.append(subject_score)
     total_score = json_data.get("totalScore")
     if has_total_score and total_score:
         subject_score = SubjectScore(
             score=total_score["userScore"],
             subject=Subject(
                 id="",
                 name=total_score["subjectName"],
                 code="99",
                 standard_score=total_score["standardScore"],
                 exam=exam,
             ),
             person=StuPerson(),
             class_rank=ExtraRank(rank=exam.classRank),
             grade_rank=ExtraRank(rank=exam.gradeRank))
         # subject_score.create_time = 0
         mark.append(subject_score)
     return mark