import { UserListComponent } from './UserListComponent' ; import { Share } from "./share" ; import { UserManager } from './UserManager' ; /**
 * Discussion (students that can ask questions, make comments)
 * The message appears at the bottom of the page
 */ export class Discussion { /**
     * generate an ID for a message
     */ static generateID ( ) { return "d" + Math . random ( ) ; } /**
     * initialization
     */ static init ( ) { document . getElementById ( "questions" ) . hidden = true ; } description static askQuestion ( ) { let question = prompt ( "Type your question/comment:" ) ; if ( question == null ) return ; question = question . trim ( ) ; if ( question == "" ) return ; Share . execute ( "questionAdd" , [ UserManager . me . userID , Discussion . generateID ( ) , question ] ) ; } param questionID descrption static removeQuestion ( questionID ) { document . getElementById ( questionID ) . remove ( ) ; if ( document . getElementById ( "questions" ) . children . length == 0 ) document . getElementById ( "questions" ) . hidden = true ; } param userID param idquestion param question description static addQuestion ( userID , idquestion , question ) { const questionElement = document . createElement ( "div" ) ; questionElement . classList . add ( "question" ) ; questionElement . id = idquestion ; questionElement . innerHTML = UserListComponent . getUserImage ( userID ) . outerHTML + question ; questionElement . onclick = ( ) => { if ( UserManager . me . canWrite ) { Share . execute ( "questionRemove" , [ questionElement . id ] ) ; } } ; document . getElementById ( "questions" ) . appendChild ( questionElement ) ; document . getElementById ( "questions" ) . hidden = false ; } }