예제 #1
0
파일: lib.php 프로젝트: numbas/moodle
/**
 * this returns the position where the user can continue the completing.
 *
 * @global object
 * @global object
 * @global object
 * @param int $feedbackid
 * @param int $courseid
 * @param string $guestid this id will be saved temporary and is unique
 * @return int the position to continue
 */
function feedback_get_page_to_continue($feedbackid, $courseid = false, $guestid = false) {
    global $CFG, $USER, $DB;

    //is there any break?

    if (!$allbreaks = feedback_get_all_break_positions($feedbackid)) {
        return false;
    }

    $params = array();
    if ($courseid) {
        $courseselect = "AND fv.course_id = :courseid";
        $params['courseid'] = $courseid;
    } else {
        $courseselect = '';
    }

    if ($guestid) {
        $userselect = "AND fc.guestid = :guestid";
        $usergroup = "GROUP BY fc.guestid";
        $params['guestid'] = $guestid;
    } else {
        $userselect = "AND fc.userid = :userid";
        $usergroup = "GROUP BY fc.userid";
        $params['userid'] = $USER->id;
    }

    $sql =  "SELECT MAX(fi.position)
               FROM {feedback_completedtmp} fc, {feedback_valuetmp} fv, {feedback_item} fi
              WHERE fc.id = fv.completed
                    $userselect
                    AND fc.feedback = :feedbackid
                    $courseselect
                    AND fi.id = fv.item
         $usergroup";
    $params['feedbackid'] = $feedbackid;

    $lastpos = $DB->get_field_sql($sql, $params);

    //the index of found pagebreak is the searched pagenumber
    foreach ($allbreaks as $pagenr => $br) {
        if ($lastpos < $br) {
            return $pagenr;
        }
    }
    return count($allbreaks);
}
예제 #2
0
파일: lib.php 프로젝트: nadavkav/MoodleTAO
/** 
 *  this returns the position where the user can continue the completing.
 *  @param int $feedbackid
 *  @param int $courseid
 *  @param string $guestid this id will be saved temporary and is unique
 *  @return int the position to continue
 */
function feedback_get_page_to_continue($feedbackid, $courseid = false, $guestid)
{
    global $CFG, $USER;
    //is there any break?
    if (!($allbreaks = feedback_get_all_break_positions($feedbackid))) {
        return false;
    }
    if ($courseid) {
        $courseselect = "fv.course_id = " . $courseid;
    } else {
        $courseselect = "1";
    }
    if ($guestid) {
        $userselect = "AND fc.guestid = '" . $guestid . "'";
        $usergroup = "GROUP BY fc.guestid";
    } else {
        $userselect = "AND fc.userid = " . $USER->id;
        $usergroup = "GROUP BY fc.userid";
    }
    $sql = "SELECT MAX(fi.position)\n                FROM " . $CFG->prefix . "feedback_completedtmp AS fc, " . $CFG->prefix . "feedback_valuetmp AS fv, " . $CFG->prefix . "feedback_item AS fi\n                WHERE fc.id = fv.completed\n                    " . $userselect . "\n                    AND fc.feedback = " . $feedbackid . "\n                    AND " . $courseselect . "\n                    AND fi.id = fv.item\n                " . $usergroup;
    $lastpos = get_field_sql($sql);
    //the index of found pagebreak is the searched pagenumber
    foreach ($allbreaks as $pagenr => $br) {
        if ($lastpos < $br) {
            return $pagenr;
        }
    }
    return count($allbreaks);
}
예제 #3
0
                 feedback_send_email_anonym($cm, $feedback, $course, $userid);
             }
             //tracking the submit
             $multiple_count = null;
             $multiple_count->userid = $USER->id;
             $multiple_count->feedback = $feedback->id;
             $multiple_count->completed = $new_completed_id;
             $multiple_count->count = 1;
             insert_record('feedback_tracking', $multiple_count);
             unset($SESSION->feedback->is_started);
         } else {
             $savereturn = 'failed';
         }
     }
 }
 if ($allbreaks = feedback_get_all_break_positions($feedback->id)) {
     if ($gopage <= 0) {
         $startposition = 0;
     } else {
         $startposition = $allbreaks[$gopage - 1];
     }
     $ispagebreak = true;
 } else {
     $startposition = 0;
     $newpage = 0;
     $ispagebreak = false;
 }
 //get the feedbackitems after the last shown pagebreak
 $feedbackitems = get_records_select('feedback_item', 'feedback = ' . $feedback->id . ' AND position > ' . $startposition, 'position');
 //get the first pagebreak
 if ($pagebreaks = get_records_select('feedback_item', "feedback = " . $feedback->id . " AND typ = 'pagebreak'", 'position')) {
예제 #4
0
파일: lib.php 프로젝트: evltuma/moodle
/**
 * this returns the position where the user can continue the completing.
 *
 * @deprecated since Moodle 3.1
 * @global object
 * @global object
 * @global object
 * @param int $feedbackid
 * @param int $courseid
 * @param string $guestid this id will be saved temporary and is unique
 * @return int the position to continue
 */
function feedback_get_page_to_continue($feedbackid, $courseid = false, $guestid = false)
{
    global $CFG, $USER, $DB;
    debugging('Function feedback_get_page_to_continue() is deprecated and since it is ' . 'no longer used in mod_feedback', DEBUG_DEVELOPER);
    //is there any break?
    if (!($allbreaks = feedback_get_all_break_positions($feedbackid))) {
        return false;
    }
    $params = array();
    if ($courseid) {
        $courseselect = "AND fv.course_id = :courseid";
        $params['courseid'] = $courseid;
    } else {
        $courseselect = '';
    }
    if ($guestid) {
        $userselect = "AND fc.guestid = :guestid";
        $usergroup = "GROUP BY fc.guestid";
        $params['guestid'] = $guestid;
    } else {
        $userselect = "AND fc.userid = :userid";
        $usergroup = "GROUP BY fc.userid";
        $params['userid'] = $USER->id;
    }
    $sql = "SELECT MAX(fi.position)\n               FROM {feedback_completedtmp} fc, {feedback_valuetmp} fv, {feedback_item} fi\n              WHERE fc.id = fv.completed\n                    {$userselect}\n                    AND fc.feedback = :feedbackid\n                    {$courseselect}\n                    AND fi.id = fv.item\n         {$usergroup}";
    $params['feedbackid'] = $feedbackid;
    $lastpos = $DB->get_field_sql($sql, $params);
    //the index of found pagebreak is the searched pagenumber
    foreach ($allbreaks as $pagenr => $br) {
        if ($lastpos < $br) {
            return $pagenr;
        }
    }
    return count($allbreaks);
}