diff --git a/mod/data/add.php b/mod/data/add.php index 83aeff9a28f..49aa7094029 100755 --- a/mod/data/add.php +++ b/mod/data/add.php @@ -117,7 +117,11 @@ //set flag to unapproved after each edit $record = get_record('data_records','id',$rid); - $record->approved = 0; + if (isteacher($course->id)) { + $record->approved = 1; + } else { + $record->approved = 0; + } update_record('data_records',$record); foreach ($datarecord as $name=>$value){ diff --git a/mod/data/lang/en/data.php b/mod/data/lang/en/data.php index f8d0bf05498..02842192e6c 100755 --- a/mod/data/lang/en/data.php +++ b/mod/data/lang/en/data.php @@ -4,10 +4,10 @@ $string['add'] = 'Add entry'; $string['addafield'] = 'Add a Field'; $string['addtemplate'] = 'Add Template'; $string['ascending'] = 'Ascending'; -$string['atmaxentry'] = 'you are at the maximum number of entries!'; -$string['autogenallforms'] = 'Generate All Default Templates'; +$string['atmaxentry'] = 'You have entered the maximum number of entries allowed!'; +$string['autogenallforms'] = 'Generate all default templates'; $string['availablefromdate'] = 'Available from'; -$string['availabletags'] = 'Available Tags'; +$string['availabletags'] = 'Available tags'; $string['availabletodate'] = 'Available to'; $string['browse'] = 'Browse'; $string['cancel'] = 'Cancel'; @@ -23,16 +23,16 @@ $string['menu'] = 'Menu (Single-selection)'; $string['menuchoose'] = 'Choose...'; $string['emptyadd'] = 'The Add template is empty, generating a default form...'; $string['emptyaddform'] = 'You did not fill out any fields!'; -$string['entrysaved'] = 'Entry Saved'; -$string['example'] = 'Database Module Example'; -$string['fieldadded'] = 'Field Added'; -$string['fielddeleted'] = 'Field Deleted'; -$string['fieldname'] = 'Field Name'; +$string['entrysaved'] = 'Your entry has been saved'; +$string['example'] = 'Database module example'; +$string['fieldadded'] = 'Field added'; +$string['fielddeleted'] = 'Field deleted'; +$string['fieldname'] = 'Field name'; $string['fields'] = 'Fields'; -$string['fieldupdated'] = 'Field Updated'; +$string['fieldupdated'] = 'Field updated'; $string['file'] = 'File'; $string['footer'] = 'Footer'; -$string['generatedefault'] = 'Generate Default Template'; +$string['generatedefault'] = 'Generate default template'; $string['header'] = 'Header'; $string['headeraddtemplate'] = 'Defines the interface when adding new entries'; $string['headerlisttemplate'] = 'Defines browsing interface for multiple entries'; @@ -46,9 +46,9 @@ $string['listtemplate'] = 'List Template'; $string['maxentries'] = 'Maximum entries'; $string['modulename'] = 'Database'; $string['modulenameplural'] = 'Databases'; -$string['multientry'] = 'Repeated Entry'; +$string['multientry'] = 'Repeated entry'; $string['multimenu'] = 'Menu (Multiple-selection)'; -$string['multipletags'] = 'multiple tags found! template not saved'; +$string['multipletags'] = 'Multiple tags found! Template not saved'; $string['namecheckbox'] = 'Checkbox Field'; $string['namemenu'] = 'Menu Field'; $string['namemultimenu'] = 'Multiple-selection Menu Field'; @@ -58,7 +58,7 @@ $string['nameurl'] = 'URL Field'; $string['nametext'] = 'Text Field'; $string['nametextarea'] = 'Textarea Field'; $string['namepicture'] = 'Picture Field'; -$string['newentry'] = 'New Entry:'; +$string['newentry'] = 'New entry'; $string['newfield'] = 'Create a new field'; $string['nofieldindatabase'] = 'There are no fields defined for this database, please add some'; $string['nolisttemplate'] = 'List template is not yet defined'; @@ -69,25 +69,25 @@ $string['numrecords'] = 'Records'; $string['noaccess'] = 'You do not have access to this page'; $string['nomatch'] = 'No matching entries found!'; $string['norecords'] = 'No entries in database'; -$string['optionaldescription'] = 'Short Description (Optional)'; -$string['optionalfilename'] = 'File Name (Optional)'; -$string['pagesize'] = 'Number of Entries Per Page'; +$string['optionaldescription'] = 'Short description (optional)'; +$string['optionalfilename'] = 'Filename (optional)'; +$string['pagesize'] = 'Entries per page'; $string['participants'] = 'Participants'; $string['picture'] = 'Picture'; -$string['radiobutton'] = 'Radio Button(s)'; +$string['radiobutton'] = 'Radio Buttons'; $string['recorddeleted'] = 'Record Deleted'; $string['requireapproval'] = 'Require Approval?'; $string['requiredentries'] = 'Required entries'; $string['requiredentriestoview'] = 'Entries required before viewing'; $string['rsstemplate'] = 'RSS Template'; $string['save'] = 'Save'; -$string['savetemplate'] = 'Save Template'; +$string['savetemplate'] = 'Save template'; $string['singletemplate'] = 'Single Template'; $string['teachersandstudents'] = '$a->teachers and $a->students'; $string['templates'] = 'Templates'; $string['text'] = 'Text'; $string['textarea'] = 'Textarea'; -$string['type'] = 'Field Type'; +$string['type'] = 'Field type'; $string['updatefield'] = 'Update an existing field'; $string['url'] = 'Url'; $string['viewfromdate'] = 'Viewable from'; diff --git a/mod/data/lib.php b/mod/data/lib.php index e9605434f50..12a65512606 100755 --- a/mod/data/lib.php +++ b/mod/data/lib.php @@ -29,7 +29,6 @@ define ('PARTICIPANTS_TS', 3); define ('DATAMAXENTRIES', 50); define ('PERPAGE_SINGLE', 1); - class data_field_base { //base class (text field) var $type = 'text'; /// Base class implements "text" field type completely. @@ -258,7 +257,7 @@ function data_generate_default_form($dataid, $mode){ } if ($mode!='addtemplate' and $mode!='rsstemplate'){ //if not adding, we put tags in there - $str .= '##Edit## ##More## ##Delete##'; + $str .= '##Edit## ##More## ##Delete## ##Approve##'; } $str .= ''; @@ -326,8 +325,6 @@ function data_get_field_from_name($name){ if ($field){ return data_get_field($field); - } else { - return false; } } @@ -400,12 +397,17 @@ function data_numentries($data){ * output bool * ****************************************************************/ function data_add_record($dataid, $groupid=0){ - global $USER; + global $USER, $course; $record->userid = $USER->id; $record->groupid = $groupid; $record->dataid = $dataid; $record->timecreated = time(); $record->timemodified = time(); + if (isteacher($course->id)) { + $record->approved = 1; + } else { + $record->approved = 0; + } return insert_record('data_records',$record); } @@ -680,10 +682,12 @@ function data_print_template($records, $data, $search, $template, $sort, $page, unset($g); } + $record = get_record('data_records','id',$record->id); ///replacing special tags (##Edit##, ##Delete##, ##More##) $patterns[]='/\#\#Edit\#\#/i'; $patterns[]='/\#\#Delete\#\#/i'; $patterns[]='/\#\#More\#\#/i'; + $patterns[]='/\#\#Approve\#\#/i'; if (data_isowner($record->id) or isteacheredit($course->id)){ $replacement[] = 'wwwroot.'/mod/data/view.php?d='.$data->id.'&rid='.$record->id.'&search='.$search.'&sort='.$sort.'&order='.$order.'&">'.get_string('more').''; + if (isteacher($course->id) && ($data->approval) && (!$record->approved)){ + $replacement[] = data_print_approve_button($record->id, $data->id, $page, $rid, $search, $sort, $order); + }else { + $replacement[] = ''; + } + ///actual replacement of the tags $newtext = preg_replace($patterns, $replacement, $data->{$template}); echo $newtext; //prints the template with tags replaced //if this record is not yet approved, and database requires approval, print silly button - - $record = get_record('data_records','id',$record->id); - - if (isteacher($course->id) && (!$record->approved) && $data->approval) { - data_print_approve_button($record->id, $data->id, $page, $rid, $search, $sort, $order); - } echo '

'; } } @@ -727,28 +731,29 @@ function data_print_template($records, $data, $search, $template, $sort, $page, function data_print_preference_form($data, $perpage, $search, $sort='', $order='ASC'){ echo '
'; echo '
'; - echo ''; - echo ''; - echo ''; - echo ''; echo ''; - echo '
'.get_string('search').''; - echo '
'; - echo ''; - echo ':'; - $pagesizes = array(1=>1,2=>2,3=>3,4=>4,5=>5,6=>6,7=>7,8=>8,9=>9,10=>10,15=>15,20=>20,30=>30,40=>40,50=>50,100=>100,200=>200,300=>300,400=>400,500=>500,1000=>1000); + echo ''; + echo ''. + ''; + echo ''; + echo ''. + ''. + ''. + ''; echo ''; - echo ''; - echo '
'; + $pagesizes = array(1=>1,2=>2,3=>3,4=>4,5=>5,6=>6,7=>7,8=>8,9=>9,10=>10,15=>15, + 20=>20,30=>30,40=>40,50=>50,100=>100,200=>200,300=>300,400=>400,500=>500,1000=>1000); choose_from_menu($pagesizes,'perpage1',$perpage,'choose','','0'); echo '
'.get_string('search').':
'; - echo 'Sort by:'; - echo ''; + echo '
'; + echo get_string('sortby').':'; + echo ''; //foreach field, print the option $fields = get_records('data_fields','dataid',$data->id); echo '
'; - echo ''; + echo ''; + echo ''; echo '
'; echo ''; } //silly function that prints a button function data_print_approve_button($recordid, $d, $page='0', $rid='0', $search='', $sort='', $order='') { - echo '
'; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo '
'; + $str= '
'; + $str.= ''; + $str.= ''; + $str.= ''; + $str.= ''; + $str.= ''; + $str.= ''; + $str.= ''; + $str.= ''; + $str.= ''; + $str.= '
'; + return $str; } //silly function that approves a record diff --git a/mod/data/styles.php b/mod/data/styles.php new file mode 100644 index 00000000000..7e14bea620a --- /dev/null +++ b/mod/data/styles.php @@ -0,0 +1,3 @@ +#mod-data-view #sortsearch .c0 { + text-align: right; +} diff --git a/mod/data/templates.php b/mod/data/templates.php index d91896a182f..5752938ff1f 100755 --- a/mod/data/templates.php +++ b/mod/data/templates.php @@ -159,6 +159,7 @@ echo ''; echo ''; echo ''; + echo ''; echo ''; ///add the HTML editor(s) diff --git a/mod/data/view.php b/mod/data/view.php index dc63d2f66e5..3dd8c52d442 100755 --- a/mod/data/view.php +++ b/mod/data/view.php @@ -117,7 +117,7 @@ /// Check to see if groups are being used here if ($groupmode = groupmode($course, $cm)) { // Groups are being used - $currentgroup = setup_and_print_groups($course, $groupmode, "view.php?id=$cm->id"); + $currentgroup = setup_and_print_groups($course, $groupmode, "'view.php?d='.$data->id.'&search='.s($search).'&sort='.s($sort).'&order='.s($order).'&page='.$page.'&'"); } else { $currentgroup = 0; }