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
27848337
Commit
27848337
authored
Jul 31, 2012
by
Brittany Cheng
Browse files
Options
Browse Files
Download
Plain Diff
fix merge conflicts
parents
6285f2a2
ada66adf
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
152 additions
and
55 deletions
+152
-55
cms/djangoapps/contentstore/__init__.py
+0
-0
common/lib/capa/capa/inputtypes.py
+1
-1
common/lib/capa/capa/responsetypes.py
+16
-10
common/lib/capa/capa/templates/textbox.html
+2
-1
common/lib/xmodule/xmodule/capa_module.py
+1
-1
lms/djangoapps/django_comment_client/base/views.py
+7
-9
lms/djangoapps/django_comment_client/utils.py
+4
-2
lms/static/coffee/src/customwmd.coffee
+3
-1
lms/static/coffee/src/discussion.coffee
+101
-21
lms/static/sass/_discussion.scss
+10
-4
lms/templates/discussion/inline.html
+3
-3
lms/templates/discussion/thread.html
+4
-2
No files found.
cms/djangoapps/contentstore/__init__.py
0 → 100644
View file @
27848337
common/lib/capa/capa/inputtypes.py
View file @
27848337
...
...
@@ -315,7 +315,7 @@ def textbox(element, value, status, render_template, msg=''):
cols
=
element
.
get
(
'cols'
)
or
'80'
mode
=
element
.
get
(
'mode'
)
or
'python'
# mode for CodeMirror, eg "python" or "xml"
hidden
=
element
.
get
(
'hidden'
,
''
)
# if specified, then textline is hidden and id is stored in div of name given by hidden
linenumbers
=
element
.
get
(
'linenumbers'
)
# for CodeMirror
linenumbers
=
element
.
get
(
'linenumbers'
,
'true'
)
# for CodeMirror
if
not
value
:
value
=
element
.
text
# if no student input yet, then use the default input given by the problem
context
=
{
'id'
:
eid
,
'value'
:
value
,
'state'
:
status
,
'count'
:
count
,
'size'
:
size
,
'msg'
:
msg
,
'mode'
:
mode
,
'linenumbers'
:
linenumbers
,
...
...
common/lib/capa/capa/responsetypes.py
View file @
27848337
...
...
@@ -810,7 +810,8 @@ class CodeResponse(LoncapaResponse):
def
setup_response
(
self
):
xml
=
self
.
xml
self
.
url
=
xml
.
get
(
'url'
,
"http://ec2-50-16-59-149.compute-1.amazonaws.com/xqueue/submit/"
)
# FIXME -- hardcoded url
self
.
url
=
xml
.
get
(
'url'
,
"http://107.20.215.194/xqueue/submit/"
)
# FIXME -- hardcoded url
self
.
queue_name
=
xml
.
get
(
'queuename'
,
'python'
)
# TODO: Default queue_name should be course-specific
answer
=
xml
.
find
(
'answer'
)
if
answer
is
not
None
:
...
...
@@ -848,13 +849,13 @@ class CodeResponse(LoncapaResponse):
def
get_score
(
self
,
student_answers
):
try
:
submission
=
[
student_answers
[
self
.
answer_id
]
]
submission
=
student_answers
[
self
.
answer_id
]
except
Exception
as
err
:
log
.
error
(
'Error in CodeResponse
%
s: cannot get student answer for
%
s; student_answers=
%
s'
%
(
err
,
self
.
answer_id
,
student_answers
))
raise
Exception
(
err
)
self
.
context
.
update
({
'submission'
:
submission
})
extra_payload
=
{
'edX_student_response'
:
json
.
dumps
(
submission
)
}
extra_payload
=
{
'edX_student_response'
:
submission
}
r
,
queuekey
=
self
.
_send_to_queue
(
extra_payload
)
# TODO: Perform checks on the xqueue response
...
...
@@ -904,7 +905,9 @@ class CodeResponse(LoncapaResponse):
def
_send_to_queue
(
self
,
extra_payload
):
# Prepare payload
xmlstr
=
etree
.
tostring
(
self
.
xml
,
pretty_print
=
True
)
header
=
{
'return_url'
:
self
.
system
.
xqueue_callback_url
}
header
=
{
'return_url'
:
self
.
system
.
xqueue_callback_url
,
'queue_name'
:
self
.
queue_name
,
}
# Queuekey generation
h
=
hashlib
.
md5
()
...
...
@@ -913,13 +916,16 @@ class CodeResponse(LoncapaResponse):
queuekey
=
int
(
h
.
hexdigest
(),
16
)
header
.
update
({
'queuekey'
:
queuekey
})
payload
=
{
'xqueue_header'
:
json
.
dumps
(
header
),
# TODO: 'xqueue_header' should eventually be derived from a config file
'xml'
:
xmlstr
,
'edX_cmd'
:
'get_score'
,
'edX_tests'
:
self
.
tests
,
'processor'
:
self
.
code
,
body
=
{
'xml'
:
xmlstr
,
'edX_cmd'
:
'get_score'
,
'edX_tests'
:
self
.
tests
,
'processor'
:
self
.
code
,
}
body
.
update
(
extra_payload
)
payload
=
{
'xqueue_header'
:
json
.
dumps
(
header
),
'xqueue_body'
:
json
.
dumps
(
body
),
}
payload
.
update
(
extra_payload
)
# Contact queue server
try
:
...
...
common/lib/capa/capa/templates/textbox.html
View file @
27848337
...
...
@@ -34,7 +34,8 @@
%
if
linenumbers
==
'true'
:
lineNumbers
:
true
,
%
endif
mode
:
"${mode}"
mode
:
"${mode}"
,
tabsize
:
4
,
});
});
</script>
...
...
common/lib/xmodule/xmodule/capa_module.py
View file @
27848337
...
...
@@ -352,7 +352,7 @@ class CapaModule(XModule):
No ajax return is needed. Return empty dict.
"""
queuekey
=
get
[
'queuekey'
]
score_msg
=
get
[
'
response
'
]
score_msg
=
get
[
'
xqueue_body
'
]
self
.
lcp
.
update_score
(
score_msg
,
queuekey
)
return
dict
()
# No AJAX return is needed
...
...
lms/djangoapps/django_comment_client/base/views.py
View file @
27848337
...
...
@@ -19,24 +19,22 @@ from django_comment_client.utils import JsonResponse, JsonError
def
thread_author_only
(
fn
):
def
verified_fn
(
request
,
*
args
,
**
kwargs
):
thread_id
=
args
.
get
(
'thread_id'
,
False
)
or
\
kwargs
.
get
(
'thread_id'
,
False
)
thread_id
=
kwargs
.
get
(
'thread_id'
,
False
)
thread
=
comment_client
.
get_thread
(
thread_id
)
if
request
.
user
.
id
==
thread
[
'user_id'
]
:
if
str
(
request
.
user
.
id
)
==
str
(
thread
[
'user_id'
])
:
return
fn
(
request
,
*
args
,
**
kwargs
)
else
:
return
JsonError
(
400
,
"unauthorized"
)
return
JsonError
(
"unauthorized"
)
return
verified_fn
def
comment_author_only
(
fn
):
def
verified_fn
(
request
,
*
args
,
**
kwargs
):
comment_id
=
args
.
get
(
'comment_id'
,
False
)
or
\
kwargs
.
get
(
'comment_id'
,
False
)
comment_id
=
kwargs
.
get
(
'comment_id'
,
False
)
comment
=
comment_client
.
get_comment
(
comment_id
)
if
request
.
user
.
id
==
comment
[
'user_id'
]
:
if
str
(
request
.
user
.
id
)
==
str
(
comment
[
'user_id'
])
:
return
fn
(
request
,
*
args
,
**
kwargs
)
else
:
return
JsonError
(
400
,
"unauthorized"
)
return
JsonError
(
"unauthorized"
)
return
verified_fn
def
instructor_only
(
fn
):
#TODO add instructor verification
...
...
@@ -81,7 +79,7 @@ def delete_thread(request, course_id, thread_id):
response
=
comment_client
.
delete_thread
(
thread_id
)
return
JsonResponse
(
response
)
@
thread
_author_only
@
comment
_author_only
@login_required
@require_POST
def
update_comment
(
request
,
course_id
,
comment_id
):
...
...
lms/djangoapps/django_comment_client/utils.py
View file @
27848337
...
...
@@ -100,8 +100,10 @@ class JsonResponse(HttpResponse):
mimetype
=
'application/json; charset=utf8'
)
class
JsonError
(
HttpResponse
):
def
__init__
(
self
,
error_message
=
""
):
content
=
simplejson
.
dumps
({
'errors'
:
error_message
},
def
__init__
(
self
,
error_messages
=
[]):
if
isinstance
(
error_messages
,
str
):
error_messages
=
[
error_messages
]
content
=
simplejson
.
dumps
({
'errors'
:
error_messages
},
indent
=
2
,
ensure_ascii
=
False
)
super
(
JsonError
,
self
)
.
__init__
(
content
,
...
...
lms/static/coffee/src/customwmd.coffee
View file @
27848337
...
...
@@ -124,10 +124,12 @@ $ ->
return
if
not
$elem
.
find
(
".wmd-panel"
).
length
initialText
=
$elem
.
html
()
$elem
.
empty
()
_append
=
appended_id
||
""
$wmdPanel
=
$
(
"<div>"
).
addClass
(
"wmd-panel"
)
.
append
(
$
(
"<div>"
).
attr
(
"id"
,
"wmd-button-bar
#{
_append
}
"
))
.
append
(
$
(
"<textarea>"
).
addClass
(
"wmd-input"
).
attr
(
"id"
,
"wmd-input
#{
_append
}
"
))
.
append
(
$
(
"<textarea>"
).
addClass
(
"wmd-input"
).
attr
(
"id"
,
"wmd-input
#{
_append
}
"
)
.
html
(
initialText
)
)
.
append
(
$
(
"<div>"
).
attr
(
"id"
,
"wmd-preview
#{
_append
}
"
).
addClass
(
"wmd-panel wmd-preview"
))
$elem
.
append
(
$wmdPanel
)
...
...
lms/static/coffee/src/discussion.coffee
View file @
27848337
...
...
@@ -26,7 +26,7 @@ generateDiscussionLink = (cls, txt, handler) ->
Discussion
=
replyTemplate
:
"""
<
div
class="discussion-reply-new">
<
form
class="discussion-reply-new">
<ul class="discussion-errors"></ul>
<div class="reply-body"></div>
<input type="checkbox" class="discussion-post-anonymously" id="discussion-post-anonymously-{{id}}" />
...
...
@@ -35,9 +35,32 @@ Discussion =
<input type="checkbox" class="discussion-auto-watch" id="discussion-autowatch-{{id}}" checked />
<label for="discussion-auto-watch-{{id}}">watch this thread</label>
{{/showWatchCheckbox}}
</div>
<br />
<a class="discussion-submit-reply control-button" href="javascript:void(0)">Submit</a>
<a class="discussion-cancel-reply control-button" href="javascript:void(0)">Cancel</a>
</form>
"""
editThreadTemplate
:
"""
<form class="discussion-content-edit discussion-thread-edit" _id="{{id}}">
<ul class="discussion-errors discussion-update-errors"></ul>
<input type="text" class="thread-title-edit title-input" placeholder="Title" value="{{title}}"/>
<div class="thread-body-edit body-input">{{body}}</div>
<input class="thread-tags-edit" placeholder="Tags" value="{{tags}}" />
<a class="discussion-submit-update control-button" href="javascript:void(0)">Update</a>
<a class="discussion-cancel-update control-button" href="javascript:void(0)">Cancel</a>
</form>
"""
editCommentTemplate
:
"""
<form class="discussion-content-edit discussion-comment-edit" _id="{{id}}">
<ul class="discussion-errors discussion-update-errors"></ul>
<div class="comment-body-edit body-input">{{body}}</div>
<a class="discussion-submit-update control-button" href="javascript:void(0)">Update</a>
<a class="discussion-cancel-update control-button" href="javascript:void(0)">Cancel</a>
</form>
"""
urlFor
:
(
name
,
param
)
->
{
watch_commentable
:
"/courses/
#{
$$course_id
}
/discussion/
#{
param
}
/watch"
...
...
@@ -163,12 +186,6 @@ Discussion =
status
=
$discussionContent
.
attr
(
"status"
)
||
"normal"
if
status
==
"normal"
$local
(
".discussion-link"
).
show
()
else
if
status
==
"reply"
$local
(
".discussion-cancel-reply"
).
show
()
$local
(
".discussion-submit-reply"
).
show
()
else
if
status
==
"edit"
$local
(
".discussion-cancel-edit"
).
show
()
$local
(
".discussion-update-edit"
).
show
()
discussionContentHoverOut
=
->
$local
(
".discussion-link"
).
hide
()
...
...
@@ -176,9 +193,9 @@ Discussion =
$discussionContent
.
hover
(
discussionContentHoverIn
,
discussionContentHoverOut
)
handleReply
=
(
elem
)
->
edit
View
=
$local
(
".discussion-reply-new"
)
if
edit
View
.
length
edit
View
.
show
()
$reply
View
=
$local
(
".discussion-reply-new"
)
if
$reply
View
.
length
$reply
View
.
show
()
else
view
=
{
id
:
id
...
...
@@ -186,19 +203,16 @@ Discussion =
}
$discussionContent
.
append
Mustache
.
render
Discussion
.
replyTemplate
,
view
Markdown
.
makeWmdEditor
$local
(
".reply-body"
),
"-reply-body-
#{
id
}
"
,
Discussion
.
urlFor
(
'upload'
)
cancelReply
=
generateDiscussionLink
(
"discussion-cancel-reply"
,
"Cancel"
,
handleCancelReply
)
submitReply
=
generateDiscussionLink
(
"discussion-submit-reply"
,
"Submit"
,
handleSubmitReply
)
$local
(
".discussion-submit-reply"
).
click
handleSubmitReply
$local
(
".discussion-cancel-reply"
).
click
handleCancelReply
$local
(
".discussion-link"
).
hide
()
$
(
elem
).
after
(
submitReply
).
replaceWith
(
cancelReply
)
$discussionContent
.
attr
(
"status"
,
"reply"
)
handleCancelReply
=
(
elem
)
->
editView
=
$local
(
".discussion-reply-new"
)
if
editView
.
length
editView
.
hide
()
$local
(
".discussion-submit-reply"
).
remove
()
$replyView
=
$local
(
".discussion-reply-new"
)
if
$replyView
.
length
$replyView
.
hide
()
reply
=
generateDiscussionLink
(
"discussion-reply"
,
"Reply"
,
handleReply
)
$local
(
".discussion-link"
).
show
()
$
(
elem
).
replaceWith
(
reply
)
$discussionContent
.
attr
(
"status"
,
"normal"
)
...
...
@@ -232,10 +246,76 @@ Discussion =
Discussion
.
handleAnchorAndReload
(
response
)
,
'json'
handleCancelEdit
=
(
elem
)
->
$local
(
".discussion-content-edit"
).
hide
()
$local
(
".discussion-content-wrapper"
).
show
()
handleEditThread
=
(
elem
)
->
$local
(
".discussion-content-wrapper"
).
hide
()
$editView
=
$local
(
".discussion-content-edit"
)
if
$editView
.
length
$editView
.
show
()
else
view
=
{
id
:
id
title
:
$local
(
".thread-title"
).
html
()
body
:
$local
(
".thread-raw-body"
).
html
()
tags
:
$local
(
".thread-raw-tags"
).
html
()
}
$discussionContent
.
append
Mustache
.
render
Discussion
.
editThreadTemplate
,
view
Markdown
.
makeWmdEditor
$local
(
".thread-body-edit"
),
"-thread-body-edit-
#{
id
}
"
,
Discussion
.
urlFor
(
'update_thread'
,
id
)
$local
(
".thread-tags-edit"
).
tagsInput
autocomplete_url
:
Discussion
.
urlFor
(
'tags_autocomplete'
)
autocomplete
:
remoteDataType
:
'json'
interactive
:
true
defaultText
:
""
height
:
"30px"
removeWithBackspace
:
true
$local
(
".discussion-submit-update"
).
unbind
(
"click"
).
click
->
handleSubmitEditThread
(
this
)
$local
(
".discussion-cancel-update"
).
unbind
(
"click"
).
click
->
handleCancelEdit
(
this
)
handleSubmitEditThread
=
(
elem
)
->
url
=
Discussion
.
urlFor
(
'update_thread'
,
id
)
title
=
$local
(
".thread-title-edit"
).
val
()
body
=
$local
(
"#wmd-input-thread-body-edit-
#{
id
}
"
).
val
()
tags
=
$local
(
".thread-tags-edit"
).
val
()
$
.
post
url
,
{
title
:
title
,
body
:
body
,
tags
:
tags
},
(
response
,
textStatus
)
->
if
response
.
errors
errorsField
=
$local
(
".discussion-update-errors"
).
empty
()
for
error
in
response
.
errors
errorsField
.
append
(
$
(
"<li>"
).
addClass
(
"new-post-form-error"
).
html
(
error
))
else
Discussion
.
handleAnchorAndReload
(
response
)
,
'json'
handleEditComment
=
(
elem
)
->
$local
(
".discussion-content-wrapper"
).
hide
()
$editView
=
$local
(
".discussion-content-edit"
)
if
$editView
.
length
$editView
.
show
()
else
view
=
{
id
:
id
body
:
$local
(
".comment-raw-body"
).
html
()
}
$discussionContent
.
append
Mustache
.
render
Discussion
.
editCommentTemplate
,
view
Markdown
.
makeWmdEditor
$local
(
".comment-body-edit"
),
"-comment-body-edit-
#{
id
}
"
,
Discussion
.
urlFor
(
'update_comment'
,
id
)
$local
(
".discussion-submit-update"
).
unbind
(
"click"
).
click
->
handleSubmitEditComment
(
this
)
$local
(
".discussion-cancel-update"
).
unbind
(
"click"
).
click
->
handleCancelEdit
(
this
)
handleSubmitEditComment
=
(
elem
)
->
url
=
Discussion
.
urlFor
(
'update_comment'
,
id
)
body
=
$local
(
"#wmd-input-comment-body-edit-
#{
id
}
"
).
val
()
$
.
post
url
,
{
body
:
body
},
(
response
,
textStatus
)
->
if
response
.
errors
errorsField
=
$local
(
".discussion-update-errors"
).
empty
()
for
error
in
response
.
errors
errorsField
.
append
(
$
(
"<li>"
).
addClass
(
"new-post-form-error"
).
html
(
error
))
else
Discussion
.
handleAnchorAndReload
(
response
)
,
'json'
$local
(
".discussion-reply"
).
click
->
handleReply
(
this
)
...
...
lms/static/sass/_discussion.scss
View file @
27848337
...
...
@@ -48,7 +48,7 @@ $discussion_input_width: 85%;
margin-top
:
flex-gutter
(
8
);
}
}
.discussion-title
{
@include
discussion-font
;
@include
discussion-clickable
;
...
...
@@ -104,8 +104,8 @@ $discussion_input_width: 85%;
float
:
left
;
width
:
70%
;
}
.new-post-form
{
.
new-post-title
,
.new-post-body
{
.new-post-form
,
.discussion-thread-edit
{
.
title-input
,
.body-input
{
@include
discussion-font
;
display
:
block
!
important
;
width
:
$discussion_input_width
!
important
;
...
...
@@ -116,7 +116,7 @@ $discussion_input_width: 85%;
.new-post-body
{
margin-top
:
10px
;
}
.
discussion-new-post
{
.
control-button
{
@include
discussion-font
;
color
:
#1d9dd9
;
display
:
block
;
...
...
@@ -124,6 +124,12 @@ $discussion_input_width: 85%;
font-weight
:
bold
;
}
}
.discussion-content-edit
,
.discussion-reply-new
{
.control-button
{
display
:
inline-block
;
}
margin
:
10px
0
10px
0
;
}
.thread
{
//display: none;
margin-top
:
30px
;
...
...
lms/templates/discussion/inline.html
View file @
27848337
...
...
@@ -8,10 +8,10 @@
${search_bar}
<form
class=
"new-post-form"
_id=
"${discussion_id}"
>
<ul
class=
"discussion-errors"
></ul>
<input
type=
"text"
class=
"new-post-title"
placeholder=
"Title"
/>
<div
class=
"new-post-body"
></div>
<input
type=
"text"
class=
"new-post-title
title-input
"
placeholder=
"Title"
/>
<div
class=
"new-post-body
body-input
"
></div>
<input
class=
"new-post-tags"
placeholder=
"Tags"
/>
<a
class=
"discussion-new-post"
href=
"javascript:void(0)"
>
New Post
</a>
<a
class=
"discussion-new-post
control-button
"
href=
"javascript:void(0)"
>
New Post
</a>
</form>
</div>
% for thread in threads:
...
...
lms/templates/discussion/thread.html
View file @
27848337
...
...
@@ -28,12 +28,13 @@
<
%
def
name=
"render_content(content, type, **kwargs)"
>
<div
class=
"discussion-content"
>
<div
class=
"discussion-
upper
-wrapper clearfix"
>
<div
class=
"discussion-
content
-wrapper clearfix"
>
${render_vote(content)}
<div
class=
"discussion-right-wrapper clearfix"
>
${render_title(content, type, **kwargs)}
<div
class=
"discussion-content-view"
>
<div
class=
"content-body ${type}-body"
>
${content['body'] | h}
</div>
<div
class=
"content-raw-body ${type}-raw-body"
style=
"display: none"
>
${content['body'] | h}
</div>
${render_tags(content, type, **kwargs)}
${render_bottom_bar(content, type, **kwargs)}
</div>
...
...
@@ -63,9 +64,10 @@
% if type == "thread":
<div
class=
"thread-tags"
>
% for tag in content['tags']:
<a
class=
"thread-tag"
href=
"${url_for_tags([tag])}"
>
${tag}
</a>
<a
class=
"thread-tag"
href=
"${url_for_tags([tag])}"
>
${tag
| h
}
</a>
% endfor
</div>
<div
class=
"thread-raw-tags"
style=
"display: none"
>
${tag | h}
</div>
% endif
</
%
def>
...
...
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