frappe / lms

Easy to Use, 100% Open Source Learning Management System
https://frappe.io/learning
GNU Affero General Public License v3.0
1.04k stars 473 forks source link

Not able to add lesson in timetable of the batch #842

Open abhi-146 opened 5 months ago

abhi-146 commented 5 months ago

Steps to reproduce:

  1. Create a batch
  2. Create a lesson
  3. Try to add lesson in the timetable of the batch
Screenshot 2024-05-27 at 4 22 33 PM Screenshot 2024-05-27 at 4 22 05 PM

App Versions

{
    "erpnext": "15.23.0",
    "frappe": "15.26.0",
    "lms": "1.0.0"
}

Route

Form/LMS Batch/CLS-00011

Traceback

Traceback (most recent call last):
  File "apps/frappe/frappe/app.py", line 110, in application
    response = frappe.api.handle(request)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/api/__init__.py", line 49, in handle
    data = endpoint(**arguments)
           ^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/api/v1.py", line 36, in handle_rpc_call
    return frappe.handler.handle()
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/handler.py", line 49, in handle
    data = execute_cmd(cmd)
           ^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/handler.py", line 85, in execute_cmd
    return frappe.call(method, **frappe.form_dict)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/__init__.py", line 1768, in call
    return fn(*args, **newargs)
           ^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/utils/typing_validations.py", line 31, in wrapper
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/desk/form/save.py", line 39, in savedocs
    doc.save()
  File "apps/frappe/frappe/model/document.py", line 337, in save
    return self._save(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/model/document.py", line 373, in _save
    self.run_before_save_methods()
  File "apps/frappe/frappe/model/document.py", line 1091, in run_before_save_methods
    self.run_method("validate")
  File "apps/frappe/frappe/model/document.py", line 962, in run_method
    out = Document.hook(fn)(self, *args, **kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/model/document.py", line 1322, in composer
    return composed(self, method, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/model/document.py", line 1304, in runner
    add_to_return_value(self, fn(self, *args, **kwargs))
                              ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/model/document.py", line 959, in fn
    return method_object(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/lms/lms/lms/doctype/lms_batch/lms_batch.py", line 35, in validate
    self.validate_timetable()
  File "apps/lms/lms/lms/doctype/lms_batch/lms_batch.py", line 159, in validate_timetable
    if schedule.date < self.start_date or schedule.date > self.end_date:
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: '<' not supported between instances of 'NoneType' and 'str'

Request Data

{
    "type": "POST",
    "args": {
        "doc": "{\"name\":\"CLS-00011\",\"owner\":\"Administrator\",\"creation\":\"2024-05-27 15:02:23.116868\",\"modified\":\"2024-05-27 15:34:55.383226\",\"modified_by\":\"Administrator\",\"docstatus\":0,\"idx\":0,\"title\":\"Nestorbird May\",\"start_date\":\"2024-05-01\",\"end_date\":\"2024-05-31\",\"start_time\":\"10:00:00\",\"end_time\":\"19:00:00\",\"published\":1,\"allow_self_enrollment\":0,\"medium\":\"Offline\",\"seat_count\":10,\"evaluation_end_date\":\"2024-05-31\",\"description\":\"Nestorbird May 2024 Interns\",\"batch_details\":\"<div class=\\\"ql-editor read-mode\\\"><p>Third batch of interns:</p><ol><li data-list=\\\"ordered\\\"><span class=\\\"ql-ui\\\" contenteditable=\\\"false\\\"></span>Rehan</li><li data-list=\\\"ordered\\\"><span class=\\\"ql-ui\\\" contenteditable=\\\"false\\\"></span>Zayn</li></ol></div>\",\"timetable_template\":\"\",\"show_live_class\":1,\"allow_future\":0,\"paid_batch\":0,\"amount\":0,\"currency\":\"INR\",\"amount_usd\":0,\"doctype\":\"LMS Batch\",\"timetable_legends\":[],\"assessment\":[{\"name\":\"mg19bc0sfj\",\"owner\":\"Administrator\",\"creation\":\"2024-05-27 15:02:23.116868\",\"modified\":\"2024-05-27 15:34:55.383226\",\"modified_by\":\"Administrator\",\"docstatus\":0,\"idx\":1,\"assessment_type\":\"LMS Quiz\",\"assessment_name\":\"python-quiz\",\"parent\":\"CLS-00011\",\"parentfield\":\"assessment\",\"parenttype\":\"LMS Batch\",\"doctype\":\"LMS Assessment\"}],\"timetable\":[{\"docstatus\":0,\"doctype\":\"LMS Batch Timetable\",\"name\":\"new-lms-batch-timetable-pyknwvnruw\",\"__islocal\":1,\"__unsaved\":1,\"owner\":\"Administrator\",\"parent\":\"CLS-00011\",\"parentfield\":\"timetable\",\"parenttype\":\"LMS Batch\",\"idx\":1,\"__unedited\":false,\"reference_doctype\":\"Course Lesson\",\"reference_docname\":\"0005 DataTypes\",\"start_time\":\"10:00:00\",\"end_time\":\"11:00:00\"}],\"students\":[{\"name\":\"mfs79f5rgk\",\"owner\":\"Administrator\",\"creation\":\"2024-05-27 15:02:23.116868\",\"modified\":\"2024-05-27 15:34:55.383226\",\"modified_by\":\"Administrator\",\"docstatus\":0,\"idx\":1,\"student\":\"rehan@yopmail.com\",\"student_name\":\"Rehan\",\"username\":\"rehan\",\"confirmation_email_sent\":1,\"parent\":\"CLS-00011\",\"parentfield\":\"students\",\"parenttype\":\"LMS Batch\",\"doctype\":\"Batch Student\"},{\"docstatus\":0,\"doctype\":\"Batch Student\",\"name\":\"n2u9pt0bdr\",\"__unsaved\":1,\"owner\":\"Administrator\",\"confirmation_email_sent\":1,\"parent\":\"CLS-00011\",\"parentfield\":\"students\",\"parenttype\":\"LMS Batch\",\"idx\":2,\"student_name\":\"Shaan \",\"username\":\"shaan_\",\"student\":\"shaan@yopmail.com\",\"creation\":\"2024-05-27 15:02:23.116868\",\"modified\":\"2024-05-27 15:34:55.383226\",\"modified_by\":\"Administrator\"},{\"docstatus\":0,\"doctype\":\"Batch Student\",\"name\":\"n2u9v16e4p\",\"__unsaved\":1,\"owner\":\"Administrator\",\"confirmation_email_sent\":1,\"parent\":\"CLS-00011\",\"parentfield\":\"students\",\"parenttype\":\"LMS Batch\",\"idx\":3,\"student_name\":\"Zayn\",\"username\":\"zayn\",\"student\":\"zayn@yopmail.com\",\"creation\":\"2024-05-27 15:02:23.116868\",\"modified\":\"2024-05-27 15:34:55.383226\",\"modified_by\":\"Administrator\"}],\"courses\":[{\"name\":2,\"owner\":\"Administrator\",\"creation\":\"2024-05-27 15:02:23.116868\",\"modified\":\"2024-05-27 15:34:55.383226\",\"modified_by\":\"Administrator\",\"docstatus\":0,\"idx\":1,\"course\":\"frappe\",\"title\":\"Frappe\",\"parent\":\"CLS-00011\",\"parentfield\":\"courses\",\"parenttype\":\"LMS Batch\",\"doctype\":\"Batch Course\"}],\"__unsaved\":1}",
        "action": "Save"
    },
    "btn": {
        "jQuery370061454331697587361": {
            "events": {
                "click": [
                    {
                        "type": "click",
                        "origType": "click",
                        "guid": 4439,
                        "namespace": ""
                    }
                ]
            }
        }
    },
    "freeze": true,
    "headers": {},
    "error_handlers": {},
    "url": "/api/method/frappe.desk.form.save.savedocs",
    "request_id": null
}

Response Data

{
    "exception": "TypeError: '<' not supported between instances of 'NoneType' and 'str'",
    "exc_type": "TypeError",
    "_exc_source": "lms (app)"
}
abhi-146 commented 5 months ago

File: lms_batch.py

Line: 159

if schedule.date < self.start_date or schedule.date > self.end_date:

No option to select the date. schedule.date is none

Solution: Date option should be checked by default in timetable child table

Vaibhav-tech22 commented 4 months ago

If this is still open, assign it to me. I will handle it