Пример #1
0
def formQuizStart(relation, fds, mvds):
    inputString = "<div class=\"well\">Du hast folgendes eingegeben:</div>"
    if DBnormalizer.longAttributeNamesUsed():
        inputString = inputString = inputString + views.inputToString(
            relation, fds, mvds)
        inputString = inputString + "<div class=\"well\">Dass du gleich nicht so viel tippen musst, machen wir daraus mal das hier:</div>"
    DBnormalizer.resetDictionaries()
    inputString = inputString + views.inputToString(relation, fds, mvds)
    relationString = views.setOfAttributesToString(relation)
    fdsString = views.fdsToString(fds) + views.mvdsToString(mvds)
    html = """<form class="form" action="quiz.py" method="POST">"""
    html = html + "<p>Willkommen beim Quiz.</p>"
    html = html + """<input type="hidden" value="
""" + relationString + """" name="relation"></input>
		<input type="hidden" value="
""" + fdsString + """" name="fds"></input>
		<div class="row">
		<div class="col-xs-2 pull-right">
		<br/>
		<button id="step" name="step" type="submit" class="btn btn-primary" value="1">Start</button>
		</div>
		</div>
		</form>
	"""
    return views.getJumbotron("Hallo.", html) + inputString
Пример #2
0
def choosePrimaryKeys(numberOfTries, numberOfSteps, relationString, fdsString, fds, relations, targetnf = "3NF", relationnumbers=[]):
	html = """<form class="form" action="quiz.py" method="POST">
"""
	currentRelations = []
	for i, relation in enumerate(relations):
		currentRelations.append(views.setOfAttributesToString(relation))
		if relationnumbers:
			relationnumber = relationnumbers[i]
		else:
			relationnumber = i+1
		if targetnf == "3NF":
			algorithm = "Synthesealgorithmus"
			nextstep = "8"
		elif targetnf == "BCNF":
			algorithm = "Dekompositionsalgorithmus für BCNF"
			nextstep = "10"
		else:
			algorithm = "Dekompositionsalgorithmus für 4NF"
			nextstep = "10"
		html = html + "<div class=\"row\"><div class=\"col-md-2\" style=\"text-align:right;\"><br/><h4 style=\"display:inline;\">" + views.relationToString(relation, relationnumber) +" </h4></div><div class=\"col-md-2\"><input type=\"text\" class=\"form-control input-lg\" id=\"pk"+str(i)+"\" name=\"pk"+str(i)+"\"></div></div><br/>"
	currentRelationsString = ",".join(currentRelations)
	html = html + """<input type="hidden" value="
"""+relationString+"""" name="relation"></input>
		<input type="hidden" value="
"""+fdsString+"""" name="fds"></input>
		<input type="hidden" value="
"""+views.fdsToString(fds)+"""" name="currentfds"></input>
		<input type="hidden" value="
"""+currentRelationsString+"""" name="currentrelations"></input>
		<input type="hidden" value="
"""+",".join(relationnumbers)+"""" name="relationnumbers"></input>
		<input type="hidden" value="
"""+str(targetnf)+"""" name="targetnf"></input>
		<input type="hidden" value="
"""+str(numberOfTries)+"""" name="numberOfTries"></input>
		<input type="hidden" value="
"""+str(numberOfSteps)+"""" name="numberOfSteps"></input>
		<div class="row">
		<div class="col-xs-2 pull-right">
		<br/>
		<button id="step" name="step" type="submit" class="btn btn-primary" value="
"""+nextstep+"""">Weiter</button>
		</div>
		</div>
		</form>
	"""
	return views.getJumbotron(algorithm+". Primärschlüssel.", "<p>Gib für jede Relation <b>einen</b> möglichen Primärschlüssel an."+views.getHintPopover("Schreibe dazu für jede Relation die Attribute des Primärschlüssels in das zugehörige Textfeld. Um z.B. für die erste Relation den Primärschlüssel {ABCDE} hinzuzufügen, gib in das erste Textfeld ein:<br/><br/><pre>ABCDE</pre>")+"</p><p>" + html +"</p>")
Пример #3
0
def decompositionAlgorithm(numberOfTries, numberOfSteps, relationString, fdsString, relations, relationnumbers, targetnf = "BCNF"):
	currentRelations = []
	html = """<form class="form" action="quiz.py" method="POST">
		<div class="row">
		<div class="col-sm-12">
"""
	for i, r in enumerate(relations):
		currentRelations.append(views.setOfAttributesToString(r))
		html = html + "<div class=\"radio\"><label><h4 style=\"display:inline;\"><input type=\"radio\" name=\"splitrelation\" value=\""+str(i)+"\">"+views.relationToString(r, relationnumbers[i])+"</h4></label></div>"
		html = html + "<div class=\"row\"><div class=\"col-md-1\" style=\"text-align:right;\"><br/><h4 style=\"display:inline;\">R<sub>"+ relationnumbers[i].strip() +"1:=</sub></h4></div><div class=\"col-md-2\"><input type=\"text\" class=\"form-control input-lg\" id=\"first"+str(i)+"\" name=\"first"+str(i)+"\" disabled=\"disabled\"></div><div class=\"col-md-1\" style=\"text-align:right;\"><br/><h4 style=\"display:inline;\">R<sub>"+ relationnumbers[i].strip() +"2:=</sub></h4></div><div class=\"col-md-2\"><input type=\"text\" class=\"form-control input-lg\" id=\"second"+str(i)+"\" name=\"second"+str(i)+"\" disabled=\"disabled\"></div></div><br/>"
	html = html + "<div class=\"radio\"><label><h4 style=\"display:inline;\"><input type=\"radio\" name=\"splitrelation\" value=\"-1\" checked>keine Relation aufspalten</h4></label></div>"
	html = html + """<script>
			$('[name="splitrelation"]').on('change', function(){
				if($(this).prop('checked')){
					$('[id^="first"]').prop('disabled', true);
					$('[id^="second"]').prop('disabled', true);
					$('#first'+$(this).val()).prop('disabled', false);
					$('#second'+$(this).val()).prop('disabled', false);				
				}
			}).change();
		</script>"""
	currentRelationsString = ",".join(currentRelations)
	html = html + """</div>
		</div><input type="hidden" value="
"""+relationString+"""" name="relation"></input>
		<input type="hidden" value="
"""+fdsString+"""" name="fds"></input>
		<input type="hidden" value="
"""+currentRelationsString+"""" name="currentrelations"></input>
		<input type="hidden" value="
"""+",".join(relationnumbers)+"""" name="relationnumbers"></input>
		<input type="hidden" value="
"""+str(targetnf)+"""" name="targetnf"></input>
		<input type="hidden" value="
"""+str(numberOfTries)+"""" name="numberOfTries"></input>
		<input type="hidden" value="
"""+str(numberOfSteps)+"""" name="numberOfSteps"></input>
		<div class="row">
		<div class="col-xs-2 pull-right">
		<br/>
		<button id="step" name="step" type="submit" class="btn btn-primary" value="9">Weiter</button>
		</div>
		</div>
		</form>
	"""
	return views.getJumbotron("Dekompositionsalgorithmus. "+targetnf+".", "<p>Gib an, ob Relationen aufgespalten werden müssen und welche Relationen entstehen."+views.getHintPopover("Wähle zunächst die Relation aus, die du aufspalten willst, oder wähle <em>keine Relation aufspalten</em>. Wenn du eine Relation aufspalten willst, gib die Attribute der Relationen ein, die neu entstehen.")+"</p><p>" + html +"</p>")
Пример #4
0
def canonicalCoverRightReduction(numberOfTries, numberOfSteps, relationString,
                                 fdsString, fds):
    html = """<form class="form" action="quiz.py" method="POST">	
"""
    for i, fd in enumerate(fds):
        html = html + "<div class=\"row\"><div class=\"col-md-2\"><input type=\"text\" class=\"form-control input-lg\" value=\"" + views.setOfAttributesToString(
            fd[0]
        ) + "\" disabled=\"disabled\" style=\"text-align:right;\"></div><div class=\"col-md-1 text-center\" style=\"max-width:80px;\"><br/><h2 style=\"display:inline;\"><sub>-></sub></h2></div><div class=\"col-md-2\"><input type=\"text\" class=\"form-control input-lg\" id=\"fd" + str(
            i) + "\" name=\"fd" + str(
                i) + "\" value=\"" + views.setOfAttributesToString(
                    fd[1]) + "\"></div></div><br/>"
    html = html + """<input type="hidden" value="
""" + relationString + """" name="relation"></input>
		<input type="hidden" value="
""" + fdsString + """" name="fds"></input>
		<input type="hidden" value="
""" + views.fdsToString(fds) + """" name="currentfds"></input>
		<input type="hidden" value="
""" + str(numberOfTries) + """" name="numberOfTries"></input>
		<input type="hidden" value="
""" + str(numberOfSteps) + """" name="numberOfSteps"></input>
		<div class="row">
		<div class="col-xs-2 pull-left">
                <button class="btn btn-xs btn-default" type="reset"><span class="glyphicon glyphicon-repeat aria-hidden="true"></span> Eingabe zurücksetzen</button>
                </div>
		<div class="col-xs-2 pull-right">
		<br/>
		<button id="step" name="step" type="submit" class="btn btn-primary" value="3-3">Weiter</button>
		</div>
		</div>
		</form>
	"""
    return views.getJumbotron(
        "Kanonische Überdeckung. Rechtsreduktion.",
        "<p>Gib die neuen rechten Seiten der FDs an." + views.getHintPopover(
            "Um die leere Menge &empty; einzugeben, lasse das Feld einfach leer."
        ) + "</p><p>" + html + "</p>")
Пример #5
0
def formQuizStart(relation, fds, mvds):
	inputString ="<div class=\"well\">Du hast folgendes eingegeben:</div>"
	if DBnormalizer.longAttributeNamesUsed():
		inputString = inputString = inputString + views.inputToString(relation, fds,mvds)
		inputString = inputString + "<div class=\"well\">Dass du gleich nicht so viel tippen musst, machen wir daraus mal das hier:</div>"
	DBnormalizer.resetDictionaries()
	inputString = inputString +  views.inputToString(relation, fds,mvds)
	relationString = views.setOfAttributesToString(relation)
	fdsString = views.fdsToString(fds)+views.mvdsToString(mvds)
	html = """<form class="form" action="quiz.py" method="POST">"""
	html = html + "<p>Willkommen beim Quiz.</p>" 
	html = html + """<input type="hidden" value="
"""+relationString+"""" name="relation"></input>
		<input type="hidden" value="
"""+fdsString+"""" name="fds"></input>
		<div class="row">
		<div class="col-xs-2 pull-right">
		<br/>
		<button id="step" name="step" type="submit" class="btn btn-primary" value="1">Start</button>
		</div>
		</div>
		</form>
	"""
	return  views.getJumbotron("Hallo.", html ) + inputString
Пример #6
0
"""

try:
    numberOfAttributes = form['numberOfAttributes'].value
except KeyError:
    numberOfAttributes = 5
try:
    mode = form['mode'].value
    try:
        funMode = int(form['fun'].value)
    except:
        funMode = 0
    if mode == 'generateFds':
        relation, fds, mvds = DBnormalizer.generateNewProblem(
            numberOfAttributes, False, funMode)
        print html(views.setOfAttributesToString(relation),
                   views.fdsToString(fds) + views.mvdsToString(mvds),
                   numberOfAttributes,
                   funMode) + views.getAlgorithmTutorial() + htmlend
    elif mode == 'generateMvds':
        relation, fds, mvds = DBnormalizer.generateNewProblem(
            numberOfAttributes, True, funMode)
        print html(views.setOfAttributesToString(relation),
                   views.fdsToString(fds) + views.mvdsToString(mvds),
                   numberOfAttributes,
                   funMode) + views.getAlgorithmTutorial() + htmlend
    else:
        #Mode is showResults or Quiz
        relation = str(form['relation'].value)
        fds = str(form['fds'].value)
        input = "[" + relation + "][" + fds + "][" + str(
Пример #7
0
def decompositionAlgorithm(numberOfTries,
                           numberOfSteps,
                           relationString,
                           fdsString,
                           relations,
                           relationnumbers,
                           targetnf="BCNF"):
    currentRelations = []
    html = """<form class="form" action="quiz.py" method="POST">
		<div class="row">
		<div class="col-sm-12">
"""
    for i, r in enumerate(relations):
        currentRelations.append(views.setOfAttributesToString(r))
        html = html + "<div class=\"radio\"><label><h4 style=\"display:inline;\"><input type=\"radio\" name=\"splitrelation\" value=\"" + str(
            i) + "\">" + views.relationToString(
                r, relationnumbers[i]) + "</h4></label></div>"
        html = html + "<div class=\"row\"><div class=\"col-md-1\" style=\"text-align:right;\"><br/><h4 style=\"display:inline;\">R<sub>" + relationnumbers[
            i].strip(
            ) + "1:=</sub></h4></div><div class=\"col-md-2\"><input type=\"text\" class=\"form-control input-lg\" id=\"first" + str(
                i
            ) + "\" name=\"first" + str(
                i
            ) + "\" disabled=\"disabled\"></div><div class=\"col-md-1\" style=\"text-align:right;\"><br/><h4 style=\"display:inline;\">R<sub>" + relationnumbers[
                i].strip(
                ) + "2:=</sub></h4></div><div class=\"col-md-2\"><input type=\"text\" class=\"form-control input-lg\" id=\"second" + str(
                    i) + "\" name=\"second" + str(
                        i) + "\" disabled=\"disabled\"></div></div><br/>"
    html = html + "<div class=\"radio\"><label><h4 style=\"display:inline;\"><input type=\"radio\" name=\"splitrelation\" value=\"-1\" checked>keine Relation aufspalten</h4></label></div>"
    html = html + """<script>
			$('[name="splitrelation"]').on('change', function(){
				if($(this).prop('checked')){
					$('[id^="first"]').prop('disabled', true);
					$('[id^="second"]').prop('disabled', true);
					$('#first'+$(this).val()).prop('disabled', false);
					$('#second'+$(this).val()).prop('disabled', false);				
				}
			}).change();
		</script>"""
    currentRelationsString = ",".join(currentRelations)
    html = html + """</div>
		</div><input type="hidden" value="
""" + relationString + """" name="relation"></input>
		<input type="hidden" value="
""" + fdsString + """" name="fds"></input>
		<input type="hidden" value="
""" + currentRelationsString + """" name="currentrelations"></input>
		<input type="hidden" value="
""" + ",".join(relationnumbers) + """" name="relationnumbers"></input>
		<input type="hidden" value="
""" + str(targetnf) + """" name="targetnf"></input>
		<input type="hidden" value="
""" + str(numberOfTries) + """" name="numberOfTries"></input>
		<input type="hidden" value="
""" + str(numberOfSteps) + """" name="numberOfSteps"></input>
		<div class="row">
		<div class="col-xs-2 pull-right">
		<br/>
		<button id="step" name="step" type="submit" class="btn btn-primary" value="9">Weiter</button>
		</div>
		</div>
		</form>
	"""
    return views.getJumbotron(
        "Dekompositionsalgorithmus. " + targetnf + ".",
        "<p>Gib an, ob Relationen aufgespalten werden müssen und welche Relationen entstehen."
        + views.getHintPopover(
            "Wähle zunächst die Relation aus, die du aufspalten willst, oder wähle <em>keine Relation aufspalten</em>. Wenn du eine Relation aufspalten willst, gib die Attribute der Relationen ein, die neu entstehen."
        ) + "</p><p>" + html + "</p>")
Пример #8
0
def choosePrimaryKeys(numberOfTries,
                      numberOfSteps,
                      relationString,
                      fdsString,
                      fds,
                      relations,
                      targetnf="3NF",
                      relationnumbers=[]):
    html = """<form class="form" action="quiz.py" method="POST">
"""
    currentRelations = []
    for i, relation in enumerate(relations):
        currentRelations.append(views.setOfAttributesToString(relation))
        if relationnumbers:
            relationnumber = relationnumbers[i]
        else:
            relationnumber = i + 1
        if targetnf == "3NF":
            algorithm = "Synthesealgorithmus"
            nextstep = "8"
        elif targetnf == "BCNF":
            algorithm = "Dekompositionsalgorithmus für BCNF"
            nextstep = "10"
        else:
            algorithm = "Dekompositionsalgorithmus für 4NF"
            nextstep = "10"
        html = html + "<div class=\"row\"><div class=\"col-md-2\" style=\"text-align:right;\"><br/><h4 style=\"display:inline;\">" + views.relationToString(
            relation, relationnumber
        ) + " </h4></div><div class=\"col-md-2\"><input type=\"text\" class=\"form-control input-lg\" id=\"pk" + str(
            i) + "\" name=\"pk" + str(i) + "\"></div></div><br/>"
    currentRelationsString = ",".join(currentRelations)
    html = html + """<input type="hidden" value="
""" + relationString + """" name="relation"></input>
		<input type="hidden" value="
""" + fdsString + """" name="fds"></input>
		<input type="hidden" value="
""" + views.fdsToString(fds) + """" name="currentfds"></input>
		<input type="hidden" value="
""" + currentRelationsString + """" name="currentrelations"></input>
		<input type="hidden" value="
""" + ",".join(relationnumbers) + """" name="relationnumbers"></input>
		<input type="hidden" value="
""" + str(targetnf) + """" name="targetnf"></input>
		<input type="hidden" value="
""" + str(numberOfTries) + """" name="numberOfTries"></input>
		<input type="hidden" value="
""" + str(numberOfSteps) + """" name="numberOfSteps"></input>
		<div class="row">
		<div class="col-xs-2 pull-right">
		<br/>
		<button id="step" name="step" type="submit" class="btn btn-primary" value="
""" + nextstep + """">Weiter</button>
		</div>
		</div>
		</form>
	"""
    return views.getJumbotron(
        algorithm + ". Primärschlüssel.",
        "<p>Gib für jede Relation <b>einen</b> möglichen Primärschlüssel an." +
        views.getHintPopover(
            "Schreibe dazu für jede Relation die Attribute des Primärschlüssels in das zugehörige Textfeld. Um z.B. für die erste Relation den Primärschlüssel {ABCDE} hinzuzufügen, gib in das erste Textfeld ein:<br/><br/><pre>ABCDE</pre>"
        ) + "</p><p>" + html + "</p>")
Пример #9
0
def canonicalCoverLeftReduction(numberOfTries, numberOfSteps, relationString, fdsString, fds):
	html = """<form class="form" action="quiz.py" method="POST">
"""
	for i, fd in enumerate(fds):
		html = html + "<div class=\"row\"><div class=\"col-md-2\"><input type=\"text\" class=\"form-control input-lg\" id=\"fd"+str(i)+"\" name=\"fd"+str(i)+"\" value=\""+views.setOfAttributesToString(fd[0])+"\" style=\"text-align:right;\"></div><div class=\"col-md-1 text-center\" style=\"max-width:80px;\"><br/><h2 style=\"display:inline;\"><sub>-></sub></h2></div> <div class=\"col-md-2\"><input type=\"text\" class=\"form-control input-lg\" value=\""+views.setOfAttributesToString(fd[1])+"\" disabled=\"disabled\"></div></div></br>"
	html = html + """<input type="hidden" value="
"""+relationString+"""" name="relation"></input>
		<input type="hidden" value="
"""+fdsString+"""" name="fds"></input>
		<input type="hidden" value="
"""+str(numberOfTries)+"""" name="numberOfTries"></input>
		<input type="hidden" value="
"""+str(numberOfSteps)+"""" name="numberOfSteps"></input>
		<div class="row">
		<div class="col-xs-2 pull-right">
		<br/>
		<button id="step" name="step" type="submit" class="btn btn-primary" value="3-2">Weiter</button>
		</div>
		</div>
		</form>
	"""
	return views.getJumbotron("Kanonische Überdeckung. Linksreduktion.", "<p>Gib die neuen linken Seiten der FDs an."+views.getHintPopover("Um die leere Menge &empty; einzugeben, lasse das Feld einfach leer.")+"</p><p>" + html +"</p>")