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
ab0cb29c
Commit
ab0cb29c
authored
Dec 16, 2011
by
Piotr Mitros
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Better/more AJAXy problem rendering
parent
1f609974
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
37 additions
and
54 deletions
+37
-54
main.html
+1
-0
problem.html
+0
-29
problem.js
+35
-25
problem_ajax.html
+1
-0
No files found.
main.html
View file @
ab0cb29c
...
@@ -9,6 +9,7 @@
...
@@ -9,6 +9,7 @@
<script
type=
"text/javascript"
src=
"/static/lib/jquery-ui-1.8.16.custom.min.js"
></script>
<script
type=
"text/javascript"
src=
"/static/lib/jquery-ui-1.8.16.custom.min.js"
></script>
<script
type=
"text/javascript"
src=
"/static/lib//swfobject/swfobject.js"
></script>
<script
type=
"text/javascript"
src=
"/static/lib//swfobject/swfobject.js"
></script>
<script
type=
"text/javascript"
src=
"/static/js/video_player.js"
></script>
<script
type=
"text/javascript"
src=
"/static/js/video_player.js"
></script>
<script
type=
"text/javascript"
src=
"/static/js/schematic.js"
></script>
<style
type=
"text/css"
>
#slider
{
margin
:
10px
;
}
</style>
<style
type=
"text/css"
>
#slider
{
margin
:
10px
;
}
</style>
<!-- Warning: Do not upgrade FancyBox. V2.0 is under a non-free CC license -->
<!-- Warning: Do not upgrade FancyBox. V2.0 is under a non-free CC license -->
<script
type=
"text/javascript"
src=
"/static/lib/fancybox/jquery.fancybox-1.3.4.js"
></script>
<script
type=
"text/javascript"
src=
"/static/lib/fancybox/jquery.fancybox-1.3.4.js"
></script>
...
...
problem.html
View file @
ab0cb29c
...
@@ -2,35 +2,6 @@
...
@@ -2,35 +2,6 @@
${ problem['html'] }
${ problem['html'] }
<br>
<br>
<input
type=
"hidden"
name=
"problem_id"
value=
"${ problem['name'] }"
>
<input
type=
"hidden"
name=
"problem_id"
value=
"${ problem['name'] }"
>
<script>
$
(
function
()
{
$
(
'#check_${ id }'
).
click
(
function
()
{
var
submit_data
=
{};
$
.
each
(
$
(
"[id^=input_${ id }_]"
),
function
(
index
,
value
){
submit_data
[
value
.
id
]
=
value
.
value
;
});
if
(
$
(
'#check_${ id }'
).
attr
(
'value'
).
substring
(
0
,
5
)
!=
'Reset'
)
{
$
.
getJSON
(
'/modx/problem/${ id }/problem_check'
,
submit_data
,
function
(
json
)
{
for
(
p
in
json
)
{
if
(
json
[
p
]
==
'correct'
)
$
(
"#status_"
+
p
).
attr
(
"class"
,
"ui-icon ui-icon-check"
);
if
(
json
[
p
]
==
'incorrect'
)
$
(
"#status_"
+
p
).
attr
(
"class"
,
"ui-icon ui-icon-close"
);
$
(
'#check_${ id }'
).
attr
(
"value"
,
"Reset"
);
}
});
}
else
/* if 'Reset' */
{
// Possible cleanup: Move from getJSON to just load
$
.
getJSON
(
'/modx/problem/${ id }/problem_reset'
,
{
'id'
:
'${ id }'
},
function
(
json
)
{
$
(
'#main_${ id }'
).
html
(
json
);
MathJax
.
Hub
.
Queue
([
"Typeset"
,
MathJax
.
Hub
]);
});
}
});
});
</script>
% if check_button:
% if check_button:
<input
id=
"check_${ id }"
type=
"button"
value=
"${ check_button }"
>
<input
id=
"check_${ id }"
type=
"button"
value=
"${ check_button }"
>
% endif
% endif
problem.js
View file @
ab0cb29c
$
(
function
()
{
function
$
{
id
}
_load
()
{
$
(
'#check_${ id }'
).
click
(
function
()
{
$
(
'#main_${ id }'
).
load
(
'${ ajax_url }problem_get?id=${ id }'
,
var
submit_data
=
{};
function
()
{
$
.
each
(
$
(
"[id^=input_${ id }_]"
),
function
(
index
,
value
){
MathJax
.
Hub
.
Queue
([
"Typeset"
,
MathJax
.
Hub
]);
submit_data
[
value
.
id
]
=
value
.
value
;
});
$
(
'#check_${ id }'
).
click
(
function
()
{
var
submit_data
=
{};
$
.
each
(
$
(
"[id^=input_${ id }_]"
),
function
(
index
,
value
){
submit_data
[
value
.
id
]
=
value
.
value
;
});
if
(
$
(
'#check_${ id }'
).
attr
(
'value'
)
==
'Check'
)
{
if
(
$
(
'#check_${ id }'
).
attr
(
'value'
).
substring
(
0
,
5
)
!=
'Reset'
)
{
$
.
getJSON
(
'/modx/problem/${ id }/problem_check'
,
$
.
getJSON
(
'/modx/problem/${ id }/problem_check'
,
submit_data
,
submit_data
,
function
(
json
)
{
function
(
json
)
{
for
(
p
in
json
)
{
for
(
p
in
json
)
{
if
(
json
[
p
]
==
'correct'
)
if
(
json
[
p
]
==
'correct'
)
$
(
"#status_"
+
p
).
attr
(
"class"
,
"ui-icon ui-icon-check"
);
$
(
"#status_"
+
p
).
attr
(
"class"
,
"ui-icon ui-icon-check"
);
if
(
json
[
p
]
==
'incorrect'
)
if
(
json
[
p
]
==
'incorrect'
)
$
(
"#status_"
+
p
).
attr
(
"class"
,
"ui-icon ui-icon-close"
);
$
(
"#status_"
+
p
).
attr
(
"class"
,
"ui-icon ui-icon-close"
);
$
(
'#check_${ id }'
).
attr
(
"value"
,
"Reset"
);
$
(
'#check_${ id }'
).
attr
(
"value"
,
"Reset"
);
}
}
});
});
}
else
/* if 'Reset' */
{
}
else
/* if 'Reset' */
{
// Possible cleanup: Move from getJSON to just load
$
.
getJSON
(
'/modx/problem/${ id }/problem_reset'
,
{
'id'
:
'${ id }'
},
function
(
json
)
{
$
.
getJSON
(
'/modx/problem/${ id }/problem_reset'
,
{
'id'
:
'${ id }'
},
function
(
json
)
{
$
{
id
}
_load
();
$
(
'#main_${ id }'
).
html
(
json
);
//$('#main_${ id }').html(json);
});
//MathJax.Hub.Queue(["Typeset",MathJax.Hub]);
}
});
});
}
});
});
}
$
(
function
()
{
$
{
id
}
_load
();
});
});
problem_ajax.html
0 → 100644
View file @
ab0cb29c
<div
id=
"main_${id}"
></div>
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