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

PHP prepare_choice_show_results函数代码示例

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

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



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

示例1: get_choice_results

 /**
  * Returns user's results for a specific choice
  * and a list of those users that did not answered yet.
  *
  * @param int $choiceid the choice instance id
  * @return array of responses details
  * @since Moodle 3.0
  */
 public static function get_choice_results($choiceid)
 {
     global $USER, $PAGE;
     $params = self::validate_parameters(self::get_choice_results_parameters(), array('choiceid' => $choiceid));
     if (!($choice = choice_get_choice($params['choiceid']))) {
         throw new moodle_exception("invalidcoursemodule", "error");
     }
     list($course, $cm) = get_course_and_cm_from_instance($choice, 'choice');
     $context = context_module::instance($cm->id);
     self::validate_context($context);
     $groupmode = groups_get_activity_groupmode($cm);
     // Check if we have to include responses from inactive users.
     $onlyactive = $choice->includeinactive ? false : true;
     $users = choice_get_response_data($choice, $cm, $groupmode, $onlyactive);
     // Show those who haven't answered the question.
     if (!empty($choice->showunanswered)) {
         $choice->option[0] = get_string('notanswered', 'choice');
         $choice->maxanswers[0] = 0;
     }
     $results = prepare_choice_show_results($choice, $course, $cm, $users);
     $options = array();
     $fullnamecap = has_capability('moodle/site:viewfullnames', $context);
     foreach ($results->options as $optionid => $option) {
         $userresponses = array();
         $numberofuser = 0;
         $percentageamount = 0;
         if (property_exists($option, 'user') and (has_capability('mod/choice:readresponses', $context) or choice_can_view_results($choice))) {
             $numberofuser = count($option->user);
             $percentageamount = (double) $numberofuser / (double) $results->numberofuser * 100.0;
             if ($choice->publish) {
                 foreach ($option->user as $userresponse) {
                     $response = array();
                     $response['userid'] = $userresponse->id;
                     $response['fullname'] = fullname($userresponse, $fullnamecap);
                     $userpicture = new user_picture($userresponse);
                     $userpicture->size = 1;
                     // Size f1.
                     $response['profileimageurl'] = $userpicture->get_url($PAGE)->out(false);
                     // Add optional properties.
                     foreach (array('answerid', 'timemodified') as $field) {
                         if (property_exists($userresponse, 'answerid')) {
                             $response[$field] = $userresponse->{$field};
                         }
                     }
                     $userresponses[] = $response;
                 }
             }
         }
         $options[] = array('id' => $optionid, 'text' => external_format_string($option->text, $context->id), 'maxanswer' => $option->maxanswer, 'userresponses' => $userresponses, 'numberofuser' => $numberofuser, 'percentageamount' => $percentageamount);
     }
     $warnings = array();
     return array('options' => $options, 'warnings' => $warnings);
 }
开发者ID:alanaipe2015,项目名称:moodle,代码行数:61,代码来源:external.php


示例2: qualified_me

    } else {
        if (!is_enrolled($context)) {
            // Only people enrolled can make a choice
            $SESSION->wantsurl = qualified_me();
            $SESSION->enrolcancel = get_local_referer(false);
            $coursecontext = context_course::instance($course->id);
            $courseshortname = format_string($course->shortname, true, array('context' => $coursecontext));
            echo $OUTPUT->box_start('generalbox', 'notice');
            echo '<p align="center">' . get_string('notenrolledchoose', 'choice') . '</p>';
            echo $OUTPUT->container_start('continuebutton');
            echo $OUTPUT->single_button(new moodle_url('/enrol/index.php?', array('id' => $course->id)), get_string('enrolme', 'core_enrol', $courseshortname));
            echo $OUTPUT->container_end();
            echo $OUTPUT->box_end();
        }
    }
}
// print the results at the bottom of the screen
if (choice_can_view_results($choice, $current, $choiceopen)) {
    if (!empty($choice->showunanswered)) {
        $choice->option[0] = get_string('notanswered', 'choice');
        $choice->maxanswers[0] = 0;
    }
    $results = prepare_choice_show_results($choice, $course, $cm, $allresponses);
    $renderer = $PAGE->get_renderer('mod_choice');
    echo $renderer->display_result($results);
} else {
    if (!$choiceformshown) {
        echo $OUTPUT->box(get_string('noresultsviewable', 'choice'));
    }
}
echo $OUTPUT->footer();
开发者ID:pzhu2004,项目名称:moodle,代码行数:31,代码来源:view.php


示例3: format_string

                echo $ug2 . "\t";
                if (isset($option_text)) {
                    echo format_string($option_text, true);
                }
                echo "\n";
            }
        }
    }
    exit;
}
// Show those who haven't answered the question.
if (!empty($choice->showunanswered)) {
    $choice->option[0] = get_string('notanswered', 'choice');
    $choice->maxanswers[0] = 0;
}
$results = prepare_choice_show_results($choice, $course, $cm, $users);
$renderer = $PAGE->get_renderer('mod_choice');
echo $renderer->display_result($results, has_capability('mod/choice:readresponses', $context));
//now give links for downloading spreadsheets.
if (!empty($users) && has_capability('mod/choice:downloadresponses', $context)) {
    $downloadoptions = array();
    $options = array();
    $options["id"] = "{$cm->id}";
    $options["download"] = "ods";
    $button = $OUTPUT->single_button(new moodle_url("report.php", $options), get_string("downloadods"));
    $downloadoptions[] = html_writer::tag('li', $button, array('class' => 'reportoption'));
    $options["download"] = "xls";
    $button = $OUTPUT->single_button(new moodle_url("report.php", $options), get_string("downloadexcel"));
    $downloadoptions[] = html_writer::tag('li', $button, array('class' => 'reportoption'));
    $options["download"] = "txt";
    $button = $OUTPUT->single_button(new moodle_url("report.php", $options), get_string("downloadtext"));
开发者ID:pzhu2004,项目名称:moodle,代码行数:31,代码来源:report.php



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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