PsychoPy Builder - How to I take a rest part way through a set of trials? - psychopy

In PsychoPy builder, I have a lot of trials and I want to let the participant take a rest/break part way through and then press SPACE to continue when they're ready.
Any suggestions about how best to do this?

PsychoPy Builder uses the TrialHandler class and you can make use of its attributes to do control when you want to take a rest.
Assuming you're trial loop is utilising an Excel/csv file to get the trial data then make use of trialHandler's attribute : thisTrialN
e.g.
1/ Add a routine containing a text component into your loop (probably at the beginning) with your 'now take a rest...' message and a keyboard component to take the response when they are ready to continue.
2/ Add a custom code component as well and place something similar to this code into its "Begin Routine" tab:
if trials.thisTrialN not in [ int(trials.nTotal / 2) ]:
continueRoutine=False
where 'trials' is the 'name' of your trial loop.
The above will put a rest in the middle of the current set of trials but you could replace it with something like this
if trials.thisTrialN not in [10,20]:
continueRoutine=False
if you wanted to stop after 10 and again after 20 trials.
Note, if you're NOT using an Excel file but are simply using the 'repeat' feature of a simple trial loop, then you'll need to replace thisTrialN with thisRepN
If you're using an Excel file AND reps you'll need to factor in both when working out when you want to rest.
This works by using one of Builder's own variables - continueRoutine and sets it false for most trials so that most of the time it doesn't display the 'take a rest' message.
If you want to understand more, then use the 'compile script' button (or F5) and take a look at the python code that Builder generates for you.

Related

Using minecrafts plugin Skript - How to make a loop, that checks, if player goes in WorldGuard region?

So, I wanna make a loop, that checks, if player goes in WorldGuard region. I don't have any specific details, just i wanna know how to do it.
This is how my code looks like:
set {_rg::*} to %region at player%
loop {_rg::*}:
if "%loop-value%" contains "fail1_1"
execute console command "tp %player% -425.5 9.87500 2299.767 0.0 50.0"
if "%loop-value%" contains "fail1_2":
execute console command "tp %player% -425.5 10 2304.5 0.0 50.0"
Im not really an expert, but i tried to look it up. So, nothing really happened, there were no errors, but it didn't work as i expected (if you fall into region, you get teleported to a location)
I think it is most likely that your Skript installation is broken, your code should give multiple errors that make you aware why your code is not working. Try the latest version of Skript that is available on GitHub.
set {_rg::*} to %region at player%
If you are not working inside a text, you can't use the percentage signs, these are made to interpolate the given variable to text. Skript would create a working {_rg:*} list variable without the percentage signs.
You could use the percentage signs if you wanted to message at which regions the player is:
message "Regions: %region at player%" to player
if "%loop-value%" contains "fail1_1"
A colon is missing at the end of this statement, which should lead to errors while parsing.
execute console command "tp %player% -425.5 9.87500 2299.767 0.0 50.0"
While you can execute commands to teleport players using Skript, you can also teleport players without executing console commands. The reason for this is that Skript will not check if the command is going to work.
Instead, you can use the location function to create a new location and teleport the player to it.
teleport player to location(-425.5, 9.87500, 2299.767, player's world, 0.0, 50.0)

calling RankToPosition() and _onMoveToPositionClicked

I have a situation where i'd like to enter a "3" into a textbox on a user story grid, call something like RankToPosition(3) to move that user story row to position 3 in the current rank. Within the same grid, the idea is to have a textbox on each row, so the row beneath may have a 4 in there, and when i click SUBMIT, the entire table would be processed by using the numbers in the row textbox and calling RankToPosition(#). This is like the Netflix queue. There have been similar questions on here, but my thought is to just call the underlying method alluded to here as "_onMoveToPositionClicked":
https://help.rallydev.com/apps/2.0rc3/doc/source/MoveToPositionMenuItem.html#Rally-ui-menu-item-MoveToPositionMenuItem-cfg-rankRecordHelper
If i could iterate through the table grid, store initial rank values (i realize they're not just integers), and pick the new text values up, run code to call the _onMoveToPositionClicked beneath the scenes, it may accomplish a bulk rank grid for when users have 200+ items to manage, for instance.
Any insight you have for just calling this in custom code would be helpful. Any solution for representing this functionality would be appreciated. I am currently using Rally 2.0rc3.
Thank you for your time
Is it possible to upgrade to a newer version of the App SDK? 2.0rc3 is a very old pre-release. The latest is 2.1: https://help.rallydev.com/apps/2.1/doc/
In any case, the way ranking is performed is relative to another object via the rankAbove or rankBelow parameters. So given the record you want to rerank:
record.save({
params: {
rankAbove: '/hierarchicalrequirement/12345'
}
});

How do I write a robust structural search template to report Mockito times(1)/Times(1) passed to verify in IntelliJ IDEA?

In my project Mockito.times(1) is often used when verifying mocks:
verify(mock, times(1)).call();
This is redundant since Mockito uses implicit times(1) for verify(Object), thus the following code does exactly what the code above does:
verify(mock).call();
So I'm going to write an a structural search drive inspection to report such cases (let's say, named something like Mockito.times(1) is redundant). As I'm not an expert in IntelliJ IDEA structural search, my first attempt was:
Mockito.times(1)
Obviously, this is not a good seach template because it ignores the call-site. Let's say, I find it useful for the following code and I would not like the inspection to trigger:
VerificationMode times = Mockito.times(1);
// ^ unwanted "Mockito.times(1) is redundant"
So now I would like to define the context where I would like the inspection to trigger. Now the inspection search template becomes:
Mockito.verify($mock$, Mockito.times(1))
Great! Now code like verify(mock, times(1)).call() is reported fine (if times was statically imported from org.mockito.Mockito). But there is also one thing. Mockito.times actually comes from its VerificationModeFactory class where such verification modes are grouped, so the following line is ignored by the inspection:
verify(mockSupplier, VerificationModeFactory.times(1)).get();
My another attempt to fix this one was something like:
Mockito.verify($mock$, $times$(1))
where:
$mock$ is still a default template variable;
$times$ is a variable with Text/regexp set to times, Whole words only and Value is read are set to true, and Expression type (regexp) is set to (Times|VerificationMode) -- at least this is the way I believed it should work.
Can't make it work. Why is Times also included to the regexp? This is the real implementation of *.times(int), so, ideally, the following line should be reported too:
verify(mockSupplier, new Times(1)).get();
Of course, I could create all three inspection templates, but is it possible to create such a template using single search template and what am I missing when configuring the $times$ variable?
(I'm using IntelliJ IDEA Community Edition 2016.1.1)
Try the following search query:
Mockito.verify($mock$, $Qualifier$.times(1))
With $Qualifier$ text/regexp VerificationModeFactory|Mockito and occurrences count 0,1 (to find it when statically imported also).
To also match new Times(1) you can use the following query:
Mockito.verify($mock$, $times$)
With $times$ text/regexp .*times\s*\(\s*1\s*\) and uncheck the Case sensitive checkbox.

FastReports: Adding Objects to other than OverlayBand

I am writing a FastReport from code (not using the designer), the report eventually to be exported to a file.
If I export the report created from code to a .fpx - a report preview file, the file's bands do not appear when opened in "Edit Page" mode via the designer (though the bands' contents - e.g. data - does). The report is rendered, correctly - the content is where it needs to be. The only band that is present is the OverlayBand - not explicitly created by me in the code.
If I add band objects through code - for instance, a DataBand object - how do I ensure the added objects are: [1] added to the report, itself; and [2] not absorbed (?) by - or, added to - the OverlayBand object.
I consulted the scant documentation and have not found an answer. I am not looking for you to code the report for me. My thought is that I am missing a critical piece of the creation-from-code puzzle, e.g. the addition of further layers (not bands) to the report page.
Currently, I am instantiating a report:
Dim rptReport As New Report
Dim rptPage As New ReportPage
rptReport.Pages.Add(prtPage)
Further objects are then added to the the rptPage.Bands using:
' Pseudo-code:
rptPage.Bands.Add(aBandObject)
Must I explicitly add layers to the page before I can begin adding bands to it? My thought is that there is code that must enable the addition of bands to layers other than the overlay band, i.e.:
Dim rptReport As New Report
Dim rptPage As New ReportPage
rptReport.Pages.Add(prtPage)
' CODE INSERTED HERE: rptPage.Objects.Add(Bands) (Pseudo-code)
Again, if you are able to point in the right direction, I am okay with that; however, I have consulted the forums and documentation and am unable to find an answer - hence my asking, here.
From what I can see, the issue does not appear to arise from the code.
When saved as a .fpx file and then opened in "Edit Mode", it remains true that the bands disappear; however, if I run rptObject.Design() and open the report that way, the bands appear as they should.
The problem appears to arise from saving the file as a .fpx, the "preview" file (as opposed to .frx)

SharePoint Workflow Error: "Unable to transform the input lookup data into the requested type" BUT only on New Item Creation

FYI to start, I am aware of how to properly set up an update to a lookup, and am 99% positive I've done this correctly.
I know this because When I set the workflow to automatically start when an Item is Changed, then it works perfectly. But when I simply change this setting so it will automatically start on New Item Creation, it Cancels the workflow and I get a "Coercion Failed: Unable to transform the input lookup data into the requested type." If both options are checked then it fails on creation, but simply clicking edit on the item properties, and the "Save" makes it work.
The workflow is on a Document Library and works as follows;
User selects the Work Task LookUp from a dropdown in the edit properties form after uploading, and then Saves the item (adding it to the document library). The workflow is suppose to then look at the Work Task LookUp selected, and pull the Account and Effective Date-Type lookUp ID's that Work Task item has, and sets the Document's identical fields to the same value.
Here is the code for the workflow if it helps;
If Current Item: Parent Task is not empty
If Current Item: Sub Task is not empty
Log Both are empty to workflow history list
Then Set Account to Work Tasks:Account
The Log Set Account to workflow history list
Then Set Effective Date and Type to WorkTasks: Effective Date and Type
The Log Set EffDateType to the workflow history list
This is all done in one step. I also added additional steps to test if the account and effective date type fields have been set properly, and if not to set them again. But everytime I run the workflow on change and it works, it always correctly sets these fields based upon the first Step (posted above) and the additional check logs to the history that they are not needed.
As an example, The lookUp for Integer for Tasks:Account is set to work as follows;
Date Source: Work Tasks (a list)
Field from Source: Account (a lookup)
Return Field as: Lookup ID (as Integer)
Find the List Item
Field: Title (from the Work Tasks list)
Value: Current Item: Parent Task (Which is a look up of the "Title"
Field from Work Tasks List, and is set to return the Value as a LookUp Value (As Text))
The Effective Date and Type setting is pretty much identical.
So anyone have any insight? I've tried running it as an impersonated Step, setting a workflow pause (for 1 minute), changing the lookup types incase I messed it up to start with, but ultimately the above workflow DOES work, but only when I set it to "Automatically start on the Change (edit) of an Item", NOT "Automatically start on New Item Creation" like I need to to do.
Oh yes, fyi, I am using SPServices CascadingDropDown on the Work Task and Sub Task fields of the doc Library form, but I honestly do not believe this has anything to do with my issue.
UPDATE:
I've talked with another developer, and he believes it is due to the issue that the workflow is occuring too quickly, before the item creates an ID for itself, which it needs to conduct the lookUps. He had me add another "Pause Workflow" to the very top of my workflow code (above the If conditions) and set it for 1 minute.
It then worked properly.
Downside is we want this to labeling to occur as close to item creation as possible. Because a view of the library relies on grouping based upon Account and Effective Date and Type. To add to this downer, Microsoft's Pause Workflow only allows for 1 minute or more, and then the timer used for this is often off, resulting in a pause longer than that. So far, every test is currently showing 2 minutes minimum on the pause.
A possible alternative solution for instantaniously populate the fileds is to use Javascript and SPServices to do the lookUp to the Task list to pull the account and effective date - type fields and then populate, but my Javascript is not very strong and I would need help doing this. If anyone has any suggestions, I would appreciate them.
(Answered in a question edit. Converted to a community wiki answer. See Question with no answers, but issue solved in the comments (or extended in chat) )
The OP wrote:
I don't know if it is the ID for the item after further testing. I changed the start of the workflow to wait until a field in the item changes. I set it to wait until the ID field is not 0 (since you cannot set to null), and it still does not work.
6/14/2012 4:13 PM Comment System Account Waiting on ID ​
6/14/2012 4:13 PM Comment System Account Waiting complete on ID ​
6/14/2012 4:13 PM Error System Account Coercion Failed: Unable to transform the input lookup data into the requested type.
I have tried other fields as well, like document ID value is not empty, and it will wait, log it finishing the wait, and then fail.
UPDATE This issue has something to do with the Parent Task field. I have solved the issue without having to wait for a period of time by setting the change from above to wait until the Parent Task field is not empty. It then completes the workflow fine.
Anyone know why there is a delay though? I've solved it, but still don't fully understand what takes it so long.
The main fault has been solved (hence the answer), and the remaining point about the reasons for the delay would probably be a discussion point or not specific enough for SO. Any further clarification can be edited in here.