Commit 34f8b798 authored by SANCHIT JAIN's avatar SANCHIT JAIN

"inetermediate_commit"

parent faa5b37c
......@@ -50,7 +50,7 @@
<li><a href="#contact_me">Contact Us</a></li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li><a href="#">
<li><a href="/arfa/profile">
{% block name %}
{% endblock %}
</a></li>
......@@ -98,6 +98,9 @@
Submit me
</button>
{%endblock%}
<div style="height:100%">
</div>
</body>
</html>
......@@ -75,13 +75,59 @@ def create_question(request):
args={'username':request.session['username']}
return render(request,'ARFA_app/create_question.html',args)
def view_personal_question(request):
args={'username':request.session['username']}
cursor = connection.cursor()
cursor.execute(''' SELECT s.subject,q."q_ID" as q_ID,q.question_text,q.topic,q.subtopic,q.source,
q.difficulty_set,q.image_link,q.visibility,q.ownership,o."option_Value",
o."is_Answer"
FROM "ARFA_app_question" as q,
"ARFA_app_options" as o,"ARFA_app_subject" as s
WHERE q.faculty_id = %s and s."subject_ID" = q."subject_ID_id" and q."q_ID" = o."q_ID_id"
order by s.subject,q_ID ''',[args['username']])
rows = cursor.fetchall()
print(len(rows))
columns = [col[0] for col in cursor.description]
res=[]
options_so_far = []
answer_so_far = []
preval = []
first = True
for val in rows :
if(first==True):
first=False
preval = list(val)
options_so_far.append(val[-2])
answer_so_far.append(val[-1])
else:
if not(preval[0]==val[0] and preval[1]==val[1]):
preval[-2] = options_so_far
preval[-1] = answer_so_far
preval[1] = "q"+str(preval[1])
t = dict(zip(columns, preval))
res.append(t)
options_so_far = [val[-2]]
answer_so_far = [val[-1]]
preval = list(val)
else:
options_so_far.append(val[-2])
answer_so_far.append(val[-1])
if not(first):
preval[-2] = options_so_far
preval[-1] = answer_so_far
preval[1] = "q"+str(preval[1])
t = dict(zip(columns, preval))
res.append(t)
# return res
return render(request,'ARFA_app/view_personal_question.html',res)
def view_personal_question(request):
questions=[
{
'id':"q1",
'id_drop':"dropdown"+"q1",
'text':"I am the first question",
'option':[
'q_ID':"q1",
'question_text':"I am the first question",
'option_value':[
{
'tag':"a",
'text':"I am option a for id 1"},
......@@ -91,10 +137,9 @@ def view_personal_question(request):
]
},
{
'id':"q2",
'id_drop':"dropdown"+"q2",
'text':"I am the second question",
'option':[
'q_ID':"q2",
'question_text':"I am the second question",
'option_value':[
{
'tag':"a",
'text':"I am option a for id 2"},
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment