# Showing Sum of Routine Points Earned at the end of the Experiment

**URL:** <https://discourse.psychopy.org/t/showing-sum-of-routine-points-earned-at-the-end-of-the-experiment/24092>\
**Category:** Builder\
**Created:** [July 17, 2021, 10:29pm UTC](https://discourse.psychopy.org/t/showing-sum-of-routine-points-earned-at-the-end-of-the-experiment/24092 "2021-07-17T22:29:23Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![David\_Cox](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/david_cox/32/30311_2.png) [@David\_Cox](https://discourse.psychopy.org/u/David_Cox)\
**Post date:** [July 17, 2021, 10:29pm UTC](https://discourse.psychopy.org/t/showing-sum-of-routine-points-earned-at-the-end-of-the-experiment/24092/1 "2021-07-17T22:29:23Z")

</div>

If this template helps then use it. If not then just delete and start from scratch.

**OS** : macOS Big Sur 11.4  
**PsychoPy version** : 2020.2.10  
**What are you trying to achieve?:**  
I have a three-condition experiment where each condition is a separate routine. In each routine, the participant earns points. At the end of the experiment, I want to show them the total number of points they earned.

**What did you try to make it work?:**  
I have tried solutions such as the links below, but the number of points keeps coming up as 0.

- Example 1: [Copying data from one routine to others](https://discourse.psychopy.org/t/copying-data-from-one-routine-to-others/10965)
- Example 2: [Saving data from one routine to use on following routines - #2 by TParsons](https://discourse.psychopy.org/t/saving-data-from-one-routine-to-use-on-following-routines/14543/2)

My main challenge is that I don’t know exactly where I am supposed to be inserting those code components in the builder. And, if there is a way to modify the .py file directly I would be very comfortable doing that if someone can point me to where it’s supposed to be located in the standard folder structure.

---

<div class="post-metadata">

**Author:** ![tandy](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/tandy/32/9246_2.png) [@tandy](https://discourse.psychopy.org/u/tandy)\
**Post date:** [July 18, 2021, 6:31am UTC](https://discourse.psychopy.org/t/showing-sum-of-routine-points-earned-at-the-end-of-the-experiment/24092/2 "2021-07-18T06:31:25Z")

</div>

Place the code component inside the routine you want to score, at the very top of the component list. In one of thhese components set a variable in the begin experiment tab (e.g. myScore = 0). In each code component in the every frame tab set myScore to go up by one when the participant does something rignt. At the end of the experiment you can show the total number of points with a text component containing $myScore as text

---

<div class="post-metadata">

**Author:** ![David\_Cox](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/david_cox/32/30311_2.png) [@David\_Cox](https://discourse.psychopy.org/u/David_Cox)\
**Post date:** [July 18, 2021, 2:58pm UTC](https://discourse.psychopy.org/t/showing-sum-of-routine-points-earned-at-the-end-of-the-experiment/24092/3 "2021-07-18T14:58:31Z")

</div>

Thank you for helping, @tandy! I must still be missing something. Below are screen shots of what I believed your recommendations to be. The final text was still showing 0. Perhaps I’m calling the variable incorrectly at the end?

 ![ph_1_code_begin](https://us1.discourse-cdn.com/flex002/uploads/psychopy/original/3X/2/e/2ec6e6b385e9472fd309930ec92e591955c9eb25.jpeg)  
 ![ph_1_code_frame](https://us1.discourse-cdn.com/flex002/uploads/psychopy/original/3X/6/4/64e939466cb0077a13880d39d3611de04139696d.jpeg)

---

<div class="post-metadata">

**Author:** ![David\_Cox](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/david_cox/32/30311_2.png) [@David\_Cox](https://discourse.psychopy.org/u/David_Cox)\
**Post date:** [July 18, 2021, 2:59pm UTC](https://discourse.psychopy.org/t/showing-sum-of-routine-points-earned-at-the-end-of-the-experiment/24092/4 "2021-07-18T14:59:04Z")

</div>

![ph_2_code_begin](https://us1.discourse-cdn.com/flex002/uploads/psychopy/original/3X/e/3/e329424c77f6676aee41566d965547f89fcec330.jpeg)  
 ![ph_2_code_frame](https://us1.discourse-cdn.com/flex002/uploads/psychopy/original/3X/d/8/d801ccc01f7b75b096787d3998c86caac93b6a3d.jpeg)

---

<div class="post-metadata">

**Author:** ![David\_Cox](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/david_cox/32/30311_2.png) [@David\_Cox](https://discourse.psychopy.org/u/David_Cox)\
**Post date:** [July 18, 2021, 2:59pm UTC](https://discourse.psychopy.org/t/showing-sum-of-routine-points-earned-at-the-end-of-the-experiment/24092/5 "2021-07-18T14:59:38Z")

</div>

![end_exp_bank](https://us1.discourse-cdn.com/flex002/uploads/psychopy/original/3X/e/0/e0bc0ab28c444c7f5c14ea2f581a993e2189e2c9.jpeg)

---

<div class="post-metadata">

**Author:** ![David\_Cox](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/david_cox/32/30311_2.png) [@David\_Cox](https://discourse.psychopy.org/u/David_Cox)\
**Post date:** [July 18, 2021, 4:15pm UTC](https://discourse.psychopy.org/t/showing-sum-of-routine-points-earned-at-the-end-of-the-experiment/24092/6 "2021-07-18T16:15:25Z")

</div>

Update on this thread in case anyone finds it. I still am unable to get the points to show when I run the .psyexp file locally. However, when I deploy it online the code is working. If anyone can solve that riddle, I would love to know! Otherwise, I think I am okay for now.

---

<div class="post-metadata">

**Author:** ![tandy](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/tandy/32/9246_2.png) [@tandy](https://discourse.psychopy.org/u/tandy)\
**Post date:** [July 19, 2021, 12:07pm UTC](https://discourse.psychopy.org/t/showing-sum-of-routine-points-earned-at-the-end-of-the-experiment/24092/7 "2021-07-19T12:07:33Z")

</div>

Hi David,

I am really puzzled about why the code is not working. I was suggesting another soution that for sure works online but should also localy, I you want you can give it a try anyway.

Basically you set your mouse to record the correct response (you also need to add a column with the correct response on your .xlsx files) and in the code component in the end routine tab, you add one to the score if the response was correct (e.g. if mouse.corr: → score =+1)

---

<div class="post-metadata">

**Author:** ![David\_Cox](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/david_cox/32/30311_2.png) [@David\_Cox](https://discourse.psychopy.org/u/David_Cox)\
**Post date:** [July 23, 2021, 11:13am UTC](https://discourse.psychopy.org/t/showing-sum-of-routine-points-earned-at-the-end-of-the-experiment/24092/8 "2021-07-23T11:13:48Z")

</div>

Hey Tandy,

I am puzzled as well - very odd. I am also running into another issue when I push the experiment online in that the order of the stimuli on the screen are reversed. For example, text in one component should be viewable on top of a square. However, when I push it online, the square is now on top of (and thus hiding) the text. Any thoughts on this one?

Warmly,  
David
