• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP survey_already_done函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中survey_already_done函数的典型用法代码示例。如果您正苦于以下问题:PHP survey_already_done函数的具体用法?PHP survey_already_done怎么用?PHP survey_already_done使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了survey_already_done函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: survey_user_complete

function survey_user_complete($course, $user, $mod, $survey)
{
    global $CFG;
    if (survey_already_done($survey->id, $user->id)) {
        if ($survey->template == SURVEY_CIQ) {
            // print out answers for critical incidents
            $table = NULL;
            $table->align = array("left", "left");
            $questions = get_records_list("survey_questions", "id", $survey->questions);
            $questionorder = explode(",", $survey->questions);
            foreach ($questionorder as $key => $val) {
                $question = $questions[$val];
                $questiontext = get_string($question->shorttext, "survey");
                if ($answer = survey_get_user_answer($survey->id, $question->id, $user->id)) {
                    $answertext = "{$answer->answer1}";
                } else {
                    $answertext = "No answer";
                }
                $table->data[] = array("<b>{$questiontext}</b>", $answertext);
            }
            print_table($table);
        } else {
            survey_print_graph("id={$mod->id}&amp;sid={$user->id}&amp;type=student.png");
        }
    } else {
        print_string("notdone", "survey");
    }
}
开发者ID:JackCanada,项目名称:moodle-hacks,代码行数:28,代码来源:lib.php


示例2: array

}
if ($course->format == "weeks") {
    $table->head = array($strweek, $strname, $strstatus);
    $table->align = array("CENTER", "LEFT", "LEFT");
} else {
    if ($course->format == "topics") {
        $table->head = array($strtopic, $strname, $strstatus);
        $table->align = array("CENTER", "LEFT", "LEFT");
    } else {
        $table->head = array($strname, $strstatus);
        $table->align = array("LEFT", "LEFT");
    }
}
$currentsection = '';
foreach ($surveys as $survey) {
    if (!empty($USER->id) and survey_already_done($survey->id, $USER->id)) {
        $ss = $strdone;
    } else {
        $ss = $strnotdone;
    }
    $printsection = "";
    if ($survey->section !== $currentsection) {
        if ($survey->section) {
            $printsection = $survey->section;
        }
        if ($currentsection !== "") {
            $table->data[] = 'hr';
        }
        $currentsection = $survey->section;
    }
    //Calculate the href
开发者ID:BackupTheBerlios,项目名称:samouk-svn,代码行数:31,代码来源:index.php


示例3: require_capability

$context = context_module::instance($cm->id);
require_capability('mod/survey:participate', $context);
if (!($survey = $DB->get_record("survey", array("id" => $cm->instance)))) {
    print_error('invalidsurveyid', 'survey');
}
$trimmedintro = trim($survey->intro);
if (empty($trimmedintro)) {
    $tempo = $DB->get_field("survey", "intro", array("id" => $survey->template));
    $survey->intro = get_string($tempo, "survey");
}
if (!($template = $DB->get_record("survey", array("id" => $survey->template)))) {
    print_error('invalidtmptid', 'survey');
}
$showscales = $template->name != 'ciqname';
// Check the survey hasn't already been filled out.
$surveyalreadydone = survey_already_done($survey->id, $USER->id);
if ($surveyalreadydone) {
    // Trigger course_module_viewed event and completion.
    survey_view($survey, $course, $cm, $context, 'graph');
} else {
    survey_view($survey, $course, $cm, $context, 'form');
}
$strsurvey = get_string("modulename", "survey");
$PAGE->set_title($survey->name);
$PAGE->set_heading($course->fullname);
echo $OUTPUT->header();
echo $OUTPUT->heading($survey->name);
// Check to see if groups are being used in this survey.
if ($groupmode = groups_get_activity_groupmode($cm)) {
    // Groups are being used.
    $currentgroup = groups_get_activity_group($cm);
开发者ID:evltuma,项目名称:moodle,代码行数:31,代码来源:view.php


示例4: error

    error("Course Module ID was incorrect");
}
if (!($course = get_record("course", "id", $cm->course))) {
    error("Course is misconfigured");
}
require_login($course->id, false, $cm);
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
require_capability('mod/survey:participate', $context);
if (!($survey = get_record("survey", "id", $cm->instance))) {
    error("Survey ID was incorrect");
}
add_to_log($course->id, "survey", "submit", "view.php?id={$cm->id}", "{$survey->id}", "{$cm->id}");
$strsurveysaved = get_string('surveysaved', 'survey');
$navigation = build_navigation('', $cm);
print_header_simple("{$strsurveysaved}", "", $navigation, "");
if (survey_already_done($survey->id, $USER->id)) {
    notice(get_string("alreadysubmitted", "survey"), $_SERVER["HTTP_REFERER"]);
    exit;
}
// Sort through the data and arrange it
// This is necessary because some of the questions
// may have two answers, eg Question 1 -> 1 and P1
$answers = array();
foreach ($formdata as $key => $val) {
    if ($key != "userid" && $key != "id") {
        if (substr($key, 0, 1) == "q") {
            $key = clean_param(substr($key, 1), PARAM_ALPHANUM);
            // keep everything but the 'q', number or Pnumber
        }
        if (substr($key, 0, 1) == "P") {
            $realkey = (int) substr($key, 1);
开发者ID:kai707,项目名称:ITSA-backup,代码行数:31,代码来源:save.php


示例5: get_all_sections

        $sections = get_all_sections($course->id);
    }

    $table = new html_table();
    $table->width = '100%';

    if ($usesections) {
        $table->head  = array ($strsectionname, $strname, $strstatus);
    } else {
        $table->head  = array ($strname, $strstatus);
    }

    $currentsection = '';

    foreach ($surveys as $survey) {
        if (isloggedin() and survey_already_done($survey->id, $USER->id)) {
            $ss = $strdone;
        } else {
            $ss = $strnotdone;
        }
        $printsection = "";
        if ($usesections) {
            if ($survey->section !== $currentsection) {
                if ($survey->section) {
                    $printsection = get_section_name($course, $sections[$survey->section]);
                }
                if ($currentsection !== "") {
                    $table->data[] = 'hr';
                }
                $currentsection = $survey->section;
            }
开发者ID:JP-Git,项目名称:moodle,代码行数:31,代码来源:index.php


示例6: survey_user_complete

/**
 * @global stdObject
 * @global object
 * @uses SURVEY_CIQ
 * @param object $course
 * @param object $user
 * @param object $mod
 * @param object $survey
 */
function survey_user_complete($course, $user, $mod, $survey) {
    global $CFG, $DB, $OUTPUT;

    if (survey_already_done($survey->id, $user->id)) {
        if ($survey->template == SURVEY_CIQ) { // print out answers for critical incidents
            $table = new html_table();
            $table->align = array("left", "left");

            $questions = $DB->get_records_list("survey_questions", "id", explode(',', $survey->questions));
            $questionorder = explode(",", $survey->questions);

            foreach ($questionorder as $key=>$val) {
                $question = $questions[$val];
                $questiontext = get_string($question->shorttext, "survey");

                if ($answer = survey_get_user_answer($survey->id, $question->id, $user->id)) {
                    $answertext = "$answer->answer1";
                } else {
                    $answertext = "No answer";
                }
                $table->data[] = array("<b>$questiontext</b>", s($answertext));
            }
            echo html_writer::table($table);

        } else {

            survey_print_graph("id=$mod->id&amp;sid=$user->id&amp;type=student.png");
        }

    } else {
        print_string("notdone", "survey");
    }
}
开发者ID:rezaies,项目名称:moodle,代码行数:42,代码来源:lib.php


示例7: submit_answers

 /**
  * Submit the answers for a given survey.
  *
  * @param int $surveyid the survey instance id
  * @param array $answers the survey answers
  * @return array of warnings and status result
  * @since Moodle 3.0
  * @throws moodle_exception
  */
 public static function submit_answers($surveyid, $answers)
 {
     global $DB, $USER;
     $params = self::validate_parameters(self::submit_answers_parameters(), array('surveyid' => $surveyid, 'answers' => $answers));
     $warnings = array();
     // Request and permission validation.
     $survey = $DB->get_record('survey', array('id' => $params['surveyid']), '*', MUST_EXIST);
     list($course, $cm) = get_course_and_cm_from_instance($survey, 'survey');
     $context = context_module::instance($cm->id);
     self::validate_context($context);
     require_capability('mod/survey:participate', $context);
     if (survey_already_done($survey->id, $USER->id)) {
         throw new moodle_exception("alreadysubmitted", "survey");
     }
     // Build the answers array. Data is cleaned inside the survey_save_answers function.
     $answers = array();
     foreach ($params['answers'] as $answer) {
         $key = $answer['key'];
         $answers[$key] = $answer['value'];
     }
     survey_save_answers($survey, $answers, $course, $context);
     $result = array();
     $result['status'] = true;
     $result['warnings'] = $warnings;
     return $result;
 }
开发者ID:rushi963,项目名称:moodle,代码行数:35,代码来源:external.php



注:本文中的survey_already_done函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP survey_count_responses函数代码示例发布时间:2022-05-23
下一篇:
PHP surveyGetXMLData函数代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap