Tinderbox User-to-User Forum (for formal tech support please email: info@eastgate.com)
Tinderbox Users >> Agent, Actions, Rules & Automation >> Limiting notes used to calculate a sum

Message started by BCrane on Sep 29th, 2015, 10:01pm

Title: Limiting notes used to calculate a sum
Post by BCrane on Sep 29th, 2015, 10:01pm

I am (still) working on a grading rubric and have a question about limiting what is calculated by ďsum".

I have a working rule that Iíd like to build on. It is:


Is it possible to sum only the $Points values of children for which $Checked is also true? If so, how?

Iíve gone through TbRef trying to avoid asking but itís doing my head in and Iím not making much progress.

Title: Re: Limiting notes used to calculate a sum
Post by Mark Anderson on Sep 30th, 2015, 4:24am

Did you try sum_if()?

Also I think your sum() syntax is wrong. It should be:


To sum only children who tick box is checked, use:


As the first parameter of sum() supports find() as a way of specifying the group, you could do:

$Grade=sum(find(inside($Name(that) & $Checked==true),$Points)

However, sum_if is I think clearer here if only because it's simpler and easier to read.

Aside, I'm interested that you didn't easily find sum_if() when looking in aTbRef. That's not criticising you but it makes me wonder where/how the aTbRef layout didn't work with your searching strategy? Perhaps I need to make the link from the txt of the sum() article a bit more explicit as to what it does?

I ask both as it's germane to my current PhD studies and I want the aTbRef resource to be as self-serve as realistically possible. Over its 10+ years, I've restructured both the content and page templates to try and improve discoverability but there's always scope for more.  :)

Title: Re: Limiting notes used to calculate a sum
Post by BCrane on Sep 30th, 2015, 7:51am

Thank you Mark. As usual, this fixed everything.

How did I manage not to find the info in the TbRef? In part, I think it's because I didn't realize what I was looking for, and that problem was conceptual rather than textual (i.e. not a problem with ToC or indexing etc.).

I had been trying to limit sum using an agent and this hadn't been working. Conceptually (at least to me), I was trying to create an external process and then use its result to do a sum. That wasn't working and based on the TbReg I was pretty sure it wouldn't because somewhere it points out that relative selection of a parent requires taking two steps up the hierarchy and then coming back down. I didn't have two layers of stable hierarchy to work through because the rubric's grandparent will continually change as I use it for different students' assignments. So I knew the agent approach wasn't working but I didn't know what would.

...and the actual solution you've given me is--at least conceptually, to me--the polar opposite of an external, incremental process. The sum_if expression requires me to nest my condition as the middle term in a parenthesis that is "inside" the action I want to do. It's the exact opposite of how I was thinking about the problem and so I just didn't have any idea what I was looking for and wouldn't have known it (or been able to use it) if I'd seen it.

I take it as proof that the problem wasn't with TbRef that once you told me what I needed I went to there, dug around, found the explanation (it was clear as day), and then went to the home page. From the home page, I could get back to my answer with two clicks on purple links. So the info was right there...I just couldn't figure out how to use it.

As a kind of test after reading your suggestion and seeing that it fixed my sum problem, I decided to tackle the same problem in my export code. (I'm making my rubric in TBX not because I want to calculate grades--a spreadsheet can do that easily--but because I want to generate exported comment sheets giving basic feedback that are formatted to be upload and distributed to individual students through our school's online system. The idea is to reserve my handwritten comments for ideas rather than basics like formatting, etc.)

The checked/unchecked issue comes up again at export: I only want to export checked comments. So I jumped forward and started building my export templates, went to TbRef, found the ^if(condition)^ page, ... and am lost completely! Seriously. I don't understand why I don't understand but I don't. I'm experimenting and will figure this out, but it's going to take some trial and error, which is fine.

My point is that I'm pretty sure that this is not a problem with TbRef. I'm not a comp sci guy, I just use computers to teach/write. So I don't think in the manner of comp sci. I think this means--and how could it not mean this?--that TbRef (and the other various pieces of documentation) and I don't share a sense of what's obvious and not-obvious. And that means figuring out is required/impossible/but required/oh, wait,...got it...that makes sense.

...that may be more than two cents worth...

Title: Re: Limiting notes used to calculate a sum
Post by BCrane on Sep 30th, 2015, 8:01am

Quick, odd follow-up:

When I was first learning French I found it impossible to use object pronouns. In English I would say "She threw it" but in French I would have to say "She it threw." I could not manage this and the problem was not that I didn't know the rule. The problem was--and I complained about this incessantly--was that in the press of real speech I couldn't possibly now the object of the action until I knew the action. Yet, French required me to drop two objects on the table of conversation and only then draw the the line of action between them.

Today I don't think twice about this, but at the time, the conceptual problem shut me down.

I was reminded of this writing my previous post and don't think they are unrelated experiences.

Title: Re: Limiting notes used to calculate a sum
Post by Mark Anderson on Sep 30th, 2015, 9:36am

Interesting - and very valid. I'm with you on the syntax issue - it's surprisingly resilient, like the way different folk chunk numbers differently. Writing/running aTbRef has been long lesson in the different ways people look for things - every day a learning day.

Title: Re: Limiting notes used to calculate a sum
Post by BCrane on Oct 2nd, 2015, 2:36pm

I have a working export template!

This post (http://www.eastgate.com/Tinderbox/forum//YaBB.cgi?num=1432786841) gave me the working example of ^if(condition)^ that let me see how it worked.

Tinderbox User-to-User Forum (for formal tech support please email: info@eastgate.com) » Powered by YaBB 2.2.1!
YaBB © 2000-2008. All Rights Reserved.