def Main(): form = cgi.FormContent() userKey, lastTime, gradeTime, startTime, noonTime, endTime, caseNum = functs.retreiveUser() state = form["state"][0] if caseNum[0] == "s": etime = form["etime"][0] T, H, R = "N", "N", "N" if form.has_key("T"): T = form["T"][0] if form.has_key("H"): H = form["H"][0] if form.has_key("R"): R = form["R"][0] update = admindb.query("UPDATE users set state = '"+state+"', etime = '"+etime+"', optiona = '"+R+"', optionb = '"+H+"', optionc = '"+T+"' WHERE userKey = '"+str(userKey)+"' ") if caseNum[0] == "w": S, F, C = "N", "N", "N" if form.has_key("S"): S = form["S"][0] if form.has_key("F"): F = form["F"][0] if form.has_key("C"): C = form["C"][0] update = admindb.query("UPDATE users set state = '"+state+"', optiona = '"+S+"', optionb = '"+F+"', optionc = '"+C+"' WHERE userKey = '"+str(userKey)+"' ") print 'Content-type: text/html \n\n' print '<HTML><HEAD>' print '<meta http-equiv="Refresh" content="0; URL=/cgi-bin/severe2/intermediate/hour.py?userKey='+str(userKey)+'&noon=yes">' print '</HEAD>' print '<body></body></HTML>'
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()
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)
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()
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()
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")
def Main(): form = cgi.FormContent() userKey, lastTime, gradeTime, startTime, noonTime, endTime, caseNum = functs.retreiveUser() answers = mydb.query("SELECT * from users WHERE userKey = '"+str(userKey)+"' ").dictresult() state = answers[0]["state"] etime = answers[0]["etime"] if caseNum[0] == "s": torn_txt, hail_txt, rain_txt = "No", "No", "No" rain_guess = answers[0]["optiona"] if rain_guess == "R": rain_guess_txt = "Yes" else: rain_guess_txt = "No" hail_guess = answers[0]["optionb"] if hail_guess == "H": hail_guess_txt = "Yes" else: hail_guess_txt = "No" torn_guess = answers[0]["optionc"] if torn_guess == "T": torn_guess_txt = "Yes" else: torn_guess_txt = "No" state_pts = grade_state(state, caseNum) etime_pts = grade_time(state, etime, caseNum) torn_pts, hail_pts, rain_pts = 0,0,0 if state_pts > 0 and etime_pts > 0: torn_txt, hail_txt, rain_txt, torn_pts, hail_pts, rain_pts = grade_summer(state, torn_guess, hail_guess, rain_guess, caseNum, etime) else: snowTxt, freezeTxt, chillTxt = "No", "No", "No" snowGuessTxt = "No" freezeGuessTxt = "No" chillGuessTxt = "No" snowGuess = answers[0]["optiona"] if snowGuess == "S": snowGuessTxt = "6-12 in" elif snowGuess == "T": snowGuessTxt = "12+ in" freezeGuess = answers[0]["optionb"] if freezeGuess == "F": freezeGuessTxt = "Yes" chillGuess = answers[0]["optionc"] if chillGuess == "C": chillGuessTxt = "Yes" state_pts = grade_state(state, caseNum) snowPts, freezePts, chillPts = 0,0,0 snowTxt, freezeTxt, chillText = "No", "No", "No" if state_pts > 0: snowTxt, freezeTxt, chillTxt, snowPts, freezePts, chillPts = grade_winter(state, snowGuess, freezeGuess, chillGuess, caseNum) bonus_pts = answers[0]["bonuspoints"] results = get_results(caseNum) style.header("Forecast Exercise Results", "white") print '<TABLE WIDTH="900" ALIGN="CENTER">' print '<caption><H1>Forecast Results for Case -> '+caseNum+'</H1></caption>' print '<TR>' print '<TD valign="top">' print '<TABLE align="CENTER" bgcolor="black" cellpadding="2" border="0" width="100%">' print '<TR WIDTH="100%"><TD>' print '<TABLE bgcolor="#EEEEEE" border="0" cellpadding="2" width="100%">' print '<TR><TD><font color="blue" size="4" face="ARIAL"><B>Severe Weather Events:</B></font></TD></TR>' print '<TR><TD bgcolor="white" align="center">' list_results(results, state, caseNum) print '</TD></TR></TABLE>' print '</TD></TR></TABLE>' print '</TD>' print '<TD valign="top">' print '<TABLE align="CENTER" bgcolor="black" cellpadding="2" border="0" width="100%">' print '<TR WIDTH="100%"><TD>' print '<TABLE bgcolor="#EEEEEE" border="0" cellpadding="2" width="100%">' print '<TR><TD><font color="blue" size="4" face="ARIAL"><B>Graphical Representation:</B></font></TD></TR>' print '<TR><TD bgcolor="white" align="center">' fileRef = "/home/www/pals/html/archivewx/cases/results/"+caseNum+".gif" if os.path.isfile(fileRef): print '<img src="/archivewx/cases/results/'+caseNum+'.gif">' else: # print fileRef+" Not found<BR>" print 'Visual image for today is not available' print '</TD></TR></TABLE>' print '</TD></TR></TABLE>' print '<TABLE align="CENTER" bgcolor="black" cellpadding="2" border="0" width="100%">' print '<TR WIDTH="100%"><TD>' print '<TABLE bgcolor="#EEEEEE" border="0" cellpadding="2" width="100%">' print '<TR><TD><font color="blue" size="4" face="ARIAL"><B>Your Forecast Score:</B></font></TD></TR>' print '<TR><TD bgcolor="white" align="center">' print '<TABLE>' print '<TR><TD></TD><TH>You Predicted:</TH><TH>Actual:</TH><TH>Points:</TH></TR>' print '<TR><TH>State:</TH><TH>'+state+'</TH><TH>'+state+'</TH><TH>',state_pts,'</TH></TR>' if caseNum[0] == "s": print '<TR><TH>Time:</TH>' print '<TH>'+realtime(str(etime))+'</TH>' print '<TH>'+realtime(str(etime))+'</TH>' print '<TH>'+str(etime_pts)+'</TH></TR>' print '<TR><TH>Tornado:</TH><TH>'+torn_guess_txt+'</TH><TH>'+torn_txt+'</TH><TH>',torn_pts,'</TH></TR>' print '<TR><TH>Flash Flooding:</TH><TH>'+rain_guess_txt+'</TH><TH>'+rain_txt+'</TH><TH>',rain_pts,'</TH></TR>' print '<TR><TH>Hail:</TH><TH>'+hail_guess_txt+'</TH><TH>'+hail_txt+'</TH><TH>',hail_pts,'</TH></TR>' try: total = etime_pts + state_pts + torn_pts + rain_pts + hail_pts + int(bonus_pts) except: total = etime_pts + state_pts + torn_pts + rain_pts + hail_pts if caseNum[0] == "w": print '<TR><TH>Snowfall:</TH><TH>'+snowGuessTxt+'</TH><TH>'+snowTxt+'</TH><TH>',snowPts,'</TH></TR>' print '<TR><TH>Freezing Rain Event:</TH><TH>'+freezeGuessTxt+'</TH><TH>'+freezeTxt+'</TH><TH>',freezePts,'</TH></TR>' print '<TR><TH>Wind Chill:</TH><TH>'+chillGuessTxt+'</TH><TH>'+chillTxt+'</TH><TH>',chillPts,'</TH></TR>' try: total = state_pts + snowPts + freezePts + chillPts + int(bonus_pts) except: total = state_pts + snowPts + freezePts + chillPts print '</TABLE>' print '<BR><H3>Bonus Points (from Bonus Questions):</H3>', bonus_pts , '<BR><HR>' print '<BR><H3>Total Points:</H3>', total , '<BR>' print '</TD></TR></TABLE>' print '</TD></TR></TABLE>' print '<BR><a href="/svr_frcst/">Forecasting Exercise Homepage</a>' print '<BR><a href="/">PALS Homepage</a>' print '<BR><a href="/cgi-bin/severe2/basic/list.py">Work a new case</a>' print '</TD></TR>' print '</TABLE></BODY></HTML>' # mailresults.Main(secs, key) functs.updateUser(userKey, "userkey", "10") sys.exit(0)
def Main(userKey, caseNum, forecast_pts, bonus_pts, className): userKey, lastTime, gradeTime, startTime, noonTime, endTime, caseNum, className = functs.retreiveUser() name = advdb.query("SELECT name, email from users WHERE userKey = '"+str(userKey)+"' ").dictresult() subject = "Adv SxFrcst output for "+name[0]["name"] try: remoteHost = os.environ["REMOTE_HOST"] except: remoteHost = "NATF" nowDate = mx.DateTime.now() startDate = mx.DateTime.localtime( int(float(userKey)) ) endDate = mx.DateTime.ISO.ParseDateTimeGMT(endTime) now_date = nowDate.strftime("%x %I:%M %p") start_date = startDate.strftime("%x %I:%M %p") str_date = endDate.strftime("%x %I Z") mailstring = "**** On-Line Forecasting Exercise Results **** \n" mailstring = mailstring + "Case Number => "+caseNum+" \n" mailstring = mailstring + "Case End Date => "+str_date+" \n" mailstring = mailstring + "Student Name => "+name[0]["name"]+" \n" mailstring = mailstring + "Student Email => "+name[0]["email"]+" \n" mailstring = mailstring + "Student Started At => "+start_date+" \n" mailstring = mailstring + "Student Finished At=> "+now_date+" \n" mailstring = mailstring + "Class of Student => "+className+" \n" mailstring = mailstring + "IP of Remote Host => "+remoteHost+" \n" mailstring = mailstring + "********************************************** \n\n" mailstring = mailstring + "**** Points earned from automatic Grading **** \n" mailstring = mailstring + "Forecasting Points => "+forecast_pts+"\n" mailstring = mailstring + "Bonus Points => "+bonus_pts+"\n" mailstring = mailstring + "********************************************** \n\n" forecasts = advdb.query("SELECT etime, state, optiona, optionb, optionc, optiond from users WHERE userKey = '"+str(userKey)+"' ").getresult() mailstring = mailstring + "**** The Students Forecast **** \n" mailstring = mailstring + "Forecasted State => "+forecasts[0][1]+"\n" if caseNum[0] == 's': mailstring = mailstring + "Forecasted Time => "+forecasts[0][0]+"\n" mailstring = mailstring + "Heavy Rainfall => "+forecasts[0][2]+"\n" mailstring = mailstring + "Tornado => "+forecasts[0][3]+"\n" mailstring = mailstring + "Hail => "+forecasts[0][4]+"\n" elif caseNum[0] == 'w': mailstring = mailstring + "Six Inch Snowfall => "+forecasts[0][2]+"\n" mailstring = mailstring + "Twelve Inch Snow => "+forecasts[0][3]+"\n" mailstring = mailstring + "Freezing Rainfall => "+forecasts[0][4]+"\n" mailstring = mailstring + "Wind Chill => "+forecasts[0][5]+"\n" mailstring = mailstring + "********************************************** \n\n" sections = tmpdb.query("SELECT * from s"+str(userKey)+" ").dictresult() mailstring = mailstring + "***** Answers to individual questions ***** \n" for i in range(len(sections)): q_id = sections[i]["ticks"] question = sections[i]["question"] theirAnswer = sections[i]["answer"] correctAnswer = sections[i]["cor_answer"] theirAnswer = regsub.gsub("´", "'", theirAnswer) if len(theirAnswer) > 1 or correctAnswer == 'T': # We have a text question mailstring = mailstring +" \n Question "+q_id+": \n \t "+question+" \n \n "+name[0]["name"]+" Replied: \n \t "+theirAnswer+" \n" else: # We have a multiple choice guessOption= "option"+string.lower(theirAnswer[0][0]) answerOption = "option"+string.lower(correctAnswer[0][0]) guessTxt = advdb.query("SELECT "+guessOption+" from questions WHERE q_id = '"+q_id+"' ").getresult() if len(guessTxt) == 0: guessTxt = advdb.query("SELECT "+guessOption+" from questions_custom WHERE className = '"+className+"' and validTime = '"+q_id+"' ").getresult() answerTxt = advdb.query("SELECT "+answerOption+" from questions WHERE q_id = '"+q_id+"' ").getresult() if len(answerTxt) == 0: answerTxt = advdb.query("SELECT "+answerOption+" from questions_custom WHERE className = '"+className+"' and validTime = '"+q_id+"' ").getresult() mailstring = mailstring +" \n Question "+q_id+": \n \t "+question+" \n \n "+name[0]["name"]+" Replied: \n \t "+string.upper(theirAnswer)+". "+guessTxt[0][0]+"\n" mailstring = mailstring +"\n The Correct Answer was: \n \t "+correctAnswer[0][0]+". "+answerTxt[0][0]+" \n" mailstring = mailstring +"-------------------------------------------------------------------------------" instructorEmail =advdb.query("SELECT instructor_email from classes WHERE class_abv = '"+className+"' ").getresult()[0][0] sysstring = 'echo "' + mailstring+ '" | mail -s "'+subject+'" "'+SENDTO+'"' posix.system(sysstring) sysstring = 'echo "' + mailstring+ '" | mail -s "'+subject+'" "'+instructorEmail+'"' posix.system(sysstring)