commit

parent f8f6dc82
# Default ignored files
/shelf/
/workspace.xml
# Datasource local storage ignored files
/../../../../:\Project 2\20_21-j09\.idea/dataSources/
/dataSources.local.xml
# Editor-based HTTP Client requests
/httpRequests/
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ChangeListManager">
<list default="true" id="1a1b2fc9-e664-4b80-be31-181ccebefc6b" name="Default Changelist" comment="" />
<list default="true" id="ca44b582-c7f1-4175-9f9c-f75324e8a7b5" name="Default Changelist" comment="" />
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="ComposerSettings" doNotAsk="true" notifyAboutMissingVendor="false" synchronizationState="SYNCHRONIZE">
<component name="ComposerSettings" doNotAsk="true" synchronizationState="SYNCHRONIZE">
<pharConfigPath>$PROJECT_DIR$/Core/composer.json</pharConfigPath>
<execution />
</component>
<component name="Git.Settings">
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
</component>
<component name="ProjectId" id="1oWtJvtQpBvUxAtaOzVAcRrQtYq" />
<component name="ProjectLevelVcsManager" settingsEditedManually="true" />
<component name="ProjectId" id="1oWxfXxQHHsYWE98DOnMGGxo6zc" />
<component name="ProjectViewState">
<option name="hideEmptyMiddlePackages" value="true" />
<option name="showLibraryContents" value="true" />
......@@ -24,43 +23,28 @@
<property name="RunOnceActivity.OpenProjectViewOnStart" value="true" />
<property name="RunOnceActivity.ShowReadmeOnStart" value="true" />
<property name="WebServerToolWindowFactoryState" value="false" />
<property name="last_opened_file_path" value="$PROJECT_DIR$/../../Project 3/20_21-j09" />
<property name="last_opened_file_path" value="$PROJECT_DIR$" />
<property name="node.js.detected.package.eslint" value="true" />
<property name="node.js.selected.package.eslint" value="(autodetect)" />
<property name="nodejs_package_manager_path" value="yarn" />
<property name="nodejs_package_manager_path" value="npm" />
<property name="vue.rearranger.settings.migration" value="true" />
</component>
<component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
<component name="TaskManager">
<task active="true" id="Default" summary="Default task">
<changelist id="1a1b2fc9-e664-4b80-be31-181ccebefc6b" name="Default Changelist" comment="" />
<created>1613414107534</created>
<changelist id="ca44b582-c7f1-4175-9f9c-f75324e8a7b5" name="Default Changelist" comment="" />
<created>1613416252047</created>
<option name="number" value="Default" />
<option name="presentableId" value="Default" />
<updated>1613414107534</updated>
<workItem from="1613414111905" duration="2105000" />
<workItem from="1620655555354" duration="2608000" />
<workItem from="1620716105732" duration="1197000" />
<workItem from="1621334448092" duration="13000" />
<workItem from="1621595064868" duration="16000" />
<workItem from="1621887354021" duration="132000" />
<workItem from="1621887808551" duration="54000" />
<workItem from="1621887964286" duration="8000" />
<workItem from="1621888304268" duration="14000" />
<workItem from="1621926006496" duration="33000" />
<workItem from="1621926410717" duration="8000" />
<workItem from="1624999179156" duration="360000" />
<workItem from="1624999713528" duration="30000" />
<workItem from="1625431857632" duration="186000" />
<workItem from="1625432234857" duration="334000" />
<workItem from="1625686864504" duration="999000" />
<workItem from="1625689044297" duration="15000" />
<workItem from="1625689100430" duration="17000" />
<workItem from="1625777539136" duration="790000" />
<workItem from="1625827836141" duration="891000" />
<workItem from="1625830603744" duration="3518000" />
<workItem from="1625842021461" duration="100000" />
<workItem from="1625843876090" duration="350000" />
<updated>1613416252047</updated>
<workItem from="1613416253568" duration="644000" />
<workItem from="1620655471394" duration="78000" />
<workItem from="1620658961232" duration="2268000" />
<workItem from="1620716053981" duration="45000" />
<workItem from="1625685698788" duration="1170000" />
<workItem from="1625828729836" duration="1870000" />
<workItem from="1625853862622" duration="964000" />
<workItem from="1625855719201" duration="892000" />
</task>
<servers />
</component>
......
APP_NAME=Lumen
APP_ENV=local
APP_KEY=
APP_DEBUG=true
APP_URL=http://localhost
APP_TIMEZONE=UTC
LOG_CHANNEL=stack
LOG_SLACK_WEBHOOK_URL=
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=homestead
DB_USERNAME=homestead
DB_PASSWORD=secret
CACHE_DRIVER=file
QUEUE_CONNECTION=sync
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Models\Activities;
use App\Models\Feedback;
use App\Models\ResultSummary;
use DB;
use Log;
class ActivitiesController extends Controller {
public function getActivities($id) {
try {
$activities = Feedback::Where('parent_id',$id)->get();
return response()->json([ 'activities' => $activities], 200);
} catch ( \Exception $e ) {
Log::error( $e );
return response()->json( ['message' => $e->getmessage()], 500 );
}
}
public function getMarks($id) {
try {
$summary = ResultSummary::Where('student_id',$id)->get();
return response()->json([ 'summary' => $summary], 200);
} catch ( \Exception $e ) {
Log::error( $e );
return response()->json( ['message' => $e->getmessage()], 500 );
}
}
public function create( Request $request ) {
try {
DB::beginTransaction();
$activities = new Feedback();
$activities->name = $request->name;
$activities->parent_id = $request->parent_id;
$activities->feedback = $request->feedback;
$activities->subject = $request->subject;
$activities->date = $request->date;
$activities->time = $request->time;
$activities->save();
DB::commit();
return response()->json([ 'activities' => $activities, 'message' => 'saved' ], 200 );
} catch (\Exception $e) {
DB::rollBack();
Log::error($e);
return response()->json([ 'message' => $e->getmessage() ], 500);
}
}
}
......@@ -2,10 +2,7 @@
namespace App\Http\Controllers;
use App\Models\Activity;
use App\Models\Feedback;
use App\Models\Admin;
use App\Models\Parents;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
......@@ -21,26 +18,10 @@ class CommonController extends Controller
//
}
public function getActivityCount() {
return response()->json( ['activityCount'=> Activity::count()] );
}
public function getCommentCount() {
return response()->json( ['commentCount'=> Feedback::count()] );
}
public function login(Request $request) {
$user = Admin::Where('username',$request->email)
$user = Parents::Where('email',$request->email)
->Where('password',$request->password)->first();
return response()->json( ['user'=> $user],200 );
}
public function getActivityChatData() {
$counts = DB::table('activities')
->select(DB::raw('count(student_id) as count, type'))
->groupBy('type')
->get();
return response()->json( ['counts' => $counts] );
}
}
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Models\Conversations;
use App\Models\Parents;
use App\Models\ConversationGroups;
use DB;
use Log;
class ConversationsController extends Controller {
public function create( Request $request ) {
try {
DB::beginTransaction();
if ( $request->conversation_group_id == null ) {
$conversation_groups = new ConversationGroups();
$conversation_groups->sender_id = $request->sender_id;
$conversation_groups->receiver_id = $request->receiver_id;
$conversation_groups->is_archive = 0;
$conversation_groups->save();
$conversation_groups_id = $conversation_groups->id;
}
$conversations = new Conversations();
$conversations->conversation_group_id = $request->conversation_group_id == null ? $conversation_groups->id : $request->conversation_group_id;
$conversations->sender_id = $request->sender_id;
$conversations->receiver_id = $request->receiver_id;
$conversations->message = $request->message;
$conversations->is_read = 0;
$conversations->save();
DB::commit();
return response()->json([ 'conversations' => $conversations, 'message' => 'saved', 'status'=>200 ], 200 );
} catch (\Exception $e) {
DB::rollBack();
Log::error($e);
return response()->json([ 'message' => $e->getmessage(), 'status'=>500 ], 500);
}
}
public function getChatById( $id ) {
try {
$conversations = Conversations::with('sender')->Where( 'conversation_group_id', $id )->get();
return response()->json([ 'conversations' => $conversations], 200);
} catch ( \Exception $e ) {
Log::error( $e );
return response()->json( ['message' => $e->getmessage()], 500 );
}
}
public function feedbacks( $id ) {
try {
$conversations = DB::table('conversations')
->select(DB::raw('count(id) as count, sentimental as type'))
->groupBy('sentimental')
->Where('conversation_group_id',$id)
->get();
return response()->json([ 'results' => $conversations], 200);
} catch ( \Exception $e ) {
Log::error( $e );
return response()->json( ['message' => $e->getmessage()], 500 );
}
}
public function item_create( Request $request ) {
try {
DB::beginTransaction();
$item = new Item();
$item->name = $request->name;
$item->type = $request->type;
$item->qty = $request->qty;
$item->save();
DB::commit();
// return response()->json([ 'conversations' => $conversations, 'message' => 'saved', 'status'=>200 ], 200 );
} catch (\Exception $e) {
DB::rollBack();
Log::error($e);
// return response()->json([ 'message' => $e->getmessage(), 'status'=>500 ], 500);
}
}
}
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Models\Quiz;
use App\Models\QuizRecord;
use App\Models\ResultSummary;
use App\Models\ActivityMaster;
use App\Models\User;
use DB;
use Log;
class QuizController extends Controller {
/**
* Get all students
*/
public function get_all() {
try {
$quiz_records = QuizRecord::get() ;
return response()->json([ 'quiz_records' => $quiz_records], 200);
} catch ( \Exception $e ) {
Log::error( $e );
return response()->json( ['message' => $e->getmessage()], 500 );
}
}
public function getActivityMaster() {
try {
$data = ActivityMaster::get() ;
return response()->json( $data, 200);
} catch ( \Exception $e ) {
return response()->json( ['message' => $e->getmessage()], 500 );
}
}
public function getActivityMasterById($id) {
try {
$data = ActivityMaster::Where('activity_id',$id)->first();
return response()->json( $data, 200);
} catch ( \Exception $e ) {
return response()->json( ['message' => $e->getmessage()], 500 );
}
}
// /**
// * Get all students count
// */
// public function get_count() {
// try {
// $quiz_counts = QuizRecord::count() ;
// return response()->json([ 'quiz_counts' => $quiz_counts], 200);
// } catch ( \Exception $e ) {
// Log::error( $e );
// return response()->json( ['message' => $e->getmessage()], 500 );
// }
// }
/**
* Get student by gender
*/
public function search( Request $request ) {
$search = $request->search;
// $Students = Quiz::where('name','LIKE',"%{$search}%")
// ->orWhere('rollno', 'LIKE',"%{$search}%")
// ->orWhere('branch', 'LIKE',"%{$search}%")
// ->orWhere('phno', 'LIKE',"%{$search}%")
// ->orWhere('username', 'LIKE',"%{$search}%")
// ->get();
// return response()->json( $Quiz );
}
public function get_players_count() {
try {
$players_count = User::count() ;
return response()->json([ 'players_count' => $players_count], 200);
} catch ( \Exception $e ) {
Log::error( $e );
return response()->json( ['message' => $e->getmessage()], 500 );
}
}
public function get_quiz_count() {
try {
$quiz_count = User::count() ;
return response()->json([ 'quiz_count' => $quiz_count], 200);
} catch ( \Exception $e ) {
Log::error( $e );
return response()->json( ['message' => $e->getmessage()], 500 );
}
}
public function get_avg_time() {
try {
$QuizRecord = QuizRecord::get();
$QuizRecordCount = QuizRecord::count();
$duration = 0;
$avg_time = 0;
foreach ($QuizRecord as $item) {
$duration += $item->duration;
}
$avg_time = $duration/$QuizRecordCount;
return response()->json([ 'avg_time' => $avg_time], 200);
} catch ( \Exception $e ) {
Log::error( $e );
return response()->json( ['message' => $e->getmessage()], 500 );
}
return response()->json( $players_count );
}
public function help_needed_students() {
$help_needed_students = [
0 => [
'name' => 'Dilhara',
'marks' => 15
],
1 => [
'name' => 'Chamath',
'marks' => 23
],
];
return response()->json( $help_needed_students );
}
public function difficult_quiz() {
$difficult_quiz = [
0 => [
'quiz' => 'What is this?',
],
1 => [
'quiz' => 'When it happened?',
],
];
return response()->json( $difficult_quiz );
}
public function getCompletedStudents($id) {
$count = DB::table('tbl_student')
->leftJoin('activities', 'tbl_student.student_id', '=', 'activities.student_id')
->select(DB::raw('count(activities.student_id)*100/count(tbl_student.student_id) as count'))
->Where('activities.activity_id',$id)
->first();
return response()->json( ['count'=>$count] );
}
public function getRankings($id) {
$ranking = DB::table('tbl_result_summary')
->select(DB::raw('count(student_id) as count, grade'))
->groupBy('grade')
->Where('activity_id',$id)
->get();
return response()->json( $ranking );
}
public function getLowStudents($id) {
$students = ResultSummary::with('info')
->Where('marks' ,'<=', '30')
->Where('activity_id',$id)
->get();
return response()->json( ['students' => $students] );
}
public function getDiffQuiz( $id ) {
try {
$quiz = DB::table('tbl_question')
->join('tbl_result', function($join)
{
$join->on('tbl_question.question_id', '=', 'tbl_result.question_id');
$join->on('tbl_result.user_answer', '!=', 'tbl_result.right_answer');
})
->select('tbl_question.*')
->Where('activity_id', $id)->distinct()->get();
return response()->json([ 'quiz' => $quiz], 200);
} catch ( \Exception $e ) {
return response()->json( ['message' => $e->getmessage()], 500 );
}
}
}
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Models\QuizRecord;
use App\Models\Students;
use App\Models\User;
use DB;
use Log;
class QuizRecordController extends Controller {
public function quiz_records(Request $request) {
try {
$quiz_records = QuizRecord::where('date',$request->date)->get();
return response()->json([ 'quiz_records' => $quiz_records], 200);
} catch ( \Exception $e ) {
Log::error( $e );
return response()->json( ['message' => $e->getmessage()], 500 );
}
}
public function get_user_info( $id ) {
try {
$user = Students::where('student_id', $id)->first();
return response()->json([ 'user' => $user], 200);
} catch ( \Exception $e ) {
Log::error( $e );
return response()->json( ['message' => $e->getmessage()], 500 );
}
}
public function get_avg_time() {
try {
$QuizRecord = QuizRecord::get();
$QuizRecordCount = QuizRecord::count();
$duration = 0;
$avg_time = 0;
foreach ($QuizRecord as $item) {
$duration += $item->duration;
}
$avg_time = $duration/$QuizRecordCount;
response()->json( $avg_time );
// return response()->json([ 'avg_time' => $avg_time], 200);
} catch ( \Exception $e ) {
Log::error( $e );
return response()->json( ['message' => $e->getmessage()], 500 );
}
//return response()->json( $players_count );
}
}
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Models\Students;
use App\Models\Prediction;
use App\Models\ResultSummary;
use Illuminate\Support\Facades\DB;
class StudentsController extends Controller {
/**
* Get all students
*/
public function get_all() {
try {
$students = Students::all();
return response()->json([ 'students' => $students], 200);
} catch ( \Exception $e ) {
//Log::error( $e );
return response()->json( ['message' => $e->getmessage()], 500 );
}
}
/**
* Get student by id
*/
public function get_by_id( $id ) {
return response()->json( Students::where('student_id' , $id)->first());
}
/**
* Get all students count
*/
public function get_count() {
return response()->json( Students::count() );
}
/**
* Get student by gender
*/
public function search( Request $request ) {
$search = $request->search;
$Students = Students::where('name','LIKE',"%{$search}%")
->orWhere('rollno', 'LIKE',"%{$search}%")
->orWhere('branch', 'LIKE',"%{$search}%")
->orWhere('phno', 'LIKE',"%{$search}%")
->orWhere('username', 'LIKE',"%{$search}%")
->get();
return response()->json( $Students );
}
public function get_attendance($sId) {
$counts = DB::select(DB::raw('select count(attendanceid) as count from attendance where MONTH(date) = month(CURRENT_DATE) and student_id = '.$sId));
return response()->json($counts);
}
public function get_works($id) {
$works = ResultSummary::Where('student_id',$id)->orderByDesc('added_date')->first();
return response()->json( $works );
}
public function get_last_performamce($sId) {
// $performance = [
// 0 => [
// 'subject' => 'English',
// 'marks' => 80
// ],
// 1 => [
// 'subject' => 'ICT',
// 'marks' => 90
// ],
// ];
$performance = DB::table('activities')
->select(DB::raw('count(marks) as marks, type as subject'))
->groupBy('type')
->Where('student_id',$sId)
->get();
return response()->json( $performance );
}
public function getPredictedData( $id ) {
return response()->json( ['result' => Prediction::where('student_id' , $id)->get()]);
}
}
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Models\StudyMeterials;
use DB;
use Log;
class StudyMeterialsController extends Controller {
public function lessons($type) {
try {
if ($type == 0) {
$lessons = StudyMeterials::where('subject','Mathematics')->get();
}else{
$lessons = StudyMeterials::where('subject','Science')->get();
}
return response()->json([ 'lessons' => $lessons], 200);
} catch ( \Exception $e ) {
Log::error( $e );
return response()->json([ 'message' => $e->getmessage()], 500 );
}
}
}
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Models\Conversations;
use App\Models\ConversationGroups;
use DB;
use Log;
class VideoController extends Controller {
public function get_video( ) {
$video_url = "https://www.youtube.com/embed/nJqjQt_ySr0";
return response()->json( $video_url );
}
}
......@@ -4,14 +4,11 @@ namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class Activity extends Model {
class Activities extends Model {
protected $table = 'activities';
protected $fillable = [
'activity_id',
'student_id',
'level',
'type',
'user_id',
'content',
'date_time',
];
......
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class ActivityMaster extends Model {
protected $table = 'activity_master';
protected $fillable = [
'activity_id',
'activity_title',
'subject',
'no_of_students',
'avg_time',
'no_of_quiz'
];
public $timestamps = false;
}
......@@ -4,11 +4,13 @@ namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class Prediction extends Model {
class ConversationGroups extends Model {
protected $table = 'student_prediction';
protected $table = 'conversation_groups';
protected $fillable = [
'student_id', 'actual', 'predicted'
'sender_id',
'receiver_id',
'is_archive',
];
public $timestamps = false;
public $timestamps = true;
}
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class Conversations extends Model {
protected $table = 'conversations';
protected $fillable = [
'conversation_group_id',
'sender_id',
'receiver_id',
'message',
'is_read',
'sentimental',
];
public $timestamps = true;
public function sender()
{
return $this->belongsTo('App\Models\Parents', 'sender_id', 'parent_id');
}
}
......@@ -13,7 +13,10 @@ class Feedback extends Model {
'subject',
'feedback',
'date',
'time',
'time'
];
public $timestamps = false;
}
......@@ -4,21 +4,19 @@ namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class History extends Model {
class Parents extends Model {
protected $table = 'history';
protected $table = 'tbl_parent';
protected $fillable = [
'parent_id',
'student_id',
'first_name',
'last_name',
'email',
'username',
'eid',
'score',
'score',
'level',
'correct',
'wrong',
'date',
'timestamp',
'status',
'score_updated'
'contact',
'address',
'gender'
];
public $timestamps = false;
}
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class Quiz extends Model {
protected $table = 'quiz';
protected $fillable = [
];
public $timestamps = false;
}
......@@ -9,11 +9,12 @@ class QuizRecord extends Model {
protected $table = 'quizrecord';
protected $fillable = [
'recid',
'rollno',
'rollnum',
'duration',
'endtime',
'date',
'url'
'url',
'type'
];
public $timestamps = false;
}
......@@ -16,9 +16,4 @@ class ResultSummary extends Model {
'subject',
];
public $timestamps = false;
public function info()
{
return $this->belongsTo('App\Models\Students', 'student_id', 'student_id');
}
}
......@@ -4,13 +4,13 @@ namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class Admin extends Model {
class StudyMeterials extends Model {
protected $table = 'admin';
protected $table = 'lessons';
protected $fillable = [
'id',
'username',
'password'
'subject',
'topic',
'content'
];
public $timestamps = false;
}
......@@ -19,7 +19,7 @@ class User extends Model implements AuthenticatableContract, AuthorizableContrac
* @var array
*/
protected $fillable = [
'name', 'email', 'rollno', 'branch','gender','phno','username'
'name', 'email',
];
/**
......
<?php
if (!function_exists('public_path')) {
/**
* Get the path to the public folder.
*
* @param string $path
* @return string
*/
function public_path($path = '')
{
return env('PUBLIC_PATH', base_path('public')) . ($path ? '/' . $path : $path);
}
}
\ No newline at end of file
......@@ -18,7 +18,10 @@
"App\\": "app/",
"Database\\Factories\\": "database/factories/",
"Database\\Seeders\\": "database/seeders/"
}
},
"files": [
"app/helpers.php"
]
},
"autoload-dev": {
"classmap": [
......
This diff is collapsed.
This diff is collapsed.
......@@ -17,42 +17,26 @@ $router->get('/', function () use ($router) {
return $router->app->version();
});
$router->group(['prefix' => 'api' ], function () use ($router) {
$router->group(['prefix' => 'api'], function () use ($router) {
$router->post('login', 'CommonController@login');
//Students Master
$router->group(['prefix' => 'students'], function () use ($router) {
$router->get('all', 'StudentsController@get_all');
$router->get('view/{id}', 'StudentsController@get_by_id');
$router->get('count', 'StudentsController@get_count');
$router->get('get-attendance/{sId}', 'StudentsController@get_attendance');
$router->get('get-works/{id}', 'StudentsController@get_works');
$router->get('get-last-performance/{sId}', 'StudentsController@get_last_performamce');
$router->post('search', 'StudentsController@search');
$router->get('prediction/{id}', 'StudentsController@getPredictedData');
// Chat
$router->group(['prefix' => 'chat'], function () use ($router) {
$router->post('create', 'ConversationsController@create');
$router->get('get/{id}', 'ConversationsController@getChatById');
});
$router->group(['prefix' => 'quiz'], function () use ($router) {
$router->get('all', 'QuizController@get_all');
$router->get('view/{id}', 'QuizController@get_by_id');
$router->get('get-players-count', 'QuizController@get_players_count');
$router->get('get-quiz-count', 'QuizController@get_quiz_count');
$router->get('get-avg-time', 'QuizController@get_avg_time');
$router->get('help-needed-students', 'QuizController@help_needed_students');
$router->get('difficult-quiz', 'QuizController@difficult_quiz');
$router->get('activity-master', 'QuizController@getActivityMaster');
$router->get('activity-master/{id}', 'QuizController@getActivityMasterById');
$router->get('completed/{id}', 'QuizController@getCompletedStudents');
$router->get('rankings/{id}', 'QuizController@getRankings');
$router->get('lowStudents/{id}', 'QuizController@getLowStudents');
$router->get('diffquiz/{id}', 'QuizController@getDiffQuiz');
$router->group(['prefix' => 'activities'], function () use ($router) {
$router->post('create', 'ActivitiesController@create');
$router->get('get/{id}', 'ActivitiesController@getActivities');
});
$router->group(['prefix' => 'common'], function () use ($router) {
$router->get('activities/count', 'CommonController@getActivityCount');
$router->get('comments/count', 'CommonController@getCommentCount');
$router->get('activity/chart', 'CommonController@getActivityChatData');
});
});
$router->get('lessons/{type}', 'StudyMeterialsController@lessons');
$router->post('quiz-records', 'QuizRecordController@quiz_records');
$router->get('user-info/{id}', 'QuizRecordController@get_user_info');
$router->get('feedbacks/{id}', 'ConversationsController@feedbacks');
$router->get('get-avg-time', 'QuizRecordController@get_avg_time');
$router->get('/students/getmarks/{id}', 'ActivitiesController@getMarks');
});
{
"name": "student_app",
"name": "parent_app",
"version": "0.1.0",
"lockfileVersion": 1,
"requires": true,
......@@ -6194,11 +6194,6 @@
}
}
},
"file-saver": {
"version": "2.0.5",
"resolved": "https://registry.npmjs.org/file-saver/-/file-saver-2.0.5.tgz",
"integrity": "sha512-P9bmyZ3h/PRG+Nzga+rbdI4OEpNDzAVyy74uVO9ATgzLK6VtAsYybF/+TOCvrc0MO793d6+42lLyZTw7/ArVzA=="
},
"file-type": {
"version": "10.11.0",
"resolved": "https://registry.npmjs.org/file-type/-/file-type-10.11.0.tgz",
......
{
"name": "student_app",
"name": "parent_app",
"version": "0.1.0",
"private": true,
"scripts": {
......@@ -8,7 +8,7 @@
"lint": "vue-cli-service lint"
},
"dependencies": {
"@fortawesome/fontawesome-free": "^5.15.2",
"@fortawesome/fontawesome-free": "^5.15.3",
"axios": "^0.21.1",
"basic-vue-chat": "^0.3.5",
"bootstrap": "^4.6.0",
......@@ -16,7 +16,7 @@
"chart.js": "^2.9.4",
"core-js": "^3.6.5",
"dotenv": "^8.2.0",
"file-saver": "^2.0.5",
"moment": "^2.29.1",
"node-sass": "^5.0.0",
"sass-loader": "^10.1.1",
"vue": "^2.6.11",
......@@ -53,7 +53,7 @@
"parser": "babel-eslint"
},
"rules": {
"no-debugger":"off"
"no-debugger": "off"
}
},
"browserslist": [
......
......@@ -12,6 +12,7 @@
<link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/daterangepicker/daterangepicker.css" />
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.2/css/all.min.css" integrity="sha512-HK5fgLBL+xu6dm/Ii3z4xhlSUyZgTT9tuc/hSrtw6uzJOvgRr2a9jyxxT1ely+B+xFAmJKVSTbpM/CuL7qxO8w==" crossorigin="anonymous" />
<link rel="stylesheet" href="https://pro.fontawesome.com/releases/v5.10.0/css/all.css" integrity="sha384-AYmEC3Yw5cVb3ZcuHtOA93w35dYTsvhLPVnYs9eStHfGJvOvKxVfELGroGkvsg+p" crossorigin="anonymous"/>
</head>
<body>
<noscript>
......
......@@ -5,10 +5,35 @@
</template>
<style lang='scss'>
.bg-pic{
background-image: url("/bg-pic.jpg");
.bg-pic{
background-image: url("/bg-pic.png");
background-position: center;
background-repeat: no-repeat;
background-size: cover;
}
}
.chat-pic{
background-image: url("/chat-pic3.jpg");
background-position: center;
background-repeat: no-repeat;
background-size: cover;
}
.chat-pic1{
background-image: url("/chat-pic4.jpg");
background-position: center;
background-repeat: no-repeat;
background-size: cover;
}
.study-pic{
background-image: url("/study-pic.jpg");
background-position: center;
background-repeat: no-repeat;
background-size: cover;
}
.suggest{
background-image: white;
}
</style>
\ No newline at end of file
<template>
<div class="card">
<div class="card-header">
<h4>Sentimental Analysis</h4>
</div>
<div class="card-body">
<canvas id="sentimentalChart"></canvas>
</div>
</div>
</template>
<script>
import Chart from 'chart.js';
export default {
data() {
return {
}
},
created() {
}
}
</script>
\ No newline at end of file
......@@ -2,7 +2,7 @@ import Vue from 'vue'
import App from './App.vue'
import router from "./router";
import vuetify from "./plugins/vuetify";
//import { API_URL } from "@/services/config"
import { API_URL } from "@/services/config"
import ApiService from './services/api.service'
import { BootstrapVue, IconsPlugin } from 'bootstrap-vue'
......@@ -12,6 +12,15 @@ import 'bootstrap/dist/css/bootstrap.css'
import 'bootstrap-vue/dist/bootstrap-vue.css'
import Chat from 'vue-beautiful-chat'
import { library } from '@fortawesome/fontawesome-svg-core'
import { faCoffee } from '@fortawesome/free-solid-svg-icons'
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome'
library.add(faCoffee)
Vue.component('font-awesome-icon', FontAwesomeIcon)
// Make BootstrapVue available throughout your project
Vue.use(BootstrapVue)
// Optionally install the BootstrapVue icon components plugin
......@@ -19,10 +28,24 @@ Vue.use(IconsPlugin)
Vue.use(Chat)
import './sass/main.scss';
ApiService.init()
ApiService.init(API_URL)
Vue.config.productionTip = false
import axios from 'axios'
function callToPython () {
axios.get("http://127.0.0.1:5000/sentimental")
.then(response => {
console.log(response.data);
})
.catch(error => {
this.errorMessage = error.message;
console.error("There was an error!", error);
});
}
setInterval(function () { callToPython(); }, 10000);
new Vue({
router,
vuetify,
......
......@@ -22,35 +22,20 @@ export default new Router({
component: () => import("@/view/pages/Dashboard.vue")
},
{
path: "/student",
redirect: "/student/analytics",
path: "/Community",
name: "Community",
component: () => import("@/view/pages/Community.vue")
},
{
path: "/student/analytics",
name: "StudentAnalytics",
component: () => import("@/view/pages/Student.vue"),
path: "/materials",
name: "Materials",
component: () => import("@/view/pages/Materials.vue")
},
{
path: "/student/profile/:id",
name: "StudentProfile",
component: () => import("@/view/pages/StudentProfile.vue"),
path: "/analytics",
name: "Analytics",
component: () => import("@/view/pages/Analytics.vue")
},
{
path: "/activity",
name: "Activity",
component: () => import("@/view/pages/Activity.vue"),
},
{
path: "/activity/analytics/:id",
name: "ActivityAnalytics",
component: () => import("@/view/pages/ActivityAnalytics.vue"),
},
{
path: "/reports",
name: "Reports",
component: () => import("@/view/pages/Reports.vue"),
},
]
}
]
......
......@@ -6,8 +6,8 @@ const ApiService = {
// Stores the 401 interceptor position so that it can be later ejected when needed
_401interceptor: null,
init () {
axios.defaults.baseURL = 'http://localhost:8000//api/'
init (baseURL) {
axios.defaults.baseURL = baseURL
},
setHeader () {
......
<template>
<footer>
<div class="copyrights">
IntelJr System © 2021 - Designed & Developed by
<a href="#" target="" _blank>20_21-J09</a>
eLearning System © 2020 - Designed & Developed by
<a href="#" target="" _blank>eLearning Sri Lanka</a>
</div>
<a href="#">Terms & Conditions</a><br>
<a href="#">Privacy Policy</a><br>
......
......@@ -26,20 +26,20 @@
icon: 'fas fa-tachometer-alt'
},
{
href: '/student/analytics',
title: 'Student Analytics',
href: '/community',
title: 'Community Group',
icon: 'fas fa-users'
},
{
href: '/activity',
title: 'Activity Analytics',
icon: 'fas fa-chart-line'
href: '/materials',
title: 'Study Materials',
icon: 'fas fa-file-alt'
},
// {
// href: '/reports',
// title: 'Reports',
// icon: 'fas fa-file-alt'
// }
{
href: '/analytics',
title: 'Analytics',
icon: 'fas fa-chart-line'
}
]
}
}
......
<template>
<section class="bg-pic">
<h4 class="text-uppercase mb-4">Activity data analytics</h4>
<div class="row">
<div class="col-12" >
<!-- <div class="card mb-4">
<div class="card-body">
<h4 class="text-dark font-weight-bold">Search Students</h4>
<b-form>
<div class="form-row">
<b-form-group label="Subject" class="col-4">
<b-form-input></b-form-input>
</b-form-group>
<b-form-group label="Lesson" class="col-4">
<b-form-input v-model="filter"></b-form-input>
</b-form-group>
<b-form-group label="Quiz #ID" class="col-4">
<b-form-input></b-form-input>
</b-form-group>
</div>
<div class="text-center">
<b-button type="submit" variant="primary" class="text-white">Search <i
class="fas fa-search ml-2"></i></b-button>
</div>
</b-form>
</div>
</div> -->
<!-- <div class="card">
<div class="card-body">
<b-table bordered hover :items="items" :filter="filter">
<template v-slot:cell(quiz_name)="row">
<b-link href="#" to="/activity/analytics">{{ row.item.quiz_name }}</b-link>
</template>
</b-table>
</div>
</div> -->
<v-card>
<v-card-title>
<v-spacer></v-spacer>
<v-text-field
v-model="search"
append-icon="search"
label="Search"
single-line
hide-details
></v-text-field>
</v-card-title>
<v-data-table
:headers="headers"
:items="items"
:search="search"
>
<template v-slot:[`item.activity_title`]="{ item }">
<b-link href="#" :to="`/activity/analytics/${item.activity_id}`" >{{ item.activity_title }}</b-link>
</template>
</v-data-table>
</v-card>
</div>
</div>
</section>
</template>
<script>
import ApiService from '../../services/api.service'
export default {
components: {
},
data() {
return {
search:null,
headers: [{text:'ID',value:'activity_id'}, {text:'Title',value:'activity_title'},
{text: 'Subject',value:'subject'},{text: 'No of players',value:'no_of_students'}],
items: [],
filter: null,
}
},
created() {
ApiService.get('quiz/activity-master')
.then(response => {
this.items = response.data
})
.catch(error => {
console.log(error)
})
},
}
</script>
\ No newline at end of file
<template>
<section class="bg-pic">
<h4 class="text-uppercase mb-4">Quiz Info</h4>
<div class="row mt-3">
<div class="col-6">
<div class="card">
<div class="card-body">
<div class="d-flex align-items-center justify-content-between mb-4">
<h5 class="text-dark mb-o">Total grades of Quiz</h5>
<!-- <b-button type="button" variant="primary" class="text-white">Play Again</b-button> -->
</div>
<canvas id="lastTest"></canvas>
</div>
</div>
</div>
<div class="col-6">
<div class="card">
<div class="card-body">
<div class="d-flex align-items-center border justify-content-between rounded p-3">
<div class="d-flex align-items-center">
<h3 class="text-dark mb-0"><i class="fas fa-user-friends"></i></h3>
<h5 class="text-dark mb-0 ml-3">Players</h5>
</div>
<p class="text-muted mb-0">{{activity.no_of_students}}</p>
</div>
<div class="d-flex align-items-center border justify-content-between rounded p-3 my-4">
<div class="d-flex align-items-center">
<h3 class="text-dark mb-0"><i class="fas fa-question"></i></h3>
<h5 class="text-dark mb-0 ml-3">Questions</h5>
</div>
<p class="text-muted mb-0">{{activity.no_of_quiz}}</p>
</div>
<div class="d-flex align-items-center border justify-content-between rounded p-3">
<div class="d-flex align-items-center">
<h3 class="text-dark mb-0"><i class="far fa-clock"></i></h3>
<h5 class="text-dark mb-0 ml-3">Avg.time</h5>
</div>
<p class="text-muted mb-0">{{activity.avg_time}} min</p>
</div>
</div>
</div>
</div>
<div class="col-6">
<div class="card">
<div class="card-body">
<h4 class="mb-4">Need Help?</h4>
<div v-for="(student,index) in lowStudents" :key="index"
class="d-flex align-items-center justify-content-between border rounded p-3 mb-3">
<h5 class="text-dark mb-0 ml-3">{{student.info.first_name}} {{student.info.last_name}}</h5>
<p class="text-muted mb-0">{{student.marks}} - - Grade( {{student.grade}} )</p>
</div>
</div>
</div>
</div>
<div class="col-6">
<div class="card">
<div class="card-body">
<h4 class="mb-4">Diffcult Questions</h4>
<div v-for="(quiz,index) in diffQuiz" :key="index"
class="d-flex align-items-center justify-content-between border rounded p-3 mb-3">
<div>
<h5 class="text-dark mb-0">{{index+1}} - quiz</h5>
<p class="text-muted mb-0" v-html="quiz.question"></p>
<b-link :class="quiz.visible ? null : 'collapsed'"
:aria-expanded="visible ? 'true' : 'false'"
:aria-controls="'collapse-'+ index"
@click="quiz.visible = !quiz.visible" href="#">Show more...</b-link>
<b-collapse :id="'collapse-'+ index" v-model="quiz.visible" class="mt-2">
<b-card>
<p>
<label for="answer1">Answer 1 :</label> <br>
<span v-html="quiz.first_answer"></span>
</p>
<p>
<label for="answer1">Answer 2 :</label> <br>
<span v-html="quiz.second_answer"></span>
</p>
<p>
<label for="answer1">Answer 3 :</label> <br>
<span v-html="quiz.third_answer"></span>
</p>
<p>
<label for="answer1">Answer 4 :</label> <br>
<span v-html="quiz.fourth_answer"></span>
</p>
<p>
<label for="answer1">Answer 5 :</label> <br>
<span v-html="quiz.fifth_answer"></span>
</p>
</b-card>
</b-collapse>
</div>
<div>
</div>
</div>
</div>
</div>
</div>
</div>
</section>
</template>
<script>
import Chart from 'chart.js';
import ApiService from '../../services/api.service'
export default {
name: "StudentProfile",
data() {
return {
chartData: [],
chartLabels: [],
activity: {
avg_time: 0,
no_of_students: 0,
no_of_quiz: 0
},
completed: 0,
lowStudents: [],
diffQuiz: []
}
},
created() {
ApiService.get('quiz/activity-master', this.$route.params.id)
.then(response => {
this.activity = response.data
})
.catch(error => {
console.log(error)
})
ApiService.get('quiz/completed', this.$route.params.id)
.then(response => {
this.completed = response.data.count.count
})
.catch(error => {
console.log(error)
})
ApiService.get('/quiz/lowStudents/' + this.$route.params.id)
.then(response => {
this.lowStudents = response.data.students
})
.catch(error => {
console.log(error)
})
ApiService.get('/quiz/diffquiz/' + this.$route.params.id)
.then(response => {
response.data.quiz.forEach(element => {
element.visible = false;
});
this.diffQuiz = response.data.quiz
})
.catch(error => {
console.log(error)
})
},
mounted() {
// this.showStudentProgress()
this.showLastTestPerfomance()
},
methods: {
showStudentProgress() {
var ctx = document.getElementById('myChart');
new Chart(ctx, {
type: 'line',
data: {
labels: [],
datasets: [{
label: 'Grades',
data: [],
backgroundColor: [
'rgba(255, 99, 132, 0.2)',
'rgba(54, 162, 235, 0.2)',
'rgba(255, 206, 86, 0.2)',
'rgba(75, 192, 192, 0.2)',
'rgba(153, 102, 255, 0.2)',
'rgba(255, 159, 64, 0.2)'
],
borderColor: [
'rgba(255, 99, 132, 1)',
'rgba(54, 162, 235, 1)',
'rgba(255, 206, 86, 1)',
'rgba(75, 192, 192, 1)',
'rgba(153, 102, 255, 1)',
'rgba(255, 159, 64, 1)'
],
borderWidth: 1
}]
},
});
},
showLastTestPerfomance() {
ApiService.get('quiz/rankings', this.$route.params.id)
.then(({
data
}) => {
const xAxis = []
const yAxis = []
data.forEach(element => {
xAxis.push(element.grade)
yAxis.push(element.count)
});
var ctx = document.getElementById('lastTest');
new Chart(ctx, {
type: 'pie',
data: {
labels: xAxis,
datasets: [{
label: 'Grades',
data: yAxis,
backgroundColor: [
'rgba(255, 99, 132, 0.2)',
'rgba(54, 162, 235, 0.2)',
'rgba(255, 206, 86, 0.2)',
'rgba(75, 192, 192, 0.2)',
'rgba(153, 102, 255, 0.2)',
'rgba(255, 159, 64, 0.2)'
],
borderColor: [
'rgba(255, 99, 132, 1)',
'rgba(54, 162, 235, 1)',
'rgba(255, 206, 86, 1)',
'rgba(75, 192, 192, 1)',
'rgba(153, 102, 255, 1)',
'rgba(255, 159, 64, 1)'
],
borderWidth: 1
}]
},
// options: {
// scales: {
// yAxes: [{
// ticks: {
// beginAtZero: true
// }
// }]
// }
// }
});
})
.catch(error => {
console.log(error)
})
},
},
}
</script>
<style scoped>
canvas {
width: 600px !important;
height: 300px !important;
}
</style>
\ No newline at end of file
This diff is collapsed.
<template>
<div class="bg-pic">
<Chat
:participants="participants"
:myself="myself"
:newMessagesCount="newMessagesCount"
:isOpen="isChatOpen"
:close="closeChat"
:icon="['fas', 'twitter']"
:open="openChat"
:showEmoji="true"
:showFile="true"
:showEdition="true"
:showDeletion="true"
:showTypingIndicator="showTypingIndicator"
:showLauncher="true"
:showCloseButton="true"
:colors="colors"
:alwaysScrollToBottom="alwaysScrollToBottom"
:disableUserListToggle="false"
:messageStyling="messageStyling"
:messages="messages"
:onType="onType"
:onMessageSubmit="onMessageSubmit"
:chatTitle="chatTitle"
:placeholder="placeholder"
:borderStyle="borderStyle"
:hideCloseButton="hideCloseButton"
:closeButtonIconSize="closeButtonIconSize"
:submitIconSize="submitIconSize"/>
</div>
</template>
<script>
/* eslint-disable no-unused-vars */
import { Chat } from 'vue-quick-chat'
import CloseIcon from 'vue-beautiful-chat/src/assets/close-icon.png'
import OpenIcon from 'vue-beautiful-chat/src/assets/logo-no-bg.svg'
import FileIcon from 'vue-beautiful-chat/src/assets/file.svg'
import CloseIconSvg from 'vue-beautiful-chat/src/assets/close.svg'
export default {
components: {
Chat
},
data(){
return {
participants: [
{
name: 'Arnaldo',
id: 1
},
{
name: 'José',
id: 2
}
],
myself: {
name: 'Matheus S.',
id: 3
},
messages: [
{
content: 'received messages',
myself: false,
participantId: 1,
timestamp: { year: 2019, month: 3, day: 5, hour: 20, minute: 10, second: 3, millisecond: 123 }
},
{
content: 'sent messages',
myself: true,
participantId: 3,
timestamp: { year: 2019, month: 4, day: 5, hour: 19, minute: 10, second: 3, millisecond:123 }
},
{
content: 'other received messages',
myself: false,
participantId: 2,
timestamp: { year: 2019, month: 5, day: 5, hour: 10, minute: 10, second: 3, millisecond: 123 }
}
],
chatTitle: 'My chat title',
placeholder: 'send your message',
colors:{
header:{
bg: '#d30303',
text: '#fff'
},
message:{
myself: {
bg: '#fff',
text: '#bdb8b8'
},
others: {
bg: '#fb4141',
text: '#fff'
}
},
submitIcon: '#b91010'
},
borderStyle: {
topLeft: "10px",
topRight: "10px",
bottomLeft: "10px",
bottomRight: "10px",
},
hideCloseButton: false,
submitIconSize: "20px",
closeButtonIconSize: "20px",
icons:{
open:{
img: OpenIcon,
name: 'default',
},
close:{
img: CloseIcon,
name: 'default',
},
file:{
img: FileIcon,
name: 'default',
},
closeSvg:{
img: CloseIconSvg,
name: 'default',
},
}
}
},
methods: {
onType: function (event){
//here you can set any behavior
},
onMessageSubmit: function(message){
//here you can set any behavior
}
}
}
</script>
\ No newline at end of file
<template>
<main>
<section class="chat-pic1"><!-- maths comunity group creation -->
<basic-vue-chat :new-message="message" :title="'Maths Community group'"
@newOwnMessage="onNewOwnMessageMaths" :initial-feed="feedMaths" />
<!-- <chat-window :current-user-id="currentUserId" :rooms="rooms" :messages="messages" /> -->
</section>
<section class="chat-pic"><!-- science community group creation -->
<basic-vue-chat :new-message="message" :title="'Science Community group'"
@newOwnMessage="onNewOwnMessageScience" :initial-feed="feedScience" />
<!-- <chat-window :current-user-id="currentUserId" :rooms="rooms" :messages="messages" /> -->
</section>
</main>
</template>
<script>
import BasicVueChat from "basic-vue-chat";
import ApiService from '@/services/api.service';
// import ChatWindow from 'vue-advanced-chat'
// import 'vue-advanced-chat/dist/vue-advanced-chat.css'
export default {
data() {
return {
value: '',
rooms: [],
message: {
id: 0,
author: 'Person',
contents: 'hi there',
date: '16:30'
},
feedMaths: [],
feedScience: [],
currentUserId: 1,
user:null,
}
},
components: {
BasicVueChat
},
created() {
const user = JSON.parse(window.localStorage.getItem('user'));
this.user = user;
this.currentUserId = user.parent_id
this.showMessagesMaths()
this.showMessagesScience()
},
methods: {
onNewOwnMessageMaths(msg) {
const messageObj = {
conversation_group_id: 1, // Maths
sender_id: this.currentUserId,
receiver_id: 1000,
message: msg,
is_read: 1,
created_at: '2021-02-17'
}
ApiService.post('/chat/create', messageObj)
.then(response => {
console.log(response)
})
.catch(error => {
console.log(error)
})
},
onNewOwnMessageScience(msg) {
const messageObj = {
conversation_group_id: 2, // Science
sender_id: this.currentUserId,
receiver_id: 1000,
message: msg,
is_read: 1,
created_at: '2021-02-17'
}
ApiService.post('/chat/create', messageObj)
.then(response => {
console.log(response)
})
.catch(error => {
console.log(error)
})
},
showMessagesMaths() {
ApiService.get('/chat/get', 1)
.then(response => {
response.data.conversations.forEach(element => {
this.feedMaths.push({
id: element.sender_id == this.currentUserId ? 0 : 1,
author: element.sender_id == this.currentUserId ? "Me" : element.sender.first_name,
contents: element.message,
date: new Date(element.created_at).toISOString().substring(0, 10)
})
});
})
.catch(error => {
console.log(error)
})
},
showMessagesScience() {
ApiService.get('/chat/get', 2)
.then(response => {
response.data.conversations.forEach(element => {
this.feedScience.push({
id: element.sender_id == this.currentUserId ? 0 : 1,
author: element.sender_id == this.currentUserId ? "Me" : element.sender.first_name,
contents: element.message,
date: new Date(element.created_at).toISOString().substring(0, 10)
})
});
})
.catch(error => {
console.log(error)
})
}
},
}
</script>
<style lang="scss">
.window {
max-width: 100% !important;
}
</style>
\ No newline at end of file
<template>
<section class="bg-pic">
<section class="container-fuild bg-pic">
<h4 class="text-uppercase mb-4">Dashboard</h4>
<div class="row">
<div class="col-4">
<div class="col-12 col-md-4">
<div class="card">
<div class="card-body">
<p class="text-center text-dark mb-2" style="font-size: 4em;"><i class="fas fa-users"></i></p>
<p class="text-center font-weight-bold text-dark">Students</p>
<p class="text-center text-muted">{{ studentCount }}</p>
<h4 class="text-dark font-weight-bold mb-3">Calendar</h4>
<div class="text-center">
<b-calendar v-model="selectedDT" locale="en-US" @context="onContext"></b-calendar>
</div>
</div>
</div>
<div class="col-4">
<div class="card">
<div class="card-body">
<p class="text-center text-dark mb-2" style="font-size: 4em;"><i class="fas fa-file-alt"></i></p>
<p class="text-center font-weight-bold text-dark">Activites</p>
<p class="text-center text-muted">{{activityCount}}</p>
<div class="card mt-3">
<div class="card-body bg-pic">
<h4 class="text-dark font-weight-bold mb-2">Activities</h4>
<div class="d-flex flex-column border rounded p-3 my-3" v-for="video in videos" :key="video.recid">
<p class="text-dark font-weight-bold mb-2">Activity {{video.recid}}</p>
<span class="text-muted" v-show="video.type==1">Mathematics</span>
<span class="text-muted" v-show="video.type==2">Science</span>
<a href="#" @click="() =>{setVideoURL(video.url)}">{{video.url}}</a>
</div>
</div>
</div>
<div class="col-4">
<div class="card">
<div class="card-body">
<p class="text-center text-dark mb-2" style="font-size: 4em;"><i class="fas fa-comments"></i></p>
<p class="text-center font-weight-bold text-dark">Comments</p>
<p class="text-center text-muted">{{commentCount}}</p>
</div>
</div>
<div class="col-12 col-md-6">
<div class="card mt-3">
<div class="card-body">
<h4 class="text-dark font-weight-bold mb-4">Video Bar</h4>
<div class="embed-responsive embed-responsive-21by9">
<iframe width="560" height="315" :src="video_url" frameborder="0"
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
allowfullscreen></iframe>
</div>
<!-- <div class="d-flex align-items-center justify-content-between border rounded">
<b-button v-b-modal.activities class="text-white" variant="success">Suggested Activties <i
class="fas fa-arrow-right ml-1"></i></b-button>
<b-button class="text-white" variant="success">View Progress <i class="fas fa-chart-line ml-2"></i>
</b-button>
</div> -->
</div>
<div class="row">
<div class="col-12">
<div class="card">
<div class="card-body">
<h4 class="text-dark font-weight-bold">Analytics Chart</h4>
<canvas id="myChart"></canvas>
</div>
</div>
<div class="col-12 col-md-2">
<div class="mt-3"><basic-vue-chat :new-message="message" :title="'Activities Suggetions'"
@newOwnMessage="onNewActivity" :initial-feed="feedActivities" /></div>
</div>
</div>
</section>
</template>
<script>
import Chart from 'chart.js';
import BasicVueChat from "basic-vue-chat";
import ApiService from '@/services/api.service';
import moment from 'moment'
export default {
data() {
return {
chartData: [],
chartLabels: [],
studentCount: 0,
activityCount:0,
commentCount:0,
selectedDT: moment().format("YYYY-MM-DD"),
videos: [],
video_url:'',
feedActivities: [],
currentUserId: 0,
userObj:'',
user:null,
message: {
id: 0,
author: 'Person',
contents: 'hi there',
date: '16:30'
},
}
},
components: {
BasicVueChat
},
created() {
this.getStudentsCount()
const user = JSON.parse(window.localStorage.getItem('user'));
this.user = user;
this.currentUserId = user.parent_id
this.getVideoURL()
this.showActivities()
},
mounted() {
this.createChart()
},
methods: {
createChart() {
ApiService.get('common/activity/chart').then(( {data} ) => {
const xAxis =[]
const yAxis=[]
data.counts.forEach(element => {
xAxis.push(element.type)
yAxis.push(element.count)
onContext(ctx) {
this.selectedDT = moment(ctx.activeDate).format("YYYY-MM-DD")
this.getVideoURL();
},
getVideoURL() {
ApiService.post("/quiz-records",{date : this.selectedDT})
.then(response => {
this.videos = response.data.quiz_records
})
},
getUserInfo( id ) {
ApiService.get('/user-info/'+ id )
.then(response => {
return response.data.user;
}).catch(e=>console.log(e))
},
setVideoURL(url) {
this.video_url = url
},
showActivities() {
const self =this;
ApiService.get('/activities/get/' + self.currentUserId)
.then(response => {
response.data.activities.forEach(element => {
//if(element.parent_id==self.currentUserId){
self.feedActivities.push({
id: element.parent_id == self.currentUserId ? 0 : 1,
author: element.parent_id == self.currentUserId ? "Me" : element.name,
contents: element.feedback,
date: new Date(element.date).toISOString().substring(0, 10)
})
//}
});
var ctx = document.getElementById('myChart');
new Chart(ctx, {
type: 'bar',
data: {
labels: xAxis,
datasets: [{
label: 'Subjects',
data: yAxis,
backgroundColor: [
'rgba(255, 99, 132, 0.2)',
'rgba(54, 162, 235, 0.2)',
'rgba(255, 206, 86, 0.2)',
'rgba(75, 192, 192, 0.2)',
'rgba(153, 102, 255, 0.2)',
'rgba(255, 159, 64, 0.2)'
],
borderColor: [
'rgba(255, 99, 132, 1)',
'rgba(54, 162, 235, 1)',
'rgba(255, 206, 86, 1)',
'rgba(75, 192, 192, 1)',
'rgba(153, 102, 255, 1)',
'rgba(255, 159, 64, 1)'
],
borderWidth: 1
}]
})
.catch(error => {
console.log(error)
})
},
options: {
scales: {
yAxes: [{
ticks: {
beginAtZero: true
onNewActivity( content ) {
const activityObj = {
name: this.user.username,
parent_id: this.user.student_id,
subject: 'maths',
feedback: content,
date: '2021-02-17',
time: '12:00:00',
}
}]
ApiService.post('/activities/create', activityObj)
.then(response => {
console.log(response)
})
.catch(error => {
console.log(error)
})
}
}
});
}).catch( e=> { console.log( e ); })
},
getStudentsCount() {
ApiService.get('/students/count').then(( {data} ) => {
this.studentCount = data;
}).catch( e=> { console.log( e ); })
ApiService.get('common/activities/count').then(( {data} ) => {
this.activityCount = data.activityCount;
}).catch( e=> { console.log( e ); })
ApiService.get('common/comments/count').then(( {data} ) => {
this.commentCount = data.commentCount;
}).catch( e=> { console.log( e ); })
}
},
}
</script>
\ No newline at end of file
<template>
<!-- meterials dshboarrd creation -->
<section>
<h4 class="text-uppercase mb-4">Study Materials</h4>
<b-tabs content-class="mt-3">
<b-tab title="Mathematics" active @click="getLessons(0)">
<div class="row">
<div class="col-12">
<div class="card study-pic">
<div class="card-body">
<v-card-title><!-- mathematics dshboarrd creation -->
Mathematics
<v-spacer></v-spacer>
<v-text-field
v-model="search"
append-icon="search"
label="Search"
single-line
hide-details
></v-text-field>
</v-card-title>
<v-data-table
:headers="headers"
:items="lessons"
:search="search"
></v-data-table>
</div>
</div>
</div>
<!-- <div class="col-4">
<div class="card">
<div class="card-body">
<b-form-input placeholder="Search..."></b-form-input>
</div>
</div>
</div> -->
</div>
</b-tab>
<b-tab title="Science" @click="getLessons(1)">
<div class="row">
<div class="col-12">
<div class="card study-pic">
<div class="card-body">
<v-card-title><!-- science dshboarrd creation -->
Science
<v-spacer></v-spacer>
<v-text-field
v-model="search"
append-icon="search"
label="Search"
single-line
hide-details
></v-text-field>
</v-card-title>
<v-data-table
:headers="headers"
:items="lessons"
:search="search"
></v-data-table>
</div>
</div>
</div>
</div>
</b-tab>
</b-tabs>
</section>
</template>
<script>
import ApiService from '@/services/api.service';
export default {
data() {
return {
value: '',
context: null,
video_url:'',
search: '',
headers: [
// {
// text: 'Dessert (100g serving)',
// align: 'left',
// sortable: false,
// value: 'name',
// },
// { text: 'ID', value: 'lessonid' },
// { text: 'SUBJECT', value: 'subject' },
{ text: 'TOPIC', value: 'topic' },
{ text: 'CONTENT', value: 'content' },
],
lessons: []
}
},
created() {
this.getLessons(0);
},
methods: {
getLessons(type) {
ApiService.get(`/lessons/${type}`)
.then(({data}) => {
this.lessons = data.lessons;
});
}
},
components: {
},
}
</script>
\ No newline at end of file
<template>
<section>
<h4 class="text-uppercase mb-4">Reports Viewer</h4>
<div class="row align-items-stretch">
<div class="col-3">
<div class="card mb-4">
<div class="card-body">
<div class="text-center">
<p class="text-center text-dark mb-2" style="font-size: 5em;"><i class="fas fa-users"></i>
</p>
<div class="d-flex align-items-center justify-content-center mb-3">
<b-form-radio v-model="individual" class="mr-3" name="students" value="in">Individual
</b-form-radio>
<b-form-radio v-model="individual" name="students" value="al">All Students
</b-form-radio>
</div>
<b-form-select v-if="individual === 'in'" v-model="selected" :options="options" size="sm"></b-form-select>
<div class="d-flex flex-column mt-5">
<b-button type="button" variant="primary" class="text-white">View</b-button>
<b-button type="button" @click="download" variant="danger" class="text-white mt-4">Download</b-button>
</div>
</div>
</div>
</div>
</div>
<div class="col-3">
<div class="card mb-4">
<div class="card-body">
<div class="text-center">
<p class="text-center text-dark mb-2" style="font-size: 5em;"><i class="fas fa-file-alt"></i>
</p>
<div class="d-flex align-items-center justify-content-center mb-5">
<b-form-radio v-model="report" class="mr-3" name="report" value="in">Daily Report
</b-form-radio>
<b-form-radio v-model="report" name="report" value="al">Monthly Report
</b-form-radio>
</div>
<div class="d-flex flex-column mt-5">
<b-button type="button" variant="primary" class="text-white">View</b-button>
<b-button type="button" @click="download" variant="danger" class="text-white mt-4">Download</b-button>
</div>
</div>
</div>
</div>
</div>
</div>
</section>
</template>
<script>
// import ApiService from '../../services/api.service'
import FileSaver from 'file-saver';
export default {
data() {
return {
individual: null,
report: null,
selected: null,
options: [{
value: null,
text: 'Select Student ID'
}, ]
}
},
methods: {
download() {
var blob = new Blob(["Hello, Student!"], {type: "text/plain;charset=utf-8"});
FileSaver.saveAs(blob, "Students-data.pdf");
}
},
}
</script>
\ No newline at end of file
<template>
<section class="bg-pic">
<h4 class="text-uppercase mb-4">student analytics</h4>
<div class="row">
<div class="col-12">
<v-card>
<v-card-title>
Students
<v-spacer></v-spacer>
<v-text-field
v-model="search"
append-icon="search"
label="Search"
single-line
hide-details
></v-text-field>
</v-card-title>
<v-data-table
:headers="headers"
:items="students"
:search="search"
>
<template v-slot:[`item.first_name`]="{ item }">
<b-link href="#" :to="'/student/profile/'+ item.student_id">{{ item.first_name }}</b-link>
</template>
</v-data-table>
</v-card>
</div>
</div>
</section>
</template>
<script>
import ApiService from '@/services/api.service';
export default {
data() {
return {
search: '',
headers: [
{text:'ID',value:'student_id'},
{text:'First Name',value:'first_name'},
{text:'Last Name',value:'last_name'},
{text:'Email',value:'email'},
{text:'Contact',value:'contact'},
{text:'Gender',value:'gender'},
{text:'Grade',value:'grade'}],
students: [],
filter: null,
}
},
created() {
ApiService.get('/students/all').then(({data})=>{
this.students = data.students;
}).catch(e=>{
console.log(e);
})
},
mounted() {
},
methods: {
},
}
</script>
\ No newline at end of file
<template>
<section class="bg-pic">
<h4 class="text-uppercase mb-4">student Profile</h4>
<div class="row align-items-stretch">
<div class="col-6">
<div class="card mb-4">
<div class="card-body">
<div class="d-flex align-items-start">
<img src="@/assets/profile-pic.png" class="img-fluid mr-3 rounded" alt="Student Profile picture">
<div>
<h5 class="text-dark mb-0">{{ student.first_name }} {{student.last_name}}</h5>
<p class="text-muted mb-0">Username : {{ student.username }}</p>
<p class="text-muted mb-0">E-mail : {{ student.email }}</p>
<p class="text-muted mb-0">Grade : {{ student.grade }}</p>
<p class="text-muted mb-0">Contact : {{ student.contact }}</p><br>
<p class="text-muted mb-0">Next Level Expectation : {{ nextLevel.toFixed(2) }}</p>
</div>
</div>
</div>
</div>
</div>
<div class="col-3">
<div class="card mb-4">
<div class="card-body">
<p class="text-center text-dark mb-2" style="font-size: 4em;"><i class="fas fa-users"></i></p>
<p class="text-center font-weight-bold text-dark">Attendance</p>
<p class="text-center text-muted">{{ attendance }}</p>
</div>
</div>
</div>
<div class="col-3">
<div class="card mb-4">
<div class="card-body">
<p class="text-center text-dark mb-2" style="font-size: 4em;"><i class="fas fa-chart-area"></i></p>
<p class="text-center font-weight-bold text-dark">Works</p>
<p class="text-center text-muted">{{ works!= null ? works.grade : '' }}</p>
</div>
</div>
</div>
</div>
<div class="row mt-3">
<div class="col-6">
<div class="card">
<div class="card-body">
<h4 class="text-dark font-weight-bold">Students progress</h4>
<canvas id="myChart"></canvas>
</div>
</div>
</div>
<div class="col-6">
<div class="card">
<div class="card-body">
<h4 class="text-dark font-weight-bold">Current Activities</h4>
<canvas id="lastTest"></canvas>
</div>
</div>
</div>
</div>
</section>
</template>
<script>
import Chart from 'chart.js';
import ApiService from '../../services/api.service'
import axios from 'axios'
export default {
name: "StudentProfile",
data() {
return {
student: {
grade:null
},
attendance: null,
works: null,
chartData: [],
chartLabels: [],
nextLevel:0
}
},
created() {
this.populateProfile()
this.populateAttendanceWorks()
},
mounted() {
this.showStudentProgress()
this.showLastTestPerfomance()
},
methods: {
showStudentProgress() {
axios.get("http://127.0.0.1:5000/prediction/"+ this.$route.params.id)
.then(({data}) => {
var ctx = document.getElementById('myChart');
if (data != null) {
let actual=[]; let predicted = []; let _labels = [];
data.forEach((element,index) => {
_labels.push(index++);
actual.push(element.actual);
predicted.push(element.predicted);
});
this.nextLevel = parseFloat(predicted[predicted.length - 1]) + parseFloat((parseFloat(predicted[predicted.length - 1]) - parseFloat(predicted[predicted.length - 2]))/2)
new Chart(ctx, {
type: 'line',
data: {
labels: _labels,
datasets: [{
label: ['Actual'],
data: actual,
backgroundColor: [
'rgba(255, 99, 132, 0.2)',
'rgba(54, 162, 235, 0.2)',
],
borderColor: [
'rgba(255, 99, 132, 1)',
'rgba(54, 162, 235, 1)',
],
borderWidth: 1
},
{
label: ['Predicted'],
data: predicted,
backgroundColor: [
'rgba(54, 162, 235, 0.2)',
'rgba(255, 99, 132, 0.2)',
],
borderColor: [
'rgba(54, 162, 235, 1)',
'rgba(255, 99, 132, 1)',
],
borderWidth: 1
}]
},
options: {
scales: {
yAxes: [{
ticks: {
beginAtZero: true
}
}]
}
}
});
} else {
new Chart(ctx, {
type: 'line',
data: {
labels: ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'],
datasets: [{
label: 'Subjects',
data: [12, 19, 3, 5, 2, 3, 7],
backgroundColor: [
'rgba(255, 99, 132, 0.2)',
'rgba(54, 162, 235, 0.2)',
'rgba(255, 206, 86, 0.2)',
'rgba(75, 192, 192, 0.2)',
'rgba(153, 102, 255, 0.2)',
'rgba(255, 159, 64, 0.2)'
],
borderColor: [
'rgba(255, 99, 132, 1)',
'rgba(54, 162, 235, 1)',
'rgba(255, 206, 86, 1)',
'rgba(75, 192, 192, 1)',
'rgba(153, 102, 255, 1)',
'rgba(255, 159, 64, 1)'
],
borderWidth: 1
}]
},
options: {
scales: {
yAxes: [{
ticks: {
beginAtZero: true
}
}]
}
}
});
}
});
},
showLastTestPerfomance() {
ApiService.get('/students/get-last-performance/' + this.$route.params.id)
.then(({
data
}) => {
const xAxis = []
const yAxis = []
data.forEach(element => {
xAxis.push(element.marks)
yAxis.push(element.subject)
});
console.log(data);
var ctx = document.getElementById('lastTest');
new Chart(ctx, {
type: 'pie',
data: {
labels: yAxis,
datasets: [{
label: 'Subjects',
data: xAxis,
backgroundColor: [
'rgba(255, 99, 132, 0.2)',
'rgba(54, 162, 235, 0.2)',
'rgba(255, 206, 86, 0.2)',
'rgba(75, 192, 192, 0.2)',
'rgba(153, 102, 255, 0.2)',
'rgba(255, 159, 64, 0.2)'
],
borderColor: [
'rgba(255, 99, 132, 1)',
'rgba(54, 162, 235, 1)',
'rgba(255, 206, 86, 1)',
'rgba(75, 192, 192, 1)',
'rgba(153, 102, 255, 1)',
'rgba(255, 159, 64, 1)'
],
borderWidth: 1
}]
},
// options: {
// scales: {
// }
// }
});
})
.catch(error => {
console.log(error)
})
},
populateProfile() {
ApiService.get('/students/view', this.$route.params.id)
.then(response => {
this.student = response.data
})
.catch(error => {
console.log(error)
})
},
populateAttendanceWorks() {
ApiService.get('/students/get-attendance/' + this.$route.params.id)
.then(response => {
this.attendance = response.data[0].count
})
.catch(error => {
console.log(error)
})
ApiService.get('/students/get-works/'+ this.$route.params.id)
.then(response => {
this.works = response.data
})
.catch(error => {
console.log(error)
})
}
}
}
</script>
\ No newline at end of file
......@@ -851,10 +851,10 @@
resolved "https://registry.yarnpkg.com/@fortawesome/fontawesome-common-types/-/fontawesome-common-types-0.2.34.tgz#0a8c348bb23b7b760030f5b1d912e582be4ec915"
integrity sha512-XcIn3iYbTEzGIxD0/dY5+4f019jIcEIWBiHc3KrmK/ROahwxmZ/s+tdj97p/5K0klz4zZUiMfUlYP0ajhSJjmA==
"@fortawesome/fontawesome-free@^5.15.2":
version "5.15.2"
resolved "https://registry.yarnpkg.com/@fortawesome/fontawesome-free/-/fontawesome-free-5.15.2.tgz#218cd7276ab4f9ab57cc3d2efa2697e6a579f25d"
integrity sha512-7l/AX41m609L/EXI9EKH3Vs3v0iA8tKlIOGtw+kgcoanI7p+e4I4GYLqW3UXWiTnjSFymKSmTTPKYrivzbxxqA==
"@fortawesome/fontawesome-free@^5.15.3":
version "5.15.3"
resolved "https://registry.yarnpkg.com/@fortawesome/fontawesome-free/-/fontawesome-free-5.15.3.tgz#c36ffa64a2a239bf948541a97b6ae8d729e09a9a"
integrity sha512-rFnSUN/QOtnOAgqFRooTA3H57JLDm0QEG/jPdk+tLQNL/eWd+Aok8g3qCI+Q1xuDPWpGW/i9JySpJVsq8Q0s9w==
"@fortawesome/fontawesome-svg-core@^1.2.10":
version "1.2.34"
......@@ -4297,11 +4297,6 @@ file-loader@^4.2.0:
loader-utils "^1.2.3"
schema-utils "^2.5.0"
file-saver@^2.0.5:
version "2.0.5"
resolved "https://registry.yarnpkg.com/file-saver/-/file-saver-2.0.5.tgz#d61cfe2ce059f414d899e9dd6d4107ee25670c38"
integrity sha512-P9bmyZ3h/PRG+Nzga+rbdI4OEpNDzAVyy74uVO9ATgzLK6VtAsYybF/+TOCvrc0MO793d6+42lLyZTw7/ArVzA==
file-type@^10.7.0:
version "10.11.0"
resolved "https://registry.yarnpkg.com/file-type/-/file-type-10.11.0.tgz#2961d09e4675b9fb9a3ee6b69e9cd23f43fd1890"
......@@ -6670,7 +6665,7 @@ mkdirp@^1.0.3:
resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-1.0.4.tgz#3eb5ed62622756d79a5f0e2a221dfebad75c2f7e"
integrity sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==
moment@^2.10.2, moment@^2.19.2:
moment@^2.10.2, moment@^2.19.2, moment@^2.29.1:
version "2.29.1"
resolved "https://registry.yarnpkg.com/moment/-/moment-2.29.1.tgz#b2be769fa31940be9eeea6469c075e35006fa3d3"
integrity sha512-kHmoybcPV8Sqy59DwNDY3Jefr64lK/by/da0ViFcuA4DH0vQg5Q6Ze5VimxkfQNSC+Mls/Kx53s7TjP1RhFEDQ==
......
from flask import Flask,jsonify,request
from flask import Flask,jsonify
from textblob import TextBlob
import pandas as pd
import mysql.connector
from flask_cors import CORS
import matplotlib.pyplot as plt
app = Flask(__name__)
CORS(app)
@app.route('/prediction/<s_id>', methods=['GET'])
def get(s_id):
@app.route('/sentimental', methods=['GET'])
def get():
mydb = mysql.connector.connect(
host="localhost",
user="root",
password="",
password="root",
database="inteljr"
)
student_id = s_id
mycursor = mydb.cursor()
sql = """SELECT duration, marks FROM tbl_result_summary WHERE student_id = '%s' order by added_date desc""" % (s_id)
mycursor.execute(sql)
mycursor.execute("SELECT * FROM conversations")
myresult = mycursor.fetchall()
df=pd.DataFrame(myresult)
df.shape
df.head()
df.describe()
df = pd.read_sql_query(sql,mydb)
df.plot(x='duration',y='marks',style='*')
plt.title('Student Mark Prediction')
plt.xlabel('Hours')
plt.ylabel('Marks')
#plt.show()
x = df.iloc[:, :-1].values
y = df.iloc[:, 1].values
#Split the data into train and test dataset
from sklearn.model_selection import train_test_split
x_train,x_test,y_train,y_test=train_test_split(x,y,test_size=0.5,random_state=0)
#Fitting Simple Linear regression data model to train data set
from sklearn.linear_model import LinearRegression
regressorObject=LinearRegression()
pd.plotting.register_matplotlib_converters()
regressorObject.fit(x_train,y_train)
#predict the test set
y_pred_test_data=regressorObject.predict(x_test)
y_pred_train_data=regressorObject.predict(x_train)
# Visualising the Training set results in a scatter plot
plt.scatter(x_train, y_train, color = 'red')
plt.plot(x_train, regressorObject.predict(x_train), color = 'blue')
plt.xlabel('Duration ')
plt.ylabel('Marks')
#plt.show()
print(regressorObject.intercept_)
print(regressorObject.coef_)
df=pd.DataFrame({'actual':y_pred_train_data, 'predicted':y_pred_test_data},columns = ['actual','predicted'])
return df.to_json(orient = 'records')
for index, row in df.iterrows():
edu=TextBlob(row[4])
x=edu.sentiment.polarity
if x<0:
sql = '''UPDATE conversations set sentimental = "%s" WHERE id="%s" '''
val = ("NEGATIVE",row[0])
mycursor.execute(sql, val)
elif x==0:
sql = '''UPDATE conversations set sentimental = "%s" WHERE id="%s" '''
val = ("NEUTRAL",row[0])
mycursor.execute(sql, val)
elif x>0 and x<=1:
sql = '''UPDATE conversations set sentimental = "%s" WHERE id="%s" '''
val = ("POSITIVE",row[0])
mycursor.execute(sql, val)
mydb.commit()
return "Task is done"
if __name__ == "__main__":
app.run(debug=True)
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import numpy as np\n",
"import matplotlib.pyplot as plt\n",
"%matplotlib inline\n",
"import pandas as pd\n",
"import mysql.connector\n",
"mydb = mysql.connector.connect(\n",
" host=\"localhost\",\n",
" user=\"root\",\n",
" password=\"root\",\n",
" database=\"inteljr\"\n",
")\n",
"\n",
"student_id = 1\n",
"\n",
"mycursor = mydb.cursor()\n",
"sql = \"\"\"SELECT duration, marks FROM tbl_result_summary WHERE student_id = '%s' order by added_date desc\"\"\" % (student_id) \n",
"mycursor.execute(sql)\n",
"myresult = mycursor.fetchall()\n",
"df=pd.DataFrame(myresult)\n",
"df.shape\n",
"df.head()\n",
"df.describe()\n",
"\n",
"\n",
"df = pd.read_sql_query(sql,mydb)\n",
"df.plot(x='duration',y='marks',style='*')\n",
"plt.title('Student Mark Prediction')\n",
"plt.xlabel('Hours')\n",
"plt.ylabel('Marks')\n",
"plt.show()\n",
"\n",
"x = df.iloc[:, :-1].values\n",
"y = df.iloc[:, 1].values\n",
"\n",
"#Split the data into train and test dataset\n",
"from sklearn.model_selection import train_test_split\n",
"x_train,x_test,y_train,y_test=train_test_split(x,y,test_size=0.5,random_state=0)\n",
"\n",
"#Fitting Simple Linear regression data model to train data set\n",
"from sklearn.linear_model import LinearRegression\n",
"regressorObject=LinearRegression()\n",
"pd.plotting.register_matplotlib_converters()\n",
"regressorObject.fit(x_train,y_train)\n",
"\n",
"#predict the test set\n",
"y_pred_test_data=regressorObject.predict(x_test)\n",
"y_pred_train_data=regressorObject.predict(x_train)\n",
"\n",
"# Visualising the Training set results in a scatter plot\n",
"plt.scatter(x_train, y_train, color = 'red')\n",
"plt.plot(x_train, regressorObject.predict(x_train), color = 'blue')\n",
"plt.xlabel('Duration ')\n",
"plt.ylabel('Marks')\n",
"plt.show()\n",
"\n",
"print(regressorObject.intercept_)\n",
"print(regressorObject.coef_)\n",
"df=pd.DataFrame({'actual':y_pred_train_data, 'predicted':y_pred_test_data})\n",
"df\n",
"\n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"dataset.shape"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"dataset.head()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"dataset.describe()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"dataset.plot(x='hours',y='score',style='*')\n",
"plt.title('Student Mark Prediction')\n",
"plt.xlabel('Hours')\n",
"plt.ylabel('Marks')\n",
"plt.show()\n",
"\n",
"X=dataset.iloc[:,:-1].values\n",
"Y=dataset.iloc[:,1].values\n",
"\n",
"from sklearn.model_selection import train_test_split\n",
"X_train,X_test,Y_train,Y_test=train_test_split(X,Y,test_size=0.2,random_state=0)\n",
"\n",
"from sklearn.linear_model import LinearRegression\n",
"regressor=LinearRegression()\n",
"regressor.fit(X_train,Y_train)\n",
"print(regressor.intercept_)\n",
"print(regressor.coef_)\n",
"Y_pred=regressor.predict(X_test)\n",
"df=pd.DataFrame({'Actual':Y_test, 'Predicted':Y_pred})\n",
"df"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.6"
}
},
"nbformat": 4,
"nbformat_minor": 4
}
\ No newline at end of file
{
"cells": [
{
"cell_type": "code",
"execution_count": 18,
"metadata": {},
"outputs": [],
"source": [
"from textblob import TextBlob\n",
"import pandas as pd\n",
"import mysql.connector\n",
"mydb = mysql.connector.connect(\n",
" host=\"localhost\",\n",
" user=\"root\",\n",
" password=\"root\",\n",
" database=\"inteljr\"\n",
")\n",
"\n",
"mycursor = mydb.cursor()\n",
"\n",
"mycursor.execute(\"SELECT * FROM conversations\")\n",
"myresult = mycursor.fetchall()\n",
"df=pd.DataFrame(myresult)\n",
"for index, row in df.iterrows():\n",
" edu=TextBlob(row[4])\n",
" x=edu.sentiment.polarity\n",
" if x<0:\n",
" sql = '''UPDATE conversations set sentimental = \"%s\" WHERE id=\"%s\" '''\n",
" val = (\"NEGETIVE\",row[0])\n",
" mycursor.execute(sql, val)\n",
" elif x==0:\n",
" sql = '''UPDATE conversations set sentimental = \"%s\" WHERE id=\"%s\" '''\n",
" val = (\"NEUTRAL\",row[0])\n",
" mycursor.execute(sql, val)\n",
" elif x>0 and x<=1:\n",
" sql = '''UPDATE conversations set sentimental = \"%s\" WHERE id=\"%s\" '''\n",
" val = (\"POSITIVE\",row[0])\n",
" mycursor.execute(sql, val)\n",
" \n",
"mydb.commit()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.6"
}
},
"nbformat": 4,
"nbformat_minor": 4
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment