emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* execute sbe macro fails
@ 2013-07-13 20:57 Torsten Wagner
  2013-07-14 22:24 ` Eric Schulte
  0 siblings, 1 reply; 3+ messages in thread
From: Torsten Wagner @ 2013-07-13 20:57 UTC (permalink / raw)
  To: Org Mode Mailing List

[-- Attachment #1: Type: text/plain, Size: 1570 bytes --]

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

[-- Attachment #2: Type: text/html, Size: 1830 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2013-07-15  9:38 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-07-13 20:57 execute sbe macro fails Torsten Wagner
2013-07-14 22:24 ` Eric Schulte
2013-07-15  9:35   ` Torsten Wagner

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).