使用pdfobject.js实现在线浏览PDF

<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title>在指定div中浏览PDF</title>
        <!--在此引入bootstrap只为初始化样式div样式-->
        <link rel="stylesheet" href="css/bootstrap.min.css" />
        <style>
            /* 添加样式是为了实现全屏效果 */
            html,body{
                height: 100%;
                overflow: hidden;
            }
            
            #example1{
                height: 100%;
            }
            
            .pdfobject-container{
                /* height: 500px; */
            }
            
            .pdfobject{
                /* border: 1px solid #666; */
            }
        </style>
    </head>
    
    <body>
        <div id="example1"></div>
            
        <script type="text/javascript" src="js/pdfobject.min.js"></script>
        <script>
            // 我的pdf文件放在项目的pdf文件夹下,名字叫做Java.pdf,指定PDF从20页开始阅读
            PDFObject.embed("pdf/Java.pdf", "#example1", {page: "20"});
        </script>
    </body>
</html>

How to embed a PDF without using JavaScript

方式一:

<embed src="/pdf/sample-3pp.pdf#page=2" type="application/pdf" width="100%" height="100%" />

方式二:

<iframe src="/pdf/sample-3pp.pdf#page=2" width="100%" height="100%">
</iframe>

方式三:

<object data="/pdf/sample-3pp.pdf#page=2" type="application/pdf" width="100%" height="100%">
   <b>Example fallback content</b>: This browser does not support PDFs. Please download the PDF to view it: 
   <a href="/pdf/sample-3pp.pdf">Download PDF</a>.
</object>

方式四:

<object data="/pdf/sample-3pp.pdf#page=2" type="application/pdf" width="100%" height="100%">
   <iframe src="/pdf/sample-3pp.pdf#page=2" width="100%" height="100%" style="border: none;">
     This browser does not support PDFs. Please download the PDF to view it: 
     <a href="/pdf/sample-3pp.pdf">Download PDF</a>
   </iframe>
</object>

yii2 checkboxlist使用及数据入库

视图表单部分

<?php $form = \yii\widgets\ActiveForm::begin() ?>
 
<?=$form->field($model,'username')->textInput() ?>
 
<?=$form->field($model,'hobby')->checkboxList(['1'=>'篮球','2'=>'足球','3'=>'游戏','4'=>'读书'])?>
 
 
<?=\yii\helpers\Html::submitButton('保存',['class'=>'btn btn-primary'])?>
 
<?php \yii\widgets\ActiveForm::end()?>

模型部分

public function beforeSave($insert) {
    if($this->hobby) {
        $this->hobby = implode(',',$this->hobby);
 
    }
    return parent::beforeSave($insert); // TODO: Change the autogenerated stub
}
 
public function afterFind() {
    $this->hobby = explode(',',$this->hobby);
    parent::afterFind();
}
yii2.0 的 多选框实现方法

第一种:
ActiveForm::checkboxList();
 优点:可以将全部数据生成多选框,自带验证

$form->field($model, 'username')->checkboxList(ArrayHelper::map($data,'id', 'customer_name'));
第二种:
ActiveForm::checkbox();
 优点:只生成一个多选框,自带验证

$form->field($model, 'username')->checkbox(ArrayHelper::map($data,'id', 'customer_name'));
第三种:
Html::activeCheckbox();

Html::activeCheckbox($model, 'username', ArrayHelper::map($data,'id', 'customer_name'));
第四种:
Html::activeCheckboxList();

Html::activeCheckboxList($model, 'username', ArrayHelper::map($data,'id', 'customer_name'));

实现多选题评分

多选题的给分原则是多选错选不得分,部分选对得部分分

$q_answer = 'A,B,C'; //正确答案

$s_answer = 'A,D';  //学生答案
$q_answer = explode(',',$q_answer);
$s_answer = explode(',',$s_answer);

$count = count($q_answer);

$score = 6;

if(count(array_diff($s_answer,$q_answer)) > 0)
{
      $real_score = 0;
}
else
{
      $real_score = $score * count(array_intersect($q_answer,$s_answer)) / $count;
}
echo $real_score;

运行结果为:0

在线latex编辑器

下面是网上看到的Latex在线编辑器:

1.吴文中公式编辑器:https://latex.91maths.com/s/?JTVDb3ZlcnJpZ2h0YXJyb3clN0JBQiU3RA==

2.LaTeX公式编辑器:https://www.latexlive.com/home##

3.Equation Editor for online mathematics:https://editor.codecogs.com/

4.HotMath:http://www.hostmath.com/Default.aspx