Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
edx-platform-release
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
1
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Hsin-Yu Chien
edx-platform-release
Commits
79113756
Commit
79113756
authored
12 years ago
by
Vik Paruchuri
Browse files
Options
Downloads
Patches
Plain Diff
Add in ability to submit an image URL
parent
ac6f84ff
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
common/lib/xmodule/xmodule/open_ended_image_submission.py
+8
-3
8 additions, 3 deletions
common/lib/xmodule/xmodule/open_ended_image_submission.py
common/lib/xmodule/xmodule/openendedchild.py
+2
-1
2 additions, 1 deletion
common/lib/xmodule/xmodule/openendedchild.py
with
10 additions
and
4 deletions
common/lib/xmodule/xmodule/open_ended_image_submission.py
+
8
−
3
View file @
79113756
...
...
@@ -4,7 +4,7 @@ to send them to S3.
"""
from
PIL
import
Image
import
urlparse
from
urlparse
import
urlparse
import
requests
from
boto.s3.connection
import
S3Connection
from
boto.s3.key
import
Key
...
...
@@ -26,7 +26,8 @@ TRUSTED_IMAGE_DOMAINS = [
ALLOWABLE_IMAGE_SUFFIXES
=
[
'
jpg
'
,
'
png
'
,
'
gif
'
'
gif
'
,
'
jpeg
'
]
#Maximum allowed dimensions (x and y) for an uploaded image
...
...
@@ -132,7 +133,7 @@ class URLProperties(object):
"""
success
=
False
try
:
self
.
parsed_url
=
urlparse
.
urlparse
(
url_string
)
self
.
parsed_url
=
urlparse
(
self
.
url_string
)
success
=
True
except
:
pass
...
...
@@ -157,6 +158,10 @@ class URLProperties(object):
@return: True if URL passes tests, false if not.
"""
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
def
check_domain
(
self
):
...
...
This diff is collapsed.
Click to expand it.
common/lib/xmodule/xmodule/openendedchild.py
+
2
−
1
View file @
79113756
...
...
@@ -341,7 +341,7 @@ class OpenEndedChild(object):
success
,
get_data
[
'
student_answer
'
]
=
self
.
check_for_url_in_text
(
get_data
[
'
student_answer
'
])
overall_success
=
success
return
success
,
get_data
return
overall_
success
,
get_data
def
check_for_url_in_text
(
self
,
string
):
success
=
False
...
...
@@ -352,6 +352,7 @@ class OpenEndedChild(object):
if
not
success
:
string
=
re
.
sub
(
link
,
''
,
string
)
else
:
string
=
re
.
sub
(
link
,
self
.
generate_image_tag_from_url
(
link
,
link
),
string
)
success
=
True
return
success
,
string
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment