Only in /Applications/MAMP/htdocs/moodle19/mod/questionnaire/: .DS_Store Only in /Applications/MAMP/htdocs/moodle19/mod/questionnaire/css: iss.css diff -ur /Users/daniele/Desktop/questionnaire/db/install.xml /Applications/MAMP/htdocs/moodle19/mod/questionnaire/db/install.xml --- /Users/daniele/Desktop/questionnaire/db/install.xml 2008-01-22 10:43:48.000000000 +0100 +++ /Applications/MAMP/htdocs/moodle19/mod/questionnaire/db/install.xml 2008-02-18 14:16:19.000000000 +0100 @@ -68,8 +68,9 @@ - - + + + diff -ur /Users/daniele/Desktop/questionnaire/db/upgrade.php /Applications/MAMP/htdocs/moodle19/mod/questionnaire/db/upgrade.php --- /Users/daniele/Desktop/questionnaire/db/upgrade.php 2008-01-18 10:43:04.000000000 +0100 +++ /Applications/MAMP/htdocs/moodle19/mod/questionnaire/db/upgrade.php 2008-02-18 14:16:19.000000000 +0100 @@ -75,6 +75,17 @@ set_field('questionnaire_question_type', 'response_table', 'resp_multiple', 'response_table', 'response_multiple'); } + if ($result && $oldversion < 2007120103) { + + /// Define field numberalias to be added to questionnaire_question + $table = new XMLDBTable('questionnaire_question'); + $field = new XMLDBField('numberalias'); + $field->setAttributes(XMLDB_TYPE_CHAR, '15', null, XMLDB_NOTNULL, null, null, null, null, 'name'); + + /// Launch add field numberalias + $result = $result && add_field($table, $field); + } + return $result; } diff -ur /Users/daniele/Desktop/questionnaire/general.inc /Applications/MAMP/htdocs/moodle19/mod/questionnaire/general.inc --- /Users/daniele/Desktop/questionnaire/general.inc 2008-02-12 10:39:58.000000000 +0100 +++ /Applications/MAMP/htdocs/moodle19/mod/questionnaire/general.inc 2008-02-18 14:16:19.000000000 +0100 @@ -124,21 +124,21 @@ rewind(); - while ($file=$dir->read()) { - if (stristr($file,".css")) { - $pos = strrpos($file, "."); - $name = substr($file, 0,$pos); - $themes_array[$file] = $name; - } + $dir->rewind(); + while ($file=$dir->read()) { + if (stristr($file,".css")) { + $pos = strrpos($file, "."); + $name = substr($file, 0,$pos); + $themes_array[$file] = $name; } - $dir->close(); - if ($survey->theme) { - $selected = $survey->theme; - } else { - $selected = 'default'; - } - choose_from_menu ($themes_array, 'theme', $selected, ""); + } + $dir->close(); + if ($survey->theme) { + $selected = $survey->theme; + } else { + $selected = 'default'; + } + choose_from_menu ($themes_array, 'theme', $survey->theme); ?>
Only in /Applications/MAMP/htdocs/moodle19/mod/questionnaire/lang: .DS_Store diff -ur /Users/daniele/Desktop/questionnaire/lang/en_utf8/questionnaire.php /Applications/MAMP/htdocs/moodle19/mod/questionnaire/lang/en_utf8/questionnaire.php --- /Users/daniele/Desktop/questionnaire/lang/en_utf8/questionnaire.php 2008-02-21 10:42:38.000000000 +0100 +++ /Applications/MAMP/htdocs/moodle19/mod/questionnaire/lang/en_utf8/questionnaire.php 2008-02-26 10:58:59.000000000 +0100 @@ -2,6 +2,7 @@ $string['addaline'] = 'Add another answer line'; $string['additionalinfo'] = 'Additional Info'; $string['addsectionbreak'] = 'Add Section Break'; +$string['addsavenewquestion'] = 'Add/Save new question: '; $string['all'] = 'All'; $string['alreadyfilled'] = 'You have already filled out this questionnaire for us$a. Thank you.'; $string['anonymous'] = 'Anonymous'; @@ -11,8 +12,9 @@ $string['boxesnbexact'] = 'exactly $a box(es).'; $string['boxesnbmax'] = 'a maximum of $a box(es).'; $string['boxesnbmin'] = 'a minimum of $a box(es).'; -$string['boxesnbreq'] = 'For this question you must tick '; +$string['boxesnbreq'] = 'For this question you must tick '; $string['by'] = ' by '; +$string['characters'] = ' chars'; $string['changeorder'] = 'Change the order that questions are presented by choosing the desired position from the list.'; $string['checkallradiobuttons'] = 'Please check all $a radio buttons!'; $string['checkboxes'] = 'Check Boxes'; @@ -36,18 +38,26 @@ $string['deletedresp'] = 'Deleted Response'; $string['deleteresp'] = 'Delete this Response'; $string['deletingresp'] = 'Deleting Response'; +$string['deletecurrentquestion'] = 'Delete edited question'; $string['displaymethod'] = 'Display method not defined for question.'; $string['dropdown'] = 'Dropdown Box'; $string['edit'] = 'Edit'; -$string['editfield'] = 'Edit $a, or click the number of the question you want to edit.'; +$string['editnewq1'] = 'You are editing a new question $a'; +$string['editnewq2'] = 'finalize the new question definition by entering all required information and saving it'; +$string['editnewq3'] = 'use the drop down menu and the button to edit a pre-existing question.'; $string['editingquestionnaire'] = 'Editing Questionnaire - General Page'; $string['editingsurvey'] = 'Editing Questions'; -$string['editquestions'] = 'Edit Questions'; +$string['editpreexisting1'] = 'You are editing the pre-existing question $a'; +$string['editpreexisting2'] = 'finalize the pre-existing question editing by changing what you need and saving it'; +$string['editpreexisting3'] = 'use the \"New question\" button to add a new question.'; +$string['editpreexisting4'] = 'Take care: To save changes you can use the \"Save edited question\" or ask for a new question or start the edition of a different preexisting question.'; +$string['editquestion'] = 'Edit/Save Question'; +$string['editquestions'] = 'Edit/Save Questions'; $string['email'] = 'Email'; $string['errnewname'] = 'Sorry, name already in use. Pick a new name.'; $string['errquestionchange'] = 'Sorry, you cannot change between those types of question. Create a new question instead.'; $string['errquestionoption'] = 'Sorry, you need at least two answer options for $a questions.
You should go back and add one or more options to question # '; -$string['errquestiontext'] = 'Please enter text for this question OR click the Finish button to stop editing questions.'; +$string['errquestiontext'] = 'Please enter text for this question OR click the Finish button to stop editing questions.'; $string['errquestiontype'] = 'Sorry, you must select a type for this question.'; $string['errrequiredfields'] = 'Sorry, please fill out the name, group, and title before proceeding.'; $string['errorcross'] = 'Error cross-analyzing. Question not valid type.'; @@ -55,7 +65,8 @@ $string['errortable'] = 'Error system table corrupt.'; $string['essaybox'] = 'Essay Box'; $string['field'] = 'Question $a'; -$string['fieldname'] = 'Question Name (optional)'; +$string['fieldname'] = 'Name'; +$string['fieldlength'] = 'Field length'; $string['general'] = 'General'; $string['generalpage'] = 'The information on this page applies to the whole questionnaire. Fill out any options you wish on this page then click on the Edit Questions button to edit individual questions.'; $string['guestsnotallowed'] = 'Sorry, guests are not allowed to answer questionnaire $a.'; @@ -68,19 +79,28 @@ $string['invalidresponse'] = 'Invalid response specified.'; $string['invalidresponserecord'] = 'Invalid response record specified.'; $string['invalidsurveyid'] = 'Invalid questionnaire ID.'; +$string['kindoflikertscale'] = 'Kind of likert scale'; $string['length'] = 'Length'; +$string['maxdigitsallowed'] = 'Max digits allowed'; +$string['maxforcedresponses'] = 'Max forced responses'; +$string['maxtextlength'] = 'Max text length'; +$string['minforcedresponses'] = 'Min forced responses'; $string['misconfigured'] = 'Course is misconfigured'; -$string['missingquestion'] = 'You are missing required question: '; -$string['missingquestions'] = 'You are missing required question(s): '; +$string['missingquestion'] = 'You are missing required question '; +$string['missingquestions'] = 'You are missing required questions: '; +$string['missingqname'] = 'no name'; +$string['missingqnalias'] = 'no # alias'; $string['modulename'] = 'Questionnaire'; $string['modulenameplural'] = 'Questionnaires'; +$string['mustcomplete'] = 'You must complete this questionnaire now to record your results. You will not be allowed to complete it at another time
'; $string['myresponsedated'] = 'Your response dated: $a'; $string['myresponses'] = 'All your responses'; $string['myresponsetitle'] = 'Your results for $a responses'; -$string['myresults'] = 'Your Results'; +$string['myresults'] = 'My Results'; $string['name'] = 'Name'; +$string['named'] = 'named: '; $string['navigateirs'] = 'Navigate Individual Respondent Submissions'; -$string['newfield'] = 'Save question'; +$string['newfield'] = 'New question'; $string['newfieldenter'] = 'Save New question'; $string['next'] = 'Next'; $string['nextpage'] = 'Next Page'; @@ -94,10 +114,14 @@ $string['notavail'] = 'That questionnaire is not available yet. Try again later.'; $string['noteligible'] = 'You are not eligible to take this questionnaire.'; $string['notemplatesurveys'] = 'No template questionnaires.'; +$string['numberfloat'] = 'The number you entered $a->number has been reformatted/rounded with $a->precision decimal place(s).'; +$string['numberalias'] = 'Number alias'; $string['notopen'] = 'This questionnaire will not open until $a.'; $string['notused'] = 'Not Used'; $string['num'] = '#'; $string['numberfloat'] = 'The number you entered $a->number has been reformatted/rounded with $a->precision decimal place(s).'; +$string['numberlikertscaleitems'] = '# likert scale items'; +$string['numberofdecimaldigits'] = '# of decimal digits'; $string['numeric'] = 'Numeric'; $string['of'] = 'of'; $string['opendate'] = 'Use Open Date'; @@ -107,7 +131,7 @@ $string['owner'] = 'Owner'; $string['page'] = 'Page'; $string['pageof'] = 'Page $a->page of $a->totpages'; -$string['possibleanswers'] = 'Enter the possible answers (if applicable).'; +$string['possibleanswers'] = 'Enter the possible answers.'; $string['posteddata'] = 'Reached page with posted data:'; $string['precision'] = 'Precision'; $string['preview'] = 'This is a preview of how this questionnaire will look. When you are done previewing, click Close at the bottom of this page.'; @@ -162,6 +186,9 @@ $string['responseviewstudentsnever'] = 'Never'; $string['responseviewstudentswhenanswered'] = 'After answering the questionnaire'; $string['responseviewstudentswhenclosed'] = 'After the questionnaire is closed'; +$string['responseview'] = 'View responses'; +$string['responseviewstudents'] = 'Teachers and students'; +$string['responseviewteachers'] = 'Teachers only'; $string['restrictedtoteacher'] = 'These functions are restricted to editing teachers only!'; $string['resume'] = 'Save/Resume answers'; $string['resumesurvey'] = 'Resume questionnaire'; @@ -169,10 +196,12 @@ $string['save'] = 'Save'; $string['saveandreturn'] = 'Finish'; $string['savedprogress'] = 'Your progress has been saved. You may return at any time to complete this questionnaire. To do so, simply bookmark the $a link below. You may be prompted for your username and password to complete the questionnaire.'; +$string['saveeditedquestion'] = 'Save edited question'; $string['section'] = 'Description'; $string['sectionbreak'] = '----- Section Break -----'; -$string['sectiontext'] = 'Section Text'; +$string['sectiontext'] = 'Label'; $string['selectexisting'] = 'or select existing'; +$string['selectquestiontoedit'] = 'Select a question to edit/delete: '; $string['selecttheme'] = 'Select a theme (css) to use with this questionnaire.'; $string['sendemail'] = 'Sends a copy of each submission to address (or leave blank for no email backup).'; $string['strfdate'] = '%%d/%%m/%%Y'; @@ -190,8 +219,10 @@ $string['surveytitle'] = 'Title of this questionnaire, which will appear at the top of every page. By default Title is set to the questionnaire Name, but you can edit it as you like.'; $string['template'] = 'Template'; $string['templatenotviewable'] = 'Template questionnaires are not viewable.'; -$string['text'] = 'Question
Text'; -$string['textbox'] = 'Text Box'; +$string['text'] = 'Question Text'; +$string['textbox'] = 'Text Box'; +$string['textareacolumns'] = 'Textarea columns'; +$string['textarearows'] = 'Textarea rows'; $string['thank_body'] = 'Do not use the back button on your browser to go back. Click on the $a button below.'. $string['thank_head'] = 'Thank you for completing this Questionnaire.'; $string['theme'] = 'Theme'; @@ -217,4 +248,5 @@ $string['wrongformat'] = 'There is something wrong with question: '; $string['wrongformats'] = 'There is something wrong with questions: '; $string['yesno'] = 'Yes/No'; +$string['youcan'] = 'You can:'; ?> \ No newline at end of file diff -ur /Users/daniele/Desktop/questionnaire/locallib.php /Applications/MAMP/htdocs/moodle19/mod/questionnaire/locallib.php --- /Users/daniele/Desktop/questionnaire/locallib.php 2008-01-27 10:41:50.000000000 +0100 +++ /Applications/MAMP/htdocs/moodle19/mod/questionnaire/locallib.php 2008-02-21 15:02:59.000000000 +0100 @@ -885,9 +885,9 @@ // new survey if(empty($this->survey->id)) { if (isset($sdata->name)) { - $sdata->name = eregi_replace( - "[^A-Z0-9]+", "_", trim($sdata->name) ); - $sdata->name = ereg_replace('_$',"",$sdata->name); + $sdata->name = eregi_replace( + "[^A-Z0-9]+", "_", trim($sdata->name) ); + $sdata->name = ereg_replace('_$',"",$sdata->name); } // need to fill out at least some info on 1st tab before proceeding @@ -925,9 +925,9 @@ // coming from the general tab ... case "general": if (isset($sdata->name)) { - $sdata->name = eregi_replace( - "[^A-Z0-9]+", "_", trim($sdata->name) ); - $sdata->name = ereg_replace('_$',"",$sdata->name); + $sdata->name = eregi_replace( + "[^A-Z0-9]+", "_", trim($sdata->name) ); + $sdata->name = ereg_replace('_$',"",$sdata->name); } if(empty($sdata->name) || empty($sdata->title) @@ -1079,7 +1079,7 @@ // UPDATE row in the DB for the current question if($qid != '') { - $fields = array('name','type_id','length','precise','required','content'); + $fields = array('name','numberalias','type_id','length','precise','required','content'); $question_record = new Object(); $question_record->id = $qid; foreach($fields as $f) { @@ -1100,7 +1100,7 @@ } $sdata->survey_id = $this->survey->id; - $fields = array('survey_id','name','type_id','length','precise','required','content','position'); + $fields = array('survey_id','name','numberalias','type_id','length','precise','required','content','position'); $question_record = new Object(); foreach($fields as $f) { if(isset($sdata->$f)) { @@ -1121,41 +1121,63 @@ // UPDATE or INSERT rows for each of the question choices for this question if($has_choices[$sdata->type_id]) { $cids = array(); - $sql = 'SELECT c.id, c.question_id FROM '.$CFG->prefix.'questionnaire_question q, '.$CFG->prefix.'questionnaire_quest_choice c WHERE q.id=c.question_id AND q.survey_id='.$this->survey->id; + $sql = 'SELECT c.id, c.question_id, c.content '; + $sql .= 'FROM '.$CFG->prefix.'questionnaire_question q, '.$CFG->prefix.'questionnaire_quest_choice c '; + $sql .= 'WHERE q.id=c.question_id '; + $sql .= 'AND q.survey_id='.$this->survey->id.' '; + $sql .= 'AND q.id='.$sdata->id.' '; + $sql .= 'ORDER BY c.id'; + if (!($records = get_records_sql($sql))) { $records = array(); } foreach ($records as $record) { array_push($cids, $record->id); } - $count = 0; - for($i = 1; $i < $sdata->num_choices+1; $i++) { - $choice_id = intval($sdata->{"choice_id_${i}"}); - $choice_content = trim($sdata->{"choice_content_${i}"}); - // each of the submitted choices - if($choice_id=='' && $choice_content!='') { - // insert (new) - $choice_record = new Object(); - $choice_record->question_id = $qid; - $choice_record->content = $choice_content; - $result = insert_record('questionnaire_quest_choice', $choice_record); - ++$count; - } elseif($choice_id!='' && $choice_content=='') { - // delete (old) - $result = delete_records('questionnaire_quest_choice', 'id', $choice_id); - } elseif($choice_id!='' && $choice_content!='' && in_array($choice_id, $cids)) { - // update (old) - $rsult = set_field('questionnaire_quest_choice', 'content', $choice_content, 'id', $choice_id); - ++$count; - } - if($sql != '') { - if(!$result) { - $dont_clear = 1; - $errstr = get_string('warning', 'questionnaire').' [ : ]'; - return(false); - } - } - } + $count = 0; + //la variabile da salvare รจ: $sdata->allchoices + // remove empty textarea lines + $sdata->allchoices = str_replace("\t", '', $sdata->allchoices); + //$sdata->allchoices = trim($sdata->allchoices); + //$sdata->allchoices = rtrim($sdata->allchoices, "\n"); + + $choices_content = explode("\n", $sdata->allchoices); + $alreadyindb = count($records); + $recordskeys = array_keys($records); +// records[Array element]->Object + foreach ($choices_content as $choice_content) { + if ($choice_content) { + $record = $records[$recordskeys[$count]]; + $choice_id = $record->id; + // non corregge gli spazi + $choice_content = trim($choice_content); +// echo ('$choice_content='.$choice_content); +// echo (' ('.strlen($choice_content)."char)
"); + if ( $count < $alreadyindb ) { + // first records, eventually already present into the db, replace them + if ($record->content != $choice_content) { + $result = set_field('questionnaire_quest_choice', 'content', $choice_content, 'id', $choice_id); + } + } else { + // other new textarea rows, still needing to be written, add them + $choice_record = new Object(); + $choice_record->question_id = $qid; + $choice_record->content = $choice_content; + $result = insert_record('questionnaire_quest_choice', $choice_record); + } + ++$count; + } + } + if ( $count < $alreadyindb ) { + do { + // stored records exceeded the number of submitted textarea rows: delete them + $record = $records[$recordeskeys[$count]]; + $choice_id = $record->id; + $result = delete_records('questionnaire_quest_choice', 'id', $choice_id); + ++$count; + } while( $count < $alreadyindb); + } + // TODO check to be finalized JR /* if($count < 2 && !isset($sdata->extra_choices)) { @@ -1288,6 +1310,7 @@ $qid = $record->id; $tid = $record->type_id; + $nid = $record->numberalias; $lid = $record->length; $pid = $record->precise; $content = $record->content; @@ -1296,7 +1319,11 @@ } if ( ($record->required == 'y') && ($record->deleted == 'n') && ((isset($formdata->{'q'.$qid}) && $formdata->{'q'.$qid} == '') || (!isset($formdata->{'q'.$qid}))) && $tid != 8 && $tid != 100 ) { $missing++; - $strmissing .= get_string('num', 'questionnaire').$qnum.'. '; + if ($nid) { + $strmissing .= '
  • '.get_string('numberalias', 'questionnaire').' '.$nid.'
  • '; + } else { + $strmissing .= '
  • '.get_string('num', 'questionnaire').$qnum.'
  • '; + } } switch ($tid) { @@ -1311,7 +1338,11 @@ $resp = 'q'.$qid.''.substr($resp,5); if (!$formdata->$resp) { $missing++; - $strmissing .= get_string('num', 'questionnaire').$qnum.'. '; + if ($nid) { + $strmissing .= '
  • '.get_string('numberalias', 'questionnaire').' '.$nid.'
  • '; + } else { + $strmissing .= '
  • '.get_string('num', 'questionnaire').$qnum.'
  • '; + } } } break; @@ -1335,8 +1366,11 @@ // number of ticked boxes is not within min and max set limits if ( $nbrespchoices && ($nbrespchoices < $min || $nbrespchoices > $max) ) { $wrongformat++; - $strwrongformat .= get_string('num', 'questionnaire').$qnum.'. '; - break; + if ($nid) { + $strmissing .= '
  • '.get_string('numberalias', 'questionnaire').' '.$nid.'
  • '; + } else { + $strmissing .= '
  • '.get_string('num', 'questionnaire').$qnum.'
  • '; + } } break; @@ -1344,7 +1378,11 @@ $resp = $formdata->{'q'.$qid}; if (!$resp && $record->required == 'y') { $missing++; - $strmissing .= get_string('num', 'questionnaire').$qnum.'. '; + if ($nid) { + $strmissing .= '
  • '.get_string('numberalias', 'questionnaire').' '.$nid.'
  • '; + } else { + $strmissing .= '
  • '.get_string('num', 'questionnaire').$qnum.'
  • '; + } } break; @@ -1368,26 +1406,42 @@ } if ( $num == 0 && $record->required == 'y') { $missing++; - $strmissing .= get_string('num', 'questionnaire').$qnum.'. '; + if ($nid) { + $strmissing .= '
  • '.get_string('numberalias', 'questionnaire').' '.$nid.'
  • '; + } else { + $strmissing .= '
  • '.get_string('num', 'questionnaire').$qnum.'
  • '; + } break; } if ( ($num != $nbchoices) && ($num!=0) ) { $wrongformat++; - $strwrongformat .= get_string('num', 'questionnaire').$qnum.'. '; + if ($nid) { + $strwrongformat .= '
  • '.get_string('numberalias', 'questionnaire').' '.$nid.'
  • '; + } else { + $strwrongformat .= '
  • '.get_string('num', 'questionnaire').$qnum.'
  • '; + } } break; case 9: // Date if (($formdata->{'q'.$qid} != '') && (!check_date($formdata->{'q'.$qid})) ) { $wrongformat++; - $strwrongformat .= get_string('num', 'questionnaire').$qnum.'. '; + if ($nid) { + $strwrongformat .= '
  • '.get_string('numberalias', 'questionnaire').' '.$nid.'
  • '; + } else { + $strwrongformat .= '
  • '.get_string('num', 'questionnaire').$qnum.'
  • '; + } } break; case 10: // Numeric if ( ($formdata->{'q'.$qid} != '') && (!is_numeric($formdata->{'q'.$qid})) ) { $wrongformat++; - $strwrongformat .= get_string('num', 'questionnaire').$qnum.'. '; + if ($nid) { + $strwrongformat .= '
  • '.get_string('numberalias', 'questionnaire').' '.$nid.'
  • '; + } else { + $strwrongformat .= '
  • '.get_string('num', 'questionnaire').$qnum.'
  • '; + } } break; @@ -1398,9 +1452,9 @@ $message =''; if($missing) { if ($missing == 1) { - $message = get_string('missingquestion', 'questionnaire').$strmissing; + $message = get_string('missingquestion', 'questionnaire').'
      '.$strmissing.'
    '; } else { - $message = get_string('missingquestions', 'questionnaire').$strmissing; + $message = get_string('missingquestions', 'questionnaire').'
      '.$strmissing.'
    '; } if ($wrongformat) { $message .= '
    '; @@ -1408,9 +1462,9 @@ } if($wrongformat) { if ($wrongformat == 1) { - $message .= get_string('wrongformat', 'questionnaire').$strwrongformat; + $message .= get_string('wrongformat', 'questionnaire').'
      '.$strwrongformat.'
    '; } else { - $message .= get_string('wrongformats', 'questionnaire').$strwrongformat; + $message .= get_string('wrongformats', 'questionnaire').'
      '.$strwrongformat.'
    '; } } return ($message); @@ -2379,7 +2433,7 @@ Exports the results of a survey to an array. */ function generate_csv($rid='') { - global $CFG; + global $CFG; $output = array(); $columns = array( diff -ur /Users/daniele/Desktop/questionnaire/manage_survey.php /Applications/MAMP/htdocs/moodle19/mod/questionnaire/manage_survey.php --- /Users/daniele/Desktop/questionnaire/manage_survey.php 2008-02-12 10:39:58.000000000 +0100 +++ /Applications/MAMP/htdocs/moodle19/mod/questionnaire/manage_survey.php 2008-02-26 11:16:39.000000000 +0100 @@ -471,7 +471,7 @@ echo '
    '; echo ''; helpbutton("general", get_string("general", "questionnaire"), "questionnaire", true, false); - echo ' '; + echo ' '; helpbutton("editquestions", get_string("editquestions", "questionnaire"), "questionnaire", true, false); echo ' '; helpbutton("reorderquestions", get_string("reorderquestions", "questionnaire"), "questionnaire", true, false); @@ -485,9 +485,10 @@ echo ''; /// Finish the page - if ($questionnaire->usehtmleditor) { - use_html_editor(); - } + // rem needed if you don't want usehtmleditor for question_options + //if ($questionnaire->usehtmleditor) { + // use_html_editor(); + //} print_footer($c_obj); break; diff -ur /Users/daniele/Desktop/questionnaire/order.inc /Applications/MAMP/htdocs/moodle19/mod/questionnaire/order.inc --- /Users/daniele/Desktop/questionnaire/order.inc 2008-02-21 10:42:38.000000000 +0100 +++ /Applications/MAMP/htdocs/moodle19/mod/questionnaire/order.inc 2008-02-26 11:06:01.000000000 +0100 @@ -85,7 +85,7 @@ $select = 'survey_id='.$sid.' AND deleted=\'n\''; if (!($questions = - get_records_select('questionnaire_question', $select, 'position', 'id,type_id,position,content,required'))) { + get_records_select('questionnaire_question', $select, 'position', 'id,type_id,name,numberalias,position,content,required'))) { $questions = array(); } $max = count($questions); @@ -141,7 +141,7 @@
    - +
    required; $pos = $question->position; + $name = $question->name; + $numberalias = $question->numberalias; $content = format_text_email($question->content, FORMAT_HTML); - if ($required == 'y') { + /*if ($required == 'y') { $content = ''.get_string('requiredelement', 'form').
                         ' '.$content; } else { $content = '   '.$content; - } + }*/ $num++; $select = ''; for ( $i = 0; $i < $max; ) { @@ -169,21 +171,57 @@ ?> + + + - + diff -ur /Users/daniele/Desktop/questionnaire/questions.inc /Applications/MAMP/htdocs/moodle19/mod/questionnaire/questions.inc --- /Users/daniele/Desktop/questionnaire/questions.inc 2008-01-27 10:41:50.000000000 +0100 +++ /Applications/MAMP/htdocs/moodle19/mod/questionnaire/questions.inc 2008-02-26 10:58:56.000000000 +0100 @@ -52,6 +52,7 @@ if (!empty($formdata->extra_choices)) { $qcontent = $formdata->content; $qname = $formdata->name; //fixes for bug CONTRIB-187 + $numberalias = $formdata->numberalias; $qlength = $formdata->length; $qprecise = $formdata->precise; } @@ -80,7 +81,7 @@ $curr_q_id = 0; } $updated = true; // JR just in case - $fields = array('name','type_id','length','precise','required','content','position'); + $fields = array('name','numberalias','type_id','length','precise','required','content','position'); if($updated && $total_num_q > 0 && $curr_q) { // survey questions exist already // load values from DB @@ -93,7 +94,7 @@ // adding a new question (possibly because there are no questions yet) $curr_q = 0; $curr_q_id = ''; - foreach(array('name','length','precise','content','position') as $f) { + foreach(array('name','numberalias','length','precise','content','position') as $f) { $formdata->$f = ''; } } else { @@ -107,6 +108,7 @@ if (!empty($qcontent)) { $formdata->content = $qcontent; $formdata->name = $qname; //fixes for bug CONTRIB-187 + $formdata->numberalias = $numberalias; $formdata->length = $qlength; $formdata->precise = $qprecise; } @@ -118,46 +120,124 @@ while (document.phpesp.elements["choice_content_" + i]) { document.phpesp.elements["choice_content_" + i].value = ""; i++; - - } + } } // comment --> -
    +
    0) { + print_simple_box_start(); + print_string("selectquestiontoedit", "questionnaire"); + echo(''."\n"); + echo(''."\n"); - echo(''); - echo(''); - // JR display current question as plain text, not button because no action is possible on it - for($i=1; $i<$total_num_q+1; ++$i) { - if ($i == $curr_q) { - echo("[ $i ] "); - } else { - echo(' '); + $i=1; + echo (''); + echo(''); + echo(''); + // JR display current question as plain text, not button because no action is possible on it + /*for($i=1; $i<$total_num_q+1; ++$i) { + if ($i == $curr_q) { + echo("[ $i ] "); + } else { + echo(' '); + } + }*/ + if ($curr_q !=0) { + //$strremove = get_string('remove', 'questionnaire') .' ' .get_string('field', 'questionnaire', $curr_q); + //$strremove = get_string('deletecurrentquestion', 'questionnaire'); + echo ('

     '); + echo (''); + helpbutton("removequestion", get_string("remove", "questionnaire"), "questionnaire", true, false); } + print_simple_box_end(); } + + print_simple_box_start(); + print_string("addsavenewquestion", "questionnaire"); $strnewquestion = get_string('newfield', 'questionnaire'); if ($curr_q !=0) { - echo(''); + echo(' '); } else { $strnewquestion = get_string('newfieldenter', 'questionnaire'); - echo(''); - } - if ($curr_q !=0) { - $strremove = get_string('remove', 'questionnaire') .' ' .get_string('field', 'questionnaire', $curr_q); - echo ('

     '.'

    '); - helpbutton("removequestion", get_string("remove", "questionnaire"), "questionnaire", true, false); + echo(' '); } - echo'
    '; + print_simple_box_end(); if(is_numeric($curr_q) && $curr_q != 0) { - $a = ''.get_string('field', 'questionnaire', "$curr_q").''; + // $a = ''.get_string('field', 'questionnaire', "$curr_q").''; + if (!$formdata->name) { + if (!$formdata->numberalias) { + $a = $curr_q; + } else { + $a = get_string('numberalias', 'questionnaire').': '.$formdata->numberalias; + } + } else { + if (!$formdata->numberalias) { + $a = get_string('named', 'questionnaire').$formdata->name; + } else { + $a = get_string('named', 'questionnaire').$formdata->name.', '.get_string('numberalias', 'questionnaire').': '.$formdata->numberalias; + } + } + + print_simple_box_start(); + echo '

    '.get_string('editpreexisting1', 'questionnaire', $a).'

    '; + echo '
    '.get_string('youcan', 'questionnaire').'
    '; + echo '
    • '; + echo '
      '.get_string('editpreexisting2', 'questionnaire').'
      '; + echo '
    • '; + echo '
      '.get_string('editpreexisting3', 'questionnaire').'
      '; + echo '
    '; + echo '

    '.get_string('editpreexisting4', 'questionnaire').'

    '; } else { + // new question $num = $total_num_q + 1; - $a = get_string('newfield', 'questionnaire').' ('.get_string("num", "questionnaire").$num.') '; + // $a = get_string('newfield', 'questionnaire').' ('.get_string("num", "questionnaire").$num.') '; + $a = '('.get_string("num", "questionnaire").$num.'). '; + + print_simple_box_start(); + echo '

    '.get_string('editnewq1', 'questionnaire', $a).'

    '; + echo '
    '.get_string('youcan', 'questionnaire').'
    '; + echo '
    • '; + echo '
      '.get_string('editnewq2', 'questionnaire').'
      '; + echo '
    • '; + echo '
      '.get_string('editnewq3', 'questionnaire').'
      '; + echo '
    '; } + print_simple_box_end(); +/* print_simple_box(helpbutton("editquestions", get_string("editquestions", "questionnaire"), "questionnaire", true, false, '', true). get_string('editfield', 'questionnaire', $a),'center'); +*/ if (!empty($SESSION->ERROR_QUESTIONTEXT)) { questionnaire_notify ($SESSION->ERROR_QUESTIONTEXT); } @@ -165,71 +245,192 @@ questionnaire_notify ($SESSION->ERROR_QUESTIONTYPE); } ?> -
    - + + + + + + +pixpath.'/req.gif" />'; + } + } +?> '.get_string('sectionbreak', 'questionnaire').''); } ?>
    - - - - - - - - - - - - - - - + + + + + +
     
      - - type_id)) { - $formdata->type_id = 0; // JR Default = choose - } - $select = 'typeid != 99'; - if (!($results = get_records_select('questionnaire_question_type', $select, - '', 'typeid,type'))) { - $results = array(); - } - $arr = array(); - foreach ($results as $result) { - $key = $result->typeid; - $arr["$key"] = get_type ($result->typeid); - } - choose_from_menu ($arr, 'type_id', $formdata->type_id); - ?> - length)) $formdata->length = 0; - ?> - - precise)) $formdata->precise = 0; - ?> - - required)) $formdata->required = 'n'; - choose_from_menu (array("y" => get_string('yes'), "n" => get_string('no')), 'required', $formdata->required); + + + + + + + + + + + + - - - - - -
    + pixpath.'/req.gif" />'); + helpbutton("questiontypes", get_string("type", "questionnaire"), "questionnaire", true, false); + ?> + + + + type_id != '') { + if(!($formdata->type_id == QUESYESNO || + $formdata->type_id == QUESRADIO || + $formdata->type_id == QUESDROP || + $formdata->type_id == QUESDATE || + $formdata->type_id == QUESSECTIONTEXT)) { + switch ($formdata->type_id) { + case QUESTEXT: + print_string('fieldlength', 'questionnaire'); + break; + case QUESESSAY: + print_string('textareacolumns', 'questionnaire'); + break; + case QUESCHECK: + print_string('minforcedresponses', 'questionnaire'); + break; + case QUESRATE: + print_string('numberlikertscaleitems', 'questionnaire'); + break; + case QUESNUMERIC: + print_string('maxdigitsallowed', 'questionnaire'); + break; + } + helpbutton("lengthprecision", get_string("length", "questionnaire"), "questionnaire", true, false); + } + } ?> + + type_id != '') { + if(!($formdata->type_id == QUESYESNO || + $formdata->type_id == QUESRADIO || + $formdata->type_id == QUESDROP || + $formdata->type_id == QUESDATE || + $formdata->type_id == QUESSECTIONTEXT)) { + switch ($formdata->type_id) { + case QUESTEXT: + print_string('maxtextlength', 'questionnaire'); + break; + case QUESESSAY: + print_string('textarearows', 'questionnaire'); + break; + case QUESCHECK: + print_string('maxforcedresponses', 'questionnaire'); + break; + case QUESRATE: + print_string('kindoflikertscale', 'questionnaire'); + break; + case QUESNUMERIC: + print_string('numberofdecimaldigits', 'questionnaire'); + break; + } + helpbutton("lengthprecision", get_string("length", "questionnaire"), "questionnaire", true, false); + } + } ?> +
    + type_id)) { + $formdata->type_id = QUESCHOOSE; // JR Default = choose + } + $select = 'typeid != 99'; + if (!($results = get_records_select('questionnaire_question_type', $select, '', 'typeid,type'))) { + $results = array(); + } + $arr = array(); + foreach ($results as $result) { + $key = $result->typeid; + $arr["$key"] = get_type ($result->typeid); + } + //get_string('choose') + choose_from_menu ($arr, 'type_id', $formdata->type_id, null, "this.form.submit();"); + + echo(''); + echo(''); ?>
    - usehtmleditor, 10, 50, 680, 400, 'content', stripslashes($formdata->content) ); - ?> -
    +
    required)) $formdata->required = 'n'; + choose_from_menu (array("y" => get_string('yes'), "n" => get_string('no')), 'required', $formdata->required); + ?> + + length)) $formdata->length = 0; + if($formdata->type_id == '' || + $formdata->type_id == QUESYESNO || + $formdata->type_id == QUESRADIO || + $formdata->type_id == QUESDROP || + $formdata->type_id == QUESDATE || + $formdata->type_id == QUESSECTIONTEXT) { + echo (''); + } else { + echo (''); + if ($formdata->type_id == QUESTEXT) print_string('characters', 'questionnaire'); + } + ?> + + precise)) $formdata->precise = 0; + if($formdata->type_id == '' || + $formdata->type_id == QUESYESNO || + $formdata->type_id == QUESRADIO || + $formdata->type_id == QUESDROP || + $formdata->type_id == QUESDATE || + $formdata->type_id == QUESSECTIONTEXT) { + echo (''); + } else { + echo (''); + if ($formdata->type_id == QUESTEXT) print_string('characters', 'questionnaire'); + } + ?> +
     
    + + + + + + + + + + + + + + +
    + + + + + + + + +
    + usehtmleditor, 10, 50, 680, 400, 'content', stripslashes($formdata->content) ); + use_html_editor("content"); + ?> +
    type_id == QUESRADIO || + $formdata->type_id == QUESCHECK || + $formdata->type_id == QUESDROP || + $formdata->type_id == QUESRATE)) { // has answer options ... so show that part of the form if($curr_q == 0 || empty($formdata->type_id) || (get_field('questionnaire_question_type', 'has_choices', 'typeid', $formdata->type_id) == 'y')) { include('questions_options.inc'); } +} ?> + \ No newline at end of file diff -ur /Users/daniele/Desktop/questionnaire/questions_options.inc /Applications/MAMP/htdocs/moodle19/mod/questionnaire/questions_options.inc --- /Users/daniele/Desktop/questionnaire/questions_options.inc 2008-01-27 10:41:50.000000000 +0100 +++ /Applications/MAMP/htdocs/moodle19/mod/questionnaire/questions_options.inc 2008-02-21 08:19:31.000000000 +0100 @@ -40,9 +40,9 @@ ?> - + - allchoices = ''; for($i=1; $i<$num_choices+1; ++$i) { if ($updated && $curr_q && !$SESSION->NEWQUESTION) { $choice = current($choices); @@ -73,21 +74,17 @@ $choice_content = ''; } } -?> + if ($choice_content) { + if ($formdata->allchoices) { + $formdata->allchoices .= "\n"; + } + $formdata->allchoices .= $choice_content; + } + } + ?> - - - - - - -
    + ERROR_QUESTIONOPTION)) { notify ($SESSION->ERROR_QUESTIONOPTION); @@ -54,6 +54,7 @@
    . - - + + allchoices) ); ?>
      -
    diff -ur /Users/daniele/Desktop/questionnaire/questiontypes/questiontypes.class.php /Applications/MAMP/htdocs/moodle19/mod/questionnaire/questiontypes/questiontypes.class.php --- /Users/daniele/Desktop/questionnaire/questiontypes/questiontypes.class.php 2008-02-26 10:38:16.000000000 +0100 +++ /Applications/MAMP/htdocs/moodle19/mod/questionnaire/questiontypes/questiontypes.class.php 2008-02-26 11:30:00.000000000 +0100 @@ -17,6 +17,7 @@ */ /// Constants +define('QUESCHOOSE', 0); define('QUESYESNO', 1); define('QUESTEXT', 2); define('QUESESSAY', 3); @@ -54,49 +55,55 @@ * The database id of this question. * @var int $id */ - var $id = 0; + var $id = 0; /** * The database id of the survey this question belongs to. * @var int $survey_id */ - var $survey_id = 0; + var $survey_id = 0; /** * The name of this question. * @var string $name */ - var $name = ''; + var $name = ''; + + /** + * The alias of the number of this question. + * @var string $numberalias + */ + var $numberalias = ''; /** * The name of the question type. * @var string $type */ - var $type = ''; + var $type = ''; /** * Array holding any choices for this question. * @var array $choices */ - var $choices = array(); + var $choices = array(); /** * The table name for responses. * @var string $response_table */ - var $response_table = ''; + var $response_table = ''; /** * The length field. * @var int $length */ - var $length = 0; + var $length = 0; /** * The precision field. * @var int $precise */ - var $precise = 0; + var $precise = 0; /** * Position in the questionnaire @@ -108,7 +115,13 @@ * The question's content. * @var string $content */ - var $content = ''; + var $content = ''; + + /** + * The list of all question's choices. + * @var string $allchoices + */ + var $allchoices = ''; /** * The required flag. @@ -120,13 +133,13 @@ * The deleted flag. * @var boolean $deleted */ - var $deleted = 'n'; + var $deleted = 'n'; /** * The public flag. * @var boolean $public */ - var $public = 'n'; + var $public = 'n'; /// Class Methods @@ -151,6 +164,7 @@ $this->id = $question->id; $this->survey_id = $question->survey_id; $this->name = $question->name; + $this->numberalias = $question->numberalias; $this->length = $question->length; $this->precise = $question->precise; $this->position = $question->position; @@ -837,28 +851,34 @@ } function questionstart_survey_display($qnum, $data='') { - global $CFG; + global $CFG; if ($this->type_id == QUESSECTIONTEXT) { return; } + //print_r($this); echo '
    - +
    - + echo ' +
    '; + '; + if (!$this->numberalias) { + echo $qnum; + } else { + echo $this->numberalias; + } if ($this->required == 'y') { echo (''.get_string('requiredelement', 'form').
-                        ''); + '" src="'.$CFG->pixpath.'/req.gif" />'); } - echo $qnum.' - '. - format_text($this->content, FORMAT_HTML).' + format_text($this->content, FORMAT_HTML).'
      '; } @@ -1093,10 +1113,10 @@ if ($other !== 0) { // this is a normal check box $content = $choice->content; // DEV JR to accommodate associated values - $pos = strpos($content, '='); - if ($pos) { - $choice->content = substr($content, $pos + 1); - } + $pos = strpos($content, '='); + if ($pos) { + $choice->content = substr($content, $pos + 1); + } print_checkbox ('q'.$this->id.'[]', $id, in_array($id, $data->{'q'.$this->id}), format_text($choice->content, FORMAT_HTML)); echo '
    '; @@ -1314,7 +1334,10 @@ } function sectiontext_survey_display($data) { - echo ' + echo '
    '; + echo format_text($this->content, FORMAT_HTML); + echo '
    '; + /*echo '
    @@ -1327,7 +1350,7 @@
    - '; + ';*/ } ///*** @@ -1439,10 +1462,16 @@ if (strpos($choice->content, '!other') !== 0) { $content = $choice->content; // DEV JR to accommodate associated values - $pos = strpos($content, '='); - if ($pos) { - $choice->content = substr($content, $pos + 1); - } + $pos = strpos($content, '='); + if ($pos) { + $choice->content = substr($content, $pos + 1); + } + $content = $choice->content; + // DEV JR to accommodate associated values + $pos = strpos($content, '='); + if ($pos) { + $choice->content = substr($content, $pos + 1); + } if (in_array($id, $data->{'q'.$this->id})) { echo ''. ' '.