Class: V1::CalcsController

Inherits:
ApiController
  • Object
show all
Defined in:
api/app/api/v1/calcs_controller.rb

Overview

Serves calculations

Instance Method Summary collapse

Instance Method Details

#payloadHash<String, Object>

This endpoint will return all data for a specific test.

Options (one required)

  • [Integer] sensory_test_id
  • [Integer] analysis_id
  • [Integer] recruiting_campaign_id

(C#) How to see which sample-entry blinding codes were used (code_as_entered below) for a given completed_survey

    // `completed_surveys` and `serving_samples` can share a `serving_id`
    survey = payload.surveys.First()
    completed_survey = survey.completed_surveys.First()
    // look up which codes were entered for the `completed_survey` during sample entry
    IEnumerable<string> serving_samples = payload.serving_samples.Where(s => s.serving_id == completed_survey.serving_id)
                                                                 .Select(s => s.code_as_entered)
                                                                 .Distinct()
                                                                 .Where(x => !string.IsNullOrEmpty(x))
                                                                 .OrderBy(x => x);

Example

Fetch a payload for a sensory test

    curl -X GET "https://app.redjade.net/api/v1/calcs/payload.json?sensory_test_id=12345" -H "authorization: Bearer $bearer_token"
    {
      "response": {
          "analysis": {...},
          "samples": {...},
          "participants": {...},
          "demographic_categories": {...},
          "events": {...},
          "serving_samples": [
             "serving_id": 123,
             "sample_id": 321,
             "sequence_position": 1,
             "code_as_entered": "A",
             "assigned_blinding_code": "A"
          ],
          "surveys": [
            {
              "id": 1,
              ...,
              "completed_surveys": [
                "serving_id": 123
                ...
              ],
            },
            ...
          ]
        }
    }

Returns:

  • (Hash<String, Object>)

    all study data, for a complete response please download the following .json file: redjade_api_demo