Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
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
edx
edx-platform
Commits
79113756
Commit
79113756
authored
Jan 30, 2013
by
Vik Paruchuri
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add in ability to submit an image URL
parent
ac6f84ff
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
4 deletions
+10
-4
common/lib/xmodule/xmodule/open_ended_image_submission.py
+8
-3
common/lib/xmodule/xmodule/openendedchild.py
+2
-1
No files found.
common/lib/xmodule/xmodule/open_ended_image_submission.py
View file @
79113756
...
@@ -4,7 +4,7 @@ to send them to S3.
...
@@ -4,7 +4,7 @@ to send them to S3.
"""
"""
from
PIL
import
Image
from
PIL
import
Image
import
urlparse
from
urlparse
import
urlparse
import
requests
import
requests
from
boto.s3.connection
import
S3Connection
from
boto.s3.connection
import
S3Connection
from
boto.s3.key
import
Key
from
boto.s3.key
import
Key
...
@@ -26,7 +26,8 @@ TRUSTED_IMAGE_DOMAINS = [
...
@@ -26,7 +26,8 @@ TRUSTED_IMAGE_DOMAINS = [
ALLOWABLE_IMAGE_SUFFIXES
=
[
ALLOWABLE_IMAGE_SUFFIXES
=
[
'jpg'
,
'jpg'
,
'png'
,
'png'
,
'gif'
'gif'
,
'jpeg'
]
]
#Maximum allowed dimensions (x and y) for an uploaded image
#Maximum allowed dimensions (x and y) for an uploaded image
...
@@ -132,7 +133,7 @@ class URLProperties(object):
...
@@ -132,7 +133,7 @@ class URLProperties(object):
"""
"""
success
=
False
success
=
False
try
:
try
:
self
.
parsed_url
=
urlparse
.
urlparse
(
url_string
)
self
.
parsed_url
=
urlparse
(
self
.
url_string
)
success
=
True
success
=
True
except
:
except
:
pass
pass
...
@@ -157,6 +158,10 @@ class URLProperties(object):
...
@@ -157,6 +158,10 @@ class URLProperties(object):
@return: True if URL passes tests, false if not.
@return: True if URL passes tests, false if not.
"""
"""
url_is_okay
=
self
.
check_suffix
()
and
self
.
check_if_parses
()
and
self
.
check_domain
()
url_is_okay
=
self
.
check_suffix
()
and
self
.
check_if_parses
()
and
self
.
check_domain
()
log
.
debug
(
self
.
url_string
)
log
.
debug
(
"Suffix : {0}"
.
format
(
self
.
check_suffix
()))
log
.
debug
(
"Parses:{0}"
.
format
(
self
.
check_if_parses
()))
log
.
debug
(
"Check Domain:{0}"
.
format
(
self
.
check_domain
()))
return
url_is_okay
return
url_is_okay
def
check_domain
(
self
):
def
check_domain
(
self
):
...
...
common/lib/xmodule/xmodule/openendedchild.py
View file @
79113756
...
@@ -341,7 +341,7 @@ class OpenEndedChild(object):
...
@@ -341,7 +341,7 @@ class OpenEndedChild(object):
success
,
get_data
[
'student_answer'
]
=
self
.
check_for_url_in_text
(
get_data
[
'student_answer'
])
success
,
get_data
[
'student_answer'
]
=
self
.
check_for_url_in_text
(
get_data
[
'student_answer'
])
overall_success
=
success
overall_success
=
success
return
success
,
get_data
return
overall_
success
,
get_data
def
check_for_url_in_text
(
self
,
string
):
def
check_for_url_in_text
(
self
,
string
):
success
=
False
success
=
False
...
@@ -352,6 +352,7 @@ class OpenEndedChild(object):
...
@@ -352,6 +352,7 @@ class OpenEndedChild(object):
if
not
success
:
if
not
success
:
string
=
re
.
sub
(
link
,
''
,
string
)
string
=
re
.
sub
(
link
,
''
,
string
)
else
:
else
:
string
=
re
.
sub
(
link
,
self
.
generate_image_tag_from_url
(
link
,
link
),
string
)
success
=
True
success
=
True
return
success
,
string
return
success
,
string
...
...
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