/** * Generates the HTML for the submission form in Moodle versions below 2.9 * * @global object * @global object * @global object * @param object $cm The moodle course module object for this instance * @param object $turnitintool The turnitintool object for this activity * @param object $optional_params The optional parameter object for this instance * @param object $cansubmit The list of students that can be submitted for * @return string returns the HTML of the form */ function turnitintool_view_submission_form_pre_29($cm, $turnitintool, $optional_params, $cansubmit) { global $CFG, $USER, $COURSE; $output = turnitintool_box_start('generalbox boxwidthwide boxaligncenter eightyfive', 'submitbox', true); if (has_capability('mod/turnitintool:grade', turnitintool_get_context('MODULE', $cm->id))) { $submissions = turnitintool_get_records_select('turnitintool_submissions', 'turnitintoolid=' . $turnitintool->id); } else { $submissions = turnitintool_get_records_select('turnitintool_submissions', 'userid=' . $USER->id . ' AND turnitintoolid=' . $turnitintool->id); } $output .= '<script language="javascript" type="text/javascript">' . PHP_EOL; $output .= 'var stringsArray = new Array("' . get_string('addsubmission', 'turnitintool') . '","' . get_string('resubmit', 'turnitintool') . '","' . get_string('resubmission', 'turnitintool') . '","' . get_string('resubmissionnotenabled', 'turnitintool') . '","' . get_string('anonenabled', 'turnitintool') . '");' . PHP_EOL; $output .= 'var submissionArray = new Array();' . PHP_EOL; if ($turnitintool->allowlate == 1) { $parts = turnitintool_get_records_select('turnitintool_parts', "turnitintoolid='" . $turnitintool->id . "' AND deleted=0 AND dtstart < '" . time() . "'", null, 'dtstart,dtdue,dtpost,id'); } else { $parts = turnitintool_get_records_select('turnitintool_parts', "turnitintoolid='" . $turnitintool->id . "' AND deleted=0 AND dtstart < '" . time() . "' AND dtdue > '" . time() . "'", NULL, 'dtstart,dtdue,dtpost,id'); } if (is_array($submissions)) { $i = 0; foreach ($submissions as $submission) { $lockresubmission = 0; if (isset($parts[$submission->submission_part]) and $parts[$submission->submission_part]->dtdue < time()) { $lockresubmission = 1; } $output .= 'submissionArray[' . $i . '] = new Array("' . $submission->userid . '","' . $submission->submission_part . '","' . $submission->submission_title . '","' . $submission->submission_unanon . '",' . $lockresubmission . ');' . PHP_EOL; $submittedparts[] = $submission->submission_part; $i++; } } $output .= '</script>' . PHP_EOL; $table = new stdClass(); $table->width = '100%'; $table->id = 'uploadtable'; $table->class = 'uploadtable'; unset($cells); $cells = array(); $cells[0] = new stdClass(); $cells[0]->class = 'cell c0'; $cells[0]->data = get_string('submissiontype', 'turnitintool') . turnitintool_help_icon('submissiontype', get_string('submissiontype', 'turnitintool'), 'turnitintool', true, false, '', true); if ($turnitintool->type == 0) { if ($optional_params->type == 1) { $selected = array('', ' selected', '', ''); } else { if ($optional_params->type == 2) { $selected = array('', '', ' selected', ''); } else { if ($optional_params->type == 3) { $selected = array('', '', '', ' selected'); } else { $selected = array(' selected', '', '', ''); $optional_params->type = 0; } } } $cells[1] = new stdClass(); $cells[1]->class = 'cell c1'; $cells[1]->data = '<select onchange="turnitintool_jumptopage(this.value)">'; $cells[1]->data .= '<option label="Select Submission Type" value="' . $CFG->wwwroot . '/mod/turnitintool/view.php' . '?id=' . $cm->id . '&do=submissions"' . $selected[0] . '>Select Submission Type</option>'; $cells[1]->data .= '<option label="-----------------" value="#">-----------------</option>'; $typearray = turnitintool_filetype_array(false); foreach ($typearray as $typekey => $typevalue) { $cells[1]->data .= ' <option label="' . $typevalue . '" value="' . $CFG->wwwroot . '/mod/turnitintool/view.php' . '?id=' . $cm->id . '&do=submissions&type=' . $typekey . '"' . $selected[$typekey] . '>' . $typevalue . '</option>'; } $cells[1]->data .= ' </select> <input id="submissiontype" name="submissiontype" type="hidden" value="' . $optional_params->type . '" />'; } else { if ($turnitintool->type == 1) { $optional_params->type = 1; $cells[1] = new stdClass(); $cells[1]->data = '<input id="submissiontype" name="submissiontype" type="hidden" value="1" />' . get_string('fileupload', 'turnitintool'); } else { if ($turnitintool->type == 2) { $optional_params->type = 2; $cells[1] = new stdClass(); $cells[1]->data = '<input id="submissiontype" name="submissiontype" type="hidden" value="2" />' . get_string('textsubmission', 'turnitintool'); } } } $output .= '<b>' . get_string('submit', 'turnitintool') . '</b><br /> <form enctype="multipart/form-data" action="' . $CFG->wwwroot . '/mod/turnitintool/view.php' . '?id=' . $cm->id . '&do=submissions&type=' . $optional_params->type . '" method="POST" name="submissionform">'; $table->rows[0] = new stdClass(); $table->rows[0]->class = 'r0'; $table->rows[0]->cells = $cells; $context = turnitintool_get_context('MODULE', $cm->id); if ($optional_params->type != 0) { $submissiontitle = optional_param('submissiontitle', '', PARAM_CLEAN); $disableform = false; if (has_capability('mod/turnitintool:grade', turnitintool_get_context('MODULE', $cm->id))) { $utype = "tutor"; // If tutor submitting on behalf of student unset($cells); $cells[0] = new stdClass(); $cells[0]->class = 'cell c0'; $cells[0]->data = get_string('studentsname', 'turnitintool') . turnitintool_help_icon('studentsname', get_string('studentsname', 'turnitintool'), 'turnitintool', true, false, '', true); if (count($cansubmit) > 0) { $cells[1] = new stdClass(); $cells[1]->data = '<select name="userid" id="userid" onchange="updateSubForm(submissionArray,stringsArray,this.form,' . $turnitintool->reportgenspeed . ')">'; $module_group = turnitintool_module_group($cm); $studentusers = array_keys(get_users_by_capability($context, 'mod/turnitintool:submit', 'u.id', '', '', '', $module_group, '', false)); foreach ($cansubmit as $courseuser) { // Filter Guest users, admins and grader users if (in_array($courseuser->id, $studentusers)) { if (!is_null($optional_params->userid) and $optional_params->userid == $courseuser->id) { $selected = ' selected'; } else { $selected = ''; } $cells[1]->data .= '<option label="' . $courseuser->firstname . ' ' . $courseuser->lastname . '" value="' . $courseuser->id . '"' . $selected . '>' . $courseuser->lastname . ', ' . $courseuser->firstname . '</option>'; } } $cells[1]->data .= '</select>'; if ($cells[1]->data == '<select id="userid" name="userid">' . '</select>') { $cells[1]->data = '<i>' . get_string('allsubmissionsmade', 'turnitintool') . '</i>'; $disableform = true; } } else { $cells[1] = new stdClass(); $cells[1]->data = '<i>' . get_string('noenrolledstudents', 'turnitintool') . '</i>'; } $table->rows[1] = new stdClass(); $table->rows[1]->class = 'r1'; $table->rows[1]->cells = $cells; } else { $utype = "student"; // If student submitting unset($cells); $cells[0] = new stdClass(); $cells[0]->class = 'cell c0'; $cells[0]->data = ''; $cells[1] = new stdClass(); $cells[1]->data = '<input id="userid" name="userid" type="hidden" value="' . $USER->id . '" />'; $table->rows[1] = new stdClass(); $table->rows[1]->class = 'r1'; $table->rows[1]->cells = $cells; } if (!$disableform) { unset($cells); $cells[0] = new stdClass(); $cells[0]->class = 'cell c0'; $cells[0]->data = get_string('submissiontitle', 'turnitintool') . turnitintool_help_icon('submissiontitle', get_string('submissiontitle', 'turnitintool'), 'turnitintool', true, false, '', true); $cells[1] = new stdClass(); $cells[1]->data = '<input type="text" name="submissiontitle" class="formwide" maxlength="200" value="' . $submissiontitle . '" /> <span id="submissionnotice"></span>'; $table->rows[2] = new stdClass(); $table->rows[2]->class = 'r0'; $table->rows[2]->cells = $cells; if (count($parts) > 1) { unset($cells); $cells[0] = new stdClass(); $cells[0]->class = 'cell c0'; $cells[0]->data = get_string('submissionpart', 'turnitintool') . turnitintool_help_icon('submissionpart', get_string('submissionpart', 'turnitintool'), 'turnitintool', true, false, '', true); $cells[1] = new stdClass(); $cells[1]->data = '<select name="submissionpart" class="formwide" onchange="updateSubForm(submissionArray,stringsArray,this.form,' . $turnitintool->reportgenspeed . ',\'' . $utype . '\')">'; $i = 0; foreach ($parts as $part) { // Do parts that have not yet been submitted to $cells[1]->data .= '<option label="' . $part->partname . '" value="' . $part->id . '">' . $part->partname . '</option>'; $i++; } $cells[1]->data .= '</select>'; $table->rows[3] = new stdClass(); $table->rows[3]->class = 'r1'; $table->rows[3]->cells = $cells; } else { unset($cells); $cells[0] = new stdClass(); $cells[0]->class = 'cell c0'; $cells[0]->data = get_string('submissionpart', 'turnitintool') . turnitintool_help_icon('submissionpart', get_string('submissionpart', 'turnitintool'), 'turnitintool', true, false, '', true); foreach ($parts as $part) { // Do parts that have not yet been submitted to $cells[1] = new stdClass(); $cells[1]->data = $part->partname . '<input type="hidden" name="submissionpart" value="' . $part->id . '" />'; break; } $table->rows[3] = new stdClass(); $table->rows[3]->class = 'r1'; $table->rows[3]->cells = $cells; } if ($optional_params->type == 1) { unset($cells); $cells[0] = new stdClass(); $cells[0]->class = 'cell c0'; $cells[0]->data = get_string('filetosubmit', 'turnitintool') . turnitintool_help_icon('filetosubmit', get_string('filetosubmit', 'turnitintool'), 'turnitintool', true, false, '', true); $cells[1] = new stdClass(); $cells[1]->data = '<input type="hidden" name="MAX_FILE_SIZE" value="' . $turnitintool->maxfilesize . '" />'; $cells[1]->data .= '<input type="file" name="submissionfile" size="55%" />'; $table->rows[4] = new stdClass(); $table->rows[4]->class = 'r0'; $table->rows[4]->cells = $cells; } if ($optional_params->type == 2) { unset($cells); $submissiontext = optional_param('submissiontext', '', PARAM_CLEAN); $cells[0] = new stdClass(); $cells[0]->class = 'cell c0'; $cells[0]->data = get_string('texttosubmit', 'turnitintool') . turnitintool_help_icon('texttosubmit', get_string('texttosubmit', 'turnitintool'), 'turnitintool', true, false, '', true); $cells[1] = new stdClass(); $cells[1]->data = '<textarea name="submissiontext" class="submissionText">' . $submissiontext . '</textarea>'; $table->rows[5] = new stdClass(); $table->rows[5]->class = 'r1'; $table->rows[5]->cells = $cells; } if ($optional_params->type == 3) { unset($cells); $submissionurl = optional_param('submissionurl', '', PARAM_CLEAN); $cells[0] = new stdClass(); $cells[0]->class = 'cell c0'; $cells[0]->data = get_string('urltosubmit', 'turnitintool') . turnitintool_help_icon('urltosubmit', get_string('urltosubmit', 'turnitintool'), 'turnitintool', true, false, '', true); $cells[1] = new stdClass(); $cells[1]->data = '<input type="text" name="submissionurl" class="formwide" value="' . $submissionurl . '" />'; $table->rows[6] = new stdClass(); $table->rows[6]->class = 'r0'; $table->rows[6]->cells = $cells; } $checked = ''; if (!is_null($optional_params->agreement)) { $checked = ' checked'; } if (has_capability('mod/turnitintool:grade', $context) or empty($CFG->turnitin_agreement)) { unset($cells); $cells[0] = new stdClass(); $cells[0]->class = 'cell c0'; $cells[0]->data = ''; $cells[1] = new stdClass(); $cells[1]->data = '<input type="hidden" name="agreement" value="1" />'; $table->rows[7] = new stdClass(); $table->rows[7]->class = 'r1'; $table->rows[7]->cells = $cells; } else { unset($cells); $cells[0] = new stdClass(); $cells[0]->class = 'cell c0'; $cells[0]->data = '<input type="checkbox" name="agreement" value="1"' . $checked . ' />'; $cells[1] = new stdClass(); $cells[1]->data = $CFG->turnitin_agreement; $table->rows[7] = new stdClass(); $table->rows[7]->class = 'r1'; $table->rows[7]->cells = $cells; } unset($cells); $cells[0] = new stdClass(); $cells[0]->class = 'cell c0'; $cells[0]->data = ' '; $cells[1] = new stdClass(); $cells[1]->data = '<input name="submitbutton" type="submit" value="' . get_string('addsubmission', 'turnitintool') . '" />'; $table->rows[8] = new stdClass(); $table->rows[8]->class = 'r0'; $table->rows[8]->cells = $cells; } } $output .= turnitintool_print_table($table, true); if ($optional_params->type > 0) { $output .= ' <script language="javascript" type="text/javascript">updateSubForm(submissionArray,stringsArray,document.submissionform,' . $turnitintool->reportgenspeed . ',"' . $utype . '");</script> </form> '; } $output .= turnitintool_box_end(true) . '<br />'; return $output; }
$cells[4] = new stdClass(); $cells[4]->data = $submissioncount; $cells[4]->class = "cell c4 cellcenter cellthin"; $table->rows[$i] = new stdClass(); $table->rows[$i]->cells = $cells; } else { unset($cells); $cells[0] = new stdClass(); $cells[0]->data = $link; $cells[0]->class = "cell c0 cellleft"; $cells[1] = new stdClass(); $cells[1]->data = $dtstart; $cells[1]->class = "cell c1 cellcenter cellthin"; $cells[2] = new stdClass(); $cells[2]->data = $partcount; $cells[2]->class = "cell c2 cellcenter cellthin"; $cells[3] = new stdClass(); $cells[3]->data = $submissioncount; $cells[3]->class = "cell c3 cellcenter cellthin"; $table->rows[$i] = new stdClass(); $table->rows[$i]->cells = $cells; $table->data[$i - 1] = array($link, $dtstart, $partcount, $submissioncount); } $i++; } echo "<br />"; turnitintool_print_table($table); /// Finish the page echo "</div>"; turnitintool_footer($course); /* ?> */