## Script (Python) "getStudyLevelInfo" ##bind container=container ##bind context=context ##bind namespace= ##bind script=script ##bind subpath=traverse_subpath ##parameters=student=None ##title= ## # $Id: getStudyLevelInfo.py 6858 2011-10-04 06:05:39Z henrik $ """ return Info about the Studylevel try: from Products.zdb import set_trace except: def set_trace(): pass """ info = context.waeup_tool.getAccessInfo(context) student_id = info['student_id'] if student_id is None: return None mtool = context.portal_membership member = mtool.getAuthenticatedMember() member_id = str(member) course_results = context.course_results request = context.REQUEST response = request.RESPONSE import logging logger = logging.getLogger('Skins.getStudyLevelInfo') level_id = context.getId() level_doc = info['doc'] = context.getContent() info['is_so'] = is_so = info['is_sectionofficer'] #info['is_student'] = is_student = context.isStudent() info['is_ca'] = is_ca = context.isCourseAdviser() #info['student'] = student = context.students_catalog(id=student_id)[0] info['student'] = student = context.students_catalog.getRecordByKey(student_id) info['review_state'] = review_state = student.review_state is_current_level = level_id == student.level school_fee_paid = review_state == 'school_fee_paid' info['is_current_level'] = is_current_level info['has_verdict'] = has_verdict = level_doc.verdict info['submission_allowed']= school_fee_paid and is_current_level and not has_verdict and level_id != '501' info['validation_allowed']= review_state == 'courses_registered' and is_current_level and level_id != '501' info['rejection_allowed']= review_state in ('courses_registered', 'courses_validated','returning',) and\ is_current_level and level_id != '501' info['validated'] = level_doc.validated_by and not (is_current_level and review_state in ('courses_registered',)) info['show_check_boxes'] = (is_ca and school_fee_paid and is_current_level and not has_verdict) or\ (info['is_student'] and school_fee_paid and is_current_level and not has_verdict) or\ level_id == '501' or\ (is_so) # and is_current_level and not has_verdict) info['verdict'] = context.portal_vocabularies.verdicts.get(level_doc.verdict).upper() info['session'] = context.portal_vocabularies.sessions.get(level_doc.session) info['level_str'] = context.portal_vocabularies.student_levels.get(level_id) info['choosen_ids'] = request.get('ids',[]) cert_id = student.course info['cert_id'] = cert_id total_credits,gpa,carry_overs,normal1,normal2,normal3 = course_results.getCourses(student_id,level_id) info['total_credits'] = total_credits #start customization if context.objectIds(): course_results.moveResultsHere(context,student_id) logger.info("%s initiated moveResultsHere for %s in level %s" % (member_id,student_id,level_id)) max_credits = 50 try: if int(context.getId()) >= int(student.end_level): max_credits = 51 except: logger.info("%s has strange level id %s" % (student_id,level_id)) info['without_score'] = without_score = True if without_score: for rows in (normal1,normal2,normal3): for row in rows: row['score'] = 0 info['without_cascore'] = True info['max_credits'] = max_credits info['credits_exceeded'] = total_credits > max_credits current_session = student.session info['show_submit'] = not info['credits_exceeded'] and level_id != '501' info['show_update'] = level_id != '501' #end customization info['gpa'] = gpa if gpa and total_credits: info['gpa'] = "%4.2f" % (float(gpa)/int(total_credits)) # carry_overs.sort(cmp_semester_id) info['carry_overs'] = carry_overs # normal.sort(cmp_semester_id) info['normal1'] = normal1 info['normal2'] = normal2 info['normal3'] = normal3 info['data_missing'] = not info['normal1'] and not info['normal2'] and not info['normal3'] info['spillover'] = student.level > student.end_level students_object = context.portal_url.getPortalObject().campus.students student = getattr(students_object, student_id) info['app'] = student.application info['app_doc'] = student.application.getContent() return info