Example #1
0
def list():
    """Seznam odevzdaných zadání"""
    
    usr = getUser() 
    #todo pro mastera zobrazit všechny

    # zjistíme v jaké jsme skupině
    assigments = Assigment.getPending( usr.login ) 
    silent = Assigment.getSilent( usr.login ) 
    
    return template("assigments_lector", {"assigments" : assigments, "silent" : silent, "showLector" : usr.inRole("master") } )
Example #2
0
def assigmentCount():
    """ Vrácení počtu nevyřízených zadání, použito pro aktualizaci v menu"""
    usr = getUser() 
    if (not usr) or (not usr.inRole("lector")):
        return {"status" : "error", "count" : "!"}
        
    return { "status" : "ok", "count" : Assigment.getPendingCount(usr.login) }        
Example #3
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 } )
def assigmentCount():
    """ Vrácení počtu nevyřízených zadání, použito pro aktualizaci v menu"""
    usr = getUser()
    if (not usr) or (not usr.inRole("lector")):
        return {"status": "error", "count": "!"}

    return {"status": "ok", "count": Assigment.getPendingCount(usr.login)}
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})
def list():
    """Seznam odevzdaných zadání"""

    usr = getUser()
    #todo pro mastera zobrazit všechny

    # zjistíme v jaké jsme skupině
    assigments = Assigment.getPending(usr.login)
    silent = Assigment.getSilent(usr.login)

    return template(
        "assigments_lector", {
            "assigments": assigments,
            "silent": silent,
            "showLector": usr.inRole("master")
        })
def show(lecture_id):
    """Zobrazení a odevzdávání zadání """

    usr = getUser()
    lec = Lecture.get(lecture_id)

    if not lec: return HTTPError(404, "Cvičení nebylo nalezeno")

    if not lec.isActive():
        msg("Cvičení není aktivní", "error")
        redirect("/assigments")

    assigment = Assigment.getUnique(lecture_id, usr.login)

    if not assigment:
        assigment = Assigment.create(lec.lecture_id, lec.generate(), usr.login)
        msg("Cvičení bylo vygenerováno", "success")

    if request.method == 'POST' and request.files.response:
        try:
            assigment.respond(request.files.response.file.read())
            msgTxt = "Řešení bylo úspěšně odesláno"

            if request.is_xhr:
                return HTTPResponse({
                    "type": "success",
                    "msg": msgTxt
                })
            msg(msgTxt, "success")

        except Exception as e:
            msgTxt = "Chyba při odesílání řešení - %s" % e

            if request.is_xhr:
                return HTTPResponse({
                    "type": "error",
                    "msg": msgTxt
                })

            msg(msgTxt, "error")

        redirect(request.path)

    return template("assigments_show", {
        "assigment": assigment,
        "lecture": lec
    })
Example #8
0
def lectureMenu():
    usr = getUser() 

    if usr and usr.inRole("student"):
        addMenu("/assigments","Zadání",25)
        
    if usr and usr.inRole("lector"):
        addMenu("/assigments-lector","Zadání",10, Assigment.getPendingCount(usr.login) )        
def lectureMenu():
    usr = getUser()

    if usr and usr.inRole("student"):
        addMenu("/assigments", "Zadání", 25)

    if usr and usr.inRole("lector"):
        addMenu("/assigments-lector", "Zadání", 10,
                Assigment.getPendingCount(usr.login))
Example #10
0
def show(lecture_id):
    """Zobrazení a odevzdávání zadání """
                  
    usr = getUser()
    lec = Lecture.get( lecture_id );
    
    if not lec: return HTTPError(404, "Cvičení nebylo nalezeno")

    if not lec.isActive():
        msg("Cvičení není aktivní", "error")
        redirect("/assigments");
                      
    assigment = Assigment.getUnique( lecture_id, usr.login ) 
    
    if not assigment:
        assigment = Assigment.create( lec.lecture_id, lec.generate(), usr.login )
        msg("Cvičení bylo vygenerováno", "success")
        
    if request.method == 'POST' and request.files.response:
        try:        
            assigment.respond( request.files.response.file.read() )
            msgTxt = "Řešení bylo úspěšně odesláno";

            if request.is_xhr:
                 return HTTPResponse({"type": "success", "msg": msgTxt});
            msg(msgTxt ,"success")
            
        except Exception as e:
           msgTxt = "Chyba při odesílání řešení - %s" % e 
           
           if request.is_xhr:
                 return HTTPResponse({"type": "error", "msg": msgTxt});
                 
           msg(msgTxt, "error")
        
        redirect(request.path)
            
    return template("assigments_show", {"assigment" : assigment, "lecture": lec } )    
Example #11
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)
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)