diff --git a/BUGS.md b/BUGS.md index 5b7c593..48d690f 100644 --- a/BUGS.md +++ b/BUGS.md @@ -1,13 +1,13 @@ # BUGS +- nao esta a seguir o max_tries definido no ficheiro de dependencias. +- no curso de linear algebra, as perguntas estao shuffled, mas nao deviam estar... nao esta a obedecer a keyword shuffle. +- obter rankings por curso GET course=course_id +- impedir que quando students.db não é encontrado, crie um ficheiro vazio. - classificacoes so devia mostrar os que ja fizeram alguma coisa -- menu nao mostra as opcoes correctamente -- mathjax nao esta a correr sobre o titulo e sobre as solucoes. - QFactory.generate() devia fazer run da gen_async, ou remover. -- finish topic vai para a lista de cursos. devia ficar no mesmo curso. - marking all options right in a radio question breaks! -- impedir que quando students.db não é encontrado, crie um ficheiro vazio. - opcao --prefix devia afectar a base de dados? - duplo clicks no botao "responder" dessincroniza as questões, ver debounce em https://stackoverflow.com/questions/20281546/how-to-prevent-calling-of-en-event-handler-twice-on-fast-clicks - quando termina topico devia apagar as perguntas todas (se falhar a gerar novo topico, aparecem perguntas do antigo) @@ -16,8 +16,6 @@ - permitir configuracao para escolher entre static files locais ou remotos - sqlalchemy.pool.impl.NullPool: Exception during reset or similar sqlite3.ProgrammingError: SQLite objects created in a thread can only be used in that same thread. - -- porque é que md() é usado nos templates e não directamente no codigo python? - templates question-*.html tem input hidden question_ref que não é usado. remover? - guardar o estado a meio de um nível. - safari as vezes envia dois gets no inicio do topico. nesses casos, a segunda pergunta não é actualizada no browser... o topico tem de ser gerado qd se escolhe o topico em main_topics. O get nao deve alterar o estado. @@ -50,6 +48,9 @@ sqlite3.ProgrammingError: SQLite objects created in a thread can only be used in # FIXED +- menu nao mostra as opcoes correctamente +- finish topic vai para a lista de cursos. devia ficar no mesmo curso. +- mathjax nao esta a correr sobre o titulo. - forgetting factor is hardcoded in student.py - add aprendizatons --version - se aluno abre dois tabs no browser, conseque navegar em simultaneo para perguntas diferentes. quando submete uma delas dá asneira. Tem de haver um campo hidden que tenha um céodigo único que indique qual a pergunta. do lado do servidor apnas há o codigo da pergunta corrente, se forem diferentes faz redirect para /. diff --git a/aprendizations/learnapp.py b/aprendizations/learnapp.py index 207a813..0485d7a 100644 --- a/aprendizations/learnapp.py +++ b/aprendizations/learnapp.py @@ -268,6 +268,7 @@ class LearnApp(object): student.start_course(course) except Exception as e: logger.warning(f'"{uid}" could not start course "{course}": {e}') + raise else: logger.info(f'"{uid}" started course "{course}"') @@ -452,6 +453,10 @@ class LearnApp(object): return self.online[uid]['state'].get_current_course_title() # ------------------------------------------------------------------------ + def get_student_course_id(self, uid: str) -> str: + return self.online[uid]['state'].get_current_course_id() + + # ------------------------------------------------------------------------ # def get_title(self) -> str: # # return self.deps.graph.get('title', '') # return self. @@ -471,15 +476,15 @@ class LearnApp(object): return self.courses # ------------------------------------------------------------------------ - def get_rankings(self, uid: str) -> Iterable[Tuple[str, str, float, float]]: + def get_rankings(self, uid: str, course_id: str) -> Iterable[Tuple[str, str, float, float]]: - logger.info(f'User "{uid}" get rankings') + logger.info(f'User "{uid}" get rankings for {course_id}') with self.db_session() as s: students = s.query(Student.id, Student.name).all() # topic progress student_topics = s.query(StudentTopic.student_id, - StudentTopic.topic_id, + StudentTopic.topic_id, # FIXME Filter topics of the course StudentTopic.level, StudentTopic.date).all() total_topics = s.query(Topic).count() diff --git a/aprendizations/serve.py b/aprendizations/serve.py index 8f057fe..3588ad5 100644 --- a/aprendizations/serve.py +++ b/aprendizations/serve.py @@ -48,11 +48,10 @@ class WebApplication(tornado.web.Application): (r'/change_password', ChangePasswordHandler), (r'/question', QuestionHandler), # render question (r'/rankings', RankingsHandler), # rankings table - # (r'/topics', TopicsHandler), # show list of topics (r'/topic/(.+)', TopicHandler), # start topic (r'/file/(.+)', FileHandler), # serve file (r'/courses', CoursesHandler), # show list of courses - (r'/course/(.+)', CourseHandler), # show course topics + (r'/course/(.*)', CourseHandler), # show course topics (r'/', RootHandler), # redirects ] settings = { @@ -96,12 +95,17 @@ class RankingsHandler(BaseHandler): @tornado.web.authenticated def get(self): uid = self.current_user - rankings = self.learn.get_rankings(uid) + current_course = self.learn.get_student_course_id(uid) + course_id = self.get_query_argument('course', default=current_course) + rankings = self.learn.get_rankings(uid, course_id) self.render('rankings.html', appname=APP_NAME, uid=uid, name=self.learn.get_student_name(uid), - rankings=rankings) + rankings=rankings, + course_id=course_id, + course_title=self.learn.get_student_course_title(uid), # FIXME get from course var + ) # ---------------------------------------------------------------------------- @@ -202,40 +206,25 @@ class CourseHandler(BaseHandler): @tornado.web.authenticated def get(self, course): uid = self.current_user + if course == '': + course = self.learn.get_student_course_id(uid) try: self.learn.start_course(uid, course) except KeyError: self.redirect('/courses') - # print('TITULO: ---------------->', self.learn.get_title()) self.render('maintopics-table.html', appname=APP_NAME, uid=uid, name=self.learn.get_student_name(uid), state=self.learn.get_student_state(uid), - title=self.learn.get_student_course_title(uid), + course_title=self.learn.get_student_course_title(uid), + course_id=self.learn.get_student_course_id(uid), ) # ---------------------------------------------------------------------------- -# /topics -# Shows a list of topics and proficiency (stars, locked). -# ---------------------------------------------------------------------------- -# class TopicsHandler(BaseHandler): -# @tornado.web.authenticated -# def get(self): -# uid = self.current_user -# self.render('maintopics-table.html', -# appname=APP_NAME, -# uid=uid, -# name=self.learn.get_student_name(uid), -# state=self.learn.get_student_state(uid), -# title=self.learn.get_title(), -# ) - - -# ---------------------------------------------------------------------------- # /topic/... # Start a given topic # ---------------------------------------------------------------------------- @@ -253,6 +242,8 @@ class TopicHandler(BaseHandler): appname=APP_NAME, uid=uid, name=self.learn.get_student_name(uid), + # course_title=self.learn.get_student_course_title(uid), + course_id=self.learn.get_student_course_id(uid), ) diff --git a/aprendizations/static/js/topic.js b/aprendizations/static/js/topic.js index d33ab96..8c34cec 100644 --- a/aprendizations/static/js/topic.js +++ b/aprendizations/static/js/topic.js @@ -55,7 +55,7 @@ function updateQuestion(response) { $('#submit, #comments, #solution').remove(); $("#content").html(response["params"]["question"]).animateCSS('tada'); $('#topic_progress').css('width', '100%').attr('aria-valuenow', 100); - setTimeout(function(){window.location.replace('/');}, 2000); + setTimeout(function(){window.location.replace('/course/');}, 2000); break; } } @@ -137,7 +137,7 @@ function getFeedback(response) { $("#right").hide(); $('#solution').html(params['solution']).animateCSS('flipInX'); // MathJax.Hub.Queue(["Typeset", MathJax.Hub, "#solution"]); - MathJax.typeset(); + MathJax.typeset(); }); break; diff --git a/aprendizations/student.py b/aprendizations/student.py index e672e4e..c098755 100644 --- a/aprendizations/student.py +++ b/aprendizations/student.py @@ -232,6 +232,10 @@ class StudentState(object): return self.courses[self.current_course]['title'] # ------------------------------------------------------------------------ + def get_current_course_id(self) -> Optional[str]: + return self.current_course + + # ------------------------------------------------------------------------ def is_locked(self, topic: str) -> bool: return topic not in self.state diff --git a/aprendizations/templates/courses.html b/aprendizations/templates/courses.html index ee704ca..bd4d1e0 100644 --- a/aprendizations/templates/courses.html +++ b/aprendizations/templates/courses.html @@ -33,16 +33,16 @@