Example #1
0
File: list.py Project: akrherz/pals
def Main():
	functs.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">Intermediate Version:</font></H2>	
	"""


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

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


	functs.finishPage()
Example #2
0
File: hour.py Project: 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()
Example #3
0
File: noon.py Project: akrherz/pals
def Main(userKey, caseNum):
	form = cgi.FormContent()
	userKey, lastTime, gradeTime, startTime, noonTime, endTime, caseNum = functs.retreiveUser()

	print '<form method="POST" action="/cgi-bin/severe2/intermediate/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>'

	functs.finishPage()
	sys.exit(0)
Example #4
0
def Main():
	form = cgi.FormContent()
	try:
		caseNum = pals.formValue(form, "caseNum")
		userKey = initUser(caseNum)
	except:
		style.SendError("Case number parse error")

	userKey, lastTime, gradeTime, startTime, noonTime, endTime, caseNum = functs.retreiveUser(userKey)

	functs.setupPage("Welcome to the Severe Weather Forecasting Exercise")
	functs.printTime(startTime)
	
	functs.caseIntro(caseNum)
	
	functs.updateUser(userKey, "lasttime", startTime)
	print '<H2><img src="/icons/ball.red.gif" align="bottom"><font color="#a0522d" size="+2">Navigation:</font></H2>'
	print '<CENTER><a href="/cgi-bin/severe2/intermediate/hour.py?userKey='+str(userKey)+'""><img src="/gen/hour.php?label=Start%20Exercise&font_size=20" BORDER="0"></a></CENTER>'
	print '<BR><BR><BR>'
		
	functs.finishPage()
Example #5
0
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()
Example #6
0
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()
Example #7
0
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)