Forum Replies Created

Viewing 15 replies - 16 through 30 (of 89 total)
  • Thread Starter crowwoods1

    (@crowwoods1)

    Hi,

    Thanks for the suggestion! I see that I wasn’t clear that the dropdowns I have trouble with are in my Signup form, and not in the top menu. The dropdown fields, Team, Organization and Country, are created in Participant Database. It works on the computer. The dropdown fields on the mobile even show the options from my parameters, just not from the database. I was told it may have something to do with the cache.

    Yay!!!! It worked.

    Thanks for being patient!

    So I had calculations.php write the values for:
    template ->calc_body – looks great
    replacement data – looks great
    calc_list – nope, that’s what’s in the database

    So I went back to the custom_calc_field.php, the replacement value there looks good too. So maybe my problem is instead of using $record_data for all the calculations, I just need to use $replacement_data for them. What do you think?

    • This reply was modified 2 years, 8 months ago by crowwoods1.

    Thanks! Looking at calculation.php, line 84 seems to indicate that replacement data is based on $post.
    abstract protected function replacement_data( $post );

    Then line 192 seems to be setting the submission data as something that requires the field to be checked for signup.

    public function set_submission_value( $post )
      {
        foreach( $this->field_list() as $field )
        {
          if ( $field->is_signup() && isset( $post[$field->name()] ) ) {
            $this->set_field( $field->name() );
            $post[$field->name()] = $this->dynamic_value($post);
          }
        }
        
        return $post;
      }

    Most of my fields are not checked for signup. Ironically ‘role’ is the only field that’s indicated for signup. Is that a problem?

    I think if I can debug the file for numeric calculation, the one that calls this filter, I can see if it’s at least reading the template. What is the name of the file, and where can I find it?

    Thanks!

    If I want to debug it, what file(s) should I be looking at?

    ok, I deactivated my Google analytics, and the [?integer] is now working. Not sure if that’s related. The only other 2 plugins are Elementor and Calculated Fields Form.

    I know that when I first used the Echo (probably 2 upgrades ago), it was picking up the right data. It’s just that I couldn’t see the Echo unless I went back a screen. Now 2 upgrades later, I can’t even read in the right data.

    Does it have to do with this? I’m reading the record, not something just submitted and not gone into the record.
    $record_data = Participants_Db::get_participant( $field->record_id );

    Also, the Calculated Fields Form plugin allows for dynamic updating of the points field. As one updates the actions, the points update right away. No button to press. Unfortunately I can’t get it to write to the database. Can something like that be done with Participant Database?

    It doesn’t work and this is what I put into one of the templates.

    [change_led] + [test_drive] + [plant_tree] + [local_csa] + [volunteer] + [paperless] + [rain_barrels] + [aerators] + [microplastics] + [shower_heads] + [running_toilets] =[?unformatted]

    Now I put =[?integer] in at the end but every time I save, it adds [?unformatted] to the end. So I removed =[?integer]
    Does that cause it not to work?

    Nope! I put all the related fields in the templates but it’s still the same.

    I see, so I would have to have all 43 fields in the calculation template for regular_points. That seems doable.

    Is it a problem since role is not a numeric field?

    Roland,

    I used echo and I found the culprit, yay! But I don’t know how to fix it.

    It looks like the $record_data[‘role’] is pulling in the role before the update. So how do I get it to pick up the one that’s after the update?

    Ivy

    I put in an error_log right before the role_points return but it didn’t show up in the log.

    error_log(“result for role_points: $result and replacement data: $replacement_data”);

    Also, are the $result and $replacement_data supposed to be the same? Where is $replacement data set?

    I simplified the code so that it’s clear which calculated fields is doing what but the result is the same.

    Now the only thing in the debugging log between each of the updates is:
    PDb_Participant_Cache::refresh_cache: Refreshing Participants Database cache for cache group 0

    Could this have something to do with it?

    Incidentally, if I don’t redo all the calculations for role points, one time points and regular points in the program, the total points would be zero. That tells me that even though each of those 3 calculation $result is returned before calculating total points, it is not saved to the database right away. They all sit somewhere and get updated together. So the question is what is the signal that allows them to be updated. I think that signal has to be outside my program.

    What kind of error_log do you suggest? As I mentioned before, I had echo statements in there for the $result originally, and it’s calculating correctly. It’s just that what was in the echo was not posted to the database immediately. Back then I can step back a page, and the echo would be there, like they’re sitting in the back waiting to be updated.

    I have to say that total points are always in sync with the other 3 points. It posts the total of role points, one time points and regular points, whether those are from a prior time or this time.

    How do you mean to simplify the program? Like this?
    if ( $field->name() == ‘role_points’){}
    elseif ( $field->name() == ‘one_time_points’){}
    elseif ( $field->name() == ‘regular_points’){}
    elseif ( $field->name() == ‘total_points’){}

    That’s how I had it originally, but my non-php programmer friend thought that it’s not good because the total points section has to repeat all the calculations for the other 3 points, adding to the number of lines in the program. If you think my original way is better, I’ll switch back. I don’t think that’s the problem though.

Viewing 15 replies - 16 through 30 (of 89 total)