Ejemplo n.º 1
0
             } else {
                 $answer1 = " ";
             }
             if ($a->answer2) {
                 $answer2 = "{$a->answer2} - " . $answers[$a->answer2 - 1];
             } else {
                 $answer2 = " ";
             }
             $table->data[] = array($OUTPUT->user_picture($a, array('courseid' => $course->id)), "<a href=\"report.php?id={$id}&amp;action=student&amp;student={$a->userid}\">" . fullname($a) . "</a>", userdate($a->time), $answer1, $answer2);
         }
     }
     echo html_writer::table($table);
     break;
 case "students":
     echo $OUTPUT->heading(get_string("analysisof", "survey", get_string('participants')));
     if (!($results = survey_get_responses($survey->id, $currentgroup, $groupingid))) {
         echo $OUTPUT->notification(get_string("nobodyyet", "survey"));
     } else {
         survey_print_all_responses($cm->id, $results, $course->id);
     }
     break;
 case "student":
     if (!($user = $DB->get_record("user", array("id" => $student)))) {
         print_error('invaliduserid');
     }
     echo $OUTPUT->heading(get_string("analysisof", "survey", fullname($user)));
     if ($notes != '' and confirm_sesskey()) {
         if (survey_get_analysis($survey->id, $user->id)) {
             if (!survey_update_analysis($survey->id, $user->id, $notes)) {
                 echo $OUTPUT->notification("An error occurred while saving your notes.  Sorry.");
             } else {
Ejemplo n.º 2
0
/**
 * @param int $surveyid
 * @param int $groupid
 * @param int $groupingid
 * @return int
 */
function survey_count_responses($surveyid, $groupid, $groupingid) {
    if ($responses = survey_get_responses($surveyid, $groupid, $groupingid)) {
        return count($responses);
    } else {
        return 0;
    }
}
Ejemplo n.º 3
0
function get_survey_info(&$surveys, &$responses, &$accessibility)
{
    // initialize return values
    $surveys = array();
    $responses = array();
    $accessibility = array();
    // everybody gets the public surveys
    esp_require_once('/lib/espsurvey');
    survey_get_public($surveys);
    $sids = array_keys($surveys);
    // if we have a current (authenticated) respondent
    $ok = get_current_respondent($respondent);
    if ($ok && array_key_exists('realm', $respondent)) {
        // get the surveys available to that user
        survey_get_in_realm($respondent['realm'], $private);
        survey_merge_sets($surveys, $private);
        $sids = array_keys($surveys);
        // get the responses and accessibility for those surveys
        survey_get_responses($responses, $sids, $respondent['username']);
        survey_get_accessibility($accessibility, $sids, $respondent['username'], $respondent['realm']);
    } else {
        // get the accessibility of those surveys
        survey_get_accessibility($accessibility, $sids);
    }
    return true;
}