Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
ARFA
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
ARFA
ARFA
Commits
34f8b798
Commit
34f8b798
authored
Nov 05, 2018
by
SANCHIT JAIN
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
"inetermediate_commit"
parent
faa5b37c
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
57 additions
and
9 deletions
+57
-9
ARFA/ARFA_app/templates/base.html
ARFA/ARFA_app/templates/base.html
+4
-1
ARFA/ARFA_app/views.py
ARFA/ARFA_app/views.py
+53
-8
No files found.
ARFA/ARFA_app/templates/base.html
View file @
34f8b798
...
...
@@ -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>
ARFA/ARFA_app/views.py
View file @
34f8b798
...
...
@@ -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"
},
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment