From 0f7d4e5e8a4955ffe4866a12485afb3177bd6657 Mon Sep 17 00:00:00 2001 From: moodler Date: Fri, 15 Apr 2005 13:41:57 +0000 Subject: [PATCH] Cleaner updating of buttons and scales --- lib/weblib.php | 12 ++++++++++-- mod/assignment/lib.php | 19 ++++++++++++++----- 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/lib/weblib.php b/lib/weblib.php index 78375ee0161..df8c2cbc0d4 100644 --- a/lib/weblib.php +++ b/lib/weblib.php @@ -585,16 +585,24 @@ function link_to_popup_window ($url, $name='popup', $linkname='click here', * @uses $CFG */ function button_to_popup_window ($url, $name='popup', $linkname='click here', - $height=400, $width=500, $title='Popup window', $options='none', $return=false) { + $height=400, $width=500, $title='Popup window', $options='none', $return=false, + $id='', $class='') { global $CFG; if ($options == 'none') { $options = 'menubar=0,location=0,scrollbars,resizable,width='. $width .',height='. $height; } + + if ($id) { + $id = ' id="'.$id.'" '; + } + if ($class) { + $class = ' class="'.$class.'" '; + } $fullscreen = 0; - $button = '\n"; if ($return) { return $button; diff --git a/mod/assignment/lib.php b/mod/assignment/lib.php index 68a9a27501e..17ae21c2b22 100644 --- a/mod/assignment/lib.php +++ b/mod/assignment/lib.php @@ -305,6 +305,7 @@ class assignment_base { } if (empty($SESSION->flextable['mod-assignment-submissions']->collapse['status'])) { echo 'opener.document.getElementById("up'.$submission->userid.'").className="s1";'; + echo 'opener.document.getElementById("button'.$submission->userid.'").value="'.get_string('update').'";'; } echo "\n-->\n"; fflush(); @@ -329,7 +330,10 @@ class assignment_base { return '-'; } } - return $scalegrades[$grade]; + if (isset($scalegrades[$grade])) { + return $scalegrades[$grade]; + } + return ''; } } @@ -345,7 +349,7 @@ class assignment_base { error('No such user!'); } - if (!$submission = $this->get_submission($user->id)) { // Get or make one + if (!$submission = $this->get_submission($user->id, true)) { // Get one or make one error('Could not find submission!'); } @@ -567,10 +571,15 @@ class assignment_base { $comment = '
 
'; } + if ($auser->status === NULL) { + $auser->status = 0; + } + $buttontext = ($auser->status == 1) ? $strupdate : $strgrade; $button = button_to_popup_window ('/mod/assignment/submissions.php?id='.$this->cm->id.'&userid='.$auser->id.'&mode=single', - 'grade'.$auser->id, $buttontext, 450, 600, $buttontext, 'none', true); + 'grade'.$auser->id, $buttontext, 450, 600, $buttontext, 'none', true, 'button'.$auser->id); + $status = '
'.$button.'
'; $row = array($picture, fullname($auser), $grade, $comment, $studentmodified, $teachermodified, $status); @@ -601,7 +610,7 @@ class assignment_base { return false; } - $newsubmission = $this->get_submission($feedback->userid); + $newsubmission = $this->get_submission($feedback->userid, true); // Get or make one $newsubmission->grade = $feedback->grade; $newsubmission->comment = $feedback->comment; @@ -625,7 +634,7 @@ class assignment_base { } - function get_submission($userid, $createnew=true) { + function get_submission($userid, $createnew=false) { $submission = get_record('assignment_submissions', 'assignment', $this->assignment->id, 'userid', $userid); if ($submission || !$createnew) {