Commit 7f79364d by Calen Pennington

Re-enable enrollment on stable for dev purposes (just rebase this branch on top…

Re-enable enrollment on stable for dev purposes (just rebase this branch on top of whatever you are working on to all users to enroll)
parent 2be4f6a2
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
<section> <section>
<h1>Circuits &amp; Electronics</h1> <h1>Circuits &amp; Electronics</h1>
<h2>6.002x</h2> <h2>6.002x</h2>
<a class="enroll" rel="leanModal" href="/info">View 6.002x Circuits <span>&amp;</span> Electronics as a guest</a> <a class="enroll" rel="leanModal" href="#enroll"><noscript>In order to</noscript> Enroll in 6.002x Circuits <span>&amp;</span> Electronics <noscript>you need to have javascript enabled</noscript></a>
</section> </section>
<p>6.002x (Circuits and Electronics) is an experimental on-line adaptation of MIT&rsquo;s first undergraduate analog design course: 6.002. This course is running, free of charge, for students worldwide from March 5, 2012 through June 8, 2012.</p> <p>6.002x (Circuits and Electronics) is an experimental on-line adaptation of MIT&rsquo;s first undergraduate analog design course: 6.002. This course is running, free of charge, for students worldwide from March 5, 2012 through June 8, 2012.</p>
</section> </section>
...@@ -51,7 +51,7 @@ ...@@ -51,7 +51,7 @@
</section> </section>
<section class="cta"> <section class="cta">
<a class="enroll" rel="leanModal" href="/info">View 6.002x Circuits &amp; Electronics as a guest</a> <a class="enroll" rel="leanModal" href="#enroll"><noscript>In order to</noscript> Enroll in 6.002x Circuits &amp; Electronics <noscript>you need to have javascript enabled</noscript></a>
</section> </section>
</section> </section>
...@@ -79,11 +79,38 @@ ...@@ -79,11 +79,38 @@
</section> </section>
</section> </section>
<div id="enroll" class="leanModal_box" name="enroll"><%include file="create_account.html" /></div>
<script> <script>
$(function() { $(function() {
// TODO: Clean up as per http://stackoverflow.com/questions/169506/obtain-form-input-fields-using-jquery // TODO: Clean up as per http://stackoverflow.com/questions/169506/obtain-form-input-fields-using-jquery
/* Handles when the user hits 'enroll'. Grabs form data. Does AJAX.
Either shows error, or shows success. */
$('form#enroll_form').submit(function(e) {
e.preventDefault();
var submit_data={};
$.each($("[id^=ca_]"), function(index,value){
submit_data[value.name]=value.value;
});
$.each($("[id^=cb_]"), function(index,value){
submit_data[value.name]=value.checked;
});
postJSON('/create_account',
submit_data,
function(json) {
if(json.success) {
$('#enroll').html(json.value);
} else {
$('#enroll_error').html(json.value).stop().css("background-color", "#933").animate({ backgroundColor: "#333"}, 2000);
}
}
);
});
/* Activate stupid spinner drop-downs in enrollment form */ /* Activate stupid spinner drop-downs in enrollment form */
var spinner_array=$("[id^=spinner_]"); var spinner_array=$("[id^=spinner_]");
spinner_array.each(function(i) { spinner_array.each(function(i) {
......
function ${ id }_content_updated() { function ${ id }_load() {
$('#main_${ id }').load('${ ajax_url }problem_get?id=${ id }',
function() {
MathJax.Hub.Queue(["Typeset",MathJax.Hub]); MathJax.Hub.Queue(["Typeset",MathJax.Hub]);
update_schematics(); update_schematics();
$('#check_${ id }').unbind('click').click(function() { $('#check_${ id }').click(function() {
$("input.schematic").each(function(index,element){ element.schematic.update_value(); }); $("input.schematic").each(function(index,element){ element.schematic.update_value(); });
var submit_data={}; var submit_data={};
$.each($("[id^=input_${ id }_]"), function(index,value){ $.each($("[id^=input_${ id }_]"), function(index,value){
...@@ -14,30 +16,29 @@ function ${ id }_content_updated() { ...@@ -14,30 +16,29 @@ function ${ id }_content_updated() {
switch(json.success) { switch(json.success) {
case 'incorrect': // Worked, but answer not case 'incorrect': // Worked, but answer not
case 'correct': case 'correct':
$('#main_${ id }').html(json.contents); ${ id }_load();
${ id }_content_updated(); //alert("!!"+json.success);
break; break;
default: default:
alert(json.success); alert(json.success);
}} }
); });
log_event('problem_check', submit_data); log_event('problem_check', submit_data);
}); });
$('#reset_${ id }').unbind('click').click(function() { $('#reset_${ id }').click(function() {
var submit_data={}; var submit_data={};
$.each($("[id^=input_${ id }_]"), function(index,value){ $.each($("[id^=input_${ id }_]"), function(index,value){
submit_data[value.id]=value.value; submit_data[value.id]=value.value;
}); });
postJSON('/modx/problem/${ id }/problem_reset', {'id':'${ id }'}, function(html_as_json) { postJSON('/modx/problem/${ id }/problem_reset', {'id':'${ id }'}, function(json) {
$('#main_${ id }').html(html_as_json); ${ id }_load();
${ id }_content_updated();
}); });
log_event('problem_reset', submit_data); log_event('problem_reset', submit_data);
}); });
$('#show_${ id }').unbind('click').click(function() { $('#show_${ id }').click(function() {
postJSON('/modx/problem/${ id }/problem_show', {}, function(data) { postJSON('/modx/problem/${ id }/problem_show', {}, function(data) {
for (var key in data) { for (var key in data) {
$("#answer_"+key).text(data[key]); $("#answer_"+key).text(data[key]);
...@@ -45,27 +46,23 @@ function ${ id }_content_updated() { ...@@ -45,27 +46,23 @@ function ${ id }_content_updated() {
}); });
log_event('problem_show', {'problem':'${ id }'}); log_event('problem_show', {'problem':'${ id }'});
}); });
$('#save_${ id }').unbind('click').click(function() { $('#save_${ id }').click(function() {
$("input.schematic").each(function(index,element){ element.schematic.update_value(); }); $("input.schematic").each(function(index,element){ element.schematic.update_value(); });
var submit_data={}; var submit_data={};
$.each($("[id^=input_${ id }_]"), function(index,value) { $.each($("[id^=input_${ id }_]"), function(index,value){
submit_data[value.id]=value.value; submit_data[value.id]=value.value;});
});
postJSON('/modx/problem/${ id }/problem_save', postJSON('/modx/problem/${ id }/problem_save',
submit_data, submit_data, function(data){
function(data) {
if(data.success) { if(data.success) {
alert('Saved'); alert('Saved');
}}); }}
);
log_event('problem_save', submit_data); log_event('problem_save', submit_data);
}); });
} }
);}
function ${ id }_load() {
$('#main_${ id }').load('${ ajax_url }problem_get?id=${ id }', ${ id }_content_updated);
}
$(function() { $(function() {
${ id }_load(); ${ id }_load();
......
...@@ -23,8 +23,8 @@ urlpatterns = ('', ...@@ -23,8 +23,8 @@ urlpatterns = ('',
url(r'^login$', 'student.views.login_user'), url(r'^login$', 'student.views.login_user'),
url(r'^login/(?P<error>[^/]*)$', 'student.views.login_user'), url(r'^login/(?P<error>[^/]*)$', 'student.views.login_user'),
url(r'^logout$', 'student.views.logout_user'), url(r'^logout$', 'student.views.logout_user'),
# url(r'^create_account$', 'student.views.create_account'), url(r'^create_account$', 'student.views.create_account'),
# url(r'^activate/(?P<key>[^/]*)$', 'student.views.activate_account'), url(r'^activate/(?P<key>[^/]*)$', 'student.views.activate_account'),
# url(r'^reactivate/(?P<key>[^/]*)$', 'student.views.reactivation_email'), # url(r'^reactivate/(?P<key>[^/]*)$', 'student.views.reactivation_email'),
url(r'^password_reset/$', 'student.views.password_reset'), url(r'^password_reset/$', 'student.views.password_reset'),
## Obsolete Django views for password resets ## Obsolete Django views for password resets
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment