Esempio n. 1
0
 def col_classes(self, dpid=None):
     student_departments = self.col_departments(1)
     if not student_departments:
         return None
     if not dpid:
         return dict_search2(student_departments['data'], 'departid', dpid)
     else:
         return dict_search2(student_departments['data'], 'level', '6')
Esempio n. 2
0
 def _list_class(gradeid=""):
     # 列出年级下的班级
     schooldata = self.col_departments(1)
     if not schooldata:
         return
     if not gradeid:
         return dict_search2(schooldata, 'level', '6')
     grade = dict_search2(schooldata, 'departid', gradeid, one=True)
     return grade['child'] if isinstance(
         grade, dict) and 'child' in grade else None
Esempio n. 3
0
 def _class_2_grade(self, classid):
     # 根据classid获取所在年级
     schooldata = self.col_departments(1)
     if not schooldata:
         return
     if isinstance(classid, dict):
         clsid = classid['departid']
         gid = clsid['parentid']
         grade = dict_search2(schooldata, 'departid', gid)
         return grade
     grades = dict_search2(schooldata, 'level', '5')
     if not grades:
         return None
     for g in grades:
         for c in g['child']:
             if c['departid'] == classid:
                 return g
     return None
Esempio n. 4
0
 def col_teacher_class(self, userid, ftype=0):
     # class that teach
     # 3:teach; 2:classteacher; 1-classmanager
     reqd = {'userid': userid}
     realurl = self.handle_msger(reqs=reqd)
     wx_rtdata = None
     with capp_smsg('get_teacherclass') as qer:
         wx_rtdata = qer.get(urlpath=realurl)
     if wx_rtdata['code'] == 0:
         if ftype and 0<ftype<4:
             return dict_search2(wx_rtdata['data'], 'type', str(ftype))
         else:
             return wx_rtdata['data']
     return wx_rtdata
Esempio n. 5
0
 def _getclass_s(clsid_s, gradeid=None, take=None):
     # 在全校/gradeid年级搜索符合条件的班级dict: {class_dpid: {classdict}, ...}
     # take more then one class for a fasterway
     # clsid_s: [clsid, clsid, ...]
     # if gradeid: find in grade
     schooldata = self.col_departments(1)
     if not schooldata:
         return
     clslist = clsid_s if isinstance(
         clsid_s,
         (list, tuple)) else [_.strip() for _ in clsid_s.split(',')]
     source = dict_search2(schooldata, 'departid', gradeid,
                           one=True) if gradeid else schooldata
     result = dict_search3(source,
                           'departid',
                           clslist,
                           listout=False,
                           outkey='departid')
     if not take:
         return result
     out = {}
     for k, v in result.items():
         out[k] = v[take]
     return out