Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
R
RecommenderXBlock
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
RecommenderXBlock
Commits
1a576b47
Commit
1a576b47
authored
Jan 14, 2015
by
swdanielli
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
move error msg to server and add UnderscoreJs
parent
5348193d
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
20 additions
and
21 deletions
+20
-21
recommender/recommender.py
+6
-0
recommender/static/js/src/cats.js
+0
-6
recommender/static/js/src/recommender.js
+11
-15
recommender/static/js/src/recommenderstudio.js
+3
-0
recommender/static/js/src/underscore-min.js
+0
-0
No files found.
recommender/recommender.py
View file @
1a576b47
...
@@ -440,6 +440,7 @@ class RecommenderXBlock(XBlock):
...
@@ -440,6 +440,7 @@ class RecommenderXBlock(XBlock):
tracker
.
emit
(
'upload_screenshot'
,
tracker
.
emit
(
'upload_screenshot'
,
{
'uploadedFileName'
:
'FILE_TYPE_ERROR'
})
{
'uploadedFileName'
:
'FILE_TYPE_ERROR'
})
response
.
status
=
415
response
.
status
=
415
response
.
body
=
json
.
dumps
({
'error'
:
'Please upload an image in GIF/JPG/PNG'
})
return
response
return
response
# Check whether file size exceeds threshold (30MB)
# Check whether file size exceeds threshold (30MB)
...
@@ -448,6 +449,7 @@ class RecommenderXBlock(XBlock):
...
@@ -448,6 +449,7 @@ class RecommenderXBlock(XBlock):
tracker
.
emit
(
'upload_screenshot'
,
tracker
.
emit
(
'upload_screenshot'
,
{
'uploadedFileName'
:
'FILE_SIZE_ERROR'
})
{
'uploadedFileName'
:
'FILE_SIZE_ERROR'
})
response
.
status
=
413
response
.
status
=
413
response
.
body
=
json
.
dumps
({
'error'
:
'Size of uploaded file exceeds threshold'
})
return
response
return
response
try
:
try
:
...
@@ -463,6 +465,7 @@ class RecommenderXBlock(XBlock):
...
@@ -463,6 +465,7 @@ class RecommenderXBlock(XBlock):
tracker
.
emit
(
'upload_screenshot'
,
tracker
.
emit
(
'upload_screenshot'
,
{
'uploadedFileName'
:
'IMPROPER_S3_SETUP'
})
{
'uploadedFileName'
:
'IMPROPER_S3_SETUP'
})
response
.
status
=
404
response
.
status
=
404
response
.
body
=
json
.
dumps
({
'error'
:
'The configuration of Amazon S3 is not properly set'
})
return
response
return
response
response
=
Response
()
response
=
Response
()
...
@@ -707,6 +710,7 @@ class RecommenderXBlock(XBlock):
...
@@ -707,6 +710,7 @@ class RecommenderXBlock(XBlock):
response
.
headers
[
'Content-Type'
]
=
'text/plain'
response
.
headers
[
'Content-Type'
]
=
'text/plain'
if
not
self
.
get_user_is_staff
():
if
not
self
.
get_user_is_staff
():
response
.
status
=
403
response
.
status
=
403
response
.
body
=
json
.
dumps
({
'error'
:
'Only staff can import resources'
})
tracker
.
emit
(
'import_resources'
,
{
'Status'
:
'NOT_A_STAFF'
})
tracker
.
emit
(
'import_resources'
,
{
'Status'
:
'NOT_A_STAFF'
})
return
response
return
response
...
@@ -731,6 +735,7 @@ class RecommenderXBlock(XBlock):
...
@@ -731,6 +735,7 @@ class RecommenderXBlock(XBlock):
return
response
return
response
except
:
except
:
response
.
status
=
415
response
.
status
=
415
response
.
body
=
json
.
dumps
({
'error'
:
'Please submit the JSON file obtained with the download resources button'
})
tracker
.
emit
(
'import_resources'
,
{
'Status'
:
'FILE_FORMAT_ERROR'
,
'data'
:
raw_data
})
tracker
.
emit
(
'import_resources'
,
{
'Status'
:
'FILE_FORMAT_ERROR'
,
'data'
:
raw_data
})
return
response
return
response
...
@@ -819,6 +824,7 @@ class RecommenderXBlock(XBlock):
...
@@ -819,6 +824,7 @@ class RecommenderXBlock(XBlock):
frag
.
add_css
(
self
.
resource_string
(
"static/css/tooltipster.css"
))
frag
.
add_css
(
self
.
resource_string
(
"static/css/tooltipster.css"
))
frag
.
add_css
(
self
.
resource_string
(
"static/css/recommender.css"
))
frag
.
add_css
(
self
.
resource_string
(
"static/css/recommender.css"
))
frag
.
add_css
(
self
.
resource_string
(
"static/css/introjs.css"
))
frag
.
add_css
(
self
.
resource_string
(
"static/css/introjs.css"
))
frag
.
add_javascript
(
self
.
resource_string
(
"static/js/src/underscore-min.js"
))
frag
.
add_javascript
(
self
.
resource_string
(
"static/js/src/jquery.tooltipster.min.js"
))
frag
.
add_javascript
(
self
.
resource_string
(
"static/js/src/jquery.tooltipster.min.js"
))
frag
.
add_javascript
(
self
.
resource_string
(
"static/js/src/cats.js"
))
frag
.
add_javascript
(
self
.
resource_string
(
"static/js/src/cats.js"
))
frag
.
add_javascript
(
self
.
resource_string
(
"static/js/src/recommender.js"
))
frag
.
add_javascript
(
self
.
resource_string
(
"static/js/src/recommender.js"
))
...
...
recommender/static/js/src/cats.js
View file @
1a576b47
...
@@ -63,12 +63,6 @@ var tooltipsCatsText = {
...
@@ -63,12 +63,6 @@ var tooltipsCatsText = {
'.resourceRankingForRemovalButton.removeMode'
:
'<span>Click to view resources in ordinary decreasing-vote order</span>'
'.resourceRankingForRemovalButton.removeMode'
:
'<span>Click to view resources in ordinary decreasing-vote order</span>'
};
};
var
uploadFileErrorText
=
{
415
:
'Please upload an image in GIF/JPG/PNG'
,
404
:
'The configuration of Amazon S3 is not properly set'
,
413
:
'Size of uploaded file exceeds threshold'
};
var
importResourceErrorText
=
{
var
importResourceErrorText
=
{
403
:
'Only staff can import resources'
,
403
:
'Only staff can import resources'
,
415
:
'Please submit the JSON file obtained with the download resources button'
415
:
'Please submit the JSON file obtained with the download resources button'
...
...
recommender/static/js/src/recommender.js
View file @
1a576b47
if
(
typeof
Logger
===
'undefined'
)
{
if
(
typeof
Logger
===
'undefined'
)
{
var
Logger
=
{
var
Logger
=
{
log
:
function
(
a
)
{
return
;
}
log
:
function
(
a
,
b
)
{
return
;
}
}
}
}
}
...
@@ -27,16 +27,10 @@ function RecommenderXBlock(runtime, element, init_data) {
...
@@ -27,16 +27,10 @@ function RecommenderXBlock(runtime, element, init_data) {
* @returns {dictionary} The dictionary for logging an event.
* @returns {dictionary} The dictionary for logging an event.
*/
*/
function
generateLog
(
status
,
information
)
{
function
generateLog
(
status
,
information
)
{
if
(
!
information
)
{
return
_
.
find
([
return
{
'status'
:
status
,
'element'
:
$
(
element
).
attr
(
'data-usage-id'
)
};
{
'status'
:
status
,
'element'
:
$
(
element
).
attr
(
'data-usage-id'
)},
}
{
'status'
:
status
,
'element'
:
$
(
element
).
attr
(
'data-usage-id'
),
'information'
:
information
}
else
{
],
function
(
log
)
{
return
information
===
log
.
information
;
});
return
{
'status'
:
status
,
'information'
:
information
,
'element'
:
$
(
element
).
attr
(
'data-usage-id'
)
}
}
}
}
/**
/**
...
@@ -238,8 +232,9 @@ function RecommenderXBlock(runtime, element, init_data) {
...
@@ -238,8 +232,9 @@ function RecommenderXBlock(runtime, element, init_data) {
backToView
();
backToView
();
Logger
.
log
(
'mit.recommender.importResource'
,
generateLog
(
loggerStatus
[
'importResource'
][
'complete'
],
result
));
Logger
.
log
(
'mit.recommender.importResource'
,
generateLog
(
loggerStatus
[
'importResource'
][
'complete'
],
result
));
},
},
error
:
function
(
result
,
status
)
{
error
:
function
(
result
)
{
alert
(
importResourceErrorText
[
result
.
status
]);
var
data
=
JSON
.
parse
(
result
.
responseText
)
if
(
data
.
error
)
{
alert
(
data
.
error
);
}
resetImportResourcePage
();
resetImportResourcePage
();
},
},
});
});
...
@@ -454,7 +449,8 @@ function RecommenderXBlock(runtime, element, init_data) {
...
@@ -454,7 +449,8 @@ function RecommenderXBlock(runtime, element, init_data) {
* 404: The filesystem (e.g., Amazon S3) is not properly set
* 404: The filesystem (e.g., Amazon S3) is not properly set
* 413: Size of uploaded file exceeds threshold
* 413: Size of uploaded file exceeds threshold
*/
*/
alert
(
uploadFileErrorText
[
result
.
status
]);
var
data
=
JSON
.
parse
(
result
.
responseText
)
if
(
data
.
error
)
{
alert
(
data
.
error
);
}
$
(
"input[name='file']"
,
formDiv
).
val
(
''
);
$
(
"input[name='file']"
,
formDiv
).
val
(
''
);
if
(
writeType
===
writeDatabaseEnum
.
ADD
)
{
enableAddSubmit
();
}
if
(
writeType
===
writeDatabaseEnum
.
ADD
)
{
enableAddSubmit
();
}
else
if
(
writeType
===
writeDatabaseEnum
.
EDIT
)
{
enableEditSubmit
();
}
else
if
(
writeType
===
writeDatabaseEnum
.
EDIT
)
{
enableEditSubmit
();
}
...
@@ -671,7 +667,7 @@ function RecommenderXBlock(runtime, element, init_data) {
...
@@ -671,7 +667,7 @@ function RecommenderXBlock(runtime, element, init_data) {
data
[
'title'
]
=
$
(
'.editTitle'
,
element
).
val
();
data
[
'title'
]
=
$
(
'.editTitle'
,
element
).
val
();
data
[
'descriptionText'
]
=
$
(
'.editDescriptionText'
,
element
).
val
();
data
[
'descriptionText'
]
=
$
(
'.editDescriptionText'
,
element
).
val
();
data
[
'description'
]
=
''
data
[
'description'
]
=
''
if
(
data
[
'url'
]
===
''
||
data
[
'title'
]
===
''
)
{
return
;
}
if
(
!
data
.
url
||
data
.
title
)
{
return
;
}
var
formDiv
=
$
(
'.editResourceForm'
,
element
);
var
formDiv
=
$
(
'.editResourceForm'
,
element
);
var
file
=
new
FormData
(
$
(
formDiv
)[
0
]);
var
file
=
new
FormData
(
$
(
formDiv
)[
0
]);
...
...
recommender/static/js/src/recommenderstudio.js
View file @
1a576b47
...
@@ -20,6 +20,9 @@ function RecommenderXBlock(runtime, element) {
...
@@ -20,6 +20,9 @@ function RecommenderXBlock(runtime, element) {
success
:
function
(
result
)
{
success
:
function
(
result
)
{
alert
(
'The configurations have been updated'
);
alert
(
'The configurations have been updated'
);
}
}
error
:
function
(
result
)
{
alert
(
'An internal error happened. We cannot set the configurations right now. Please try again later.'
);
}
});
});
});
});
}
}
...
...
recommender/static/js/src/underscore-min.js
0 → 100644
View file @
1a576b47
This diff is collapsed.
Click to expand it.
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