emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[O] execute sbe macro fails


From: Torsten Wagner
Subject: [O] execute sbe macro fails
Date: Sat, 13 Jul 2013 22:57:44 +0200

Hi,

I wrote a python code block which should translate scores into marks.
The python code seems to work. It takes two arguments. The reached score (out of 100) as well as how many scores where needed to pass. Starting from that, higher grades are calculated on a even base.

I want to call the python block for each row using the sbe macro
However, this results in an error and I can't see why

| Name | ID   | 1.1 | 1.2 | 1.3 | 1.4 | 2.1 | 2.2 | 2.3 | 2.4 | 2.5 | Extra | Sum | Mark |
|---------------------+------------+-----+-----+-----+-----+-----+-----+-----+-----+-----+-------+-------+--------|
| Name1 |     111111 |  10 |  10 |  10 |  12 |  12 |   3 |   4 |  12 |   3 |     2 |    78 | #ERROR |
| Name2 |     22222 |     |     |     |     |     |     |     |     |     |       |     0 | #ERROR |
| Name3 |     33333 |     |     |     |     |     |     |     |     |     |       |     0 | #ERROR |
#+TBLFM: $14='(sbe score2mark (score $13) (passscore 50))

#+name: score2mark(score, passscore)
#+begin_src python
def score2mark(score, passscore):
    marklist = [5, 4.3, 4, 3.7, 3.3, 3, 2.7 ,2.3, 2, 1.7, 1.3, 1]
    step=(100-passscore)/(len(marklist)-1)
    if  score < passscore:
           return marklist[0]
    for mark in marklist[1:]:
           if round(passscore) <= score <= round(passscore+step):
               return mark
           else:
                  passscore += step
    return -1
#+end_src

Any idea what I am doing wrong? I tried different versions with "score2mark" some additional brackets etc. However, no luck yet.

Thanks for help

Torsten
 

reply via email to

[Prev in Thread] Current Thread [Next in Thread]