From mboxrd@z Thu Jan 1 00:00:00 1970 From: Matt Price Subject: Re: Showing Property in headline; generating table from properties; exporting table to CSV Date: Thu, 6 Aug 2015 13:27:20 -0400 Message-ID: References: Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=001a113df88eecc758051ca7d43a Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:57617) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZNOwu-0001T8-AH for emacs-orgmode@gnu.org; Thu, 06 Aug 2015 13:27:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZNOwr-0001nr-Pz for emacs-orgmode@gnu.org; Thu, 06 Aug 2015 13:27:24 -0400 Received: from mail-io0-x22f.google.com ([2607:f8b0:4001:c06::22f]:36437) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZNOwr-0001n6-H3 for emacs-orgmode@gnu.org; Thu, 06 Aug 2015 13:27:21 -0400 Received: by ioeg141 with SMTP id g141so88137875ioe.3 for ; Thu, 06 Aug 2015 10:27:21 -0700 (PDT) In-Reply-To: List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: John Kitchin Cc: Org Mode --001a113df88eecc758051ca7d43a Content-Type: text/plain; charset=UTF-8 This is fantastic, but it turns out my use case is a little more complex than I thought & I've now bnaged my head against it for a hwile, might as well ask you for help! I have non-assignment level-1 headlines in my comments.org files: * Introduction let me explain how this system works... and here is some code to generate the grading templates * Assignment 1 ** Student 1 ** Student 2 * Assignment 2 ** Student 1 ** Student 2 ...etc. Solution: add a tag to Assignment headlines :ASSIGNMENT and search that way: (setq assignments '()) (setq students '()) ;; get assignments (org-map-entries (lambda () (when (member "ASSIGNMENT" (org-get-tags-at (point) 'local)) ;; (= 1 (nth 0 (org-heading-components))) (add-to-list 'assignments (nth 4 (org-heading-components)) t)))) But there are also level-2 headings that shouldn't be added to the student list, and I have trouble with that part: (org-map-entries (lambda () (when (member "ASSIGNMENT" (org-element-property :tags (org-element-lineage (org-element-at-point) 'headline))) (add-to-list 'students (cons (nth 4 (org-heading-components)) '()) t)))) does not work, for instance; nor does: (org-map-entries (lambda () (when (member "ASSIGNMENT" (org-get-tags-at (save-excursion (org-up-heading-safe)) 'local)) (add-to-list 'students (cons (nth 4 (org-heading-components)) '()) t)))) What's the best way to check the tags of the parents of a headline from withing org-map-entries? On Thu, Aug 6, 2015 at 9:52 AM, John Kitchin wrote: > This gets you pretty close to what you want. I changed some grades to > make it easier to see it is doing the right thing. > > #+BEGIN_SRC emacs-lisp > (setq assignments '()) > (setq students '()) > > ;; get assignments > (org-map-entries > (lambda () > (when (= 1 (nth 0 (org-heading-components))) > (add-to-list 'assignments (nth 4 (org-heading-components)) t)))) > > ;; get student names as list of cons cells > (org-map-entries > (lambda () > (when (= 2 (nth 0 (org-heading-components))) > (add-to-list 'students (cons (nth 4 (org-heading-components)) '()) > t)))) > > > ;;loop over entries > (dolist (assignment assignments) > (save-excursion > ;; jump to assignment > (org-open-link-from-string (format "[[*%s]]" assignment)) > ;; map over entries > (org-map-entries > (lambda () > (let* ((student (car (assoc (nth 4 (org-heading-components)) > students)))) > (when student > (setf (cdr (assoc student students)) > (append (cdr (assoc student students)) > (list (org-entry-get (point) "GRADE"))))))) > nil 'tree))) > > (setq gradebook > (append (list (append '("Student") assignments) > 'hline) > students)) > > (orgtbl-to-csv gradebook nil) > #+END_SRC > > #+RESULTS: > : Student,Definition,Darwin > : Student One,10,40 > : Student Two,20,50 > : Student Three,30,60 > > > > Matt Price writes: > > > Hello eveyrone! > > > > I know the big guns are all working on last-minute 8.3 bugs (thank you!). > > > > I am hoping to get some guidance before heading off on vacation. I have > > switched over to doing all grading for my courses in org. My workflow: > > > > - export a csv file containing student names. > > - generate grading templates for each student, for each assignment > > - email comments back to students > > - enter marks in an official spreadsheet which can be used for final > grade > > submission > > > > A sample "Comments.org" is at the bottom of this email (it was a little > > long). > > > > So, here are my questions: > > > > - I currently store my grades as properties of level-2 headlines. > However, > > I would really like to be able to see the grades when the headline is > > folded, so I can have a quick visual sense of how many papers I've > marked, > > how well the students are doing, and so forth. THe best would be to be > > able to see the actual marks in the headlines; but if I could, say, > adjust > > the color of the healdine based on the property value, that would be cool > > too. > > > > - It seems silly to record the grades once in org, and then again in a > > libreoffice spreadsheet. Better would be to generate a table and/or csv > > spreadsheet directly from the headlines and property values. So, the > > example below would give the table: > > | Student | Definition | Darwin | > > | Student One | 0 | 0 | > > | Student Two | 0 | 0 | > > | Student Three | 0 | 0 | > > > > and from there I guess I could generate a CSV just with org-table-export. > > > > Had anyone done either of these tasks before? Any guidance on how to do > > it? > > > > Thanks as always, > > Matt > > > > ------------------------------------------ > > * Definition > > ** TODO Student One > > :PROPERTIES: > > :GRADE: 0 > > :MAIL_TO: student.one@utoronto.edu > > :MAIL_CC: matt.price@utoronto.ca > > :MAIL_REPLY: matt.price@utoronto.ca > > :MAIL_SUBJECT: Comments on Definition Assignment (Student One) > > :END: > > - Organization :: > > - Clarity of Thesis :: > > - Presentation of Evidence :: > > - Grammar and Spelling :: > > - Style :: > > - Citations :: > > - Further Comments :: > > - Grade :: > > ** TODO Student Two > > :PROPERTIES: > > :GRADE: 0 > > :MAIL_TO: student.two@utoronto.edu > > :MAIL_CC: matt.price@utoronto.ca > > :MAIL_REPLY: matt.price@utoronto.ca > > :MAIL_SUBJECT: Comments on Definition Assignment (Student Two) > > :END: > > - Organization :: > > - Clarity of Thesis :: > > - Presentation of Evidence :: > > - Grammar and Spelling :: > > - Style :: > > - Citations :: > > - Further Comments :: > > - Grade :: > > ** TODO Student Three > > :PROPERTIES: > > :GRADE: 0 > > :MAIL_TO: student.three@utoronto.edu > > :MAIL_CC: matt.price@utoronto.ca > > :MAIL_REPLY: matt.price@utoronto.ca > > :MAIL_SUBJECT: Comments on Definition Assignment (Student Three) > > :END: > > - Organization :: > > - Clarity of Thesis :: > > - Presentation of Evidence :: > > - Grammar and Spelling :: > > - Style :: > > - Citations :: > > - Further Comments :: > > - Grade :: > > > > > > * Darwin > > ** TODO Student One > > :PROPERTIES: > > :GRADE: 0 > > :MAIL_TO: student.one@utoronto.edu > > :MAIL_CC: matt.price@utoronto.ca > > :MAIL_REPLY: matt.price@utoronto.ca > > :MAIL_SUBJECT: Comments on Darwin Assignment (Student One) > > :END: > > - Organization :: > > - Clarity of Thesis :: > > - Presentation of Evidence :: > > - Grammar and Spelling :: > > - Style :: > > - Citations :: > > - Further Comments :: > > - Grade :: > > ** TODO Student Two > > :PROPERTIES: > > :GRADE: 0 > > :MAIL_TO: student.two@utoronto.edu > > :MAIL_CC: matt.price@utoronto.ca > > :MAIL_REPLY: matt.price@utoronto.ca > > :MAIL_SUBJECT: Comments on Darwin Assignment (Student Two) > > :END: > > - Organization :: > > - Clarity of Thesis :: > > - Presentation of Evidence :: > > - Grammar and Spelling :: > > - Style :: > > - Citations :: > > - Further Comments :: > > - Grade :: > > ** TODO Student Three > > :PROPERTIES: > > :GRADE: 0 > > :MAIL_TO: student.three@utoronto.edu > > :MAIL_CC: matt.price@utoronto.ca > > :MAIL_REPLY: matt.price@utoronto.ca > > :MAIL_SUBJECT: Comments on Darwin Assignment (Student Three) > > :END: > > - Organization :: > > - Clarity of Thesis :: > > - Presentation of Evidence :: > > - Grammar and Spelling :: > > - Style :: > > - Citations :: > > - Further Comments :: > > - Grade :: > > --------------------------------------------- > > > > I have three remaining issues > > -- > Professor John Kitchin > Doherty Hall A207F > Department of Chemical Engineering > Carnegie Mellon University > Pittsburgh, PA 15213 > 412-268-7803 > @johnkitchin > http://kitchingroup.cheme.cmu.edu > --001a113df88eecc758051ca7d43a Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
This is = fantastic, but it turns out my use case is a little more complex than I tho= ught & I've now bnaged my head against it for a hwile, might as wel= l ask you for help!

I have non-assignment level-1 headlines in= my comments.org files:

* = Introduction
let me explain how this system works... and here is s= ome code to generate the grading templates

* Assignment 1
<= /div>** Student 1
** Student 2
* Assignment 2
** Student 1** Student 2

...etc.

Solution: add a tag to Ass= ignment headlines :ASSIGNMENT and search that way:

=C2=A0 (setq ass= ignments '())
=C2=A0 (setq students '())

=C2=A0 ;; get as= signments
=C2=A0 (org-map-entries
=C2=A0=C2=A0 (lambda ()
=C2=A0= =C2=A0=C2=A0=C2=A0 (when=C2=A0 (member "ASSIGNMENT" (org-get-tags= -at (point) 'local)) ;; (=3D 1 (nth 0 (org-heading-components)))
=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (add-to-list 'assignments (nth 4 (org= -heading-components)) t))))


But there are also level= -2 headings that shouldn't be added to the student list, and I have tro= uble with that part:

=C2=A0(org-map-entries
=C2=A0=C2=A0 (lambda = ()
=C2=A0=C2=A0=C2=A0=C2=A0 (when (member "ASSIGNMENT" (org-el= ement-property :tags (org-element-lineage (org-element-at-point) 'headl= ine)))
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (add-to-list 'students (= cons=C2=A0 (nth 4 (org-heading-components)) '()) t))))

does not work, for instance; nor does:

(org-m= ap-entries
=C2=A0=C2=A0 (lambda ()
=C2=A0=C2=A0=C2=A0=C2=A0 (when (me= mber "ASSIGNMENT" (org-get-tags-at (save-excursion (org-up-headin= g-safe)) 'local))
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (add-to-list = 'students (cons=C2=A0 (nth 4 (org-heading-components)) '()) t))))=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 =
What's the best way to check the t= ags of the parents of a headline from withing org-map-entries?=C2=A0

On Thu, Aug 6, 2015 at 9:52 AM, John Kitchin <j= kitchin@andrew.cmu.edu> wrote:
This gets you pretty close to what you want. I changed some grades to make it easier to see it is doing the right thing.

#+BEGIN_SRC emacs-lisp
(setq assignments '())
(setq students '())

;; get assignments
(org-map-entries
=C2=A0(lambda ()
=C2=A0 =C2=A0(when (=3D 1 (nth 0 (org-heading-components)))
=C2=A0 =C2=A0 =C2=A0(add-to-list 'assignments (nth 4 (org-heading-compo= nents)) t))))

;; get student names as list of cons cells
(org-map-entries
=C2=A0(lambda ()
=C2=A0 =C2=A0(when (=3D 2 (nth 0 (org-heading-components)))
=C2=A0 =C2=A0 =C2=A0(add-to-list 'students (cons=C2=A0 (nth 4 (org-head= ing-components)) '()) t))))


;;loop over entries
(dolist (assignment assignments)
=C2=A0 (save-excursion
=C2=A0 =C2=A0 ;; jump to assignment
=C2=A0 =C2=A0 (org-open-link-from-string (format "[[*%s]]" assign= ment))
=C2=A0 =C2=A0 ;; map over entries
=C2=A0 =C2=A0 (org-map-entries
=C2=A0 =C2=A0 =C2=A0(lambda ()
=C2=A0 =C2=A0 =C2=A0 =C2=A0(let* ((student (car (assoc (nth 4 (org-heading-= components)) students))))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(when student
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(setf (cdr (assoc student students= ))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(append (cdr = (assoc student students))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0(list (org-entry-get (point) "GRADE")))))))
=C2=A0 =C2=A0 =C2=A0nil 'tree)))

(setq gradebook
=C2=A0 =C2=A0 =C2=A0 (append (list=C2=A0 (append '("Student")= assignments)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0'hline)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 students))

(orgtbl-to-csv gradebook nil)
#+END_SRC

#+RESULTS:
: Student,Definition,Darwin
: Student One,10,40
: Student Two,20,50
: Student Three,30,60



Matt Price writes:

> Hello eveyrone!
>
> I know the big guns are all working on last-minute 8.3 bugs (thank you= !).
>
> I am hoping to get some guidance before heading off on vacation.=C2=A0= I have
> switched over to doing all grading for my courses in org.=C2=A0 My wor= kflow:
>
> - export a csv file containing student names.
> - generate grading templates for each student, for each assignment
> - email comments back to students
> - enter marks in an official spreadsheet which can be used for final g= rade
> submission
>
> A sample=C2=A0 "Comments.org" is at the bottom of this email= (it was a little
> long).
>
> So, here are my questions:
>
> - I currently store my grades as properties of level-2 headlines. Howe= ver,
> I would really like to be able to see the grades when the headline is<= br> > folded, so I can have a quick visual sense of how many papers I've= marked,
> how well the students are doing, and so forth.=C2=A0 THe best would be= to be
> able to see the actual marks in the headlines; but if I could, say, ad= just
> the color of the healdine based on the property value, that would be c= ool
> too.
>
> - It seems silly to record the grades once in org, and then again in a=
> libreoffice spreadsheet.=C2=A0 Better would be to generate a table and= /or csv
> spreadsheet directly from the headlines and property values.=C2=A0 So,= the
> example below would give the table:
> | Student=C2=A0 =C2=A0 =C2=A0 =C2=A0| Definition | Darwin |
> | Student One=C2=A0 =C2=A0|=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 0 |=C2= =A0 =C2=A0 =C2=A0 0 |
> | Student Two=C2=A0 =C2=A0|=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 0 |=C2= =A0 =C2=A0 =C2=A0 0 |
> | Student Three |=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 0 | 0=C2=A0 =C2=A0= =C2=A0 |
>
> and from there I guess I could generate a CSV just with org-table-expo= rt.
>
> Had anyone done either of these tasks before? Any guidance on how to d= o
> it?
>
> Thanks as always,
> Matt
>
> ------------------------------------------
> * Definition
> ** TODO Student One
> :PROPERTIES:
> :GRADE:=C2=A0 =C2=A0 0
> :MAIL_TO:=C2=A0 student.on= e@utoronto.edu
> :MAIL_CC:=C2=A0 matt.price@u= toronto.ca
> :MAIL_REPLY: matt.price@utor= onto.ca
> :MAIL_SUBJECT: Comments on Definition Assignment (Student One)
> :END:
> - Organization ::
> - Clarity of Thesis ::
> - Presentation of Evidence ::
> - Grammar and Spelling ::
> - Style ::
> - Citations ::
> - Further Comments ::
> - Grade ::
> ** TODO Student Two
> :PROPERTIES:
> :GRADE:=C2=A0 =C2=A0 0
> :MAIL_TO:=C2=A0 student.tw= o@utoronto.edu
> :MAIL_CC:=C2=A0 matt.price@u= toronto.ca
> :MAIL_REPLY: matt.price@utor= onto.ca
> :MAIL_SUBJECT: Comments on Definition Assignment (Student Two)
> :END:
> - Organization ::
> - Clarity of Thesis ::
> - Presentation of Evidence ::
> - Grammar and Spelling ::
> - Style ::
> - Citations ::
> - Further Comments ::
> - Grade ::
> ** TODO Student Three
> :PROPERTIES:
> :GRADE:=C2=A0 =C2=A0 0
> :MAIL_TO:=C2=A0 student.= three@utoronto.edu
> :MAIL_CC:=C2=A0 matt.price@u= toronto.ca
> :MAIL_REPLY: matt.price@utor= onto.ca
> :MAIL_SUBJECT: Comments on Definition Assignment (Student Three)
> :END:
> - Organization ::
> - Clarity of Thesis ::
> - Presentation of Evidence ::
> - Grammar and Spelling ::
> - Style ::
> - Citations ::
> - Further Comments ::
> - Grade ::
>
>
> * Darwin
> ** TODO Student One
> :PROPERTIES:
> :GRADE:=C2=A0 =C2=A0 0
> :MAIL_TO:=C2=A0 student.on= e@utoronto.edu
> :MAIL_CC:=C2=A0 matt.price@u= toronto.ca
> :MAIL_REPLY: matt.price@utor= onto.ca
> :MAIL_SUBJECT: Comments on Darwin Assignment (Student One)
> :END:
> - Organization ::
> - Clarity of Thesis ::
> - Presentation of Evidence ::
> - Grammar and Spelling ::
> - Style ::
> - Citations ::
> - Further Comments ::
> - Grade ::
> ** TODO Student Two
> :PROPERTIES:
> :GRADE:=C2=A0 =C2=A0 0
> :MAIL_TO:=C2=A0 student.tw= o@utoronto.edu
> :MAIL_CC:=C2=A0 matt.price@u= toronto.ca
> :MAIL_REPLY: matt.price@utor= onto.ca
> :MAIL_SUBJECT: Comments on Darwin Assignment (Student Two)
> :END:
> - Organization ::
> - Clarity of Thesis ::
> - Presentation of Evidence ::
> - Grammar and Spelling ::
> - Style ::
> - Citations ::
> - Further Comments ::
> - Grade ::
> ** TODO Student Three
> :PROPERTIES:
> :GRADE:=C2=A0 =C2=A0 0
> :MAIL_TO:=C2=A0 student.= three@utoronto.edu
> :MAIL_CC:=C2=A0 matt.price@u= toronto.ca
> :MAIL_REPLY: matt.price@utor= onto.ca
> :MAIL_SUBJECT: Comments on Darwin Assignment (Student Three)
> :END:
> - Organization ::
> - Clarity of Thesis ::
> - Presentation of Evidence ::
> - Grammar and Spelling ::
> - Style ::
> - Citations ::
> - Further Comments ::
> - Grade ::
> ---------------------------------------------
>
> I have three remaining issues

--
Professor John Kitchin
Doherty Hall A207F
Department of Chemical Engineering
Carnegie Mellon University
Pittsburgh, PA 15213
412-268-7803
@johnkitchin
http://kitchingroup.cheme.cmu.edu

--001a113df88eecc758051ca7d43a--