コード例 #1
0
ファイル: lib.php プロジェクト: ccle/moodle-mod_turnitintool
/**
 * Outputs submission inbox for student submissions (Teacher View)
 *
 * @global object
 * @param object $cm The moodle course module object for this instance
 * @param object $turnitintool The turnitintool object for this activity
 * @param string $orderby The query string option for the ordering of the column
 * @return string Output of the tutor view submission inbox
 */
function turnitintool_view_all_submissions($cm, $turnitintool, $orderby = '1')
{
    global $CFG, $USER;
    $param_do = optional_param('do', null, PARAM_CLEAN);
    $param_reason = optional_param('reason', array(), PARAM_CLEAN);
    $module_group = turnitintool_module_group($cm);
    $context = turnitintool_get_context('COURSE', $turnitintool->course);
    $studentusers = get_users_by_capability($context, 'mod/turnitintool:submit', 'u.id,u.firstname,u.lastname', '', '', '', $module_group, '', false);
    $studentuser_array = array_keys($studentusers);
    $scale = turnitintool_get_record('scale', 'id', $turnitintool->grade * -1);
    $parts = turnitintool_get_records_select('turnitintool_parts', 'turnitintoolid=' . $turnitintool->id . ' AND deleted != 1');
    $concat = turnitintool_sql_concat("COALESCE(u.id,0)", "'-'", "COALESCE(s.id,0)", "'-'", "COALESCE(s.submission_objectid,0)");
    $usifieldid = 'NULL';
    $usifield = '';
    $displayusi = 'false';
    if ($CFG->turnitin_enablepseudo and $CFG->turnitin_pseudolastname > 0) {
        $uf = turnitintool_get_record('user_info_field', 'id', $CFG->turnitin_pseudolastname);
        $usifield = $uf->name;
        $usifieldid = $CFG->turnitin_pseudolastname;
    }
    $group_in = join(',', $studentuser_array);
    $groupselect = $module_group != 0 ? "u.id IN ( select gm.userid from {groups_members} gm where gm.groupid = {$module_group} ) AND" : "";
    $query = "\nSELECT\n    {$concat} AS keyid,\n    s.id AS id,\n    u.id AS userid,\n    u.firstname AS firstname,\n    u.lastname AS lastname,\n    ud.data AS usi,\n    tu.turnitin_uid AS turnitin_uid,\n    p.id AS partid,\n    p.partname AS partname,\n    p.dtstart AS dtstart,\n    p.dtdue AS dtdue,\n    p.dtpost AS dtpost,\n    p.maxmarks AS maxmarks,\n    t.name AS assignmentname,\n    t.grade AS overallgrade,\n    t.anon AS anon,\n    t.id AS turnitintoolid,\n    s.submission_part AS submission_part,\n    s.submission_title AS submission_title,\n    s.submission_type AS submission_type,\n    s.submission_filename AS submission_filename,\n    s.submission_objectid AS submission_objectid,\n    s.submission_score AS submission_score,\n    s.submission_grade AS submission_grade,\n    s.submission_gmimaged AS submission_gmimaged,\n    s.submission_status AS submission_status,\n    s.submission_queued AS submission_queued,\n    s.submission_attempts AS submission_attempts,\n    s.submission_modified AS submission_modified,\n    s.submission_parent AS submission_parent,\n    s.submission_nmuserid AS submission_nmuserid,\n    s.submission_nmfirstname AS submission_nmfirstname,\n    s.submission_nmlastname AS submission_nmlastname,\n    s.submission_unanon AS submission_unanon,\n    s.submission_unanonreason AS submission_unanonreason,\n    s.submission_transmatch AS submission_transmatch\nFROM {turnitintool_submissions} s\n    LEFT JOIN\n        {user} u ON u.id = s.userid\n    LEFT JOIN\n        {turnitintool_parts} p ON p.id = s.submission_part\n    LEFT JOIN\n        {turnitintool} t ON t.id = p.turnitintoolid\n    LEFT JOIN\n        {turnitintool_users} tu ON u.id = tu.userid\n    LEFT JOIN\n        {user_info_data} ud ON u.id = ud.userid AND ud.fieldid = {$usifieldid}\nWHERE\n    {$groupselect}\n    s.turnitintoolid = " . $turnitintool->id . "\nORDER BY s.submission_grade DESC\n";
    $records = turnitintool_get_records_sql($query);
    $records = is_array($records) ? $records : array();
    $userrows = array();
    $subuser_array = array();
    $submissionids = array();
    foreach ($records as $record) {
        $turnitin_uid = !is_null($record->turnitin_uid) ? $record->turnitin_uid : $record->submission_nmuserid;
        $key = $record->userid . '-' . $turnitin_uid;
        $record->nonmoodle = $record->submission_nmuserid ? true : false;
        $userrows[$key][] = $record;
        if (!is_null($record->id)) {
            $submissionids[] = $record->id;
        }
        if (!is_null($record->userid)) {
            $subuser_array[] = $record->userid;
        }
    }
    $comments = array();
    if (count($submissionids) > 0) {
        $submission_string = join(',', $submissionids);
        $comments = turnitintool_get_records_sql('SELECT submissionid, count( id ) AS count FROM {turnitintool_comments} WHERE deleted = 0 AND submissionid IN ( ' . $submission_string . ' ) GROUP BY submissionid');
    }
    $nosubuser_array = (!$turnitintool->shownonsubmission or $turnitintool->anon) ? array() : array_diff($studentuser_array, $subuser_array);
    foreach ($nosubuser_array as $user) {
        $key = $studentusers[$user]->id . '-' . 0;
        $record = new stdClass();
        $record->userid = $studentusers[$user]->id;
        $record->firstname = $studentusers[$user]->firstname;
        $record->lastname = $studentusers[$user]->lastname;
        $userrows[$key][] = $record;
    }
    $table = new stdClass();
    $table->style = 'display: none;';
    $table->width = '100%';
    $table->id = 'inboxTable';
    $table->class = 'gradeTable';
    $table->tablealign = 'center';
    $n = 0;
    $table->rows[0] = new stdClass();
    $table->rows[0]->class = 'header';
    $table->rows[0]->hcells[$n] = new stdClass();
    $table->rows[0]->hcells[$n]->class = 'header c' . $n . ' iconcell';
    $table->rows[0]->hcells[$n]->data = '<div>&nbsp;</div>';
    $n++;
    $table->rows[0]->hcells[$n] = new stdClass();
    $table->rows[0]->hcells[$n]->class = 'header c' . $n . ' iconcell';
    $table->rows[0]->hcells[$n]->data = '<div>&nbsp;</div>';
    $n++;
    $table->rows[0]->hcells[$n] = new stdClass();
    $table->rows[0]->hcells[$n]->class = 'header c' . $n . ' namecell';
    $table->rows[0]->hcells[$n]->data = '<div>' . get_string('submissionstudent', 'turnitintool') . '</div>';
    $n++;
    $table->rows[0]->hcells[$n] = new stdClass();
    $table->rows[0]->hcells[$n]->class = 'header c' . $n . ' markscell';
    $table->rows[0]->hcells[$n]->data = '&nbsp;';
    $n++;
    $table->rows[0]->hcells[$n] = new stdClass();
    $table->rows[0]->hcells[$n]->class = 'header c' . $n . ' markscell';
    $table->rows[0]->hcells[$n]->data = '<div>&nbsp;' . $usifield . '</div>';
    $n++;
    $table->rows[0]->hcells[$n] = new stdClass();
    $table->rows[0]->hcells[$n]->class = 'header c' . $n . ' markscell';
    $table->rows[0]->hcells[$n]->data = '<div>' . get_string('objectid', 'turnitintool') . '</div>';
    $n++;
    $table->rows[0]->hcells[$n] = new stdClass();
    $table->rows[0]->hcells[$n]->class = 'header c' . $n . ' datecell';
    $table->rows[0]->hcells[$n]->data = '&nbsp;';
    $n++;
    $table->rows[0]->hcells[$n] = new stdClass();
    $table->rows[0]->hcells[$n]->class = 'header c' . $n . ' datecell';
    $table->rows[0]->hcells[$n]->data = '<div>' . get_string('posted', 'turnitintool') . '</div>';
    $n++;
    $table->rows[0]->hcells[$n] = new stdClass();
    $table->rows[0]->hcells[$n]->class = 'header c' . $n . ' markscell';
    $table->rows[0]->hcells[$n]->data = '&nbsp;';
    $n++;
    $table->rows[0]->hcells[$n] = new stdClass();
    $table->rows[0]->hcells[$n]->class = 'header c' . $n . ' markscell';
    $table->rows[0]->hcells[$n]->data = '<div>' . get_string('submissionorig', 'turnitintool') . '</div>';
    $n++;
    $table->rows[0]->hcells[$n] = new stdClass();
    $table->rows[0]->hcells[$n]->class = 'header c' . $n . ' markscell';
    $table->rows[0]->hcells[$n]->data = '&nbsp;';
    $n++;
    $table->rows[0]->hcells[$n] = new stdClass();
    $table->rows[0]->hcells[$n]->class = 'header c' . $n . ' markscell';
    $table->rows[0]->hcells[$n]->data = '&nbsp;';
    $n++;
    $table->rows[0]->hcells[$n] = new stdClass();
    $table->rows[0]->hcells[$n]->class = 'header c' . $n . ' markscell';
    $table->rows[0]->hcells[$n]->data = '<div>' . get_string('submissiongrade', 'turnitintool') . '</div>';
    $n++;
    $table->rows[0]->hcells[$n] = new stdClass();
    $table->rows[0]->hcells[$n]->class = 'header c' . $n . ' iconcell';
    $table->rows[0]->hcells[$n]->data = '<div>&nbsp;</div>';
    $n++;
    $table->rows[0]->hcells[$n] = new stdClass();
    $table->rows[0]->hcells[$n]->class = 'header c' . $n . ' iconcell';
    $table->rows[0]->hcells[$n]->data = '<div>&nbsp;</div>';
    $n++;
    $table->rows[0]->hcells[$n] = new stdClass();
    $table->rows[0]->hcells[$n]->class = 'header c' . $n . ' iconcell';
    $table->rows[0]->hcells[$n]->data = '<div>&nbsp;</div>';
    $n++;
    $table->rows[0]->hcells[$n] = new stdClass();
    $table->rows[0]->hcells[$n]->class = 'header c' . $n . ' iconcell';
    $table->rows[0]->hcells[$n]->data = '<div>&nbsp;</div>';
    $n++;
    $table->rows[0]->hcells[$n] = new stdClass();
    $table->rows[0]->hcells[$n]->class = 'header c' . $n . ' iconcell';
    $table->rows[0]->hcells[$n]->data = '<div>&nbsp;</div>';
    $n++;
    $i = 1;
    // $postdatepassed controls whether the inbox displays part view or student name view.
    $postdatepassed = 0;
    // Get the parts, count how many are passed the post date
    $parts = turnitintool_get_records_select('turnitintool_parts', "turnitintoolid=" . $turnitintool->id . " AND deleted=0");
    $postdate_count = 0;
    foreach ($parts as $part) {
        if ($part->dtpost < time()) {
            $postdate_count++;
        }
    }
    // If every part has passed the due date, switch to student name view.
    if ($postdate_count == count($parts)) {
        $postdatepassed = 1;
    }
    foreach ($userrows as $key => $userrow) {
        if (isset($userrow[0]->id)) {
            $overall_grade = turnitintool_overallgrade($userrow, $turnitintool->grade, $parts, $scale);
        }
        $rowcount = count($userrow) == 1 && !isset($userrow[0]->id) ? 0 : count($userrow);
        $submissionstring = $rowcount == 1 ? get_string('submission', 'turnitintool') : get_string('submissions', 'turnitintool');
        if (is_null($userrow[0]->firstname)) {
            $student = '<i>' . $userrow[0]->submission_nmlastname . ', ' . $userrow[0]->submission_nmfirstname . ' (' . get_string('nonmoodleuser', 'turnitintool') . ')</i> - (' . $rowcount . ' ' . $submissionstring . ')';
        } else {
            $student = '<b><a href="' . $CFG->wwwroot . '/user/view.php?id=' . $userrow[0]->userid . '&course=' . $turnitintool->course . '">' . $userrow[0]->lastname . ', ' . $userrow[0]->firstname . '</a></b> - (' . $rowcount . ' ' . $submissionstring . ')';
        }
        foreach ($userrow as $submission) {
            $submission_postdate = (isset($submission->submission_part) and $parts[$submission->submission_part]->dtpost < time()) ? 0 : 1;
            $displayusi = ($turnitintool->anon == 1 and !$postdatepassed or !isset($CFG->turnitin_enablepseudo) or $CFG->turnitin_enablepseudo === "0") ? 'false' : 'true';
            $n = 0;
            if (!isset($submission->id) or is_null($submission->id)) {
                // Do blank user line and continue
                $nmuserid = isset($submission->submission_nmuserid) ? $submission->submission_nmuserid : 0;
                $grouprow = $submission->userid . '-' . $nmuserid;
                $table->rows[$i]->cells[$n] = new stdClass();
                $table->rows[$i]->cells[$n]->class = 'cell c' . $n;
                $table->rows[$i]->cells[$n]->data = $grouprow;
                $n++;
                $table->rows[$i]->cells[$n] = new stdClass();
                $table->rows[$i]->cells[$n]->class = 'cell c' . $n . ' hide';
                $table->rows[$i]->cells[$n]->data = $student;
                $n++;
                for ($j = 0; $j < 16; $j++) {
                    $table->rows[$i]->cells[$n] = new stdClass();
                    $table->rows[$i]->cells[$n]->class = 'cell c' . $n . ' hide';
                    if ($j == 4) {
                        $output = '00/00/00, 00:00:00';
                    } else {
                        $output = '&nbsp;&nbsp;';
                    }
                    $table->rows[$i]->cells[$n]->data = $output;
                    $n++;
                }
                $i++;
                continue;
            }
            $entryCount[$submission->userid] = !isset($entryCount[$submission->userid]) ? 1 : $entryCount[$submission->userid] + 1;
            $i++;
            $lastclass = $i == $rowcount ? ' lastmark' : ' leftmark';
            // Do Sort Row, Part Name if Anon and User Name if not
            if ($submission->anon and !$postdatepassed) {
                $grouprow = $submission->partid;
            } else {
                $grouprow = $submission->userid . '-' . $submission->submission_nmuserid;
            }
            $table->rows[$i]->cells[$n] = new stdClass();
            $table->rows[$i]->cells[$n]->class = 'cell c' . $n;
            $table->rows[$i]->cells[$n]->data = $grouprow;
            $n++;
            // Do Sort header table
            if ($submission->anon and !$postdatepassed) {
                $grouptable = '<b>' . $submission->partname . '</b>';
            } else {
                $grouptable = $student;
            }
            $table->rows[$i]->cells[$n] = new stdClass();
            $table->rows[$i]->cells[$n]->class = 'cell c' . $n . ' hide';
            $table->rows[$i]->cells[$n]->data = $grouptable;
            $n++;
            // Do Submission Filelink / Anon Button Column
            $filelink = turnitintool_get_filelink($cm, $turnitintool, $submission);
            $doscript = '';
            if (!empty($submission->submission_objectid)) {
                $doscript = ' onclick="screenOpen(\'' . $filelink . '\',\'' . $submission->id . '\',\'' . $turnitintool->autoupdates . '\');return false;"';
            }
            $length = 60;
            $truncate = strlen($submission->submission_title) > $length ? substr($submission->submission_title, 0, $length) . '...' : $submission->submission_title;
            if (!$turnitintool->anon or $postdatepassed) {
                $submission_link = '<b>' . $submission->partname . '</b>: <a href="' . $filelink . '" target="_blank" class="fileicon"' . $doscript . ' title="' . $submission->submission_title . '">' . $truncate . '</a>';
            } else {
                if ($submission->submission_unanon and $turnitintool->anon) {
                    $submission_link = '<b><a href="' . $CFG->wwwroot . '/user/view.php?id=' . $userrow[0]->userid . '&course=' . $turnitintool->course . '">' . $userrow[0]->lastname . ', ' . $userrow[0]->firstname . '</a></b>: ';
                    $submission_link .= '<a href="' . $filelink . '" target="_blank" class="fileicon"' . $doscript . ' title="' . $submission->submission_title . '">' . $truncate . '</a>';
                } else {
                    if ($turnitintool->anon and !$postdatepassed) {
                        $reason = isset($param_reason[$submission->submission_objectid]) ? $param_reason[$submission->submission_objectid] : get_string('revealreason', 'turnitintool');
                        // If there is not an object ID, disable the reveal name button
                        $disabled = $submission->submission_objectid == null ? 'disabled' : '';
                        $submission_link = '<a href="' . $filelink . '" target="_blank" class="fileicon"' . $doscript . ' title="' . $submission->submission_title . '" style="line-height: 1.8em;">' . $truncate . '</a><br /><span id="anonform_' . $submission->submission_objectid . '" style="display: none;"><form action="' . $CFG->wwwroot . '/mod/turnitintool/view.php?id=' . $cm->id . '&do=allsubmissions" method="POST" class="" onsubmit="return anonValidate(this.reason);">&nbsp;&nbsp;&nbsp;<input id="reason" name="reason[' . $submission->submission_objectid . ']" value="' . $reason . '" type="text" onclick="this.value=\'\';" /><input id="anonid" name="anonid" value="' . $submission->submission_objectid . '" type="hidden" />&nbsp;<input value="' . get_string('reveal', 'turnitintool') . '" type="submit" /></form></span><button id="studentname_' . $submission->submission_objectid . '" ' . $disabled . ' onclick="document.getElementById(\'anonform_' . $submission->submission_objectid . '\').style.display = \'block\';this.style.display = \'none\';">' . get_string('anonenabled', 'turnitintool') . '</button>';
                    }
                }
            }
            $table->rows[$i]->cells[$n] = new stdClass();
            $table->rows[$i]->cells[$n]->class = 'cell c' . $n . $lastclass;
            $table->rows[$i]->cells[$n]->data = $submission_link;
            $n++;
            // Output USI if required
            $table->rows[$i]->cells[$n] = new stdClass();
            $table->rows[$i]->cells[$n]->class = 'cell c' . $n . ' markscell';
            $table->rows[$i]->cells[$n]->data = (!isset($submission->usi) or $submission->anon and !$postdatepassed) ? '&nbsp;' : $submission->usi;
            $n++;
            $table->rows[$i]->cells[$n] = new stdClass();
            $table->rows[$i]->cells[$n]->class = 'cell c' . $n . ' markscell';
            $table->rows[$i]->cells[$n]->data = '&nbsp;';
            $n++;
            // Do Paper ID column
            $objectid = (is_null($submission->submission_objectid) or empty($submission->submission_objectid)) ? '-' : $submission->submission_objectid;
            $table->rows[$i]->cells[$n] = new stdClass();
            $table->rows[$i]->cells[$n]->class = 'cell c' . $n . ' markscell';
            $table->rows[$i]->cells[$n]->data = $objectid;
            $n++;
            // Do the hidden column for the submission date - used for sorting.
            $table->rows[$i]->cells[$n] = new stdClass();
            $table->rows[$i]->cells[$n]->class = 'cell c' . $n . ' datecell';
            $table->rows[$i]->cells[$n]->data = $submission->submission_modified;
            $n++;
            // Do Submission to Turnitin Form
            $modified = '-';
            if (empty($submission->submission_objectid) and $turnitintool->autosubmission) {
                $modified = '<div class="submittoLinkSmall"><img src="' . $CFG->wwwroot . '/mod/turnitintool/icon.gif" /><a href="' . $CFG->wwwroot . '/mod/turnitintool/view.php' . '?id=' . $cm->id . '&up=' . $submission->id . '">' . get_string('submittoturnitin', 'turnitintool') . '</a></div>';
            } else {
                if (!is_null($submission->id)) {
                    $modified = empty($submission->submission_objectid) ? '-' : userdate($submission->submission_modified, get_string('strftimedatetimeshort', 'langconfig'));
                    if ($submission->submission_modified > $submission->dtdue) {
                        $modified = '<span style="color: red;">' . $modified . '</span>';
                    }
                }
            }
            $table->rows[$i]->cells[$n] = new stdClass();
            $table->rows[$i]->cells[$n]->class = 'cell c' . $n . ' datecell';
            $table->rows[$i]->cells[$n]->data = $modified;
            $n++;
            // Get originality score if available
            $table->rows[$i]->cells[$n] = new stdClass();
            $table->rows[$i]->cells[$n]->class = 'cell c' . $n . ' markscell';
            $table->rows[$i]->cells[$n]->data = $submission->submission_score;
            $n++;
            $score = turnitintool_draw_similarityscore($cm, $turnitintool, $submission);
            $table->rows[$i]->cells[$n] = new stdClass();
            $table->rows[$i]->cells[$n]->class = 'cell c' . $n . ' markscell';
            $table->rows[$i]->cells[$n]->data = $score;
            $n++;
            // Get grade if available
            $grade = turnitintool_dogradeoutput($cm, $turnitintool, $submission, $submission->dtdue, $submission->dtpost, $submission->maxmarks);
            $grade = '<form action="' . $CFG->wwwroot . '/mod/turnitintool/view.php' . '?id=' . $cm->id . '&do=allsubmissions" method="POST">' . $grade . '</form>';
            // Raw grade goes in hidden column for sorting
            $table->rows[$i]->cells[$n] = new stdClass();
            $table->rows[$i]->cells[$n]->class = 'cell c' . $n . ' markscell';
            if ($turnitintool->grade == 0 or $overall_grade === '-') {
                $overall_grade = '-';
            } else {
                if ($turnitintool->grade < 0) {
                    // Scale
                    $scalearray = explode(",", $scale->scale);
                    // Array is zero indexed
                    // Scale positions are from 1 upward
                    $index = $overall_grade - 1;
                    $overall_grade = $index < 0 ? $scalearray[0] : $scalearray[$index];
                } else {
                    if ($turnitintool->gradedisplay == 2) {
                        // 2 is fraction
                        $overall_grade .= '/' . $turnitintool->grade;
                    } else {
                        if ($turnitintool->gradedisplay == 1) {
                            // 1 is percentage
                            $overall_grade = round($overall_grade / $turnitintool->grade * 100, 1) . '%';
                        }
                    }
                }
            }
            $overall_grade = ($turnitintool->anon and !$postdatepassed) ? '-' . $submission->submission_part : $overall_grade;
            $table->rows[$i]->cells[$n]->data = $overall_grade;
            $n++;
            $subgrade = $submission->submission_grade;
            $table->rows[$i]->cells[$n] = new stdClass();
            $table->rows[$i]->cells[$n]->class = 'cell c' . $n . ' markscell';
            $table->rows[$i]->cells[$n]->data = (!is_null($subgrade) and $subgrade != '-') ? $subgrade : 0;
            $n++;
            $table->rows[$i]->cells[$n] = new stdClass();
            $table->rows[$i]->cells[$n]->class = 'cell c' . $n . ' markscell';
            $table->rows[$i]->cells[$n]->data = $grade;
            $n++;
            // Get Student View indicator
            $grademarkurl = $CFG->wwwroot . '/mod/turnitintool/view.php?id=' . $cm->id . '&jumppage=grade';
            $grademarkurl .= '&userid=' . $USER->id . '&utp=2&objectid=' . $submission->submission_objectid;
            $warn = ($turnitintool->reportgenspeed > 0 and $submission->dtdue > time()) ? $warn = ',\'' . get_string('resubmissiongradewarn', 'turnitintool') . '\'' : '';
            if ($submission->submission_attempts > 0) {
                $cells['studentview'] = '<a href="' . $grademarkurl . '" title="' . get_string('student_read', 'turnitintool') . ' ' . userdate($submission->submission_attempts) . '" ';
                $cells['studentview'] .= ' onclick="screenOpen(this.href,\'' . $submission->id . '\',\'' . $turnitintool->autoupdates . '\'' . $warn . ');return false;"';
                $cells['studentview'] .= '><img style="position: relative; top: 4px;" src="' . $CFG->wwwroot . '/mod/turnitintool/pix/icon-student-read.png" class="tiiicons" /></a>';
            } else {
                $cells['studentview'] = '<a href="' . $grademarkurl . '" title="' . get_string('student_notread', 'turnitintool') . '" ';
                $cells['studentview'] .= ' onclick="screenOpen(this.href,\'' . $submission->id . '\',\'' . $turnitintool->autoupdates . '\'' . $warn . ');return false;"';
                $cells['studentview'] .= '><img style="position: relative; top: 4px;" src="' . $CFG->wwwroot . '/mod/turnitintool/pix/icon-dot.png" class="tiiicons" /></a>';
            }
            $table->rows[$i]->cells[$n] = new stdClass();
            $table->rows[$i]->cells[$n]->class = 'cell c' . $n . ' iconcell';
            $table->rows[$i]->cells[$n]->data = $cells['studentview'];
            $n++;
            // Get Feedback Icon if needed
            if (!$submission->nonmoodle) {
                $comment_count = isset($comments[$submission->id]) ? $comments[$submission->id]->count : 0;
                $notes = turnitintool_getnoteslink($cm, $turnitintool, $submission, $comment_count);
            } else {
                $notes = '-';
            }
            $table->rows[$i]->cells[$n] = new stdClass();
            $table->rows[$i]->cells[$n]->class = 'cell c' . $n . ' iconcell';
            $table->rows[$i]->cells[$n]->data = $notes;
            $n++;
            // Get Download Icon if needed
            if (!is_null($submission->submission_objectid)) {
                $downscript = ' onclick="screenOpen(this.href,\'' . $submission->id . '\',false,null,\'width=450,height=200\');return false;"';
                $download = '<a href="' . turnitintool_get_filelink($cm, $turnitintool, $submission, $download = true) . '" title="' . get_string('downloadsubmission', 'turnitintool') . '" target="_blank"' . $downscript . '><img src="pix/file-download.png" alt="' . get_string('downloadsubmission', 'turnitintool') . '" class="tiiicons" /></a>';
            } else {
                $download = '';
            }
            $table->rows[$i]->cells[$n] = new stdClass();
            $table->rows[$i]->cells[$n]->class = 'cell c' . $n . ' iconcell';
            $table->rows[$i]->cells[$n]->data = $download;
            $n++;
            // Get Refresh Icon if needed
            if (!is_null($submission->submission_objectid) && $submission->userid > 0) {
                $refresh = '<a class="refreshrow" style="cursor: pointer;" id="refreshrow-' . $cm->id . '-' . $turnitintool->id . '-' . $submission->id . '-' . $submission->submission_objectid . '" title="' . get_string('refresh', 'turnitintool') . '"><img src="pix/refresh.gif" alt="' . get_string('refresh', 'turnitintool') . '" class="tiiicons" /></a>';
            } else {
                $refresh = '';
            }
            $table->rows[$i]->cells[$n] = new stdClass();
            $table->rows[$i]->cells[$n]->class = 'cell c' . $n . ' iconcell';
            $table->rows[$i]->cells[$n]->data = $refresh;
            $n++;
            // Get Delete Icon if needed
            $fnd = array("\n", "\r");
            $rep = array('\\n', '\\r');
            if (empty($submission->submission_objectid)) {
                $confirm = ' onclick="return confirm(\'' . str_replace($fnd, $rep, get_string('deleteconfirm', 'turnitintool')) . '\');"';
            } else {
                $confirm = ' onclick="return confirm(\'' . str_replace($fnd, $rep, get_string('turnitindeleteconfirm', 'turnitintool')) . '\')"';
            }
            $delete = '<a href="' . $CFG->wwwroot . '/mod/turnitintool/view.php' . '?id=' . $cm->id . '&delete=' . $submission->id . '&do=' . $param_do . '"' . $confirm . ' title="' . get_string('deletesubmission', 'turnitintool') . '"><img src="pix/delete.png" alt="' . get_string('deletesubmission', 'turnitintool') . '" class="tiiicons" /></a>';
            $table->rows[$i]->cells[$n] = new stdClass();
            $table->rows[$i]->cells[$n]->class = 'cell c' . $n . ' iconcell';
            $table->rows[$i]->cells[$n]->data = $delete;
            $n++;
            $i++;
        }
    }
    $sessionrefresh = (isset($_SESSION['updatedscores'][$turnitintool->id]) and $_SESSION['updatedscores'][$turnitintool->id] > 0) ? '' : 'refreshSubmissionsAjax();';
    $output = "\n<script type=\"text/javascript\">\n    var users = " . json_encode($studentuser_array) . ";\n    var message = '" . get_string('turnitinenrollstudents', 'turnitintool') . "';\n    jQuery(document).ready(function() {\n        jQuery.inboxTable.init( '" . $cm->id . "', " . $displayusi . ", " . turnitintool_datatables_strings() . " );\n        jQuery('#loader').css( 'display', 'none' );\n        {$sessionrefresh}\n    });\n</script>";
    $output .= '
        <div class="tabLinks">
        <div style="display: none;" id="inboxNotice"><span style="background: url(pix/ajax-loader.gif) no-repeat left center;padding-left: 80px;">
        <span style="background: url(pix/ajax-loader.gif) no-repeat right center;padding-right: 80px;">' . get_string('turnitinloading', 'turnitintool') . '</span></span></div>
            <a href="' . $CFG->wwwroot . '/mod/turnitintool/view.php?id=' . $cm->id . '&do=allsubmissions' . '&update=1" onclick="refreshSubmissionsAjax();return false;" class="rightcor"><img src="' . $CFG->wwwroot . '/mod/turnitintool/pix/refresh.gif" alt="' . get_string('turnitinrefreshsubmissions', 'turnitintool') . '" class="tiiicons" /> ' . get_string('turnitinrefreshsubmissions', 'turnitintool') . '</a>
            <a href="' . $CFG->wwwroot . '/mod/turnitintool/view.php?id=' . $cm->id . '&do=allsubmissions' . '&enroll=1" onclick="enrolStudentsAjax( users, message );return false;" class="rightcor"><img src="' . $CFG->wwwroot . '/mod/turnitintool/pix/enrollicon.gif" alt="' . get_string('turnitinenrollstudents', 'turnitintool') . '" class="tiiicons" /> ' . get_string('turnitinenrollstudents', 'turnitintool') . '</a>
        </div>';
    if (count($table->rows) == 1) {
        // If we only have one row it's a header and we found no data to display
        $output .= '<div style="padding: 18px; margin: 0;text-align: center;vertical-align: center" class="navbar" id="loader">' . get_string('nosubmissions', 'turnitintool') . '</div><br /><br />';
    } else {
        $output .= '<div id="loader" style="padding: 18px; margin: 0;text-align: center;vertical-align: center" class="navbar">
        <noscript>Javascript Required</noscript>
        <script>
        jQuery("#loader span").css( "display", "inline" );
        </script><span style="display: none;background: url(pix/ajax-loader.gif) no-repeat left center;padding-left: 80px;">
        <span style="background: url(pix/ajax-loader.gif) no-repeat right center;padding-right: 80px;">' . get_string('turnitinloading', 'turnitintool') . '</span></span></div>';
        $output .= turnitintool_print_table($table, true);
    }
    return $output;
}
コード例 #2
0
                 { "sClass": "remove c3", "sWidth": "3%" }
             ],
     "aoColumnDefs": [
                 { "bSearchable": true, "bVisible": false, "aTargets": [ 0 ] },
                 { "bSearchable": true, "bVisible": false, "aTargets": [ 1 ] },
                 { "bSearchable": true, "bVisible": false, "aTargets": [ 2 ] },
                 { "bSearchable": true, "bVisible": true, "aTargets": [ 3 ] },
                 { "bSearchable": true, "bVisible": false, "aTargets": [ 4 ] },
                 { "bSearchable": true, "bVisible": true, "aTargets": [ 5 ] },
                 { "bSearchable": true, "bVisible": false, "aTargets": [ 6 ] },
                 { "bSearchable": true, "bVisible": true, "aTargets": [ 7 ] },
                 { "bSearchable": true, "bVisible": true, "aTargets": [ 8 ] }
             ],
     "aaSortingFixed": [[ 0, "asc" ]],
     "sAjaxSource": "filestable.php?module=' . $modules->id . '",
     "oLanguage": ' . turnitintool_datatables_strings() . ',
     "sDom": "r<\\"dt_page\\"pi><\\"top nav\\"lf>t<\\"bottom\\"><\\"dt_page\\"pi>",
     "bStateSave": true
 } );
 var oTable = jQuery(".dataTable").dataTable();
 oTable.fnSetFilteringDelay(1000);
 jQuery("#files_filter").append( "<label id=\\"check_filter\\"><input class=\\"deletecheck\\" type=\\"checkbox\\" /> ' . get_string('deletable', 'turnitintool') . '</label>" );
 var oSettings = oTable.fnSettings();
 if ( oSettings ) {
     var checkval = oSettings.aoPreSearchCols[8].sSearch;
     if ( checkval == "##deletable##" ) {
         jQuery("#check_filter .deletecheck").attr( "checked", "checked" );
     }
 }
 jQuery("#check_filter input").change( function () {
     var filter = "";