Changeset 1983


Ignore:
Timestamp:
09/10/07 17:08:44 (12 years ago)
Author:
pjotr
Message:

References #1512, some new stuff is in

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/utilities/scam-export.py

    r1980 r1983  
    5151subj_area_types = {'Natural sciences':'875','Geography':'544','Chemistry':'195','Physics':'978','Biology':'144','Environmental education':'431','Language and literature':'758','Foreign languages':'508','Mathematics':'790','Informatics or ICT':'1034','Art':'91','Music':'856','History':'590','Religion':'1085','Philosophy':'968','Ethics':'441','Psychology':'1040','Social sciences':'1204','Culture':'303','Citizenship':'209','Politics':'1001','Economics':'383','Media education':'798','Physical education':'974','School-community relationship':'1139','Educational administration':'761','Cross-curricular education':'292'} 
    5252 
     53# Target groups and ages 
     54targ_groups = {'pre-school education':'U-6','1st grade':'6-7','2nd grade':'7-8','3rd grade':'8-9','4th grade':'9-10','5th grade':'10-11','6th grade':'11-12','7th grade':'12-13','8th grade':'13-14','9th grade':'14-15','10th grade':'15-16','11th grade':'16-17','12th grade':'17-18','higher education':'18-U','adult education':'18-U','teachers':'21-65','special education':'6-19'} 
     55 
    5356def generateCSVfile(lemill_id,portal_url): 
    5457    lemill = getattr(app,lemill_id) 
     
    7174        fields.append(result.Title) 
    7275        # Add Description 
    73         # XXX XXX This one might be tricky and might even require us to deal with objects themselves 
    74         # ... BLA BLA BLA 
    75         # XXX TEMPORARY REPLACEMENT 
    76         fields.append('Description') 
     76        if result.meta_type == 'PILOTMaterial': 
     77            fields.append(result.getShortDescription) 
     78        else: 
     79            fields.append(result.getDescription) 
    7780        # Add LO language 
    7881        fields.append(result.Language) 
     
    9699        fields.append(lre_types[result.meta_type]) 
    97100        # Add Age range 
    98         # XXX XXX This one will require a transformation 
    99         # XXX TEMPORARY REPLACEMENT 
    100         fields.append('6-18') 
    101         # ... BLA BLA BLA 
     101        age_ranges = result.getTarget_group 
     102        def getMinimum(category,current_min): 
     103            v = targ_groups[category].split('-')[0] 
     104            if v=='U': return 'U' 
     105            elif current_min==None: return v 
     106            elif current_min=='U': return 'U' 
     107            return min(v,current_min) 
     108        def getMaximum(category,current_max): 
     109            v = targ_groups[category].split('-')[1] 
     110            if v=='U': return 'U' 
     111            elif current_max==None: return v 
     112            elif current_max=='U': return 'U' 
     113            return max(v,current_max) 
     114        minage=maxage=None 
     115        for cat in age_ranges: 
     116            if cat=='special education' and len(age_ranges)>1: 
     117                continue 
     118            minage = getMinimum(cat,minage) 
     119            maxage = getMaximum(cat,maxage) 
     120             
     121        if minage==None: 
     122            fields.append('') 
     123        else: 
     124            fields.append('-'.join((minage,maxage))) 
    102125        # Add Description of rights 
    103126        fields.append(license_link) 
Note: See TracChangeset for help on using the changeset viewer.