示例#1
0
文件: views.py 项目: adlnet/xci
def perfwks():
    d = {}
    if request.method == 'GET':
        # Determine if asking for specific fwk or not
        uri = request.args.get('uri', None)
        d['error'] = request.args.get('error', None)
        if uri:
            if current_user.is_authenticated():           
                d['registered'] = str(hash(uri)) in User(current_user.id).profile['perfwks'].keys()

            d['uri'] = uri
            d['fwk'] = models.getPerformanceFramework(uri)
            return render_template('perfwk-details.html', **d)
        d['frameworks_form'] = FrameworksForm()
    else:
        # Validate submitted fwk uri/parse/add to system
        ff = FrameworksForm(request.form)
        if ff.validate_on_submit():
            #add to system
            competency.parseComp(ff.framework_uri.data)
            d['frameworks_form'] = FrameworksForm()
        else:
            d['frameworks_form'] = ff

    d['pfwks'] = models.findPerformanceFrameworks()
    return render_template('performancefwks.html', **d)
示例#2
0
文件: views.py 项目: adlnet/xci
def badge_upload():
    # Get file and badgeimageurl that was pre-built when perfwk was created
    badge = request.files['badge']
    url = request.form['imageurl']
    uri = request.form['uri']
    componentid = request.form['componentid']

    # Make sure the file name is allowed and secure (just png for now)
    if badge and models.allowed_file(secure_filename(badge.filename)):
        parts = urlparse(url)
        path_parts = parts.path.split('/')

        badge.filename = path_parts[5]
        perflvl_id = os.path.splitext(path_parts[5])[0]
        grid_name = ':'.join(path_parts[3:6])
        try:
            saved = models.fsSaveBadgeFile(badge, grid_name)
        except Exception, e:
            return redirect(url_for('perfwks', uri=uri, error=e.message))
        else:
            perfwkobj = models.getPerformanceFramework(uri)
            for c in perfwkobj.get('components', []):
                if c['id'] == componentid:
                    for pl in c['performancelevels']:
                        if pl['id'] == perflvl_id:
                            pl['badgeuploaded'] = True
                            break
            models.updatePerformanceFramework(perfwkobj)
            return redirect(url_for('perfwks', uri=uri))
示例#3
0
def perfwks():
    d = {}
    if request.method == 'GET':
        # Determine if asking for specific fwk or not
        uri = request.args.get('uri', None)
        d['error'] = request.args.get('error', None)
        if uri:
            if current_user.is_authenticated():
                d['registered'] = str(hash(uri)) in User(
                    current_user.id).profile['perfwks'].keys()

            d['uri'] = uri
            d['fwk'] = models.getPerformanceFramework(uri)
            return render_template('perfwk-details.html', **d)
        d['frameworks_form'] = FrameworksForm()
    else:
        # Validate submitted fwk uri/parse/add to system
        ff = FrameworksForm(request.form)
        if ff.validate_on_submit():
            #add to system
            competency.parseComp(ff.framework_uri.data)
            d['frameworks_form'] = FrameworksForm()
        else:
            d['frameworks_form'] = ff

    d['pfwks'] = models.findPerformanceFrameworks()
    return render_template('performancefwks.html', **d)
示例#4
0
def badge_upload():
    # Get file and badgeimageurl that was pre-built when perfwk was created
    badge = request.files['badge']
    url = request.form['imageurl']
    uri = request.form['uri']
    componentid = request.form['componentid']

    # Make sure the file name is allowed and secure (just png for now)
    if badge and models.allowed_file(secure_filename(badge.filename)):
        parts = urlparse(url)
        path_parts = parts.path.split('/')

        badge.filename = path_parts[5]
        perflvl_id = os.path.splitext(path_parts[5])[0]
        grid_name = ':'.join(path_parts[3:6])
        try:
            saved = models.fsSaveBadgeFile(badge, grid_name)
        except Exception, e:
            return redirect(url_for('perfwks', uri=uri, error=e.message))
        else:
            perfwkobj = models.getPerformanceFramework(uri)
            for c in perfwkobj.get('components', []):
                if c['id'] == componentid:
                    for pl in c['performancelevels']:
                        if pl['id'] == perflvl_id:
                            pl['badgeuploaded'] = True
                            break
            models.updatePerformanceFramework(perfwkobj)
            return redirect(url_for('perfwks', uri=uri))
示例#5
0
文件: performance.py 项目: adlnet/xci
 def _config(self):
     self.fwkobj = models.getPerformanceFramework(self.uri)
     self.userobj = User(self.username)
     self.actor = '{"mbox": "mailto:%s"}' % self.userobj.email
     # tetris doesn't use expapi
     self.verb = 'http://adlnet.gov/xapi/verbs/completed'
     self.query_string = '?agent={0}&verb={1}&activity={2}&related_activities={3}'
     if self.userobj.profile['lrsprofiles']:
         self.profiles = self.userobj.profile['lrsprofiles']
     else:
         self.profiles = [current_app.config['DEFAULT_PROFILE']]
示例#6
0
 def _config(self):
     self.fwkobj = models.getPerformanceFramework(self.uri)
     self.userobj = User(self.username)
     self.actor = '{"mbox": "mailto:%s"}' % self.userobj.email
     # tetris doesn't use expapi
     self.verb = 'http://adlnet.gov/xapi/verbs/completed'
     self.query_string = '?agent={0}&verb={1}&activity={2}&related_activities={3}'
     if self.userobj.profile['lrsprofiles']:
         self.profiles = self.userobj.profile['lrsprofiles']
     else:
         self.profiles = [current_app.config['DEFAULT_PROFILE']]