What's a good web-based UI for capturing a time duration from the user.
Lets say that we want to capture a time duration in minutes.
But would like to present it such that the user can enter in hours and\or minutes.
Just use 2 textboxes for hrs\min?
Or a single textbox and let them type in "1hr 31min" or "91 min" ?
Or is there something better?
If you have two text boxes labelled hours and minutes then you need to deal with case where the user types into both of them.
3 into h and 35 into m => pretty clear. 3 hours 35 mins
nothing into h and 95 into m => 1 hour 35 mins (probably update the display to show that)
but what about
2 into h and then 95 into m => does that mean 3 h 35 or 1 hour 35
I've used too many annoying UIs where changing a field zaps other entries to be confident that I can devise an unastonishing set of behaviours.
Hence I would go for a single box into which we can type 3h or 1h 35m or 95m and have a separate read-only display of the interpretation.
There seems to be an opportunity for a nice widget to allow a mouse driven entry, in the same way as a calendar widget allows date entry. A little clock with dragable hands?
Thanks for all the feedback.
What I finally ended up doing was, having a single textbox that shows the time duration in the format "xxhrs yymin"
The user can edit it and when focus moves away from the textbox, it recalculates the duration and reformats the text into the canonical form.
The parser to interpret the text entered is fairly liberal.
It's a set of regular expressions to match any number followed by 'h' or 'm' or 'd' to represent hours, minutes and days.
If it doesn't find any 'unit' with a number in front of it, it assumes you have typed in a pure number as minutes and will interpret it as such.
So if the user types:
"1.5h", it will reformat to "1hr 30min" upon leaving the textbox.
"90 min" will also be reformatted as "1hr 30min"
The parser only looks at the first character following the number, which means you can enter "1 day, 7 hours and 19 minutes" and it will recognize it correctly.
Of course, it would also recognize "2 holes and 19 mice" as "2hrs and 19min".
I think I can live with that.
Just let them type the numbers only in a pre defined time format.
Place 2 textboxes for hour and minute without the hr or min.
Also you have to define whether it is a 24 hour system or 12 hour.
Well, separate hours and minutes fields is the safest but slower to use than a single field. You can default the hours to 0 if you don’t expect many durations over 1 hour.
Maybe it depends on your population, but I expect users will be able to handle hours and minutes in the same text box if you provide a prompt, such as “Time duration (hrs:min):”
With that prompt, accept any initial unbroken string of numbers as the hours and any subsequent unbroken string of numbers as minutes, so that all of the following input are treated as equivalent.
2:30
02:30
02:30:05
2.30 (or maybe not: while great for keypad entry, but you may want to make an exception for the decimal point to allow the user to enter fractional hours, such as 2.75 for 2 hrs 45 min.)
2 30
2 hrs 30 min
2 hours, 30 minutes
2jaQp 30!!!!
I see no reason to require that the minutes be less than 60. The user should also be able to express the time as:
:150
When the focus leaves the field, auto-correct whatever the users enter to the specified (hrs:min) format to feedback the interpretation you made.
If all you need for your purpose is a rough approximation of time (or your users are only estimating anyway), then consider option buttons or a dropdown list with ranges of duration (e.g., 0 to 5 minutes, 5 to 15 minutes, 15 min to 1 hour, Over an hour.). Or if there are definite bounds on the durations and the intervals are functionally linear, you can use a labeled slider.
Whatever input format or control you use, it should be compatible with the source of information. Where do users get this duration? What units, format, intervals, and degree of precision are used there? How do users think and talk about the time among themselves?
I think there should be no client side correction for the minutes greater than 60 as somebody suggested. It would only be confusing and generate unnecessary problems.
User entered the data so he should understand what he typed and there is no need to correct him.
I would leave these fields as filled by user. On the server side I would just calculate total minutes as:
$total_minutes = 60 * $_POST['hours'] + $_POST['minutes'];
I was just thinking about this and realized one familiar UI for this sort of thing is a microwave oven. For iPhone-like uses, a keypad may be better than the rolling scroller thing I often see.
In my case I think I'm going to go with a text field for "number" and a selectbox for "unit" (years, months, weeks, days, hours).
Sliders (jqueryui, html5) could be an option too, depending on what kind of range you're talking about.
Related
I'm trying to find a more efficient and speedier way (if possible) to pull subsets of observations that meet certain criteria from multiple hospital claims datasets in SAS. A simplified but common type of data pull would look like this:
data out.qualifying_patients;
set in.state1_2017
in.state1_2018
in.state1_2019
in.state1_2020
in.state2_2017
in.state2_2018
in.state2_2019
in.state2_2020;
array prcode{*} I10_PR1-I10_PR25;
do i=1 to 25;
if prcode{i} in ("0DTJ0ZZ","0DTJ4ZZ") then cohort=1;
end;
if cohort=1 then output;
run;
Now imagine that instead of 2 states and 4 years we have 18 states and 9 years -- each about 1GB in size. The code above works fine but it takes FOREVER to run on our non-optimized server setup. So I'm looking for alternate methods to perform the same task but hopefully at a faster clip.
I've tried including (KEEP=) or (DROP=) statements for each dataset included the SET statement to limit the variables being scanned, but this really didn't have much of an impact on speed -- and, for non-coding-related reasons, we pretty much need to pull all the variables.
I've also experimented a bit with hash tables but it's too much to store in memory so that didn't seem to solve the issue. This also isn't a MERGE issue which seems to be what hash tables excel at.
Any thoughts on other approaches that might help? Every data pull we do contains customized criteria for a given project, but we do these pulls a lot and it seems really inefficient to constantly be processing thru the same datasets over and over but not benefitting from that. Thanks for any help!
I happend to have a 1GB dataset on my compute, I tried several times, it takes SAS no more than 25 seconds to set the dataset 8 times. I think the set statement is too simple and basic to improve its efficient.
I think the issue may located at the do loop. Your program runs do loop 25 times for each record, may assigns to cohort more than once, which is not necessary. You can change it like:
do i=1 to 25 until(cohort=1);
if prcode{i} in ("0DTJ0ZZ","0DTJ4ZZ") then cohort=1;
end;
This can save a lot of do loops.
First, parallelization will help immensely here. Instead of running 1 job, 1 dataset after the next; run one job per state, or one job per year, or whatever makes sense for your dataset size and CPU count. (You don't want more than 1 job per CPU.). If your server has 32 cores, then you can easily run all the jobs you need here - 1 per state, say - and then after that's done, combine the results together.
Look up SAS MP Connect for one way to do multiprocessing, which basically uses rsubmits to submit code to your own machine. You can also do this by using xcmd to literally launch SAS sessions - add a parameter to the SAS program of state, then run 18 of them, have them output their results to a known location with state name or number, and then have your program collect them.
Second, you can optimize the DO loop more - in addition to the suggestions above, you may be able to optimize using pointers. SAS stores character array variables in memory in adjacent spots (assuming they all come from the same place) - see From Obscurity to Utility:
ADDR, PEEK, POKE as DATA Step Programming Tools from Paul Dorfman for more details here. On page 10, he shows the method I describe here; you PEEKC to get the concatenated values and then use INDEXW to find the thing you want.
data want;
set have;
array prcode{*} $8 I10_PR1-I10_PR25;
found = (^^ indexw (peekc (addr(prcode[1]), 200 ), '0DTJ0ZZ')) or
(^^ indexw (peekc (addr(prcode[1]), 200 ), '0DTJ4ZZ'))
;
run;
Something like that should work. It avoids the loop.
You also could, if you want to keep the loop, exit the loop once you run into an empty procedure code. Usually these things don't go all 25, at least in my experience - they're left-filled, so I10_PR1 is always filled, and then some of them - say, 5 or 10 of them - are filled, then I10_PR11 and on are empty; and if you hit an empty one, you're all done for that round. So not just leaving when you hit what you are looking for, but also leaving when you hit an empty, saves you a lot of processing time.
You probably should consider a hardware upgrade or find someone who can tune your server. This paper suggests tips to improve the processing of large datasets.
Your code is pretty straightforward. The only suggestion is to kill the loop as soon as the criteria is met to avoid wasting unnecessary resources.
do i=1 to 25;
if prcode{i} in ("0DTJ0ZZ","0DTJ4ZZ") then do;
output; * cohort criteria met so output the row;
leave; * exit the loop immediately;
end;
end;
I'm trying to set my 'MaxIdleTime' in the Registry Editor. I have used the following link to set it up to be 5 Days. How can I make it 14 days? I want it longer than 5 days, but less the 'Never' I'm not sure how to convert seconds into Hexadecimal or Decimal value. Any help would be awesome!
https://www.sevenforums.com/tutorials/118889-remote-desktop-set-time-limit-idle-sessions.html
Thanks,
I found out it was in milliseconds. I just converted the days I wanted into milliseconds and went from there
How do I convert days back into hours when using a list?
I'm calculating a list of video lengths. Because the list is so long, it eventually adds up into days (time exceeding 24 hours). What I would like it to do is rather than push the overflow (of anything over 24 hours) into days, is just have it included in hours.
For example, rather than 27 hours being shown as "1:03:00" (1 day, 3 hours, 0 minutes) I want it to appear as "27:00". You can change the time format under the Format tab, however that doesn't actually change anything. All it does is not preview that time period, it doesn't roll it into the next slot. So changing the format from Days:Hours:Minutes to Hours:Minutes changes "1:03:00" to "3:00".
I didn't list code because I'm just using "=Sum(A:A)". Is there a different format I need to select or do I need to convert it manually? How would I go about doing that when I'm dealing with time values and not mathematical values like whole numbers and decimals?
The time values in the column are listed as 12:9:49 AM for a video that's 9:49 long, if that helps. No idea why it has to add 12 in front but that's the only way I could get it to read as a numerical value rather than a text string ('9:49).
Found it!
What I was looking for was an option called "Elapsed hours" under the Format tab. Sometimes it's there, sometimes it's not.
Another method is clicking custom format (rather than date/time) and inputting [hh]:mm:ss. The square brackets mean all hours accumulated will stay there. It won't roll over back to 0 and push the excess into the days slot. So 27 hours appears as 27 hours rather than 3 hours (with the 24 being counted as 1 day).
I am new to programming, and need some help with an experiment I'm constructing in PsychoPy builder. I have made something that works, but I can tell it's inelegant and there must be a better way.
I want to conduct 24 trials. Each trial will show 7 unique images, then 1 image which may or may not be from the 7, and users are then asked to enter y/n if they have seen the image before.
In my current code I have created 24 separate input files, each containing a list of the unique objects. I have created a loop which shows the seven objects in succession. I have then created separate routines for the pre-trial fixation screen (constant for all 24 trials) and the response (probe image and correct answer manually programmed). The code works, but it is very long, and if I wanted to change something in the fixation or the probe/response, I would need to change each of the 24 trials individually.
How can I instead get Builder to create a loop which contains the fixation screen (constant), the trial loop (picking the next seven unique objects (they are named sequentially from 1-168), and then a probe/response which is unique to each trial (I have these in an input file as follows. Probe refers to a number between 1 and 7 which references the position of the image in the sequence shown in the trial.)
TrialNumber Probe CorrAns
1 4 0
2 3 1
3 4 0
4 5 1
5 4 1
...
I hope my question makes sense and I would be grateful for any assistance.
Thanks PsychoPy Beginner.
Yes, you're correct that there is a (much) more efficient way to do this.
First, start with your conditions file (i.e. .csv or .xlsx). You only need one of them. It should have 24 rows (one per trial). It will need 8 columns: 7 to specify the unique images in a trial and an eighth to specify the repeated one.
Second, you need a loop to control the trials. This is connected to the conditions file, and encompasses all of the routines (the pre-trial fixation and the image routine.
Third, you need a second, inner loop, nested within the outer one. This encompasses only the image routine. i.e. the fixation routine will run 24 times (once per outer loop), and the image routine will run 7×24 times (i.e. 7 times per trial). The inner loop is not connected to a conditions file and is simply set to run 7 times.
So note that you no longer have 24 separate routines in Builder but only two (the fixation and image routines). Instead of duplicating routines, you repeat them via the loops.
In the image stimulus image field, you can construct the image name to use on each presentation. e.g. lets say the 8 columns in your conditions file are labelled 'image0', 'image1', etc. Then in the image field, put something like this:
$'image' + str(yourInnerLoopName.thisN)
i.e. on the first iteration within each trial, the image filename would come from column image0, the second from image1, and so on.
I don't know how you are handling the responses, but you will also probably need a ninth column in the conditions file that indicates what the correct response is. The keyboard component can access that to judge whether the response is correct or not.
Question is:
Write pseudocode for a program that
calculates the service charge of a
customer owes for writing a bad check.
The program accepts a customer's name,
the date the check was written (year,
month and day), the current date
(year, month and day), and the amount
of the check in dollars and cents. The
program continues until an eof value
is encountered.
The service charge is $20 plus 2
percent of the amount of the check,
plus $5 for every month that has
passed since the check was written. A
check is one month late as soon as a
new month starts-so a bad check
written on September 30 is one month
overdue on October 1.
A program is generally a series of steps. Can you break down the problem into a series of steps necessary to calculate your answer?
Hints:
Every time the month changes, you owe another $5. Thus, "day" is irrelevant.
Next year at the same month, 12 months are passed. The previous month, the number of elapsed months is 12 - 1.
"2% more than" is equivalent to * 1.02
"Continues until EOF is reached" sounds like a loop.
Try to edit your question and make an honest attempt - no-one will solve your homework for you, but we will help you solve it.
In my humble experience, this kind of confusion is caused by trying to solve the problem and write the code at the same time.
Try solving the problem first.
Get a sheet of paper and draw a flowchart which shows the steps and decisions.
e.g. the last box might be:
EOF: Y = Stop, N = go back to "Read next line"
Pick 3 test examples e.g.
In the current month
In the last year
Greater than a year
Work these examples through your flowchart and check that the result is correct. If not, amend the flowchart and rework the test examples.
When you are happy, "translate" the flowchart into English and you will have working pseudo code.
Load the file
Read and store check_date_month in a variable
Read and store current_date_month in a variable
Read and store check_amount in a variable
Service_charge = 20 + 0.02*(check_amount) + [(current_month - check_date_month) + current_date_year - check_date_year]*5
Read customer's name and show to the user something like:
"Customer's Name"
Service charge: "$"Service_charge
The days in this case are not relevant because the charge increases every time the month changes, so, in the case we are in October and the check was done in September (10-9 = 1) we have to pay $5 more, but maybe we could be in different years, for example 2010 and 2009, that means that between October and September there are now (1 + 12 = 13) months, so now you have to pay $65. I expect this will help you to understand step 5.