Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBryan Berry <bryan@olenepal.org>2010-02-17 11:49:35 (GMT)
committer Bryan Berry <bryan@olenepal.org>2010-02-17 11:49:35 (GMT)
commitb955716b9ef9953603685c0577c803311b82dae0 (patch)
tree759b5b13438a03e1b0dc20ba2a9ca1db882cfeb1
parent3e196a9a5d49093519acf23ad3a95187a52f4833 (diff)
fix logic error in lesson
-rwxr-xr-xcss/karma.css6
-rwxr-xr-xcss/karma.css~43
-rwxr-xr-xexamples/English_Animal_Identification/js/lesson.js38
-rwxr-xr-xexamples/English_Animal_Identification/js/lesson.js~191
4 files changed, 253 insertions, 25 deletions
diff --git a/css/karma.css b/css/karma.css
index 607bcbb..7481928 100755
--- a/css/karma.css
+++ b/css/karma.css
@@ -40,4 +40,10 @@ body{
background-color: white;
}
+/* for first-time users */
+#kMain #itWorks{
+ text-align: center;
+ font-size: 4em;
+}
+
diff --git a/css/karma.css~ b/css/karma.css~
new file mode 100755
index 0000000..607bcbb
--- /dev/null
+++ b/css/karma.css~
@@ -0,0 +1,43 @@
+/* import nepal's Themeroller theme */
+@import url(./ui.base.css);
+@import url(./theme/jquery-ui-1.7.2.custom.css);
+@import url(./ui.dialog.css);
+@import url(./ui.resizable.css);
+@import url(./ui.feedback.css);
+
+/* special hack for the current karma-loader notification */
+@media screen {
+ #karma-loader{
+ position:absolute;
+ top:0;
+ left:0;
+ padding: 2px 2px 1px 5px;
+ font-size: 12px;
+ background: #0066cc;
+ color: #ffffff;
+
+ }
+ #karma-loader.status{
+ left:110px;
+ }
+}
+
+body{
+ padding: 0px;
+ margin: 0 auto 0 auto;
+ width: 1200px;
+ height: 900px;
+ overflow: hidden;
+ position: relative;
+ background-color: purple;
+}
+
+#kMain {
+ width: 1200px;
+ height: 760px;
+ float: left;
+ clear: both;
+ background-color: white;
+}
+
+
diff --git a/examples/English_Animal_Identification/js/lesson.js b/examples/English_Animal_Identification/js/lesson.js
index 4d60c7d..52ca412 100755
--- a/examples/English_Animal_Identification/js/lesson.js
+++ b/examples/English_Animal_Identification/js/lesson.js
@@ -1,44 +1,32 @@
$(document).ready(
function(){
+
+ //preloads assets into karma 'collections'
var k = Karma({
audio: [{'name':'correct','file':'correct.ogg'},
{'name':'incorrect','file':'incorrect.ogg'}
]});
+ //this command will scale down the lesson if the user's browser window
+ //is smaller than 950px X 600px
k.scaleWindow();
- $.i18n.setLocale('ne');
-
+
+ //sets locale, otherwise defaults to English
+ $.i18n.setLocale('en');
+
+ //put your main lesson code here
k.ready(
function(){
- var flag, i ,j;
- var object_counter = 1;
- var imgNameRand = [];
- var optPosition = [];
- var optOtherPos = [];
- var imageObject = [];
- var imgNames = ["Bear", "Cow", "Elephant", "Horse", "Tiger", "Goat"];
- var correctPosition;
- var selectedOption;
- var score = 0;
- var wrong_selected = 0; //wrong option selected so don't score up
- var pos;
- var t;
- var current_image;
-
- var $help = $('#kHelpText').dialog({
- position:[ "right", "top"], modal:'true',autoOpen:false
- });
-
- var $feedback = $('#feedback').feedback();
-
- $('#kHeaderHelpBtn').click(function(){ $help.dialog('open');});
-
$('#kHeader').kHeader({'title': 'English Animal Identification',
lessonPlan: true, teachersNote: true});
+ //Set up feedback widget, this shows the user a correct or incorrect
+ //icon and sound when triggered programmatically
+ var $feedback = $('#feedback').feedback();
+
var kFooter = $('#kFooter').kFooter({'winningScore': 6});
kFooter.bind('kFooterWinGame',
function(){
diff --git a/examples/English_Animal_Identification/js/lesson.js~ b/examples/English_Animal_Identification/js/lesson.js~
new file mode 100755
index 0000000..4d60c7d
--- /dev/null
+++ b/examples/English_Animal_Identification/js/lesson.js~
@@ -0,0 +1,191 @@
+$(document).ready(
+ function(){
+
+ var k = Karma({
+ audio: [{'name':'correct','file':'correct.ogg'},
+ {'name':'incorrect','file':'incorrect.ogg'}
+ ]});
+
+ k.scaleWindow();
+ $.i18n.setLocale('ne');
+
+ k.ready(
+ function(){
+
+ var flag, i ,j;
+ var object_counter = 1;
+ var imgNameRand = [];
+ var optPosition = [];
+ var optOtherPos = [];
+ var imageObject = [];
+ var imgNames = ["Bear", "Cow", "Elephant", "Horse", "Tiger", "Goat"];
+ var correctPosition;
+ var selectedOption;
+ var score = 0;
+ var wrong_selected = 0; //wrong option selected so don't score up
+ var pos;
+ var t;
+ var current_image;
+
+ var $help = $('#kHelpText').dialog({
+ position:[ "right", "top"], modal:'true',autoOpen:false
+ });
+
+ var $feedback = $('#feedback').feedback();
+
+ $('#kHeaderHelpBtn').click(function(){ $help.dialog('open');});
+
+
+ $('#kHeader').kHeader({'title': 'English Animal Identification',
+ lessonPlan: true, teachersNote: true});
+
+ var kFooter = $('#kFooter').kFooter({'winningScore': 6});
+ kFooter.bind('kFooterWinGame',
+ function(){
+ $('.optImg').hide();
+ $('.imageBox').hide();
+ $('#gameOver').show();
+ });
+ kFooter.bind('kFooterRestart',
+ function() {
+ object_counter = 1;
+ imgNameRand = [];
+ optPosition = [];
+ optOtherPos = [];
+ imageObject = [];
+ score = 0;
+ wrong_selected = 0; //wrong option selected so don't score up
+
+ load_images();
+ game();
+
+ }
+ );
+
+ load_images(); //load the image numbers for random display
+ game(); //let the game begin
+
+
+ function checkDisplay(){ //Displays the correct and incorrect info
+ if(wrong_selected == 1){
+ $feedback.feedback('incorrect');
+ }
+ else if (object_counter === 7 ){
+ $feedback.feedback('win');
+ } else{
+ $feedback.feedback('correct');
+ }
+ }
+
+ $("#anchorPlayAgain").click(function(){
+ $('#gameOver').hide();
+ $('.optImg').show();
+ $('.imageBox').show();
+ load_images();
+ score = 0;
+ object_counter = 1;
+ wrong_selected = 0;
+ //display_score();
+ kFooter.kFooter('reset');
+ game();
+
+ });
+ $("#anchorOpt0").click(function(){
+ selected_Option_Process('0');
+ });
+ $("#anchorOpt1").click(function(){
+ selected_Option_Process('1');
+ });
+ $("#anchorOpt2").click(function(){
+ selected_Option_Process('2');
+ });
+ $("#anchorOpt3").click(function(){
+ selected_Option_Process('3');
+ });
+
+
+ function load_images(){
+ imageObject = k.shuffle([1, 2, 3, 4, 5, 6]);
+ }
+
+ function selected_Option_Process(selectedOption){
+
+ if(selectedOption == correctPosition){
+ object_counter++;
+ wrong_selected = 0;
+ score++;
+ kFooter.kFooter('inc');
+ kFooter.kFooter('incTotal');
+ checkDisplay();
+ game();
+ }
+ else {
+ wrong_selected = 1;
+ kFooter.kFooter('incTotal');
+ checkDisplay();
+ }
+
+ }
+
+ function game(){
+
+ wrong_selected = 0;
+ current_image = object_counter%6;
+ document.getElementById("imgObject").src = "assets/image/" +
+ imageObject[current_image] + ".png";
+
+ //find correct answer and apply it to the position
+ var currentImage = imageObject[current_image];
+ imgNameRand[0] = currentImage;
+ //generate choices
+
+ for(i=1; i<4; i++){
+ do{
+ flag = 0;
+ imgNameRand[i] = k.rand(1, 6);
+ for(j=0; j<i; j++){
+ if(imgNameRand[i]===imgNameRand[j]){
+ flag++;
+ }
+ }
+ }while(flag != 0 ); //end of do while loop
+ }
+
+
+ correctPosition = k.rand(0, 3);
+
+ optOtherPos[0] = correctPosition;
+
+ for(i=1; i<4; i++){
+ do{
+ flag = 0;
+ optOtherPos[i] = k.rand(0, 3);
+ for(j=0; j<i; j++){ //chek repeat within optOtherPos array
+ if(optOtherPos[i] === optOtherPos[j]){
+ flag++;
+ }
+ }
+
+ }while(flag != 0);
+
+ }
+
+ for(i=0; i<4; i++){
+ pos = optOtherPos[i];
+ optPosition[pos] = imgNameRand[i];
+ //optPosition[pos] = imgNames[i];
+ }
+
+
+
+ //random positions are stored in optOtherPos array. Great
+
+
+ for(i=0; i<4; i++){
+ document.getElementById("option"+i+"").src = "assets/image/image_name/"+optPosition[i]+".png";
+ }
+
+
+ } //no change
+ }); //end of games
+}); //end of DOM \ No newline at end of file