Skip to main content
Inspiring
December 1, 2010
Question

Login Stats "false-positive"?

  • December 1, 2010
  • 4 replies
  • 832 views

This deals with login stats... (I've not done any coding yet - just trying to hypothesize first... but will use CF queries)

I'm sure there's a way to do this but can't quite figure it. I know it's easy enough to do a database row count or add the 'number fields' in a

database column for a total, but - how to do this without getting a "false positive" as per below?

Goal: To find the name of the school with the lowest number of Teacher logins.

The LoginCounter database field is set up as a 'number field' and adds an increment of 1 each time a teacher logs in to the site. (for my counter code

to work, this field starts with a default of 1). I have a SchoolName field in the TeacherID row, associating a Teacher with a school and, currently

there are 5 schools... I don't have to do any kind of table join - all fields are in one table.

No problem with pulling a total on the total number of logins of ALL teachers in ALL schools or All teachers in THIS school and then comparing this

number between the different schools.

But I can see more than one "false positive" per the following:

Say, there are 20 TeacherID in School_01 and 40 TeacherID in School_02. And say, totaling the LoginCounter column shows a total of 30 teacher logins

for School_01 and 50 teacher logins for School_02. By just adding up the total LoginCounter per school would show that School_01 has the lowest number

of teacher logins.

However, you have to take into consideration that some teachers may have only logged in once (or rather, none)... as well as considering that, say, 15

teachers out of 20 teachers in School_01 may have logged in a total of 30 times... when, at School_02, one teacher may have logged in 35 times along

with 5 of his colleagues logging in once apiece. In this scenario School_01 still has the lowest total of loggins but School_02 actually has the poorer

score of total teacher logins.

How would I average the number of teachers per school with the total number of schools with the number of logins per teacher to

obtain an accurate count of actual teacher logins? An "over-zealous" teacher, logging in way more numerous times than other teachers would throw the

final figure off...

Is it even possible to obtain an accurate comparison the way I have the database fields set up? I guess (the way I have it set up) I can only consider the LoginCounter fields that have only a "1" (the number of teachers who have never logged in) and get an average to compare between schools. But if all the teachers in a school have logged in numerous times, I'll have to find some kind of "representative number" based on some kind of average between the number of teachers in a school and (the part I can't figure) some kind of average of each teacher's login total.

In retrospect, after re-reading this before posting... I guess I have only two things here: (1) The total number of logins per school (disregarding an

'over-zealous' teacher and, (2) a count on teachers who have never logged in, compared between schools. I just don't know if I can get an accurate

count for "Lowest Number of Logins School" if all teachers in a school have logged in numerous times... Is there a way to get some kind of average, or rather some 'representative number'  based on the number of teachers per school and each one's login total? Or, maybe each teacher's LoginCount doesn't even come into play here... (I know this sounds a bit confusing.)

- ed

    This topic has been closed for replies.

    4 replies

    Owainnorth
    Inspiring
    December 1, 2010

    Sounds like you need a table of user logins, that would solve pretty all your problems and means you're definitely storing all the data you need, then it's just a case of querying it back correcand grouping correctly.

    NessmukAuthor
    Inspiring
    December 1, 2010

    Thanks for the responses, folks...

    All of you are right about the LoginCounter not having to have a default of "1". I had forgotten that, when a participating school is set up, all teachers are set up with a unique "generic-basic unique login" name and password -- just to be able to login on "Training Day". They can change their name and password once they are in their admin section. Teachers who aren't there on "Training Day" are sent an email with instructions on logging in for the first time and changing their name and password. I guess what I'm saying is that, when a participating school 'comes on board', all the participating teachers are added to the database before they even start using the teacher admin section. Maybe it doesn't matter -- I just didn't want an empty or null value when each row is set up...

    The login code is as follows, running on the 'validation page' upon login submit.

    <cfif session.status IS "valid">
    <cfoutput QUERY="getuser">
    <cfif #LastLoginDate# NEQ #TodaysDateTime#>
        <cfset #newcount# = LoginCounter + 1>
        <cfquery datasource="#application.dsn#">
        UPDATE teacher_logon
    SET
    LastLoginDate=#TodaysDateTime#,
    LoginCounter=#newcount#
    WHERE AdminID = #AminID#
    </cfquery>
    <cflocation url="Teacher/index.cfm?TeacherID=#AdminID#" addtoken="Yes">
    </cfif>
    </cfoutput>

    So... "0" + "1" = "1" ... I just wasn't sure, when I wrote the code, if this field could be left blank ("blank" + "1")... so, when the individual's row is first entered I put a default "1" here -- since, for training purposes they are already set up to go into the admin section with a pre-created name and password. I figured I could always subtract "1" from the individual's LoginCounter field for accuracy.

    I think 12Roberts login ratio is probably what I'm looking for -- Login Ratio: A = total number of teachers and Z = teachers who have never logged in...... Login Ratio = A-Z. (In my existing case a field value of "1" would equal a teacher who has never logged in and a field value of "2" would be a teacher who has logged in once.) I know, I know -- Why don't I just make it complicated or something, LOL.)

    I think I was over-blowing my question and 12Robots simple Login Ration is what I was looking. Thanks, 12Robots and, thanks to all for the input. I'm going to mark this post as 'solved' since, the way I have this set up, this ratio is about all I can do with a "lowest login school count".

    Thanks again, folks...

    - ed

    12Robots
    Participating Frequently
    December 1, 2010

    As far as your other questions are concerned, do you have to produce ONE final number per school?

    These kinds of analytics are typically reported using multiple numbers.  For example:

    Total Teacher logins: X

    Unique Teach Logins: Y

    Teachers who have never logged in: Z

    Total Number of Teachers: A

    Login Ratio: A:(A-Z)

    Or something like that.

    Hope this helps. And I would still like to know why your counter logic requires a default of 1, cause that doesn't make sense to me. If a teacher has never logged in, the value should be 0.

    Jason

    12Robots
    Participating Frequently
    December 1, 2010

    I'm curious why you feel this it true: "..for my counter code to work, this field starts with a default of 1".

    Why can't you start with zero (0)?

    Jason

    Inspiring
    December 1, 2010

    The way you are storing your data does not enable you to do that.  For information like that, you need a database record for every login.  You said you were simply incrementing a counter.