This content has been marked as final. Show 10 replies
OK, I have managed to solve half of the problem, the b part (Give a grade for each question ( 5 for single correct answers, 2,5 for each of the double words, and 0 for wrong) as follows:
answer = member("answer").text
correct1 = ["one","two","three,four"] -- correct answers worth full 5 points
correct2 = ["three"] -- correct answers worth half (2.5) points
CASE TRUE OF
(correct1.getPos(member("answer").text) <> 0):
grade = 1
(correct2.getPos(member("test").text) <> 0):
grade = (0.5).float
the floatPrecision = 1
grade = 0
put grade & RETURN after field "test2" -- this is where I record the grades for each question so i can later add them. Any ideas how to do that? I mean how to add up integers and floating numbers stored in a field?
Anyone? I guess what i am asking should be trivial but i can not find a way to make it work!
OK This is the format of my field member:
I tried this code below, but I got compeltely irrelevant results.
tText = member("answer").text
maxLines = tText.line.count
repeat with i = 1 to maxLines
total = integer(tText.line + tText.line[maxLines])
I'd probably go for some form of global list to keep track of the answers then add up the results from the list.
g_test_answers = [:]
test_answer = [:]
test_answer.addProp( #question_num, 1 )
test_answer.addProp( #answers, ["Lacedaemon", "replica", "destroyed"] )
test_answer.addProp( #score, 5 )
g_test_answers.addProp( 1, test_answer )
total_score = 0
repeat with answer in g_test_answers
total_score = total_score + answer[#score]
thanks for your reply, is it possible to help me a bit more with your script please? I am a bit confused on that properties that you have used in your list. Also, I am not sure from where do you read the contents of the answer field in which the user types in his answer.
As I haven't used any property lists before, I find it extremely hard to figure out what is going on. Please either provide me with a more complete example or help me to understand your code. Many thanks for all your help so far!
As I am not sure how to make the script suggested by McFazstp to work can someone please suggest me a solution on what I Have implemented? Add the integers and floating numbers in a field member?
the plus-sign adds numbers.
a textmember or fieldmember contains string
you have to convert the lines in the field, which are the operands of
the sum, to a number (be it float or integer) and then add up. Not the
other way around like you have now.
Though it's hard to judge from here, I'd brush up on (property)lists and
go with something McFazstp suggest. In the end it's way more flexible
then most or any other solution(s).
Take a look at Dean Utian's tutorials
( http://www.fbe.unsw.edu.au/Learning/Director/) or director-online.com's
article database for the better learning experience :)
> As I am not sure ho wto make the script suggested by McFazstp to work can someone please suggest me a solution on what I Have implemented? Add the integers and floating numbers in a field member?
Here is the answer for anyone that may need it:
Hi wgb, my post was just a suggestion, sorry if the details were a bit confusing.
Basically I was creating a property list of property lists. The sub lists contain the answers to a particular question. For example if you wanted to check their answers for question 1.
put getAnswer( 1 )
-- ["Lacedaemon", "replica", "destroyed"]
put getAnswer( 2 )
on getAnswer( answer_num )
answer = g_test_answers.getAProp( answer_num )
if NOT ( answer.ilk = #propList ) then