UBG Admin

<% id = Request.QueryString("id") qid = Request.QueryString("qid") rank = Request.QueryString("rk") if Request.Form.Count > 0 then if qid = 0 then sqlStr = "INSERT INTO UBG_QuizQuestionsTeen (quizid, question, answer_a, answer_b, answer_c, correct, rank) VALUES (" & id & ", '" & ValidateSQL(Request.Form("question")) & "', '" &_ ValidateSQL(Request.Form("answer_a")) & "', '" & ValidateSQL(Request.Form("answer_b")) & "', '" & ValidateSQL(Request.Form("answer_c")) & "', '" & Request.Form("correct") & "', " &_ rank & ")" else sqlStr = "UPDATE UBG_QuizQuestionsTeen SET question='" & ValidateSQL(Request.Form("question")) & "', answer_a='" & ValidateSQL(Request.Form("answer_a")) & "', " &_ "answer_b='" & ValidateSQL(Request.Form("answer_b")) & "', answer_c='" & ValidateSQL(Request.Form("answer_c")) & "', correct='" & Request.Form("correct") & "' WHERE id=" & qid end if oConn.Execute sqlStr qid = "" end if select case Request.QueryString("action") case "up" if rank > 1 then oConn.Execute "UPDATE UBG_QuizQuestionsTeen SET rank=0 WHERE quizid=" & id & " AND rank=" & rank - 1 oConn.Execute "UPDATE UBG_QuizQuestionsTeen SET rank=" & rank - 1 & " WHERE quizid=" & id & " AND rank=" & rank oConn.Execute "UPDATE UBG_QuizQuestionsTeen SET rank=" & rank & " WHERE quizid=" & id & " AND rank=0" end if qid = "" case "down" oRS.Open "SELECT MAX(rank) AS maxRank FROM UBG_QuizQuestions WHERE quizid=" & id, oConn, 0, 1, 1 if oRS("maxRank") <> rank then oConn.Execute "UPDATE UBG_QuizQuestionsTeen SET rank=0 WHERE quizid=" & id & " AND rank=" & rank + 1 oConn.Execute "UPDATE UBG_QuizQuestionsTeen SET rank=" & rank + 1 & " WHERE quizid=" & id & " AND rank=" & rank oConn.Execute "UPDATE UBG_QuizQuestionsTeen SET rank=" & rank & " WHERE quizid=" & id & " AND rank=0" end if oRS.Close qid = "" case "del" oConn.Execute "DELETE FROM UBG_QuizQuestionsTeen WHERE id=" & qid & "; UPDATE UBG_QuizQuestionsTeen SET rank=rank-1 WHERE quizid=" & id & " AND rank>" & rank qid = "" end select %>
COPY
QUIZ <% if qid <> "" then if qid <> 0 then oRS.Open "SELECT question, answer_a, answer_b, answer_c, correct FROM UBG_QuizQuestionsTeen WHERE id=" & qid, oConn, 0, 1, 1 quStr = oRS("question") anaStr = oRS("answer_a") anbStr = oRS("answer_b") ancStr = oRS("answer_c") anStr = oRS("correct") oRS.Close end if %> <%end if%> <% oRS.Open "SELECT rank, id, question FROM UBG_QuizQuestionsTeen WHERE quizid=" & id & " ORDER BY rank", oConn, 0, 1, 1 do while not oRS.EOF %> <% rank = oRS("rank") oRS.MoveNext loop %>
QUIZ ADMIN - Questions
Question
Answer A checked<%end if%>>
Answer B checked<%end if%>>
Answer C checked<%end if%>>
 
 Question
<%=oRS("rank")%> <%=oRS("question")%> Up Down Delete
New question