Beispiel #1
0
def printResults(string, answers={}):
                history = DBtransactions.parseInput(string)
                if not isinstance(history, basestring):
                        historyString = views.historyToString(history)
			historyTable = views.historyToTable(history)
                        result = DBtransactions.computeEverything(history)
			conflictOperations = views.conflictOperationsToString(result['conflictOperations'])
			readingTAs = views.readingTAsToString(result['readingTAs'])
			committedTransactions = views.transactionListToString(result['committedTAs'])
			abortedTransactions = views.transactionListToString(result['abortedTAs'])
                        graph = result['graph']
                        isSR = result['SR']
                        operationsNotRC = result['operationsNotRC']
			isRC = result['RC']
                        operationsNotACA = result['operationsNotACA']
			isACA = result['ACA']
                        operationsNotST = result['operationsNotST']
			isST = result['ST']
			
			resultString =  historyTable+views.wrapInPanel("Konfliktoperationen", conflictOperations,3)+views.wrapInPanel("Lesende Transaktionen", readingTAs, 3)+views.wrapInPanel("Committete Transaktionen", committedTransactions, 3)+views.wrapInPanel("Abortete Transaktionen", abortedTransactions, 3)+views.htmlGraph()+"<div>"+views.wrapInPanel("Eigenschaften von H := "+historyString, views.booleanPropertyToString("serialisierbar", isSR)+views.propertyToString("rücksetzbar", history, operationsNotRC)+views.propertyToString("vermeidet kaskadierendes Rücksetzen", history, operationsNotACA)+views.propertyToString("strikt", history, operationsNotST), 12)+"</div>"+printjquery(graph, history)
                	if answers:
				if answers['SR'] == isSR and  answers['RC'] == isRC and  answers['ACA'] == isACA and  answers['ST'] == isST:
					returnString = printCheckboxes(answers) + views.getMessageBox("Richtig!","thumbs-up") + resultString
				else:
					returnString = printCheckboxes(answers) + views.getMessageBox("Leider falsch!","thumbs-down")
			else:
				returnString = printCheckboxes(result) + resultString
		else:
			returnString = printCheckboxes(answers) + history
		return returnString
Beispiel #2
0
def printResults(string, answers={}):
                history = DBtransactions.parseInput(string)
                if not isinstance(history, basestring):
                        historyString = views.historyToString(history)
			historyTable = views.historyToTable(history)
                        result = DBtransactions.computeEverything(history)
			conflictOperations = views.conflictOperationsToString(result['conflictOperations'])
			readingTAs = views.readingTAsToString(result['readingTAs'])
			committedTransactions = views.transactionListToString(result['committedTAs'])
			abortedTransactions = views.transactionListToString(result['abortedTAs'])
                        graph = result['graph']
                        isSR = result['SR']
                        operationsNotRC = result['operationsNotRC']
			isRC = result['RC']
                        operationsNotACA = result['operationsNotACA']
			isACA = result['ACA']
                        operationsNotST = result['operationsNotST']
			isST = result['ST']
			
			resultString =  historyTable+views.wrapInPanel("Konfliktoperationen", conflictOperations,3)+views.wrapInPanel("Lesende Transaktionen", readingTAs, 3)+views.wrapInPanel("Committete Transaktionen", committedTransactions, 3)+views.wrapInPanel("Abortete Transaktionen", abortedTransactions, 3)+views.htmlGraph()+"<div>"+views.wrapInPanel("Eigenschaften von H := "+historyString, views.booleanPropertyToString("serialisierbar", isSR)+views.propertyToString("rücksetzbar", history, operationsNotRC)+views.propertyToString("vermeidet kaskadierendes Rücksetzen", history, operationsNotACA)+views.propertyToString("strikt", history, operationsNotST), 12)+"</div>"+printjquery(graph, history)
                	if answers:
				if answers['SR'] == isSR and  answers['RC'] == isRC and  answers['ACA'] == isACA and  answers['ST'] == isST:
					returnString = printCheckboxes(answers) + views.getMessageBox("Richtig!","thumbs-up") + resultString
				else:
					returnString = printCheckboxes(answers) + views.getMessageBox("Leider falsch!","thumbs-down")
			else:
				returnString = printCheckboxes(result) + resultString
		else:
			returnString = printCheckboxes(answers) + history
		return returnString
Beispiel #3
0
def printjquery(graph, history):
	graphJson = DBtransactions.graphToJson(graph)
	jq = """<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
		<script src="http://home.in.tum.de/~becher/static/js/cytoscape.min.js"></script>
		<script src="http://cdnjs.cloudflare.com/ajax/libs/qtip2/2.2.0/jquery.qtip.min.js"></script>
		<link href="http://cdnjs.cloudflare.com/ajax/libs/qtip2/2.2.0/jquery.qtip.min.css" rel="stylesheet" type="text/css" />
		<script src="https://cdn.rawgit.com/cytoscape/cytoscape.js-qtip/2.2.5/cytoscape-qtip.js"></script>
		
		 <script>
		$(function(){
		"""
	jq = jq + graphJson+graphStyle(history)
	return jq
Beispiel #4
0
def printjquery(graph, history):
	graphJson = DBtransactions.graphToJson(graph)
	jq = """<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
		<script src="/becher/static/js/cytoscape.min.js"></script>
		<script src="http://cdnjs.cloudflare.com/ajax/libs/qtip2/2.2.0/jquery.qtip.min.js"></script>
		<link href="http://cdnjs.cloudflare.com/ajax/libs/qtip2/2.2.0/jquery.qtip.min.css" rel="stylesheet" type="text/css" />
		<script src="https://cdn.rawgit.com/cytoscape/cytoscape.js-qtip/2.2.5/cytoscape-qtip.js"></script>
		
		 <script>
		$(function(){
		"""
	jq = jq + graphJson+graphStyle(history)
	return jq
Beispiel #5
0
def historyToTable(history):
    transactions = sorted(list(DBtransactions.involvedTransactions(history)))
    table = """<table class="table table-bordered table-striped table-hover " style="width: 100%;">
  		<thead>
    			<tr><th>#</th>"""
    for t in transactions:
        table = table + "<th>" + transactionToString(t) + "</th>"
    table = table + "</thead><tbody>"
    for step, e in enumerate(history):
        table = table + "<tr><td>" + str(step) + "</td>"
        index = transactions.index(e.transaction)
        for i in range(len(transactions)):
            table = table + "<td>"
            if i == index:
                table = table + e.toString()
            table = table + "</td>"
        table = table + "</tr>"
    table = table + "</tbody></table>"
    return wrapInPanel("Historie H", table, 12)
Beispiel #6
0
def historyToTable(history):
	transactions = sorted(list(DBtransactions.involvedTransactions(history)))
	table = """<table class="table table-bordered table-striped table-hover " style="width: 100%;">
  		<thead>
    			<tr><th>#</th>"""
	for t in transactions:
		table = table + "<th>"+transactionToString(t)+"</th>"
	table = table + "</thead><tbody>"
	for step, e in enumerate(history):
		table = table + "<tr><td>"+str(step)+"</td>"
		index = transactions.index(e.transaction)
		for i in range(len(transactions)):
			table = table + "<td>"
			if i == index:
				table = table + e.toString()
			table = table + "</td>"
		table = table + "</tr>"
	table = table + "</tbody></table>"
	return wrapInPanel("Historie H", table, 12)
Beispiel #7
0
def conflictOperationsTooltip(history):
    conflictOperations = DBtransactions.getConflictOperationsPerEdge(history)
    returnString = ""

    for id, operations in conflictOperations.iteritems():
        content = conflictOperationsToString(operations)
        returnString = returnString + """
			graph.$('#""" + id + """').qtip({
			  content: '""" + content + """',
			  position: {
			    my: 'top center',
			    at: 'bottom center'
			  },
			  style: {
			    classes: 'qtip-bootstrap',
			    tip: {
			      width: 16,
			      height: 8
			    }
			  }
			});
		"""
    return returnString
Beispiel #8
0
def conflictOperationsTooltip(history):
	conflictOperations = DBtransactions.getConflictOperationsPerEdge(history)
	returnString = ""

	for id, operations in conflictOperations.iteritems():
		content = conflictOperationsToString(operations)
		returnString = returnString + """
			graph.$('#"""+ id +"""').qtip({
			  content: '"""+ content +"""',
			  position: {
			    my: 'top center',
			    at: 'bottom center'
			  },
			  style: {
			    classes: 'qtip-bootstrap',
			    tip: {
			      width: 16,
			      height: 8
			    }
			  }
			});
		"""
	return returnString
Beispiel #9
0
			}
			else{
				$(this).removeClass().addClass("btn btn-danger");
				$('span', this).html('<span class="glyphicon glyphicon-flash" aria-hidden="true" onclick="return iconclicked('+this.id+');"></span>'+this.id);
			}
			}).change();
		</script>

		<script>
			function iconclicked(label){
				$("#"+label.id).click();
			};
		</script>
                </div>
                </div>
		"""
	return returnString

try:
	history = str(form['history'].value)
	try:
		quizButton = form['quizbutton'].value
		#quiz has been sent
		print html(history) +  printResults(history, getUserAnswers(form)) + htmlend
	except KeyError:
		#just show the results
		print html(history) + printResults(history) + htmlend
except KeyError:
	history = views.historyToString(DBtransactions.generateHistory(), False)
    	print html(history)+printCheckboxes()+htmlend
Beispiel #10
0
			}
			else{
				$(this).removeClass().addClass("btn btn-danger");
				$('span', this).html('<span class="glyphicon glyphicon-flash" aria-hidden="true" onclick="return iconclicked('+this.id+');"></span>'+this.id);
			}
			}).change();
		</script>

		<script>
			function iconclicked(label){
				$("#"+label.id).click();
			};
		</script>
                </div>
                </div>
		"""
	return returnString

try:
	history = str(form['history'].value)
	try:
		quizButton = form['quizbutton'].value
		#quiz has been sent
		print html(history) +  printResults(history, getUserAnswers(form)) + htmlend
	except KeyError:
		#just show the results
		print html(history) + printResults(history) + htmlend
except KeyError:
	history = views.historyToString(DBtransactions.generateHistory(), False)
    	print html(history)+printCheckboxes()+htmlend