Beispiel #1
0
         }
     }
 }
 echo '<br /><br /><div id="function-title">' . $usr->userName . " (" . $usr->fullName . ") course: " . $course->fullname . "</div>";
 unset($checker);
 echo '<div id="function-description">' . $summary . '</div>';
 //---------------------?????????? ? ??????---------------------------//
 $data = array();
 $data['wordcount'] = wordcount($summary_s);
 $data['worduniquecount'] = worduniquecount($summary_s);
 $data['numberofsentences'] = numberofsentences($summary_s);
 if ($data['numberofsentences'] == 0 || empty($data['numberofsentences'])) {
     $data['numberofsentences'] = 1;
 }
 $data['averagepersentence'] = averagepersentence($summary_s, $data['wordcount'], $data['numberofsentences']);
 list($data['hardwords'], $data['hardwordspersent']) = hardwords($summary_s, $data['wordcount']);
 $data['lexicaldensity'] = lexicaldensity($summary_s, $data['wordcount'], $data['worduniquecount']);
 $data['fogindex'] = fogindex($summary_s, $data['averagepersentence'], $data['hardwordspersent']);
 $data['laters'] = laters($summary_s);
 echo '<p><span class="function-bold">Text analysis:</span></p>';
 echo '<div id="function-example"><table cellspacing="20"><tr><td valign="top">';
 echo '<table width="300"><tr>';
 echo '<td align="right">Total Word Count: </td><td> <b>' . $data['wordcount'] . '</b></td></tr><tr>';
 echo '<td align="right">Total Unique Words: </td><td> <b>' . $data['worduniquecount'] . '</b></td></tr><tr>';
 echo '<td align="right">Number of Sentences: </td><td> <b>' . $data['numberofsentences'] . '</b></td></tr><tr>';
 echo '<td align="right">Average Words per Sentence: </td><td> <b>' . $data['averagepersentence'] . '</b></td></tr><tr>';
 echo '<td align="right">Hard Words: </td><td> <b>' . $data['hardwords'] . '</b> (' . $data['hardwordspersent'] . '%)' . '</td></tr><tr>';
 echo '<td align="right">Lexical Density: </td><td> <b>' . $data['lexicaldensity'] . '</b>%' . '</td></tr><tr>';
 echo '<td align="right">Fog Index: </td><td> <b>' . $data['fogindex'] . '</b></td>';
 echo '</tr></table>';
 echo '</td><td valign="top">';
Beispiel #2
0
                        $forums = get_records("forum_posts", "userid", $student->id);
                        $text = "";
                        foreach ($forums as $forum) {
                            $forum->message = strip_tags($forum->message);
                            $text .= $forum->message;
                        }
                        $userdata = get_record("user", "id", $student->id);
                        $data = array();
                        $data['wordcount'] = wordcount($text);
                        $data['worduniquecount'] = worduniquecount($text);
                        $data['numberofsentences'] = numberofsentences($text);
                        if ($data['numberofsentences'] == 0 || empty($data['numberofsentences'])) {
                            $data['numberofsentences'] = 1;
                        }
                        $data['averagepersentence'] = averagepersentence($text, $data['wordcount'], $data['numberofsentences']);
                        list($data['hardwords'], $data['hardwordspersent']) = hardwords($text, $data['wordcount']);
                        $data['lexicaldensity'] = lexicaldensity($text, $data['wordcount'], $data['worduniquecount']);
                        $data['fogindex'] = fogindex($text, $data['averagepersentence'], $data['hardwordspersent']);
                        $data['laters'] = laters($text);
                        $contents .= $userdata->username . ' (' . fullname($userdata) . '),' . ',' . $course->fullname . ',' . $data['wordcount'] . ',' . $data['worduniquecount'] . ',' . $data['numberofsentences'] . ',' . $data['averagepersentence'] . ',' . $data['hardwords'] . ',' . $data['lexicaldensity'] . ',' . $data['fogindex'] . "\r\n";
                    }
                }
            }
        }
    }
}
header("Content-type: application/octet-stream");
header('Content-Disposition: inline; filename=text_content_analysis_tool.csv');
echo $contents;
function wordcount($text)
{