diff options
Diffstat (limited to 'Moodle/mod/print/lib.php')
-rwxr-xr-x | Moodle/mod/print/lib.php | 84 |
1 files changed, 36 insertions, 48 deletions
diff --git a/Moodle/mod/print/lib.php b/Moodle/mod/print/lib.php index 6bcc38c..fbc5229 100755 --- a/Moodle/mod/print/lib.php +++ b/Moodle/mod/print/lib.php @@ -66,9 +66,9 @@ class print_base { } #$this->submissions = $this->check_database("print_submissions"); - $this->printconfig->cmidnumber = $this->cm->id; // compatibility with modedit assignment obj - $this->printconfig->courseid = $this->course->id; // compatibility with modedit assignment obj - $this->printconfig->maxbytes = 2097152; + $this->printconfig->id = $this->cm->id; // compatibility with modedit assignment obj + $this->printconfig->course = $this->course->id; // compatibility with modedit assignment obj + } function check_database($table) { global $CFG,$USER; @@ -83,45 +83,36 @@ function check_database($table) { function view1() { global $USER; + + require_capability('mod/print:view', $this->context); - require_capability('mod/print:view', $this->context); - - add_to_log($this->course->id, 'print', 'view', "view.php?id={$this->cm->id}", $this->printconfig->id, $this->cm->id); - - $this->view_header(); + add_to_log($this->course->id, 'print', 'view', "view.php?id={$this->cm->id}", $this->printconfig->id, $this->cm->id); + $this->view_header(); - if (has_capability('mod/print:submit', $this->context)) { - - if ($this->submissions = get_records_sql($this->check_database("print_submissions"))) { - - - } else { - $substring = "No Submissions yet"; - print_simple_box(get_string('nofilesyet', 'assignment'), 'center'); - } - + + if (has_capability('mod/print:submit', $this->context)) { - $filecount = $this->count_user_files($USER->id); - $submission = $this->get_submissions1($USER->id); + $filecount = $this->count_user_files($USER->id); + $submission = $this->get_submissions1($USER->id); - # $this->view_feedback(); - print_heading(get_string('submissiondraft', 'assignment'), '', 3); + print_heading(get_string('submissiondraft', 'assignment'), '', 3); - if ($filecount and $submission) { - print_simple_box($this->print_user_files($USER->id, true), 'center'); - } else { - print_simple_box(get_string('nofilesyet', 'assignment'), 'center'); - } + if ($filecount and $submission) { + print_simple_box($this->print_user_files($USER->id, true), 'center'); + } else { + print_simple_box(get_string('nofilesyet', 'assignment'), 'center'); + } - $this->view_upload_form(); - + $this->view_upload_form(); + print_footer($this->course); - } - } + } +} + function view_header($subpage='') { global $CFG; @@ -410,15 +401,11 @@ function view1() { $auser->status = 1; } - $buttontext = ($auser->status == 1) ? $strupdate : $strgrade; + $text = ($auser->status == 1) ? 'Assignment Ready' : 'No Print Submissions'; ///No more buttons, we use popups ;-). - $popup_url = '/mod/print/submissions.php?id='.$this->cm->id - . '&userid='.$auser->id.'&mode=single'.'&offset='.$offset++; - $button = link_to_popup_window ($popup_url, 'grade'.$auser->id, $buttontext, 600, 780, - $buttontext, 'none', true, 'button'.$auser->id); - - $status = '<div id="up'.$auser->id.'" class="s'.$auser->status.'">'.$button.'</div>'; + $text; + $status = '<div id="up'.$auser->id.'" class="s'.$auser->status.'">'.$text.'</div>'; $url = $this->print_user_files($auser->id,true,true); $submissions = '<div id="down'.$auser->id.'" class="s'.$auser->status.'">'.$url.'</div>'; @@ -477,7 +464,7 @@ function view1() { echo '</td></tr></table>'; echo '</div></form></div>'; ///End of mini form -# print_footer($this->course); + print_footer($this->course); } @@ -672,9 +659,9 @@ function view1() { notify(get_string('deletefilefailed', 'assignment')); print_continue($returnurl); if (empty($mode)) { - # $this->view_footer(); + print_footer($this->course); } else { - #print_footer('none'); + print_footer('none'); } die; } @@ -985,18 +972,19 @@ function print_get_all_submissions($assignment, $sort="", $dir="DESC") { function print_add_instance($print) { - $print->timemodified = time(); - $print->courseid = $print->course; + $print->timemodified = time(); + $print->id = 1; + $print->course = 1; + if (! $printrecord = get_record('print', 'id', 1)) { + return insert_record('print', $print); + } trigger_error("Sorry doesnt work this way"); - # You may have to add extra stuff in here # - - return insert_record('print', $print); } /** * Given an object containing all the necessary data, - * (defined by the form in mod_form.php) this function + * (defined by the form in mod_form.php) this sfunction * will update an existing instance with new data. * * @param object $print An object from the form in mod_form.php @@ -1008,7 +996,7 @@ function print_update_instance($print) { $print->id = $print->instance; # You may have to add extra stuff in here # - + return update_record('print', $print); } |