~ubuntu-branches/ubuntu/jaunty/moodle/jaunty

« back to all changes in this revision

Viewing changes to grade/export/grade_export_form.php

  • Committer: Bazaar Package Importer
  • Author(s): Jordan Mantha, Matt Oquist
  • Date: 2009-02-25 15:16:22 UTC
  • mfrom: (1.1.11 upstream)
  • Revision ID: james.westby@ubuntu.com-20090225151622-0ekt1liwhv2obfza
Tags: 1.9.4.dfsg-0ubuntu1
* Merge with Debian git (Closes LP: #322961, #239481, #334611):
  - use Ubuntu's smarty lib directory for linking
  - use internal yui library 
  - add update-notifier support back in

[Matt Oquist]
  * renamed prerm script
  * significantly rewrote postinst and other maintainer scripts to improve
    user experience and package maintainability
    (Closes LP: #225662, #325450, #327843, #303078, #234609)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?php // $Id: grade_export_form.php,v 1.27.2.8 2008/03/03 10:21:41 nicolasconnault Exp $
 
2
 
 
3
///////////////////////////////////////////////////////////////////////////
 
4
//                                                                       //
 
5
// NOTICE OF COPYRIGHT                                                   //
 
6
//                                                                       //
 
7
// Moodle - Modular Object-Oriented Dynamic Learning Environment         //
 
8
//          http://moodle.com                                            //
 
9
//                                                                       //
 
10
// Copyright (C) 1999 onwards  Martin Dougiamas  http://moodle.com       //
 
11
//                                                                       //
 
12
// This program is free software; you can redistribute it and/or modify  //
 
13
// it under the terms of the GNU General Public License as published by  //
 
14
// the Free Software Foundation; either version 2 of the License, or     //
 
15
// (at your option) any later version.                                   //
 
16
//                                                                       //
 
17
// This program is distributed in the hope that it will be useful,       //
 
18
// but WITHOUT ANY WARRANTY; without even the implied warranty of        //
 
19
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         //
 
20
// GNU General Public License for more details:                          //
 
21
//                                                                       //
 
22
//          http://www.gnu.org/copyleft/gpl.html                         //
 
23
//                                                                       //
 
24
///////////////////////////////////////////////////////////////////////////
 
25
 
 
26
require_once $CFG->libdir.'/formslib.php';
 
27
 
 
28
class grade_export_form extends moodleform {
 
29
    function definition() {
 
30
        global $CFG, $COURSE, $USER;
 
31
 
 
32
        $mform =& $this->_form;
 
33
        if (isset($this->_customdata)) {  // hardcoding plugin names here is hacky
 
34
            $features = $this->_customdata;
 
35
        } else {
 
36
            $features = array();
 
37
        }
 
38
 
 
39
        $mform->addElement('header', 'options', get_string('options', 'grades'));
 
40
 
 
41
        $mform->addElement('advcheckbox', 'export_feedback', get_string('exportfeedback', 'grades'));
 
42
        $mform->setDefault('export_feedback', 0);
 
43
 
 
44
        $options = array('10'=>10, '20'=>20, '100'=>100, '1000'=>1000, '100000'=>100000);
 
45
        $mform->addElement('select', 'previewrows', get_string('previewrows', 'grades'), $options); 
 
46
        
 
47
        if (!empty($features['updategradesonly'])) {
 
48
            $mform->addElement('advcheckbox', 'updatedgradesonly', get_string('updatedgradesonly', 'grades'));
 
49
        }
 
50
        /// selections for decimal points and format, MDL-11667, defaults to site settings, if set
 
51
        //$default_gradedisplaytype = $CFG->grade_export_displaytype;
 
52
        $options = array(GRADE_DISPLAY_TYPE_REAL       => get_string('real', 'grades'),
 
53
                         GRADE_DISPLAY_TYPE_PERCENTAGE => get_string('percentage', 'grades'),
 
54
                         GRADE_DISPLAY_TYPE_LETTER     => get_string('letter', 'grades'));
 
55
        
 
56
        /*
 
57
        foreach ($options as $key=>$option) {
 
58
            if ($key == $default_gradedisplaytype) {
 
59
                $options[GRADE_DISPLAY_TYPE_DEFAULT] = get_string('defaultprev', 'grades', $option);
 
60
                break;
 
61
            }
 
62
        }
 
63
        */
 
64
        $mform->addElement('select', 'display', get_string('gradeexportdisplaytype', 'grades'), $options);  
 
65
        $mform->setDefault('display', $CFG->grade_export_displaytype);
 
66
        
 
67
        //$default_gradedecimals = $CFG->grade_export_decimalpoints;
 
68
        $options = array(0=>0, 1=>1, 2=>2, 3=>3, 4=>4, 5=>5);
 
69
        $mform->addElement('select', 'decimals', get_string('gradeexportdecimalpoints', 'grades'), $options);
 
70
        $mform->setDefault('decimals', $CFG->grade_export_decimalpoints);
 
71
        $mform->disabledIf('decimals', 'display', 'eq', GRADE_DISPLAY_TYPE_LETTER);
 
72
        /*
 
73
        if ($default_gradedisplaytype == GRADE_DISPLAY_TYPE_LETTER) {
 
74
            $mform->disabledIf('decimals', 'display', "eq", GRADE_DISPLAY_TYPE_DEFAULT);
 
75
        }
 
76
        */
 
77
 
 
78
        if (!empty($features['includeseparator'])) {
 
79
            $radio = array();
 
80
            $radio[] = &MoodleQuickForm::createElement('radio', 'separator', null, get_string('septab', 'grades'), 'tab');
 
81
            $radio[] = &MoodleQuickForm::createElement('radio', 'separator', null, get_string('sepcomma', 'grades'), 'comma');
 
82
            $mform->addGroup($radio, 'separator', get_string('separator', 'grades'), ' ', false);
 
83
            $mform->setDefault('separator', 'comma');
 
84
        }
 
85
 
 
86
        if (!empty($CFG->gradepublishing) and !empty($features['publishing'])) {
 
87
            $mform->addElement('header', 'publishing', get_string('publishing', 'grades'));
 
88
            $options = array(get_string('nopublish', 'grades'), get_string('createnewkey', 'userkey'));
 
89
            if ($keys = get_records_select('user_private_key', "script='grade/export' AND instance={$COURSE->id} AND userid={$USER->id}")) {
 
90
                foreach ($keys as $key) {
 
91
                    $options[$key->value] = $key->value; // TODO: add more details - ip restriction, valid until ??
 
92
                }
 
93
            }
 
94
            $mform->addElement('select', 'key', get_string('userkey', 'userkey'), $options);
 
95
            $mform->setHelpButton('key', array('userkey', get_string('userkey', 'userkey'), 'grade'));
 
96
            $mform->addElement('static', 'keymanagerlink', get_string('keymanager', 'userkey'),
 
97
                    '<a href="'.$CFG->wwwroot.'/grade/export/keymanager.php?id='.$COURSE->id.'">'.get_string('keymanager', 'userkey').'</a>');
 
98
 
 
99
            $mform->addElement('text', 'iprestriction', get_string('keyiprestriction', 'userkey'), array('size'=>80));
 
100
            $mform->setHelpButton('iprestriction', array('keyiprestriction', get_string('keyiprestriction', 'userkey'), 'userkey'));
 
101
            $mform->setDefault('iprestriction', getremoteaddr()); // own IP - just in case somebody does not know what user key is
 
102
 
 
103
            $mform->addElement('date_time_selector', 'validuntil', get_string('keyvaliduntil', 'userkey'), array('optional'=>true));
 
104
            $mform->setHelpButton('validuntil', array('keyvaliduntil', get_string('keyvaliduntil', 'userkey'), 'userkey'));
 
105
            $mform->setDefault('validuntil', time()+3600*24*7); // only 1 week default duration - just in case somebody does not know what user key is
 
106
 
 
107
            $mform->disabledIf('iprestriction', 'key', 'noteq', 1);
 
108
            $mform->disabledIf('validuntil', 'key', 'noteq', 1);
 
109
        }
 
110
 
 
111
        $mform->addElement('header', 'gradeitems', get_string('gradeitemsinc', 'grades'));
 
112
        
 
113
        $switch = grade_get_setting($COURSE->id, 'aggregationposition', $CFG->grade_aggregationposition);
 
114
 
 
115
        // Grab the grade_seq for this course
 
116
        $gseq = new grade_seq($COURSE->id, $switch);
 
117
 
 
118
        if ($grade_items = $gseq->items) {
 
119
            $needs_multiselect = false;
 
120
            foreach ($grade_items as $grade_item) {
 
121
                if (!empty($features['idnumberrequired']) and empty($grade_item->idnumber)) {
 
122
                    $mform->addElement('advcheckbox', 'itemids['.$grade_item->id.']', $grade_item->get_name(), get_string('noidnumber', 'grades'));
 
123
                    $mform->hardFreeze('itemids['.$grade_item->id.']');
 
124
                } else {
 
125
                    $mform->addElement('advcheckbox', 'itemids['.$grade_item->id.']', $grade_item->get_name(), null, array('group' => 1));
 
126
                    $mform->setDefault('itemids['.$grade_item->id.']', 1);
 
127
                    $needs_multiselect = true;
 
128
                }
 
129
            }
 
130
            
 
131
            if ($needs_multiselect) {
 
132
                $this->add_checkbox_controller(1, null, null, 1); // 1st argument is group name, 2nd is link text, 3rd is attributes and 4th is original value
 
133
            }
 
134
        }
 
135
 
 
136
        $mform->addElement('hidden', 'id', $COURSE->id);
 
137
        $this->add_action_buttons(false, get_string('submit'));
 
138
 
 
139
    }
 
140
}
 
141
?>