示例#1
0
文件: list.py 项目: akrherz/pals
def Main():
	style.header("Choose time and question to edit", "white")

	form = cgi.FormContent()

	print '<font color="red"><H2>Edit Answer Keys for generic questions</H2></font>'

	if form.has_key('caseNum'):
		caseNum = form["caseNum"][0]

		print '<a href="list.py">Change Current Case</a><BR><BR>'

		print '<form method="POST" action="list.py" name="switch">'
		print '</form>'
		print '<HR><HR>'

		print '<form method="POST" action="edit.py">'
		print '<input type="hidden" name="caseNum" value="'+caseNum+'">'
		print '<H3>Pick Which Question for Case '+caseNum+':</H3>'
		print_questions(caseNum[0])
	else:
		print '<form method="POST" action="list.py">'
		print '<H3>Select which case: </H3>'
		SEVERE2.listAllCases()

	print '<H3>Submit:</H3>'
	print '<input type="submit">'

	print '</form>'

	print '<BR><BR><a href="/admin">Admin Page</a>'
示例#2
0
文件: list.py 项目: akrherz/pals
def makePage(className):
	SEVERE2.setupPage("Sx Wx Forecasting Activity | Advanced Version")
	
	print """<CENTER>
	<img src="/icons/svrTop.gif">
	</CENTER>
	<blockquote>
	The Severe Weather Forecasting Exercise is a web-based exercise that is designed to stimulate interest in severe weather. This
	exercise is being developed for use by all levels of meteorologists and K-12 students as well. Because of the wide range of skills
	among users, there are three versions of the forecasting exercise.

	<P>The exercise is worked by trying one of the cases below.  The case uses archived data and prepared questions to guide the user
	thoughout the cases duration.  Currently, we have two types of cases: the "Summer-like Events" contain questions that concern summer
	like severe weather (tornado, hail, heavy rain), and the "Winter-like Events" stress winter severe weather phenonema.

	<P>The advanced version of the exercise has been designed to allow any instructor administrative control over the exercise.  Once you 
	are an administrator, you can customize the questions that appear and allow your students to work through cases that you hand select.
	The results of your students work is then emailed back to you for your review.  More information on this feature can be found 
	<a href="/svr_frcst/advInstructor.html">here.</a>

	</blockquote>
	<H2><font color="#a0522d">Advanced Version:</font></H2>
			<dd>The advanced version of the forecasting exercise contains questions that are geared to upper-level meteorology students and prodessional meteorologists.
			</dd>
		"""

	print "<H3>Summer-like Events:</H3>"
	list_cases2(className, "s")

	print "<H3>Winter-like Events:</H3>"
	list_cases2(className, "w")
	SEVERE2.finishPage("advanced", className)
	sys.exit(0)
示例#3
0
文件: index.py 项目: akrherz/pals
def Main():
	style.header("Edit Specific Questions", "white")

	print '<H2 align="center">Editing and Adding questions to Basic excercise</H2>'

	print '<B>Info:</B><HR>'
	print 'This program creates specific questions for the Basic forecasting exercise.'

	form = cgi.FormContent()
	if not form.has_key("caseNum"):
		print '<form method="POST" action="index.py">'
		print '<H3>Select Case to Edit Questions for:</H3>'
		SEVERE2.listAllCases()
		print '<BR><input type="submit" value="Select Case">'
		print '</form>'
	else:
		caseNum = form["caseNum"][0]
		print '<form method="POST" action="edit.py">'
		print '<input type="hidden" value="'+caseNum+'" name="caseNum">'
		print '<H3>Select Hour to Add/Delete/Edit Specific Question For:</H3>'
		SEVERE2.listHours(caseNum)
		print '<BR><input type="submit" value="Select Specific Time">'
		print '</form>'


	print '<P>Links outta here:'
	print '<HR>'
	print '<a href="/admin">Admin page</a>'
示例#4
0
文件: list.py 项目: akrherz/pals
def Main():
	SEVERE2.setupPage()

	form = cgi.FormContent()

	print """
	<CENTER>
	<img src="/icons/svrTop.gif">
	</CENTER>

	<dd>The Severe Weather Forecasting Exercise is a web-based exercise that is designed to stimulate interest in severe weather. This
exercise is being developed for use by all levels of meteorologists and K-12 students as well. Because of the wide range of skills
among users, there are three versions of the forecasting exercise.</dd>

	<dd>The exercise is worked by trying one of the cases below.  The case uses archived data and prepared questions to guide the user
thoughout the cases duration.  Currently, we have two types of cases: the "Summer-like Events" contain questions that concern summer
like severe weather (tornado, hail, heavy rain), and the "Winter-like Events" stress winter severe weather phenonema.</dd>

	<H2><font color="#a0522d">Basic Version:</font></H2>

	<DD>Here is a listing of available cases that can be worked though.  Please feel free to try any of them out.  They do not hurt.</dd>
	"""

	print "<H3>Summer-like Events:</H3>"
	list_cases("s")
	
	print "<H3>Winter-like Events:</H3>"
	list_cases("w")

	SEVERE2.finishPage("basic")
示例#5
0
文件: newClass.py 项目: akrherz/pals
def Main():

	SEVERE2.setupPage("Creating Class for Advanced Forecasting Exercise")


	if form.has_key("name"):
		enterForm()
	else:
		newClassForm()

	SEVERE2.finishPage()
示例#6
0
文件: list.py 项目: akrherz/pals
def Main():
	
	form = cgi.FormContent()
	if form.has_key("className"):
		className = form["className"][0]
		origPass = advdb.query("SELECT classpasswd from classes WHERE class_abv = '"+className+"' ").dictresult()[0]["classpasswd"]

		if form.has_key("classpasswd"):
			classpasswd = form["classpasswd"][0]					
			if classpasswd != origPass:
				style.SendError("The password you entered was incorrect, Try again.")
			makePage(className)
		elif origPass == "No" or form.has_key("sstr"):
			makePage(className)			

		elif origPass != "No":
			SEVERE2.setupPage("Class Authentification.")
			print '<H3>Password Required:</H3>'
			print '<P>This class requires a password, please enter it now.'
			print '<form method="POST" action="list.py">'
			print '<input type="hidden" name="className" value="'+className+'">'	
			print '<BR><B>Enter Password:</B> <input type="text" name="classpasswd">'
			print '<BR><input type="SUBMIT" value="Enter Exercise">'
			print '</form>'
			SEVERE2.finishPage("advanced")
			sys.exit(0)

		else:
			style.jump_page("first.py?className="+className+"&caseNum="+caseNum+"")

	else:
		SEVERE2.setupPage("Sx Wx Forecasting Activity | Advanced Version")
		askForClass()
		SEVERE2.finishPage("advanced")
		sys.exit(0)	
示例#7
0
文件: index.py 项目: akrherz/pals
def Main():
	SEVERE2.setupPage("ClassAdmin for Sx Forecasting Activity")

	print """
	<H3>Edit Specific Hourly Questions:</H3>
	<blockquote>
	<B>Instructions:</B> This exercise comes pre-built with a standard set of questions that get asked at various hours.  You can add your
	own questions at any hour of your choice.  These questions are then asked when students work through the exercise and the results are
	emailed back to you.
	</blockquote>
	"""

	form = cgi.FormContent()
	if not form.has_key("caseNum"):
		print '<form method="POST" action="index.py">'
		print '<H3>Select Case to Edit Questions for:</H3>'
		SEVERE2.listGoodCases()
		print '<BR><input type="submit" value="Select Case">'
		print '</form>'
	else:
		caseNum = form["caseNum"][0]
		print '<form method="POST" action="edit.py">'
		print '<input type="hidden" value="'+caseNum+'" name="caseNum">'
		print '<H3>Select Hour to Add/Delete/Edit Specific Question For:</H3>'
		SEVERE2.listHours(caseNum)
		print '<BR><input type="submit" value="Select Specific Time">'
		print '</form>'


	print '<P>Links outta here:'
	print '<HR>'
	print '<a href="../index.py">ClassAdmin</a>'
	
	SEVERE2.finishPage()
示例#8
0
文件: hourly.py 项目: akrherz/pals
def Main():
	form = cgi.FormContent()
	SEVERE2.setupPage("classAdmin for Sx Wx Forecasting")
	print """
	<H3>Edit Annotations for the Exercise.</H3>
	<blockquote>
	<B>Instructions:</B> The exercise comes pre-built with comments and annotations for each hour during the duration of each case.
	These annontations can be edited with this dialog, first select the case and then select the hour.  Your changes will imediately start
	appearing once you make the submissions.
	
	</blockquote>
	"""
	if form.has_key("caseNum"):
		print """
		<HR>
		<a href="hourly.py">Select a different Case</a><BR><HR>"""

		print '<form method="post" action="editHourly.py">'
		print '<input type="hidden" value="'+form["caseNum"][0]+'" name="caseNum">'
		SEVERE2.listHours( form["caseNum"][0] )
	else:
		print '<form method="post" action="hourly.py">'
		SEVERE2.listGoodCases()

	print '<input type="submit" value="submit">'

	print '<P>Back to <a href="../index.py">ClassAdmin Homepage</a>'

	SEVERE2.finishPage()
示例#9
0
文件: noon.py 项目: akrherz/pals
def Main(userKey, caseNum):
	form = cgi.FormContent()
	userKey, lastTime, gradeTime, startTime, noonTime, endTime, caseNum, className = functs.retreiveUser()

	print '<form method="POST" action="/cgi-bin/severe2/advanced/wrapper.py">'
	print '<input type="hidden" name="userKey" value="'+str(userKey)+'">'

	instructions()

	print """<font color="BLUE"><H2>Make Your Forecast:</H2></font>
	<font color="#a0522d"><blockquote>You are now asked to forecast a state where you believe severe weather will occur.  More 
	specifically, forecast during which time period this will occur and what type(s) of severe weather.  Your forecast will be validated at the end
	of the exercise.</blockquote></font>"""

	print '<TABLE align="CENTER" WIDTH="90%">'
	print '<TR><TH bgcolor="#EEEEEE">Select a state:</TH></TR>'
	print '<TR><TD align="center">'
	states()
	print '</TD></TR>'

        if caseNum[0] == "s":
                print '<TR><TH bgcolor="#EEEEEE">Select A Valid Time:</TH></TR>'
                print '<TR><TD align="CENTER">'
                times()
                print '</TD></TR>'

                print '<TR><TH bgcolor="#EEEEEE">Type of Severe Weather: (Check all that apply)</TH></TR>'
                print '<TR><TD align="CENTER">'
                sum_types()
                print '</TD></TR>'

        if caseNum[0] == "w":
                print '<TR><TH bgcolor="#EEEEEE">Type of Severe Weather: (Check all that apply)</TH></TR>'
                print '<TR><TD align="CENTER">'
                win_types()
                print '</TD></TR>'


        print '<TR><TH bgcolor="#EEEEEE">Submit Your Forecast:</TH></TR>'
        print '<TR><TD align="CENTER">'
        print '<input type="IMAGE" src="/gen/hour.php?label=Submit%20Forecast&font_size=20" BORDER="0">'
        print '</TD></TR>'

        print '</TABLE>'
        print '</BODY></HTML>'

	SEVERE2.finishPage("advanced", className)
	sys.exit(0)
示例#10
0
文件: hour.py 项目: akrherz/pals
def Main():
	form = cgi.FormContent()
	userKey, lastTime, gradeTime, startTime, noonTime, endTime, caseNum = functs.retreiveUser()

	if (mx.DateTime.ISO.ParseDateTimeGMT(lastTime) >= mx.DateTime.ISO.ParseDateTimeGMT(endTime)):
		results.Main()

	functs.setupPage()
	functs.printTime(lastTime)
	functs.makeHelp()
	
	# Check first if we have a question to display
	if (mx.DateTime.ISO.ParseDateTimeGMT(lastTime) > mx.DateTime.ISO.ParseDateTimeGMT(gradeTime)):
		question.Main(lastTime, userKey, caseNum, startTime)
	if (mx.DateTime.ISO.ParseDateTimeGMT(lastTime) == noonTime and not form.has_key("noon")):
		noon.Main(userKey, caseNum)
		
	
	print """<font color="#a0522d">
	<BLOCKQUOTE><P><FONT FACE="Britannic Bold">Check it out!</FONT> Click under the column titled 
	<FONT COLOR="#b0020f">Current,</FONT> and find out what is happening around the country at this hour. 
	<FONT COLOR="#b0020f" SIZE="+1">Hint</FONT>: If you need help understanding the charts, please review our help topics.</P></BLOCKQUOTE>	
	</font>	
	"""

	functs.dbComments(lastTime, "comments", "Hourly Notes:")
	
	if caseNum[0] == 'w':
		SEVERE2.makeData(lastTime, userKey, caseNum, 3)
	else:
		SEVERE2.makeData(lastTime, userKey, caseNum, 1)
		
	
	if (mx.DateTime.ISO.ParseDateTimeGMT(lastTime) > noonTime):
		functs.dbComments(lastTime, "analysis", "Analysis:")
	
	if caseNum[0] == 's' and (mx.DateTime.ISO.ParseDateTimeGMT(lastTime) > noonTime) :
		nextTime = mx.DateTime.ISO.ParseDateTimeGMT(lastTime) + mx.DateTime.RelativeDateTime(hours=+2)	
	elif caseNum[0] == 's':
		nextTime = mx.DateTime.ISO.ParseDateTimeGMT(lastTime) + mx.DateTime.RelativeDateTime(hours=+1)	
	else:
		nextTime = mx.DateTime.ISO.ParseDateTimeGMT(lastTime) + mx.DateTime.RelativeDateTime(hours=+3)
		
	functs.updateUser(userKey, "lasttime", nextTime)

	navigation(userKey)
	
	functs.finishPage()
示例#11
0
def Main():
	form = cgi.FormContent()
	try:
		caseNum = form["caseNum"][0]
		zticks = form["zticks"][0]
	except:
		style.SendError("CGI Parse Error")

	entry  = get_entry(caseNum,  float( zticks ) )

	try:
		comment = entry[0]["comments"]
	except IndexError:
		comment = "Write Something here"
	try:
		analysis = entry[0]["analysis"]
	except IndexError: 
                analysis = "Write Something here"

	localTuple = time.localtime( float(zticks) )
	nowStr = time.strftime("%b %d, %Y -- %HZ", localTuple)

	SEVERE2.setupPage("classAdmin for Sx Wx Activity")
	print '<H3 align="center">Edit annotation for '+nowStr+'</H3>'
	print """
	<HR>
		<a href="hourly.py">Select a different Case</a><BR>"""
	print '<a href="hourly.py?caseNum='+caseNum+'">Select a different Hour for this Case</a><BR><HR>'

        print '<form method="post" action="addHourly.py">'
	print '<input type="hidden" name="zticks" value="'+str(int(zticks))+'">'
	print '<input type="hidden" name="caseNum" value="'+str(caseNum)+'">'
	adds(comment, analysis)
	print '<BR><input type="submit" value="Click to Save this Entry">'
	print '</form>'

	print '<P><a href="../index.py">Back to ClassAdmin</a>'

	SEVERE2.finishPage()	
示例#12
0
文件: sxpage.py 项目: akrherz/pals
def Main():
	form = cgi.FormContent()
	try:
		year = int(form["year"][0])
		day = int(form["day"][0])
		month = int(form["month"][0])
		ztime = int(form["ztime"][0])
		version = form["version"][0]
		zswitch = form["zswitch"][0]
	except:
		style.SendError("Bzz, give me a date please...")

	myDate = DateTime.mktime(year, month, day, ztime, 0, 0, '','','0')
	secs = myDate.ticks()
	time_tuple = myDate.tuple()
	myDateStr = DateTime.ISO.strGMT(myDate)

	SEVERE2.setupPage()
        SEVERE2.printTime(myDateStr)

	dir_format = myDate.strftime("/archivewx/data/%Y_%m_%d/")
	print '<BASE HREF="http://www.pals.iastate.edu'+dir_format+'">'

	if version == "basic":
	        functs.dbComments(myDateStr, "comments", "News and Notes:", zswitch)
	else:
	        functs.db_comments_417(secs, time_tuple, "comments", "News and Notes:", "mt417")


        functs.mk_data(time_tuple, 1)

	if version == "basic":
	        functs.dbComments(myDateStr, "analysis", "Meteorological Analysis:", zswitch)
	else:
	        functs.db_comments_417(secs, time_tuple, "analysis", "Meteorological Analysis:", "mt417")
	

	functs.finishPage()
示例#13
0
文件: release.py 项目: akrherz/pals
def Main():
	if form.has_key("type"):
		caseNum = form["caseNum"][0]
		type = form["type"][0]
		if type == "add":
			delete = mydb.query("DELETE from basiccases WHERE caseNum = '"+caseNum+"' ")
			hello = mydb.query("INSERT into basiccases VALUES ('"+caseNum+"')")
		else:
			hello = mydb.query("DELETE from basiccases WHERE caseNum = '"+caseNum+"' ")


	print 'Content-type: text/html \n\n'

	print '<H3 align="CENTER">Pick A Case</H3>'

	print '<P>Release or remove cases to your hearts content.'

	print '<TABLE WIDTH="100%"><TR><TD>'
	print '<H3>Cases available</H3>'
	print '<FORM name="add" METHOD="POST" ACTION="release.py">'
	print '<input type="hidden" name="type" value="add">'
	SEVERE2.listAllCases()
	print '<input type="submit" value="Add This Case">'
	print '</form><BR>'

	print '</TD><TD>'
	
	print '<H3>Cases allready released</H3>'
	print '<FORM name="del" METHOD="POST" ACTION="release.py">'
	print '<input type="hidden" name="type" value="del">'
	list_cases2()
	print '<input type="submit" value="Delete This Case">'
	print '</form><BR>'

	print '</TD></TR></TABLE>'

	print '<HR><a href="/admin/index.html">Back to Admin Page</a>'
示例#14
0
文件: release.py 项目: akrherz/pals
def Main():
	if form.has_key("type"):
		caseNum = form["caseNum"][0]
		type = form["type"][0]
		if type == "add":
			delete = mydb2.query("DELETE from basecases_custom WHERE caseNum = '"+caseNum+"' and className = '"+className+"' ")
			hello = mydb2.query("INSERT into basecases_custom(casenum, className) VALUES ('"+caseNum+"', '"+className+"')")
		else:
			hello = mydb2.query("DELETE from basecases_custom WHERE caseNum = '"+caseNum+"' and className = '"+className+"' ")


	SEVERE2.setupPage("Add/Revoke Cases to the System.")

	print """
	<blockquote>
	<B>Instructions:</B> This dialog releases and revokes which cases your students can work with.  When your students access the
	main page, they are presented with a listing of cases that you have released to them to work.  That listing is controled from 
	this dialog.  Removing or adding cases DOES NOT delete any work done on the specific questions nor the comments.
	</blockquote>
	"""

	print '<H3 align="CENTER">Pick A Case</H3>'

	print '<P>Release or remove cases to your hearts content.'

	print '<TABLE WIDTH="100%"><TR><TD>'
	print '<H3>Cases available</H3>'
	print '<FORM name="add" METHOD="POST" ACTION="release.py">'
	print '<input type="hidden" name="type" value="add">'
	print '<input type="hidden" name="className" value="'+className+'">'
	SEVERE2.listGoodCases()
	print '<input type="submit" value="Add This Case">'
	print '</form><BR>'

	print '</TD><TD>'
	
	print '<H3>Cases allready released</H3>'
	print '<FORM name="del" METHOD="POST" ACTION="release.py">'
	print '<input type="hidden" name="className" value="'+className+'">'
	print '<input type="hidden" name="type" value="del">'
	list_cases2(className)
	print '<input type="submit" value="Delete This Case">'
	print '</form><BR>'

	print '</TD></TR></TABLE>'

	print '<a href="../index.py">ClassAdmin Homepage</a>'

	SEVERE2.finishPage()
示例#15
0
文件: first.py 项目: akrherz/pals
def Main():
	form = cgi.FormContent()
	if not form.has_key("caseNum"):
		style.SendError("No case number was supplied to this script")
	if not form.has_key("className"):
		style.SendError("No class name specified")

	caseNum = form["caseNum"][0]  
	className = form["className"][0]

	userKey = mk_new_entry()

	SEVERE2.setupPage("Welcome to the Severe Weather Forecasting Activity")

	if form.has_key("test"):
		print """
		You may proceed through this exercise as a guest of this system.  Your answers will not be emailed to anybody.<BR>
		<BR>You may want to choose to not answer any of the specific questions that pop up during the exercise.  This helps to
		speed up the exercise quite a bit.  You will still be asked the questions about where you believe severe weather to occur.
		<BR><BR>
		<form method="POST" action="index.py">
		<input name="answerQs" value="True" CHECKED  type="radio">Answer Questions<BR>
		<input name="answerQs" value="False" type="radio">No questions please<BR>
		"""
		print '<INPUT type="hidden" value="'+className+'" name="className">'
		print '<INPUT type="hidden" value="'+caseNum+'" name="caseNum">'
		print '<INPUT type="hidden" value="'+str(userKey)+'" name="userKey">'
		print '<INPUT type="hidden" value="*****@*****.**" name="email">'
		print '<INPUT type="hidden" value="NOB" name="name">'

		print """
		<BR><input type="SUBMIT" value="Let's Start!!">
		</form>"""

		SEVERE2.finishPage("advanced", className)
		sys.exit(0)
	
	ask_for_info(caseNum, userKey, className)

	SEVERE2.finishPage("advanced", className)
示例#16
0
文件: index.py 项目: akrherz/pals
def Main():
	form = cgi.FormContent()
	if not form.has_key("email"): style.SendError("Please go back and enter your email address")
	email = form["email"][0]

	if not form.has_key("name"): style.SendError("Please go back and enter your name")
	name = form["name"][0]

	answerQs = form["answerQs"][0]
	userKey = form["userKey"][0]
	caseNum = form["caseNum"][0]
	className = form["className"][0]

	query = basedb.query("SELECT startTime from cases WHERE casenum = '"+caseNum+"' ").dictresult()
	startTime = query[0]["starttime"]

	update_db(userKey, name, email, className, startTime, answerQs, caseNum)

	SEVERE2.setupPage("Sx Wx Forecasting Exercise | Advanced Version")
	SEVERE2.printTime( startTime )

#	svrFrcst.svrTop(start_tuple, start_secs)


	print """
	This is a forecasting exercise for forecasting severe weather. You will be given hourly data for 6 hours and then asked to make some
decisions on where you believe severe weather will occur.  Then you will be guided  through the rest of the case and then given the results at the
end.  During this exercise, you may be asked  other case specific questions about the data that you are seeing.  Make sure to look at the maps, and
good luck!
	<BR><BR>"""

	svrFrcst.printIntro(caseNum, className)

	print '<CENTER>'
	cgiValues = 'userKey='+str(userKey)
	print '<a href="/cgi-bin/severe2/advanced/hour.py?'+cgiValues+'"><img src="/gen/hour.php?label=Click%20To%20Start&font_size=25" border="0"></a>'
	print '</CENTER>'
	SEVERE2.finishPage("advanced")
示例#17
0
文件: answer.py 项目: akrherz/pals
def Main():
    form = cgi.FormContent()
    userKey, lastTime, gradeTime, startTime, noonTime, endTime, caseNum = functs.retreiveUser()

    functs.setupPage()
    functs.printTime(lastTime)
    functs.makeHelp()

    bonus_pts = 0
    pause_page = 1
    i = 0

    for quest in qs:
        i = i + 1
        if form.has_key(quest):
            if form.has_key(quest + "text"):
                donothing = 1
            else:
                try:
                    this_option = form[quest + "option"][0]
                except:
                    style.SendError("You need to answer Question number " + str(i) + ", go back")

    print """<font color="#a0522d">
	<BLOCKQUOTE><P>Listed below is the answer for the question that you just answered.  Feel free to review the weather
	data up till this point, if you missed this question. Otherwise, continue on with the exercise.</P></BLOCKQUOTE></font>
	"""

    print '<H2 align="CENTER">Question Response</H2>'
    i = 0
    for quest in qs:
        i = i + 1
        if form.has_key(quest):
            q_id = form[quest][0]

            this_option = form[quest + "option"][0]
            intval = form["intval"][0]

            try:
                this_answer = mydb.query(
                    "SELECT answer from intanswers WHERE intval = '" + intval + "' and casenum = '" + caseNum + "' "
                ).getresult()
                option_wanted = "option" + this_answer[0][0]
                if option_wanted == "optionN":
                    option_wanted = "nooption"
                ans_txt = mydb.query(
                    "SELECT " + option_wanted + " from intquestions WHERE intval = '" + intval + "' "
                ).getresult()
                comments = mydb.query(
                    "SELECT correct, wrong from intanswers WHERE intval =  '"
                    + intval
                    + "' and caseNum = '"
                    + caseNum
                    + "' "
                ).getresult()
                this_answer = this_answer[0][0]
                if string.lower(this_answer) == string.lower(this_option):  # Take care of sloppy db entry routines :)
                    print "<H3>You answered <font color='red'>correctly</font> for question " + str(i) + ":</H3>"
                    print "<P><B><i>The Correct answer was =></i> " + this_answer + ". " + ans_txt[0][0] + "</B>"

                    print "<BR><BR clear='all'>"
                    print comments[0][0]
                    print "<BR clear='all'>"
                    bonus_pts = bonus_pts + 10
                    pointsReceived = 10
                elif option_wanted == "nooption":
                    bonus_pts = bonus_pts + 10
                    pointsReceived = 10
                else:
                    print "<H3>You answered <font color='red'>incorrectly</font> for question " + str(i) + ":</H3>"
                    print "<P><B><i>The Correct answer was =></i> " + this_answer + ". " + ans_txt[0][0] + "</B>"

                    print "<BR><BR clear='all'>"
                    print comments[0][1]
                    print "<BR clear='all'>"
                    pointsReceived = 0

                print "<P>Bonus Points Received:" + str(pointsReceived)
            except:

                print "An error occurred trying to find the answer for this question..."

            print "<HR>"

    print '<CENTER><a href="/cgi-bin/severe2/intermediate/hour.py?userKey=' + userKey + '">'
    print '<img src="/gen/button.php?label=Click%20To%20Continue&font_size=30" BORDER="0"></a></CENTER>'

    if caseNum[0] == "w":
        SEVERE2.makeData(lastTime, userKey, caseNum, 3)
    else:
        SEVERE2.makeData(lastTime, userKey, caseNum, 1)

    update_time(userKey, bonus_pts, lastTime)
    functs.updateUser(userKey, "gradeTime", lastTime)

    functs.finishPage()
示例#18
0
文件: question.py 项目: akrherz/pals
def Main(lastTime, userKey, caseNum, startTime):

	# First, decide what the interval value should be...	
	hours = mydb.query("SELECT date_part('hour', age(lastTime, '"+startTime+"')), \
		date_part('day', age(lastTime, '"+startTime+"')) from users WHERE userKey = "+str(userKey)+" ").getresult()

	hourVal = int( hours[0][0] )
	dayVal = int( hours[0][1] )
	if (dayVal > 0 ):
		hourVal = 24+hourVal

	# This is the value of the question in the db to look for
	intval = caseNum[0]+str( hourVal )

	questions = mydb.query("SELECT question, type, optiona, optionb, optionc, optiond, optione, optionf, optiong, optionh  from intquestions WHERE intval = '"+intval+"' ").dictresult()
	
	try:
		# If we do not find any questions, update the gradeTime and return
		if len(questions[0]) == 0:
			functs.updateUser(userKey,'gradetime', lastTime)
			return 1
	except:
		functs.updateUser(userKey,'gradetime', lastTime)
		return 1

	print '<H1 align="CENTER">Bonus Question!</H1>'

	print """<font color="#a0522d">
	<blockquote>You are now asked to answer the questions below.  Use the available weather maps and your 
	knowledge of this case so far to answer the questions below...</blockquote></font><BR><BR>"""
	

	print '<form method="POST" action="/cgi-bin/severe2/intermediate/answer.py">'
	print '<input type="hidden" name="userKey" value="'+str(userKey)+'">'
	print '<input type="hidden" name="intval" value="'+intval+'">'
	

	# For each question, loop 
	for i in range(len(questions)):
		
		type = questions[i]["type"]
		if type == "T":
			make_text_q(questions[i], str(i))
		else:
			make_other(questions[i], str(i))
		


	print """
		<input type="submit" value="Submit my answers">
		<input type="reset"></form><BR><BR>"""

	if caseNum[0] == 'w':
		SEVERE2.makeData(lastTime, userKey, caseNum, 3)
	else:
		SEVERE2.makeData(lastTime, userKey, caseNum, 1)
		
	functs.finishPage()

	
	sys.exit(0)
示例#19
0
文件: answer.py 项目: akrherz/pals
def Main():
	form = cgi.FormContent()
	userKey, lastTime, gradeTime, startTime, noonTime, endTime, caseNum, className = functs.retreiveUser()
	
	bonus_pts = int( advdb.query("SELECT bonuspoints from users WHERE userKey = '"+userKey+"' ").getresult()[0][0] )
	pause_page = 1
	i = 0
	
	for quest in qs:
		i = i + 1
		if form.has_key(quest):
			if form.has_key(quest+"txt"):
				donothing = 1
			else:
				try:
					this_option = form[quest+"option"][0]
				except:
					style.SendError("You need to answer Question number "+str(i)+", go back")			

	SEVERE2.setupPage()
	SEVERE2.printTime(lastTime)


	print '<H2 align="CENTER">Question Response</H2>'
	i = 0
	for quest in qs:
		i = i + 1
		if form.has_key(quest):
			q_id = form[quest+"q_id"][0]
			if form.has_key(quest+"text"):			# We have a text question
				textAns = form[quest+"text"][0]
				textAns = functs.clean_str(textAns)
				print '<HR><font color="blue">Question '+str(i)+':</font><BR>'  
				if len(q_id) < 5:
					question = advdb.query("SELECT question from questions WHERE q_id = '"+q_id+"' ").getresult()[0][0]
				else:
					question = advdb.query("SELECT question from questions_custom WHERE validTime = '"+q_id+"' ").getresult()[0][0]
				enter_text(userKey, textAns, 'T', q_id, '0', question)
				print 'Your Text response was entered and will be sent to your instructor..<HR>'
			else:
				print '<HR><font color="blue">Question '+str(i)+':</font><BR>'
				pause_page = 0
				this_option = string.lower( form[quest+"option"][0] )
				optionName = "option"+this_option
				if optionName == "optionyes":
					print "<H3> Did you forget to answer one of the questions? Go back and answer it!</H3>"
					SEVERE2.finishPage()
					sys.exit(0)
				

				if len(q_id) > 5: # We have a custom question
					thisQuery = advdb.query("SELECT question, answer, "+optionName+", correct, wrong from questions_custom WHERE validTime = '"+q_id+"' and className = '"+className+"' ").dictresult()
					thisQuestion = thisQuery[0]["question"]
					thisAnswer = thisQuery[0]["answer"]
					thisOptionText = thisQuery[0][optionName]
					thisCorrect = thisQuery[0]["correct"]
					thisWrong = thisQuery[0]["wrong"]
															
				else:	# We must have a standard Question 
					thisQuery = advdb.query("SELECT question, "+optionName+" from questions WHERE q_id = '"+q_id+"' ").dictresult()
					thisQuestion = thisQuery[0]["question"]
					thisOptionText = thisQuery[0][optionName]

					thisQuery = advdb.query("SELECT answer, correct, wrong from answers WHERE q_id = '"+q_id+"' and caseNum = '"+caseNum+"' ").dictresult()
					if len(thisQuery) == 0:
						print 'This question '+q_id+' for case num '+case_num+' needs to be answered yet<BR>'
						thisAnswer = "NA"
					
						thisAnswer = thisQuery[0]["answer"]
						thisCorrect = thisQuery[0]["correct"]
						thisWrong = thisQuery[0]["wrong"]
					else:
						thisAnswer = thisQuery[0]["answer"]
						thisCorrect = thisQuery[0]["correct"]
						thisWrong = thisQuery[0]["wrong"]				
			
				if thisAnswer == "NA":
					print " "
				else:
					if len(q_id) > 5: # We have a custom question
						thisAnswerText = advdb.query("SELECT option"+thisAnswer+" from questions_custom WHERE validTime = '"+q_id+"' and className = '"+className+"' ").getresult()[0][0]

					else:
						thisAnswerText = advdb.query("SELECT option"+thisAnswer+" from questions WHERE q_id = '"+q_id+"' ").getresult()[0][0]

					if string.lower(thisAnswer) == string.lower(this_option): 	# Take care of sloppy db entry routines :)
						print "<H3>You answered Correctly:</H3>"
						print "<P><B><i>You were asked =></i></b> "+thisQuestion
						print "<P><B><i>You responded =></i></b> "+string.upper(this_option)+". "+thisOptionText
						print "<P><B><i>The Correct answer was =></i></b> "+thisAnswer+". "+thisAnswerText
						print "<P><B><i>The instructor's response =></i></b>" +thisCorrect
						bonus_pts = bonus_pts + 10
					else:
						print "<H3>You answered Incorrectly:</H3>"
						print "<P><B><i>You were asked =></i></b> "+thisQuestion
						print "<P><B><i>You responded =></i></b> "+string.upper(this_option)+". "+thisOptionText
						print "<P><B><i>The Correct answer was =></i></b> "+thisAnswer+". "+thisAnswerText
						print "<P><B><i>The instructor's response =></i></b>" +thisWrong
				
				enter_text(userKey, this_option, thisAnswer, q_id, bonus_pts, thisQuestion )
				print "<HR>"
					

	functs.updateUser(userKey, "gradeTime", lastTime)
	
	functs.updateUser(userKey, "bonuspoints", bonus_pts)

	
	if (pause_page):
		print '<P align="right"><a href="/cgi-bin/severe2/advanced/hour.py?userKey='+userKey+'">'
		print '<img src="/gen/button.php?label=Click%20To%20Continue&font_size=30" BORDER="0"></a>'
		SEVERE2.finishPage("advanced")
		sys.exit(0)

	print '<CENTER>'
	print '<P><a href="/cgi-bin/severe2/advanced/hour.py?userKey='+userKey+'">'
	print '<img src="/gen/button.php?label=Click%20To%20Continue&font_size=30" BORDER="0"></a>'
	print '</CENTER>'

	if caseNum[0] == 'w':
		SEVERE2.makeData(lastTime, userKey, caseNum, 3)
	else:
		SEVERE2.makeData(lastTime, userKey, caseNum, 1)

	SEVERE2.finishPage("advanced")
示例#20
0
文件: functs.py 项目: akrherz/pals
def setupPage(title="Severe Wx Forecasting Exercise"):
    SEVERE2.setupPage(title)
示例#21
0
文件: functs.py 项目: akrherz/pals
def printTime(thisDate=0):
    SEVERE2.printTime(thisDate)
示例#22
0
文件: functs.py 项目: akrherz/pals
def finishPage():
    SEVERE2.finishPage("intermediate")
示例#23
0
文件: functs.py 项目: akrherz/pals
def makeHelp():
    SEVERE2.makeHelp()