function delete_relation($params, $pod) { error_log('delete relation ' . json_encode($params) . '-' . json_encode($pod)); $evaluations = RelationModel::evaluations($params->id); error_log('rel evaluations ' . json_encode($evaluations)); foreach ($evaluations as $key => $evaluation) { wp_delete_post($evaluation->ID, true); } }
* @param evaluation_id * @param step */ Ajax::run('getHistoricalResponses', 'both', function () { if (file_exists(LS_RPC_PATH)) { require_once LS_RPC_PATH; } else { die(print_r(LS_RPC_PATH, true)); } // get all evaluations for a given relation $relation_id = array_key_exists('relation_id', $_REQUEST) ? (int) $_REQUEST['relation_id'] : null; $relation_step = array_key_exists('step', $_REQUEST) ? (int) $_REQUEST['step'] : null; $evaluation_id = array_key_exists('evaluation_id', $_REQUEST) ? (int) $_REQUEST['evaluation_id'] : null; $evaluations = []; if ($relation_id) { $evaluations = RelationModel::evaluations($relation_id); } elseif ($evaluation_id) { $evaluations[] = pods('evaluation', $evaluation_id); } // instanciate a new client $myJSONRPCClient = new jsonRPCClient(LS_BASEURL); // receive session key $sessionKey = $myJSONRPCClient->get_session_key(LS_USER, LS_PASSWORD); // calculate averages for current evaluation $response = []; foreach ($evaluations as $key => $evaluation) { $limesurvey_id = EvaluationModel::surveyID($evaluation->ID, $relation_step); $type = $relation_step === '360' ? 'company' : 'agency'; // questions $questions_filename = $type . '_' . $limesurvey_id . '_questions.json'; $survey_questions = json_decode(file_get_contents(CABSPATH . 'cache/' . $questions_filename), true);