mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 08:56:36 +02:00
adding capability, indenting, putting in brackets etc
This commit is contained in:
parent
d63545d8e8
commit
38ac07d284
1 changed files with 230 additions and 220 deletions
|
@ -6,7 +6,6 @@
|
|||
*/
|
||||
class assignment_upload extends assignment_base {
|
||||
|
||||
|
||||
function print_student_answer($userid, $return=false){
|
||||
global $CFG, $USER;
|
||||
|
||||
|
@ -70,10 +69,12 @@ class assignment_upload extends assignment_base {
|
|||
}
|
||||
|
||||
//display Blank if there were no files uploaded yet, otherwithe display submission status
|
||||
if (!$submission->data1)
|
||||
if (!$submission->data1) {
|
||||
$submission_status = get_string('submissionstatusblank','assignment');
|
||||
else
|
||||
}
|
||||
else {
|
||||
$submission_status = $submission->data1;
|
||||
}
|
||||
|
||||
//display submisison status
|
||||
notify("<b>".get_string('submissionstatus', 'assignment')." </b> ".$submission_status);
|
||||
|
@ -142,22 +143,22 @@ class assignment_upload extends assignment_base {
|
|||
global $offset;
|
||||
|
||||
//if this is final submit
|
||||
if ($_POST['save']===get_string('sendformarking','assignment')){
|
||||
$savestr = optional_param('save', '', PARAM_ALPHA);
|
||||
if ($savestr === get_string('sendformarking','assignment')) {
|
||||
|
||||
$this->final_upload();
|
||||
|
||||
}else{
|
||||
} else {
|
||||
//if this is draft upload
|
||||
if ($_POST['save']==get_string('attachfile','assignment') && !isset($_POST['userid'])){
|
||||
|
||||
$this->submission_upload();
|
||||
|
||||
}else{
|
||||
} else {
|
||||
//if this is upload of teacher's response
|
||||
$id = optional_param('id'); // Course module ID
|
||||
$a = optional_param('a'); // Assignment ID
|
||||
$userid = required_param('userid'); // Stores student id for uploading a review file to
|
||||
|
||||
$id = optional_param('id', 0, PARAM_INT); // Course module ID
|
||||
$a = optional_param('a', 0, PARAM_INT); // Assignment ID
|
||||
$userid = required_param('userid', 0, PARAM_INT); // Stores student id for uploading a review file to
|
||||
$this->response_upload($userid); // Upload files
|
||||
echo "<form action=\"submissions.php\">";
|
||||
echo "<input type=\"hidden\" value=\"$userid\" name=\"userid\">";
|
||||
|
@ -172,9 +173,7 @@ class assignment_upload extends assignment_base {
|
|||
function submission_upload() {
|
||||
global $CFG, $USER, $counter;
|
||||
|
||||
if (isguest($USER->id)) {
|
||||
error(get_string('guestnoupload','assignment'));
|
||||
}
|
||||
require_capability('mod/assignment:submit', get_context_instance(CONTEXT_MODULE, $this->cm->id));
|
||||
|
||||
$this->view_header(get_string('upload'));
|
||||
|
||||
|
@ -185,7 +184,7 @@ class assignment_upload extends assignment_base {
|
|||
$basedir = $this->file_area($USER->id);
|
||||
$files = get_directory_list($basedir);
|
||||
|
||||
if ($this->isopen() ){//&& ($this->assignment->var1 || !$filecount || $this->assignment->resubmit || !$submission->timemarked)) {
|
||||
if ($this->isopen()) {//&& ($this->assignment->var1 || !$filecount || $this->assignment->resubmit || !$submission->timemarked)) {
|
||||
if ($submission) {
|
||||
//TODO: change later to ">= 0", to prevent resubmission when graded 0
|
||||
if (($submission->grade > 0) and !$this->assignment->resubmit) {
|
||||
|
@ -207,16 +206,23 @@ class assignment_upload extends assignment_base {
|
|||
//$submission->timemodified = time();
|
||||
$flag=false;
|
||||
foreach ($files as $key => $file) {
|
||||
if ($file == $newfile_name)
|
||||
if ($file == $newfile_name) {
|
||||
$flag = true;
|
||||
}
|
||||
}
|
||||
//if this is an assignment for single upload
|
||||
if (!$this->assignment->var1){
|
||||
if (!$this->assignment->var1) {
|
||||
//if numfiles=1
|
||||
if ( $submission->numfiles==0 && !$flag) $submission->numfiles ++;
|
||||
}else
|
||||
if ($submission->numfiles==0 && !$flag) {
|
||||
$submission->numfiles ++;
|
||||
}
|
||||
} else {
|
||||
//if file with the same name has not been uploaded before
|
||||
if (!$flag) $submission->numfiles ++;
|
||||
if (!$flag) {
|
||||
$submission->numfiles ++;
|
||||
}
|
||||
}
|
||||
|
||||
$submission->comment = addslashes($submission->comment);
|
||||
unset($submission->data1); // Don't need to update this.
|
||||
//unset($submission->data2); // Don't need to update this.
|
||||
|
@ -230,7 +236,7 @@ class assignment_upload extends assignment_base {
|
|||
notify(get_string("uploadfailnoupdate", "assignment"));
|
||||
}
|
||||
//if it's first student's submission
|
||||
} else{
|
||||
} else {
|
||||
$newsubmission = $this->prepare_new_submission($USER->id);
|
||||
//submissions has been created, but not submitted for marking
|
||||
$newsubmission->timecreated = time();
|
||||
|
@ -244,7 +250,7 @@ class assignment_upload extends assignment_base {
|
|||
//$this->email_teachers($newsubmission);
|
||||
print_heading(get_string('uploadedfile'));
|
||||
} else {
|
||||
notify(get_string("uploadnotregistered", "assignment", $newfile_name) );
|
||||
notify(get_string("uploadnotregistered", "assignment", $newfile_name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -479,7 +485,7 @@ class assignment_upload extends assignment_base {
|
|||
///as the userid to store...
|
||||
//removed by Oksana. it was braking functionality and submitting teacher's feedback to.. teacher-user
|
||||
//this was inherited from upload type. check if nothing brackes???????????????
|
||||
if ((int)$feedback->saveuserid !== -1){
|
||||
if ((int)$feedback->saveuserid !== -1) {
|
||||
$feedback->userid = $feedback->saveuserid;
|
||||
}
|
||||
if (!empty($feedback->cancel)) { // User hit cancel button
|
||||
|
@ -494,11 +500,12 @@ class assignment_upload extends assignment_base {
|
|||
$newsubmission->mailed = 0; // Make sure mail goes out (again, even)
|
||||
$newsubmission->timemarked = time();
|
||||
//marker graded assignment then status set into Marked; if marker didn't grade it then status set into Returned
|
||||
if (/*$feedback->grade != 0 && */ $feedback->grade != -1 )
|
||||
if (/*$feedback->grade != 0 && */ $feedback->grade != -1 ) {
|
||||
$newsubmission->data1 = get_string("submissionstatusmarked", "assignment");
|
||||
else
|
||||
}
|
||||
else {
|
||||
$newsubmission->data1 = get_string("submissionstatusreturned", "assignment");
|
||||
|
||||
}
|
||||
//unset($newsubmission->data1); // Don't need to update this.
|
||||
//unset($newsubmission->data2); // Don't need to update this.
|
||||
|
||||
|
@ -567,7 +574,7 @@ class assignment_upload extends assignment_base {
|
|||
break;
|
||||
}
|
||||
|
||||
foreach ($_POST[$col] as $id => $unusedvalue){
|
||||
foreach ($_POST[$col] as $id => $unusedvalue) {
|
||||
|
||||
$id = (int)$id; //clean parameter name
|
||||
if (!$submission = $this->get_submission($id)) {
|
||||
|
@ -593,11 +600,12 @@ class assignment_upload extends assignment_base {
|
|||
}
|
||||
|
||||
//change status if assignment was graded or returned
|
||||
if ($submission->grade != -1 )
|
||||
if ($submission->grade != -1 ) {
|
||||
$submission->data1 = get_string("submissionstatusmarked", "assignment");
|
||||
else
|
||||
}
|
||||
else {
|
||||
$submission->data1 = get_string("submissionstatusreturned", "assignment");
|
||||
|
||||
}
|
||||
if ($commenting) {
|
||||
$commentvalue = trim($_POST['comment'][$id]);
|
||||
$updatedb = $updatedb || ($submission->comment != stripslashes($commentvalue));
|
||||
|
@ -613,7 +621,7 @@ class assignment_upload extends assignment_base {
|
|||
//if it is not an update, we don't change the last modified time etc.
|
||||
//this will also not write into database if no comment and grade is entered.
|
||||
|
||||
if ($updatedb){
|
||||
if ($updatedb) {
|
||||
if ($newsubmission) {
|
||||
if (!insert_record('assignment_submissions', $submission)) {
|
||||
return false;
|
||||
|
@ -720,7 +728,7 @@ class assignment_upload extends assignment_base {
|
|||
}
|
||||
|
||||
//display student's submission for marking in pop-up window
|
||||
function display_submission() {
|
||||
function display_submission() {
|
||||
|
||||
global $CFG, $offset;
|
||||
|
||||
|
@ -767,7 +775,7 @@ function display_submission() {
|
|||
//we don't need to grade draft or empty assignments
|
||||
|
||||
require_once($CFG->libdir.'/tablelib.php');
|
||||
if($sort = flexible_table::get_sql_sort('mod-assignment-submissions')) {
|
||||
if ($sort = flexible_table::get_sql_sort('mod-assignment-submissions')) {
|
||||
$sort = 'ORDER BY '.$sort.' ';
|
||||
}
|
||||
|
||||
|
@ -952,7 +960,7 @@ function display_submission() {
|
|||
}
|
||||
|
||||
//print teacher's files
|
||||
function print_user_response_files($stuid,$display_remove_button=false,$offset=NULL){//, $return=false) {
|
||||
function print_user_response_files($stuid,$display_remove_button=false,$offset=NULL) {//, $return=false) {
|
||||
|
||||
global $CFG, $USER;
|
||||
|
||||
|
@ -978,7 +986,7 @@ function display_submission() {
|
|||
//get feedback file size, generate and display remove file link
|
||||
$filesize = display_size(filesize($basedir."/".$file));
|
||||
$remove_link='';
|
||||
if ($display_remove_button){
|
||||
if ($display_remove_button) {
|
||||
$course_mod_id=$this->cm->id;
|
||||
$deleteurl="$CFG->wwwroot/mod/assignment/type/upload/deleteonesubmission.php?confirm=0&view=teacher&userid=$stuid&id=$course_mod_id&name=$file&file=".$basedir."/".$file."&offset=".$offset;
|
||||
$remove_link='[<a href="'.$deleteurl.'">'.get_string("removelink", "assignment").'</a>]';
|
||||
|
@ -1029,24 +1037,24 @@ function display_submission() {
|
|||
if (isteacher($this->course->id)) {
|
||||
$output .= '<img align="middle" src="'.$CFG->pixpath.'/f/'.$icon.'" height="16" width="16" alt="'.$icon.'" />'.
|
||||
'<a href="'.$ffurl.'" >'.$file.'</a> ['.$filesize.'] <br />';
|
||||
}else {
|
||||
} else {
|
||||
if (isset($USER->id)) {
|
||||
if ($submission = $this->get_submission($USER->id)){
|
||||
if ($submission = $this->get_submission($USER->id)) {
|
||||
//i have changed timemodified=0 for Draft assignments, thats' why we remove this condition
|
||||
//otherwise student's dont' se etheir own submissions
|
||||
// if ($submission->timemodified) {
|
||||
if ($submission->timemodified <= $this->assignment->timedue || empty($this->assignment->timedue)){
|
||||
if ($submission->timemodified <= $this->assignment->timedue || empty($this->assignment->timedue)) {
|
||||
//remove link shouldn't be displayed if file was marked or submited for marking
|
||||
$remove_link = '';
|
||||
if ($submission->data1 == get_string("submissionstatusdraft", "assignment") || $submission->data1 == get_string("submissionstatusreturned", "assignment")){
|
||||
if ($submission->data1 == get_string("submissionstatusdraft", "assignment") || $submission->data1 == get_string("submissionstatusreturned", "assignment")) {
|
||||
$course_mod_id=$this->cm->id;
|
||||
$deleteurl="$CFG->wwwroot/mod/assignment/type/upload/deleteonesubmission.php?confirm=0&view=student&userid=$userid&id=$course_mod_id&name=$file&file=".$basedir."/".$file;
|
||||
$remove_link= '[<a href="'.$deleteurl.'">'.get_string("removelink", "assignment").'</a>]'; //students of the course
|
||||
}
|
||||
$output .= '<img align="middle" src="'.$CFG->pixpath.'/f/'.$icon.'" height="16" width="16" alt="'.$icon.'" />'.$file.' ['.$filesize.']'.$remove_link.'<br />';
|
||||
}else
|
||||
} else {
|
||||
$output .= '';
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1073,7 +1081,7 @@ function display_submission() {
|
|||
/* first we check to see if the form has just been submitted
|
||||
* to request user_preference updates
|
||||
*/
|
||||
if (isset($_POST['updatepref'])){
|
||||
if (isset($_POST['updatepref'])) {
|
||||
$perpage = optional_param('perpage', 10, PARAM_INT);
|
||||
$perpage = ($perpage <= 0) ? 10 : $perpage ;
|
||||
set_user_preference('assignment_perpage', $perpage);
|
||||
|
@ -1211,10 +1219,10 @@ function display_submission() {
|
|||
}
|
||||
|
||||
//if there is no upload status, then display "blank"
|
||||
if (empty($auser->upload_status))
|
||||
if (empty($auser->upload_status)) {
|
||||
$auser->upload_status=get_string("submissionstatusblank", "assignment");
|
||||
|
||||
if (!empty($auser->submissionid)){
|
||||
}
|
||||
if (!empty($auser->submissionid)) {
|
||||
///Prints student answer and student modified date
|
||||
///attach file or print link to student answer, depending on the type of the assignment.
|
||||
///Refer to print_student_answer in inherited classes
|
||||
|
@ -1229,7 +1237,7 @@ function display_submission() {
|
|||
//display teachers feedback files here as well
|
||||
$teachermodified = '<div id="tt'.$auser->id.'">'.$this->print_user_response_files($auser->id,false).userdate($auser->timemarked).'</div>';
|
||||
//disable grading ability in case of Blank or Draft assignment
|
||||
if ($quickgrade ){//&& ($auser->upload_status != get_string("submissionstatusdraft", "assignment") || !$auser->upload_status )){// get_string("submissionstatusblank", "assignment"))){
|
||||
if ($quickgrade) {//&& ($auser->upload_status != get_string("submissionstatusdraft", "assignment") || !$auser->upload_status )){// get_string("submissionstatusblank", "assignment"))){
|
||||
$grade = '<div id="g'.$auser->id.'">'.choose_from_menu(make_grades_menu($this->assignment->grade),
|
||||
'menu['.$auser->id.']', $auser->grade, get_string('nograde'),'',-1,true,false,$tabindex++).'</div>';
|
||||
} else {
|
||||
|
@ -1239,7 +1247,7 @@ function display_submission() {
|
|||
} else {
|
||||
$teachermodified = '<div id="tt'.$auser->id.'"> </div>';
|
||||
|
||||
if ($quickgrade && $auser->upload_status != get_string("submissionstatusdraft", "assignment") && $auser->upload_status != get_string("submissionstatusblank", "assignment")){
|
||||
if ($quickgrade && $auser->upload_status != get_string("submissionstatusdraft", "assignment") && $auser->upload_status != get_string("submissionstatusblank", "assignment")) {
|
||||
$grade = '<div id="g'.$auser->id.'">'.choose_from_menu(make_grades_menu($this->assignment->grade),
|
||||
'menu['.$auser->id.']', $auser->grade, get_string('nograde'),'',-1,true,false,$tabindex++).'</div>';
|
||||
} else {
|
||||
|
@ -1247,7 +1255,7 @@ function display_submission() {
|
|||
}
|
||||
}
|
||||
///Print Comment
|
||||
if ($quickgrade && $auser->upload_status != get_string("submissionstatusdraft", "assignment") && $auser->upload_status != get_string("submissionstatusblank", "assignment")){
|
||||
if ($quickgrade && $auser->upload_status != get_string("submissionstatusdraft", "assignment") && $auser->upload_status != get_string("submissionstatusblank", "assignment")) {
|
||||
$comment = '<div id="com'.$auser->id.'"><textarea tabindex="'.$tabindex++.'" name="comment['.$auser->id.']" id="comment['.$auser->id.']">'.($auser->comment).'</textarea></div>';
|
||||
} else {
|
||||
$comment = '<div id="com'.$auser->id.'">'.shorten_text(strip_tags($auser->comment),15).'</div>';
|
||||
|
@ -1257,7 +1265,7 @@ function display_submission() {
|
|||
$teachermodified = '<div id="tt'.$auser->id.'"> </div>';
|
||||
$status = '<div id="st'.$auser->id.'"> </div>';
|
||||
|
||||
if ($quickgrade && $auser->upload_status != get_string("submissionstatusdraft", "assignment") && $auser->upload_status != get_string("submissionstatusblank", "assignment") ){ // allow editing
|
||||
if ($quickgrade && $auser->upload_status != get_string("submissionstatusdraft", "assignment") && $auser->upload_status != get_string("submissionstatusblank", "assignment")) { // allow editing
|
||||
$grade = '<div id="g'.$auser->id.'">'.choose_from_menu(make_grades_menu($this->assignment->grade),
|
||||
'menu['.$auser->id.']', $auser->grade, get_string('nograde'),'',-1,true,false,$tabindex++).'</div>';
|
||||
} else {
|
||||
|
@ -1280,7 +1288,7 @@ function display_submission() {
|
|||
//do not display link to the grading pop-up if upload_status={Blank, Draft}
|
||||
if ($auser->upload_status == get_string("submissionstatusdraft", "assignment") || $auser->upload_status == get_string("submissionstatusblank", "assignment")){
|
||||
$button = $buttontext;
|
||||
}else{
|
||||
} else {
|
||||
///No more buttons, we use popups ;-).
|
||||
$button = link_to_popup_window ('/mod/assignment/submissions.php?id='.$this->cm->id.'&userid='.$auser->id.'&mode=single'.'&offset='.$offset++,'grade'.$auser->id, $buttontext, 500, 780, $buttontext, 'none', true, 'button'.$auser->id);
|
||||
}
|
||||
|
@ -1292,7 +1300,7 @@ function display_submission() {
|
|||
}
|
||||
|
||||
/// Print quickgrade form around the table
|
||||
if ($quickgrade){
|
||||
if ($quickgrade) {
|
||||
echo '<form action="submissions.php" name="fastg" method="post">';
|
||||
echo '<input type="hidden" name="id" value="'.$this->cm->id.'">';
|
||||
echo '<input type="hidden" name="mode" value="fastgrade">';
|
||||
|
@ -1301,7 +1309,7 @@ function display_submission() {
|
|||
|
||||
$table->print_html(); /// Print the whole table
|
||||
|
||||
if ($quickgrade){
|
||||
if ($quickgrade) {
|
||||
echo '<p align="center"><input type="submit" name="fastg" value="'.get_string('saveallfeedback', 'assignment').'" /></p>';
|
||||
echo '</form>';
|
||||
}
|
||||
|
@ -1324,7 +1332,7 @@ function display_submission() {
|
|||
print_string('quickgrade','assignment');
|
||||
echo ':</td>';
|
||||
echo '<td align="left">';
|
||||
if ($quickgrade){
|
||||
if ($quickgrade) {
|
||||
echo '<input type="checkbox" name="quickgrade" value="1" checked="checked" />';
|
||||
} else {
|
||||
echo '<input type="checkbox" name="quickgrade" value="1" />';
|
||||
|
@ -1341,7 +1349,7 @@ function display_submission() {
|
|||
}
|
||||
|
||||
//deletes submitted file (assignment or response)
|
||||
function deleteonesubmission (){
|
||||
function deleteonesubmission () {
|
||||
global $CFG, $USER;
|
||||
|
||||
require_once($CFG->libdir.'/filelib.php');
|
||||
|
@ -1358,26 +1366,28 @@ function display_submission() {
|
|||
$submission = $this->get_submission($USER->id);
|
||||
|
||||
|
||||
if ($view == 'teacher'){
|
||||
if ($view == 'teacher') {
|
||||
$yes_url = "$CFG->wwwroot/mod/assignment/type/upload/deleteonesubmission.php?confirm=1&view=teacher&userid=$userid&id=$id&name=$name&file=$file&offset=$offset";
|
||||
$no_url = "../../submissions.php?userid=$userid&id=$id&mode=single&offset=$offset";
|
||||
$back_button = get_string("backtofeedback", "assignment");
|
||||
$action_url = '../../submissions.php';
|
||||
}else{
|
||||
} else {
|
||||
$yes_url = "$CFG->wwwroot/mod/assignment/type/upload/deleteonesubmission.php?confirm=1&view=student&userid=$userid&id=$id&name=$name&file=$file&offset=$offset";
|
||||
$no_url = "../../view.php?id=$id&offset=$offset";
|
||||
$back_button = get_string("backtoassignment", "assignment");
|
||||
$action_url = '../../view.php';
|
||||
}
|
||||
|
||||
if ($view == 'student') $this->view_header();
|
||||
if ($view == 'student') {
|
||||
$this->view_header();
|
||||
}
|
||||
|
||||
if (!empty($confirm)) {
|
||||
|
||||
if (!fulldelete($file)) {
|
||||
notify(get_string("deletefail", "assignment"));
|
||||
notify($file);
|
||||
}else{
|
||||
} else {
|
||||
//if student deletes submitted files then numfiles should be changed
|
||||
if ($view == 'student'){
|
||||
$submission->numfiles --;
|
||||
|
@ -1387,7 +1397,7 @@ function display_submission() {
|
|||
notify(get_string("deletefail", "assignment"));
|
||||
notify($file);
|
||||
}
|
||||
}else{
|
||||
} else {
|
||||
notify(get_string("deleteednotification", "assignment"));
|
||||
}
|
||||
|
||||
|
@ -1470,7 +1480,7 @@ function display_submission() {
|
|||
}
|
||||
|
||||
return get_string('fullnamedisplay', '', $user) . $user_id;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue