Commit 8989605c by Isaac Chuang Committed by Piotr Mitros

Moving in Ike's new files, touches of multicourse

parent 15cae333
...@@ -62,7 +62,7 @@ def textline(element, value, state, msg=""): ...@@ -62,7 +62,7 @@ def textline(element, value, state, msg=""):
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
# TODO: Make a wrapper for <formulainput> # TODO: Make a wrapper for <formulainput>
# TODO: Make an AJAX loop to confirm equation is okay in real-time as user types # TODO: Make an AJAX loop to confirm equation is okay in real-time as user types
def js_textline(element, value, state, msg=""): def jstextline(element, value, state, msg=""):
''' '''
textline is used for simple one-line inputs, like formularesponse and symbolicresponse. textline is used for simple one-line inputs, like formularesponse and symbolicresponse.
''' '''
...@@ -76,7 +76,7 @@ def js_textline(element, value, state, msg=""): ...@@ -76,7 +76,7 @@ def js_textline(element, value, state, msg=""):
'dojs':dojs, 'dojs':dojs,
'msg':msg, 'msg':msg,
} }
html=render_to_string("textinput.html", context) html=render_to_string("jstext.html", context)
return etree.XML(html) return etree.XML(html)
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
......
...@@ -30,7 +30,7 @@ from lxml import etree ...@@ -30,7 +30,7 @@ from lxml import etree
import requests import requests
from copy import deepcopy from copy import deepcopy
print "Warning: Dark code. Needs review before enabling in prod." print "[lib.sympy_check.formula] Warning: Dark code. Needs review before enabling in prod."
os.environ['PYTHONIOENCODING'] = 'utf-8' os.environ['PYTHONIOENCODING'] = 'utf-8'
......
...@@ -5,12 +5,35 @@ import tempfile ...@@ -5,12 +5,35 @@ import tempfile
import djcelery import djcelery
### Dark code. Should be enabled in local settings for devel.
ENABLE_MULTICOURSE = False # set to False to disable multicourse display (see lib.util.views.mitxhome)
###
MITX_ROOT_URL = '' MITX_ROOT_URL = ''
COURSE_NAME = "6.002_Spring_2012" COURSE_NAME = "6.002_Spring_2012"
COURSE_NUMBER = "6.002x" COURSE_NUMBER = "6.002x"
COURSE_TITLE = "Circuits and Electronics" COURSE_TITLE = "Circuits and Electronics"
COURSE_DEFAULT = '6.002_Spring_2012'
COURSE_LIST = {'6.002_Spring_2012': {'number' : '6.002x',
'title' : 'Circuits and Electronics',
'datapath': '6002x/',
},
'8.02_Spring_2013': {'number' : '8.02x',
'title' : 'Electricity &amp; Magnetism',
'datapath': '802x/',
},
'8.01_Spring_2013': {'number' : '8.01x',
'title' : 'Mechanics',
'datapath': '801x/',
},
}
ROOT_URLCONF = 'urls' ROOT_URLCONF = 'urls'
# from settings2.askbotsettings import LIVESETTINGS_OPTIONS # from settings2.askbotsettings import LIVESETTINGS_OPTIONS
......
<span>
<input type="hidden" class="imageinput" src="${src}" name="input_${id}" id="input_${id}" value="${value}" />
<div id="imageinput_${id}" onclick="image_input_click('${id}',event);" style = "background-image:url('${src}');width:${width}px;height:${height}px;position: relative; left: 0; top: 0;">
<img src="/static/green-pointer.png" id="cross_${id}" style="position: absolute;top: ${gy}px;left: ${gx}px;" />
</div>
% if state == 'unsubmitted':
<span class="unanswered" style="display:inline-block;" id="status_${id}"></span>
% elif state == 'correct':
<span class="correct" id="status_${id}"></span>
% elif state == 'incorrect':
<span class="incorrect" id="status_${id}"></span>
% elif state == 'incomplete':
<span class="incorrect" id="status_${id}"></span>
% endif
</span>
<section class="text-input">
<input type="text" name="input_${id}" id="input_${id}" value="${value}"
% if size:
size="${size}"
% endif
% if dojs == 'math':
onkeyup="DoUpdateMath('${id}')"
% endif
/>
% if dojs == 'math':
<span id="display_${id}">`{::}`</span>
% endif
<span id="answer_${id}"></span>
% if dojs == 'math':
<textarea style="display:none" id="input_${id}_fromjs" name="input_${id}_fromjs"></textarea>
% endif
% if state == 'unsubmitted':
<span class="unanswered" style="display:inline-block;" id="status_${id}"></span>
% elif state == 'correct':
<span class="correct" id="status_${id}"></span>
% elif state == 'incorrect':
<span class="incorrect" id="status_${id}"></span>
% elif state == 'incomplete':
<span class="incorrect" id="status_${id}"></span>
% endif
% if msg:
<br/>
<span class="debug">${msg|n}</span>
% endif
</section>
<section class="math-string">
% if isinline:
<span>[mathjaxinline]${mathstr}[/mathjaxinline]</span>
% else:
<span>[mathjax]${mathstr}[/mathjax]</span>
% endif
<span>${tail}</span>
</section>
<%inherit file="main.html" />
<%block name="js_extra">
<script>
$(document).ready(function(){
//if(!page) {
// cookie_page = $.cookie("book_page");
// if(cookie_page) {
// goto_page(cookie_page);
// }
//}
$(".handouts ol").treeview({collapsed:true, unique:true/*, cookieId: "treeview-book-nav", persist: "cookie"*/});
});
</script>
</%block>
<%block name="title"><title>MITx Home</title></%block>
<%include file="navigation.html" args="active_page='info'" />
<section class="main-content">
<div class="info-wrapper">
<section class="updates">
<h2>Welcome to MITx</h2>
<hr width="100%">
<h3>Courses available:</h3>
<ul>
<li><a href=${ MITX_ROOT_URL }/courseware/6.002_Spring_2012/>6.002 (Spring 2012)</a></li>
<li><a href=${ MITX_ROOT_URL }/courseware/8.02_Spring_2013/>8.02 (Spring 2013)</a></li>
<li><a href=${ MITX_ROOT_URL }/courseware/8.01_Spring_2013/>8.01 (Spring 201x)</a></li>
</ul>
</section>
</div>
</section>
...@@ -2,7 +2,13 @@ ...@@ -2,7 +2,13 @@
<div class="header-wrapper"> <div class="header-wrapper">
<header> <header>
<hgroup> <hgroup>
<h1><em>MITx</em></h1> <h1><em>
% if settings.ENABLE_MULTICOURSE:
<a href="${ MITX_ROOT_URL }/mitxhome" style="color:black;">MITx</a>
% else:
MITx
% endif
</em></h1>
<h2><a href="${ MITX_ROOT_URL }/courseware/">${ settings.COURSE_TITLE }</a></h2> <h2><a href="${ MITX_ROOT_URL }/courseware/">${ settings.COURSE_TITLE }</a></h2>
</hgroup> </hgroup>
......
...@@ -3,7 +3,8 @@ function ${ id }_content_updated() { ...@@ -3,7 +3,8 @@ function ${ id }_content_updated() {
update_schematics(); update_schematics();
$('#check_${ id }').unbind('click').click(function() { $('#check_${ id }').unbind('click').click(function() {
$("input.schematic").each(function(index,element){ element.schematic.update_value(); }); $("input.schematic").each(function(index,element){ element.schematic.update_value(); });
$(".CodeMirror").each(function(index,element){ if (element.CodeMirror.save) element.CodeMirror.save(); });
var submit_data={}; var submit_data={};
$.each($("[id^=input_${ id }_]"), function(index,value){ $.each($("[id^=input_${ id }_]"), function(index,value){
if (value.type==="checkbox"){ if (value.type==="checkbox"){
...@@ -52,6 +53,8 @@ function ${ id }_content_updated() { ...@@ -52,6 +53,8 @@ function ${ id }_content_updated() {
log_event('problem_reset', submit_data); log_event('problem_reset', submit_data);
}); });
// show answer button
// TODO: the button should turn into "hide answer" afterwards
$('#show_${ id }').unbind('click').click(function() { $('#show_${ id }').unbind('click').click(function() {
postJSON('${ MITX_ROOT_URL }/modx/problem/${ id }/problem_show', {}, function(data) { postJSON('${ MITX_ROOT_URL }/modx/problem/${ id }/problem_show', {}, function(data) {
for (var key in data) { for (var key in data) {
......
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