Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTony Anderson <tony@traveler.(none)>2011-01-14 10:27:29 (GMT)
committer Tony Anderson <tony@traveler.(none)>2011-01-14 10:27:29 (GMT)
commit0adb823c97e6627c46a1acdc3eca1555f5f5f124 (patch)
tree55c95ea5fe8b5ba8faaf490019dcfbb6e0fb2516
parente6571da2ebc457c64e25a6617fd3ca3e02df5bea (diff)
version 11.2
-rwxr-xr-xactivity/activity.info2
-rwxr-xr-xcgi-bin/results.py271
-rwxr-xr-xcgi-bin/return.py13
-rwxr-xr-xcgi-bin/saveFile.py4
-rwxr-xr-xcontent/Mathematics/index.html4
-rwxr-xr-xcontent/css/global.css5
-rwxr-xr-xcontent/js/global.js9
-rwxr-xr-xcontent/js/learner_lesson.js1
-rwxr-xr-xcontent/js/learner_subject.js2
-rwxr-xr-xcontent/js/navigation.js3
-rwxr-xr-xcontentedit.html26
-rwxr-xr-xtinymce/themes/advanced/skins/default/content.css2
12 files changed, 117 insertions, 225 deletions
diff --git a/activity/activity.info b/activity/activity.info
index 99feb66..0081caa 100755
--- a/activity/activity.info
+++ b/activity/activity.info
@@ -1,5 +1,5 @@
[Activity]
-#version 11.1
+#version = 11.2
name = Learn
service_name = org.olerwanda.Learn
icon = activity-learn
diff --git a/cgi-bin/results.py b/cgi-bin/results.py
index 9e5da11..6d3a77a 100755
--- a/cgi-bin/results.py
+++ b/cgi-bin/results.py
@@ -18,7 +18,7 @@ log = open('/tmp/logr','w')
retval = 0
cgitb.enable(display=True)
print 'Content-type:text/html\n\n'
-#parameters is score
+#parameter are score, subject, milestone, activity
form = cgi.FieldStorage()
score = form.getfirst('score', default="")
subject = form.getfirst('subject',default="")
@@ -29,222 +29,71 @@ if len(score) > 0 and len(subject) > 0 and len(milestone) >0 and len(activity) >
#close current session (/tmp/current_session)
#update student record (/tmp/learner)
#check for log in
- try:
- fin=open(DATAPATH / 'learner','r')
- learner = fin.read()
- fin.close()
- except:
- #no one is logged in
- print >> log, 'no one is logged in'
- learner = 'unknown'
- print >> log, 'learner',learner
+ fin=open(DATAPATH / 'learner','r')
+ learner = fin.read()
+ fin.close()
#read student record
- try:
- fin = open(DATAPATH / learner,'r')
- txt = fin.read()
- fin.close()
- except:
- print >> log, 'no matching student record'
- #no matching student_record - force blank student_record
- learner = 'unknown'
- txt = '{}'
- try:
- student_record = eval(txt)
- except:
- student_record = {}
- student_record['grade'] = ''
- student_record['milestones'] = ['1.1','1.1']
- student_record['progress'] = []
- print >> log, 'student_record eval failed',sys.exc_info()[:2]
- print >> log, 'student record txt',txt
+ fin = open(DATAPATH / learner,'r')
+ txt = fin.read()
+ fin.close()
+ student_record = eval(txt)
#read current_session
- try:
- fin = open('/tmp/current_session','r')
- txt = fin.read()
- fin.close()
- except:
- #no session open
- txt = ""
- print >> log,'no session open'
- print >> log, 'session', txt
+ fin = open('/tmp/current_session','r')
+ txt = fin.read()
+ fin.close()
session_data = txt.split(',')
- if len(session_data)>1:
- activity=session_data[0]
- starttime = session_data[1]
- stoptime = str(int(time.time()))
- result = score
- print >> log, 'session data', activity, starttime, stoptime, result
+ activity=session_data[0]
+ starttime = session_data[1]
+ stoptime = str(int(time.time()))
+ result = score
+ #make next activity the current activity - use student record
+ mss = student_record['milestones']
+ if subject == 'English':
+ msstate = mss[0]
else:
- activity = ""
- result = ''
- print >> log, 'no session data'
- #update activities.js
- print >> log, 'update activities.js', activity, result
- if len(activity)>0 and int(result) >= 70:
- #we can do this via the form
- #update activities.js
- #find current milestone
- #get milestones, find red one
- #find current activity
- #get activities
- #find red one
- #update to green
- #find next one
- #update to red
- milestone = activity[:7]
- if activity[:2] == 'en':
- subject = 'English'
- else:
- subject = 'Mathematics'
- pth = path('content') / subject / milestone / 'activities.js'
- print >> log, 'read activities activities.js',pth
- try:
- fin = open(pth,'r')
- txt = fin.read()
- fin.close()
- except:
- print 'open activities activities.js failed', sys.exc_info()[:2]
- lines = txt.split('\n')
- txtout = ""
- nxtflag = False
- print >>log, 'activities.js lines',len(lines)
- for line in lines:
- line = line + '\n'
- if activity in line:
- nxtflag=True
- retval = 1
- txtout=txtout+line.replace('red','green')
- elif nxtflag and line.find('blue')>-1:
- nxtflag=False
- txtout=txtout+line.replace('blue','red')
- else:
- txtout = txtout+line
- try:
- fout = open(pth,'w')
- fout.write(txtout)
- fout.close()
- except:
- print >> log, 'write activities activities.js failed',sys.exc_info()[:2]
- print >> log, 'activity activities.js updated', nxtflag
- #if nxtflag == True - means end of milestone
- if nxtflag:
- #update milestones in student record
- try:
- milestones = student_record['milestones']
- print >> log, 'milestones', milestones
- if subject == 'English':
- msstate = milestones[0]
- else:
- msstate = milestones[1]
- print >> log, 'msstate', msstate
- try:
- temp = msstate.split('.')
- msstr = int(temp[0])+1
- temp[0] = str(int(msstr))
- temp[1] = '1'
- msstate = temp[0]+'.'+temp[1]
- except:
- print >> log, 'msstate set up failed', sys.exc_info()[:2]
- if subject == 'English':
- milestones[0] = msstate
- else:
- milestones[1] = msstate
- student_record['milestones']=milestones
- except:
- print >> log, 'update milestones failed',sys.exc_info()[:2]
- #update activities.js for subject
- milestone = activity[:7]
- pth = path('content') / subject / 'activities.js'
- print >> log, 'milestone',milestone,'pth',pth
- fin = open(pth,'r')
- txt = fin.read()
- fin.close()
- lines = txt.split('\n')
- txtout = ""
- nxtmsflag = False
- for line in lines:
- line = line + '\n'
- if milestone in line:
- nxtmsflag = True
- retval = 2
- txtout = txtout + line.replace('red','green')
- elif nxtmsflag == True:
- if line.find('blue')>0:
- nxtmsflag = False
- txtout = txtout + line.replace('blue','red')
- elif line.find('Blue')>0:
- nxtmsflag = False
- txtout = txtout + line.replace('Blue','red')
- else:
- print >> log, nxtmsflag, line
- txtout = txtout + line
- fout = open(pth,'w')
- fout.write(txtout)
- fout.close()
- if nxtmsflag:
- #what do we do now - this learner is done!
- print >> log, 'learner is done!'
- retval = 3
- #update first activity in next milestone
- print >> log, 'first activity in next milestone', milestone
- nxt = str(int(milestone[5:7])+1)
- if len(nxt)<2:
- nxt = '0'+nxt
- next_milestone = milestone[:5]+nxt
- next_activity = next_milestone + 'a01'
- print >> log, 'next', next_milestone, next_activity
- pth = path('content') / subject / next_milestone / 'activities.js'
- print >> log, 'pth', pth
- fin = open(pth,'r')
- txt = fin.read()
- fin.close()
- lines = txt.split('\n')
- txtout = ""
- for line in lines:
- line = line + '\n'
- if next_activity in line:
- t1 = line.replace('Blue','red')
- txtout = txtout + t1.replace('blue','red')
- else:
- txtout = txtout + line
- fout = open(pth,'w')
- fout.write(txtout)
- fout.close()
+ msstate = mss[1]
+ temp = msstate.split('.')
+ active_milestone = int(temp[0])-1
+ active_activity = int(temp[1])-1
+ milestones = getMilestones(subject)
+ activities = getActivities(subject, milestones[active_milestone][4])
+ activities[active_activity][5] = 'green'
+ print >> log,'set ',active_activity,activities[active_activity]
+ active_activity +=1
+ if active_activity < len(activities):
+ activities[active_activity][5] = 'red'
+ retval = 1
+ print >> log,'set ',active_activity,activities[active_activity]
+ else:
+ retval = 2
+ print >> log, 'setActivities',active_milestone,milestones[active_milestone][4]
+ setActivities(subject, milestones[active_milestone][4], activities)
+ if retval == 2: #move to next milestone
+ active_activity = 1
+ milestones[active_milestone][5] = 'green'
+ active_milestone += 1
+ if active_milestone == len(milestones): #student is done!
+ retval = 3
else:
- #update milestones in student record
- milestones = student_record['milestones']
- if subject == 'English':
- msstate = milestones[0]
- else:
- msstate = milestones[1]
- temp = msstate.split('.')
- msstr = int(temp[1])+1
- temp[1] = str(int(msstr))
- msstate = temp[0]+'.'+temp[1]
- if subject == 'English':
- milestones[0] = msstate
- else:
- milestones[1] = msstate
- student_record['milestones']=milestones
+ milestones[active_milestone][5] = 'red'
+ activities = getActivities(subject, milestones[active_milestone][4])
+ activities[0][5] = 'red'
+ setActivities(subject, milestones[active_milestone][4],activities)
+ setMilestones(subject, student_record['grade'], milestones)
#update student_record
- #if there is a problem, above processing should leave activity = ''
- print >> log, activity, len(activity)
- if len(activity) == 10:
- try:
- progress = student_record['progress']
- status = (starttime, stoptime, result)
- progress.append({activity:status})
- student_record['progress'] = progress
- except:
- print >> log, 'update progress failed', sys.exc_info()[:2]
- try:
- fout = open(DATAPATH / learner,'w')
- fout.write(str(student_record))
- fout.close()
- except:
- print >> log, 'update student record failed', sys.exc_info()[:2]
- #close current session - works even if none open
- subprocess.call('rm -rf /tmp/current_session',shell=True)
+ msstate = str(active_milestone+1) + '.' + str(active_activity+1)
+ if subject == 'English':
+ mss[0] = msstate
+ else:
+ mss[1] = msstate
+ student_record['milestones']=mss
+ progress = student_record['progress']
+ status = (starttime, stoptime, result)
+ progress.append({activity:status})
+ student_record['progress'] = progress
+ fout = open(DATAPATH / learner,'w')
+ fout.write(str(student_record))
+ fout.close()
print >> log, 'exception?',sys.exc_info()[:2]
print retval
diff --git a/cgi-bin/return.py b/cgi-bin/return.py
new file mode 100755
index 0000000..d2cbae2
--- /dev/null
+++ b/cgi-bin/return.py
@@ -0,0 +1,13 @@
+#!/usr/bin/python
+import sys, subprocess
+import cgi, cgitb
+from path import path
+
+cgitb.enable(display=True)
+print 'Content-Type:text/html\n\n'
+form = cgi.FieldStorage()
+fin = open('/tmp/openfile','r')
+f = fin.read()
+fin.close()
+fpth = path(f).parent
+print fpth
diff --git a/cgi-bin/saveFile.py b/cgi-bin/saveFile.py
index a481860..ac776b0 100755
--- a/cgi-bin/saveFile.py
+++ b/cgi-bin/saveFile.py
@@ -178,8 +178,8 @@ fin = open('/tmp/openfile','r')
f = fin.read()
fin.close()
fpth = path(f).parent
-srcpth = fpth / 'source'
-savepth = srcpth / 'a.txt'
+srcpth = fpth'
+savepth = srcpth / 'source.txt'
txt = form.getfirst('content', default='no text found')
soup = BeautifulSoup(txt)
imgs = soup.findAll('img')
diff --git a/content/Mathematics/index.html b/content/Mathematics/index.html
index 28ff111..838ea1f 100755
--- a/content/Mathematics/index.html
+++ b/content/Mathematics/index.html
@@ -1,7 +1,7 @@
<!DOCTYPE html>
<html>
<head>
- <title>English </title>
+ <title>Mathematics </title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<link type="text/css" rel="stylesheet" href="../css/global.css" />
<link type="image/ico" rel="icon" href="../assets/default/image/favicon.ico" />
@@ -20,7 +20,7 @@
</div></div>
<div id="lesson_title">
<img src="../assets/image/title_block_lt.png" width="33" height="75" align = "absmiddle" />
- English
+ Mathematics
<img src="../assets/image/title_block_rt.png" width="33" height="75" align = "absmiddle" />
</div>
<div id="topbtn_right">
diff --git a/content/css/global.css b/content/css/global.css
index 7893362..a52342d 100755
--- a/content/css/global.css
+++ b/content/css/global.css
@@ -33,6 +33,11 @@ body {
overflow-x:hidden;
z-index: 0;
}
+#cntnt{
+ position:relative;
+ width:1200px;
+ height:748px;
+}
#topbtn_left {
float: left;
height: 60px;
diff --git a/content/js/global.js b/content/js/global.js
index 9ac7c57..e547138 100755
--- a/content/js/global.js
+++ b/content/js/global.js
@@ -8,6 +8,13 @@ var back = '../index.html'; // return to activity ladder
var backOne = '../../index.html' // return to subject menu
var backTwo = '../../../index.html' // return to main menu
+function editreturn(){
+ $('<div id="temp"/>')
+ .load('http://localhost:8008/cgi-bin/return.py',
+ function(responseTxt,status,xhr){
+ window.location = responseTxt
+ });
+}
function goback(){
window.location = back;
}
@@ -18,13 +25,11 @@ function gobackTwo(){
window.location = backTwo;
}
function apply(){
- alert(window.location+' type '+typeof(window.location+''));
items = (window.location+"").split('/');
score = '70';
subject = items[4];
milestone = items[5];
activity = items[6];
- alert(score+' '+subject+' '+milestone+' '+activity);
$('#content').load('http://localhost:8008/cgi-bin/results.py',{
'score':score,
'subject':subject,
diff --git a/content/js/learner_lesson.js b/content/js/learner_lesson.js
index fe874d3..0ddfc88 100755
--- a/content/js/learner_lesson.js
+++ b/content/js/learner_lesson.js
@@ -49,7 +49,6 @@ $(document).ready(
// directory structure: content/subject/milestone/activity
// for learners, we want the 'red' activity
url = window.location+"";
- alert(url.indexOf('?F'));
if ((x > xy[1])&&(x < xy[1]+cellsize)&&(y < xy[2])&&(y > xy[2] - cellsize) ){
if ((xy[5]=='red') || (url.indexOf('?F') > -1)){
//set path
diff --git a/content/js/learner_subject.js b/content/js/learner_subject.js
index 069586a..fe52553 100755
--- a/content/js/learner_subject.js
+++ b/content/js/learner_subject.js
@@ -52,7 +52,6 @@ $(document).ready(
}else{
mode = 'student'
}
- alert(mode);
$("canvas").click(function($e) {
// find out which act in acts was clicked
x = $e.pageX
@@ -69,7 +68,6 @@ $(document).ready(
pth = xy[4]+'/index.html';
window.location = pth;
};
- });
});
});
// ladder
diff --git a/content/js/navigation.js b/content/js/navigation.js
index 6299b03..11cc5bd 100755
--- a/content/js/navigation.js
+++ b/content/js/navigation.js
@@ -13,6 +13,9 @@ $(document).ready(function(){
$('#linkBackThree').click(function(){
gobackThree();
});
+ $('#editReturn').click(function(){
+ editreturn();
+ });
$('#linkApply').click(function(){
apply();
});
diff --git a/contentedit.html b/contentedit.html
index 6831fa7..f224c5b 100755
--- a/contentedit.html
+++ b/contentedit.html
@@ -3,8 +3,11 @@
<head>
<title>Siyavula Content Editor</title>
<link rel="stylesheet" href="css/screen.css" type="text/css" />
+<link rel="stylesheet" href="content/css/global.css" type="text/css"/>
<script type="text/javascript" src="js/jquery-latest.js"></script>
<script type="text/javascript" src="js/jquery.ui.all.js"</script>
+<script type="text/javascript" src="content/js/global.js"</script>
+<script type="text/javascript" src="content/js/navigation.js"</script>
<script type="text/javascript" src="tinymce/tiny_mce.js"></script>
<script type="text/javascript">
@@ -21,6 +24,8 @@ tinyMCE.init({
relative_urls : true,
document_base_url : 'http://localhost:8008/imgs',
content_css: "http://localhost:8008/content/css/global.css",
+ width: "1200",
+ height: "1200"
});
$(document).ready(function(){
@@ -52,7 +57,17 @@ function toggleEditor(id) {
</script>
</head>
<body>
-<div id="hdr">
+ <div id="header">
+ <div id="topbtn_left"><div title="linkBack" id="editReturn"
+class="linkBack" />
+ </div></div>
+ <div id="lesson_title">
+ <img src="../assets/image/title_block_lt.png" width="33"
+height="75" al$
+ Content Editor
+ <img src="../assets/image/title_block_rt.png" width="33"
+height="75" al$
+ </div>
<span style="font-size:24px; font-weight:bold">
<fieldset>
<legend>Siyavula Content Editor</legend>
@@ -61,12 +76,17 @@ function toggleEditor(id) {
<a href="javascript:toggleEditor('cntnt');">web/html</a>
</fieldset>
</span>
-</div>
+ <div id="topbtn_right">
+ <div title="Quit" id="linkQuit" class="linkQuit"></div>
+ </div>
+ </div>
+<div id="content">
<textarea id="cntnt"
name='cntnt'
class='mceAdvanced'
- style='width:100%;height:2000px;">
</textarea>
+</div>
+<div id='footer'/>
</body>
</html>
diff --git a/tinymce/themes/advanced/skins/default/content.css b/tinymce/themes/advanced/skins/default/content.css
index dcb09ad..de2fb1f 100755
--- a/tinymce/themes/advanced/skins/default/content.css
+++ b/tinymce/themes/advanced/skins/default/content.css
@@ -1,7 +1,7 @@
body, td, pre {
color:#000;
font-family:Verdana, Arial, Helvetica, sans-serif;
- font-size:10px;
+ font-size:14px;
margin:8px;
}
body {background:#FFF;}