Esempio n. 1
0
	def get_html(self, answer):		
		html = "<div class=\"container\">"
		html += "<p>Use a <b>caesar</b> cipher with key " + str(self.key)  + " to encrypt the plain text.</p>"
		topArray = ["Plain text"]
		bottomArray = ["Cipher text"]
		
		#Load the Plain text into a list
		for char in self.plaintext:
			topArray.append(str(char))
			
		#Load the cipher text into the bottom array
		for char in self.ciphertext:
			bottomArray.append(str(char))
		
		#Replace hotspot positions with text boxes
		i = 0
		for pos in self.hotspots:
			if answer['answer'] == None: #DR1
				bottomArray[pos+1] = html_util.get_text('answer', '', 1) #DR2
			else:
				bottomArray[pos+1] = html_util.get_text('answer', answer['answer'][i], 1) #DR3 #DR4
				i=i+1
		
		tableArray = [topArray, bottomArray]
		
		html += html_util.get_table(tableArray, "class=\"center_table\"")

		return html + "</div>"
Esempio n. 2
0
	def get_html(self,answer):
		j = 0
		html = "<style type='text/css'>"
		html += html_util.make_css_borders(1)
		html += "</style>"
		html += "<p>Use a <b>caesar</b> cipher with key %d to encrypt the plain text.</p><center>" % self.key
		plaintext_list = [("plain text", "right")]
		for i in range(0, len(self.plaintext)):
			plaintext_list.append(("<tt>" + self.plaintext[i] + "</tt>", "left_border center")) # DR1
		ciphertext_list = [("cipher text", "top_border right")]
		for i in range(0, len(self.ciphertext)):
			if(i in self.hotspots):
				ciphertext_list.append(("<tt>" + html_util.get_text("char_%i" % j, '' if answer['char_%i' % j] is None else answer['char_%i' % j]) + "</tt>", "left_border top_border")) # DR2, DR3, DR4
				j += 1
			else:
				ciphertext_list.append(("<tt>" + self.ciphertext[i] + "</tt>", "left_border top_border")) # DR 5
		html += html_util.get_table([plaintext_list, ciphertext_list], "cellspacing=0 cellpadding=3")
		html += "</center>"	

		return html	
Esempio n. 3
0
import html_util

print '''<html>
<head><title>html_util test output</title></head>
<body>
'''

print 'default width ' + html_util.get_text('text0','0') + \
 '<p>' + \
 'explicit width ' + html_util.get_text('text1','1',10)

print '''
</body>
</html>
'''