Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
problem-builder
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
problem-builder
Commits
426b44e9
Commit
426b44e9
authored
Dec 12, 2016
by
Matjaz Gregoric
Committed by
GitHub
Dec 12, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #136 from open-craft/mtyaka/extended-course-key-2
Use django Q objects instead of raw SQL query
parents
c1db1116
e502a556
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
8 additions
and
12 deletions
+8
-12
circle.yml
+1
-1
problem_builder/answer.py
+6
-10
setup.py
+1
-1
No files found.
circle.yml
View file @
426b44e9
...
...
@@ -11,7 +11,7 @@ dependencies:
-
"
pip
install
-r
requirements.txt"
-
"
pip
install
-r
$VIRTUAL_ENV/src/xblock-sdk/requirements/base.txt"
-
"
pip
install
-r
$VIRTUAL_ENV/src/xblock-sdk/requirements/test.txt"
-
"
pip
uninstall
-y
xblock-problem-builder
&&
python
setup.py
sdist
&&
pip
install
dist/xblock-problem-builder-2.6.
4
.tar.gz"
-
"
pip
uninstall
-y
xblock-problem-builder
&&
python
setup.py
sdist
&&
pip
install
dist/xblock-problem-builder-2.6.
5
.tar.gz"
-
"
pip
install
-r
test_requirements.txt"
-
"
mkdir
var"
test
:
...
...
problem_builder/answer.py
View file @
426b44e9
...
...
@@ -25,6 +25,7 @@ from lazy import lazy
from
django.core.exceptions
import
ValidationError
from
django.db
import
IntegrityError
from
django.db.models
import
Q
from
django.utils.crypto
import
get_random_string
from
.models
import
Answer
...
...
@@ -70,16 +71,11 @@ class AnswerMixin(XBlockWithPreviewMixin, XBlockWithTranslationServiceMixin):
@staticmethod
def
_fetch_model_object
(
name
,
student_id
,
course_id
):
sql_query
=
'''SELECT * FROM problem_builder_answer
WHERE name =
%
s
AND student_id =
%
s
AND (course_key =
%
s
OR course_id =
%
s)'''
params
=
[
name
,
student_id
,
course_id
,
course_id
]
try
:
answer
=
Answer
.
objects
.
raw
(
sql_query
,
params
)[
0
]
except
IndexError
:
raise
Answer
.
DoesNotExist
()
answer
=
Answer
.
objects
.
get
(
Q
(
name
=
name
),
Q
(
student_id
=
student_id
),
Q
(
course_key
=
course_id
)
|
Q
(
course_id
=
course_id
)
)
if
not
answer
.
course_key
:
answer
.
course_key
=
answer
.
course_id
return
answer
...
...
setup.py
View file @
426b44e9
...
...
@@ -71,7 +71,7 @@ BLOCKS = [
setup
(
name
=
'xblock-problem-builder'
,
version
=
'2.6.
4
'
,
version
=
'2.6.
5
'
,
description
=
'XBlock - Problem Builder'
,
packages
=
[
'problem_builder'
,
'problem_builder.v1'
],
install_requires
=
[
...
...
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