예제 #1
0
/**
 * Set attempt in a text string with the date
 * 
 * @param stdClass $attempt The treasure hunt course module activity.
 * @param bool $groupmode If instance is in group mode or not.
 * @return string 
 */
function treasurehunt_set_string_attempt($attempt, $groupmode)
{
    $attempt->date = userdate($attempt->timecreated);
    // Si se es un grupo y el usuario no es el mismo que el que lo descubrio/fallo.
    if ($groupmode) {
        $attempt->user = treasurehunt_get_user_fullname_from_id($attempt->user);
        // If it is an attempt to a question.
        if ($attempt->type === 'question') {
            if ($attempt->questionsolved) {
                return get_string('groupquestionovercome', 'treasurehunt', $attempt);
            } else {
                return get_string('groupquestionfailed', 'treasurehunt', $attempt);
            }
        } else {
            if ($attempt->type === 'location') {
                if ($attempt->geometrysolved) {
                    if (!$attempt->success) {
                        return get_string('grouplocationovercome', 'treasurehunt', $attempt);
                    } else {
                        return get_string('groupstageovercome', 'treasurehunt', $attempt);
                    }
                } else {
                    return get_string('grouplocationfailed', 'treasurehunt', $attempt);
                }
            } else {
                if ($attempt->type === 'activity') {
                    return get_string('groupactivityovercome', 'treasurehunt', $attempt);
                }
            }
        }
    } else {
        // Individual mode.
        // If it is an attempt to a question.
        if ($attempt->type === 'question') {
            if ($attempt->questionsolved) {
                return get_string('userquestionovercome', 'treasurehunt', $attempt);
            } else {
                return get_string('userquestionfailed', 'treasurehunt', $attempt);
            }
        } else {
            if ($attempt->type === 'location') {
                if ($attempt->geometrysolved) {
                    if (!$attempt->success) {
                        return get_string('userlocationovercome', 'treasurehunt', $attempt);
                    } else {
                        return get_string('userstageovercome', 'treasurehunt', $attempt);
                    }
                } else {
                    return get_string('userlocationfailed', 'treasurehunt', $attempt);
                }
            } else {
                if ($attempt->type === 'activity') {
                    return get_string('useractivityovercome', 'treasurehunt', $attempt);
                }
            }
        }
    }
}
예제 #2
0
    try {
        $teacherreview = true;
        $username = '';
        if ($groupid != -1) {
            $username = groups_get_group_name($groupid);
            $params = treasurehunt_get_group_road($groupid, $treasurehunt->id, $username);
        } else {
            if ($userid == $USER->id) {
                $teacherreview = false;
            } else {
                $username = treasurehunt_get_user_fullname_from_id($userid);
            }
            $params = treasurehunt_get_user_group_and_road($userid, $treasurehunt, $cm->id, $teacherreview, $username);
            if ($userid == $USER->id) {
                if ($params->groupid) {
                    $username = groups_get_group_name($params->groupid);
                } else {
                    $username = treasurehunt_get_user_fullname_from_id($userid);
                }
            }
        }
        echo treasurehunt_view_user_historical_attempts($treasurehunt, $params->groupid, $userid, $params->roadid, $cm->id, $username, $teacherreview);
    } catch (Exception $e) {
        echo $output->notification($e->getMessage());
    }
}
if (has_capability('mod/treasurehunt:managetreasurehunt', $context) || has_capability('mod/treasurehunt:viewusershistoricalattempts', $context) || time() > $treasurehunt->allowattemptsfromdate) {
    echo treasurehunt_view_users_progress_table($cm, $course->id, $context);
}
// Finish the page.
echo $output->footer();