Exemplo n.º 1
0
def assigmentRate(assigment_id):
    """Úprava a obodování zadání"""
    usr = getUser() 

    assigment = Assigment.get( assigment_id ) 
    if not assigment: return HTTPError(404, "Cvičení nebylo nalezeno")
    #todo if ???: return HTTPError(403, "Nemáte oprávnění")

        

    if request.method == 'POST':
        action = request.forms.get("action")
        if (not action) or  (not action in ("lock", "rate", "unlock")): HTTPError(400, "Neznámá akce")
        print("----------action", action)
        try:
            if action == "lock":
                assigment.lock()
                msg("Řešení bylo zamčeno", "success")
            elif action == "rate":
                assigment.rate(  request.forms.get("points") )
                msg("Řešení bylo ohodnoceno", "success")
            elif action == "unlock":
                assigment.unlock()
                msg("Řešení bylo odemčeno", "success")            
        except ModelException as e:
            msg("Chyba při manipulaci: %s" %s, "error")             
        redirect('/assigments-lector')
        return

    return template("assigments_rate", {"assigment" : assigment } )
Exemplo n.º 2
0
def assigmentRate(assigment_id):
    """Úprava a obodování zadání"""
    usr = getUser()

    assigment = Assigment.get(assigment_id)
    if not assigment: return HTTPError(404, "Cvičení nebylo nalezeno")
    #todo if ???: return HTTPError(403, "Nemáte oprávnění")

    if request.method == 'POST':
        action = request.forms.get("action")
        if (not action) or (not action in ("lock", "rate", "unlock")):
            HTTPError(400, "Neznámá akce")
        print("----------action", action)
        try:
            if action == "lock":
                assigment.lock()
                msg("Řešení bylo zamčeno", "success")
            elif action == "rate":
                assigment.rate(request.forms.get("points"))
                msg("Řešení bylo ohodnoceno", "success")
            elif action == "unlock":
                assigment.unlock()
                msg("Řešení bylo odemčeno", "success")
        except ModelException as e:
            msg("Chyba při manipulaci: %s" % s, "error")
        redirect('/assigments-lector')
        return

    return template("assigments_rate", {"assigment": assigment})
Exemplo n.º 3
0
def assigmentDownload(assigment_id):
    """Stažení zadání"""
    usr = getUser() 

    assigment = Assigment.get( assigment_id ) 
    if not assigment: return HTTPError(404, "Cvičení nebylo nalezeno")
    #todo if ???: return HTTPError(403, "Nemáte oprávnění")

    headers = {}
    headers['Content-Type'] = "text/txt"
    headers['Content-Disposition'] = 'attachment; filename="%s.asm"' % assigment.login

    data = assigment.response

    return HTTPResponse(data, **headers)
Exemplo n.º 4
0
def assigmentDownload(assigment_id):
    """Stažení zadání"""
    usr = getUser()

    assigment = Assigment.get(assigment_id)
    if not assigment: return HTTPError(404, "Cvičení nebylo nalezeno")
    #todo if ???: return HTTPError(403, "Nemáte oprávnění")

    headers = {}
    headers['Content-Type'] = "text/txt"
    headers[
        'Content-Disposition'] = 'attachment; filename="%s.asm"' % assigment.login

    data = assigment.response

    return HTTPResponse(data, **headers)