Heartwork 0.1

Today was a really beautiful day.  A little cool, but very clear.  After starting my blood pressure medicine yesterday, I actually felt stronger this morning.  I measured my pressure at 130/70, and then headed out for the hills with the dogs.

We did a 6 mile hike going along the Appalachian Trail from the Rte. 40 pedestrian bridge to the Washington Monument at the State Park, and back.  The last hill was a bit steep, but we climbed the tower

app_trail 009

for the beautiful scenic overview,

app_trail 007

and then rushed to get back before dark as the chill set in.  It was cold enough that I wore my coat the whole hike.  The interesting thing is that this section of the AT changed congressional districts from district 6 (now John Delaney formerly Roscoe Bartlett) to district 8 (Chris van Hollen).  It is right on the border, and we traversed both districts during the hike.

I felt pretty good – great actually.  Lisinopril is supposed to start working pretty fast.  Maybe it’s the medicine.  Anyway, I’ve been doing a little work on a new program Heartwork 0.1, a program to teach/learn about cardiology, while one listens to Vivaldi’s 4 seasons, and watches pictures of flowers.  During the course of this work, I’ve learned that the drug is an ACE inhibitor, and it works by vasodilating (like taking a bath) thereby decreasing cardiac afterload, and increasing stroke volume.and therefore cardiac output, and perfusion.  Maybe that’s why I feel stronger.

Thinking about what is probably going on physiologically, I am starting to understand a little better what caffeine has been doing to my body.  Because, I probably have tissue perfusion problems, I have been compensating by stimulating my heart.  I’ve eliminated caffeine and reduced the amount of salt in my diet to lower my blood pressure, but since the vascular perfusion problem has been medically corrected with the ACE-inhibitor, small stimulations of the heart may be ok with an occasional coffee.  I should probably discuss this with a nurse.

I’m trying to put together a lot of information about what tests have been run in the past week.  Obviously, there was the volume challenge: 1 Liter IV in 45 min.  I took it, but my head felt weird.  The EKG and pressures were abnormal coming in, but the enzymes did not show a recent infarct.  They later normalized.  The stress test was started with a BP of 180/100, and I only lasted 6 min. before my BP got up to 219 and I stopped.  I had some dizziness as blood flow was redirected from my head to my heart.  Also, a little numbness on the right side of my face and shoulder.  So, I’m guessing that there is some occlusion on that side relative to the other side (probably at the brachiocephalic artery before it branches).  With the blood pressure measurements, the machines are having a hard time I think because my pulse is weak.  When it is stopped in the brachial artery, the stethoscope is still sometimes picking up a weaker sound of pulsing blood flow to much higher pressures, but it is probably not the beat of the brachial artery.  Another possibility is that there is a clot in that artery, and obstruction with the cuff does not uniformly and equally cut off blood flow in the artery.  Or could there be a splitting of the valve signal?

I also realize that as a diabetic there are a couple of situations that occur with low blood sugar that are also indicative.  I’ve passed out twice in my life (that I remember), once in a setting where I thought there was going to be an explosion (I fell to the floor, and then recovered to crawl out), and the other time when I was quite young, and had low blood sugar that was not treated (at camp).  One of my symptoms when my blood sugar gets low, is pulsing vision.  I will see for a second, and then not for the next 2 seconds, like I am just getting enough blood flow to give me a little vision.  Obviously, epinephrine is released, and it causes very severe vasoconstriction and blood redirection to the heart during these low blood sugar episodes.  If there were a really bad clot, I might lose consciousness, but I don’t.  I’m still quite functional and alert – even with the vasoconstriction that very obviously accompanies the insulin reactions.

So, I am probably experiencing some degree of compromised heart function from 40 years of diabetes and consequently ischemia.  My heart rate has always run high (high 90’s to 100).  Obviously, I need to lose at least 25 pounds.

The SUN/creatinine ratio was slightly elevated.  That may be from dehydration, or possibly kidney problems.  The urine did not show ketones or protein.  I don’t know about the protein.  I’ve done my own tests on Petey and me, and they have always had a little protein in them.  I suspect that ketones were present from the fact that my insulin had not been working well.  I’m not sure why they were not reported in the blood work.

I should probably schedule an end of the year physical with a diabetologist to include a kidney assessment.  The diabetologist, as opposed to a general internist will be able to process and integrate the various problems that I have with different systems.  They will have seen them over and over and over in patients.  It’s been over 10 years since I’ve seen one.

Anyway, here’s the first version of the bash script program, that I modified from the botany program (so the picture files still redirect from there).  You have to rerun the time file for it to work (have the itunes music directories set up with Vivaldi).  It kind of destresses to alternate between flowers, 4 seasons, and heart information.  And I like the random nature of the program because is sometimes juxtaposes different pieces of information in other ways than they might otherwise present.  I haven”t had a chance to bench it yet.  Not prettty, but it works.

—————————————————————————————————-

The gen_heart_facts.txt file

01c:ANSWER: 120 QUESTION: Blood pressure readings are generally represented as 120/80, for example.  _______ is the systolic blood pressure.
02c: ANSWER: 80 QUESTION: Blood pressure readings are generally represented as 120/80, for example.  _______ is the diastolic blood pressure..
03c: ANSWER: diastolic QUESTION: 70-90 mm Hg is the normal range for the ____________ blood pressure.
04c: ANSWER: systolic QUESTION: 110-130 mm Hg is the normal range for the ____________ blood pressure.
05c: ANSWER: systolic QUESTION: The __________ blood pressure is the pressure required to stop blood flow through the artery, at which point the sound of the heart beat transmits to the stethoscope as the blood pushes against the barrier.
06c: ANSWER: diastolic QUESTION: The __________ blood pressure is the pressure required to restore blood flow through the artery, at which point the sound of the heart beat is no longer detected by the stethoscope because the blood flows through the barrier.
07c: ANSWER: 4 QUESTION: The human heart has ___ chambers.  The 2 halves of the heart are separated by a septum.
08c: ANSWER: atrioventricular QUESTION: The first heart sound occurs when the ______________ valves close.
09c: ANSWER: semilunar QUESTION: The second heart sound occurs when the ___________ valves close.
10c: ANSWER: mitral QUESTION: Rheumatic heart disease can cause mild  ________ valve stenosis (< 1.5 square cm).
11c: ANSWER: Rheumatic QUESTION: ________ heart disease causes leaflet thickening, commissural fusion, and chordal fusion of the mitral valve.
12c: ANSWER: left QUESTION: Mitral stenosis causes a pressure overload in the ______ atrium, because of the obstruction to outflow.
13c: ANSWER: atrial QUESTION: Pulmonary venous hypertension, pulmonary artery hypertension, and right heart failure can all result because of an increase in left _______ pressure.
14c: ANSWER: Atrial QUESTION: ________ fibrillation can occur because of an increase in left atrial size.
15c: ANSWER: stenosis QUESTION: Treatments for mitral valve ___________ may include diuretics, slowing the heart rate, and managing atrial fibrillation.
16c: ANSWER: papillary QUESTION: There are 2 sets of ________ muscles that control the mitral valve: lateral, and medial.
17c: ANSWER: chordae QUESTION: The ________ tendinease attach the papillary muscles to the mitral valve.
18c: ANSWER: dilation QUESTION: In mitral regurgitation, cardiac output is sustained with left ventricular ___________.
19c: ANSWER: regurgitation QUESTION: An operation to repair the mitral valve is the first choice in mitral ____________ if the valve is repairable.
20c: ANSWER: stenosis QUESTION: Approximately 25% of all patients with rheumatic heart disease have pure mitral ________, and an additional 40% have this combined with mitral regurgitation.
21c: ANSWER: rheumatic QUESTION: Rare acquired causes of mitral valve obstruction other than __________ heart disease include left atrial myxoma, ball-valve thrombus, mucopolysaccharidosis, and severe mitral annular calcification.
22c: ANSWER: right QUESTION: Severe pulmonary hypertension results in ______-sided heart failure, with dilation of the right ventricle and its annulus and secondary tricuspid and sometimes pulmonic regurgitation.
23c: ANSWER: fibrillation QUESTION: 30-40% of patients with mitral stenosis develop atrial ______________.
24c: ANSWER: stroke QUESTION: Cardiac output is the product of heart rate and _______ volume.
25c: ANSWER: heartbeat QUESTION: Stroke volume is the volume of blood pumped out of the heart with each ___________.
26c: ANSWER: tachycardia QUESTION: Compensatory ___________ occurs when the heart increases its heart rate in order to compensate for a decrease in stroke volume.
27c: ANSWER: stroke volume QUESTION: At heart rates greater than 150, diastolic filling times become so short that the tachycardia will produce a drop in _______ _________.
28c: ANSWER: contractility QUESTION: Stroke volume is affected by 3 factors: preload, postload, and _____________.
29c: ANSWER: preload QUESTION: Cardiac _________ must be carefully adjusted.   Too little, and the cardiac output will be low, leading to a low ejection fraction.  Too much, and the heart muscle will stretch, leading to cardiac failure.
30c: ANSWER: preload QUESTION: Signs of inadequate _________ include: poor skin turgor, dry mucous memebranes, low urine output, tachycardia, thirst, weak pulses, and flat neck veins.
31c: ANSWER: preload QUESTION: Signs of excess ________ in a patient with adequate cardiac function include distended neck veins, crackles in the lungs, and bounding pulses.
32c: ANSWER: preload QUESTION: Increased _________ in a patient with poor cardiac function presents with crackles in the lungs, an S3 heart sound, low urine output, tachycardia, cold clammy skin with weak pulses, and edema.
33c: ANSWER: dehydration QUESTION: Insufficient preload is commonly called hypovolemia or ____________.
34c: ANSWER: sympathetic QUESTION: When insufficient volume is present in the vascular tree, the _________ nervous system is stimulated to release the catecholemines: epinephrine and norepinephrine.
35c: ANSWER: vasoconstriction QUESTION: The catecholamines epinephrine and norepinephrine cause increased heart rate and arterial ________________.
36c: ANSWER: Afterload QUESTION: ___________ is defined as the resistance that the left ventricle must overcome to eject its load.
37c: ANSWER: resistance QUESTION: The most important determinant of afterload is vascular ____________.
38c: ANSWER: compliance QUESTION: Factors affecting afterload include vascular resistance, blood viscosity, valvular disease, and aortic ____________.
39c: ANSWER: constrict QUESTION: As arterial vessels _________, the afterload increases.
40c: ANSWER: dilate QUESTION: As arterial vessels __________, the afterload decreases.
41c: ANSWER: High QUESTION: ______ afterload increases myocardial work and decreases stroke volume.
42c: ANSWER: high QUESTION: Patients with _______ afterload present with symptoms of arterial vasoconstriction.
43c: ANSWER: vasoconstriction QUESTION: Symptoms of arterial _____________ include cool clammy skin, capillary refill greater than 5 sec, and narrow pulse pressure.
44c: ANSWER: pulse QUESTION: The _______ pressure is calculated by subtracting the diastolic blood pressure from the systolic blood pressure.
45c: ANSWER: 40 QUESTION: The normal pulse pressure at the brachial artery is _____ mm Hg.
46c: ANSWER: work QUESTION: Low afterload decreases cardiac work and increases stroke volume.
47c: ANSWER: low QUESTION: Patients with _____ afterload present with symptoms of arterial dilation.
48c: ANSWER: dilation QUESTION: Symptoms of arterial ________ include warm flushed skin, bounding pulses, and wide pulse pressure.
49c: ANSWER: low QUESTION: If afterload is too ________, hypotension may result.
50c: ANSWER: failure QUESTION:  A key component for treatment of heart __________, is afterload reduction using beta blockers and ACE inhibitors.
51c: ANSWER: resistance QUESTION: By decreasing the __________ to ventricular ejection, cardiac output is increased and myocardial work is decreased.
52c: ANSWER: output QUESTION: Increasing cardiac _________ improves the functional status of heart failure patients.
53c: ANSWER: Contractility QUESTION: ___________ refers to the inherent ability of the heart muscle to contract regardless of preload or afterload.
54c: ANSWER: positive QUESTION: Contractility is enhanced by exercise, catecholamines, and ________ inotropic drugs.
55c: ANSWER: negative QUESTION: Contractility is decreased by hypothermia, hypoxemia, acidosis, and _________ inotropic drugs.
56v: ANSWER: compliance QUESTION: Myocardial ___________ refers to the ability of the ventricle to stretch to receive a given volume of blood.
57c: ANSWER: small QUESTION: A normal ventricle is very compliant: A large change in volume will produce a _______ change in pressure.
58c: ANSWER: small QUESTION: If compliance is low, a _______ change in volume will produce a large change in pressure.
59c: ANSWER: increased QUESTION: If compliance is low (the ventricle cannot stretch), it cannot increase cardiac output with __________ preload.
60c: ANSWER: perfusion QUESTION: Adequate cardiac output is necessary for tissue ____________.

—————————————————————————————————-

The Linux Code

#!/bin/bash
# heartwork.sh v.0.1 a program submitted by livedoggb on 12/23/2012
# dependencies compiled random1.c, intdiv2float.c, botany directory containing a botany_pics subdirectory with jpg pictures of local flora numbered 01 dandelion.jpg 12 prickly poppy.jpg etc.
# a heart subdirectory inside the for_kids directory that has a file named gen_heart_facts.txt
# itunes directory named flower music with songs that you want to use sequentially numbered 01 …, 02 …, 03 … etc.
# a local_flora_txt subdirectory within botany containing files named 01 dandelion.txt, 02 prickly_poppy.txt, etc.
# with the number corresponding to the line number of the verb in the text file.
# It also outputs a file sommaire.out that has the statistics of your session.
dir_path=”/mnt/sdc1″
dir_txt_path=$( echo $dir_path/for_kids/heart )
pic_dir_path=$( echo $dir_path/botany/botany_Houston_pics )
mus_dir_path=$( echo $dir_path/botany/botany_Houston_mus )
temp_path=/root/
if [ -e $temp_path/sommaire.out ]
then
rm $temp_path/sommaire.out
fi
if [ -n $temp_path/botany_own_pics ]
then
mkdir $temp_path/botany_own_pics
fi
if [ -n $temp_path/botany_own_mus ]
then
mkdir $temp_path/botany_own_mus
fi
function set_path {
echo
echo “1.  Use Houston pictures and Verdi’s 4 Seasons.”
echo “2.  Use your own pictures and music moved to the root directory in a”
echo ”    subdirectory called botany_own_pics and botany_own_music.”
echo
echo “Please choose an option.”
read pic_set
case $pic_set in
1)
pic_dir_path=$( echo $pic_dir_path/ )
mus_dir_path=$( echo $mus_dir_path)
;;
2)
pic_dir_path=$( echo $pic_dir_path/$own_dir_path )
mus_dir_path=$( echo $temp_path/botany_own_mus )
;;
esac
return
}

function trim_line {
i=1
echo
#num_words=$(gawk ‘{ sum += $1 }; END { print sum }’ testline.out)
words_left=”c”
while [ “$words_left” != “” ]
do
j=$(( $i + 7 ))
words_left=$( echo $line | cut -d’ ‘ -f$i-$j )
echo $words_left
i=$(( $j + 1 ))
done
return
}

function echo_in_color_br_sentence {
part1=$( echo $testline | sed “s/\(.*_\)_*_\(_.*\)/\1/” )
part2=$( echo $testline | sed “s/\(.*_\)_*_\(_.*\)/$echo_verb/” )
part3=$( echo $testline | sed “s/\(.*_\)_*_\(_.*\)/\2/” )
#”blue”
echo -n -e ‘\E[47;34m'”33[1m$part133[0m”
#”red”
echo -n -e ‘\E[47;31m'”33[1m$part233[0m”
#”blue”
echo -e ‘\E[47;34m'”33[1m$part333[0m”
tput sgr0
return
}

#rm $dir_path/hyper-tense-files_used.out
sum_fautes=0
echo “Please wait for a few minutes while the system sets up the music database.”
if [ -e $dir_path/hyper-tense-flowers-time2.out ]
then
echo “The program has found a time file.”
echo “1. Use this file.”
echo “2. Make a new time file. Choose 2 if you have changed the music.”
echo “Please choose:  (If you aren´t sure, choose 2.  The default is 2.)”
read choice
else
choice=2
fi
if [ -e $choice ]
then
choice=”2″
fi
echo “The best way to end the program in slideshow mode is to press the ESC key.”
echo
case “$choice” in
1)
echo “Using the old file.”
;;
2)
echo “Making another file.  This will take a few minutes.  Please be patient.”
echo
echo
echo “0” > $temp_path/hyper-tense-flowers-time2.out
if [ -n $mus_dir_path/*.* ]
then
echo “A link to your music does not exist in the root file system.  Please fix this.”
else
mplayer -msglevel all=-1 -profile gnome-mplayer -ss 10 -endpos 1 -volume 0 $mus_dir_path/*.* | tee $temp_dir/temp.out | grep “^A: ” | sed -e ‘s/^A: .* of \([0-9]*\).* .*/\1/g’ >> $temp_path/hyper-tense-flowers-time2.out
fi
;;
esac
time_array=($(cat $temp_path/hyper-tense-flowers-time2.out))
i=1
num_files=$(expr $(grep -c . $temp_path/hyper-tense-flowers-time2.out))

i=0
while [ $i -lt $num_files ]
do
echo “$i. ${time_array[$i]}”
i=$(( $i + 1 ))
done
num_files=$(( $num_files – 1 ))
echo “num_files=” $num_files
echo “Several options are possible.  Please choose.”
echo
echo “1. Slideshow”
echo “2. Instruction”
echo “3. Quiz (interactive).”
echo
echo -n “Please choose:”
read choice
#echo  “With quotes? Choose y or n.  Default is n.”
#read with_quotes
#echo “Oral reading? Choose y or n. Default is n.”
#read read_aloud
#echo “With pictures? Choose y or n. Default is y.”
#read show_pics
#echo “With music? Choose y or n. Default is y.”
#read with_music
with_quotes=”n”
read_aloud=”n”
show_pics=”y”
with_music=”y”
more_local_info=”n”
if [ -e $read_aloud ]
then
read_aloud=”n”
fi
if [ -e $with_quotes ]
then
with_quotes=”n”
fi
if [ -e $show_pics ]
then
show_pics=”y”
fi
if [ -e $with_music ]
then
with_music=”y”
fi
case “$choice” in
1)
echo “Slideshow mode.”
set_path
viewnior –slideshow $pic_dir_path/01\ *.jpg < /dev/null &
mplayer -msglevel all=-1 -profile gnome-mplayer -volume 200 “$mus_dir_path”/*.*
;;
2)
echo “Instruction mode.”
set_path
echo “All information derives from gen_botany_facts.txt in the folder botany.”
c=””
right=0
asked=0
rightverbs=””
wrongverbs=””
average=0
verb_guess=””
num_vfiles=$(expr $(ls -1  $pic_dir_path/*.jpg | grep -c . ))
echo “num_vfiles=” $num_vfiles
hours_bgn=$( date| sed “s/.* \(..\):\(..\):\(..\).*/\1/”| sed “s/0\([0-9]\)/\1/” )
min_bgn=$( date| sed “s/.* \(..\):\(..\):\(..\).*/\2/”| sed “s/0\([0-9]\)/\1/” )
sec_bgn=$( date| sed “s/.* \(..\):\(..\):\(..\).*/\3/”| sed “s/0\([0-9]\)/\1/” )

while [ -e $c ]
do
if [ -e $dir_txt_path/gen_botany_facts.txt ]
then
maxlinenum=$( grep -c . $dir_txt_path/gen_botany_facts.txt)
#maxlinenum=$(( $maxlinenum – 1  ))
quizfact=$( $dir_path/random1 1 $maxlinenum)
correctquizfact=$( echo “$quizfact”c)
omit_line=$( grep “^$correctquizfact:” $dir_txt_path/gen_botany_facts.txt)
#      echo “random quiz line is:” $quizfact $correctquizfact
if [ “$omit_line” != “” ]
then
#echo “The verb is: ” $verb
echo “Random quiz line is:” $quizfact

testline=$( grep “^$correctquizfact:” $dir_txt_path/gen_botany_facts.txt | sed -e “s/^.*QUESTION:\(.*\)/\1/” )
line=$testline
echo_verb=$( grep “^$correctquizfact:” $dir_txt_path/gen_botany_facts.txt | sed -e “s/^.*ANSWER:\(.*\) QUESTION:.*/\1/” )
echo_in_color_br_sentence

asked=$(( $asked + 1 ))
echo “Press enter to continue (enter e to exit):”
read verb_guess
if [ “$verb_guess” == “e” ]
then
break
fi
verb_guess=$echo_verb
if [ $verb_guess == $echo_verb ]
then
echo “Correct.”
right=$(( $right + 1 ))
average=$(( $right/$asked ))
rightverbs=$( echo $rightverbs, $echo_verb)
if [ $show_pics == “y” ]
then
random_verb_num=$( $dir_path/random1 1 $num_vfiles)
fn=$random_verb_num
#fn=1
echo “random_pic_num is:” $random_verb_num
verb=$(ls $pic_dir_path/$fn\ *.jpg | sed “s/^.*$fn \(.*\).jpg/\1/” )
echo $verb
mypid=$$
viewnior $pic_dir_path/$fn\ *.jpg < /dev/null &
cpid=$!
if [ $more_local_info == “y” ]
then
random_verb_num=$( $dir_path/random1 1 5)
echo “random verb num is ” $random_verb_num
fn=$random_verb_num
if [ -e $dir_txt_path/local_flora_facts/$fn\ *.txt ]
then
num_facts=$( grep -c . $dir_txt_path/local_flora_facts/$fn\ *.txt )
echo “I am in this loop.” $num_facts
num_facts=$(( $num_facts – 1 ))
picked_fact=$( $dir_path/random1 1 $num_facts )
correctquote=$( echo “$picked_fact”c )
dfact=$( grep “^$correctquote:” $dir_txt_path/local_flora_facts/$fn\ *.txt | sed “s/^.*c://” )
xmessage -timeout 30 $dfact < /dev/null &
fi
fi
fi
if [ $with_music == “y” ]
then
num_mus=$( $dir_path/random1 1 $num_files )
num_mus_fixed=$(echo $num_mus | sed -e “s/^0//”)
prob_time=$(( ${time_array[$num_mus_fixed]} – 20 ))
ssx=($(expr $($dir_path/random1 0 $prob_time)))

mplayer -msglevel all=-1 -profile gnome-mplayer -ss $ssx -endpos 30 -volume 200 “$mus_dir_path”/$num_mus*.*
fi
kill -s SIGTERM $cpid
if [ $with_quotes == “y” ]
then
num_quotes=$( grep -c . $dir_txt_path/environmental_quotes.txt )
picked_quote=$( $dir_path/random1 1 $num_quotes )
correctquote=$( echo “$picked_quote”c )
dquote=$( grep “^$correctquote:” $dir_txt_path/environmental_quotes.txt | sed “s/^.*c://”)
xmessage -timeout 30 $dquote < /dev/null &
fi
else
echo “No.  The correct answer is:” $echo_verb
wrongverbs=$( echo $wrongverbs, $echo_verb )
fi
if [ $read_aloud == “y” ]
then
repeat=”y”
if [ -e /mnt/sda1/Documents\ and\ Settings/TEMP/My\ Documents/My\ Music/aaenglish\ highlit/$verb$quizfact.* ]
then
while [ $repeat == “y” ]
do
mplayer -volume 80 /mnt/sda1/Documents\ and\ Settings/TEMP/My\ Documents/My\ Music/aaenglish\ highlit/$verb$quizfact.*
echo “Write the sentences that you heard on paper.  Repeat? (y or n. The default is n.)”
read repeat
if [ -e $repeat]
then
repeat=”n”
fi

done
echo
#$shighlit=$(grep “^$correctquizfact:” $dir_txt_path/$fn*.txt | sed -e “s/^.* SHIGHLIT:\(.*\)TRANSSHIGHLIT:.*/\1/”)
#$echo $shighlit
#$echo
#$echo “Count the number of mistakes in what you wrote. One point for every word.”
#$echo How many errors?
#$read fault_number
if [ -e $fault_number ]
then
fault_number=0
fi
sum_faults=$(( $sum_faults + $fault_number ))
fi
fi
#$trans_sent=$(grep “^$correctquizfact:” $dir_txt_path/$fn*.txt | sed -e “s/^.*ETSENT1:\(.*\)ETSENT2:.*/\1/”)
#
echo
#$shighlit=$(grep “^$correctquizfact:” $dir_txt_path/$fn*.txt | sed -e “s/^.* SHIGHLIT:\(.*\)TRANSSHIGHLIT:.*/\1/”)
#$echo $shighlit
#echo
#echo “Please finish by reading the above sentence out loud.”
#read
echo “The line number is:” $quizfact
#echo $testline | sed “s/.*(\(.*\)).*/\1/”
#                echo $testline | sed “s/\(.*[ |^]_\)_*_\(_.*\)/\1$echo_verb\2/”
#                echo $testline | sed “s/\(.*_\)_*_\(_.*\)/\1$echo_verb\2/”
#                echo_in_color_br_sentence
#echo $trans_sent
aver_right=$( $dir_path/intdiv2float $right $asked | sed -e “s/\([0-9]*\…\).*/\1/” )
echo $right “/” $asked ” correct.  Batting average:” $aver_right “Dictation errors: ” $sum_faults
echo “Please wait…I’m looking for another question…”
fi
fi
done
hours_end=$( date| sed “s/.* \(..\):\(..\):\(..\).*/\1/”| sed “s/0\([0-9]\)/\1/” )
min_end=$( date| sed “s/.* \(..\):\(..\):\(..\).*/\2/”| sed “s/0\([0-9]\)/\1/” )
sec_end=$( date| sed “s/.* \(..\):\(..\):\(..\).*/\3/”| sed “s/0\([0-9]\)/\1/” )
hours_diff=$(( $hours_end – $hours_bgn ))
min_diff=$(( $min_end – $min_bgn ))
sec_diff=$(( $sec_end – $sec_bgn ))
midnight=12
if [ $hours_diff -lt 0 ]
then
hours_diff=$(( $(( $midnight – $hours_bgn )) + $hours_end ))
# fix hour change if it happens at midnight or noon,
fi
time_of_ans=$(( $hours_diff * 60 + $min_diff ))
aver_time=$( $dir_path/intdiv2float $time_of_ans $((asked – 1)) | sed -e “s/\([0-9]*\…\).*/\1/” )

echo “You worked ” $time_of_ans “minutes for an average of: ” $aver_time “minutes per question, and a sum of ” $(($asked – 1)) “questions.” | tee >>$temp_path/sommaire.out
echo “The correct answers (” $right “):” $rightverbs  | tee >>$temp_path/sommaire.out
wrong=$(( $asked – $right – 1 ))
echo “The incorrect answers (” $wrong “):” $wrongverbs | tee >>$temp_path/sommaire.out
num_entries=$(grep “^[0-9]*c:” $dir_txt_path/*.txt | grep -c .)
echo “The database had ” $num_entries “entries.” | tee >>$temp_path/sommaire.out
echo “Your percentage: ” $aver_right | tee >>$temp_path/sommaire.out
cat $temp_path/sommaire.out
echo “Life is a tree. You are a meristem.  How would you like to differentiate from here?”
echo “Choices are:”
echo “1. Painting a picture of a flower.”
echo “2. Yoga or prayer activity.”
echo “3. Nature walk with dogs and camera.”
echo “4. Gardening activity.”
echo “5. Relaxation or sleep.”
echo
echo “Enter a number, or enter R to have the computer randomly choose an activity.”
read choice
if [ $choice == “R” ]
then
comp_choice=$( $dir_path/random1 1 5 )
echo “You won the lottery! The random choice was: $comp_choice.  Enjoy your activity!”
#fi
else
echo “You chose $choice.  Enjoy your activity.”
fi
;;
3)
echo “Quiz mode.”
set_path
echo “All information derives from gen_heart_facts.txt in the folder hearts.”
c=””
right=0
asked=0
rightverbs=””
wrongverbs=””
average=0
verb_guess=””
num_vfiles=$(expr $(ls -1  $pic_dir_path/*.jpg | grep -c . ))
echo “num_vfiles=” $num_vfiles
hours_bgn=$( date| sed “s/.* \(..\):\(..\):\(..\).*/\1/”| sed “s/0\([0-9]\)/\1/” )
min_bgn=$( date| sed “s/.* \(..\):\(..\):\(..\).*/\2/”| sed “s/0\([0-9]\)/\1/” )
sec_bgn=$( date| sed “s/.* \(..\):\(..\):\(..\).*/\3/”| sed “s/0\([0-9]\)/\1/” )

while [ -e $c ]
do
if [ -e $dir_txt_path/gen_heart_facts.txt ]
then
maxlinenum=$( grep -c . $dir_txt_path/gen_heart_facts.txt)
#maxlinenum=$(( $maxlinenum – 1  ))
quizfact=$( $dir_path/random1 1 $maxlinenum)
correctquizfact=$( echo “$quizfact”c)
omit_line=$( grep “^$correctquizfact:” $dir_txt_path/gen_heart_facts.txt)
#      echo “random quiz line is:” $quizfact $correctquizfact
if [ “$omit_line” != “” ]
then
#echo “The verb is: ” $verb
echo “Random quiz line is:” $quizfact

testline=$( grep “^$correctquizfact:” $dir_txt_path/gen_heart_facts.txt | sed -e “s/^.*QUESTION:\(.*\)/\1/” )
line=$testline
trim_line
verb_guess=””
asked=$(( $asked + 1 ))
while [ -e $verb_guess ]
do
echo “Enter your answer (enter e to exit):”
read verb_guess
done
if [ “$verb_guess” == “e” ]
then
break
fi
echo_verb=$( grep “^$correctquizfact:” $dir_txt_path/gen_heart_facts.txt | sed -e “s/^.*ANSWER:\(.*\) QUESTION:.*/\1/” )
if [ $verb_guess == $echo_verb ]
then
echo “Correct.”
right=$(( $right + 1 ))
average=$(( $right/$asked ))
rightverbs=$( echo $rightverbs, $echo_verb)
if [ $show_pics == “y” ]
then
random_verb_num=$( $dir_path/random1 1 $num_vfiles)
fn=$random_verb_num
#fn=1
echo “random_pic_num is:” $random_verb_num
verb=$(ls $pic_dir_path/$fn\ *.jpg | sed “s/^.*$fn \(.*\).jpg/\1/” )
echo $verb
mypid=$$
viewnior $pic_dir_path/$fn\ *.jpg < /dev/null &
cpid=$!
if [ $more_local_info == “y” ]
then
random_verb_num=$( $dir_path/random1 1 5)
echo “random verb num is ” $random_verb_num
fn=$random_verb_num
if [ -e $dir_txt_path/local_flora_facts/$fn\ *.txt ]
then
num_facts=$( grep -c . $dir_txt_path/local_flora_facts/$fn\ *.txt )
echo “I am in this loop.” $num_facts
num_facts=$(( $num_facts – 1 ))
picked_fact=$( $dir_path/random1 1 $num_facts )
correctquote=$( echo “$picked_fact”c )
dfact=$( grep “^$correctquote:” $dir_txt_path/local_flora_facts/$fn\ *.txt | sed “s/^.*c://” )
xmessage -timeout 30 $dfact < /dev/null &
fi
fi
fi
if [ $with_music == “y” ]
then
num_mus=$( $dir_path/random1 1 $num_files )
num_mus_fixed=$(echo $num_mus | sed -e “s/^0//”)
prob_time=$(( ${time_array[$num_mus_fixed]} – 20 ))
ssx=($(expr $($dir_path/random1 0 $prob_time)))

mplayer -msglevel all=-1 -profile gnome-mplayer -ss $ssx -endpos 30 -volume 200 “$mus_dir_path”/$num_mus*.*
fi
kill -s SIGTERM $cpid
if [ $with_quotes == “y” ]
then
num_quotes=$( grep -c . $dir_txt_path/environmental_quotes.txt )
picked_quote=$( $dir_path/random1 1 $num_quotes )
correctquote=$( echo “$picked_quote”c )
dquote=$( grep “^$correctquote:” $dir_txt_path/environmental_quotes.txt | sed “s/^.*c://”)
xmessage -timeout 30 $dquote < /dev/null &
fi
else
echo “No.  The correct answer is:” $echo_verb
wrongverbs=$( echo $wrongverbs, $echo_verb )
fi
if [ $read_aloud == “y” ]
then
repeat=”y”
if [ -e /mnt/sda1/Documents\ and\ Settings/TEMP/My\ Documents/My\ Music/aaenglish\ highlit/$verb$quizfact.* ]
then
while [ $repeat == “y” ]
do
mplayer -volume 80 /mnt/sda1/Documents\ and\ Settings/TEMP/My\ Documents/My\ Music/aaenglish\ highlit/$verb$quizfact.*
echo “Write the sentences that you heard on paper.  Repeat? (y or n. The default is n.)”
read repeat
if [ -e $repeat]
then
repeat=”n”
fi

done
echo
#$shighlit=$(grep “^$correctquizfact:” $dir_txt_path/$fn*.txt | sed -e “s/^.* SHIGHLIT:\(.*\)TRANSSHIGHLIT:.*/\1/”)
#$echo $shighlit
#$echo
#$echo “Count the number of mistakes in what you wrote. One point for every word.”
#$echo How many errors?
#$read fault_number
if [ -e $fault_number ]
then
fault_number=0
fi
sum_faults=$(( $sum_faults + $fault_number ))
fi
fi
#$trans_sent=$(grep “^$correctquizfact:” $dir_txt_path/$fn*.txt | sed -e “s/^.*ETSENT1:\(.*\)ETSENT2:.*/\1/”)
#
echo
#$shighlit=$(grep “^$correctquizfact:” $dir_txt_path/$fn*.txt | sed -e “s/^.* SHIGHLIT:\(.*\)TRANSSHIGHLIT:.*/\1/”)
#$echo $shighlit
#echo
#echo “Please finish by reading the above sentence out loud.”
#read
echo “The line number is:” $quizfact
#echo $testline | sed “s/.*(\(.*\)).*/\1/”
#                echo $testline | sed “s/\(.*[ |^]_\)_*_\(_.*\)/\1$echo_verb\2/”
#                echo $testline | sed “s/\(.*_\)_*_\(_.*\)/\1$echo_verb\2/”
echo_in_color_br_sentence
#echo $trans_sent
aver_right=$( $dir_path/intdiv2float $right $asked | sed -e “s/\([0-9]*\…\).*/\1/” )
echo $right “/” $asked ” correct.  Batting average:” $aver_right “Dictation errors: ” $sum_faults
echo “Please wait…I’m looking for another question…”
fi
fi
done
hours_end=$( date| sed “s/.* \(..\):\(..\):\(..\).*/\1/”| sed “s/0\([0-9]\)/\1/” )
min_end=$( date| sed “s/.* \(..\):\(..\):\(..\).*/\2/”| sed “s/0\([0-9]\)/\1/” )
sec_end=$( date| sed “s/.* \(..\):\(..\):\(..\).*/\3/”| sed “s/0\([0-9]\)/\1/” )
hours_diff=$(( $hours_end – $hours_bgn ))
min_diff=$(( $min_end – $min_bgn ))
sec_diff=$(( $sec_end – $sec_bgn ))
midnight=12
if [ $hours_diff -lt 0 ]
then
hours_diff=$(( $(( $midnight – $hours_bgn )) + $hours_end ))
# fix hour change if it happens at midnight or noon,
fi
time_of_ans=$(( $hours_diff * 60 + $min_diff ))
aver_time=$( $dir_path/intdiv2float $time_of_ans $((asked – 1)) | sed -e “s/\([0-9]*\…\).*/\1/” )

echo “You worked ” $time_of_ans “minutes for an average of: ” $aver_time “minutes per question, and a sum of ” $(($asked – 1)) “questions.” | tee >>$temp_path/sommaire.out
echo “The correct answers (” $right “):” $rightverbs  | tee >>$temp_path/sommaire.out
wrong=$(( $asked – $right – 1 ))
echo “The incorrect answers (” $wrong “):” $wrongverbs | tee >>$temp_path/sommaire.out
num_entries=$(grep “^[0-9]*c:” $dir_txt_path/*.txt | grep -c .)
echo “The database had ” $num_entries “entries.” | tee >>$temp_path/sommaire.out
echo “Your percentage: ” $aver_right | tee >>$temp_path/sommaire.out
cat $temp_path/sommaire.out
echo “Life is a tree. You are a meristem.  How would you like to differentiate from here?”
echo “Choices are:”
echo “1. Painting a picture of a flower.”
echo “2. Yoga or prayer activity.”
echo “3. Nature walk with dogs and camera.”
echo “4. Gardening activity.”
echo “5. Relaxation or sleep.”
echo
echo “Enter a number, or enter R to have the computer randomly choose an activity.”
read choice
if [ $choice == “R” ]
then
comp_choice=$( $dir_path/random1 1 5 )
echo “You won the lottery! The random choice was: $comp_choice.  Enjoy your activity!”
#fi
else
echo “You chose $choice.  Enjoy your activity.”
fi
;;
esac

Advertisements
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s