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
85101828
Commit
85101828
authored
Sep 28, 2016
by
Chris Rodriguez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updating Yaml
parent
e6330716
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
68 additions
and
69 deletions
+68
-69
common/lib/xmodule/xmodule/templates/problem/jsinput_response.yaml
+68
-69
No files found.
common/lib/xmodule/xmodule/templates/problem/jsinput_response.yaml
View file @
85101828
...
@@ -5,39 +5,15 @@ metadata:
...
@@ -5,39 +5,15 @@ metadata:
showanswer
:
never
showanswer
:
never
data
:
|
data
:
|
<problem>
<problem>
<p>
<script type="loncapa/python">
In these problems (also called custom JavaScript problems or JS Input
problems), you add a problem or tool that uses JavaScript in Studio.
Studio embeds the problem in an IFrame so that your students can
interact with it in the LMS. You can grade your students' work using
JavaScript and some basic Python, and the grading is integrated into the
edX grading system.
</p>
<p>
The JS Input problem that you create must use HTML, JavaScript, and
cascading style sheets (CSS). You can use any application creation tool,
such as the Google Web Toolkit (GWT), to create your JS Input problem.
</p>
<p>
For more information, see
<a href="http://edx.readthedocs.io/projects/edx-partner-course-staff/en/latest/exercises_tools/custom_javascript.html" target="_blank">
Custom JavaScript Problem</a> in <i>Building and Running an edX Course</i>.
</p>
<p>
JavaScript developers can also see
<a href="http://edx.readthedocs.io/projects/edx-developer-guide/en/latest/extending_platform/javascript.html" target="_blank">
Custom JavaScript Applications</a> in the <i>EdX Developer's Guide</i>.
</p>
<p>
When you add the problem, be sure to select <strong>Settings</strong>
to specify a <strong>Display Name</strong> and other values that apply.
</p>
<p>You can use the following example problem as a model.</p>
<customresponse cfn="vglcfn">
<script type="loncapa/python">
<![CDATA[
import json
import json
########## Course Author Section #########
## Change whatever you need to in here. ##
##########################################
# These are REQUIRED for all problems.
# These are REQUIRED for all problems.
problem_type = 'interval' # Set to 'interval' or a 'number'
problem_type = 'interval' # Set to 'interval' or a 'number'
show_open_close = False # Do we ask for open/closed interval?
show_open_close = False # Do we ask for open/closed interval?
...
@@ -51,21 +27,26 @@ data: |
...
@@ -51,21 +27,26 @@ data: |
brackets = [1, 0.5, 0.25, 0] # Scores for various range brackets
brackets = [1, 0.5, 0.25, 0] # Scores for various range brackets
# Only for interval-guessing:
# Only for interval-guessing:
correct_interval = [416,660] # Please put the lower value on the left.
correct_interval = [416,660]
# Please put the lower value on the left.
interval_type = ['closed', 'closed'] # Are endpoints 'open' or 'closed'?
interval_type = ['closed', 'closed']
# Are endpoints 'open' or 'closed'?
interval_tolerance = 'linear' # Options: 'linear', 'strict', or 'generous'
interval_tolerance = 'linear' # Options: 'linear', 'strict', or 'generous'
type_penalty = 0.1 # Points off if open/closed incorrect
type_penalty = 0.1
# Points off if open/closed incorrect
# Only for estimation
# Only for estimation
max_time = 1000 # Large number of people beyond actual high
max_time = 1000 # Large number of people beyond actual high
######## End Course Author Section #########
## Don't change anything below this line. ##
############################################
# Set the outer bounds for the slider
# Set the outer bounds for the slider
lowerlimit = 0
lowerlimit = 0
upperlimit = 1000
upperlimit = 1000
def answercheck(e, ans):
def answercheck(e, ans):
# Get the student's answer.
# Get the student's answer.
parsed = json.loads(ans)
parsed = json.loads(ans)
answer = json.loads(parsed['answer'])
answer = json.loads(parsed['answer'])
...
@@ -73,11 +54,11 @@ data: |
...
@@ -73,11 +54,11 @@ data: |
guess_lower = answer['lowerguess']
guess_lower = answer['lowerguess']
guess_upper_closed = answer['upperclosed']
guess_upper_closed = answer['upperclosed']
guess_lower_closed = answer['lowerclosed']
guess_lower_closed = answer['lowerclosed']
# Now begins the grading.
# Now begins the grading.
message = ''
message = ''
final_grade = 0
final_grade = 0
if problem_type == 'interval':
if problem_type == 'interval':
if guess_upper < correct_interval[0]:
if guess_upper < correct_interval[0]:
# No points if there's no overlap.
# No points if there's no overlap.
...
@@ -93,21 +74,21 @@ data: |
...
@@ -93,21 +74,21 @@ data: |
endpoints.append(guess_upper)
endpoints.append(guess_upper)
endpoints.append(guess_lower)
endpoints.append(guess_lower)
endpoints.sort()
endpoints.sort()
overlap = endpoints[2] - endpoints[1]
overlap = endpoints[2] - endpoints[1]
bigrange = max(correct_interval[1] - correct_interval[0], guess_upper - guess_lower)
bigrange = max(correct_interval[1] - correct_interval[0], guess_upper - guess_lower)
final_grade = float(overlap) / float(bigrange)
final_grade = float(overlap) / float(bigrange)
message = str(int(round(final_grade, 2) * 100)) + '% overlap with correct answer.'
message = str(int(round(final_grade, 2) * 100)) + '% overlap with correct answer.'
if interval_tolerance == 'strict':
if interval_tolerance == 'strict':
final_grade = final_grade * final_grade
final_grade = final_grade * final_grade
elif interval_tolerance == 'generous':
elif interval_tolerance == 'generous':
final_grade = math.sqrt(final_grade)
final_grade = math.sqrt(final_grade)
# Round up to the nearest tenth.
# Round up to the nearest tenth.
final_grade = math.ceil(final_grade*10.0) / 10.0
final_grade = math.ceil(final_grade*10.0) / 10.0
if show_open_close:
if show_open_close:
if(guess_lower_closed != True and interval_type[0] == 'closed'):
if(guess_lower_closed != True and interval_type[0] == 'closed'):
final_grade = final_grade - type_penalty
final_grade = final_grade - type_penalty
...
@@ -121,11 +102,11 @@ data: |
...
@@ -121,11 +102,11 @@ data: |
if(guess_upper_closed == True and interval_type[1] != 'closed'):
if(guess_upper_closed == True and interval_type[1] != 'closed'):
final_grade = final_grade - type_penalty
final_grade = final_grade - type_penalty
message += ' Upper endpoint is wrong.'
message += ' Upper endpoint is wrong.'
else:
else:
farthest = max(abs(correct_number - guess_upper), abs(correct_number - guess_lower))
farthest = max(abs(correct_number - guess_upper), abs(correct_number - guess_lower))
if farthest < tolerance[0]:
if farthest < tolerance[0]:
final_grade = brackets[0]
final_grade = brackets[0]
message = 'Close enough! Actual answer: ' + str(correct_number)
message = 'Close enough! Actual answer: ' + str(correct_number)
...
@@ -138,12 +119,12 @@ data: |
...
@@ -138,12 +119,12 @@ data: |
else:
else:
final_grade = brackets[3]
final_grade = brackets[3]
message = 'Your range is too large to get points.'
message = 'Your range is too large to get points.'
if guess_upper > correct_number and guess_lower < correct_number:
if guess_upper > correct_number and guess_lower < correct_number:
message += ' The answer is within your range.'
message += ' The answer is within your range.'
else:
else:
message += ' The answer is outside your range.'
message += ' The answer is outside your range.'
if not feedback:
if not feedback:
message = ''
message = ''
...
@@ -153,29 +134,47 @@ data: |
...
@@ -153,29 +134,47 @@ data: |
isOK = "Partial"
isOK = "Partial"
else:
else:
isOK = False
isOK = False
return {
return {
'input_list': [
'input_list': [
{ 'ok': isOK, 'msg': message, 'grade_decimal': final_grade},
{ 'ok': isOK, 'msg': message, 'grade_decimal': final_grade},
]
]
}
}
]]>
</script>
<script type="text/javascript">
$(document).ready(function(){
console.log('Let\'s go!');
});
// Logs a javascript object.
function logThatThing(ThatThing){
// Log it to the console just to verify it's working
console.log(JSON.stringify(ThatThing));
// Send it to the official edX logamajig!
// Logger.log("harvardx.public_demo.range_guesser", ThatThing);
}
</script>
</script>
<p>What is the range of passengers that can fit on a 747 aircraft? Set the low and high bounds. (416 and 660 persons)</p>
<p>What is the range of passengers that can fit on a 747 aircraft? Set the low and high bounds. (416 and 660 persons)</p>
<p class="sr" aria-hidden="true">
<p class="sr" aria-hidden="true">
<span id="lowerlimit">$lowerlimit</span>
<span id="lowerlimit">$lowerlimit</span>
<span id="upperlimit">$upperlimit</span>
<span id="upperlimit">$upperlimit</span>
<span id="openclose">$show_open_close</span>
<span id="openclose">$show_open_close</span>
<span id="istimequestion">$is_time_question</span>
<span id="istimequestion">$is_time_question</span>
<span id="maxtime">$max_time</span>
<span id="maxtime">$max_time</span>
</p>
</p>
<customresponse cfn="answercheck">
<customresponse cfn="answercheck">
<jsinput gradefn="guesser.getGrade" get_statefn="guesser.getState" set_statefn="guesser.setState" width="800" height="120" html_file="https://files.edx.org/custom-js
/guesser.html" sop="false"/>
<jsinput gradefn="guesser.getGrade" get_statefn="guesser.getState" set_statefn="guesser.setState" width="800" height="120" html_file="/static
/guesser.html" sop="false"/>
</customresponse>
</customresponse>
<solution>
<solution>
<div class="detailed-solution">
<div class="detailed-solution">
<p>Explanation</p>
<p>Explanation</p>
<p>Answer: The 747-400 passenger version can accommodate between 416 and 660 passengers depending on the layout and configuration.</p>
<p>Answer: The 747-400 passenger version can accommodate between 416 and 660 passengers depending on the layout and configuration.</p>
</div>
</div>
</solution>
</solution>
</problem>
</problem>
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