From 83b10e578e784a8a72eb2be25477ee2d8ab74e29 Mon Sep 17 00:00:00 2001 From: dongsheng Date: Sun, 15 Jun 2008 09:14:55 +0000 Subject: [PATCH] "MDL-14129, fix print_error" --- lang/en_utf8/error.php | 2 +- lang/en_utf8/survey.php | 6 ++++++ mod/survey/download.php | 14 +++++++------- mod/survey/graph.php | 10 +++++----- mod/survey/index.php | 2 +- mod/survey/mod_form.php | 4 ++-- mod/survey/report.php | 12 ++++++------ mod/survey/save.php | 10 +++++----- mod/survey/view.php | 10 +++++----- 9 files changed, 38 insertions(+), 32 deletions(-) diff --git a/lang/en_utf8/error.php b/lang/en_utf8/error.php index ffb20d1721..a4d62d8ab7 100644 --- a/lang/en_utf8/error.php +++ b/lang/en_utf8/error.php @@ -299,7 +299,7 @@ $string['nopermissiontorate'] = 'Rating of items not allowed!'; $string['nopermissiontoimportact'] = 'You do not have the required permissions to import activities to this course'; $string['nopermissiontolock'] = 'No permission to lock!'; $string['nopermissiontomkdir'] = 'Cannot create folder. The site administrator needs to fix the file permissions'; -$string['nopermissiontoshow'] = 'No permission to show!'; +$string['nopermissiontoshow'] = 'No permission to see this!'; $string['nopermissiontounlock'] = 'No permission to unlock!'; $string['nopermissiontoupdateblock'] = 'No permission to update $a!'; $string['nopermissiontoviewpage'] = 'You are not allowed to look at this page'; diff --git a/lang/en_utf8/survey.php b/lang/en_utf8/survey.php index 6975ac9495..3d68f1f115 100644 --- a/lang/en_utf8/survey.php +++ b/lang/en_utf8/survey.php @@ -58,6 +58,10 @@ $string['attlsm2'] = 'Connected Learning'; $string['attlsm3'] = 'Separate Learning'; $string['attlsmintro'] = 'In discussion ...'; $string['attlsname'] = 'ATTLS (20 item version)'; +$string['cannotfindsurveytmpt'] = 'No survey templates found!'; +$string['cannotfindquestion'] = 'Question doesn\'t exist'; +$string['cannotfindanswer'] = 'There are no answers for this survey yet.'; +$string['cannotinsertanswer'] = 'Encountered a problem trying to store your results. Sorry.'; $string['ciq1'] = 'At what moment in class were you most engaged as a learner?'; $string['ciq1short'] = 'Most engaged'; $string['ciq2'] = 'At what moment in class were you most distanced as a learner?'; @@ -176,6 +180,8 @@ $string['howlong'] = 'How long did this survey take you to complete?'; $string['howlongoptions'] = 'under 1 min,1-2 min,2-3 min,3-4 min,4-5-min,5-10 min,more than 10'; $string['ifoundthat'] = 'I found that'; $string['introtext'] = 'Introduction text'; +$string['invalidsurveyid'] = 'Survey ID was incorrect'; +$string['invalidtmptid'] = 'Invalid template id'; $string['ipreferthat'] = 'I prefer that'; $string['modulename'] = 'Survey'; $string['modulenameplural'] = 'Surveys'; diff --git a/mod/survey/download.php b/mod/survey/download.php index 5b3ac438d1..ec3b92ca1c 100644 --- a/mod/survey/download.php +++ b/mod/survey/download.php @@ -9,11 +9,11 @@ $group = optional_param('group', 0, PARAM_INT); if (! $cm = $DB->get_record("course_modules", array("id"=>$id))) { - print_error("Course Module ID was incorrect"); + print_error('invalidcoursemodule'); } if (! $course = $DB->get_record("course", array("id"=>$cm->course))) { - print_error("Course is misconfigured"); + print_error('coursemisconf'); } $context = get_context_instance(CONTEXT_MODULE, $cm->id); @@ -22,7 +22,7 @@ require_capability('mod/survey:download', $context) ; if (! $survey = $DB->get_record("survey", array("id"=>$cm->instance))) { - print_error("Survey ID was incorrect"); + print_error('invalidsurveyid', 'survey'); } add_to_log($course->id, "survey", "download", "download.php?id=$cm->id&type=$type", "$survey->id", $cm->id); @@ -96,7 +96,7 @@ // Get and collate all the results in one big array if (! $aaa = $DB->get_records("survey_answers", array("survey"=>$survey->id), "time ASC")) { - print_error("There are no answers for this survey yet."); + print_error('cannotfindanswer', 'survey'); } foreach ($aaa as $a) { @@ -150,7 +150,7 @@ $col = 0; $row++; if (! $u = $DB->get_record("user", array("id"=>$user))) { - print_error("Error finding student # $user"); + print_error('invaliduserid'); } if ($n = $DB->get_record("survey_analysis", array("survey"=>$survey->id, "userid"=>$user))) { $notes = $n->notes; @@ -220,7 +220,7 @@ $col = 0; $row++; if (! $u = $DB->get_record("user", array("id"=>$user))) { - print_error("Error finding student # $user"); + print_error('invaliduserid'); } if ($n = $DB->get_record("survey_analysis", array("survey"=>$survey->id, "userid"=>$user))) { $notes = $n->notes; @@ -280,7 +280,7 @@ foreach ($results as $user => $rest) { if (! $u = $DB->get_record("user", array("id"=>$user))) { - print_error("Error finding student # $user"); + print_error('invaliduserid'); } echo $survey->id."\t"; echo strip_tags(format_string($survey->name,true))."\t"; diff --git a/mod/survey/graph.php b/mod/survey/graph.php index c7ad83ed8e..fc159cf7a8 100644 --- a/mod/survey/graph.php +++ b/mod/survey/graph.php @@ -11,11 +11,11 @@ $qid = optional_param('qid', 0, PARAM_INT); // Group ID if (! $cm = get_coursemodule_from_id('survey', $id)) { - print_error("Course Module ID was incorrect"); + print_error('invalidcoursemodule'); } if (! $course = $DB->get_record("course", array("id"=>$cm->course))) { - print_error("Course is misconfigured"); + print_error('coursemisconf'); } require_login($course->id, false, $cm); @@ -25,14 +25,14 @@ if (!has_capability('mod/survey:readresponses', $context)) { if ($type != "student.png" or $sid != $USER->id ) { - print_error("Sorry, you aren't allowed to see this."); + print_error('nopermissiontoshow'); } else if ($groupmode and !groups_is_member($group)) { - print_error("Sorry, you aren't allowed to see this."); + print_error('nopermissiontoshow'); } } if (! $survey = $DB->get_record("survey", array("id"=>$cm->instance))) { - print_error("Survey ID was incorrect"); + print_error('invalidsurveyid', 'survey'); } /// Check to see if groups are being used in this survey diff --git a/mod/survey/index.php b/mod/survey/index.php index 9c7ef54d7e..e3c5658a93 100644 --- a/mod/survey/index.php +++ b/mod/survey/index.php @@ -6,7 +6,7 @@ $id = required_param('id', PARAM_INT); // Course Module ID if (!$course = $DB->get_record('course', array('id'=>$id))) { - print_error("Course ID is incorrect"); + print_error('invalidcourseid'); } require_course_login($course); diff --git a/mod/survey/mod_form.php b/mod/survey/mod_form.php index 3962270b27..86733df0b8 100644 --- a/mod/survey/mod_form.php +++ b/mod/survey/mod_form.php @@ -18,7 +18,7 @@ class mod_survey_mod_form extends moodleform_mod { $mform->addRule('name', null, 'required', null, 'client'); if (!$options = $DB->get_records_menu("survey", array("template"=>0), "name", "id, name")) { - print_error('No survey templates found!'); + print_error('cannotfindsurveytmpt', 'survey'); } foreach ($options as $id => $name) { @@ -46,4 +46,4 @@ class mod_survey_mod_form extends moodleform_mod { } -?> \ No newline at end of file +?> diff --git a/mod/survey/report.php b/mod/survey/report.php index 9424ba9a41..7872abdb79 100644 --- a/mod/survey/report.php +++ b/mod/survey/report.php @@ -16,11 +16,11 @@ $qid = implode (',', $qids); if (! $cm = get_coursemodule_from_id('survey', $id)) { - print_error("Course Module ID was incorrect"); + print_error('invalidcoursemodule'); } if (! $course = $DB->get_record("course", array("id"=>$cm->course))) { - print_error("Course is misconfigured"); + print_error('coursemisconf'); } require_login($course->id, false, $cm); @@ -30,11 +30,11 @@ require_capability('mod/survey:readresponses', $context); if (! $survey = $DB->get_record("survey", array("id"=>$cm->instance))) { - print_error("Survey ID was incorrect"); + print_error('invalidsurveyid', 'survey'); } if (! $template = $DB->get_record("survey", array("id"=>$survey->template))) { - print_error("Template ID was incorrect"); + print_error('invalidtmptid', 'survey'); } $showscales = ($template->name != 'ciqname'); @@ -261,7 +261,7 @@ case "question": if (!$question = $DB->get_record("survey_questions", array("id"=>$qid))) { - print_error("Question doesn't exist"); + print_error('cannotfindquestion', 'survey'); } $question->text = get_string($question->text, "survey"); @@ -321,7 +321,7 @@ case "student": if (!$user = $DB->get_record("user", array("id"=>$student))) { - print_error("Student doesn't exist"); + print_error('invaliduserid'); } print_heading(get_string("analysisof", "survey", fullname($user))); diff --git a/mod/survey/save.php b/mod/survey/save.php index 6bbbdea462..a405d4969f 100644 --- a/mod/survey/save.php +++ b/mod/survey/save.php @@ -7,17 +7,17 @@ // Make sure this is a legitimate posting if (!$formdata = data_submitted()) { - print_error("You are not supposed to use this script like that."); + print_error('cannotcallscript'); } $id = required_param('id', PARAM_INT); // Course Module ID if (! $cm = get_coursemodule_from_id('survey', $id)) { - print_error("Course Module ID was incorrect"); + print_error('invalidcoursemodule'); } if (! $course = $DB->get_record("course", array("id"=>$cm->course))) { - print_error("Course is misconfigured"); + print_error('coursemisconf'); } require_login($course->id, false, $cm); @@ -26,7 +26,7 @@ require_capability('mod/survey:participate', $context); if (! $survey = $DB->get_record("survey", array("id"=>$cm->instance))) { - print_error("Survey ID was incorrect"); + print_error('invalidsurveyid', 'survey'); } add_to_log($course->id, "survey", "submit", "view.php?id=$cm->id", "$survey->id", "$cm->id"); @@ -85,7 +85,7 @@ } if (! $DB->insert_record("survey_answers", $newdata)) { - print_error("Encountered a problem trying to store your results. Sorry."); + print_error('cannotinsertanswer', 'survey'); } } diff --git a/mod/survey/view.php b/mod/survey/view.php index 0cc346c65a..4fa6b05eee 100644 --- a/mod/survey/view.php +++ b/mod/survey/view.php @@ -6,11 +6,11 @@ $id = required_param('id', PARAM_INT); // Course Module ID if (! $cm = get_coursemodule_from_id('survey', $id)) { - print_error("Course Module ID was incorrect"); + print_error('invalidcoursemodule'); } if (! $course = $DB->get_record("course", array("id"=>$cm->course))) { - print_error("Course is misconfigured"); + print_error('coursemisconf'); } require_login($course->id, false, $cm); @@ -20,7 +20,7 @@ require_capability('mod/survey:participate', $context); if (! $survey = $DB->get_record("survey", array("id"=>$cm->instance))) { - print_error("Survey ID was incorrect"); + print_error('invalidsurveyid', 'survey'); } $trimmedintro = trim($survey->intro); if (empty($trimmedintro)) { @@ -29,7 +29,7 @@ } if (! $template = $DB->get_record("survey", array("id"=>$survey->template))) { - print_error("Template ID was incorrect"); + print_error('invalidtmptid', 'survey'); } $showscales = ($template->name != 'ciqname'); @@ -115,7 +115,7 @@ // Get all the major questions and their proper order if (! $questions = $DB->get_records_list("survey_questions", "id", explode(',', $survey->questions))) { - print_error("Couldn't find any questions in this survey!!"); + print_error('cannotfindquestion', 'survey'); } $questionorder = explode( ",", $survey->questions); -- 2.39.5